Merge pull request #10861 from JosJuice/android-new-sd

Android: Bring SD card settings up to date with DolphinQt
This commit is contained in:
JMC47 2022-07-23 07:59:19 -04:00 committed by GitHub
commit 3d7b66bcfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 90 additions and 15 deletions

View File

@ -187,16 +187,11 @@ public final class EmulationActivity extends AppCompatActivity
{
new AfterDirectoryInitializationRunner().runWithLifecycle(activity, true, () ->
{
if (FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DEFAULT_ISO) &&
FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_FS_PATH) &&
FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DUMP_PATH) &&
FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_LOAD_PATH) &&
FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_RESOURCEPACK_PATH) &&
FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_SD_PATH))
{
continueCallback.run();
}
else
if (!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DEFAULT_ISO) ||
!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_FS_PATH) ||
!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DUMP_PATH) ||
!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_LOAD_PATH) ||
!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_RESOURCEPACK_PATH))
{
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(R.string.unavailable_paths);
@ -206,10 +201,25 @@ public final class EmulationActivity extends AppCompatActivity
continueCallback.run());
builder.show();
}
else if (!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_WII_SD_CARD_IMAGE_PATH) ||
!FileBrowserHelper.isPathEmptyOrValid(
StringSetting.MAIN_WII_SD_CARD_SYNC_FOLDER_PATH))
{
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(R.string.unavailable_paths);
builder.setPositiveButton(R.string.yes, (dialogInterface, i) ->
SettingsActivity.launch(activity, MenuTag.CONFIG_WII));
builder.setNeutralButton(R.string.continue_anyway, (dialogInterface, i) ->
continueCallback.run());
builder.show();
}
else
{
continueCallback.run();
}
});
}
public static void launchSystemMenu(FragmentActivity activity)
{
if (sIgnoreLaunchRequests)

View File

@ -29,6 +29,8 @@ public enum BooleanSetting implements AbstractBooleanSetting
MAIN_SIMULATE_KONGA_2(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SimulateKonga2", false),
MAIN_SIMULATE_KONGA_3(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SimulateKonga3", false),
MAIN_WII_SD_CARD(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "WiiSDCard", true),
MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE,
"WiiSDCardEnableFolderSync", false),
MAIN_WIIMOTE_CONTINUOUS_SCANNING(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE,
"WiimoteContinuousScanning", false),
MAIN_WIIMOTE_ENABLE_SPEAKER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE,

View File

@ -29,7 +29,10 @@ public enum StringSetting implements AbstractStringSetting
MAIN_RESOURCEPACK_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "ResourcePackPath",
""),
MAIN_FS_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "NANDRootPath", ""),
MAIN_SD_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "WiiSDCardPath", ""),
MAIN_WII_SD_CARD_IMAGE_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "WiiSDCardPath",
""),
MAIN_WII_SD_CARD_SYNC_FOLDER_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL,
"WiiSDCardSyncFolder", ""),
MAIN_WFS_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "WFSPath", ""),
GFX_ENHANCE_POST_SHADER(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS,

View File

@ -41,7 +41,10 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoice
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.utils.BooleanSupplier;
import org.dolphinemu.dolphinemu.utils.EGLHelper;
import org.dolphinemu.dolphinemu.utils.ThreadUtil;
import org.dolphinemu.dolphinemu.utils.WiiUtils;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@ -423,8 +426,6 @@ public final class SettingsFragmentPresenter
MainPresenter.REQUEST_DIRECTORY, "/Load"));
sl.add(new FilePicker(mContext, StringSetting.MAIN_RESOURCEPACK_PATH,
R.string.resource_pack_path, 0, MainPresenter.REQUEST_DIRECTORY, "/ResourcePacks"));
sl.add(new FilePicker(mContext, StringSetting.MAIN_SD_PATH, R.string.SD_card_path, 0,
MainPresenter.REQUEST_SD_FILE, "/Wii/sd.raw"));
sl.add(new FilePicker(mContext, StringSetting.MAIN_WFS_PATH, R.string.wfs_path, 0,
MainPresenter.REQUEST_DIRECTORY, "/WFS"));
}
@ -445,6 +446,7 @@ public final class SettingsFragmentPresenter
private void addWiiSettings(ArrayList<SettingsItem> sl)
{
sl.add(new HeaderSetting(mContext, R.string.wii_misc_settings, 0));
sl.add(new SingleChoiceSetting(mContext, IntSetting.SYSCONF_LANGUAGE, R.string.system_language,
0, R.array.wiiSystemLanguageEntries, R.array.wiiSystemLanguageValues));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.SYSCONF_WIDESCREEN, R.string.wii_widescreen,
@ -455,10 +457,29 @@ public final class SettingsFragmentPresenter
R.string.wii_screensaver, R.string.wii_screensaver_description));
sl.add(new SingleChoiceSetting(mContext, IntSetting.SYSCONF_SOUND_MODE, R.string.sound_mode, 0,
R.array.soundModeEntries, R.array.soundModeValues));
sl.add(new HeaderSetting(mContext, R.string.wii_sd_card_settings, 0));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_WII_SD_CARD, R.string.insert_sd_card,
R.string.insert_sd_card_description));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_ALLOW_SD_WRITES,
R.string.wii_sd_card_allow_writes, 0));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC,
R.string.wii_sd_card_sync, R.string.wii_sd_card_sync_description));
// TODO: Hardcoding "Load" here is wrong, because the user may have changed the Load path.
// The code structure makes this hard to fix, and with scoped storage active the Load path
// can't be changed anyway
sl.add(new FilePicker(mContext, StringSetting.MAIN_WII_SD_CARD_IMAGE_PATH,
R.string.wii_sd_card_path, 0, MainPresenter.REQUEST_SD_FILE, "/Load/WiiSD.raw"));
sl.add(new FilePicker(mContext, StringSetting.MAIN_WII_SD_CARD_SYNC_FOLDER_PATH,
R.string.wii_sd_sync_folder, 0, MainPresenter.REQUEST_DIRECTORY, "/Load/WiiSDSync/"));
sl.add(new RunRunnable(mContext, R.string.wii_sd_card_folder_to_file, 0,
R.string.wii_sd_card_folder_to_file_confirmation, 0,
() -> convertOnThread(WiiUtils::syncSdFolderToSdImage)));
sl.add(new RunRunnable(mContext, R.string.wii_sd_card_file_to_folder, 0,
R.string.wii_sd_card_file_to_folder_confirmation, 0,
() -> convertOnThread(WiiUtils::syncSdImageToSdFolder)));
sl.add(new HeaderSetting(mContext, R.string.wii_wiimote_settings, 0));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.SYSCONF_WIIMOTE_MOTOR,
R.string.wiimote_rumble, 0));
sl.add(new IntSliderSetting(mContext, IntSetting.SYSCONF_SPEAKER_VOLUME,
@ -1384,4 +1405,11 @@ public final class SettingsFragmentPresenter
mView.getAdapter().notifyAllSettingsChanged();
}
private void convertOnThread(BooleanSupplier f)
{
ThreadUtil.runOnThreadAndShowResult(mView.getActivity(), R.string.wii_converting, 0, () ->
mContext.getResources().getString(
f.get() ? R.string.wii_convert_success : R.string.wii_convert_failure));
}
}

