Permalink
Browse files

Front: Moved "Buttons style" option to touchscreen profile + added cu…

…stom layout option

All custom layouts must be placed in the "CustomSkins" directory
  • Loading branch information...
Gillou68310
Gillou68310 committed Oct 19, 2015
1 parent ef22219 commit 39eef0916fa798c454b4261705ad874958ffbbd2
@@ -37,6 +37,23 @@
</group>
</menu>
</item>
<item
android:id="@+id/menuItem_skins"
android:title="@string/touchscreenStyle_title">
<menu>
<group android:checkableBehavior="none" >
<item
android:id="@+id/menuItem_outline"
android:title="@string/touchscreenStyle_entryOutline"/>
<item
android:id="@+id/menuItem_shaded"
android:title="@string/touchscreenStyle_entryShaded"/>
<item
android:id="@+id/menuItem_custom"
android:title="@string/touchscreenStyle_entryCustom"/>
</group>
</menu>
</item>
<item
android:id="@+id/menuItem_exit"
android:title="@string/menuItem_exit"/>
View
@@ -63,25 +63,6 @@
<string name="touchscreenAutoHold_default" translatable="false">2</string>
<!-- Touchscreen Auto-Holdable Buttons -->
<!-- Touchscreen Button Styles -->
<string-array name="touchscreenStyle_entries" translatable="false">
<item>@string/touchscreenStyle_entryOutline</item>
<item>@string/touchscreenStyle_entryShaded</item>
</string-array>
<string-array name="touchscreenStyle_values" translatable="false">
<item>Outline</item>
<item>Shaded</item>
</string-array>
<string name="touchscreenStyle_default" translatable="false">Outline</string>
<!-- Touchscreen Layout Heights -->
<!-- Touchscreen Layouts -->
<string name="touchscreenLayout_fpsOnly" translatable="false">Mupen64Plus-AE-Just-FPS</string>
<!-- Xperia Play Touchpad Layouts -->
<string-array name="touchpadLayout_entries" translatable="false">
<item>@string/touchpadLayout_entryDefault</item>
View
@@ -251,6 +251,7 @@
<string name="touchscreenStyle_title">Button style</string>
<string name="touchscreenStyle_entryOutline">Outlines</string>
<string name="touchscreenStyle_entryShaded">Shaded</string>
<string name="touchscreenStyle_entryCustom">Custom</string>
<string name="touchpadLayout_title">Touchpad layout</string>
<string name="touchpadLayout_entryDefault">Left pad: Analog control; Right pad: C buttons</string>
@@ -184,14 +184,6 @@
mupen64:stepSize="1"
mupen64:units="%" />
<paulscode.android.mupen64plusae.preference.CompatibleListPreference
android:defaultValue="@string/touchscreenStyle_default"
android:entries="@array/touchscreenStyle_entries"
android:entryValues="@array/touchscreenStyle_values"
android:key="touchscreenStyle"
android:summary="@string/selectedValue"
android:title="@string/touchscreenStyle_title" />
<paulscode.android.mupen64plusae.preference.SeekBarPreference
android:defaultValue="100"
android:key="touchscreenTransparency"
@@ -96,7 +96,6 @@
private static final String AUDIO_SDL_BUFFER_SIZE = "audioSDLBufferSize";
private static final String AUDIO_SLES_BUFFER_SIZE = "audioSLESBufferSize";
private static final String AUDIO_SLES_BUFFER_NBR = "audioSLESBufferNbr";
private static final String TOUCHSCREEN_STYLE = "touchscreenStyle";
private static final String TOUCHSCREEN_AUTO_HOLD = "touchscreenAutoHold";
private static final String TOUCHPAD_LAYOUT = "touchpadLayout";
private static final String NAVIGATION_MODE = "navigationMode";
@@ -133,7 +132,6 @@ public void onCreate( Bundle savedInstanceState )
PrefUtil.validateListPreference( res, mPrefs, AUDIO_SDL_BUFFER_SIZE, R.string.audioSDLBufferSize_default, R.array.audioSDLBufferSize_values );
PrefUtil.validateListPreference( res, mPrefs, AUDIO_SLES_BUFFER_SIZE, R.string.audioSLESBufferSize_default, R.array.audioSLESBufferSize_values );
PrefUtil.validateListPreference( res, mPrefs, AUDIO_SLES_BUFFER_NBR, R.string.audioSLESBufferNbr_default, R.array.audioSLESBufferNbr_values );
PrefUtil.validateListPreference( res, mPrefs, TOUCHSCREEN_STYLE, R.string.touchscreenStyle_default, R.array.touchscreenStyle_values );
PrefUtil.validateListPreference( res, mPrefs, TOUCHSCREEN_AUTO_HOLD, R.string.touchscreenAutoHold_default, R.array.touchscreenAutoHold_values );
PrefUtil.validateListPreference( res, mPrefs, TOUCHPAD_LAYOUT, R.string.touchpadLayout_default, R.array.touchpadLayout_values );
PrefUtil.validateListPreference( res, mPrefs, NAVIGATION_MODE, R.string.navigationMode_default, R.array.navigationMode_values );
@@ -142,6 +140,9 @@ public void onCreate( Bundle savedInstanceState )
// Refresh the preference data wrapper
mGlobalPrefs = new GlobalPrefs( this, mAppData );
// Make sure custom skin directory exist
new File( mGlobalPrefs.touchscreenCustomSkinsDir ).mkdirs();
// Initialize the OUYA interface if running on OUYA
if( AppData.IS_OUYA_HARDWARE )
OuyaFacade.getInstance().init( this, DEVELOPER_ID );
@@ -376,6 +376,21 @@ public static void promptFile( Context context, CharSequence title, CharSequence
promptFile( context, title, message, startPath, false, false, true, false, listener );
}
/**
* Open a dialog to prompt the user for a directory.
*
* @param context The activity context.
* @param title The title of the dialog.
* @param message The message to be shown inside the dialog.
* @param startPath The directory holding the directory to select from.
* @param listener The listener to process the directory, when selected.
*/
public static void promptDirectory( Context context, CharSequence title, CharSequence message,
File startPath, final PromptFileListener listener )
{
promptFile( context, title, message, startPath, false, true, false, false, listener );
}
/**
* Open a dialog to prompt the user for text.
*
@@ -260,7 +260,7 @@ public void onCreateEnd( Bundle savedInstanceState )
{
// The touch map and overlay are needed to display frame rate and/or controls
mTouchscreenMap = new VisibleTouchMap( mActivity.getResources() );
mTouchscreenMap.load( mGlobalPrefs.touchscreenSkin, mGamePrefs.touchscreenProfile,
mTouchscreenMap.load( mGamePrefs.touchscreenSkin, mGamePrefs.touchscreenProfile,
mGamePrefs.isTouchscreenAnimated, mGlobalPrefs.isFpsEnabled,
mGlobalPrefs.touchscreenScale, mGlobalPrefs.touchscreenTransparency );
mOverlay.initialize( mTouchscreenMap, !mGamePrefs.isTouchscreenHidden,
@@ -147,11 +147,8 @@
/** True if the touchscreen overlay is hidden. */
public final boolean isTouchscreenHidden;
/** The folder name of the selected touchscreen layout. */
public final String touchscreenLayout;
/** True if a custom touchscreen is provided. */
public final boolean isTouchscreenCustom;
/** The directory of the selected touchscreen skin. */
public final String touchscreenSkin;
/** True if Player 1's controller is enabled. */
public final boolean isControllerEnabled1;
@@ -268,84 +265,30 @@ public GamePrefs( Context context, String romMd5, String crc, String headerName,
// Touchscreen prefs
isTouchscreenEnabled = touchscreenProfile != null;
isTouchscreenAnimated = touchscreenProfile.get( "touchscreenAnimated", "False" ).equals( "True" );
// Determine the touchscreen layout
boolean isCustom = false;
String folder = "";
if( isTouchscreenEnabled )
if ( isTouchscreenEnabled )
{
isTouchscreenAnimated = touchscreenProfile.get( "touchscreenAnimated", "False" ).equals( "True" );
// Determine the touchscreen auto-holdables
touchscreenAutoHoldables = getSafeIntSet( touchscreenProfile,
"touchscreenAutoHoldables" );
String layout = touchscreenProfile.get( "touchscreenLayout", "" );
// Determine the touchscreen layout
String layout = touchscreenProfile.get( "touchscreenSkin", "Outline" );
if( layout.equals( "Custom" ) )
{
isCustom = true;
folder = touchscreenProfile.get( "pathCustomTouchscreen", "" );
}
touchscreenSkin = touchscreenProfile.get( "touchscreenCustomSkinPath", "" );
else
{
// Use the "No-stick" skin if analog input is shown but stick ("hat") is not
// animated
if( layout.equals( "Mupen64Plus-AE-Analog" )
|| layout.equals( "Mupen64Plus-AE-All" ) )
{
if( isTouchscreenAnimated )
layout += "-Stick";
else
layout += "-Nostick";
}
String height = touchscreenProfile.get( "touchscreenHeight", "" );
if( TextUtils.isEmpty( height ) )
{
// Use the "Tablet" skin if the device is a tablet or is in portrait orientation
if( context instanceof Activity )
{
DisplayMetrics metrics = new DisplayMetrics();
( (Activity) context ).getWindowManager().getDefaultDisplay()
.getMetrics( metrics );
float screenWidthInches = (float) metrics.widthPixels
/ (float) metrics.xdpi;
float screenHeightInches = (float) metrics.heightPixels
/ (float) metrics.ydpi;
float screenSizeInches = (float) Math
.sqrt( ( screenWidthInches * screenWidthInches )
+ ( screenHeightInches * screenHeightInches ) );
if( screenSizeInches >= Utility.MINIMUM_TABLET_SIZE
|| globalPrefs.displayOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|| globalPrefs.displayOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT )
{
layout += "-Half-Height";
}
else
{
layout += "-Full-Height";
}
}
}
else
{
layout += height;
}
folder = appData.touchscreenSkinsDir + layout;
}
touchscreenSkin = appData.touchscreenSkinsDir + layout;
}
else
{
// Touchscreen disabled, profile is null
if( globalPrefs.isFpsEnabled )
{
folder = appData.touchscreenSkinsDir
+ context.getString( R.string.touchscreenLayout_fpsOnly );
}
isTouchscreenAnimated = false;
touchscreenAutoHoldables = null;
touchscreenSkin = "";
}
isTouchscreenHidden = !isTouchscreenEnabled || globalPrefs.touchscreenTransparency == 0;
isTouchscreenCustom = isCustom;
touchscreenLayout = folder;
// Determine which peripheral controllers are enabled
isControllerEnabled1 = controllerProfile1 != null;
@@ -112,6 +112,9 @@
/** The subdirectory where hi-res textures must be unzipped. */
public final String hiResTextureDir;
/** The directory containing all custom touchscreen skin folders. */
public final String touchscreenCustomSkinsDir;
/** The path of the rom info cache for the gallery. */
public final String romInfoCache_cfg;
@@ -145,9 +148,6 @@
/** True if the touchscreen feedback is enabled. */
public final boolean isTouchscreenFeedbackEnabled;
/** The directory of the selected touchscreen skin. */
public final String touchscreenSkin;
/** The touchscreen transparency value. */
public final int touchscreenTransparency;
@@ -316,6 +316,7 @@ public GlobalPrefs( Context context, AppData appData )
touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg";
emulationProfiles_cfg = profilesDir + "/emulation.cfg";
customCheats_txt = profilesDir + "/customCheats.txt";
touchscreenCustomSkinsDir = userDataDir + "/CustomSkins";
// Plug-ins
audioPlugin = new Plugin( mPreferences, appData.libsDir, "audioPlugin" );
@@ -328,7 +329,6 @@ public GlobalPrefs( Context context, AppData appData )
isTouchscreenFeedbackEnabled = mPreferences.getBoolean( "touchscreenFeedback", false );
touchscreenScale = ( (float) mPreferences.getInt( "touchscreenScale", 100 ) ) / 100.0f;
touchscreenTransparency = ( 255 * mPreferences.getInt( "touchscreenTransparency", 100 ) ) / 100;
touchscreenSkin = appData.touchscreenSkinsDir + "/" + mPreferences.getString( "touchscreenStyle", "Outline" );
touchscreenAutoHold = getSafeInt( mPreferences, "touchscreenAutoHold", 0 );
// Xperia PLAY touchpad prefs
@@ -20,10 +20,14 @@
*/
package paulscode.android.mupen64plusae.profile;
import java.io.File;
import org.apache.commons.lang.ArrayUtils;
import org.mupen64plusae.v3.alpha.R;
import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.dialog.Prompt;
import paulscode.android.mupen64plusae.dialog.Prompt.PromptFileListener;
import paulscode.android.mupen64plusae.dialog.SeekBarGroup;
import paulscode.android.mupen64plusae.game.GameOverlay;
import paulscode.android.mupen64plusae.input.AbstractController;
@@ -91,6 +95,7 @@
// User preferences wrapper
private GlobalPrefs mGlobalPrefs;
private AppData mAppData;
// Visual elements
private VisibleTouchMap mTouchscreenMap;
@@ -110,6 +115,9 @@
// Don't enter immersive mode until the ActionBar menus are closed
private boolean actionBarMenuOpen = false;
// The directory of the selected touchscreen skin.
private String touchscreenSkin;
// True if the touchscreen joystick is animated
private boolean isTouchscreenAnimated;
@@ -121,8 +129,8 @@ protected void onCreate( Bundle savedInstanceState )
super.onCreate( savedInstanceState );
// Get the user preferences wrapper
AppData appData = new AppData( this );
mGlobalPrefs = new GlobalPrefs( this, appData );
mAppData = new AppData( this );
mGlobalPrefs = new GlobalPrefs( this, mAppData );
mGlobalPrefs.enforceLocale( this );
// Load the profile; fail fast if there are any programmer usage errors
@@ -186,7 +194,11 @@ public void onMenuVisibilityChanged( boolean isVisible )
});
}
isTouchscreenAnimated = mProfile.get( "touchscreenAnimated", "False" ).equals( "True" );
String layout = mProfile.get( "touchscreenSkin", "Outline" );
if( layout.equals( "Custom" ) )
touchscreenSkin = mProfile.get( "touchscreenCustomSkinPath", "" );
else
touchscreenSkin = mAppData.touchscreenSkinsDir + layout;
// Initialize the touchmap and overlay
mTouchscreenMap = new VisibleTouchMap( getResources() );
@@ -198,7 +210,7 @@ public void onMenuVisibilityChanged( boolean isVisible )
private void refresh()
{
// Reposition the assets and refresh the overlay and options menu
mTouchscreenMap.load( mGlobalPrefs.touchscreenSkin, mProfile,
mTouchscreenMap.load( touchscreenSkin, mProfile,
isTouchscreenAnimated, true, mGlobalPrefs.touchscreenScale,
mGlobalPrefs.touchscreenTransparency );
mOverlay.postInvalidate();
@@ -318,6 +330,19 @@ public boolean onOptionsItemSelected( MenuItem item )
case R.id.menuItem_buttonS:
toggleAsset( BUTTON_S );
return true;
case R.id.menuItem_outline:
touchscreenSkin = mAppData.touchscreenSkinsDir + "Outline";
mProfile.put( "touchscreenSkin", "Outline" );
refresh();
return true;
case R.id.menuItem_shaded:
touchscreenSkin = mAppData.touchscreenSkinsDir + "Shaded";
mProfile.put( "touchscreenSkin", "Shaded" );
refresh();
return true;
case R.id.menuItem_custom:
loadCustomSkinFromPrompt();
return true;
default:
return super.onOptionsItemSelected( item );
}
@@ -332,6 +357,26 @@ private void toggleAsset( String assetName )
refresh();
}
private void loadCustomSkinFromPrompt()
{
CharSequence title = this.getText( R.string.touchscreenStyle_entryCustom );
File startPath = new File( mGlobalPrefs.touchscreenCustomSkinsDir );
Prompt.promptDirectory( this, title, null, startPath, new PromptFileListener()
{
@Override
public void onDialogClosed( File file, int which )
{
if( which >= 0 )
{
touchscreenSkin = file.getAbsolutePath();
mProfile.put( "touchscreenSkin", "Custom" );
mProfile.put( "touchscreenCustomSkinPath", touchscreenSkin );
refresh();
}
}
} );
}
private void setHoldable( int n64Index, boolean holdable )
{
String index = String.valueOf( n64Index );

0 comments on commit 39eef09

Please sign in to comment.