Permalink
Browse files

Front: Moved resolution and zoom options to game preference activity

  • Loading branch information...
Gillou68310
Gillou68310 committed Oct 28, 2015
1 parent 3d48a0f commit 38c045bb9ee7743f69bba7a0e0e735d9b051e964
@@ -2,7 +2,29 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mupen64="http://schemas.android.com/apk/res/org.mupen64plusae.v3.alpha"
android:key="screenRoot" >
<PreferenceScreen
android:icon="@drawable/ic_display"
android:key="screenDisplay"
android:title="@string/categoryDisplay_title" >
<paulscode.android.mupen64plusae.preference.CompatibleListPreference
android:defaultValue="@string/displayResolution_default"
android:entries="@array/displayResolution_entries"
android:entryValues="@array/displayResolution_values"
android:key="displayResolution"
android:summary="@string/selectedValue"
android:title="@string/displayResolution_title" />
<paulscode.android.mupen64plusae.preference.CompatibleListPreference
android:defaultValue="@string/displayZoom_default"
android:entries="@array/displayZoom_entries"
android:entryValues="@array/displayZoom_values"
android:key="displayZoom"
android:summary="@string/selectedValue"
android:title="@string/displayZoom_title" />
</PreferenceScreen>
<paulscode.android.mupen64plusae.preference.ProfilePreference
android:icon="@drawable/ic_circuit"
android:key="emulationProfile"
@@ -10,21 +10,6 @@
android:key="r4300Emulator"
android:summary="@string/selectedValue"
android:title="@string/r4300Emulator_title" />
<paulscode.android.mupen64plusae.preference.StringSeekBarPreference
android:defaultValue="100"
android:key="videoResolution"
android:title="@string/displayResolution_title"
mupen64:maximumValue="100"
mupen64:minimumValue="1"
mupen64:stepSize="1"
mupen64:units="%" />
<paulscode.android.mupen64plusae.preference.CompatibleListPreference
android:defaultValue="@string/displayZoom_default"
android:entries="@array/displayZoom_entries"
android:entryValues="@array/displayZoom_values"
android:key="displayZoom"
android:summary="@string/selectedValue"
android:title="@string/displayZoom_title" />
<paulscode.android.mupen64plusae.preference.CompatibleListPreference
android:defaultValue="@string/videoPlugin_default"
android:entries="@array/videoPlugin_entries"
@@ -261,7 +261,12 @@ public void onCreateEnd( Bundle savedInstanceState )
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mSurface.getLayoutParams();
params.width = Math.round ( (float) mGlobalPrefs.videoSurfaceWidth * ( (float) mGamePrefs.videoSurfaceZoom / 100.f ) );
params.height = Math.round ( (float) mGlobalPrefs.videoSurfaceHeight * ( (float) mGamePrefs.videoSurfaceZoom / 100.f ) );
params.gravity = mGlobalPrefs.displayPosition | Gravity.CENTER_HORIZONTAL;
if( (mGlobalPrefs.displayOrientation & 1) == 1 )
params.gravity = mGlobalPrefs.displayPosition | Gravity.CENTER_HORIZONTAL;
else
params.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL;
mSurface.setLayoutParams( params );
// Initialize the screen elements
@@ -267,11 +267,41 @@ public GamePrefs( Context context, String romMd5, String crc, String headerName,
glide64MaxFrameskip = Math.abs( maxFrameskip );
// Display prefs
int resolution = getSafeInt( emulationProfile, "videoResolution", 100 );
videoRenderWidth = Math.round( ( float ) ( globalPrefs.videoSurfaceWidth * resolution ) / 100.f );
videoRenderHeight = Math.round( ( float ) ( globalPrefs.videoSurfaceHeight * resolution ) / 100.f );
int hResolution = getSafeInt( mPreferences, "displayResolution", 0 );
videoSurfaceZoom = getSafeInt( emulationProfile, "displayZoom", 100 );
switch( hResolution )
{
case 720:
videoRenderWidth = 960;
videoRenderHeight = 720;
break;
case 600:
videoRenderWidth = 800;
videoRenderHeight = 600;
break;
case 480:
videoRenderWidth = 640;
videoRenderHeight = 480;
break;
case 360:
videoRenderWidth = 480;
videoRenderHeight = 360;
break;
case 240:
videoRenderWidth = 320;
videoRenderHeight = 240;
break;
case 120:
videoRenderWidth = 160;
videoRenderHeight = 120;
break;
default:
videoRenderWidth = globalPrefs.videoSurfaceWidth;
videoRenderHeight = globalPrefs.videoSurfaceHeight;
break;
}
videoSurfaceZoom = getSafeInt( mPreferences, "displayZoom", 100 );
// Touchscreen prefs
isTouchscreenEnabled = touchscreenProfile != null;
@@ -399,6 +429,18 @@ private static int getSafeInt( Profile profile, String key, int defaultValue )
}
}
private static int getSafeInt( SharedPreferences preferences, String key, int defaultValue )
{
try
{
return Integer.parseInt( preferences.getString( key, String.valueOf( defaultValue ) ) );
}
catch( NumberFormatException ex )
{
return defaultValue;
}
}
private static Set<Integer> getSafeIntSet( Profile profile, String key )
{
Set<Integer> mutableSet = new HashSet<Integer>();

0 comments on commit 38c045b

Please sign in to comment.