Commits

rmtew committed acf9268

- Fixed in-game "Menu" sub-menu buttons to not have trailing ':'.
- Cleaned up move tapping menus to be properly tracked even whether enabled or not, so they appear correct when disabled and re-enabled randomly.
- Corrected in-game menu copying to be proper Java object copying, rather than reference copying, which was causing 'orrible problems.

Comments (0)

Files changed (3)

AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="org.disinterest.broguex"
-      android:versionCode="9"
-      android:versionName="1.7.009">
+      android:versionCode="10"
+      android:versionName="1.7.010">
     <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <application android:label="@string/app_name" android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

res/raw/releasenotes.txt

-BrogueX 1.7.009
+BrogueX 1.7.010
 * Email me about any problems or complaints (address below).
 * Bad reviews do not contain enough information.  So email (as well) please!
 * See the help menu item for information about controls.
 
 RECENT CHANGES
-- Added a directional movement touch mode.  More info within help menu item.
-- Restored support for keys that require shift to be pressed (e.g. >).
-- Improved pinch to zoom gesture support.  Maybe works worse.
-- Added a help menu item to view instructions & controls.
+- With move tapping, getting "jump into depths" dialog does not lose in-game menu afterwards.
+- With move tapping, turning it off and on should reliably show the correct menu and not crash.
+
+Thanks to Ashley King & Mladen Mihajlovic for reporting the above problems.
 
 CONTACT INFORMATION
 richard.m.tew@gmail.com

src/org/disinterest/broguex/SDLActivity.java

 		case R.id.toggle_move_tapping_menu_item:
 			mMoveTapping = !mMoveTapping;
 			/* This should also take care of hiding or showing the button menus. */
-			if (mMoveTapping)
-				brogueMenuState.display();
-			else
-				brogueMenuState.dismiss();
+			if (brogueMenuState != null) {
+				if (mMoveTapping)
+					brogueMenuState.display();
+				else
+					brogueMenuState.dismiss();
+			}
 
 			/* Persist new setting. */
 	    	prefs = getPreferences(MODE_PRIVATE);
     	}
     	if (outIdxStart == -1 && outIdxEnd == 0)
     		return "";
+    	/* strip trailing colons, i.e. the in-game sub-Menu. */
     	return String.valueOf(out, outIdxStart, outIdxEnd-outIdxStart+1);
     }
 
 	    	buttonIndex = 0;
 	    	window = null;
 		}
