mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Android: Implement save overwrite confirmation
This commit is contained in:
@ -56,6 +56,9 @@ static jmethodID s_network_helper_get_network_ip_address;
|
||||
static jmethodID s_network_helper_get_network_prefix_length;
|
||||
static jmethodID s_network_helper_get_network_gateway;
|
||||
|
||||
static jclass s_boolean_supplier_class;
|
||||
static jmethodID s_boolean_supplier_get;
|
||||
|
||||
namespace IDCache
|
||||
{
|
||||
JNIEnv* GetEnvForThread()
|
||||
@ -261,6 +264,11 @@ jmethodID GetNetworkHelperGetNetworkGateway()
|
||||
return s_network_helper_get_network_gateway;
|
||||
}
|
||||
|
||||
jmethodID GetBooleanSupplierGet()
|
||||
{
|
||||
return s_boolean_supplier_get;
|
||||
}
|
||||
|
||||
} // namespace IDCache
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -361,6 +369,11 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
s_network_helper_get_network_gateway =
|
||||
env->GetStaticMethodID(s_network_helper_class, "GetNetworkGateway", "()I");
|
||||
|
||||
const jclass boolean_supplier_class =
|
||||
env->FindClass("org/dolphinemu/dolphinemu/utils/BooleanSupplier");
|
||||
s_boolean_supplier_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_supplier_class));
|
||||
s_boolean_supplier_get = env->GetMethodID(s_boolean_supplier_class, "get", "()Z");
|
||||
|
||||
return JNI_VERSION;
|
||||
}
|
||||
|
||||
|
@ -56,4 +56,6 @@ jmethodID GetNetworkHelperGetNetworkIpAddress();
|
||||
jmethodID GetNetworkHelperGetNetworkPrefixLength();
|
||||
jmethodID GetNetworkHelperGetNetworkGateway();
|
||||
|
||||
jmethodID GetBooleanSupplierGet();
|
||||
|
||||
} // namespace IDCache
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <jni.h>
|
||||
|
||||
#include "jni/AndroidCommon/AndroidCommon.h"
|
||||
#include "jni/AndroidCommon/IDCache.h"
|
||||
|
||||
#include "Core/HW/WiiSave.h"
|
||||
#include "Core/WiiUtils.h"
|
||||
@ -44,12 +45,14 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_install
|
||||
return static_cast<jboolean>(WiiUtils::InstallWAD(path));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_importWiiSave(JNIEnv* env,
|
||||
jclass,
|
||||
jstring jFile)
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_importWiiSave(
|
||||
JNIEnv* env, jclass, jstring jFile, jobject jCanOverwrite)
|
||||
{
|
||||
const std::string path = GetJString(env, jFile);
|
||||
const auto can_overwrite = [] { return true; }; // TODO
|
||||
const auto can_overwrite = [&] {
|
||||
const jmethodID get = IDCache::GetBooleanSupplierGet();
|
||||
return static_cast<bool>(env->CallBooleanMethod(jCanOverwrite, get));
|
||||
};
|
||||
|
||||
return ConvertCopyResult(WiiSave::Import(path, can_overwrite));
|
||||
}
|
||||
|
Reference in New Issue
Block a user