Changes in / [15ddb57:54e0965] in advance-wars
- Location:
- src/com/example
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/example/advancewars/GameView.java
r15ddb57 r54e0965 59 59 private SurfaceHolder mSurfaceHolder; 60 60 61 private Hashtable<String, GUIObject> drawableObjects;61 private com.example.gui.Window wndMainMenu, wndBattleMap; 62 62 63 63 public DrawingThread(SurfaceHolder surfaceHolder, Context context, Handler handler) { … … 91 91 mTilePaint2.setARGB(255, 0, 0, 255); 92 92 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)); 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)); 100 99 101 100 Tile grassTile = new Tile(mTilePaint1); … … 331 330 switch(mGameState) { 332 331 case MAIN_MENU: 333 for (GUIObject o : drawableObjects.values()) { 334 o.draw(canvas); 335 } 332 wndMainMenu.draw(canvas); 336 333 break; 337 334 case BATTLE_MAP: … … 403 400 case MAIN_MENU: 404 401 Log.i("AdvanceWars", "Switching to battle map"); 405 if(thread. drawableObjects.get("btnNewGame").isClicked(event.getX(), event.getY())) {402 if(thread.wndMainMenu.getGUIObject("btnNewGame").isClicked(event.getX(), event.getY())) { 406 403 thread.mGameState = GameState.BATTLE_MAP; 407 }else if(thread. drawableObjects.get("btnLoadGame").isClicked(event.getX(), event.getY())) {404 }else if(thread.wndMainMenu.getGUIObject("btnLoadGame").isClicked(event.getX(), event.getY())) { 408 405 thread.mGameState = GameState.BATTLE_MAP; 409 }else if(thread. drawableObjects.get("btnQuit").isClicked(event.getX(), event.getY())) {406 }else if(thread.wndMainMenu.getGUIObject("btnQuit").isClicked(event.getX(), event.getY())) { 410 407 mGame.finish(); 411 408 }
Note:
See TracChangeset
for help on using the changeset viewer.