Migrate game INI profile setting to new config system

This commit is contained in:
JosJuice 2023-03-11 17:14:01 +01:00
parent 62ff2f1030
commit 53e7090f55
10 changed files with 16 additions and 69 deletions

View File

@ -1,37 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.settings.model;
import androidx.annotation.NonNull;
public class AbstractLegacySetting implements AbstractSetting
{
protected final String mFile;
protected final String mSection;
protected final String mKey;
public AbstractLegacySetting(String file, String section, String key)
{
mFile = file;
mSection = section;
mKey = key;
}
@Override
public boolean isOverridden(@NonNull Settings settings)
{
return settings.isGameSpecific() && settings.getSection(mFile, mSection).exists(mKey);
}
@Override
public boolean isRuntimeEditable()
{
return false;
}
@Override
public boolean delete(@NonNull Settings settings)
{
return settings.getSection(mFile, mSection).delete(mKey);
}
}

View File

@ -1,28 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.settings.model;
import androidx.annotation.NonNull;
public class LegacyStringSetting extends AbstractLegacySetting implements AbstractStringSetting
{
private final String mDefaultValue;
public LegacyStringSetting(String file, String section, String key, String defaultValue)
{
super(file, section, key);
mDefaultValue = defaultValue;
}
@NonNull @Override
public String getString(@NonNull Settings settings)
{
return settings.getSection(mFile, mSection).getString(mKey, mDefaultValue);
}
@Override
public void setString(@NonNull Settings settings, @NonNull String newValue)
{
settings.getSection(mFile, mSection).setString(mKey, newValue);
}
}

View File

@ -26,6 +26,7 @@ public class Settings implements Closeable
public static final String FILE_GFX = "GFX"; public static final String FILE_GFX = "GFX";
public static final String FILE_LOGGER = "Logger"; public static final String FILE_LOGGER = "Logger";
public static final String FILE_WIIMOTE = "WiimoteNew"; public static final String FILE_WIIMOTE = "WiimoteNew";
public static final String FILE_GAME_SETTINGS_ONLY = "GameSettingsOnly";
public static final String SECTION_INI_ANDROID = "Android"; public static final String SECTION_INI_ANDROID = "Android";
public static final String SECTION_INI_ANDROID_OVERLAY_BUTTONS = "AndroidOverlayButtons"; public static final String SECTION_INI_ANDROID_OVERLAY_BUTTONS = "AndroidOverlayButtons";

View File

@ -29,10 +29,10 @@ import org.dolphinemu.dolphinemu.features.input.ui.ProfileDialogPresenter;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AdHocBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.AdHocBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AdHocStringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.FloatSetting; import org.dolphinemu.dolphinemu.features.settings.model.FloatSetting;
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.LegacyStringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.PostProcessing; import org.dolphinemu.dolphinemu.features.settings.model.PostProcessing;
import org.dolphinemu.dolphinemu.features.settings.model.ScaledIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.ScaledIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -1198,7 +1198,7 @@ public final class SettingsFragmentPresenter
String[] profiles = new ProfileDialogPresenter(mMenuTag).getProfileNames(false); String[] profiles = new ProfileDialogPresenter(mMenuTag).getProfileNames(false);
String profileKey = profileString + "Profile" + controllerNumber; String profileKey = profileString + "Profile" + controllerNumber;
sl.add(new StringSingleChoiceSetting(mContext, sl.add(new StringSingleChoiceSetting(mContext,
new LegacyStringSetting("", "Controls", profileKey, ""), new AdHocStringSetting(Settings.FILE_GAME_SETTINGS_ONLY, "Controls", profileKey, ""),
R.string.input_profile, 0, profiles, profiles, R.string.input_profiles_empty)); R.string.input_profile, 0, profiles, profiles, R.string.input_profiles_empty));
} }

View File

@ -43,6 +43,10 @@ static Config::Location GetLocation(JNIEnv* env, jstring file, jstring section,
{ {
system = Config::System::WiiPad; system = Config::System::WiiPad;
} }
else if (decoded_file == "GameSettingsOnly")
{
system = Config::System::GameSettingsOnly;
}
else else
{ {
ASSERT(false); ASSERT(false);

View File

@ -159,7 +159,8 @@ static const std::map<System, std::string> system_to_name = {
{System::SYSCONF, "SYSCONF"}, {System::SYSCONF, "SYSCONF"},
{System::DualShockUDPClient, "DualShockUDPClient"}, {System::DualShockUDPClient, "DualShockUDPClient"},
{System::FreeLook, "FreeLook"}, {System::FreeLook, "FreeLook"},
{System::Session, "Session"}}; {System::Session, "Session"},
{System::GameSettingsOnly, "GameSettingsOnly"}};
const std::string& GetSystemName(System system) const std::string& GetSystemName(System system)
{ {

View File

@ -33,6 +33,7 @@ enum class System
DualShockUDPClient, DualShockUDPClient,
FreeLook, FreeLook,
Session, Session,
GameSettingsOnly,
}; };
constexpr std::array<LayerType, 7> SEARCH_ORDER{{ constexpr std::array<LayerType, 7> SEARCH_ORDER{{

View File

@ -159,6 +159,9 @@ public:
if (location.system == Config::System::Session) if (location.system == Config::System::Session)
continue; continue;
if (location.system == Config::System::GameSettingsOnly)
continue;
auto ini = inis.find(location.system); auto ini = inis.find(location.system);
if (ini == inis.end()) if (ini == inis.end())
{ {

View File

@ -104,6 +104,7 @@ static const INIToSectionMap& GetINIToSectionMap()
{"Video_Stereoscopy", {Config::System::GFX, "Stereoscopy"}}, {"Video_Stereoscopy", {Config::System::GFX, "Stereoscopy"}},
{"Video_Hacks", {Config::System::GFX, "Hacks"}}, {"Video_Hacks", {Config::System::GFX, "Hacks"}},
{"Video", {Config::System::GFX, "GameSpecific"}}, {"Video", {Config::System::GFX, "GameSpecific"}},
{"Controls", {Config::System::GameSettingsOnly, "Controls"}},
}; };
return ini_to_section; return ini_to_section;
} }

View File

@ -18,7 +18,8 @@ bool IsSettingSaveable(const Config::Location& config_location)
{ {
for (Config::System system : for (Config::System system :
{Config::System::SYSCONF, Config::System::GFX, Config::System::DualShockUDPClient, {Config::System::SYSCONF, Config::System::GFX, Config::System::DualShockUDPClient,
Config::System::Logger, Config::System::FreeLook, Config::System::Main}) Config::System::Logger, Config::System::FreeLook, Config::System::Main,
Config::System::GameSettingsOnly})
{ {
if (config_location.system == system) if (config_location.system == system)
return true; return true;