Changeset fea4b77 in advance-wars for src/com/medievaltech/advancewars/Game.java
- Timestamp:
- Jun 6, 2011, 6:07:43 PM (14 years ago)
- Branches:
- master
- Children:
- 99433bb
- Parents:
- b660017
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/medievaltech/advancewars/Game.java
rb660017 rfea4b77 15 15 16 16 public class Game extends Activity { 17 private static final int MENU_SAVE = 1;18 private static final int MENU_MAIN = 2;19 private static final int MENU_EXIT = 3;20 21 /** A handle to the thread that's actually running the animation. */22 17 public DrawingThread mThread; 23 24 /** A handle to the View in which the game is running. */25 18 private GameView mGameView; 26 19 … … 35 28 super.onCreateOptionsMenu(menu); 36 29 37 menu.add(0, MENU_SAVE, 0, R.string.menu_save); 38 menu.add(0, MENU_MAIN, 0, R.string.menu_main); 39 menu.add(0, MENU_EXIT, 0, R.string.menu_exit); 30 menu.add(0, MenuOption.END_TURN.ordinal(), 0, R.string.menu_end_turn); 31 menu.add(0, MenuOption.SAVE.ordinal(), 0, R.string.menu_save); 32 menu.add(0, MenuOption.MAIN.ordinal(), 0, R.string.menu_main); 33 menu.add(0, MenuOption.EXIT.ordinal(), 0, R.string.menu_exit); 40 34 return true; 41 35 } … … 50 44 @Override 51 45 public boolean onOptionsItemSelected(MenuItem item) { 52 switch (item.getItemId()) {53 case MENU_SAVE:54 try{55 PrintWriter p = new PrintWriter(new FileWriter(android.os.Environment.getExternalStorageDirectory()+"/save.txt"));56 mThread.mMap.save(p);57 p.close();58 }catch(IOException ioe) {59 ioe.printStackTrace();60 }61 break;62 case MENU_MAIN:63 mThread.mGameState = GameState.MAIN_MENU;64 break;65 case MENU_EXIT:66 finish();67 break;46 int i = item.getItemId(); 47 48 if(i == MenuOption.END_TURN.ordinal()) { 49 mThread.mTurn = Turn.ENEMY_TURN; 50 }else if(i == MenuOption.SAVE.ordinal()) { 51 try { 52 PrintWriter p = new PrintWriter(new FileWriter(android.os.Environment.getExternalStorageDirectory()+"/save.txt")); 53 mThread.mMap.save(p); 54 p.close(); 55 }catch(IOException ioe) { 56 ioe.printStackTrace(); 57 } 58 }else if(i == MenuOption.MAIN.ordinal()) { 59 mThread.mGameState = GameState.MAIN_MENU; 60 }else if(i == MenuOption.EXIT.ordinal()) { 61 finish(); 68 62 } 69 63
Note:
See TracChangeset
for help on using the changeset viewer.