Permalink
Browse files

front: Show popup dialog if multi-player mapping is needed.

  • Loading branch information...
littleguy77 committed Jun 8, 2015
1 parent 18991b0 commit 0488d08091f1c7bd6a19c633aa6cf6c8f32defab
View
@@ -398,6 +398,7 @@
<!-- Player Map Preferences -->
<string name="playerMap_title">Multi-player</string>
<string name="playerMap_summary">Define each player\'s controller(s)</string>
+ <string name="playerMap_needed">Please define multi-player controller mappings in game settings</string>
<!-- Profile Preferences -->
<string name="emulationProfile_title">Emulation profile</string>
@@ -45,6 +45,8 @@
import paulscode.android.mupen64plusae.task.ComputeMd5Task;
import paulscode.android.mupen64plusae.task.ComputeMd5Task.ComputeMd5Listener;
import paulscode.android.mupen64plusae.util.Notifier;
+import paulscode.android.mupen64plusae.util.RomDatabase;
+import paulscode.android.mupen64plusae.util.RomDatabase.RomDetail;
import paulscode.android.mupen64plusae.util.RomHeader;
import android.annotation.TargetApi;
import android.content.Context;
@@ -754,29 +756,32 @@ public void launchGameActivity( String romPath, String romMd5, boolean isRestart
{
RomHeader romHeader = new RomHeader( romPath );
GamePrefs gamePrefs = new GamePrefs( this, romMd5, romHeader );
+
+ // Popup the multi-player dialog if necessary and abort if any players are unassigned
+ RomDatabase romDatabase = new RomDatabase( mAppData.mupen64plus_ini );
+ RomDetail romDetail = romDatabase.lookupByMd5WithFallback( romMd5, new File( romPath ) );
+ if( romDetail.players > 1 && gamePrefs.playerMap.isEnabled()
+ && mGlobalPrefs.getPlayerMapReminder() )
+ {
+ gamePrefs.playerMap.removeUnavailableMappings();
+ boolean needs1 = gamePrefs.isControllerEnabled1 && !gamePrefs.playerMap.isMapped( 1 );
+ boolean needs2 = gamePrefs.isControllerEnabled2 && !gamePrefs.playerMap.isMapped( 2 );
+ boolean needs3 = gamePrefs.isControllerEnabled3 && !gamePrefs.playerMap.isMapped( 3 )
+ && romDetail.players > 2;
+ boolean needs4 = gamePrefs.isControllerEnabled4 && !gamePrefs.playerMap.isMapped( 4 )
+ && romDetail.players > 3;
+
+ if( needs1 || needs2 || needs3 || needs4 )
+ {
// TODO FIXME
-// // Popup the multi-player dialog if necessary and abort if any players are unassigned
-// RomDatabase romDatabase = new RomDatabase( mAppData.mupen64plus_ini );
-// RomDetail romDetail = romDatabase.lookupByMd5WithFallback( romMd5, new File( romPath ) );
-// if( romDetail.players > 1 && gamePrefs.playerMap.isEnabled()
-// && mGlobalPrefs.getPlayerMapReminder() )
-// {
-// gamePrefs.playerMap.removeUnavailableMappings();
-// boolean needs1 = gamePrefs.isControllerEnabled1 && !gamePrefs.playerMap.isMapped( 1 );
-// boolean needs2 = gamePrefs.isControllerEnabled2 && !gamePrefs.playerMap.isMapped( 2 );
-// boolean needs3 = gamePrefs.isControllerEnabled3 && !gamePrefs.playerMap.isMapped( 3 )
-// && romDetail.players > 2;
-// boolean needs4 = gamePrefs.isControllerEnabled4 && !gamePrefs.playerMap.isMapped( 4 )
-// && romDetail.players > 3;
-//
-// if( needs1 || needs2 || needs3 || needs4 )
-// {
-// @SuppressWarnings( "deprecation" )
-// PlayerMapPreference pref = (PlayerMapPreference) findPreference( "playerMap" );
-// pref.show();
-// return;
-// }
-// }
+// @SuppressWarnings( "deprecation" )
+// PlayerMapPreference pref = (PlayerMapPreference) findPreference( "playerMap" );
+// pref.show();
+// return;
+ Popups.showNeedsPlayerMap( this );
+ return;
+ }
+ }
// Make sure that the storage is accessible
if( !mAppData.isSdCardAccessible() )
@@ -89,4 +89,11 @@ public static void showAppVersion( Context context )
appData.appVersionCode );
new Builder( context ).setTitle( title ).setMessage( message ).create().show();
}
+
+ public static void showNeedsPlayerMap( Context context )
+ {
+ String title = context.getString( R.string.playerMap_title );
+ String message = context.getString( R.string.playerMap_needed );
+ new Builder( context ).setTitle( title ).setMessage( message ).create().show();
+ }
}

0 comments on commit 0488d08

Please sign in to comment.