Add SingleChoiceSettingDynamicDescriptions
This commit is contained in:
parent
630de81309
commit
7d98c4f3a4
|
@ -20,6 +20,7 @@ public abstract class SettingsItem
|
||||||
public static final int TYPE_INPUT_BINDING = 5;
|
public static final int TYPE_INPUT_BINDING = 5;
|
||||||
public static final int TYPE_STRING_SINGLE_CHOICE = 6;
|
public static final int TYPE_STRING_SINGLE_CHOICE = 6;
|
||||||
public static final int TYPE_RUMBLE_BINDING = 7;
|
public static final int TYPE_RUMBLE_BINDING = 7;
|
||||||
|
public static final int TYPE_SINGLE_CHOICE_DYNAMIC_DESCRIPTIONS = 8;
|
||||||
|
|
||||||
private String mKey;
|
private String mKey;
|
||||||
private String mSection;
|
private String mSection;
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
package org.dolphinemu.dolphinemu.features.settings.model.view;
|
||||||
|
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.Setting;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||||
|
|
||||||
|
public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem
|
||||||
|
{
|
||||||
|
private int mDefaultValue;
|
||||||
|
|
||||||
|
private int mChoicesId;
|
||||||
|
private int mValuesId;
|
||||||
|
private int mDescriptionChoicesId;
|
||||||
|
private int mDescriptionValuesId;
|
||||||
|
private MenuTag menuTag;
|
||||||
|
|
||||||
|
public SingleChoiceSettingDynamicDescriptions(String key, String section, int titleId,
|
||||||
|
int descriptionId,
|
||||||
|
int choicesId, int valuesId, int descriptionChoicesId, int descriptionValuesId,
|
||||||
|
int defaultValue, Setting setting, MenuTag menuTag)
|
||||||
|
{
|
||||||
|
super(key, section, setting, titleId, descriptionId);
|
||||||
|
mValuesId = valuesId;
|
||||||
|
mChoicesId = choicesId;
|
||||||
|
mDescriptionChoicesId = descriptionChoicesId;
|
||||||
|
mDescriptionValuesId = descriptionValuesId;
|
||||||
|
mDefaultValue = defaultValue;
|
||||||
|
this.menuTag = menuTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleChoiceSettingDynamicDescriptions(String key, String section, int titleId,
|
||||||
|
int descriptionId,
|
||||||
|
int choicesId, int valuesId, int descriptionChoicesId, int descriptionValuesId,
|
||||||
|
int defaultValue, Setting setting)
|
||||||
|
{
|
||||||
|
this(key, section, titleId, descriptionId, choicesId, valuesId, descriptionChoicesId,
|
||||||
|
descriptionValuesId, defaultValue, setting, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChoicesId()
|
||||||
|
{
|
||||||
|
return mChoicesId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValuesId()
|
||||||
|
{
|
||||||
|
return mValuesId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDescriptionChoicesId()
|
||||||
|
{
|
||||||
|
return mDescriptionChoicesId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDescriptionValuesId()
|
||||||
|
{
|
||||||
|
return mDescriptionValuesId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSelectedValue()
|
||||||
|
{
|
||||||
|
if (getSetting() != null)
|
||||||
|
{
|
||||||
|
IntSetting setting = (IntSetting) getSetting();
|
||||||
|
return setting.getValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mDefaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuTag getMenuTag()
|
||||||
|
{
|
||||||
|
return menuTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a value to the backing int. If that int was previously null,
|
||||||
|
* initializes a new one and returns it, so it can be added to the Hashmap.
|
||||||
|
*
|
||||||
|
* @param selection New value of the int.
|
||||||
|
* @return null if overwritten successfully otherwise; a newly created IntSetting.
|
||||||
|
*/
|
||||||
|
public IntSetting setSelectedValue(int selection)
|
||||||
|
{
|
||||||
|
if (getSetting() == null)
|
||||||
|
{
|
||||||
|
IntSetting setting = new IntSetting(getKey(), getSection(), selection);
|
||||||
|
setSetting(setting);
|
||||||
|
return setting;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IntSetting setting = (IntSetting) getSetting();
|
||||||
|
setting.setValue(selection);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType()
|
||||||
|
{
|
||||||
|
return TYPE_SINGLE_CHOICE_DYNAMIC_DESCRIPTIONS;
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.InputBindingSettin
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.RumbleBindingSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.RumbleBindingSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSetting;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSettingDynamicDescriptions;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SliderSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SliderSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
|
||||||
|
@ -78,6 +79,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||||
return new CheckBoxSettingViewHolder(view, this);
|
return new CheckBoxSettingViewHolder(view, this);
|
||||||
|
|
||||||
case SettingsItem.TYPE_STRING_SINGLE_CHOICE:
|
case SettingsItem.TYPE_STRING_SINGLE_CHOICE:
|
||||||
|
case SettingsItem.TYPE_SINGLE_CHOICE_DYNAMIC_DESCRIPTIONS:
|
||||||
case SettingsItem.TYPE_SINGLE_CHOICE:
|
case SettingsItem.TYPE_SINGLE_CHOICE:
|
||||||
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||||
return new SingleChoiceViewHolder(view, this);
|
return new SingleChoiceViewHolder(view, this);
|
||||||
|
@ -187,6 +189,22 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||||
mDialog = builder.show();
|
mDialog = builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSingleChoiceDynamicDescriptionsClick(SingleChoiceSettingDynamicDescriptions item,
|
||||||
|
int position)
|
||||||
|
{
|
||||||
|
mClickedItem = item;
|
||||||
|
mClickedPosition = position;
|
||||||
|
|
||||||
|
int value = getSelectionForSingleChoiceDynamicDescriptionsValue(item);
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());
|
||||||
|
|
||||||
|
builder.setTitle(item.getNameId());
|
||||||
|
builder.setSingleChoiceItems(item.getChoicesId(), value, this);
|
||||||
|
|
||||||
|
mDialog = builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
public void onSliderClick(SliderSetting item, int position)
|
public void onSliderClick(SliderSetting item, int position)
|
||||||
{
|
{
|
||||||
mClickedItem = item;
|
mClickedItem = item;
|
||||||
|
@ -312,6 +330,24 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||||
|
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
|
else if (mClickedItem instanceof SingleChoiceSettingDynamicDescriptions)
|
||||||
|
{
|
||||||
|
SingleChoiceSettingDynamicDescriptions scSetting =
|
||||||
|
(SingleChoiceSettingDynamicDescriptions) mClickedItem;
|
||||||
|
|
||||||
|
int value = getValueForSingleChoiceDynamicDescriptionsSelection(scSetting, which);
|
||||||
|
if (scSetting.getSelectedValue() != value)
|
||||||
|
mView.onSettingChanged();
|
||||||
|
|
||||||
|
// Get the backing Setting, which may be null (if for example it was missing from the file)
|
||||||
|
IntSetting setting = scSetting.setSelectedValue(value);
|
||||||
|
if (setting != null)
|
||||||
|
{
|
||||||
|
mView.putSetting(setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
closeDialog();
|
||||||
|
}
|
||||||
else if (mClickedItem instanceof StringSingleChoiceSetting)
|
else if (mClickedItem instanceof StringSingleChoiceSetting)
|
||||||
{
|
{
|
||||||
StringSingleChoiceSetting scSetting = (StringSingleChoiceSetting) mClickedItem;
|
StringSingleChoiceSetting scSetting = (StringSingleChoiceSetting) mClickedItem;
|
||||||
|
@ -439,6 +475,48 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getValueForSingleChoiceDynamicDescriptionsSelection(
|
||||||
|
SingleChoiceSettingDynamicDescriptions item, int which)
|
||||||
|
{
|
||||||
|
int valuesId = item.getValuesId();
|
||||||
|
|
||||||
|
if (valuesId > 0)
|
||||||
|
{
|
||||||
|
int[] valuesArray = mContext.getResources().getIntArray(valuesId);
|
||||||
|
return valuesArray[which];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return which;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSelectionForSingleChoiceDynamicDescriptionsValue(
|
||||||
|
SingleChoiceSettingDynamicDescriptions item)
|
||||||
|
{
|
||||||
|
int value = item.getSelectedValue();
|
||||||
|
int valuesId = item.getValuesId();
|
||||||
|
|
||||||
|
if (valuesId > 0)
|
||||||
|
{
|
||||||
|
int[] valuesArray = mContext.getResources().getIntArray(valuesId);
|
||||||
|
for (int index = 0; index < valuesArray.length; index++)
|
||||||
|
{
|
||||||
|
int current = valuesArray[index];
|
||||||
|
if (current == value)
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
private void putVideoBackendSetting(int which)
|
private void putVideoBackendSetting(int which)
|
||||||
{
|
{
|
||||||
StringSetting gfxBackend = null;
|
StringSetting gfxBackend = null;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.InputBindingSettin
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.RumbleBindingSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.RumbleBindingSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSetting;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSettingDynamicDescriptions;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SliderSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SliderSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
|
||||||
|
@ -418,10 +419,11 @@ public final class SettingsFragmentPresenter
|
||||||
R.array.videoBackendValues, 0, videoBackend));
|
R.array.videoBackendValues, 0, videoBackend));
|
||||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_SHOW_FPS, Settings.SECTION_GFX_SETTINGS,
|
sl.add(new CheckBoxSetting(SettingsFile.KEY_SHOW_FPS, Settings.SECTION_GFX_SETTINGS,
|
||||||
R.string.show_fps, R.string.show_fps_description, false, showFps));
|
R.string.show_fps, R.string.show_fps_description, false, showFps));
|
||||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_SHADER_COMPILATION_MODE,
|
sl.add(new SingleChoiceSettingDynamicDescriptions(SettingsFile.KEY_SHADER_COMPILATION_MODE,
|
||||||
Settings.SECTION_GFX_SETTINGS, R.string.shader_compilation_mode,
|
Settings.SECTION_GFX_SETTINGS, R.string.shader_compilation_mode, 0,
|
||||||
R.string.shader_compilation_mode_description, R.array.shaderCompilationModeEntries,
|
R.array.shaderCompilationModeEntries,
|
||||||
R.array.shaderCompilationModeValues, 0, shaderCompilationMode));
|
R.array.shaderCompilationModeValues, R.array.shaderCompilationDescriptionEntries,
|
||||||
|
R.array.shaderCompilationDescriptionValues, 0, shaderCompilationMode));
|
||||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_WAIT_FOR_SHADERS, Settings.SECTION_GFX_SETTINGS,
|
sl.add(new CheckBoxSetting(SettingsFile.KEY_WAIT_FOR_SHADERS, Settings.SECTION_GFX_SETTINGS,
|
||||||
R.string.wait_for_shaders, R.string.wait_for_shaders_description, false,
|
R.string.wait_for_shaders, R.string.wait_for_shaders_description, false,
|
||||||
waitForShaders));
|
waitForShaders));
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.widget.TextView;
|
||||||
import org.dolphinemu.dolphinemu.R;
|
import org.dolphinemu.dolphinemu.R;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSetting;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSettingDynamicDescriptions;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
|
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
|
||||||
|
|
||||||
|
@ -63,6 +64,22 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
|
||||||
if (valueIndex != -1)
|
if (valueIndex != -1)
|
||||||
mTextSettingDescription.setText(choices[valueIndex]);
|
mTextSettingDescription.setText(choices[valueIndex]);
|
||||||
}
|
}
|
||||||
|
else if (item instanceof SingleChoiceSettingDynamicDescriptions)
|
||||||
|
{
|
||||||
|
SingleChoiceSettingDynamicDescriptions setting =
|
||||||
|
(SingleChoiceSettingDynamicDescriptions) item;
|
||||||
|
int selected = setting.getSelectedValue();
|
||||||
|
Resources resMgr = mTextSettingDescription.getContext().getResources();
|
||||||
|
String[] choices = resMgr.getStringArray(setting.getDescriptionChoicesId());
|
||||||
|
int[] values = resMgr.getIntArray(setting.getDescriptionValuesId());
|
||||||
|
for (int i = 0; i < values.length; ++i)
|
||||||
|
{
|
||||||
|
if (values[i] == selected)
|
||||||
|
{
|
||||||
|
mTextSettingDescription.setText(choices[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,5 +94,10 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
|
||||||
{
|
{
|
||||||
getAdapter().onStringSingleChoiceClick((StringSingleChoiceSetting) mItem, position);
|
getAdapter().onStringSingleChoiceClick((StringSingleChoiceSetting) mItem, position);
|
||||||
}
|
}
|
||||||
|
else if (mItem instanceof SingleChoiceSettingDynamicDescriptions)
|
||||||
|
{
|
||||||
|
getAdapter().onSingleChoiceDynamicDescriptionsClick(
|
||||||
|
(SingleChoiceSettingDynamicDescriptions) mItem, position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,20 @@
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
</integer-array>
|
</integer-array>
|
||||||
|
|
||||||
|
<!-- Ubershader Mode Dynamic Descriptions -->
|
||||||
|
<string-array name="shaderCompilationDescriptionEntries" translatable="false">
|
||||||
|
<item>Synchronous: Ubershaders are never used. Stuttering will occur during shader compilation, but GPU demands are low. Recommended for low-end hardware.\nIf unsure, select this mode.</item>
|
||||||
|
<item>Synchronous (Ubershaders): Ubershaders will always be used. Provides a near stutter-free experience at the cost of high GPU performance requirements. Only recommended for high-end systems.</item>
|
||||||
|
<item>Asynchronous (Ubershaders): Ubershaders will be used to prevent stuttering during shader compilation, but specialized shaders will be used when they will not cause stuttering. In the best case it eliminates shader compilation stuttering while having minimal performance impact, but results depend on video driver behavior.</item>
|
||||||
|
<item>Asynchronous (Skip Drawing): Prevents shader compilation stuttering by not rendering waiting objects. Can work in scenarios where Ubershaders doesn\'t, at the cost of introducing visual glitches and broken effects. Not recommended, only use if the other options give poor results on your system.</item>
|
||||||
|
</string-array>
|
||||||
|
<integer-array name="shaderCompilationDescriptionValues" translatable="false">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
|
</integer-array>
|
||||||
|
|
||||||
<!-- Internal Resolution Preference -->
|
<!-- Internal Resolution Preference -->
|
||||||
<string-array name="internalResolutionEntries" translatable="false">
|
<string-array name="internalResolutionEntries" translatable="false">
|
||||||
<item>1x Native (640x528)</item>
|
<item>1x Native (640x528)</item>
|
||||||
|
|
|
@ -238,7 +238,6 @@
|
||||||
<string name="aspect_ratio">Aspect Ratio</string>
|
<string name="aspect_ratio">Aspect Ratio</string>
|
||||||
<string name="aspect_ratio_description">Select what aspect ratio to use when rendering</string>
|
<string name="aspect_ratio_description">Select what aspect ratio to use when rendering</string>
|
||||||
<string name="shader_compilation_mode">Shader Compilation Mode</string>
|
<string name="shader_compilation_mode">Shader Compilation Mode</string>
|
||||||
<string name="shader_compilation_mode_description">Specifies when to use Ubershaders. Disabled - Never, Hybrid - Use ubershaders while compiling specialized shaders. Exclusive - Use only ubershaders, largest performance impact. Skip Drawing - Do not draw objects while shaders are compiling, will cause broken effects.</string>
|
|
||||||
<string name="wait_for_shaders">Compile Shaders Before Starting</string>
|
<string name="wait_for_shaders">Compile Shaders Before Starting</string>
|
||||||
<string name="wait_for_shaders_description">This causes a delay when launching games, but will reduce stuttering early on.</string>
|
<string name="wait_for_shaders_description">This causes a delay when launching games, but will reduce stuttering early on.</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue