Android: Show overridden game settings in bold

This commit is contained in:
JosJuice 2020-07-22 17:51:02 +02:00
parent e24d50e881
commit 736505f020
32 changed files with 210 additions and 0 deletions

View File

@ -13,6 +13,12 @@ public class AbstractLegacySetting implements AbstractSetting
mKey = key;
}
@Override
public boolean isOverridden(Settings settings)
{
return settings.isGameSpecific() && settings.getSection(mFile, mSection).exists(mKey);
}
@Override
public boolean delete(Settings settings)
{

View File

@ -2,5 +2,7 @@ package org.dolphinemu.dolphinemu.features.settings.model;
public interface AbstractSetting
{
boolean isOverridden(Settings settings);
boolean delete(Settings settings);
}

View File

@ -20,6 +20,12 @@ public class AdHocBooleanSetting implements AbstractBooleanSetting
}
}
@Override
public boolean isOverridden(Settings settings)
{
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@Override
public boolean delete(Settings settings)
{

View File

@ -107,6 +107,15 @@ public enum BooleanSetting implements AbstractBooleanSetting
mDefaultValue = defaultValue;
}
@Override
public boolean isOverridden(Settings settings)
{
if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey))
return settings.getSection(mFile, mSection).exists(mKey);
else
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@Override
public boolean delete(Settings settings)
{

View File

@ -20,6 +20,15 @@ public enum FloatSetting implements AbstractFloatSetting
mDefaultValue = defaultValue;
}
@Override
public boolean isOverridden(Settings settings)
{
if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey))
return settings.getSection(mFile, mSection).exists(mKey);
else
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@Override
public boolean delete(Settings settings)
{

View File

@ -47,6 +47,15 @@ public enum IntSetting implements AbstractIntSetting
mDefaultValue = defaultValue;
}
@Override
public boolean isOverridden(Settings settings)
{
if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey))
return settings.getSection(mFile, mSection).exists(mKey);
else
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@Override
public boolean delete(Settings settings)
{

View File

@ -13,6 +13,8 @@ public class NativeConfig
public static native void save(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 String getString(int layer, String file, String section, String key,

View File

@ -33,6 +33,15 @@ public enum StringSetting implements AbstractStringSetting
mDefaultValue = defaultValue;
}
@Override
public boolean isOverridden(Settings settings)
{
if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey))
return settings.getSection(mFile, mSection).exists(mKey);
else
return NativeConfig.isOverridden(mFile, mSection, mKey);
}
@Override
public boolean delete(Settings settings)
{

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public class CheckBoxSetting extends SettingsItem
@ -28,4 +29,10 @@ public class CheckBoxSetting extends SettingsItem
{
return TYPE_CHECKBOX;
}
@Override
public AbstractSetting getSetting()
{
return mSetting;
}
}

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
public final class ConfirmRunnable extends SettingsItem
{
private int mAlertText;
@ -35,4 +37,10 @@ public final class ConfirmRunnable extends SettingsItem
{
return TYPE_CONFIRM_RUNNABLE;
}
@Override
public AbstractSetting getSetting()
{
return null;
}
}

View File

@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -35,4 +36,10 @@ public final class FilePicker extends SettingsItem
{
return TYPE_FILE_PICKER;
}
@Override
public AbstractSetting getSetting()
{
return mSetting;
}
}

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public class FloatSliderSetting extends SliderSetting
@ -23,4 +24,10 @@ public class FloatSliderSetting extends SliderSetting
{
mSetting.setFloat(settings, selection);
}
@Override
public AbstractSetting getSetting()
{
return mSetting;
}
}

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
public final class HeaderSetting extends SettingsItem
{
public HeaderSetting(int titleId, int descriptionId)
@ -12,4 +14,10 @@ public final class HeaderSetting extends SettingsItem
{
return SettingsItem.TYPE_HEADER;
}
@Override
public AbstractSetting getSetting()
{
return null;
}
}

View File

@ -6,6 +6,7 @@ import android.view.InputDevice;
import android.view.KeyEvent;
import org.dolphinemu.dolphinemu.DolphinApplication;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public class InputBindingSetting extends SettingsItem
@ -93,4 +94,10 @@ public class InputBindingSetting extends SettingsItem
{
return mGameId;
}
@Override
public AbstractSetting getSetting()
{
return null;
}
}

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public final class IntSliderSetting extends SliderSetting
@ -23,4 +24,10 @@ public final class IntSliderSetting extends SliderSetting
{
mSetting.setInt(settings, selection);
}
@Override
public AbstractSetting getSetting()
{
return mSetting;
}
}

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public final class InvertedCheckBoxSetting extends CheckBoxSetting
@ -22,4 +23,10 @@ public final class InvertedCheckBoxSetting extends CheckBoxSetting
{
mSetting.setBoolean(settings, !checked);
}
@Override
public AbstractSetting getSetting()
{
return mSetting;
}
}

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public final class PercentSliderSetting extends FloatSliderSetting
@ -22,4 +23,10 @@ public final class PercentSliderSetting extends FloatSliderSetting
{
mSetting.setFloat(settings, selection / 100);
}
@Override
public AbstractSetting getSetting()
{
return mSetting;
}
}

View File

