Changes in / [15ddb57:54e0965] in advance-wars


Ignore:
Location:
src/com/example
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/com/example/advancewars/GameView.java

    r15ddb57 r54e0965  
    5959        private SurfaceHolder mSurfaceHolder;
    6060       
    61         private Hashtable<String, GUIObject> drawableObjects;
     61        private com.example.gui.Window wndMainMenu, wndBattleMap;
    6262       
    6363        public DrawingThread(SurfaceHolder surfaceHolder, Context context, Handler handler) {
     
    9191            mTilePaint2.setARGB(255, 0, 0, 255);
    9292           
    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));
    10099           
    101100            Tile grassTile = new Tile(mTilePaint1);
     
    331330                switch(mGameState) {
    332331                case MAIN_MENU:
    333                 for (GUIObject o : drawableObjects.values()) {
    334                         o.draw(canvas);
    335                 }
     332                wndMainMenu.draw(canvas);
    336333                        break;
    337334                case BATTLE_MAP:
     
    403400                case MAIN_MENU:
    404401                        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())) {
    406403                                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())) {
    408405                                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())) {
    410407                                mGame.finish();
    411408                        }
Note: See TracChangeset for help on using the changeset viewer.