View File

@ -33,4 +33,8 @@ public final class WiiUtils
public static native boolean isSystemMenuInstalled();
public static native String getSystemMenuVersion();
public static native boolean syncSdFolderToSdImage();
public static native boolean syncSdImageToSdFolder();
}

View File

@ -133,6 +133,9 @@
<string name="slot_b_device">GameCube Slot B Device</string>
<string name="serial_port_1_device">GameCube Serial Port 1 Device</string>
<string name="wii_submenu">Wii</string>
<string name="wii_misc_settings">Misc Settings</string>
<string name="wii_sd_card_settings">SD Card Settings</string>
<string name="wii_wiimote_settings">Wii Remote Settings</string>
<string name="wii_widescreen">Widescreen</string>
<string name="wii_widescreen_description">Changes aspect ratio from 4:3 to 16:9 in games that support it.</string>
<string name="wii_pal60">Use PAL60 Mode (EuRGB60)</string>
@ -143,6 +146,17 @@
<string name="insert_sd_card">Insert SD Card</string>
<string name="insert_sd_card_description">Supports SD and SDHC. Default size is 128 MB.</string>
<string name="wii_sd_card_allow_writes">Allow Writes to SD Card</string>
<string name="wii_sd_card_sync">Automatically Sync with Folder</string>
<string name="wii_sd_card_sync_description">Synchronizes the SD Card with the SD Sync Folder when starting and ending emulation.</string>
<string name="wii_sd_card_path">SD Card Path</string>
<string name="wii_sd_sync_folder">SD Sync Folder</string>
<string name="wii_sd_card_folder_to_file">Convert Folder to File Now</string>
<string name="wii_sd_card_folder_to_file_confirmation">You are about to convert the content of the SD sync folder into the SD card file. All current content of the file will be deleted. Are you sure you want to continue?</string>
<string name="wii_sd_card_file_to_folder">Convert File to Folder Now</string>
<string name="wii_sd_card_file_to_folder_confirmation">You are about to convert the content of the SD card file into the SD sync folder. All current content of the folder will be deleted. Are you sure you want to continue?</string>
<string name="wii_converting">Converting...</string>
<string name="wii_convert_success">Conversion done.</string>
<string name="wii_convert_failure">Conversion failed.</string>
<string name="wiimote_rumble">Wii Remote Rumble</string>
<string name="wiimote_volume">Wii Remote Speaker Volume</string>
<string name="sensor_bar_sensitivity">Sensor Bar Sensitivity</string>
@ -218,7 +232,6 @@
<string name="dump_path">Dump Path</string>
<string name="load_path">Load Path</string>
<string name="resource_pack_path">Resource Pack Path</string>
<string name="SD_card_path">SD Card Path</string>
<string name="wfs_path">WFS Path</string>
<!-- Graphics Settings -->

View File

@ -8,12 +8,15 @@
#include "jni/AndroidCommon/AndroidCommon.h"
#include "jni/AndroidCommon/IDCache.h"
#include "Common/FatFsUtil.h"
#include "Common/ScopeGuard.h"
#include "Core/CommonTitles.h"
#include "Core/HW/WiiSave.h"
#include "Core/IOS/ES/ES.h"
#include "Core/IOS/IOS.h"
#include "Core/WiiUtils.h"
#include "DiscIO/NANDImporter.h"
// The hardcoded values here must match WiiUtils.java
@ -175,4 +178,16 @@ Java_org_dolphinemu_dolphinemu_utils_WiiUtils_getSystemMenuVersion(JNIEnv* env,
return ToJString(env, DiscIO::GetSysMenuVersionString(tmd.GetTitleVersion()));
}
JNIEXPORT jboolean JNICALL
Java_org_dolphinemu_dolphinemu_utils_WiiUtils_syncSdFolderToSdImage(JNIEnv* env, jclass)
{
return static_cast<jboolean>(Common::SyncSDFolderToSDImage(false));
}
JNIEXPORT jboolean JNICALL
Java_org_dolphinemu_dolphinemu_utils_WiiUtils_syncSdImageToSdFolder(JNIEnv* env, jclass)
{
return static_cast<jboolean>(Common::SyncSDImageToSDFolder());
}
}