Commits

rmtew committed 30a1d48

Added help menu item & associated text file.
Added help dialog tied to help menu item selection.
Added initial move tapping touch mode.
Added fullscreen and font resolution zoom menu items.
Fixed Eclipse project to properly clean for rebuilding.

Comments (0)

Files changed (7)

 					<folderInfo id="com.android.toolchain.gcc.248156545.1122566074" name="/" resourcePath="">
 						<toolChain id="com.android.toolchain.gcc.1942822620" name="com.android.toolchain.gcc" superClass="com.android.toolchain.gcc">
 							<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="com.android.targetPlatform.766321111" isAbstract="false" superClass="com.android.targetPlatform"/>
-							<builder arguments="" command="${NDK_ROOT}/ndk-build" enableCleanBuild="false" enabledIncrementalBuild="true" id="com.android.builder.2058536580" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Android Builder" superClass="com.android.builder"/>
+							<builder arguments="" command="${NDK_ROOT}/ndk-build" enableCleanBuild="true" enabledIncrementalBuild="true" id="com.android.builder.2058536580" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Android Builder" superClass="com.android.builder"/>
 							<tool id="com.android.gcc.compiler.1023041572" name="Android GCC Compiler" superClass="com.android.gcc.compiler">
 								<option id="com.android.gcc.option.includePath.1237805345" superClass="com.android.gcc.option.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;D:\Code\android-ndk-r8\platforms\android-14\arch-arm\usr\include&quot;"/>
 	<buildSpec>
 		<buildCommand>
 			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
-			<triggers>full,incremental,</triggers>
+			<triggers>clean,full,incremental,</triggers>
 			<arguments>
 			</arguments>
 		</buildCommand>

res/layout/help.xml

+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingTop="1dp"
+    android:paddingBottom="1dp"
+    android:orientation="vertical" >
+
+    <ScrollView
+        android:id="@+id/scrollView2"
+        android:layout_width="match_parent"
+        android:layout_height="0dip"
+        android:layout_weight="0.38" >
+
+           <TextView
+               android:id="@+id/help_text"
+               android:layout_width="match_parent"
+               android:layout_height="wrap_content"
+               android:ems="10"
+               android:autoLink="all">
+
+                <requestFocus />
+            </TextView>
+
+    </ScrollView>
+    
+</LinearLayout>

res/menu/main.xml

     </item>
     <item android:id="@+id/options_menu_item" android:enabled="true" android:title="@string/options_menu_item" android:visible="true" android:titleCondensed="@string/options_menu_item">
         <menu>
-            <item android:id="@+id/toggle_keyboard_menu_item" android:title="@string/toggle_keyboard_menu_item_name" android:visible="true" android:enabled="true"/>
-            <item android:id="@+id/scaling_menu_item" android:visible="true" android:enabled="true" android:title="@string/scaling_menu_item_name"/>
+            <item android:id="@+id/help_menu_item" android:title="@string/help_menu_item_name" android:enabled="true" android:visible="true" /><item android:id="@+id/toggle_move_tapping_menu_item" android:titleCondensed="@string/toggle_move_tapping_menu_item_cname" android:enabled="true" android:checked="false" android:title="@string/toggle_move_tapping_menu_item_name" android:checkable="true" android:visible="true" /><item android:id="@+id/toggle_keyboard_menu_item" android:title="@string/toggle_keyboard_menu_item_name" android:visible="true" android:enabled="true"/>
+            
+            
+            <item android:id="@+id/scaling_fs_menu_item" android:titleCondensed="@string/scaling_fs_menu_item_cname" android:title="@string/scaling_fs_menu_item_name" android:enabled="true" android:visible="true"/><item android:id="@+id/scaling_font_menu_item" android:visible="true" android:enabled="true" android:title="@string/scaling_menu_item_name" />
+            
         </menu>
     </item>
 </menu>

res/raw/releasenotes.txt

 BrogueX 1.6.408
 * 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
-- With SDL2, instead of getting the '>' character for a key press, SHIFT+'.' is received.  Similarly SHIFT+'`' is sent instead of '~'.  These are now fixed in libtcod.
+- Fixed remaining keyboard issues.  '>', '~', '<' and other characters involving pressing SHIFT should now work.
+- Improved pinch to zoom gesture support.  Should zoom nearer center of pinch point, and can be dragged while pinching.
+- Added a help menu item to view instructions & controls.
+- Added a directional movement touch mode.  More info within help menu item.
 
 CONTACT INFORMATION
 richard.m.tew@gmail.com
