Skip to content
Permalink
Browse files

Merge pull request #7810 from Ebola16/GFXUI

Android: Graphic setting description improvements
  • Loading branch information...
Helios747 committed Sep 1, 2019
2 parents b0a5a9f + 7d98c4f commit ecef374cd881759b2c2fbd0ef912e130e10e3b97
@@ -20,6 +20,7 @@
public static final int TYPE_INPUT_BINDING = 5;
public static final int TYPE_STRING_SINGLE_CHOICE = 6;
public static final int TYPE_RUMBLE_BINDING = 7;
public static final int TYPE_SINGLE_CHOICE_DYNAMIC_DESCRIPTIONS = 8;

private String mKey;
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.RumbleBindingSetting;
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.SingleChoiceSettingDynamicDescriptions;
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.SubmenuSetting;
@@ -78,6 +79,7 @@ public SettingViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
return new CheckBoxSettingViewHolder(view, this);

case SettingsItem.TYPE_STRING_SINGLE_CHOICE:
case SettingsItem.TYPE_SINGLE_CHOICE_DYNAMIC_DESCRIPTIONS:
case SettingsItem.TYPE_SINGLE_CHOICE:
view = inflater.inflate(R.layout.list_item_setting, parent, false);
return new SingleChoiceViewHolder(view, this);
@@ -187,6 +189,22 @@ public void onStringSingleChoiceClick(StringSingleChoiceSetting item, int positi
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)
{
mClickedItem = item;
@@ -312,6 +330,24 @@ else if (scSetting.getKey().contains(SettingsFile.KEY_WIIMOTE_EXTENSION) &&

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)
{
StringSingleChoiceSetting scSetting = (StringSingleChoiceSetting) mClickedItem;
@@ -439,6 +475,48 @@ private int getSelectionForSingleChoiceValue(SingleChoiceSetting item)
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)
{
StringSetting gfxBackend = null;
@@ -18,6 +18,7 @@
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.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.StringSingleChoiceSetting;
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
@@ -418,15 +419,16 @@ private void addGraphicsSettings(ArrayList<SettingsItem> sl)
R.array.videoBackendValues, 0, videoBackend));
sl.add(new CheckBoxSetting(SettingsFile.KEY_SHOW_FPS, Settings.SECTION_GFX_SETTINGS,
R.string.show_fps, R.string.show_fps_description, false, showFps));
sl.add(new SingleChoiceSetting(SettingsFile.KEY_SHADER_COMPILATION_MODE,
Settings.SECTION_GFX_SETTINGS, R.string.shader_compilation_mode,
R.string.shader_compilation_mode_description, R.array.shaderCompilationModeEntries,
R.array.shaderCompilationModeValues, 0, shaderCompilationMode));
sl.add(new SingleChoiceSettingDynamicDescriptions(SettingsFile.KEY_SHADER_COMPILATION_MODE,
Settings.SECTION_GFX_SETTINGS, R.string.shader_compilation_mode, 0,
R.array.shaderCompilationModeEntries,
R.array.shaderCompilationModeValues, R.array.shaderCompilationDescriptionEntries,
R.array.shaderCompilationDescriptionValues, 0, shaderCompilationMode));
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,
waitForShaders));
sl.add(new SingleChoiceSetting(SettingsFile.KEY_ASPECT_RATIO, Settings.SECTION_GFX_SETTINGS,
R.string.aspect_ratio, R.string.aspect_ratio_description, R.array.aspectRatioEntries,
R.string.aspect_ratio, 0, R.array.aspectRatioEntries,
R.array.aspectRatioValues, 0, aspectRatio));

sl.add(new HeaderSetting(null, null, R.string.graphics_enhancements_and_hacks, 0));
@@ -682,7 +684,7 @@ private void addStereoSettings(ArrayList<SettingsItem> sl)
Setting swapEyes = stereoScopySection.getSetting(SettingsFile.KEY_STEREO_SWAP);

sl.add(new SingleChoiceSetting(SettingsFile.KEY_STEREO_MODE, Settings.SECTION_STEREOSCOPY,
R.string.stereoscopy_mode, R.string.stereoscopy_mode_description,
R.string.stereoscopy_mode, 0,
R.array.stereoscopyEntries, R.array.stereoscopyValues, 0, stereoModeValue));
sl.add(new SliderSetting(SettingsFile.KEY_STEREO_DEPTH, Settings.SECTION_STEREOSCOPY,
R.string.stereoscopy_depth, R.string.stereoscopy_depth_description, 100, "%", 20,
@@ -7,6 +7,7 @@
import org.dolphinemu.dolphinemu.R;
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.SingleChoiceSettingDynamicDescriptions;
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;

@@ -63,6 +64,22 @@ else if (item instanceof StringSingleChoiceSetting)
if (valueIndex != -1)
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
@@ -77,5 +94,10 @@ else if (mItem instanceof StringSingleChoiceSetting)
{
getAdapter().onStringSingleChoiceClick((StringSingleChoiceSetting) mItem, position);
}
else if (mItem instanceof SingleChoiceSettingDynamicDescriptions)
{
getAdapter().onSingleChoiceDynamicDescriptionsClick(
(SingleChoiceSettingDynamicDescriptions) mItem, position);
}
}
}
@@ -123,6 +123,20 @@
<item>3</item>
</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 -->
<string-array name="internalResolutionEntries" translatable="false">
<item>1x Native (640x528)</item>
@@ -238,7 +238,6 @@
<string name="aspect_ratio">Aspect Ratio</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_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_description">This causes a delay when launching games, but will reduce stuttering early on.</string>

0 comments on commit ecef374

Please sign in to comment.
You can’t perform that action at this time.