Changes in / [7f693b4:a0f5455] in advance-wars
- Location:
- src/com/example
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/example/advancewars/GameView.java
r7f693b4 ra0f5455 59 59 private SurfaceHolder mSurfaceHolder; 60 60 61 private com.example.gui.Window wndMainMenu, wndBattleMap;61 private Hashtable<String, GUIObject> drawableObjects; 62 62 63 63 public DrawingThread(SurfaceHolder surfaceHolder, Context context, Handler handler) { … … 91 91 mTilePaint2.setARGB(255, 0, 0, 255); 92 92 93 wndMainMenu = new com.example.gui.Window(0, 0, 320, 450);; 94 wndMainMenu.addGUIObject("txtTitle", new Text("Main Menu", 100, 30, 120, 20, mTextPaint)); 95 wndMainMenu.addGUIObject("btnNewGame", new Button("New Game", 100, 90, 120, 20, mLinePaint, mButtonPaint)); 96 wndMainMenu.addGUIObject("btnLoadGame", new Button("Load Game", 100, 125, 120, 20, mLinePaint, mButtonPaint)); 97 wndMainMenu.addGUIObject("btnMapEditor", new Button("Map Editor", 100, 160, 120, 20, mLinePaint, mButtonPaint)); 98 wndMainMenu.addGUIObject("btnQuit", new Button("Quit", 100, 195, 120, 20, mLinePaint, mButtonPaint)); 93 drawableObjects = new Hashtable<String, GUIObject>(); 94 95 drawableObjects.put("txtTitle", new Text("Main Menu", 100, 30, 120, 20, mTextPaint)); 96 drawableObjects.put("btnNewGame", new Button("New Game", 100, 90, 120, 20, mLinePaint, mButtonPaint)); 97 drawableObjects.put("btnLoadGame", new Button("Load Game", 100, 125, 120, 20, mLinePaint, mButtonPaint)); 98 drawableObjects.put("btnMapEditor", new Button("Map Editor", 100, 160, 120, 20, mLinePaint, mButtonPaint)); 99 drawableObjects.put("btnQuit", new Button("Quit", 100, 195, 120, 20, mLinePaint, mButtonPaint)); 99 100 100 101 Tile grassTile = new Tile(mTilePaint1); … … 330 331 switch(mGameState) { 331 332 case MAIN_MENU: 332 wndMainMenu.draw(canvas); 333 for (GUIObject o : drawableObjects.values()) { 334 o.draw(canvas); 335 } 333 336 break; 334 337 case BATTLE_MAP: … … 400 403 case MAIN_MENU: 401 404 Log.i("AdvanceWars", "Switching to battle map"); 402 if(thread. wndMainMenu.getGUIObject("btnNewGame").isClicked(event.getX(), event.getY())) {405 if(thread.drawableObjects.get("btnNewGame").isClicked(event.getX(), event.getY())) { 403 406 thread.mGameState = GameState.BATTLE_MAP; 404 }else if(thread. wndMainMenu.getGUIObject("btnLoadGame").isClicked(event.getX(), event.getY())) {407 }else if(thread.drawableObjects.get("btnLoadGame").isClicked(event.getX(), event.getY())) { 405 408 thread.mGameState = GameState.BATTLE_MAP; 406 }else if(thread. wndMainMenu.getGUIObject("btnQuit").isClicked(event.getX(), event.getY())) {409 }else if(thread.drawableObjects.get("btnQuit").isClicked(event.getX(), event.getY())) { 407 410 mGame.finish(); 408 411 }
Note:
See TracChangeset
for help on using the changeset viewer.