-http://disinterest.org/broguex/
-
-EXTRA ANDROID CONTROLS
-- Pinch gesture / drag gesture: Zoom in, and drag the displayed zoomed in area around, like you would use your maps app.
-- Escape key has been replaced by the space key.  Use it to back out of menus.
+http://disinterest.org/broguex/

res/values/strings.xml

     <string name="app_name">BrogueX</string>
     <string name="do_not_display_again">Do not display again</string>
     <string name="settings_name">Settings</string>
-    <string name="scaling_menu_item_name">Zoom to unscaled</string>
+    <string name="scaling_menu_item_name">Zoom to font resolution</string>
+    <string name="scaling_menu_item_cname">Zoom (font)</string>
+    <string name="scaling_fs_menu_item_name">Zoom to fullscreen resolution</string>
+    <string name="scaling_fs_menu_item_cname">Zoom (fullscreen)</string>
     <string name="dev_name">Dev</string>
     <string name="development_name">Development</string>
     <string name="record_gesture_menu_item_name">Record gesture</string>
     <string name="fps_unlimited_menu_item_name">unlimited fps</string>
     <string name="options_menu_item">Options</string>
     <string name="toggle_keyboard_menu_item_name">Toggle keyboard</string>
+    <string name="toggle_move_tapping_menu_item_name">Move tapping layer</string>
+    <string name="toggle_move_tapping_menu_item_cname">Move layer</string>
+    <string name="help_menu_item_name">Help</string>
 </resources>

src/org/disinterest/broguex/SDLActivity.java

 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.res.Configuration;
 
-
 /**
     SDL Activity
 */
 
     private static boolean mShowReleaseNotes;
     private static int mTCODFPS;
+    private static boolean mMoveTapping;
     private static String mVersionName;
     private static boolean mDebuggable;
     
         setContentView(mSurface);
         // SurfaceHolder holder = mSurface.getHolder();        
 
+        mMoveTapping = false;
+
     	SharedPreferences prefs = getPreferences(MODE_PRIVATE);
     	mTCODFPS = prefs.getInt(PREFS_TCOD_FPS_LIMIT, 30);
     	SDLActivity.nativeTCODSetFPS(mTCODFPS);
 		item = menu.findItem(R.id.fps_unlimited_menu_item);
 		item.setChecked(mTCODFPS == 0);
 		
+		item = menu.findItem(R.id.toggle_move_tapping_menu_item);
+		item.setChecked(mMoveTapping);
+		
 		item = menu.findItem(R.id.dev_menu_item);
 		item.setVisible(mDebuggable);
 		item.setEnabled(mDebuggable);
 		SharedPreferences.Editor prefsEd;
 
 		switch (item.getItemId()) {
+		case R.id.help_menu_item:
+			showHelp();
+			break;
+		case R.id.toggle_move_tapping_menu_item:
+			mMoveTapping = !mMoveTapping;
+			break;
 		case R.id.toggle_keyboard_menu_item:
 			/* This comes back to Java in a roundabout way, but should make SDL's API more reliable. */
 			nativeSDLToggleScreenKeyboard();
 			break;
-		case R.id.scaling_menu_item:
-	    	SDLActivity.nativeTCODSetNoScaling();
+		case R.id.scaling_font_menu_item:
+	    	SDLActivity.nativeTCODSetScaleFactor(0.0f);
+			break;
+		case R.id.scaling_fs_menu_item:
+	    	SDLActivity.nativeTCODSetScaleFactor(1.0f);
 			break;
 		case R.id.fps_90_menu_item:
 			fps_value += 30;
 	    	prefsEd.putInt(PREFS_TCOD_FPS_LIMIT, mTCODFPS);
 	    	prefsEd.commit();
 	    	
-	    	SDLActivity.nativeTCODSetFPS(mTCODFPS);
-	    	
+	    	SDLActivity.nativeTCODSetFPS(mTCODFPS);	    	
 			break;
 		default:
 			return false;
     public static native void onNativeAccel(float x, float y, float z);
     public static native void nativeRunAudioThread();
 
-    public static native void nativeTCODSetNoScaling();
+    public static native void nativeTCODSetScaleFactor(float scale_factor);
     public static native void nativeTCODSetFPS(int value);
     public static native void nativeSDLToggleScreenKeyboard();
 
     private static boolean isHardwareKeyboardAvailable() {
     	return mSingleton.getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
     }
+    
+    public static boolean moveTappingLayerActive() {
+    	return mMoveTapping;
+    }
 
     private void showReleaseNotes() {
     	if (!mShowReleaseNotes) {
 			    	SharedPreferences.Editor prefsEd = prefs.edit();
 			    	prefsEd.putString(PREFS_RELEASE_NOTES_SEEN, mVersionName);
 			    	boolean savedSuccessfully = prefsEd.commit();
-			    	Log.d("BrogueX", String.format("Saved release-note-version='%s' => %b", mVersionName, savedSuccessfully));
 				}
 			}
 		});
     	/* Non-blocking, execution proceeds. */
     	alert.show();
     }