@ -6,6 +6,7 @@ import android.view.KeyEvent;
import org.dolphinemu.dolphinemu.DolphinApplication;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.utils.Rumble;
@ -55,4 +56,10 @@ public class RumbleBindingSetting extends InputBindingSetting
{
return TYPE_RUMBLE_BINDING;
}
@Override
public AbstractSetting getSetting()
{
return null;
}
}

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
/**
@ -57,4 +59,12 @@ public abstract class SettingsItem
* @return An integer (ideally, one of the constants defined in this file)
*/
public abstract int getType();
protected abstract AbstractSetting getSetting();
public boolean isOverridden(Settings settings)
{
AbstractSetting setting = getSetting();
return setting != null && setting.isOverridden(settings);
}
}

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
@ -58,4 +59,10 @@ public final class SingleChoiceSetting extends SettingsItem
{
return TYPE_SINGLE_CHOICE;
}
@Override
public AbstractSetting getSetting()
{
return mSetting;
}
}

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
@ -75,4 +76,10 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem
{
return TYPE_SINGLE_CHOICE_DYNAMIC_DESCRIPTIONS;
}
@Override
public AbstractSetting getSetting()
{
return mSetting;
}
}

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.DolphinApplication;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
@ -102,6 +103,12 @@ public class StringSingleChoiceSetting extends SettingsItem
{
return TYPE_STRING_SINGLE_CHOICE;
}
@Override
public AbstractSetting getSetting()
{
return mSetting;
}
}

View File

@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
public final class SubmenuSetting extends SettingsItem
@ -22,4 +23,10 @@ public final class SubmenuSetting extends SettingsItem
{
return TYPE_SUBMENU;
}
@Override
public AbstractSetting getSetting()
{
return null;
}
}

View File

@ -293,6 +293,13 @@ public final class SettingsFragmentPresenter
}
}
@Override
public boolean isOverridden(Settings settings)
{
return BooleanSetting.MAIN_DSP_HLE.isOverridden(settings) ||
BooleanSetting.MAIN_DSP_JIT.isOverridden(settings);
}
@Override
public boolean delete(Settings settings)
{

View File

@ -59,6 +59,8 @@ public final class CheckBoxSettingViewHolder extends SettingViewHolder
}
mCheckbox.setChecked(mItem.isChecked(getAdapter().getSettings()));
setStyle(mTextSettingName, mItem);
}
@Override
@ -67,5 +69,7 @@ public final class CheckBoxSettingViewHolder extends SettingViewHolder
mCheckbox.toggle();
getAdapter().onBooleanClick(mItem, getAdapterPosition(), mCheckbox.isChecked());
setStyle(mTextSettingName, mItem);
}
}

View File

@ -45,6 +45,8 @@ public final class FilePickerViewHolder extends SettingViewHolder
{
mTextSettingDescription.setText(mFilePicker.getSelectedValue(getAdapter().getSettings()));
}
setStyle(mTextSettingName, mItem);
}
@Override
@ -58,5 +60,7 @@ public final class FilePickerViewHolder extends SettingViewHolder
{
getAdapter().onFilePickerFileClick(mItem);
}
setStyle(mTextSettingName, mItem);
}
}

View File

@ -44,11 +44,15 @@ public final class InputBindingSettingViewHolder extends SettingViewHolder
mTextSettingName.setText(mItem.getNameId());
mTextSettingDescription
.setText(sharedPreferences.getString(mItem.getKey() + mItem.getGameId(), ""));
setStyle(mTextSettingName, mItem);
}
@Override
public void onClick(View clicked)
{
getAdapter().onInputBindingClick(mItem, getAdapterPosition());
setStyle(mTextSettingName, mItem);
}
}

View File

@ -44,11 +44,15 @@ public class RumbleBindingViewHolder extends SettingViewHolder
mTextSettingName.setText(item.getNameId());
mTextSettingDescription
.setText(sharedPreferences.getString(mItem.getKey() + mItem.getGameId(), ""));
setStyle(mTextSettingName, mItem);
}
@Override
public void onClick(View clicked)
{
getAdapter().onInputBindingClick(mItem, getAdapterPosition());
setStyle(mTextSettingName, mItem);
}
}

View File

@ -1,6 +1,8 @@
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;
import android.graphics.Typeface;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
@ -28,6 +30,12 @@ public abstract class SettingViewHolder extends RecyclerView.ViewHolder
return mAdapter;
}
protected void setStyle(TextView textView, SettingsItem settingsItem)
{
boolean overridden = settingsItem.isOverridden(mAdapter.getSettings());
textView.setTypeface(null, overridden ? Typeface.BOLD : Typeface.NORMAL);
}
/**
* Gets handles to all this ViewHolder's child views using their XML-defined identifiers.
*

View File

@ -80,6 +80,8 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
}
}
}
setStyle(mTextSettingName, mItem);
}
@Override
@ -99,5 +101,7 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
getAdapter().onSingleChoiceDynamicDescriptionsClick(
(SingleChoiceSettingDynamicDescriptions) mItem, position);
}
setStyle(mTextSettingName, mItem);
}
}

View File

@ -49,12 +49,16 @@ public final class SliderViewHolder extends SettingViewHolder
.getString(R.string.slider_setting_value,
mItem.getSelectedValue(getAdapter().getSettings()), mItem.getUnits()));
}
setStyle(mTextSettingName, mItem);
}
@Override
public void onClick(View clicked)
{
getAdapter().onSliderClick(mItem, getAdapterPosition());
setStyle(mTextSettingName, mItem);
}
}

View File

@ -112,6 +112,15 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_Na
return GetLayer(layer, {})->Save();
}
JNIEXPORT jboolean JNICALL
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_isOverridden(
JNIEnv* env, jclass obj, jstring file, jstring section, jstring key)
{
const Config::Location location = GetLocation(env, file, section, key);
const bool result = Config::GetActiveLayerForConfig(location) != Config::LayerType::Base;
return static_cast<jboolean>(result);
}
JNIEXPORT jboolean JNICALL
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_deleteKey(
JNIEnv* env, jclass obj, jint layer, jstring file, jstring section, jstring key)