Merge pull request #11641 from JosJuice/android-remove-old-config

Android: Remove support for the old config system
This commit is contained in:
Mai 2023-03-14 15:48:04 -04:00 committed by GitHub
commit 4281606838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 388 additions and 580 deletions

View File

@ -400,7 +400,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
WindowManager.LayoutParams attributes = getWindow().getAttributes();
attributes.layoutInDisplayCutoutMode =
BooleanSetting.MAIN_EXPAND_TO_CUTOUT_AREA.getBoolean(mSettings) ?
BooleanSetting.MAIN_EXPAND_TO_CUTOUT_AREA.getBoolean() ?
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES :
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
@ -423,7 +423,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
protected void onStop()
{
super.onStop();
mSettings.saveSettings(null, null);
mSettings.saveSettings(null);
}
public void onTitleChanged()
@ -437,7 +437,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
setTitle(NativeLibrary.GetCurrentTitleDescription());
mEmulationFragment.refreshInputOverlay(mSettings);
mEmulationFragment.refreshInputOverlay();
}
@Override
@ -521,7 +521,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
private void updateOrientation()
{
setRequestedOrientation(IntSetting.MAIN_EMULATION_ORIENTATION.getInt(mSettings));
setRequestedOrientation(IntSetting.MAIN_EMULATION_ORIENTATION.getInt());
}
private boolean closeSubmenu()
@ -589,11 +589,11 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
// Populate the switch value for joystick center on touch
menu.findItem(R.id.menu_emulation_joystick_rel_center)
.setChecked(BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean(mSettings));
.setChecked(BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean());
if (wii)
{
menu.findItem(R.id.menu_emulation_ir_recenter)
.setChecked(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean(mSettings));
.setChecked(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean());
}
popup.setOnMenuItemClickListener(this::onOptionsItemSelected);
@ -794,7 +794,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
private void toggleRecenter(boolean state)
{
BooleanSetting.MAIN_IR_ALWAYS_RECENTER.setBoolean(mSettings, state);
mEmulationFragment.refreshOverlayPointer(mSettings);
mEmulationFragment.refreshOverlayPointer();
}
private void editControlsPlacement()
@ -831,7 +831,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this)
.setTitle(R.string.emulation_toggle_controls);
int currentController = InputOverlay.getConfiguredControllerType(mSettings);
int currentController = InputOverlay.getConfiguredControllerType();
if (currentController == InputOverlay.OVERLAY_GAMECUBE)
{
@ -840,7 +840,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
for (int i = 0; i < gcEnabledButtons.length; i++)
{
gcEnabledButtons[i] = BooleanSetting.valueOf(gcSettingBase + i).getBoolean(mSettings);
gcEnabledButtons[i] = BooleanSetting.valueOf(gcSettingBase + i).getBoolean();
}
builder.setMultiChoiceItems(R.array.gcpadButtons, gcEnabledButtons,
(dialog, indexSelected, isChecked) -> BooleanSetting
@ -854,7 +854,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
for (int i = 0; i < wiiClassicEnabledButtons.length; i++)
{
wiiClassicEnabledButtons[i] =
BooleanSetting.valueOf(classicSettingBase + i).getBoolean(mSettings);
BooleanSetting.valueOf(classicSettingBase + i).getBoolean();
}
builder.setMultiChoiceItems(R.array.classicButtons, wiiClassicEnabledButtons,
(dialog, indexSelected, isChecked) -> BooleanSetting
@ -868,7 +868,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
for (int i = 0; i < wiiEnabledButtons.length; i++)
{
wiiEnabledButtons[i] = BooleanSetting.valueOf(wiiSettingBase + i).getBoolean(mSettings);
wiiEnabledButtons[i] = BooleanSetting.valueOf(wiiSettingBase + i).getBoolean();
}
if (currentController == InputOverlay.OVERLAY_WIIMOTE_NUNCHUK)
{
@ -887,15 +887,15 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
builder.setNeutralButton(R.string.emulation_toggle_all,
(dialogInterface, i) -> mEmulationFragment.toggleInputOverlayVisibility(mSettings))
.setPositiveButton(R.string.ok, (dialogInterface, i) ->
mEmulationFragment.refreshInputOverlay(mSettings))
mEmulationFragment.refreshInputOverlay())
.show();
}
public void chooseDoubleTapButton()
{
int currentValue = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getInt(mSettings);
int currentValue = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getInt();
int buttonList = InputOverlay.getConfiguredControllerType(mSettings) ==
int buttonList = InputOverlay.getConfiguredControllerType() ==
InputOverlay.OVERLAY_WIIMOTE_CLASSIC ? R.array.doubleTapWithClassic : R.array.doubleTap;
int checkedItem = -1;
@ -914,7 +914,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
(DialogInterface dialog, int which) -> IntSetting.MAIN_DOUBLE_TAP_BUTTON.setInt(
mSettings, InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(which)))
.setPositiveButton(R.string.ok,
(dialogInterface, i) -> mEmulationFragment.initInputPointer(mSettings))
(dialogInterface, i) -> mEmulationFragment.initInputPointer())
.show();
}
@ -925,7 +925,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
final Slider scaleSlider = dialogBinding.inputScaleSlider;
final TextView scaleValue = dialogBinding.inputScaleValue;
scaleSlider.setValueTo(150);
scaleSlider.setValue(IntSetting.MAIN_CONTROL_SCALE.getInt(mSettings));
scaleSlider.setValue(IntSetting.MAIN_CONTROL_SCALE.getInt());
scaleSlider.setStepSize(1);
scaleSlider.addOnChangeListener(
(slider, progress, fromUser) -> scaleValue.setText(((int) progress + 50) + "%"));
@ -935,7 +935,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
final Slider sliderOpacity = dialogBinding.inputOpacitySlider;
final TextView valueOpacity = dialogBinding.inputOpacityValue;
sliderOpacity.setValueTo(100);
sliderOpacity.setValue(IntSetting.MAIN_CONTROL_OPACITY.getInt(mSettings));
sliderOpacity.setValue(IntSetting.MAIN_CONTROL_OPACITY.getInt());
sliderOpacity.setStepSize(1);
sliderOpacity.addOnChangeListener(
(slider, progress, fromUser) -> valueOpacity.setText(((int) progress) + "%"));
@ -948,13 +948,13 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
{
IntSetting.MAIN_CONTROL_SCALE.setInt(mSettings, (int) scaleSlider.getValue());
IntSetting.MAIN_CONTROL_OPACITY.setInt(mSettings, (int) sliderOpacity.getValue());
mEmulationFragment.refreshInputOverlay(mSettings);
mEmulationFragment.refreshInputOverlay();
})
.setNeutralButton(R.string.default_values, (dialog, which) ->
{
IntSetting.MAIN_CONTROL_SCALE.delete(mSettings);
IntSetting.MAIN_CONTROL_OPACITY.delete(mSettings);
mEmulationFragment.refreshInputOverlay(mSettings);
mEmulationFragment.refreshInputOverlay();
})
.show();
}
@ -962,7 +962,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
private void addControllerIfNotNone(List<CharSequence> entries, List<Integer> values,
IntSetting controller, int entry, int value)
{
if (controller.getInt(mSettings) != 0)
if (controller.getInt() != 0)
{
entries.add(getString(entry));
values.add(value);
@ -992,7 +992,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
IntSetting controllerSetting = NativeLibrary.IsEmulatingWii() ?
IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER;
int currentValue = controllerSetting.getInt(mSettings);
int currentValue = controllerSetting.getInt();
int checkedItem = -1;
for (int i = 0; i < values.size(); i++)
@ -1013,7 +1013,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
.setPositiveButton(R.string.ok, (dialogInterface, i) ->
{
editor.apply();
mEmulationFragment.refreshInputOverlay(mSettings);
mEmulationFragment.refreshInputOverlay();
})
.setNeutralButton(R.string.emulation_more_controller_settings,
(dialogInterface, i) -> SettingsActivity.launch(this, MenuTag.SETTINGS))
@ -1025,11 +1025,11 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.emulation_ir_mode)
.setSingleChoiceItems(R.array.irModeEntries,
IntSetting.MAIN_IR_MODE.getInt(mSettings),
IntSetting.MAIN_IR_MODE.getInt(),
(dialog, indexSelected) ->
IntSetting.MAIN_IR_MODE.setInt(mSettings, indexSelected))
.setPositiveButton(R.string.ok, (dialogInterface, i) ->
mEmulationFragment.refreshOverlayPointer(mSettings))
mEmulationFragment.refreshOverlayPointer())
.show();
}
@ -1065,7 +1065,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
new MaterialAlertDialogBuilder(this)
.setTitle(getString(R.string.emulation_touch_overlay_reset))
.setPositiveButton(R.string.yes,
(dialogInterface, i) -> mEmulationFragment.resetInputOverlay(mSettings))
(dialogInterface, i) -> mEmulationFragment.resetInputOverlay())
.setNegativeButton(R.string.cancel, null)
.show();
}
@ -1160,7 +1160,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
public void initInputPointer()
{
mEmulationFragment.initInputPointer(mSettings);
mEmulationFragment.initInputPointer();
}
@Override

View File

@ -59,7 +59,7 @@ class GameAdapter(private val mActivity: FragmentActivity) : RecyclerView.Adapte
val gameFile = mGameFiles[position]
holder.apply {
if (BooleanSetting.MAIN_SHOW_GAME_TITLES.booleanGlobal) {
if (BooleanSetting.MAIN_SHOW_GAME_TITLES.boolean) {
binding.textGameTitle.text = gameFile.title
binding.textGameTitle.visibility = View.VISIBLE
binding.textGameTitleInner.visibility = View.GONE

View File

@ -92,7 +92,7 @@ public class GamePropertiesDialog extends DialogFragment
{
settings.loadSettings();
StringSetting.MAIN_DEFAULT_ISO.setString(settings, path);
settings.saveSettings(null, getContext());
settings.saveSettings(getContext());
}
});
}

