Android: Get rid of LegacyBooleanSetting

This commit is contained in:
JosJuice 2022-02-20 13:48:06 +01:00
parent db0ca3fc96
commit 2273742f9e
4 changed files with 24 additions and 39 deletions

View File

@ -18,6 +18,14 @@ public enum BooleanSetting implements AbstractBooleanSetting
MAIN_OVERRIDE_REGION_SETTINGS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE,
"OverrideRegionSettings", false),
MAIN_AUDIO_STRETCH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AudioStretch", false),
MAIN_ADAPTER_RUMBLE_0(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AdapterRumble0", true),
MAIN_ADAPTER_RUMBLE_1(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AdapterRumble1", true),
MAIN_ADAPTER_RUMBLE_2(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AdapterRumble2", true),
MAIN_ADAPTER_RUMBLE_3(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AdapterRumble3", true),
MAIN_SIMULATE_KONGA_0(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SimulateKonga0", false),
MAIN_SIMULATE_KONGA_1(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SimulateKonga1", false),
MAIN_SIMULATE_KONGA_2(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SimulateKonga2", false),
MAIN_SIMULATE_KONGA_3(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SimulateKonga3", false),
MAIN_WII_SD_CARD(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "WiiSDCard", true),
MAIN_WIIMOTE_CONTINUOUS_SCANNING(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE,
"WiimoteContinuousScanning", false),
@ -322,4 +330,16 @@ public enum BooleanSetting implements AbstractBooleanSetting
{
NativeConfig.setBoolean(layer, mFile, mSection, mKey, newValue);
}
public static BooleanSetting getSettingForAdapterRumble(int channel)
{
return new BooleanSetting[]{MAIN_ADAPTER_RUMBLE_0, MAIN_ADAPTER_RUMBLE_1, MAIN_ADAPTER_RUMBLE_2,
MAIN_ADAPTER_RUMBLE_3}[channel];
}
public static BooleanSetting getSettingForSimulateKonga(int channel)
{
return new BooleanSetting[]{MAIN_SIMULATE_KONGA_0, MAIN_SIMULATE_KONGA_1, MAIN_SIMULATE_KONGA_2,
MAIN_SIMULATE_KONGA_3}[channel];
}
}

View File

@ -1,26 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.settings.model;
public class LegacyBooleanSetting extends AbstractLegacySetting implements AbstractBooleanSetting
{
private final boolean mDefaultValue;
public LegacyBooleanSetting(String file, String section, String key, boolean defaultValue)
{
super(file, section, key);
mDefaultValue = defaultValue;
}
@Override
public boolean getBoolean(Settings settings)
{
return settings.getSection(mFile, mSection).getBoolean(mKey, mDefaultValue);
}
@Override
public void setBoolean(Settings settings, boolean newValue)
{
settings.getSection(mFile, mSection).setBoolean(mKey, newValue);
}
}

View File

@ -16,7 +16,6 @@ import org.dolphinemu.dolphinemu.features.settings.model.AdHocBooleanSetting;
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.LegacyBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.LegacyStringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.PostProcessing;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -865,15 +864,10 @@ public final class SettingsFragmentPresenter
}
else if (gcPadType == 12) // Adapter
{
LegacyBooleanSetting rumble = new LegacyBooleanSetting(Settings.FILE_DOLPHIN,
Settings.SECTION_INI_CORE, SettingsFile.KEY_GCADAPTER_RUMBLE + gcPadNumber, false);
LegacyBooleanSetting bongo = new LegacyBooleanSetting(Settings.FILE_DOLPHIN,
Settings.SECTION_INI_CORE, SettingsFile.KEY_GCADAPTER_BONGOS + gcPadNumber, false);
sl.add(new CheckBoxSetting(mContext, rumble, R.string.gc_adapter_rumble,
R.string.gc_adapter_rumble_description));
sl.add(new CheckBoxSetting(mContext, bongo, R.string.gc_adapter_bongos,
R.string.gc_adapter_bongos_description));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.getSettingForAdapterRumble(gcPadNumber),
R.string.gc_adapter_rumble, R.string.gc_adapter_rumble_description));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.getSettingForSimulateKonga(gcPadNumber),
R.string.gc_adapter_bongos, R.string.gc_adapter_bongos_description));
}
}

View File

@ -43,9 +43,6 @@ public final class SettingsFile
public static final String KEY_GCBIND_DPAD_LEFT = "DPadLeft_";
public static final String KEY_GCBIND_DPAD_RIGHT = "DPadRight_";
public static final String KEY_GCADAPTER_RUMBLE = "AdapterRumble";
public static final String KEY_GCADAPTER_BONGOS = "SimulateKonga";
public static final String KEY_EMU_RUMBLE = "EmuRumble";
public static final String KEY_WIIMOTE_EXTENSION = "Extension";