+
+        
+        
+        public BrogueMenuState(BrogueMenuState menuState) {
+			super();
+
+			buttonCount = menuState.buttonCount;
+			buttonMode = menuState.buttonMode;
+
+	    	labels = menuState.labels;
+	    	hotkeys = menuState.hotkeys;
+	    	cxs = menuState.cxs;
+	    	cys = menuState.cys;
+	    	buttonIndex = menuState.buttonIndex;
+	    	window = null;
+		}
         
         public void addButton(String text, char hotkey, int cx, int cy) {
 			if (buttonMode == BROGUE_NG_NEW_GAME || buttonMode == BROGUE_NG_NEW_GAME_WITH_SEED) {
+				/* Exclude the menu text following the leading key (and : following the key). */
 				String arr[] = text.split(" ", 2);
-				text = arr[0];
+				if (arr[0].endsWith(":"))
+					text = arr[0].substring(0, arr[0].length()-1);
+				else
+					text = arr[0];
 			}
 
         	labels[buttonIndex] = text;
         }
 
 		public void display() {
-			if (window != null)
+			if (window != null) {
+				// Log.v("SDL", "BrogueMenuState.display() aborting, already displayed");
 				return;
+			}
 
 			Button button;
     		LinearLayout layout = new LinearLayout(mSingleton);
 			if (window != null) {
 	    	    mSingleton.runOnUiThread(new java.lang.Runnable() {
 					public void run() {
-						window.dismiss();
-						window = null;
+						if (window != null) {
+							window.dismiss();
+							window = null;
+						}
 					}        		
 	        	});
 			}
     public static boolean brogueInInventoryItemFlag = false;
     public static boolean brogueInAcknowledgeState = false;
 
-    /*
-     * Notification of when a new main menu switch happens.
+    private static boolean brogueShowGameMenu() {
+    	if (brogueMenuState != null)
+    		brogueMenuState.dismiss();
+    	brogueInGameMenu = true;
+		brogueMenuState = new BrogueMenuState(brogueMenuStateCopy);
+		if (mMoveTapping) {
+			brogueMenuState.display();
+			return true;
+		}
+		return false;
+    }
+
+	/*
+     * Notification of when a main menu option is selected.
      */
     public static void brogueApplicationMode(int mode) {
     	//Log.v("SDL", String.format("brogueApplicationMode %d", mode));
     	if (brogueEvents == null)
     		brogueEvents = new ArrayList<BrogueEvent>();
-    	/* Flush the event queue. */
+    	/* Flush any selection events that follow the first one.  This solves race
+    	 * condition event ordering problems, like CTRL press arriving after N press. */
     	while (dispatchNextBrogueEvent())
     		;
     	/* If we are switching modes, we definitely want to remove the popup window. */
     }
     
     /*
-     * Nofication when entering and exiting the inventory window.
+     * Notification when entering and exiting the inventory window.
      */
     public static void brogueInInventory(int flag) {
     	//Log.v("SDL", String.format("brogueInInventory %d", flag));
         brogueInInventoryFlag = flag == 1;
         if (!brogueInInventoryFlag) {
-	    	//Log.v("SDL", String.format("brogueInInventory - ! check"));
+	    	//Log.v("SDL", String.format("brogueInInventory - left inventory"));
         	/* Exiting the inventory does not recreate the bottom of screen game buttons. */
-        	brogueMenuState = brogueMenuStateCopy;
-        	brogueInGameMenu = true;
-			if (mMoveTapping) {
-		    	//Log.v("SDL", String.format("brogueInInventory - display"));
-				brogueMenuState.display();
-			}
+	    	brogueShowGameMenu();
         }
     }
     
      * Identify the display of one of the button set.
      */
     public static void brogueInitButton(String text, char hotkey, int cx, int cy) {
+    	text = stripBrogueString(text);
     	//Log.v("SDL", String.format("brogueInitButton %s %c", stripBrogueString(text), hotkey));
-    	text = stripBrogueString(text);
     	brogueMenuState.addButton(text, hotkey, cx, cy);
     	/* When all the buttons have been initialised, show the menu (if global option is enabled). */
     	if (brogueMenuState.haveAllButtons()) {
-			if (mMoveTapping && brogueEvents.isEmpty()) {
+			if (brogueEvents.isEmpty()) {
 				/* The game menu is constant, we need to manually redisplay it, so keep a copy for that. */
 				if (brogueMenuStateCopy == null) {
-					brogueMenuStateCopy = brogueMenuState;
+					brogueMenuStateCopy = new BrogueMenuState(brogueMenuState);
 		        	brogueInGameMenu = true;
 				}
-				brogueMenuState.display();
+				if (mMoveTapping)
+					brogueMenuState.display();
 			}
     	}
     }
+
+    /*
+     * This is not really usable for switch detection.
+     */
+    public static void brogueButtonPress(int flag) {}
     
-    public static void brogueButtonPress(int flag) {
-    }
-    
-    public static void brogueShowGameMenu() {
-		brogueMenuState = brogueMenuStateCopy;
-    	brogueInGameMenu = true;
-		brogueMenuState.display();    	
-    }
-
     public static void brogueExitButtonLoop(int flag) {
     	/* The general assumption is that a button press dismisses the current menu. */
     	//Log.v("SDL", "brogueExitButtonLoop");
-    	if (brogueMenuState != null) {
+    	if (!brogueInInventoryFlag) {
+    		brogueShowGameMenu();
+    	} else if (brogueMenuState != null) {
         	//Log.v("SDL", "brogueExitButtonLoop 1");
     		brogueMenuState.dismiss();
     		brogueMenuState = null;
     	}
-    	if (!brogueInInventoryFlag)
-    		brogueShowGameMenu();
     }
 
-    public static Button brogueCreateButton(int buttonId, String buttonLabel) {
+    private static Button brogueCreateButton(int buttonId, String buttonLabel) {
 		Button button = new Button(mSingleton);
 		button.setId(buttonId);
 		button.setText(buttonLabel);
     	brogueInAcknowledgeState = flag == 0;
     	//Log.v("SDL", String.format("brogueTextDismissed - enter - %d", flag));
     	if (brogueMode == BROGUE_NG_NEW_GAME || brogueMode == BROGUE_NG_NEW_GAME_WITH_SEED) {
-			if (mMoveTapping) {
-				if (flag == 1) {
-			    	//Log.v("SDL", String.format("brogueTextDismissed - restore menu"));
-		    		brogueShowGameMenu();
-				} else {
-			    	//Log.v("SDL", String.format("brogueTextDismissed - hide current menu"));
-			    	if (brogueMenuState != null) {
-			    		brogueMenuState.dismiss();
-			    		brogueMenuState = null;
-			    	}					
-				}
-			}    		
+			if (flag == 1) {
+		    	//Log.v("SDL", String.format("brogueTextDismissed - restore menu"));
+	    		brogueShowGameMenu();
+			} else {
+		    	//Log.v("SDL", String.format("brogueTextDismissed - hide current menu"));
+		    	if (brogueMenuState != null) {
+		    		brogueMenuState.dismiss();
+		    		brogueMenuState = null;
+		    	}					
+			}
     	}
     }
     
     public static void broguePromptDismissed(int flag) {
     	if (brogueMode == BROGUE_NG_NEW_GAME || brogueMode == BROGUE_NG_NEW_GAME_WITH_SEED) {
-			if (mMoveTapping) {
-			    	//Log.v("SDL", String.format("brogueTextDismissed - restore menu"));
-			    	if (brogueMenuState != null) {
-			    		brogueMenuState.dismiss();
-			    		brogueMenuState = null;
-			    	}					
-		    		brogueShowGameMenu();
-			}    		
+	    	//Log.v("SDL", String.format("brogueTextDismissed - restore menu"));
+    		brogueShowGameMenu();
     	}
     }