View File

@ -160,7 +160,7 @@ class CheatsActivity : AppCompatActivity(), PanelSlideListener {
fun loadGameSpecificSettings(): Settings {
val settings = Settings()
settings.loadSettings(null, gameId, revision, isWii)
settings.loadSettings(gameId, revision, isWii)
return settings
}

View File

@ -42,8 +42,8 @@ abstract class SettingDisabledWarningFragment(
override fun onResume() {
super.onResume()
val activity = requireActivity() as CheatsActivity
activity.loadGameSpecificSettings().use { settings ->
val cheatsEnabled = setting.getBoolean(settings)
activity.loadGameSpecificSettings().use {
val cheatsEnabled = setting.getBoolean()
requireView().visibility = if (cheatsEnabled) View.GONE else View.VISIBLE
}
}

View File

@ -2,6 +2,8 @@
package org.dolphinemu.dolphinemu.features.input.model;
import androidx.annotation.NonNull;
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.ControlGroup;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -16,19 +18,19 @@ public class ControlGroupEnabledSetting implements AbstractBooleanSetting
}
@Override
public boolean getBoolean(Settings settings)
public boolean getBoolean()
{
return mControlGroup.getEnabled();
}
@Override
public void setBoolean(Settings settings, boolean newValue)
public void setBoolean(@NonNull Settings settings, boolean newValue)
{
mControlGroup.setEnabled(newValue);
}
@Override
public boolean isOverridden(Settings settings)
public boolean isOverridden()
{
return false;
}
@ -40,7 +42,7 @@ public class ControlGroupEnabledSetting implements AbstractBooleanSetting
}
@Override
public boolean delete(Settings settings)
public boolean delete(@NonNull Settings settings)
{
boolean newValue = mControlGroup.getDefaultEnabledValue() != ControlGroup.DEFAULT_ENABLED_NO;
mControlGroup.setEnabled(newValue);

View File

@ -2,6 +2,8 @@
package org.dolphinemu.dolphinemu.features.input.model;
import androidx.annotation.NonNull;
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -16,19 +18,19 @@ public class InputMappingBooleanSetting implements AbstractBooleanSetting
}
@Override
public boolean getBoolean(Settings settings)
public boolean getBoolean()
{
return mNumericSetting.getBooleanValue();
}
@Override
public void setBoolean(Settings settings, boolean newValue)
public void setBoolean(@NonNull Settings settings, boolean newValue)
{
mNumericSetting.setBooleanValue(newValue);
}
@Override
public boolean isOverridden(Settings settings)
public boolean isOverridden()
{
return false;
}
@ -40,7 +42,7 @@ public class InputMappingBooleanSetting implements AbstractBooleanSetting
}
@Override
public boolean delete(Settings settings)
public boolean delete(@NonNull Settings settings)
{
mNumericSetting.setBooleanValue(mNumericSetting.getBooleanDefaultValue());
return true;

View File

@ -2,6 +2,8 @@
package org.dolphinemu.dolphinemu.features.input.model;
import androidx.annotation.NonNull;
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -17,19 +19,19 @@ public class InputMappingDoubleSetting implements AbstractFloatSetting
}
@Override
public float getFloat(Settings settings)
public float getFloat()
{
return (float) mNumericSetting.getDoubleValue();
}
@Override
public void setFloat(Settings settings, float newValue)
public void setFloat(@NonNull Settings settings, float newValue)
{
mNumericSetting.setDoubleValue(newValue);
}
@Override
public boolean isOverridden(Settings settings)
public boolean isOverridden()
{
return false;
}
@ -41,7 +43,7 @@ public class InputMappingDoubleSetting implements AbstractFloatSetting
}
@Override
public boolean delete(Settings settings)
public boolean delete(@NonNull Settings settings)
{
mNumericSetting.setDoubleValue(mNumericSetting.getDoubleDefaultValue());
return true;

View File

@ -2,6 +2,8 @@
package org.dolphinemu.dolphinemu.features.input.model;
import androidx.annotation.NonNull;
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -16,19 +18,19 @@ public class InputMappingIntSetting implements AbstractIntSetting
}
@Override
public int getInt(Settings settings)
public int getInt()
{
return mNumericSetting.getIntValue();
}
@Override
public void setInt(Settings settings, int newValue)
public void setInt(@NonNull Settings settings, int newValue)
{
mNumericSetting.setIntValue(newValue);
}
@Override
public boolean isOverridden(Settings settings)
public boolean isOverridden()
{
return false;
}
@ -40,7 +42,7 @@ public class InputMappingIntSetting implements AbstractIntSetting
}
@Override
public boolean delete(Settings settings)
public boolean delete(@NonNull Settings settings)
{
mNumericSetting.setIntValue(mNumericSetting.getIntDefaultValue());
return true;

View File

@ -24,13 +24,13 @@ public class InputDeviceSetting extends StringSingleChoiceSetting
}
@Override
public String getSelectedChoice(Settings settings)
public String getSelectedChoice()
{
return mController.getDefaultDevice();
}
@Override
public String getSelectedValue(Settings settings)
public String getSelectedValue()
{
return mController.getDefaultDevice();
}

View File

@ -44,7 +44,7 @@ class RiivolutionBootActivity : AppCompatActivity() {
val revision = intent.getIntExtra(ARG_REVISION, -1)
val discNumber = intent.getIntExtra(ARG_DISC_NUMBER, -1)
var loadPath = StringSetting.MAIN_LOAD_PATH.stringGlobal
var loadPath = StringSetting.MAIN_LOAD_PATH.string
if (loadPath.isEmpty()) loadPath = DirectoryInitialization.getUserDirectory() + "/Load"
binding.textSdRoot.text = getString(R.string.riivolution_sd_root, "$loadPath/Riivolution")

View File

@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
public interface AbstractBooleanSetting extends AbstractSetting
{
boolean getBoolean(@NonNull Settings settings);
boolean getBoolean();
void setBoolean(@NonNull Settings settings, boolean newValue);
}

View File

@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
public interface AbstractFloatSetting extends AbstractSetting
{
float getFloat(@NonNull Settings settings);
float getFloat();
void setFloat(@NonNull Settings settings, float newValue);
}

View File

@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
public interface AbstractIntSetting extends AbstractSetting
{
int getInt(@NonNull Settings settings);
int getInt();
void setInt(@NonNull Settings settings, int newValue);
}

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

@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
public interface AbstractSetting
{
boolean isOverridden(@NonNull Settings settings);
boolean isOverridden();
boolean isRuntimeEditable();

View File

@ -7,7 +7,7 @@ import androidx.annotation.NonNull;
public interface AbstractStringSetting extends AbstractSetting
{
@NonNull
String getString(@NonNull Settings settings);
String getString();
void setString(@NonNull Settings settings, @NonNull String newValue);
}

View File

@ -25,7 +25,7 @@ public class AdHocBooleanSetting implements AbstractBooleanSetting
}
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@ -43,7 +43,7 @@ public class AdHocBooleanSetting implements AbstractBooleanSetting
}
@Override
public boolean getBoolean(@NonNull Settings settings)
public boolean getBoolean()
{
return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}

View File

@ -25,7 +25,7 @@ public class AdHocStringSetting implements AbstractStringSetting
}
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@ -43,7 +43,7 @@ public class AdHocStringSetting implements AbstractStringSetting
}
@NonNull @Override
public String getString(@NonNull Settings settings)
public String getString()
{
return NativeConfig.getString(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}

View File

@ -296,11 +296,8 @@ public enum BooleanSetting implements AbstractBooleanSetting
}
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey))
return settings.getSection(mFile, mSection).exists(mKey);
else
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@ -322,62 +319,41 @@ public enum BooleanSetting implements AbstractBooleanSetting
@Override
public boolean delete(@NonNull Settings settings)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
throw new UnsupportedOperationException(
"Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
}
return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey);
}
else
{
return settings.getSection(mFile, mSection).delete(mKey);
}
}
@Override
public boolean getBoolean(@NonNull Settings settings)
public boolean getBoolean()
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey,
mDefaultValue);
}
else
{
return settings.getSection(mFile, mSection).getBoolean(mKey, mDefaultValue);
}
return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}
@Override
public void setBoolean(@NonNull Settings settings, boolean newValue)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
throw new UnsupportedOperationException(
"Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
}
NativeConfig.setBoolean(settings.getWriteLayer(), mFile, mSection, mKey, newValue);
}
else
public void setBoolean(int layer, boolean newValue)
{
settings.getSection(mFile, mSection).setBoolean(mKey, newValue);
}
if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
throw new UnsupportedOperationException(
"Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
}
public void setBoolean(int layerType, boolean newValue)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
NativeConfig.setBoolean(layerType, mFile, mSection, mKey, newValue);
}
else
{
throw new UnsupportedOperationException("The old config system doesn't support layers");
}
}
public boolean getBooleanGlobal()
{
return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}
public void setBooleanGlobal(int layer, boolean newValue)
{
NativeConfig.setBoolean(layer, mFile, mSection, mKey, newValue);
}

View File

