mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Implement video settings + support for missing files / settings
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
<activity
|
||||
android:name=".ui.settings.SettingsActivity"
|
||||
android:theme="@style/DolphinSettingsGamecube"
|
||||
android:label="@string/grid_menu_settings"/>
|
||||
android:label="@string/grid_menu_core_settings"/>
|
||||
|
||||
<activity
|
||||
android:name=".activities.EmulationActivity"
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ public final class BooleanSetting extends Setting
|
||||
{
|
||||
private boolean mValue;
|
||||
|
||||
public BooleanSetting(String key, SettingSection section, boolean value)
|
||||
public BooleanSetting(String key, String section, boolean value)
|
||||
{
|
||||
super(key, section);
|
||||
mValue = value;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ public final class FloatSetting extends Setting
|
||||
{
|
||||
private float mValue;
|
||||
|
||||
public FloatSetting(String key, SettingSection section, float value)
|
||||
public FloatSetting(String key, String section, float value)
|
||||
{
|
||||
super(key, section);
|
||||
mValue = value;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ public final class IntSetting extends Setting
|
||||
{
|
||||
private int mValue;
|
||||
|
||||
public IntSetting(String key, SettingSection section, int value)
|
||||
public IntSetting(String key, String section, int value)
|
||||
{
|
||||
super(key, section);
|
||||
mValue = value;
|
||||
|
||||
+3
-4
@@ -3,10 +3,9 @@ package org.dolphinemu.dolphinemu.model.settings;
|
||||
public abstract class Setting
|
||||
{
|
||||
private String mKey;
|
||||
private String mSection;
|
||||
|
||||
private SettingSection mSection;
|
||||
|
||||
public Setting(String key, SettingSection section)
|
||||
public Setting(String key, String section)
|
||||
{
|
||||
mKey = key;
|
||||
mSection = section;
|
||||
@@ -17,7 +16,7 @@ public abstract class Setting
|
||||
return mKey;
|
||||
}
|
||||
|
||||
public SettingSection getSection()
|
||||
public String getSection()
|
||||
{
|
||||
return mSection;
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ public final class StringSetting extends Setting
|
||||
{
|
||||
private String mValue;
|
||||
|
||||
public StringSetting(String key, SettingSection section, String value)
|
||||
public StringSetting(String key, String section, String value)
|
||||
{
|
||||
super(key, section);
|
||||
mValue = value;
|
||||
|
||||
+30
-5
@@ -6,21 +6,46 @@ import org.dolphinemu.dolphinemu.model.settings.Setting;
|
||||
|
||||
public class CheckBoxSetting extends SettingsItem
|
||||
{
|
||||
public CheckBoxSetting(String key, Setting setting, int titleId, int descriptionId)
|
||||
private boolean mDefaultValue;
|
||||
|
||||
public CheckBoxSetting(String key, String section, int titleId, int descriptionId, boolean defaultValue, Setting setting)
|
||||
{
|
||||
super(key, setting, titleId, descriptionId);
|
||||
super(key, section, setting, titleId, descriptionId);
|
||||
mDefaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public boolean isChecked()
|
||||
{
|
||||
if (getSetting() == null)
|
||||
{
|
||||
return mDefaultValue;
|
||||
}
|
||||
|
||||
BooleanSetting setting = (BooleanSetting) getSetting();
|
||||
return setting.getValue();
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked)
|
||||
/**
|
||||
* Write a value to the backing boolean. If that boolean was previously null,
|
||||
* initializes a new one and returns it, so it can be added to the Hashmap.
|
||||
*
|
||||
* @param checked Pretty self explanatory.
|
||||
* @return null if overwritten successfully; otherwise, a newly created BooleanSetting.
|
||||
*/
|
||||
public BooleanSetting setChecked(boolean checked)
|
||||
{
|
||||
BooleanSetting setting = (BooleanSetting) getSetting();
|
||||
setting.setValue(checked);
|
||||
if (getSetting() == null)
|
||||
{
|
||||
BooleanSetting setting = new BooleanSetting(getKey(), getSection(), checked);
|
||||
setSetting(setting);
|
||||
return setting;
|
||||
}
|
||||
else
|
||||
{
|
||||
BooleanSetting setting = (BooleanSetting) getSetting();
|
||||
setting.setValue(checked);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ public class HeaderSetting extends SettingsItem
|
||||
{
|
||||
public HeaderSetting(String key, Setting setting, int titleId, int descriptionId)
|
||||
{
|
||||
super(key, setting, titleId, descriptionId);
|
||||
super(key, null, setting, titleId, descriptionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+14
-1
@@ -11,14 +11,17 @@ public abstract class SettingsItem
|
||||
public static final int TYPE_SUBMENU = 4;
|
||||
|
||||
private String mKey;
|
||||
private String mSection;
|
||||
|
||||
private Setting mSetting;
|
||||
|
||||
private int mTitleId;
|
||||
private int mDescriptionId;
|
||||
|
||||
public SettingsItem(String key, Setting setting, int titleId, int descriptionId)
|
||||
public SettingsItem(String key, String section, Setting setting, int titleId, int descriptionId)
|
||||
{
|
||||
mKey = key;
|
||||
mSection = section;
|
||||
mSetting = setting;
|
||||
mTitleId = titleId;
|
||||
mDescriptionId = descriptionId;
|
||||
@@ -29,11 +32,21 @@ public abstract class SettingsItem
|
||||
return mKey;
|
||||
}
|
||||
|
||||
public String getSection()
|
||||
{
|
||||
return mSection;
|
||||
}
|
||||
|
||||
public Setting getSetting()
|
||||
{
|
||||
return mSetting;
|
||||
}
|
||||
|
||||
public void setSetting(Setting setting)
|
||||
{
|
||||
mSetting = setting;
|
||||
}
|
||||
|
||||
public int getNameId()
|
||||
{
|
||||
return mTitleId;
|
||||
|
||||
+36
-8
@@ -1,18 +1,22 @@
|
||||
package org.dolphinemu.dolphinemu.model.settings.view;
|
||||
|
||||
|
||||
import org.dolphinemu.dolphinemu.model.settings.IntSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.Setting;
|
||||
|
||||
public class SingleChoiceSetting extends SettingsItem
|
||||
{
|
||||
private int mDefaultValue;
|
||||
|
||||
private int mChoicesId;
|
||||
private int mValuesId;
|
||||
|
||||
public SingleChoiceSetting(String key, Setting setting, int titleId, int descriptionId, int choicesId, int valuesId)
|
||||
public SingleChoiceSetting(String key, String section, int titleId, int descriptionId, int choicesId, int valuesId, int defaultValue, Setting setting)
|
||||
{
|
||||
super(key, setting, titleId, descriptionId);
|
||||
mChoicesId = choicesId;
|
||||
super(key, section, setting, titleId, descriptionId);
|
||||
mValuesId = valuesId;
|
||||
mChoicesId = choicesId;
|
||||
mDefaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public int getChoicesId()
|
||||
@@ -27,14 +31,38 @@ public class SingleChoiceSetting extends SettingsItem
|
||||
|
||||
public int getSelectedValue()
|
||||
{
|
||||
IntSetting setting = (IntSetting) getSetting();
|
||||
return setting.getValue();
|
||||
if (getSetting() != null)
|
||||
{
|
||||
IntSetting setting = (IntSetting) getSetting();
|
||||
return setting.getValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
return mDefaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedValue(int selection)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
IntSetting setting = (IntSetting) getSetting();
|
||||
setting.setValue(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
|
||||
|
||||
+49
-8
@@ -9,14 +9,16 @@ import org.dolphinemu.dolphinemu.utils.SettingsFile;
|
||||
public class SliderSetting extends SettingsItem
|
||||
{
|
||||
private int mMax;
|
||||
private int mDefaultValue;
|
||||
|
||||
private String mUnits;
|
||||
|
||||
public SliderSetting(String key, Setting setting, int titleId, int descriptionId, int max, String units)
|
||||
public SliderSetting(String key, String section, int titleId, int descriptionId, int max, String units, int defaultValue, Setting setting)
|
||||
{
|
||||
super(key, setting, titleId, descriptionId);
|
||||
super(key, section, setting, titleId, descriptionId);
|
||||
mMax = max;
|
||||
mUnits = units;
|
||||
mDefaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public int getMax()
|
||||
@@ -28,6 +30,11 @@ public class SliderSetting extends SettingsItem
|
||||
{
|
||||
Setting setting = getSetting();
|
||||
|
||||
if (setting == null)
|
||||
{
|
||||
return mDefaultValue;
|
||||
}
|
||||
|
||||
if (setting instanceof IntSetting)
|
||||
{
|
||||
IntSetting intSetting = (IntSetting) setting;
|
||||
@@ -52,16 +59,50 @@ public class SliderSetting extends SettingsItem
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedValue(int selection)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
IntSetting setting = (IntSetting) getSetting();
|
||||
setting.setValue(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;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedValue(float selection)
|
||||
/**
|
||||
* Write a value to the backing float. If that float was previously null,
|
||||
* initializes a new one and returns it, so it can be added to the Hashmap.
|
||||
*
|
||||
* @param selection New value of the float.
|
||||
* @return null if overwritten successfully otherwise; a newly created FloatSetting.
|
||||
*/
|
||||
public FloatSetting setSelectedValue(float selection)
|
||||
{
|
||||
FloatSetting setting = (FloatSetting) getSetting();
|
||||
setting.setValue(selection);
|
||||
if (getSetting() == null)
|
||||
{
|
||||
FloatSetting setting = new FloatSetting(getKey(), getSection(), selection);
|
||||
setSetting(setting);
|
||||
return setting;
|
||||
}
|
||||
else
|
||||
{
|
||||
FloatSetting setting = (FloatSetting) getSetting();
|
||||
setting.setValue(selection);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getUnits()
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class SubmenuSetting extends SettingsItem
|
||||
|
||||
public SubmenuSetting(String key, Setting setting, int titleId, int descriptionId, String menuKey)
|
||||
{
|
||||
super(key, setting, titleId, descriptionId);
|
||||
super(key, null, setting, titleId, descriptionId);
|
||||
mMenuKey = menuKey;
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -20,7 +20,6 @@ import org.dolphinemu.dolphinemu.adapters.PlatformPagerAdapter;
|
||||
import org.dolphinemu.dolphinemu.model.GameProvider;
|
||||
import org.dolphinemu.dolphinemu.ui.platform.PlatformGamesView;
|
||||
import org.dolphinemu.dolphinemu.ui.settings.SettingsActivity;
|
||||
import org.dolphinemu.dolphinemu.utils.SettingsFile;
|
||||
import org.dolphinemu.dolphinemu.utils.StartupHandler;
|
||||
|
||||
/**
|
||||
@@ -116,9 +115,9 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchSettingsActivity()
|
||||
public void launchSettingsActivity(String menuTag)
|
||||
{
|
||||
SettingsActivity.launch(this, SettingsFile.FILE_NAME_DOLPHIN);
|
||||
SettingsActivity.launch(this, menuTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-2
@@ -7,6 +7,7 @@ import org.dolphinemu.dolphinemu.DolphinApplication;
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.model.GameDatabase;
|
||||
import org.dolphinemu.dolphinemu.utils.SettingsFile;
|
||||
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.functions.Action1;
|
||||
@@ -41,8 +42,12 @@ public final class MainPresenter
|
||||
{
|
||||
switch (itemId)
|
||||
{
|
||||
case R.id.menu_settings:
|
||||
mView.launchSettingsActivity();
|
||||
case R.id.menu_settings_core:
|
||||
mView.launchSettingsActivity(SettingsFile.FILE_NAME_DOLPHIN);
|
||||
return true;
|
||||
|
||||
case R.id.menu_settings_video:
|
||||
mView.launchSettingsActivity(SettingsFile.FILE_NAME_GFX);
|
||||
return true;
|
||||
|
||||
case R.id.menu_refresh:
|
||||
|
||||
@@ -32,7 +32,7 @@ public interface MainView
|
||||
void refreshFragmentScreenshot(int fragmentPosition);
|
||||
|
||||
|
||||
void launchSettingsActivity();
|
||||
void launchSettingsActivity(String menuTag);
|
||||
|
||||
void launchFileListActivity();
|
||||
|
||||
|
||||
+8
-4
@@ -113,7 +113,7 @@ public final class TvMainActivity extends Activity implements MainView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchSettingsActivity()
|
||||
public void launchSettingsActivity(String menuTag)
|
||||
{
|
||||
SettingsActivity.launch(this, SettingsFile.FILE_NAME_DOLPHIN);
|
||||
}
|
||||
@@ -230,9 +230,13 @@ public final class TvMainActivity extends Activity implements MainView
|
||||
R.drawable.ic_refresh_tv,
|
||||
R.string.grid_menu_refresh));
|
||||
|
||||
rowItems.add(new TvSettingsItem(R.id.menu_settings,
|
||||
R.drawable.ic_settings_tv,
|
||||
R.string.grid_menu_settings));
|
||||
rowItems.add(new TvSettingsItem(R.id.menu_settings_core,
|
||||
R.drawable.ic_settings_core_tv,
|
||||
R.string.grid_menu_core_settings));
|
||||
|
||||
rowItems.add(new TvSettingsItem(R.id.menu_settings_video,
|
||||
R.drawable.ic_settings_graphics_tv,
|
||||
R.string.grid_menu_core_settings));
|
||||
|
||||
rowItems.add(new TvSettingsItem(R.id.button_add_directory,
|
||||
R.drawable.ic_add_tv,
|
||||
|
||||
+18
-9
@@ -25,7 +25,7 @@ public class SettingsActivityPresenter
|
||||
mView = view;
|
||||
}
|
||||
|
||||
public void onCreate(Bundle savedInstanceState, String filename)
|
||||
public void onCreate(Bundle savedInstanceState, final String filename)
|
||||
{
|
||||
mFileName = filename;
|
||||
|
||||
@@ -35,14 +35,23 @@ public class SettingsActivityPresenter
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Action1<HashMap<String, SettingSection>>()
|
||||
{
|
||||
@Override
|
||||
public void call(HashMap<String, SettingSection> settingsBySection)
|
||||
{
|
||||
mSettingsBySection = settingsBySection;
|
||||
mView.onSettingsFileLoaded(settingsBySection);
|
||||
}
|
||||
});
|
||||
{
|
||||
@Override
|
||||
public void call(HashMap<String, SettingSection> settingsBySection)
|
||||
{
|
||||
mSettingsBySection = settingsBySection;
|
||||
mView.onSettingsFileLoaded(settingsBySection);
|
||||
}
|
||||
},
|
||||
new Action1<Throwable>()
|
||||
{
|
||||
@Override
|
||||
public void call(Throwable throwable)
|
||||
{
|
||||
Log.error("[SettingsActivityPresenter] Error reading file " + filename + ".ini: "+ throwable.getMessage());
|
||||
mView.onSettingsFileLoaded(null);
|
||||
}
|
||||
});
|
||||
|
||||
mView.showSettingsFragment(mFileName, false);
|
||||
}
|
||||
|
||||
+31
-5
@@ -9,10 +9,12 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.model.settings.BooleanSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.FloatSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.IntSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.CheckBoxSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.SettingsItem;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.SingleChoiceSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.SliderSetting;
|
||||
@@ -117,6 +119,17 @@ public class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolder>
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void onBooleanClick(CheckBoxSetting item, int position, boolean checked)
|
||||
{
|
||||
BooleanSetting setting = item.setChecked(checked);
|
||||
notifyItemChanged(position);
|
||||
|
||||
if (setting != null)
|
||||
{
|
||||
mView.addSetting(setting);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSingleChoiceClick(SingleChoiceSetting item)
|
||||
{
|
||||
mClickedItem = item;
|
||||
@@ -162,7 +175,7 @@ public class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolder>
|
||||
|
||||
public void onSubmenuClick(SubmenuSetting item)
|
||||
{
|
||||
Toast.makeText(mContext, "Submenu item clicked", Toast.LENGTH_SHORT).show();
|
||||
mView.loadSubMenu(item.getMenuKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,7 +187,12 @@ public class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolder>
|
||||
|
||||
int value = getValueForSingleChoiceSelection(scSetting, which);
|
||||
|
||||
scSetting.setSelectedValue(value);
|
||||
IntSetting setting = scSetting.setSelectedValue(value);
|
||||
if (setting != null)
|
||||
{
|
||||
mView.addSetting(setting);
|
||||
}
|
||||
|
||||
closeDialog();
|
||||
}
|
||||
else if (mClickedItem instanceof SliderSetting)
|
||||
@@ -193,11 +211,19 @@ public class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolder>
|
||||
value = (float) mSeekbarProgress;
|
||||
}
|
||||
|
||||
sliderSetting.setSelectedValue(value);
|
||||
FloatSetting setting = sliderSetting.setSelectedValue(value);
|
||||
if (setting != null)
|
||||
{
|
||||
mView.addSetting(setting);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sliderSetting.setSelectedValue(mSeekbarProgress);
|
||||
IntSetting setting = sliderSetting.setSelectedValue(mSeekbarProgress);
|
||||
if (setting != null)
|
||||
{
|
||||
mView.addSetting(setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-6
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import org.dolphinemu.dolphinemu.BuildConfig;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.model.settings.Setting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.SettingSection;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.SettingsItem;
|
||||
import org.dolphinemu.dolphinemu.ui.DividerItemDecoration;
|
||||
@@ -22,7 +23,7 @@ import java.util.HashMap;
|
||||
public final class SettingsFragment extends Fragment implements SettingsFragmentView
|
||||
{
|
||||
private SettingsFragmentPresenter mPresenter = new SettingsFragmentPresenter(this);
|
||||
private SettingsActivityView mView;
|
||||
private SettingsActivityView mActivity;
|
||||
|
||||
private SettingsAdapter mAdapter;
|
||||
|
||||
@@ -31,7 +32,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
||||
{
|
||||
super.onAttach(context);
|
||||
|
||||
mView = (SettingsActivityView) context;
|
||||
mActivity = (SettingsActivityView) context;
|
||||
mPresenter.onAttach();
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
||||
public void onDetach()
|
||||
{
|
||||
super.onDetach();
|
||||
mView = null;
|
||||
mActivity = null;
|
||||
|
||||
if (mAdapter != null)
|
||||
{
|
||||
@@ -91,11 +92,11 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passOptionsToActivity(HashMap<String, SettingSection> settings)
|
||||
public void passSettingsToActivity(HashMap<String, SettingSection> settings)
|
||||
{
|
||||
if (mView != null)
|
||||
if (mActivity != null)
|
||||
{
|
||||
mView.setSettings(settings);
|
||||
mActivity.setSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +106,24 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
||||
mAdapter.setSettings(settingsList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSubMenu(String menuKey)
|
||||
{
|
||||
mActivity.showSettingsFragment(menuKey, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showToastMessage(String message)
|
||||
{
|
||||
mActivity.showToastMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSetting(Setting setting)
|
||||
{
|
||||
mPresenter.addSetting(setting);
|
||||
}
|
||||
|
||||
public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".fragment.settings";
|
||||
|
||||
public static final String ARGUMENT_MENU_TAG = FRAGMENT_TAG + ".menu_tag";
|
||||
|
||||
+208
-18
@@ -1,12 +1,17 @@
|
||||
package org.dolphinemu.dolphinemu.ui.settings;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.model.settings.BooleanSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.IntSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.Setting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.SettingSection;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.CheckBoxSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.HeaderSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.SettingsItem;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.SingleChoiceSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.SliderSetting;
|
||||
import org.dolphinemu.dolphinemu.model.settings.view.SubmenuSetting;
|
||||
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
||||
import org.dolphinemu.dolphinemu.utils.SettingsFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -45,23 +50,22 @@ public class SettingsFragmentPresenter
|
||||
{
|
||||
if (mSettings != null)
|
||||
{
|
||||
mView.passOptionsToActivity(mSettings);
|
||||
mView.passSettingsToActivity(mSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public void addSetting(Setting setting)
|
||||
{
|
||||
mSettings.get(setting.getSection()).putSetting(setting.getKey(), setting);
|
||||
}
|
||||
|
||||
public void setSettings(HashMap<String, SettingSection> settings)
|
||||
{
|
||||
if (mSettingsList == null)
|
||||
{
|
||||
if (settings != null)
|
||||
{
|
||||
mSettings = settings;
|
||||
}
|
||||
mSettings = settings;
|
||||
|
||||
if (mSettings != null)
|
||||
{
|
||||
loadSettingsList();
|
||||
}
|
||||
loadSettingsList();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,8 +81,23 @@ public class SettingsFragmentPresenter
|
||||
{
|
||||
case SettingsFile.FILE_NAME_DOLPHIN:
|
||||
addCoreSettings(sl);
|
||||
|
||||
break;
|
||||
|
||||
case SettingsFile.FILE_NAME_GFX:
|
||||
addGraphicsSettings(sl);
|
||||
break;
|
||||
|
||||
case SettingsFile.SECTION_GFX_ENHANCEMENTS:
|
||||
addEnhanceSettings(sl);
|
||||
break;
|
||||
|
||||
case SettingsFile.SECTION_GFX_HACKS:
|
||||
addHackSettings(sl);
|
||||
break;
|
||||
|
||||
default:
|
||||
mView.showToastMessage("Unimplemented menu.");
|
||||
return;
|
||||
}
|
||||
|
||||
mSettingsList = sl;
|
||||
@@ -87,16 +106,187 @@ public class SettingsFragmentPresenter
|
||||
|
||||
private void addCoreSettings(ArrayList<SettingsItem> sl)
|
||||
{
|
||||
Setting cpuCore = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_CPU_CORE);
|
||||
sl.add(new SingleChoiceSetting(cpuCore.getKey(), cpuCore, R.string.cpu_core, 0, R.array.string_emu_cores, R.array.int_emu_cores));
|
||||
Setting cpuCore = null;
|
||||
Setting dualCore = null;
|
||||
Setting overclockEnable = null;
|
||||
Setting overclock = null;
|
||||
|
||||
Setting dualCore = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_DUAL_CORE);
|
||||
sl.add(new CheckBoxSetting(dualCore.getKey(), dualCore, R.string.dual_core, R.string.dual_core_descrip));
|
||||
if (mSettings != null)
|
||||
{
|
||||
cpuCore = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_CPU_CORE);
|
||||
dualCore = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_DUAL_CORE);
|
||||
overclockEnable = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_OVERCLOCK_ENABLE);
|
||||
overclock = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_OVERCLOCK_PERCENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSettings = new HashMap<>();
|
||||
mSettings.put(SettingsFile.SECTION_CORE, new SettingSection(SettingsFile.SECTION_CORE));
|
||||
|
||||
Setting overclockEnable = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_OVERCLOCK_ENABLE);
|
||||
sl.add(new CheckBoxSetting(overclockEnable.getKey(), overclockEnable, R.string.overclock_enable, R.string.overclock_enable_description));
|
||||
mView.passSettingsToActivity(mSettings);
|
||||
}
|
||||
|
||||
Setting overclock = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_OVERCLOCK_PERCENT);
|
||||
sl.add(new SliderSetting(overclock.getKey(), overclock, R.string.overclock_title, 0, 400, "%"));
|
||||
// TODO Set default value for cpuCore based on arch.
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_CPU_CORE, SettingsFile.SECTION_CORE, R.string.cpu_core, 0, R.array.string_emu_cores, R.array.int_emu_cores, 4, cpuCore));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_DUAL_CORE, SettingsFile.SECTION_CORE, R.string.dual_core, R.string.dual_core_descrip, true, dualCore));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_OVERCLOCK_ENABLE, SettingsFile.SECTION_CORE, R.string.overclock_enable, R.string.overclock_enable_description, false, overclockEnable));
|
||||
sl.add(new SliderSetting(SettingsFile.KEY_OVERCLOCK_PERCENT, SettingsFile.SECTION_CORE, R.string.overclock_title, 0, 400, "%", 100, overclock));
|
||||
|
||||
}
|
||||
|
||||
private void addGraphicsSettings(ArrayList<SettingsItem> sl)
|
||||
{
|
||||
Setting showFps = null;
|
||||
|
||||
if (mSettings != null)
|
||||
{
|
||||
showFps = mSettings.get(SettingsFile.SECTION_GFX_SETTINGS).getSetting(SettingsFile.KEY_SHOW_FPS);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSettings = new HashMap<>();
|
||||
|
||||
mSettings.put(SettingsFile.SECTION_GFX_SETTINGS, new SettingSection(SettingsFile.SECTION_GFX_SETTINGS));
|
||||
mSettings.put(SettingsFile.SECTION_GFX_ENHANCEMENTS, new SettingSection(SettingsFile.SECTION_GFX_ENHANCEMENTS));
|
||||
mSettings.put(SettingsFile.SECTION_GFX_HACKS, new SettingSection(SettingsFile.SECTION_GFX_HACKS));
|
||||
|
||||
mView.passSettingsToActivity(mSettings);
|
||||
}
|
||||
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_SHOW_FPS, SettingsFile.SECTION_GFX_SETTINGS, R.string.show_fps, 0, true, showFps));
|
||||
|
||||
sl.add(new SubmenuSetting(null, null, R.string.enhancements, 0, SettingsFile.SECTION_GFX_ENHANCEMENTS));
|
||||
sl.add(new SubmenuSetting(null, null, R.string.hacks, 0, SettingsFile.SECTION_GFX_HACKS));
|
||||
}
|
||||
|
||||
private void addEnhanceSettings(ArrayList<SettingsItem> sl)
|
||||
{
|
||||
Setting resolution = mSettings.get(SettingsFile.SECTION_GFX_SETTINGS).getSetting(SettingsFile.KEY_INTERNAL_RES);
|
||||
Setting fsaa = mSettings.get(SettingsFile.SECTION_GFX_SETTINGS).getSetting(SettingsFile.KEY_FSAA);
|
||||
Setting anisotropic = mSettings.get(SettingsFile.SECTION_GFX_ENHANCEMENTS).getSetting(SettingsFile.KEY_ANISOTROPY);
|
||||
Setting efbScaledCopy = mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_SCALED_EFB);
|
||||
Setting perPixel = mSettings.get(SettingsFile.SECTION_GFX_SETTINGS).getSetting(SettingsFile.KEY_PER_PIXEL);
|
||||
Setting forceFilter = mSettings.get(SettingsFile.SECTION_GFX_ENHANCEMENTS).getSetting(SettingsFile.KEY_FORCE_FILTERING);
|
||||
Setting disableFog = mSettings.get(SettingsFile.SECTION_GFX_SETTINGS).getSetting(SettingsFile.KEY_DISABLE_FOG);
|
||||
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_INTERNAL_RES, SettingsFile.SECTION_GFX_SETTINGS, R.string.internal_resolution, R.string.internal_resolution_descrip, R.array.internalResolutionEntries, R.array.internalResolutionValues, 0, resolution));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_FSAA, SettingsFile.SECTION_GFX_SETTINGS, R.string.FSAA, R.string.FSAA_descrip, R.array.FSAAEntries, R.array.FSAAValues, 0, fsaa));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_ANISOTROPY, SettingsFile.SECTION_GFX_ENHANCEMENTS, R.string.anisotropic_filtering, R.string.anisotropic_filtering_descrip, R.array.anisotropicFilteringEntries, R.array.anisotropicFilteringValues, 0, anisotropic));
|
||||
|
||||
// TODO
|
||||
// Setting shader = mSettings.get(SettingsFile.SECTION_GFX_ENHANCEMENTS).getSetting(SettingsFile.KEY_POST_SHADER)
|
||||
// sl.add(new SingleChoiceSetting(.getKey(), , R.string., R.string._descrip, R.array., R.array.));
|
||||
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_SCALED_EFB, SettingsFile.SECTION_GFX_HACKS, R.string.scaled_efb_copy, R.string.scaled_efb_copy_descrip, true, efbScaledCopy));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_PER_PIXEL, SettingsFile.SECTION_GFX_SETTINGS, R.string.per_pixel_lighting, R.string.per_pixel_lighting_descrip, false, perPixel));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_FORCE_FILTERING, SettingsFile.SECTION_GFX_ENHANCEMENTS, R.string.force_texture_filtering, R.string.force_texture_filtering_descrip, false, forceFilter));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_DISABLE_FOG, SettingsFile.SECTION_GFX_SETTINGS, R.string.disable_fog, R.string.disable_fog_descrip, false, disableFog));
|
||||
|
||||
/*
|
||||
Check if we support stereo
|
||||
If we support desktop GL then we must support at least OpenGL 3.2
|
||||
If we only support OpenGLES then we need both OpenGLES 3.1 and AEP
|
||||
*/
|
||||
EGLHelper helper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);
|
||||
|
||||
if ((helper.supportsOpenGL() && helper.GetVersion() >= 320) ||
|
||||
(helper.supportsGLES3() && helper.GetVersion() >= 310 && helper.SupportsExtension("GL_ANDROID_extension_pack_es31a")))
|
||||
{
|
||||
sl.add(new SubmenuSetting(null, null, R.string.stereoscopy, 0, SettingsFile.SECTION_STEREOSCOPY));
|
||||
}
|
||||
}
|
||||
|
||||
private void addHackSettings(ArrayList<SettingsItem> sl)
|
||||
{
|
||||
int efbCopyMethodValue = getEfbCopyMethodValue();
|
||||
int xfbValue = getXfbValue();
|
||||
|
||||
Setting skipEFB = mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_SKIP_EFB);
|
||||
Setting ignoreFormat = mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_IGNORE_FORMAT);
|
||||
IntSetting efbCopyMethod = new IntSetting(SettingsFile.KEY_EFB_COPY_METHOD, null, efbCopyMethodValue);
|
||||
Setting texCacheAccuracy = mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_TEXCACHE_ACCURACY);
|
||||
IntSetting xfb = new IntSetting(SettingsFile.KEY_XFB, SettingsFile.SECTION_GFX_HACKS, xfbValue);
|
||||
Setting fastDepth = mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_FAST_DEPTH);
|
||||
Setting aspectRatio = mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_ASPECT_RATIO);
|
||||
|
||||
sl.add(new HeaderSetting(null, null, R.string.embedded_frame_buffer, 0));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_SKIP_EFB, SettingsFile.SECTION_GFX_HACKS, R.string.skip_efb_access, R.string.skip_efb_access_descrip, false, skipEFB));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_IGNORE_FORMAT, SettingsFile.SECTION_GFX_HACKS, R.string.ignore_format_changes, R.string.ignore_format_changes_descrip, false, ignoreFormat));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_EFB_COPY_METHOD, SettingsFile.SECTION_GFX_HACKS, R.string.efb_copy_method, R.string.efb_copy_method_descrip, R.array.efbCopyMethodEntries, R.array.efbCopyMethodValues, 1, efbCopyMethod));
|
||||
|
||||
sl.add(new HeaderSetting(null, null, R.string.texture_cache, 0));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_TEXCACHE_ACCURACY, SettingsFile.SECTION_GFX_HACKS, R.string.texture_cache_accuracy, R.string.texture_cache_accuracy_descrip, R.array.textureCacheAccuracyEntries, R.array.textureCacheAccuracyValues, 128, texCacheAccuracy));
|
||||
|
||||
sl.add(new HeaderSetting(null, null, R.string.external_frame_buffer, 0));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_XFB, SettingsFile.SECTION_GFX_HACKS, R.string.external_frame_buffer, R.string.external_frame_buffer_descrip, R.array.externalFrameBufferEntries, R.array.externalFrameBufferValues, 0, xfb));
|
||||
|
||||
sl.add(new HeaderSetting(null, null, R.string.other, 0));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_FAST_DEPTH, SettingsFile.SECTION_GFX_HACKS, R.string.fast_depth_calculation, R.string.fast_depth_calculation_descrip, true, fastDepth));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_ASPECT_RATIO, SettingsFile.SECTION_GFX_HACKS, R.string.aspect_ratio, R.string.aspect_ratio_descrip, R.array.aspectRatioEntries, R.array.aspectRatioValues, 0, aspectRatio));
|
||||
}
|
||||
|
||||
private int getEfbCopyMethodValue()
|
||||
{
|
||||
int efbCopyMethodValue;
|
||||
try
|
||||
{
|
||||
boolean efbCopyOn = ((BooleanSetting) mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_EFB_COPY)).getValue();
|
||||
boolean efbCopyTexture = ((BooleanSetting) mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_EFB_TEXTURE)).getValue();
|
||||
boolean efbCopyCache = ((BooleanSetting) mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_EFB_CACHE)).getValue();
|
||||
|
||||
|
||||
if (!efbCopyOn)
|
||||
{
|
||||
efbCopyMethodValue = 0;
|
||||
}
|
||||
else if (efbCopyTexture)
|
||||
{
|
||||
efbCopyMethodValue = 1;
|
||||
}
|
||||
else if (!efbCopyCache)
|
||||
{
|
||||
efbCopyMethodValue = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
efbCopyMethodValue = 3;
|
||||
}
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
efbCopyMethodValue = 1;
|
||||
}
|
||||
|
||||
return efbCopyMethodValue;
|
||||
}
|
||||
|
||||
private int getXfbValue()
|
||||
{
|
||||
int xfbValue;
|
||||
|
||||
try
|
||||
{
|
||||
boolean usingXFB = ((BooleanSetting) mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_XFB)).getValue();
|
||||
boolean usingRealXFB = ((BooleanSetting) mSettings.get(SettingsFile.SECTION_GFX_HACKS).getSetting(SettingsFile.KEY_XFB_REAL)).getValue();
|
||||
|
||||
if (!usingXFB)
|
||||
{
|
||||
xfbValue = 0;
|
||||
}
|
||||
else if (!usingRealXFB)
|
||||
{
|
||||
xfbValue = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
xfbValue = 2;
|
||||
}
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
xfbValue = 0;
|
||||
}
|
||||
|
||||
return xfbValue;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user