Index: src/com/medievaltech/advancewars/GameView.java
===================================================================
--- src/com/medievaltech/advancewars/GameView.java	(revision 41c11ddbc8715657adbee13ce2a02275cc620a31)
+++ src/com/medievaltech/advancewars/GameView.java	(revision 4666fae269693feb5cd590f9fa66afb09a922c18)
@@ -14,89 +14,62 @@
 import android.util.AttributeSet;
 import android.util.Log;
-import android.widget.TextView;
 
 class GameView extends SurfaceView implements SurfaceHolder.Callback {
 	
-    class DrawingThread extends Thread {        
-        public GameState mGameState;
-        
-        //maybe make this private and make an accessor for it
-        //public Map mMap;
-        
-        public Tile grassTile, oceanTile;
-        
-        public Turn mTurn;
-        
-        public Player enemy;
+    class DrawingThread extends Thread {
+    	
         private Unit selectedUnit;
-        
-        private int mCanvasHeight = 1;
-        private int mCanvasWidth = 1;
 
         private Paint mLinePaint, mTextPaint, mButtonPaint, mTilePaint1,
         			mTilePaint2, mSelectionPaint, mUnitPaint1, mUnitPaint2;
 
-        /** Indicate whether the surface has been created & is ready to draw */
-        private boolean mRun = false;
-
         /** Handle to the surface manager object we interact with */
         private SurfaceHolder mSurfaceHolder;
         
-        private com.medievaltech.gui.Window wndMainMenu;
-        
         public DrawingThread(SurfaceHolder surfaceHolder, Context context, Handler handler) {
             mSurfaceHolder = surfaceHolder;
             
             mLinePaint = new Paint();
-            mLinePaint.setAntiAlias(true);
-            mLinePaint.setARGB(255, 0, 255, 0);
+            initPaint(mLinePaint, 0, 255, 0);
 
             mTextPaint = new Paint();
-            mTextPaint.setAntiAlias(true);
-            mTextPaint.setARGB(255, 255, 255, 255);
             mTextPaint.setTextSize(12);
             mTextPaint.setTextAlign(Paint.Align.CENTER);
+            initPaint(mTextPaint, 255, 255, 255);
             
             mButtonPaint = new Paint();
-            mButtonPaint.setAntiAlias(true);
-            mButtonPaint.setARGB(255, 0, 0, 0);
             mButtonPaint.setTextSize(20);
             mButtonPaint.setTextAlign(Paint.Align.CENTER);
+            initPaint(mButtonPaint, 0, 0, 0);
             
             mTilePaint1 = new Paint();
-            mTilePaint1.setAntiAlias(true);
-            mTilePaint1.setARGB(255, 0, 255, 0);
+            initPaint(mTilePaint1, 0, 255, 0);
             
             mTilePaint2 = new Paint();
-            mTilePaint2.setAntiAlias(true);
-            mTilePaint2.setARGB(255, 0, 0, 255);
+            initPaint(mTilePaint2, 0, 0, 255);
             
             mUnitPaint1 = new Paint();
-            mUnitPaint1.setAntiAlias(true);
-            mUnitPaint1.setARGB(255, 255, 0, 0);
+            initPaint(mUnitPaint1, 255, 0, 0);
             
             mUnitPaint2 = new Paint();
-            mUnitPaint2.setAntiAlias(true);
-            mUnitPaint2.setARGB(255, 160, 160, 255);
+            initPaint(mUnitPaint2, 160, 160, 255);
             
             mSelectionPaint = new Paint();
-            mSelectionPaint.setAntiAlias(true);
-            mSelectionPaint.setARGB(255, 255, 127, 0);
+            initPaint(mSelectionPaint, 255, 127, 0);
             
             Player.neutralColor = new Paint();
-            Player.neutralColor.setAntiAlias(true);
-            Player.neutralColor.setARGB(255, 127, 127, 127);
-            
-            wndMainMenu = new com.medievaltech.gui.Window(0, 0, 320, 450);;
-            wndMainMenu.addGUIObject("txtTitle", new Text("Main Menu", 100, 30, 120, 20, mTextPaint));
-            wndMainMenu.addGUIObject("btnNewGame", new Button("New Game", 100, 90, 120, 20, mLinePaint, mButtonPaint));
-            wndMainMenu.addGUIObject("btnLoadGame", new Button("Load Game", 100, 125, 120, 20, mLinePaint, mButtonPaint));
-            wndMainMenu.addGUIObject("btnMapEditor", new Button("Map Editor", 100, 160, 120, 20, mLinePaint, mButtonPaint));
-            wndMainMenu.addGUIObject("btnQuit", new Button("Quit", 100, 195, 120, 20, mLinePaint, mButtonPaint));
-            
-            grassTile = new Tile(mTilePaint1, TerrainType.LAND);
-            oceanTile = new Tile(mTilePaint2, TerrainType.SEA);
-            
-            Static.map = new Map(grassTile, 6, 8, new Point(10, 25));
+            initPaint(Player.neutralColor, 127, 127, 127);
+            
+            Static.wndMainMenu = new com.medievaltech.gui.Window(0, 0, 320, 450);
+            Static.wndMainMenu.addGUIObject("txtTitle", new Text("Main Menu", 100, 30, 120, 20, mTextPaint));
+            Static.wndMainMenu.addGUIObject("btnNewGame", new Button("New Game", 100, 90, 120, 20, mLinePaint, mButtonPaint));
+            Static.wndMainMenu.addGUIObject("btnLoadGame", new Button("Load Game", 100, 125, 120, 20, mLinePaint, mButtonPaint));
+            Static.wndMainMenu.addGUIObject("btnMapEditor", new Button("Map Editor", 100, 160, 120, 20, mLinePaint, mButtonPaint));
+            Static.wndMainMenu.addGUIObject("btnQuit", new Button("Quit", 100, 195, 120, 20, mLinePaint, mButtonPaint));
+            
+            Static.grassTile = new Tile(mTilePaint1, TerrainType.LAND);
+            Static.oceanTile = new Tile(mTilePaint2, TerrainType.SEA);
+            
+            Static.map = new Map(Static.grassTile, 6, 8, new Point(10, 25));
             
             boolean land = true;
@@ -105,7 +78,7 @@
     			for(int y=0; y<Static.map.getHeight(); y++) {
     				if(land)
-    					Static.map.setTile(x, y, new Tile(grassTile, new Point(x, y)));
+    					Static.map.setTile(x, y, new Tile(Static.grassTile, new Point(x, y)));
     				else
-    					Static.map.setTile(x, y, new Tile(oceanTile, new Point(x, y)));
+    					Static.map.setTile(x, y, new Tile(Static.oceanTile, new Point(x, y)));
     				land = !land;
     			}
@@ -113,16 +86,21 @@
             }
             
-            Player humanPlayer = new Player("Human", mUnitPaint1);
-            enemy = new Player("Comp", mUnitPaint2);
-            
-            Static.map.getTile(0, 0).addUnit(new Soldier(enemy));
-            Static.map.getTile(2, 3).addUnit(new Soldier(humanPlayer));
-            Static.map.getTile(5, 6).addUnit(new Soldier(humanPlayer));
+            Static.human = new Player("Human", mUnitPaint1);
+            Static.enemy = new Player("Comp", mUnitPaint2);
+            
+            Static.map.getTile(0, 0).addUnit(new Soldier(Static.enemy));
+            Static.map.getTile(2, 3).addUnit(new Soldier(Static.human));
+            Static.map.getTile(5, 6).addUnit(new Soldier(Static.human));
             
             Static.map.getTile(4, 4).addBuilding(new City());
             
-            mTurn = Turn.YOUR_TURN;
-            
-            mGameState = GameState.MAIN_MENU;
+            Static.turn = Turn.YOUR_TURN;
+            
+            Static.gameState = GameState.MAIN_MENU;
+        }
+        
+        public void initPaint(Paint p, int r, int g, int b) {
+            p.setAntiAlias(true);
+            p.setARGB(255, r, g, b);
         }
         
@@ -134,5 +112,5 @@
             synchronized (mSurfaceHolder) {
                 Log.i("AdvanceWars", "Player's turn starting now");
-                mGameState = GameState.MAIN_MENU;
+                Static.gameState = GameState.MAIN_MENU;
             }
         }
@@ -140,5 +118,5 @@
         @Override
         public void run() {
-            while (mRun) {
+            while (Static.run) {
                 Canvas c = null;
                 try {
@@ -158,20 +136,8 @@
             }
         }
-
-        /**
-         * Used to signal the thread whether it should be running or not.
-         * Passing true allows the thread to run; passing false will shut it
-         * down if it's already running. Calling start() after this was most
-         * recently called with false will result in an immediate shutdown.
-         * 
-         * @param b true to run, false to shut down
-         */
-        public void setRunning(boolean b) {
-            mRun = b;
-        }
         
         public void setGameState(GameState state) {
             synchronized (mSurfaceHolder) {
-                mGameState = state;
+            	Static.gameState = state;
             }
         }
@@ -179,20 +145,16 @@
         /* Callback invoked when the surface dimensions change. */
         public void setSurfaceSize(int width, int height) {
-            // synchronized to make sure these all change atomically
             synchronized (mSurfaceHolder) {
-                mCanvasWidth = width;
-                mCanvasHeight = height;
-                
-                Log.i("AdvanceWars", "width: "+mCanvasWidth+", height: "+mCanvasHeight);
+                Log.i("AdvanceWars", "width: "+width+", height: "+height);
             }
         }
         
         private void doLogic() {
-        	if(mTurn == Turn.YOUR_TURN)
+        	if(Static.turn == Turn.YOUR_TURN)
         		return;
         	
-        	switch(mGameState) {
+        	switch(Static.gameState) {
         	case BATTLE_MAP:
-        		Iterator<Unit> iter = enemy.getControlledUnits().iterator();
+        		Iterator<Unit> iter = Static.enemy.getControlledUnits().iterator();
         		Unit cur;
         		int x, y;
@@ -213,5 +175,5 @@
         		
 				
-				mTurn = Turn.YOUR_TURN;
+        		Static.turn = Turn.YOUR_TURN;
         		break;
         	}
@@ -225,7 +187,7 @@
         	canvas.drawColor(Color.BLACK);
         	
-        	switch(mGameState) {
+        	switch(Static.gameState) {
         	case MAIN_MENU:
-            	wndMainMenu.draw(canvas);
+            	Static.wndMainMenu.draw(canvas);
         		break;
         	case BATTLE_MAP:
@@ -249,10 +211,5 @@
 
     /** Pointer to the text view to display "Paused.." etc. */
-    private TextView mStatusText;
-
-    /** The thread that actually draws the animation */
-    private DrawingThread thread;
-    
-    public Game mGame;
+    //private TextView mStatusText;
 
     public GameView(Context context, AttributeSet attrs) {
@@ -264,11 +221,5 @@
 
         // create thread only; it's started in surfaceCreated()
-        thread = new DrawingThread(holder, context, new Handler() {
-            @Override
-            public void handleMessage(Message m) {
-                mStatusText.setVisibility(m.getData().getInt("viz"));
-                mStatusText.setText(m.getData().getString("text"));
-            }
-        });
+        Static.thread = new DrawingThread(holder, context, new Handler() {});
 
         setFocusable(true); // make sure we get key events
@@ -280,10 +231,10 @@
     	if(event.getAction() == MotionEvent.ACTION_UP) {
     		Log.i("AdvanceWars", "Detected UP touch action");
-    		switch(thread.mGameState) {
+    		switch(Static.gameState) {
     		case MAIN_MENU:
     			Log.i("AdvanceWars", "Switching to battle map");
-    			if(thread.wndMainMenu.getGUIObject("btnNewGame").isClicked(event.getX(), event.getY())) {
-    				thread.mGameState = GameState.BATTLE_MAP;
-    			}else if(thread.wndMainMenu.getGUIObject("btnLoadGame").isClicked(event.getX(), event.getY())) {
+    			if(Static.wndMainMenu.getGUIObject("btnNewGame").isClicked(event.getX(), event.getY())) {
+    				Static.gameState = GameState.BATTLE_MAP;
+    			}else if(Static.wndMainMenu.getGUIObject("btnLoadGame").isClicked(event.getX(), event.getY())) {
     				BufferedReader b;
             		try {
@@ -298,5 +249,5 @@
             			int offsetY = Integer.parseInt(offset.substring(offset.indexOf("x")+1));
             			
-            			Static.map = new Map(thread.grassTile, width, height, new Point(offsetX, offsetY));
+            			Static.map = new Map(Static.grassTile, width, height, new Point(offsetX, offsetY));
             			
             			Log.i("GameSave", "Created the map");
@@ -309,7 +260,7 @@
             					TerrainType type = TerrainType.values()[Integer.parseInt(arr[y])];
             					if(type.equals(TerrainType.LAND))
-            						Static.map.setTile(x, y, new Tile(thread.grassTile, new Point(10, 25)));
+            						Static.map.setTile(x, y, new Tile(Static.grassTile, new Point(10, 25)));
                 				else
-                					Static.map.setTile(x, y, new Tile(thread.oceanTile, new Point(10, 25)));
+                					Static.map.setTile(x, y, new Tile(Static.oceanTile, new Point(10, 25)));
             				}
             			}
@@ -321,5 +272,5 @@
                 			int y = Integer.parseInt(unit.substring(unit.indexOf(",")+1));
             				
-                			Player humanPlayer = new Player("Human", mGame.mThread.mUnitPaint1);
+                			Player humanPlayer = new Player("Human", Static.thread.mUnitPaint1);
                 			
                 			Static.map.getTile(x, y).addUnit(new Soldier(humanPlayer));
@@ -330,7 +281,7 @@
             			ioe.printStackTrace();
             		}
-    				thread.mGameState = GameState.BATTLE_MAP;
-    			}else if(thread.wndMainMenu.getGUIObject("btnQuit").isClicked(event.getX(), event.getY())) {
-    				mGame.finish();
+            		Static.gameState = GameState.BATTLE_MAP;
+    			}else if(Static.wndMainMenu.getGUIObject("btnQuit").isClicked(event.getX(), event.getY())) {
+    				Static.game.finish();
     			}
     			break;
@@ -344,14 +295,14 @@
     				Unit target = Static.map.getTile(x, y).currentUnit;
     				
-    				if(thread.selectedUnit != null && thread.selectedUnit.getMovementRange().contains(new Point(x, y))) {
-    					if(target == null || target == thread.selectedUnit) {
-    							Static.map.getTile(thread.selectedUnit.location.x, thread.selectedUnit.location.y).removeUnit();
-    							Static.map.getTile(x, y).addUnit(thread.selectedUnit);
+    				if(Static.thread.selectedUnit != null && Static.thread.selectedUnit.getMovementRange().contains(new Point(x, y))) {
+    					if(target == null || target == Static.thread.selectedUnit) {
+    							Static.map.getTile(Static.thread.selectedUnit.location.x, Static.thread.selectedUnit.location.y).removeUnit();
+    							Static.map.getTile(x, y).addUnit(Static.thread.selectedUnit);
     					}else {
     						// the target contains another unit. If the unit is enemy-controlled, attack it
     					}
-    					thread.selectedUnit = null;
+    					Static.thread.selectedUnit = null;
     				}else
-    					thread.selectedUnit = target;
+    					Static.thread.selectedUnit = target;
     			}
     			
@@ -366,25 +317,9 @@
         return true;
     }
-    
-    /**
-     * Fetches the animation thread corresponding to this LunarView.
-     * 
-     * @return the animation thread
-     */
-    public DrawingThread getThread() {
-        return thread;
-    }
-
-    /**
-     * Installs a pointer to the text view used for messages.
-     */
-    public void setTextView(TextView textView) {
-        mStatusText = textView;
-    }
 
     /* Callback invoked when the surface dimensions change. */
     public void surfaceChanged(SurfaceHolder holder, int format, int width,
             int height) {
-        thread.setSurfaceSize(width, height);
+    	Static.thread.setSurfaceSize(width, height);
     }
 
@@ -394,6 +329,6 @@
      */
     public void surfaceCreated(SurfaceHolder holder) {
-        thread.setRunning(true);
-        thread.start();
+    	Static.run = true;
+    	Static.thread.start();
     }
 
@@ -407,8 +342,8 @@
         // it might touch the Surface after we return and explode
         boolean retry = true;
-        thread.setRunning(false);
+        Static.run = false;
         while (retry) {
             try {
-                thread.join();
+            	Static.thread.join();
                 retry = false;
             } catch (InterruptedException e) {