@ -25,11 +25,8 @@ public enum FloatSetting implements AbstractFloatSetting
}
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey))
return settings.getSection(mFile, mSection).exists(mKey);
else
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@ -42,48 +39,34 @@ public enum FloatSetting implements AbstractFloatSetting
@Override
public boolean delete(@NonNull Settings settings)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
throw new UnsupportedOperationException(
"Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
}
return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey);
}
else
{
return settings.getSection(mFile, mSection).delete(mKey);
}
}
@Override
public float getFloat(@NonNull Settings settings)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
public float getFloat()
{
return NativeConfig.getFloat(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}
else
{
return settings.getSection(mFile, mSection).getFloat(mKey, mDefaultValue);
}
}
@Override
public void setFloat(@NonNull Settings settings, float newValue)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
throw new UnsupportedOperationException(
"Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
}
NativeConfig.setFloat(settings.getWriteLayer(), mFile, mSection, mKey, newValue);
}
else
{
settings.getSection(mFile, mSection).setFloat(mKey, newValue);
}
}
public float getFloatGlobal()
{
return NativeConfig.getFloat(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}
public void setFloatGlobal(int layer, float newValue)
public void setFloat(int layer, float newValue)
{
NativeConfig.setFloat(layer, mFile, mSection, mKey, newValue);
}

View File

@ -121,11 +121,8 @@ public enum IntSetting implements AbstractIntSetting
}
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey))
return settings.getSection(mFile, mSection).exists(mKey);
else
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@ -147,49 +144,41 @@ public enum IntSetting implements AbstractIntSetting
@Override
public boolean delete(@NonNull Settings settings)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
throw new UnsupportedOperationException(
"Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
}
return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey);
}
else
{
return settings.getSection(mFile, mSection).delete(mKey);
}
}
@Override
public int getInt(@NonNull Settings settings)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
public int getInt()
{
return NativeConfig.getInt(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}
else
{
return settings.getSection(mFile, mSection).getInt(mKey, mDefaultValue);
}
}
@Override
public void setInt(@NonNull Settings settings, int newValue)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
throw new UnsupportedOperationException(
"Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
}
NativeConfig.setInt(settings.getWriteLayer(), mFile, mSection, mKey, newValue);
}
else
public void setInt(int layer, int newValue)
{
settings.getSection(mFile, mSection).setInt(mKey, newValue);
}
if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
throw new UnsupportedOperationException(
"Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
}
public int getIntGlobal()
{
return NativeConfig.getInt(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}
public void setIntGlobal(int layer, int newValue)
{
NativeConfig.setInt(layer, mFile, mSection, mKey, newValue);
}

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

@ -18,10 +18,14 @@ public class NativeConfig
public static native void save(int layer);
public static native void deleteAllKeys(int layer);
public static native boolean isOverridden(String file, String section, String key);
public static native boolean deleteKey(int layer, String file, String section, String key);
public static native boolean exists(int layer, String file, String section, String key);
public static native String getString(int layer, String file, String section, String key,
String defaultValue);

View File

@ -6,8 +6,8 @@ class ScaledIntSetting(
private val scale: Int,
private val setting: AbstractIntSetting
) : AbstractIntSetting {
override fun isOverridden(settings: Settings): Boolean {
return setting.isOverridden(settings)
override fun isOverridden(): Boolean {
return setting.isOverridden()
}
override fun isRuntimeEditable(): Boolean {
@ -18,8 +18,8 @@ class ScaledIntSetting(
return setting.delete(settings)
}
override fun getInt(settings: Settings): Int {
return setting.getInt(settings) / scale
override fun getInt(): Int {
return setting.getInt() / scale
}
override fun setInt(settings: Settings, newValue: Int) {

View File

@ -9,15 +9,9 @@ import android.widget.Toast;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.input.model.MappingCommon;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.IniFile;
import java.io.Closeable;
import java.util.HashMap;
import java.util.Map;
public class Settings implements Closeable
{
@ -26,6 +20,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";
@ -51,40 +46,14 @@ public class Settings implements Closeable
public static final String SECTION_ANALYTICS = "Analytics";
public static final String GAME_SETTINGS_PLACEHOLDER_FILE_NAME = "";
private String mGameId;
private int mRevision;
private boolean mIsWii;
private static final String[] configFiles = new String[]{FILE_DOLPHIN, FILE_GFX, FILE_LOGGER,
FILE_WIIMOTE};
private Map<String, IniFile> mIniFiles = new HashMap<>();
private boolean mSettingsLoaded = false;
private boolean mLoadedRecursiveIsoPathsValue = false;
private IniFile getGameSpecificFile()
{
if (!isGameSpecific() || mIniFiles.size() != 1)
throw new IllegalStateException();
return mIniFiles.get(GAME_SETTINGS_PLACEHOLDER_FILE_NAME);
}
public IniFile.Section getSection(String fileName, String sectionName)
{
if (!isGameSpecific())
{
return mIniFiles.get(fileName).getOrCreateSection(sectionName);
}
else
{
return getGameSpecificFile()
.getOrCreateSection(SettingsFile.mapSectionNameFromIni(sectionName));
}
}
public boolean isGameSpecific()
{
return !TextUtils.isEmpty(mGameId);
@ -100,91 +69,56 @@ public class Settings implements Closeable
return isGameSpecific() ? NativeConfig.LAYER_LOCAL_GAME : NativeConfig.LAYER_BASE_OR_CURRENT;
}
public boolean isEmpty()
public boolean areSettingsLoaded()
{
return mIniFiles.isEmpty();
return mSettingsLoaded;
}
public void loadSettings()
{
// The value of isWii doesn't matter if we don't have any SettingsActivity
loadSettings(null, true);
loadSettings(true);
}
public void loadSettings(SettingsActivityView view, boolean isWii)
public void loadSettings(boolean isWii)
{
mIsWii = isWii;
mSettingsLoaded = true;
mIniFiles = new HashMap<>();
if (!isGameSpecific())
{
loadDolphinSettings(view);
}
else
if (isGameSpecific())
{
// Loading game INIs while the core is running will mess with the game INIs loaded by the core
if (NativeLibrary.IsRunning())
throw new IllegalStateException("Attempted to load game INI while emulating");
NativeConfig.loadGameInis(mGameId, mRevision);
loadCustomGameSettings(mGameId, view);
}
mLoadedRecursiveIsoPathsValue = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this);
mLoadedRecursiveIsoPathsValue = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean();
}
private void loadDolphinSettings(SettingsActivityView view)
{
for (String fileName : configFiles)
{
IniFile ini = new IniFile();
SettingsFile.readFile(fileName, ini, view);
mIniFiles.put(fileName, ini);
}
}
private void loadCustomGameSettings(String gameId, SettingsActivityView view)
{
IniFile ini = new IniFile();
SettingsFile.readCustomGameSettings(gameId, ini, view);
mIniFiles.put(GAME_SETTINGS_PLACEHOLDER_FILE_NAME, ini);
}
public void loadSettings(SettingsActivityView view, String gameId, int revision, boolean isWii)
public void loadSettings(String gameId, int revision, boolean isWii)
{
mGameId = gameId;
mRevision = revision;
loadSettings(view, isWii);
loadSettings(isWii);
}
public void saveSettings(SettingsActivityView view, Context context)
public void saveSettings(Context context)
{
if (!isGameSpecific())
{
if (context != null)
Toast.makeText(context, R.string.settings_saved, Toast.LENGTH_SHORT).show();
for (Map.Entry<String, IniFile> entry : mIniFiles.entrySet())
{
SettingsFile.saveFile(entry.getKey(), entry.getValue(), view);
}
MappingCommon.save();
NativeConfig.save(NativeConfig.LAYER_BASE);
if (!NativeLibrary.IsRunning())
{
// Notify the native code of the changes to legacy settings
NativeLibrary.ReloadConfig();
}
// LogManager does use the new config system, but doesn't pick up on changes automatically
NativeLibrary.ReloadLoggerConfig();
NativeLibrary.UpdateGCAdapterScanThread();
if (mLoadedRecursiveIsoPathsValue != BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this))
if (mLoadedRecursiveIsoPathsValue != BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean())
{
// Refresh game library
GameFileCacheManager.startRescan();
@ -200,18 +134,13 @@ public class Settings implements Closeable
Toast.LENGTH_SHORT).show();
}
SettingsFile.saveCustomGameSettings(mGameId, getGameSpecificFile());
NativeConfig.save(NativeConfig.LAYER_LOCAL_GAME);
}
}
public void clearSettings()
public void clearGameSettings()
{
for (String fileName : mIniFiles.keySet())
{
mIniFiles.put(fileName, new IniFile());
}
NativeConfig.deleteAllKeys(NativeConfig.LAYER_LOCAL_GAME);
}
public boolean gameIniContainsJunk()
@ -237,7 +166,8 @@ public class Settings implements Closeable
if (!isGameSpecific())
return false;
return getSection(Settings.FILE_DOLPHIN, SECTION_INI_INTERFACE).exists("ThemeName");
return NativeConfig.exists(NativeConfig.LAYER_LOCAL_GAME, FILE_DOLPHIN, SECTION_INI_INTERFACE,
"ThemeName");
}
@Override

View File

@ -65,11 +65,8 @@ public enum StringSetting implements AbstractStringSetting
}
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey))
return settings.getSection(mFile, mSection).exists(mKey);
else
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@ -87,50 +84,29 @@ public enum StringSetting implements AbstractStringSetting
@Override
public boolean delete(@NonNull Settings settings)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey);
}
else
{
return settings.getSection(mFile, mSection).delete(mKey);
}
}
@NonNull @Override
public String getString(@NonNull Settings settings)
public String getString()
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
return NativeConfig.getString(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey,
mDefaultValue);
}
else
{
return settings.getSection(mFile, mSection).getString(mKey, mDefaultValue);
throw new UnsupportedOperationException(
"Unsupported setting: " + mFile + ", " + mSection + ", " + mKey);
}
return NativeConfig.getString(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}
@Override
public void setString(@NonNull Settings settings, @NonNull String newValue)
{
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
{
NativeConfig.setString(settings.getWriteLayer(), mFile, mSection, mKey, newValue);
}
else
{
settings.getSection(mFile, mSection).setString(mKey, newValue);
}
}
public String getStringGlobal()
{
return NativeConfig.getString(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}
public void setStringGlobal(int layer, String newValue)
public void setString(int layer, String newValue)
{
NativeConfig.setString(layer, mFile, mSection, mKey, newValue);
}

View File

@ -25,7 +25,7 @@ class DateTimeChoiceSetting(
setting.setString(settings, selection)
}
fun getSelectedValue(settings: Settings): String {
return setting.getString(settings)
fun getSelectedValue(): String {
return setting.getString()
}
}

View File

@ -25,9 +25,9 @@ public final class FilePicker extends SettingsItem
mDefaultPathRelativeToUserDirectory = defaultPathRelativeToUserDirectory;
}
public String getSelectedValue(Settings settings)
public String getSelectedValue()
{
return mSetting.getString(settings);
return mSetting.getString();
}
public void setSelectedValue(Settings settings, String selection)

