Migrate game INI profile setting to new config system
This commit is contained in:
parent
62ff2f1030
commit
53e7090f55
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ public class Settings implements Closeable
|
|||
public static final String FILE_GFX = "GFX";
|
||||
public static final String FILE_LOGGER = "Logger";
|
||||
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_OVERLAY_BUTTONS = "AndroidOverlayButtons";
|
||||
|
|
|
@ -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.AbstractIntSetting;
|
||||
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.FloatSetting;
|
||||
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.ScaledIntSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
|
@ -1198,7 +1198,7 @@ public final class SettingsFragmentPresenter
|
|||
String[] profiles = new ProfileDialogPresenter(mMenuTag).getProfileNames(false);
|
||||
String profileKey = profileString + "Profile" + controllerNumber;
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,10 @@ static Config::Location GetLocation(JNIEnv* env, jstring file, jstring section,
|
|||
{
|
||||
system = Config::System::WiiPad;
|
||||
}
|
||||
else if (decoded_file == "GameSettingsOnly")
|
||||
{
|
||||
system = Config::System::GameSettingsOnly;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(false);
|
||||
|
|
|
@ -159,7 +159,8 @@ static const std::map<System, std::string> system_to_name = {
|
|||
{System::SYSCONF, "SYSCONF"},
|
||||
{System::DualShockUDPClient, "DualShockUDPClient"},
|
||||
{System::FreeLook, "FreeLook"},
|
||||
{System::Session, "Session"}};
|
||||
{System::Session, "Session"},
|
||||
{System::GameSettingsOnly, "GameSettingsOnly"}};
|
||||
|
||||
const std::string& GetSystemName(System system)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ enum class System
|
|||
DualShockUDPClient,
|
||||
FreeLook,
|
||||
Session,
|
||||
GameSettingsOnly,
|
||||
};
|
||||
|
||||
constexpr std::array<LayerType, 7> SEARCH_ORDER{{
|
||||
|
|
|
@ -159,6 +159,9 @@ public:
|
|||
if (location.system == Config::System::Session)
|
||||
continue;
|
||||
|
||||
if (location.system == Config::System::GameSettingsOnly)
|
||||
continue;
|
||||
|
||||
auto ini = inis.find(location.system);
|
||||
if (ini == inis.end())
|
||||
{
|
||||
|
|
|
@ -104,6 +104,7 @@ static const INIToSectionMap& GetINIToSectionMap()
|
|||
{"Video_Stereoscopy", {Config::System::GFX, "Stereoscopy"}},
|
||||
{"Video_Hacks", {Config::System::GFX, "Hacks"}},
|
||||
{"Video", {Config::System::GFX, "GameSpecific"}},
|
||||
{"Controls", {Config::System::GameSettingsOnly, "Controls"}},
|
||||
};
|
||||
return ini_to_section;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ bool IsSettingSaveable(const Config::Location& config_location)
|
|||
{
|
||||
for (Config::System system :
|
||||
{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)
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue