Changeset 113d7cf in advance-wars for src/com/medievaltech/advancewars/Game.java
- Timestamp:
- May 9, 2011, 6:23:05 PM (14 years ago)
- Branches:
- master
- Children:
- bdd63ba
- Parents:
- ae564dc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/medievaltech/advancewars/Game.java
rae564dc r113d7cf 1 1 package com.medievaltech.advancewars; 2 2 3 import com.medievaltech.advancewars.R;4 import com.medievaltech.advancewars.GameView; 3 import java.io.*; 4 5 5 import com.medievaltech.advancewars.GameView.DrawingThread; 6 6 … … 14 14 15 15 public class Game extends Activity { 16 private static final int MENU_EXIT = 1; 17 private static final int MENU_NEW = 2; 16 private static final int MENU_SAVE = 1; 17 private static final int MENU_MAIN = 2; 18 private static final int MENU_EXIT = 3; 18 19 19 20 public enum State{BUST, ACTIVE, DOUBLEDOWN}; … … 35 36 super.onCreateOptionsMenu(menu); 36 37 38 menu.add(0, MENU_SAVE, 0, R.string.menu_save); 39 menu.add(0, MENU_MAIN, 0, R.string.menu_main); 37 40 menu.add(0, MENU_EXIT, 0, R.string.menu_exit); 38 41 return true; … … 49 52 public boolean onOptionsItemSelected(MenuItem item) { 50 53 switch (item.getItemId()) { 54 case MENU_SAVE: 55 try { 56 PrintWriter p = new PrintWriter(new FileWriter(android.os.Environment.getExternalStorageDirectory()+"/save.txt")); 57 mThread.mMap.save(p); 58 p.close(); 59 }catch(IOException ioe) { 60 ioe.printStackTrace(); 61 } 62 break; 63 case MENU_MAIN: 64 mThread.mGameState = GameState.MAIN_MENU; 65 break; 51 66 case MENU_EXIT: 52 this.finish();67 finish(); 53 68 break; 54 69 } … … 93 108 94 109 mGameView.getThread().mGameState = (GameState)savedInstanceState.getSerializable("gameState"); 95 96 mGameView.getThread().mPlayerWins = savedInstanceState.getInt("playerWins");97 mGameView.getThread().mPlayerLosses = savedInstanceState.getInt("playerLosses");98 110 } 99 111 } … … 117 129 protected void onSaveInstanceState(Bundle outState) { 118 130 outState.putSerializable("gameState", mGameView.getThread().mGameState); 119 outState.putSerializable("playerWins", mGameView.getThread().mPlayerWins); 120 outState.putSerializable("playerLosses", mGameView.getThread().mPlayerLosses); 121 131 122 132 super.onSaveInstanceState(outState); 123 Log.w(" Blackjack", "onSaveInstanceState called");133 Log.w("AdvanceWars", "onSaveInstanceState called"); 124 134 } 125 135
Note:
See TracChangeset
for help on using the changeset viewer.