View File

@ -26,9 +26,9 @@ public class FloatSliderSetting extends SliderSetting
mSetting = setting;
}
public int getSelectedValue(Settings settings)
public int getSelectedValue()
{
return Math.round(mSetting.getFloat(settings));
return Math.round(mSetting.getFloat());
}
public void setSelectedValue(Settings settings, float selection)

View File

@ -43,9 +43,9 @@ public class InputStringSetting extends SettingsItem
this(context, setting, titleId, descriptionId, choicesId, valuesId, null);
}
public String getSelectedValue(Settings settings)
public String getSelectedValue()
{
return mSetting.getString(settings);
return mSetting.getString();
}
public MenuTag getMenuTag()

View File

@ -19,9 +19,9 @@ public final class IntSliderSetting extends SliderSetting
mSetting = setting;
}
public int getSelectedValue(Settings settings)
public int getSelectedValue()
{
return mSetting.getInt(settings);
return mSetting.getInt();
}
public void setSelectedValue(Settings settings, int selection)

View File

@ -17,9 +17,9 @@ public final class InvertedSwitchSetting extends SwitchSetting
}
@Override
public boolean isChecked(Settings settings)
public boolean isChecked()
{
return !mSetting.getBoolean(settings);
return !mSetting.getBoolean();
}
@Override

View File

@ -17,9 +17,9 @@ public final class PercentSliderSetting extends FloatSliderSetting
}
@Override
public int getSelectedValue(Settings settings)
public int getSelectedValue()
{
return Math.round(mSetting.getFloat(settings) * 100);
return Math.round(mSetting.getFloat() * 100);
}
@Override

View File

@ -75,10 +75,10 @@ public abstract class SettingsItem
protected abstract AbstractSetting getSetting();
public boolean isOverridden(Settings settings)
public boolean isOverridden()
{
AbstractSetting setting = getSetting();
return setting != null && setting.isOverridden(settings);
return setting != null && setting.isOverridden();
}
public boolean isEditable()

View File

@ -43,9 +43,9 @@ public final class SingleChoiceSetting extends SettingsItem
return mValuesId;
}
public int getSelectedValue(Settings settings)
public int getSelectedValue()
{
return mSetting.getInt(settings);
return mSetting.getInt();
}
public MenuTag getMenuTag()

View File

@ -60,9 +60,9 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem
return mDescriptionValuesId;
}
public int getSelectedValue(Settings settings)
public int getSelectedValue()
{
return mSetting.getInt(settings);
return mSetting.getInt();
}
public MenuTag getMenuTag()

View File

@ -31,7 +31,7 @@ public abstract class SliderSetting extends SettingsItem
mUnits = units;
}
public abstract int getSelectedValue(Settings settings);
public abstract int getSelectedValue();
public int getMin()
{

View File

@ -94,19 +94,19 @@ public class StringSingleChoiceSetting extends SettingsItem
return "";
}
public String getSelectedChoice(Settings settings)
public String getSelectedChoice()
{
return getChoiceAt(getSelectedValueIndex(settings));
return getChoiceAt(getSelectedValueIndex());
}
public String getSelectedValue(Settings settings)
public String getSelectedValue()
{
return mSetting.getString(settings);
return mSetting.getString();
}
public int getSelectedValueIndex(Settings settings)
public int getSelectedValueIndex()
{
String selectedValue = getSelectedValue(settings);
String selectedValue = getSelectedValue();
for (int i = 0; i < mValues.length; i++)
{
if (mValues[i].equals(selectedValue))

View File

@ -26,9 +26,9 @@ public class SwitchSetting extends SettingsItem
mSetting = setting;
}
public boolean isChecked(Settings settings)
public boolean isChecked()
{
return mSetting.getBoolean(settings);
return mSetting.getBoolean();
}
public void setChecked(Settings settings, boolean checked)

View File

@ -276,7 +276,7 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
new MaterialAlertDialogBuilder(this)
.setTitle(getString(R.string.game_ini_junk_title))
.setMessage(getString(R.string.game_ini_junk_question))
.setPositiveButton(R.string.yes, (dialogInterface, i) -> mPresenter.clearSettings())
.setPositiveButton(R.string.yes, (dialogInterface, i) -> mPresenter.clearGameSettings())
.setNegativeButton(R.string.no, null)
.show();
}

View File

@ -66,11 +66,11 @@ public final class SettingsActivityPresenter
{
mView.hideLoading();
if (mSettings.isEmpty())
if (!mSettings.areSettingsLoaded())
{
if (!TextUtils.isEmpty(mGameId))
{
mSettings.loadSettings(mView, mGameId, mRevision, mIsWii);
mSettings.loadSettings(mGameId, mRevision, mIsWii);
if (mSettings.gameIniContainsJunk())
{
@ -79,7 +79,7 @@ public final class SettingsActivityPresenter
}
else
{
mSettings.loadSettings(mView, mIsWii);
mSettings.loadSettings(mIsWii);
}
}
@ -99,9 +99,9 @@ public final class SettingsActivityPresenter
return mSettings;
}
public void clearSettings()
public void clearGameSettings()
{
mSettings.clearSettings();
mSettings.clearGameSettings();
onSettingChanged();
}
@ -110,7 +110,7 @@ public final class SettingsActivityPresenter
if (mSettings != null && finishing && mShouldSave)
{
Log.debug("[SettingsActivity] Settings activity stopping. Saving settings to INI...");
mSettings.saveSettings(mView, mActivity);
mSettings.saveSettings(mActivity);
}
}

View File

