Skip to content

Commit

Permalink
Merge pull request dolphin-emu#11460 from t895/reveal-settings
Browse files Browse the repository at this point in the history
Android: Reveal several hidden settings
  • Loading branch information
delroth authored Jan 29, 2023
2 parents 19d16b1 + 860f561 commit 05b7792
Show file tree
Hide file tree
Showing 12 changed files with 405 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum BooleanSetting implements AbstractBooleanSetting
{
// These entries have the same names and order as in C++, just for consistency.

MAIN_SKIP_IPL(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SkipIPL", true),
MAIN_DSP_HLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "DSPHLE", true),
MAIN_FASTMEM(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "Fastmem", true),
MAIN_CPU_THREAD(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "CPUThread", true),
Expand All @@ -36,8 +37,15 @@ public enum BooleanSetting implements AbstractBooleanSetting
MAIN_WIIMOTE_ENABLE_SPEAKER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE,
"WiimoteEnableSpeaker", false),
MAIN_MMU(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "MMU", false),
MAIN_PAUSE_ON_PANIC(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "PauseOnPanic", false),
MAIN_ACCURATE_CPU_CACHE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AccurateCPUCache",
false),
MAIN_SYNC_GPU(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SyncGPU", false),
MAIN_OVERCLOCK_ENABLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "OverclockEnable", false),
MAIN_RAM_OVERRIDE_ENABLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "RAMOverrideEnable",
false),
MAIN_CUSTOM_RTC_ENABLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "EnableCustomRTC",
false),
MAIN_AUTO_DISC_CHANGE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AutoDiscChange", false),
MAIN_ALLOW_SD_WRITES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "WiiSDCardAllowWrites",
true),
Expand Down Expand Up @@ -260,6 +268,10 @@ public enum BooleanSetting implements AbstractBooleanSetting
MAIN_ENABLE_CHEATS,
MAIN_OVERRIDE_REGION_SETTINGS,
MAIN_MMU,
MAIN_PAUSE_ON_PANIC,
MAIN_ACCURATE_CPU_CACHE,
MAIN_RAM_OVERRIDE_ENABLE,
MAIN_CUSTOM_RTC_ENABLE,
MAIN_DSP_JIT,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public enum IntSetting implements AbstractIntSetting
MAIN_CPU_CORE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "CPUCore",
NativeLibrary.DefaultCPUCore()),
MAIN_GC_LANGUAGE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SelectedLanguage", 0),
MAIN_MEM1_SIZE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "MEM1Size", 0x01800000),
MAIN_MEM2_SIZE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "MEM2Size", 0x04000000),
MAIN_SLOT_A(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SlotA", 8),
MAIN_SLOT_B(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SlotB", 255),
MAIN_SERIAL_PORT_1(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SerialPort1", 255),
Expand Down Expand Up @@ -54,11 +56,16 @@ public enum IntSetting implements AbstractIntSetting
GFX_ASPECT_RATIO(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "AspectRatio", 0),
GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS,
"SafeTextureCacheColorSamples", 128),
GFX_PNG_COMPRESSION_LEVEL(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "PNGCompressionLevel",
6),
GFX_MSAA(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "MSAA", 1),
GFX_EFB_SCALE(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "InternalResolution", 1),
GFX_SHADER_COMPILATION_MODE(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS,
"ShaderCompilationMode", 0),

GFX_ENHANCE_FORCE_TEXTURE_FILTERING(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS,
"ForceTextureFiltering", 0),

GFX_ENHANCE_MAX_ANISOTROPY(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, "MaxAnisotropy",
0),

Expand All @@ -80,6 +87,8 @@ public enum IntSetting implements AbstractIntSetting
private static final IntSetting[] NOT_RUNTIME_EDITABLE_ARRAY = new IntSetting[]{
MAIN_CPU_CORE,
MAIN_GC_LANGUAGE,
MAIN_MEM1_SIZE,
MAIN_MEM2_SIZE,
MAIN_SLOT_A, // Can actually be changed, but specific code is required
MAIN_SLOT_B, // Can actually be changed, but specific code is required
MAIN_SERIAL_PORT_1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public enum StringSetting implements AbstractStringSetting
MAIN_BBA_BUILTIN_DNS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "BBA_BUILTIN_DNS",
"149.56.167.128"),

MAIN_CUSTOM_RTC_VALUE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "CustomRTCValue",
"0x386d4380"),

MAIN_GFX_BACKEND(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "GFXBackend",
NativeLibrary.GetDefaultGraphicsBackendName()),

Expand All @@ -39,6 +42,7 @@ public enum StringSetting implements AbstractStringSetting
"PostProcessingShader", "");

