Changes in / [7f693b4:a0f5455] in advance-wars


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

Legend:

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

    r7f693b4 ra0f5455  
    5959        private SurfaceHolder mSurfaceHolder;
    6060       
    61         private com.example.gui.Window wndMainMenu, wndBattleMap;
     61        private Hashtable<String, GUIObject> drawableObjects;
    6262       
    6363        public DrawingThread(SurfaceHolder surfaceHolder, Context context, Handler handler) {
     
    9191            mTilePaint2.setARGB(255, 0, 0, 255);
    9292           
    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));
    99100           
    100101            Tile grassTile = new Tile(mTilePaint1);
     
    330331                switch(mGameState) {
    331332                case MAIN_MENU:
    332                 wndMainMenu.draw(canvas);
     333                for (GUIObject o : drawableObjects.values()) {
     334                        o.draw(canvas);
     335                }
    333336                        break;
    334337                case BATTLE_MAP:
     
    400403                case MAIN_MENU:
    401404                        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())) {
    403406                                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())) {
    405408                                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())) {
    407410                                mGame.finish();
    408411                        }
Note: See TracChangeset for help on using the changeset viewer.