@ -217,7 +217,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
DialogInputStringBinding binding = DialogInputStringBinding.inflate(inflater);
TextInputEditText input = binding.input;
input.setText(item.getSelectedValue(getSettings()));
input.setText(item.getSelectedValue());
mDialog = new MaterialAlertDialogBuilder(mView.getActivity())
.setView(binding.getRoot())
@ -226,7 +226,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
{
String editTextInput = input.getText().toString();
if (!item.getSelectedValue(mView.getSettings()).equals(editTextInput))
if (!item.getSelectedValue().equals(editTextInput))
{
notifyItemChanged(position);
mView.onSettingChanged();
@ -272,7 +272,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
{
mDialog = new MaterialAlertDialogBuilder(mView.getActivity())
.setTitle(item.getName())
.setSingleChoiceItems(item.getChoices(), item.getSelectedValueIndex(getSettings()),
.setSingleChoiceItems(item.getChoices(), item.getSelectedValueIndex(),
this)
.show();
}
@ -296,7 +296,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
{
mClickedItem = item;
mClickedPosition = position;
mSeekbarProgress = item.getSelectedValue(getSettings());
mSeekbarProgress = item.getSelectedValue();
LayoutInflater inflater = LayoutInflater.from(mView.getActivity());
DialogSliderBinding binding = DialogSliderBinding.inflate(inflater);
@ -430,8 +430,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI,
filePicker.getSelectedValue(mView.getSettings()));
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, filePicker.getSelectedValue());
}
mView.getActivity().startActivityForResult(intent, filePicker.getRequestType());
@ -441,7 +440,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
{
mClickedItem = item;
mClickedPosition = position;
long storedTime = Long.decode(item.getSelectedValue(mView.getSettings())) * 1000;
long storedTime = Long.decode(item.getSelectedValue()) * 1000;
// Helper to extract hour and minute from epoch time
Calendar calendar = Calendar.getInstance();
@ -481,7 +480,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
epochTime += (long) timePicker.getHour() * 60 * 60;
epochTime += (long) timePicker.getMinute() * 60;
String rtcString = "0x" + Long.toHexString(epochTime);
if (!item.getSelectedValue(mView.getSettings()).equals(rtcString))
if (!item.getSelectedValue().equals(rtcString))
{
notifyItemChanged(mClickedPosition);
mView.onSettingChanged();
@ -498,7 +497,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
{
FilePicker filePicker = (FilePicker) mClickedItem;
if (!filePicker.getSelectedValue(mView.getSettings()).equals(selectedFile))
if (!filePicker.getSelectedValue().equals(selectedFile))
{
notifyItemChanged(mClickedPosition);
mView.onSettingChanged();
@ -543,7 +542,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
SingleChoiceSetting scSetting = (SingleChoiceSetting) mClickedItem;
int value = getValueForSingleChoiceSelection(scSetting, which);
if (scSetting.getSelectedValue(getSettings()) != value)
if (scSetting.getSelectedValue() != value)
mView.onSettingChanged();
scSetting.setSelectedValue(getSettings(), value);
@ -556,7 +555,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
(SingleChoiceSettingDynamicDescriptions) mClickedItem;
int value = getValueForSingleChoiceDynamicDescriptionsSelection(scSetting, which);
if (scSetting.getSelectedValue(getSettings()) != value)
if (scSetting.getSelectedValue() != value)
mView.onSettingChanged();
scSetting.setSelectedValue(getSettings(), value);
@ -567,7 +566,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
{
StringSingleChoiceSetting scSetting = (StringSingleChoiceSetting) mClickedItem;
String value = scSetting.getValueAt(which);
if (!scSetting.getSelectedValue(getSettings()).equals(value))
if (!scSetting.getSelectedValue().equals(value))
mView.onSettingChanged();
scSetting.setSelectedValue(getSettings(), value);
@ -577,7 +576,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
else if (mClickedItem instanceof IntSliderSetting)
{
IntSliderSetting sliderSetting = (IntSliderSetting) mClickedItem;
if (sliderSetting.getSelectedValue(getSettings()) != mSeekbarProgress)
if (sliderSetting.getSelectedValue() != mSeekbarProgress)
mView.onSettingChanged();
sliderSetting.setSelectedValue(getSettings(), mSeekbarProgress);
@ -587,7 +586,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
else if (mClickedItem instanceof FloatSliderSetting)
{
FloatSliderSetting sliderSetting = (FloatSliderSetting) mClickedItem;
if (sliderSetting.getSelectedValue(getSettings()) != mSeekbarProgress)
if (sliderSetting.getSelectedValue() != mSeekbarProgress)
mView.onSettingChanged();
sliderSetting.setSelectedValue(getSettings(), mSeekbarProgress);
@ -637,7 +636,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
private int getSelectionForSingleChoiceValue(SingleChoiceSetting item)
{
int value = item.getSelectedValue(getSettings());
int value = item.getSelectedValue();
int valuesId = item.getValuesId();
if (valuesId > 0)
@ -679,7 +678,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
private int getSelectionForSingleChoiceDynamicDescriptionsValue(
SingleChoiceSettingDynamicDescriptions item)
{
int value = item.getSelectedValue(getSettings());
int value = item.getSelectedValue();
int valuesId = item.getValuesId();
if (valuesId > 0)

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.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;
@ -368,9 +368,9 @@ public final class SettingsFragmentPresenter
AbstractIntSetting appTheme = new AbstractIntSetting()
{
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
return IntSetting.MAIN_INTERFACE_THEME.isOverridden(settings);
return IntSetting.MAIN_INTERFACE_THEME.isOverridden();
}
@Override
@ -388,9 +388,9 @@ public final class SettingsFragmentPresenter
}
@Override
public int getInt(@NonNull Settings settings)
public int getInt()
{
return IntSetting.MAIN_INTERFACE_THEME.getInt(settings);
return IntSetting.MAIN_INTERFACE_THEME.getInt();
}
@Override
@ -416,9 +416,9 @@ public final class SettingsFragmentPresenter
AbstractIntSetting themeMode = new AbstractIntSetting()
{
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
return IntSetting.MAIN_INTERFACE_THEME_MODE.isOverridden(settings);
return IntSetting.MAIN_INTERFACE_THEME_MODE.isOverridden();
}
@Override
@ -436,9 +436,9 @@ public final class SettingsFragmentPresenter
}
@Override
public int getInt(@NonNull Settings settings)
public int getInt()
{
return IntSetting.MAIN_INTERFACE_THEME_MODE.getInt(settings);
return IntSetting.MAIN_INTERFACE_THEME_MODE.getInt();
}
@Override
@ -455,9 +455,9 @@ public final class SettingsFragmentPresenter
AbstractBooleanSetting blackBackgrounds = new AbstractBooleanSetting()
{
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
return BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.isOverridden(settings);
return BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.isOverridden();
}
@Override
@ -474,9 +474,9 @@ public final class SettingsFragmentPresenter
}
@Override
public boolean getBoolean(@NonNull Settings settings)
public boolean getBoolean()
{
return BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBoolean(settings);
return BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBoolean();
}
@Override
@ -500,15 +500,15 @@ public final class SettingsFragmentPresenter
AbstractIntSetting dspEmulationEngine = new AbstractIntSetting()
{
@Override
public int getInt(@NonNull Settings settings)
public int getInt()
{
if (BooleanSetting.MAIN_DSP_HLE.getBoolean(settings))
if (BooleanSetting.MAIN_DSP_HLE.getBoolean())
{
return DSP_HLE;
}
else
{
boolean jit = BooleanSetting.MAIN_DSP_JIT.getBoolean(settings);
boolean jit = BooleanSetting.MAIN_DSP_JIT.getBoolean();
return jit ? DSP_LLE_RECOMPILER : DSP_LLE_INTERPRETER;
}
}
@ -536,10 +536,10 @@ public final class SettingsFragmentPresenter
}
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
return BooleanSetting.MAIN_DSP_HLE.isOverridden(settings) ||
BooleanSetting.MAIN_DSP_JIT.isOverridden(settings);
return BooleanSetting.MAIN_DSP_HLE.isOverridden() ||
BooleanSetting.MAIN_DSP_JIT.isOverridden();
}
@Override
@ -681,15 +681,15 @@ public final class SettingsFragmentPresenter
AbstractIntSetting synchronizeGpuThread = new AbstractIntSetting()
{
@Override
public int getInt(@NonNull Settings settings)
public int getInt()
{
if (BooleanSetting.MAIN_SYNC_GPU.getBoolean(settings))
if (BooleanSetting.MAIN_SYNC_GPU.getBoolean())
{
return SYNC_GPU_ALWAYS;
}
else
{
boolean syncOnSkipIdle = BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.getBoolean(settings);
boolean syncOnSkipIdle = BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.getBoolean();
return syncOnSkipIdle ? SYNC_GPU_ON_IDLE_SKIP : SYNC_GPU_NEVER;
}
}
@ -717,10 +717,10 @@ public final class SettingsFragmentPresenter
}
@Override
public boolean isOverridden(@NonNull Settings settings)
public boolean isOverridden()
{
return BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.isOverridden(settings) ||
BooleanSetting.MAIN_SYNC_GPU.isOverridden(settings);
return BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.isOverridden() ||
BooleanSetting.MAIN_SYNC_GPU.isOverridden();
}
@Override
@ -879,7 +879,7 @@ public final class SettingsFragmentPresenter
R.string.texture_filtering, R.string.texture_filtering_description,
R.array.textureFilteringEntries, R.array.textureFilteringValues));
int stereoModeValue = IntSetting.GFX_STEREO_MODE.getInt(mSettings);
int stereoModeValue = IntSetting.GFX_STEREO_MODE.getInt();
final int anaglyphMode = 3;
String[] shaderList = stereoModeValue == anaglyphMode ?
PostProcessing.getAnaglyphShaderList() : PostProcessing.getShaderList();
@ -1198,7 +1198,7 @@ public final class SettingsFragmentPresenter
String[] profiles = new ProfileDialogPresenter(mMenuTag).getProfileNames(false);
String profileKey = profileString + "Profile" + (controllerNumber + 1);
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));
}
@ -1216,7 +1216,7 @@ public final class SettingsFragmentPresenter
sl.add(new SwitchSetting(mContext, new AbstractBooleanSetting()
{
@Override
public boolean isOverridden(Settings settings)
public boolean isOverridden()
{
return false;
}
@ -1228,20 +1228,20 @@ public final class SettingsFragmentPresenter
}
@Override
public boolean delete(Settings settings)
public boolean delete(@NonNull Settings settings)
{
mView.setMappingAllDevices(false);
return true;
}
@Override
public boolean getBoolean(Settings settings)
public boolean getBoolean()
{
return mView.isMappingAllDevices();
}
@Override
public void setBoolean(Settings settings, boolean newValue)
public void setBoolean(@NonNull Settings settings, boolean newValue)
{
mView.setMappingAllDevices(newValue);
}

View File

@ -22,7 +22,7 @@ class DateTimeSettingViewHolder(
override fun bind(item: SettingsItem) {
mItem = item as DateTimeChoiceSetting
val inputTime = mItem!!.getSelectedValue(adapter.settings)
val inputTime = mItem!!.getSelectedValue()
binding.textSettingName.text = item.getName()
if (!TextUtils.isEmpty(inputTime)) {

View File

@ -35,7 +35,7 @@ public final class FilePickerViewHolder extends SettingViewHolder
mFilePicker = (FilePicker) item;
mItem = item;
String path = mFilePicker.getSelectedValue(getAdapter().getSettings());
String path = mFilePicker.getSelectedValue();
if (FileBrowserHelper.isPathEmptyOrValid(path))
{

View File

@ -31,7 +31,7 @@ public final class InputStringSettingViewHolder extends SettingViewHolder
{
mInputString = (InputStringSetting) item;
String inputString = mInputString.getSelectedValue(getAdapter().getSettings());
String inputString = mInputString.getSelectedValue();
mBinding.textSettingName.setText(item.getName());

View File

@ -41,7 +41,7 @@ public abstract class SettingViewHolder extends RecyclerView.ViewHolder
protected void setStyle(TextView textView, SettingsItem settingsItem)
{
boolean overridden = settingsItem.isOverridden(mAdapter.getSettings());
boolean overridden = settingsItem.isOverridden();
textView.setTypeface(null, overridden ? Typeface.BOLD : Typeface.NORMAL);
if (!settingsItem.isEditable())

View File

@ -18,7 +18,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoice
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
import java.util.function.Function;
import java.util.function.Supplier;
public final class SingleChoiceViewHolder extends SettingViewHolder
{
@ -39,9 +39,6 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
mBinding.textSettingName.setText(item.getName());
SettingsAdapter adapter = getAdapter();
Settings settings = adapter.getSettings();
if (!TextUtils.isEmpty(item.getDescription()))
{
mBinding.textSettingDescription.setText(item.getDescription());
@ -49,7 +46,7 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
else if (item instanceof SingleChoiceSetting)
{
SingleChoiceSetting setting = (SingleChoiceSetting) item;
int selected = setting.getSelectedValue(settings);
int selected = setting.getSelectedValue();
Resources resMgr = mBinding.textSettingDescription.getContext().getResources();
String[] choices = resMgr.getStringArray(setting.getChoicesId());
int[] values = resMgr.getIntArray(setting.getValuesId());
@ -64,14 +61,14 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
else if (item instanceof StringSingleChoiceSetting)
{
StringSingleChoiceSetting setting = (StringSingleChoiceSetting) item;
String choice = setting.getSelectedChoice(settings);
String choice = setting.getSelectedChoice();
mBinding.textSettingDescription.setText(choice);
}
else if (item instanceof SingleChoiceSettingDynamicDescriptions)
{
SingleChoiceSettingDynamicDescriptions setting =
(SingleChoiceSettingDynamicDescriptions) item;
int selected = setting.getSelectedValue(settings);
int selected = setting.getSelectedValue();
Resources resMgr = mBinding.textSettingDescription.getContext().getResources();
String[] choices = resMgr.getStringArray(setting.getDescriptionChoicesId());
int[] values = resMgr.getIntArray(setting.getDescriptionValuesId());
@ -85,7 +82,7 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
}
MenuTag menuTag = null;
Function<Settings, Integer> getSelectedValue = null;
Supplier<Integer> getSelectedValue = null;
if (item instanceof SingleChoiceSetting)
{
SingleChoiceSetting setting = (SingleChoiceSetting) item;
@ -99,15 +96,14 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
getSelectedValue = setting::getSelectedValueIndex;
}
if (menuTag != null &&
adapter.hasMenuTagActionForValue(menuTag, getSelectedValue.apply(settings)))
if (menuTag != null && getAdapter().hasMenuTagActionForValue(menuTag, getSelectedValue.get()))
{
mBinding.buttonMoreSettings.setVisibility(View.VISIBLE);
final MenuTag finalMenuTag = menuTag;
final Function<Settings, Integer> finalGetSelectedValue = getSelectedValue;
final Supplier<Integer> finalGetSelectedValue = getSelectedValue;
mBinding.buttonMoreSettings.setOnClickListener((view) ->
adapter.onMenuTagAction(finalMenuTag, finalGetSelectedValue.apply(settings)));
getAdapter().onMenuTagAction(finalMenuTag, finalGetSelectedValue.get()));
}
else
{

View File

@ -44,9 +44,8 @@ public final class SliderViewHolder extends SettingViewHolder
}
else
{
mBinding.textSettingDescription.setText(mContext
.getString(R.string.slider_setting_value,
mItem.getSelectedValue(getAdapter().getSettings()), mItem.getUnits()));
mBinding.textSettingDescription.setText(mContext.getString(R.string.slider_setting_value,
mItem.getSelectedValue(), mItem.getUnits()));
}
setStyle(mBinding.textSettingName, mItem);

View File

@ -38,7 +38,7 @@ public final class SwitchSettingViewHolder extends SettingViewHolder
mBinding.textSettingName.setText(item.getName());
mBinding.textSettingDescription.setText(item.getDescription());
mBinding.settingSwitch.setChecked(mItem.isChecked(getAdapter().getSettings()));
mBinding.settingSwitch.setChecked(mItem.isChecked());
mBinding.settingSwitch.setEnabled(mItem.isEditable());
// Check for IPL to make sure user can skip.
@ -56,14 +56,7 @@ public final class SwitchSettingViewHolder extends SettingViewHolder
}
}
if (mItem.isChecked(getAdapter().getSettings()))
{
mBinding.settingSwitch.setEnabled(iplExists);
}
else
{
mBinding.settingSwitch.setEnabled(true);
}
mBinding.settingSwitch.setEnabled(iplExists || !mItem.isChecked());
}
mBinding.settingSwitch.setOnCheckedChangeListener((buttonView, isChecked) ->
@ -95,7 +88,7 @@ public final class SwitchSettingViewHolder extends SettingViewHolder
if (mItem.getSetting() == BooleanSetting.MAIN_SKIP_IPL && !iplExists)
{
if (mItem.isChecked(getAdapter().getSettings()))
if (mItem.isChecked())
{
showIplNotAvailableError();
return;

View File

@ -115,7 +115,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
{
int overlayX = mInputOverlay.getLeft();
int overlayY = mInputOverlay.getTop();
mInputOverlay.setSurfacePosition(activity.getSettings(), new Rect(
mInputOverlay.setSurfacePosition(new Rect(
surfaceView.getLeft() - overlayX, surfaceView.getTop() - overlayY,
surfaceView.getRight() - overlayX, surfaceView.getBottom() - overlayY));
});
@ -135,7 +135,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
super.onResume();
if (mInputOverlay != null && NativeLibrary.IsGameMetadataValid())
mInputOverlay.refreshControls(activity.getSettings());
mInputOverlay.refreshControls();
run(activity.isActivityRecreated());
}
@ -171,34 +171,34 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
public void toggleInputOverlayVisibility(Settings settings)
{
BooleanSetting.MAIN_SHOW_INPUT_OVERLAY
.setBoolean(settings, !BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBoolean(settings));
.setBoolean(settings, !BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBoolean());
if (mInputOverlay != null)
mInputOverlay.refreshControls(settings);
mInputOverlay.refreshControls();
}
public void initInputPointer(Settings settings)
public void initInputPointer()
{
if (mInputOverlay != null)
mInputOverlay.initTouchPointer(settings);
mInputOverlay.initTouchPointer();
}
public void refreshInputOverlay(Settings settings)
public void refreshInputOverlay()
{
if (mInputOverlay != null)
mInputOverlay.refreshControls(settings);
mInputOverlay.refreshControls();
}
public void refreshOverlayPointer(Settings settings)
public void refreshOverlayPointer()
{
if (mInputOverlay != null)
mInputOverlay.refreshOverlayPointer(settings);
mInputOverlay.refreshOverlayPointer();
}
public void resetInputOverlay(Settings settings)
public void resetInputOverlay()
{
if (mInputOverlay != null)
mInputOverlay.resetButtonPlacement(settings);
mInputOverlay.resetButtonPlacement();
}
@Override

View File

@ -65,13 +65,12 @@ class GridOptionDialogFragment : BottomSheetDialogFragment() {
}
private fun setUpCoverButtons() {
mBindingMobile.switchDownloadCovers.isChecked =
BooleanSetting.MAIN_USE_GAME_COVERS.booleanGlobal
mBindingMobile.switchDownloadCovers.isChecked = BooleanSetting.MAIN_USE_GAME_COVERS.boolean
mBindingMobile.rootDownloadCovers.setOnClickListener {
mBindingMobile.switchDownloadCovers.isChecked = !mBindingMobile.switchDownloadCovers.isChecked
}
mBindingMobile.switchDownloadCovers.setOnCheckedChangeListener { _: CompoundButton, _: Boolean ->
BooleanSetting.MAIN_USE_GAME_COVERS.setBooleanGlobal(
BooleanSetting.MAIN_USE_GAME_COVERS.setBoolean(
NativeConfig.LAYER_BASE,
mBindingMobile.switchDownloadCovers.isChecked
)
@ -80,12 +79,12 @@ class GridOptionDialogFragment : BottomSheetDialogFragment() {
}
private fun setUpTitleButtons() {
mBindingMobile.switchShowTitles.isChecked = BooleanSetting.MAIN_SHOW_GAME_TITLES.booleanGlobal
mBindingMobile.switchShowTitles.isChecked = BooleanSetting.MAIN_SHOW_GAME_TITLES.boolean
mBindingMobile.rootShowTitles.setOnClickListener {
mBindingMobile.switchShowTitles.isChecked = !mBindingMobile.switchShowTitles.isChecked
}
mBindingMobile.switchShowTitles.setOnCheckedChangeListener { _: CompoundButton, _: Boolean ->
BooleanSetting.MAIN_SHOW_GAME_TITLES.setBooleanGlobal(
BooleanSetting.MAIN_SHOW_GAME_TITLES.setBoolean(
NativeConfig.LAYER_BASE,
mBindingMobile.switchShowTitles.isChecked
)
@ -96,12 +95,12 @@ class GridOptionDialogFragment : BottomSheetDialogFragment() {
// TODO: Remove this when leanback is removed
private fun setUpCoverButtonsTv() {
mBindingTv.switchDownloadCovers.isChecked =
BooleanSetting.MAIN_USE_GAME_COVERS.booleanGlobal
BooleanSetting.MAIN_USE_GAME_COVERS.boolean
mBindingTv.rootDownloadCovers.setOnClickListener {
mBindingTv.switchDownloadCovers.isChecked = !mBindingTv.switchDownloadCovers.isChecked
}
mBindingTv.switchDownloadCovers.setOnCheckedChangeListener { _: CompoundButton, _: Boolean ->
BooleanSetting.MAIN_USE_GAME_COVERS.setBooleanGlobal(
BooleanSetting.MAIN_USE_GAME_COVERS.setBoolean(
NativeConfig.LAYER_BASE,
mBindingTv.switchDownloadCovers.isChecked
)

View File

@ -92,7 +92,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
{
if (IntSetting.MAIN_INTERFACE_THEME.getIntGlobal() != ThemeHelper.DEFAULT)
if (IntSetting.MAIN_INTERFACE_THEME.getInt() != ThemeHelper.DEFAULT)
{
@ColorInt int color = new ElevationOverlayProvider(view.getContext()).compositeOverlay(
MaterialColors.getColor(view, R.attr.colorSurface),
@ -114,7 +114,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
mBinding.menuSkylanders.setVisibility(View.GONE);
}
if (!BooleanSetting.MAIN_EMULATE_SKYLANDER_PORTAL.getBooleanGlobal())
if (!BooleanSetting.MAIN_EMULATE_SKYLANDER_PORTAL.getBoolean())
{
mBinding.menuSkylanders.setVisibility(View.GONE);
}
@ -176,7 +176,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
{
super.onResume();
boolean savestatesEnabled = BooleanSetting.MAIN_ENABLE_SAVESTATES.getBooleanGlobal();
boolean savestatesEnabled = BooleanSetting.MAIN_ENABLE_SAVESTATES.getBoolean();
int savestateVisibility = savestatesEnabled ? View.VISIBLE : View.GONE;
mBinding.menuQuicksave.setVisibility(savestateVisibility);
mBinding.menuQuickload.setVisibility(savestateVisibility);

View File

@ -98,7 +98,7 @@ public class GameFileCache
public static String[] getAllGamePaths()
{
boolean recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBooleanGlobal();
boolean recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean();
LinkedHashSet<String> folderPathsSet = getPathSet(true);

View File

@ -36,7 +36,6 @@ import org.dolphinemu.dolphinemu.features.input.model.controlleremu.EmulatedCont
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import java.util.ArrayList;
import java.util.Arrays;
@ -145,13 +144,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
requestFocus();
}
public void setSurfacePosition(Settings settings, Rect rect)
public void setSurfacePosition(Rect rect)
{
mSurfacePosition = rect;
initTouchPointer(settings);
initTouchPointer();
}
public void initTouchPointer(Settings settings)
public void initTouchPointer()
{
// Check if we have all the data we need yet
boolean aspectRatioAvailable = NativeLibrary.IsRunningAndStarted();
@ -162,9 +161,9 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
if (!NativeLibrary.IsEmulatingWii())
return;
int doubleTapButton = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getIntGlobal();
int doubleTapButton = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getInt();
if (getConfiguredControllerType(settings) != InputOverlay.OVERLAY_WIIMOTE_CLASSIC &&
if (getConfiguredControllerType() != InputOverlay.OVERLAY_WIIMOTE_CLASSIC &&
doubleTapButton == ButtonType.CLASSIC_BUTTON_A)
{
doubleTapButton = ButtonType.WIIMOTE_BUTTON_A;
@ -185,8 +184,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
}
overlayPointer = new InputOverlayPointer(mSurfacePosition, doubleTapControl,
IntSetting.MAIN_IR_MODE.getIntGlobal(),
BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBooleanGlobal(), mControllerIndex);
IntSetting.MAIN_IR_MODE.getInt(), BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean(),
mControllerIndex);
}
@Override
@ -553,55 +552,55 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private void addGameCubeOverlayControls(String orientation)
{
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_0.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_0.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_a,
R.drawable.gcpad_a_pressed, ButtonType.BUTTON_A, ControlId.GCPAD_A_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_1.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_1.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_b,
R.drawable.gcpad_b_pressed, ButtonType.BUTTON_B, ControlId.GCPAD_B_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_2.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_2.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_x,
R.drawable.gcpad_x_pressed, ButtonType.BUTTON_X, ControlId.GCPAD_X_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_3.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_3.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_y,
R.drawable.gcpad_y_pressed, ButtonType.BUTTON_Y, ControlId.GCPAD_Y_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_4.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_4.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_z,
R.drawable.gcpad_z_pressed, ButtonType.BUTTON_Z, ControlId.GCPAD_Z_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_5.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_5.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_start,
R.drawable.gcpad_start_pressed, ButtonType.BUTTON_START, ControlId.GCPAD_START_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_6.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_6.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_l,
R.drawable.gcpad_l_pressed, ButtonType.TRIGGER_L, ControlId.GCPAD_L_DIGITAL,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_7.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_7.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_r,
R.drawable.gcpad_r_pressed, ButtonType.TRIGGER_R, ControlId.GCPAD_R_DIGITAL,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_8.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_8.getBoolean())
{
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction,
@ -609,13 +608,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
ButtonType.BUTTON_UP, ControlId.GCPAD_DPAD_UP, ControlId.GCPAD_DPAD_DOWN,
ControlId.GCPAD_DPAD_LEFT, ControlId.GCPAD_DPAD_RIGHT, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_9.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_9.getBoolean())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed, ButtonType.STICK_MAIN,
ControlId.GCPAD_MAIN_STICK_X, ControlId.GCPAD_MAIN_STICK_Y, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_10.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_10.getBoolean())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcpad_c, R.drawable.gcpad_c_pressed, ButtonType.STICK_C,
@ -625,49 +624,49 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private void addWiimoteOverlayControls(String orientation)
{
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_0.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_0.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_a,
R.drawable.wiimote_a_pressed, ButtonType.WIIMOTE_BUTTON_A, ControlId.WIIMOTE_A_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_1.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_1.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_b,
R.drawable.wiimote_b_pressed, ButtonType.WIIMOTE_BUTTON_B, ControlId.WIIMOTE_B_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_2.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_2.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_one,
R.drawable.wiimote_one_pressed, ButtonType.WIIMOTE_BUTTON_1,
ControlId.WIIMOTE_ONE_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_3.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_3.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_two,
R.drawable.wiimote_two_pressed, ButtonType.WIIMOTE_BUTTON_2,
ControlId.WIIMOTE_TWO_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_4.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_4.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus,
R.drawable.wiimote_plus_pressed, ButtonType.WIIMOTE_BUTTON_PLUS,
ControlId.WIIMOTE_PLUS_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_5.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_5.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus,
R.drawable.wiimote_minus_pressed, ButtonType.WIIMOTE_BUTTON_MINUS,
ControlId.WIIMOTE_MINUS_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_6.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_6.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home,
R.drawable.wiimote_home_pressed, ButtonType.WIIMOTE_BUTTON_HOME,
ControlId.WIIMOTE_HOME_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_7.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_7.getBoolean())
{
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction,
@ -679,19 +678,19 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private void addNunchukOverlayControls(String orientation)
{
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_8.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_8.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_c,
R.drawable.nunchuk_c_pressed, ButtonType.NUNCHUK_BUTTON_C, ControlId.NUNCHUK_C_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_9.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_9.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_z,
R.drawable.nunchuk_z_pressed, ButtonType.NUNCHUK_BUTTON_Z, ControlId.NUNCHUK_Z_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_10.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_10.getBoolean())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed,
@ -702,73 +701,73 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private void addClassicOverlayControls(String orientation)
{
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_0.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_0.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_a,
R.drawable.classic_a_pressed, ButtonType.CLASSIC_BUTTON_A, ControlId.CLASSIC_A_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_1.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_1.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_b,
R.drawable.classic_b_pressed, ButtonType.CLASSIC_BUTTON_B, ControlId.CLASSIC_B_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_2.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_2.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_x,
R.drawable.classic_x_pressed, ButtonType.CLASSIC_BUTTON_X, ControlId.CLASSIC_X_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_3.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_3.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_y,
R.drawable.classic_y_pressed, ButtonType.CLASSIC_BUTTON_Y, ControlId.CLASSIC_Y_BUTTON,
orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_4.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_4.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus,
R.drawable.wiimote_plus_pressed, ButtonType.CLASSIC_BUTTON_PLUS,
ControlId.CLASSIC_PLUS_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_5.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_5.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus,
R.drawable.wiimote_minus_pressed, ButtonType.CLASSIC_BUTTON_MINUS,
ControlId.CLASSIC_MINUS_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_6.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_6.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home,
R.drawable.wiimote_home_pressed, ButtonType.CLASSIC_BUTTON_HOME,
ControlId.CLASSIC_HOME_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_7.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_7.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_l,
R.drawable.classic_l_pressed, ButtonType.CLASSIC_TRIGGER_L,
ControlId.CLASSIC_L_DIGITAL, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_8.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_8.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_r,
R.drawable.classic_r_pressed, ButtonType.CLASSIC_TRIGGER_R,
ControlId.CLASSIC_R_DIGITAL, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_9.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_9.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zl,
R.drawable.classic_zl_pressed, ButtonType.CLASSIC_BUTTON_ZL,
ControlId.CLASSIC_ZL_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_10.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_10.getBoolean())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zr,
R.drawable.classic_zr_pressed, ButtonType.CLASSIC_BUTTON_ZR,
ControlId.CLASSIC_ZR_BUTTON, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_11.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_11.getBoolean())
{
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction,
@ -776,14 +775,14 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
ButtonType.CLASSIC_DPAD_UP, ControlId.CLASSIC_DPAD_UP, ControlId.CLASSIC_DPAD_DOWN,
ControlId.CLASSIC_DPAD_LEFT, ControlId.CLASSIC_DPAD_RIGHT, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_12.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_12.getBoolean())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed,
ButtonType.CLASSIC_STICK_LEFT, ControlId.CLASSIC_LEFT_STICK_X,
ControlId.CLASSIC_LEFT_STICK_Y, orientation));
}
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_13.getBooleanGlobal())
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_13.getBoolean())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed,
@ -792,7 +791,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
}
}
public void refreshControls(Settings settings)
public void refreshControls()
{
unregisterControllers();
@ -805,19 +804,19 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ?
"-Portrait" : "";
mControllerType = getConfiguredControllerType(settings);
mControllerType = getConfiguredControllerType();
IntSetting controllerSetting = NativeLibrary.IsEmulatingWii() ?
IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER;
int controllerIndex = controllerSetting.getInt(settings);
int controllerIndex = controllerSetting.getInt();
if (BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBooleanGlobal())
if (BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBoolean())
{
// Add all the enabled overlay items back to the HashSet.
switch (mControllerType)
{
case OVERLAY_GAMECUBE:
if (IntSetting.getSettingForSIDevice(controllerIndex).getInt(settings) ==
if (IntSetting.getSettingForSIDevice(controllerIndex).getInt() ==
DISABLED_GAMECUBE_CONTROLLER && mIsFirstRun)
{
Toast.makeText(getContext(), R.string.disabled_gc_overlay_notice, Toast.LENGTH_SHORT)
@ -866,21 +865,21 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
invalidate();
}
public void refreshOverlayPointer(Settings settings)
public void refreshOverlayPointer()
{
if (overlayPointer != null)
{
overlayPointer.setMode(IntSetting.MAIN_IR_MODE.getInt(settings));
overlayPointer.setRecenter(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean(settings));
overlayPointer.setMode(IntSetting.MAIN_IR_MODE.getInt());
overlayPointer.setRecenter(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean());
}
}
public void resetButtonPlacement(Settings settings)
public void resetButtonPlacement()
{
boolean isLandscape =
getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
final int controller = getConfiguredControllerType(settings);
final int controller = getConfiguredControllerType();
if (controller == OVERLAY_GAMECUBE)
{
if (isLandscape)
@ -908,26 +907,26 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
wiiOnlyPortraitDefaultOverlay();
}
}
refreshControls(settings);
refreshControls();
}
public static int getConfiguredControllerType(Settings settings)
public static int getConfiguredControllerType()
{
IntSetting controllerSetting = NativeLibrary.IsEmulatingWii() ?
IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER;
int controllerIndex = controllerSetting.getInt(settings);
int controllerIndex = controllerSetting.getInt();
if (controllerIndex >= 0 && controllerIndex < 4)
{
// GameCube controller
if (IntSetting.getSettingForSIDevice(controllerIndex).getInt(settings) == 6)
if (IntSetting.getSettingForSIDevice(controllerIndex).getInt() == 6)
return OVERLAY_GAMECUBE;
}
else if (controllerIndex >= 4 && controllerIndex < 8)
{
// Wii Remote
int wiimoteIndex = controllerIndex - 4;
if (IntSetting.getSettingForWiimoteSource(wiimoteIndex).getInt(settings) == 1)
if (IntSetting.getSettingForWiimoteSource(wiimoteIndex).getInt() == 1)
{
int attachmentIndex = EmulatedController.getSelectedWiimoteAttachment(wiimoteIndex);
switch (attachmentIndex)
@ -939,7 +938,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
}
NumericSetting sidewaysSetting = EmulatedController.getSidewaysWiimoteSetting(wiimoteIndex);
boolean sideways = new InputMappingBooleanSetting(sidewaysSetting).getBoolean(settings);
boolean sideways = new InputMappingBooleanSetting(sidewaysSetting).getBoolean();
return sideways ? OVERLAY_WIIMOTE_SIDEWAYS : OVERLAY_WIIMOTE;
}
@ -1071,7 +1070,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
break;
}
scale *= (IntSetting.MAIN_CONTROL_SCALE.getIntGlobal() + 50);
scale *= (IntSetting.MAIN_CONTROL_SCALE.getInt() + 50);
scale /= 100;
// Initialize the InputOverlayDrawableButton.
@ -1097,7 +1096,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Need to set the image's position
overlayDrawable.setPosition(drawableX, drawableY);
overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getIntGlobal() * 255 / 100);
overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getInt() * 255 / 100);
return overlayDrawable;
}
@ -1152,7 +1151,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
break;
}
scale *= (IntSetting.MAIN_CONTROL_SCALE.getIntGlobal() + 50);
scale *= (IntSetting.MAIN_CONTROL_SCALE.getInt() + 50);
scale /= 100;
// Initialize the InputOverlayDrawableDpad.
@ -1183,7 +1182,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Need to set the image's position
overlayDrawable.setPosition(drawableX, drawableY);
overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getIntGlobal() * 255 / 100);
overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getInt() * 255 / 100);
return overlayDrawable;
}
@ -1212,7 +1211,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Decide scale based on user preference
float scale = 0.275f;
scale *= (IntSetting.MAIN_CONTROL_SCALE.getIntGlobal() + 50);
scale *= (IntSetting.MAIN_CONTROL_SCALE.getInt() + 50);
scale /= 100;
// Initialize the InputOverlayDrawableJoystick.
@ -1252,7 +1251,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Need to set the image's position
overlayDrawable.setPosition(drawableX, drawableY);
overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getIntGlobal() * 255 / 100);
overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getInt() * 255 / 100);
return overlayDrawable;
}

View File

@ -102,7 +102,7 @@ public final class InputOverlayDrawableJoystick
public boolean TrackEvent(MotionEvent event)
{
boolean reCenter = BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBooleanGlobal();
boolean reCenter = BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean();
int action = event.getActionMasked();
boolean firstPointer = action != MotionEvent.ACTION_POINTER_DOWN &&
action != MotionEvent.ACTION_POINTER_UP;

View File

@ -378,7 +378,7 @@ public final class MainActivity extends AppCompatActivity
public void onTabSelected(@NonNull TabLayout.Tab tab)
{
super.onTabSelected(tab);
IntSetting.MAIN_LAST_PLATFORM_TAB.setIntGlobal(NativeConfig.LAYER_BASE,
IntSetting.MAIN_LAST_PLATFORM_TAB.setInt(NativeConfig.LAYER_BASE,
tab.getPosition());
}
});
@ -388,7 +388,7 @@ public final class MainActivity extends AppCompatActivity
mBinding.tabsPlatforms.getTabAt(i).setIcon(PlatformPagerAdapter.TAB_ICONS[i]);
}
mBinding.pagerPlatforms.setCurrentItem(IntSetting.MAIN_LAST_PLATFORM_TAB.getIntGlobal());
mBinding.pagerPlatforms.setCurrentItem(IntSetting.MAIN_LAST_PLATFORM_TAB.getInt());
showGames();
GameFileCacheManager.startLoad();

View File

@ -175,7 +175,7 @@ public final class MainPresenter
{
Uri uri = result.getData();
boolean recursive = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBooleanGlobal();
boolean recursive = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean();
String[] childNames = ContentHandler.getChildNames(uri, recursive);
if (Arrays.stream(childNames).noneMatch((name) -> FileBrowserHelper.GAME_EXTENSIONS.contains(
FileBrowserHelper.getExtension(name, false))))

View File

@ -21,7 +21,7 @@ object Analytics {
@JvmStatic
fun checkAnalyticsInit(activity: FragmentActivity) {
AfterDirectoryInitializationRunner().runWithoutLifecycle {
if (!BooleanSetting.MAIN_ANALYTICS_PERMISSION_ASKED.booleanGlobal) {
if (!BooleanSetting.MAIN_ANALYTICS_PERMISSION_ASKED.boolean) {
AnalyticsDialog().show(activity.supportFragmentManager, AnalyticsDialog.TAG)
}
}
@ -34,7 +34,7 @@ object Analytics {
BooleanSetting.MAIN_ANALYTICS_PERMISSION_ASKED.setBoolean(settings, true)
// Context is set to null to avoid toasts
settings.saveSettings(null, null)
settings.saveSettings(null)
}
}

View File

@ -37,7 +37,7 @@ object CoilUtils {
}
)
}
} else if (BooleanSetting.MAIN_USE_GAME_COVERS.booleanGlobal) {
} else if (BooleanSetting.MAIN_USE_GAME_COVERS.boolean) {
imageView.load(CoverHelper.buildGameTDBUrl(gameFile, CoverHelper.getRegion(gameFile))) {
error(R.drawable.no_banner)
target(
@ -58,13 +58,13 @@ object CoilUtils {
}
private fun enableInnerTitle(gameViewHolder: GameViewHolder?) {
if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.booleanGlobal) {
if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.boolean) {
gameViewHolder.binding.textGameTitleInner.visibility = View.VISIBLE
}
}
private fun disableInnerTitle(gameViewHolder: GameViewHolder?) {
if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.booleanGlobal) {
if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.boolean) {
gameViewHolder.binding.textGameTitleInner.visibility = View.GONE
}
}

View File

@ -361,30 +361,29 @@ public final class DirectoryInitialization
private static void checkThemeSettings(Context context)
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if (IntSetting.MAIN_INTERFACE_THEME.getIntGlobal() !=
if (IntSetting.MAIN_INTERFACE_THEME.getInt() !=
preferences.getInt(ThemeHelper.CURRENT_THEME, ThemeHelper.DEFAULT))
{
preferences.edit()
.putInt(ThemeHelper.CURRENT_THEME, IntSetting.MAIN_INTERFACE_THEME.getIntGlobal())
.putInt(ThemeHelper.CURRENT_THEME, IntSetting.MAIN_INTERFACE_THEME.getInt())
.apply();
}
if (IntSetting.MAIN_INTERFACE_THEME_MODE.getIntGlobal() !=
if (IntSetting.MAIN_INTERFACE_THEME_MODE.getInt() !=
preferences.getInt(ThemeHelper.CURRENT_THEME_MODE,
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM))
{
preferences.edit()
.putInt(ThemeHelper.CURRENT_THEME_MODE,
IntSetting.MAIN_INTERFACE_THEME_MODE.getIntGlobal())
.putInt(ThemeHelper.CURRENT_THEME_MODE, IntSetting.MAIN_INTERFACE_THEME_MODE.getInt())
.apply();
}
if (BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBooleanGlobal() !=
if (BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBoolean() !=
preferences.getBoolean(ThemeHelper.USE_BLACK_BACKGROUNDS, false))
{
preferences.edit()
.putBoolean(ThemeHelper.USE_BLACK_BACKGROUNDS,
BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBooleanGlobal())
BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBoolean())
.apply();
}
}

View File

@ -79,7 +79,7 @@ public final class FileBrowserHelper
public static boolean isPathEmptyOrValid(StringSetting path)
{
return isPathEmptyOrValid(path.getStringGlobal());
return isPathEmptyOrValid(path.getString());
}
/**

View File

@ -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);
@ -134,12 +138,14 @@ Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_unloadGameIn
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_save(
JNIEnv*, jclass, jint layer)
{
const std::shared_ptr<Config::Layer> layer_ptr = GetLayer(layer, {});
return GetLayer(layer, {})->Save();
}
// Workaround for the Settings class carrying around a legacy map of settings it always saves
layer_ptr->MarkAsDirty();
return layer_ptr->Save();
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_deleteAllKeys(JNIEnv*, jclass,
jint layer)
{
return GetLayer(layer, {})->DeleteAllKeys();
}
JNIEXPORT jboolean JNICALL
@ -162,6 +168,16 @@ Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_deleteKey(
return static_cast<jboolean>(had_value);
}
JNIEXPORT jboolean JNICALL
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_exists(JNIEnv* env, jclass,
jint layer, jstring file,
jstring section,
jstring key)
{
const Config::Location location = GetLocation(env, file, section, key);
return static_cast<jboolean>(GetLayer(layer, location)->Exists(location));
}
JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_getString(
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key,

View File

@ -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)
{

View File

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

View File

@ -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())
{

View File

@ -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;
}

View File

@ -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;