private static final StringSetting[] NOT_RUNTIME_EDITABLE_ARRAY = new StringSetting[]{
MAIN_CUSTOM_RTC_VALUE,
MAIN_GFX_BACKEND,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.settings.model.view

import android.content.Context
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting
import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting
import org.dolphinemu.dolphinemu.features.settings.model.Settings

class DateTimeChoiceSetting(
context: Context,
private val setting: AbstractStringSetting,
nameId: Int,
descriptionId: Int
) : SettingsItem(context, nameId, descriptionId) {
override fun getType(): Int {
return TYPE_DATETIME_CHOICE
}

override fun getSetting(): AbstractSetting {
return setting
}

fun setSelectedValue(settings: Settings?, selection: String) {
setting.setString(settings, selection)
}

fun getSelectedValue(settings: Settings): String {
return setting.getString(settings)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public abstract class SettingsItem
public static final int TYPE_RUN_RUNNABLE = 10;
public static final int TYPE_STRING = 11;
public static final int TYPE_HYPERLINK_HEADER = 12;
public static final int TYPE_DATETIME_CHOICE = 13;

private final CharSequence mName;
private final CharSequence mDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.provider.DocumentsContract;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
Expand All @@ -20,10 +21,14 @@
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.color.MaterialColors;
import com.google.android.material.datepicker.CalendarConstraints;
import com.google.android.material.datepicker.MaterialDatePicker;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.elevation.ElevationOverlayProvider;
import com.google.android.material.slider.Slider;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.timepicker.MaterialTimePicker;
import com.google.android.material.timepicker.TimeFormat;

import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.databinding.DialogInputStringBinding;
Expand All @@ -34,6 +39,7 @@
import org.dolphinemu.dolphinemu.databinding.ListItemSubmenuBinding;
import org.dolphinemu.dolphinemu.dialogs.MotionAlertDialog;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.model.view.DateTimeChoiceSetting;
import org.dolphinemu.dolphinemu.features.settings.model.view.SwitchSetting;
import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker;
import org.dolphinemu.dolphinemu.features.settings.model.view.FloatSliderSetting;
Expand All @@ -47,6 +53,7 @@
import org.dolphinemu.dolphinemu.features.settings.model.view.InputStringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.DateTimeSettingViewHolder;
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.FilePickerViewHolder;
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.HeaderHyperLinkViewHolder;
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.HeaderViewHolder;
Expand All @@ -68,6 +75,8 @@
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.TimeZone;

public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolder>
implements DialogInterface.OnClickListener, Slider.OnChangeListener
Expand Down Expand Up @@ -135,6 +144,9 @@ public SettingViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewT
case SettingsItem.TYPE_HYPERLINK_HEADER:
return new HeaderHyperLinkViewHolder(ListItemHeaderBinding.inflate(inflater), this);

case SettingsItem.TYPE_DATETIME_CHOICE:
return new DateTimeSettingViewHolder(ListItemSettingBinding.inflate(inflater), this);

default:
throw new IllegalArgumentException("Invalid view type: " + viewType);
}
Expand Down Expand Up @@ -377,6 +389,63 @@ public void onFilePickerFileClick(SettingsItem item, int position)
mView.getActivity().startActivityForResult(intent, filePicker.getRequestType());
}

public void onDateTimeClick(DateTimeChoiceSetting item, int position)
{
mClickedItem = item;
mClickedPosition = position;
long storedTime = Long.decode(item.getSelectedValue(mView.getSettings())) * 1000;

// Helper to extract hour and minute from epoch time
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(storedTime);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));

// Start and end epoch times available for the Wii's date picker
CalendarConstraints calendarConstraints = new CalendarConstraints.Builder()
.setStart(946684800000L)
.setEnd(2082672000000L)
.build();

int timeFormat = TimeFormat.CLOCK_12H;
if (DateFormat.is24HourFormat(mView.getActivity()))
{
timeFormat = TimeFormat.CLOCK_24H;
}

MaterialDatePicker<Long> datePicker = MaterialDatePicker.Builder.datePicker()
.setSelection(storedTime)
.setTitleText(R.string.select_rtc_date)
.setCalendarConstraints(calendarConstraints)
.build();
MaterialTimePicker timePicker = new MaterialTimePicker.Builder()
.setTimeFormat(timeFormat)
.setHour(calendar.get(Calendar.HOUR_OF_DAY))
.setMinute(calendar.get(Calendar.MINUTE))
.setTitleText(R.string.select_rtc_time)
.build();

datePicker.addOnPositiveButtonClickListener(
selection -> timePicker.show(mView.getActivity().getSupportFragmentManager(),
"TimePicker"));
timePicker.addOnPositiveButtonClickListener(selection ->
{
long epochTime = datePicker.getSelection() / 1000;
epochTime += (long) timePicker.getHour() * 60 * 60;
epochTime += (long) timePicker.getMinute() * 60;
String rtcString = "0x" + Long.toHexString(epochTime);
if (!item.getSelectedValue(mView.getSettings()).equals(rtcString))
{
notifyItemChanged(mClickedPosition);
mView.onSettingChanged();
}

item.setSelectedValue(mView.getSettings(), rtcString);

mClickedItem = null;
});
datePicker.show(mView.getActivity().getSupportFragmentManager(), "DatePicker");
}

public void onFilePickerConfirmation(String selectedFile)
{
FilePicker filePicker = (FilePicker) mClickedItem;
Expand Down
Loading

0 comments on commit 05b7792

Please sign in to comment.