Skip to content

Commit

Permalink
Android: Add Set as Default ISO to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Meredith committed Mar 22, 2019
1 parent fcd0dbe commit 462cf6c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -18,14 +19,16 @@ public class GameSettingsDialog extends DialogFragment
{
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);

Expand All @@ -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))
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public final class SettingsFile
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";
Expand Down Expand Up @@ -649,6 +650,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.
Expand Down
2 changes: 2 additions & 0 deletions Source/Android/app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,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 462cf6c

Please sign in to comment.