+
+    private void showHelp() {    	
+    	AlertDialog.Builder alert = new AlertDialog.Builder(this);
+    	alert.setIcon(R.drawable.icon);
+    	alert.setTitle("Help");
+    	alert.setNeutralButton("OK", new DialogInterface.OnClickListener() {
+			public void onClick(DialogInterface dialog, int which) {}
+		});
+
+    	LayoutInflater factory = LayoutInflater.from(this);
+        final View alertView = factory.inflate(R.layout.help, null);
+        
+        /* Populate the text view with the release notes. */
+        TextView tv = (TextView) alertView.findViewById(R.id.help_text);    	
+    	InputStream is = null;
+    	try {
+    		is = getResources().openRawResource(R.raw.help);
+    		byte[] reader = new byte[is.available()];
+    		while (is.read(reader) != -1) {}
+    		tv.setText(new String(reader));
+    	} catch (IOException e) {    	
+    		Log.e("ReadRawResourceFile", e.getMessage(), e);
+    	} finally {
+	    	if (is != null) {
+		    	try {
+			    	is.close();
+		    	} catch (IOException e) {}
+	    	}
+    	}
+    	
+    	alert.setView(alertView);
+    	/* Non-blocking, execution proceeds. */
+    	alert.show();
+    }
     
     public static void openMenu() {
     	mSingleton.openOptionsMenu();
     }
 }
 
+class CustomKeys {
+	/* These keycodes were added in API version 11, but too many people are
+	 * using earlier versions.  So we hardcode them which is safe as houses. */
+	public static int NUMPAD_1 = 145;
+	public static int NUMPAD_2 = 146;
+	public static int NUMPAD_3 = 147;
+	public static int NUMPAD_4 = 148;
+	public static int NUMPAD_5 = 149;
+	public static int NUMPAD_6 = 150;
+	public static int NUMPAD_7 = 151;
+	public static int NUMPAD_8 = 152;
+	public static int NUMPAD_9 = 153;
+}
 
 /**
     SDLSurface. This is what we draw on, so we need to know when it's created
              float y = event.getY(actionPointerIndex) / mHeight;
              float p = event.getPressure(actionPointerIndex);
 
+             /* BrogueX control modification. */
+             if (SDLActivity.moveTappingLayerActive()) {
+            	 if (action == MotionEvent.ACTION_DOWN)
+            		 onMoveTapJiggeryPokery(x, y);
+            	 return true;
+             }
+
              if (action == MotionEvent.ACTION_MOVE && pointerCount > 1) {
                 // TODO send motion to every pointer if its position has
                 // changed since prev event.
              }
         }
       return true;
-   } 
+    } 
 
+    public void onMoveTapJiggeryPokery(float x, float y) {
+        int keyCode = 0;
+
+	   	if (x < 0.333f) {
+	   		if (y < 0.333f)			keyCode = CustomKeys.NUMPAD_7;
+	   		else if (y < 0.666f)	keyCode = CustomKeys.NUMPAD_4;
+	   		else					keyCode = CustomKeys.NUMPAD_1;
+	   	} else if (x < 0.666f) {
+	   		if (y < 0.333f)			keyCode = CustomKeys.NUMPAD_8;
+	   		else if (y < 0.666f)	keyCode = CustomKeys.NUMPAD_5;
+	   		else					keyCode = CustomKeys.NUMPAD_2;
+	   	} else {
+	   		if (y < 0.333f)			keyCode = CustomKeys.NUMPAD_9;
+	   		else if (y < 0.666f)	keyCode = CustomKeys.NUMPAD_6;
+	   		else					keyCode = CustomKeys.NUMPAD_3;
+	   	}
+
+	   	if (keyCode != 0) {
+	   	 	SDLActivity.onNativeKeyDown(keyCode);
+	        SDLActivity.onNativeKeyUp(keyCode);    	
+	   	}
+    }
+    
     // Sensor events
     public void enableSensor(int sensortype, boolean enabled) {
         // TODO: This uses getDefaultSensor - what if we have >1 accels?