Skip to content
Permalink
Browse files

Android: Add Set as Default ISO to UI

  • Loading branch information...
Ryan Meredith authored and Ebola16 committed Mar 22, 2019
1 parent 828dc0f commit aa802eb841cfde01ae1d4476c5030097cd434775
@@ -138,6 +138,7 @@ public boolean onLongClick(View view)
FragmentActivity activity = (FragmentActivity) view.getContext();
GameViewHolder holder = (GameViewHolder) view.getTag();
String gameId = holder.gameFile.getGameId();
String gamePath = holder.gameFile.getPath();

if (gameId.isEmpty())
{
@@ -150,7 +151,7 @@ public boolean onLongClick(View view)
}

GameSettingsDialog fragment =
GameSettingsDialog.newInstance(gameId, holder.gameFile.getPlatform());
GameSettingsDialog.newInstance(gameId, gamePath, holder.gameFile.getPlatform());
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction()
.add(fragment, GameSettingsDialog.TAG).commit();
return true;
@@ -85,6 +85,7 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item)
{
FragmentActivity activity = (FragmentActivity) view.getContext();
String gameId = gameFile.getGameId();
String gamePath = holder.gameFile.getPath();

if (gameId.isEmpty())
{
@@ -97,7 +98,7 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item)
}

GameSettingsDialog fragment =
GameSettingsDialog.newInstance(gameId, holder.gameFile.getPlatform());
GameSettingsDialog.newInstance(gameId, gamePath, holder.gameFile.getPlatform());
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction()
.add(fragment, GameSettingsDialog.TAG).commit();

@@ -9,6 +9,7 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;

@@ -18,14 +19,16 @@
{
public static final String TAG = "GameSettingsDialog";
public static final String ARG_GAMEID = "game_id";
public static final String ARG_GAMEPATH = "gamePath";
public static final String ARG_PLATFORM = "platform";

public static GameSettingsDialog newInstance(String gameId, int platform)
public static GameSettingsDialog newInstance(String gameId, String gamePath, int platform)
{
GameSettingsDialog fragment = new GameSettingsDialog();

Bundle arguments = new Bundle();
arguments.putString(ARG_GAMEID, gameId);
arguments.putString(ARG_GAMEPATH, gamePath);
arguments.putInt(ARG_PLATFORM, platform);
fragment.setArguments(arguments);

@@ -38,6 +41,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());

String gameId = getArguments().getString(ARG_GAMEID);
String gamePath = getArguments().getString(ARG_GAMEPATH);
int platform = getArguments().getInt(ARG_PLATFORM);

builder.setTitle(getActivity().getString(R.string.preferences_game_settings) + ": " + gameId)
@@ -64,14 +68,24 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
SettingsActivity.launch(getActivity(), MenuTag.WIIMOTE, gameId);
break;
case 4:
clearGameSettings(gameId);
// Set as default ISO for GC, Wii clear game settings for else
if (platform == Platform.GAMECUBE.toInt())
{
SettingsFile.putDefaultISOSetting(gamePath);
Toast.makeText(getContext(), "Default ISO set", Toast.LENGTH_SHORT).show();
}
else
clearGameSettings(gameId);
break;
case 5:
SettingsFile.putDefaultISOSetting(gamePath);
Toast.makeText(getContext(), "Default ISO set", Toast.LENGTH_SHORT).show();
break;
}
});
return builder.create();
}


private void clearGameSettings(String gameId)
{
String path =
@@ -53,6 +53,7 @@
public static final String KEY_SLOT_B_DEVICE = "SlotB";
public static final String KEY_ENABLE_SAVE_STATES = "EnableSaveStates";
public static final String KEY_LOCK_LANDSCAPE = "LockLandscape";
public static final String KEY_DEFAULT_ISO = "DefaultISO";

public static final String KEY_ANALYTICS_ENABLED = "Enabled";
public static final String KEY_ANALYTICS_PERMISSION_ASKED = "PermissionAsked";
@@ -631,6 +632,23 @@ public static void firstAnalyticsAdd(boolean enabled)
saveFile(SettingsFile.FILE_NAME_DOLPHIN, saveSection, null);
}

public static void putDefaultISOSetting(String gamePath)
{
HashMap<String, SettingSection> dolphinSections =
readFile(SettingsFile.FILE_NAME_DOLPHIN, null);
SettingSection coreSection = dolphinSections.get(Settings.SECTION_INI_CORE);

Setting defaultISO =
new StringSetting(KEY_DEFAULT_ISO, Settings.SECTION_INI_CORE, gamePath);

coreSection.putSetting(defaultISO);

dolphinSections.put(Settings.SECTION_INI_CORE, coreSection);

TreeMap<String, SettingSection> saveSection = new TreeMap<>(dolphinSections);
saveFile(SettingsFile.FILE_NAME_DOLPHIN, saveSection, null);
}

/**
* For a line of text, determines what type of data is being represented, and returns
* a Setting object containing this data.
@@ -340,12 +340,14 @@
<item>GFX Settings</item>
<item>GameCube Controller Settings</item>
<item>Clear Game Settings</item>
<item>Set as Default ISO</item>
</string-array>
<string-array name="gameSettingsMenusWii">
<item>Core Settings</item>
<item>GFX Settings</item>
<item>GameCube Controller Settings</item>
<item>Wii Controller Settings</item>
<item>Clear Game Settings</item>
<item>Set as Default ISO</item>
</string-array>
</resources>

0 comments on commit aa802eb

Please sign in to comment.
You can’t perform that action at this time.