mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Android: Convert PatchCheat to Kotlin
This commit is contained in:
parent
408b6cb50c
commit
9cbe66bce4
@ -1,60 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.cheats.model;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class PatchCheat extends AbstractCheat
|
||||
{
|
||||
@Keep
|
||||
private final long mPointer;
|
||||
|
||||
public PatchCheat()
|
||||
{
|
||||
mPointer = createNew();
|
||||
}
|
||||
|
||||
@Keep
|
||||
private PatchCheat(long pointer)
|
||||
{
|
||||
mPointer = pointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public native void finalize();
|
||||
|
||||
private native long createNew();
|
||||
|
||||
public boolean supportsCreator()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsNotes()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public native String getName();
|
||||
|
||||
@NonNull
|
||||
public native String getCode();
|
||||
|
||||
public native boolean getUserDefined();
|
||||
|
||||
public native boolean getEnabled();
|
||||
|
||||
@Override
|
||||
protected native int trySetImpl(@NonNull String name, @NonNull String creator,
|
||||
@NonNull String notes, @NonNull String code);
|
||||
|
||||
@Override
|
||||
protected native void setEnabledImpl(boolean enabled);
|
||||
|
||||
@NonNull
|
||||
public static native PatchCheat[] loadCodes(String gameId, int revision);
|
||||
|
||||
public static native void saveCodes(String gameId, int revision, PatchCheat[] codes);
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.cheats.model
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
class PatchCheat : AbstractCheat {
|
||||
@Keep
|
||||
private val pointer: Long
|
||||
|
||||
constructor() {
|
||||
pointer = createNew()
|
||||
}
|
||||
|
||||
@Keep
|
||||
private constructor(pointer: Long) {
|
||||
this.pointer = pointer
|
||||
}
|
||||
|
||||
external fun finalize()
|
||||
|
||||
private external fun createNew(): Long
|
||||
|
||||
override fun supportsCreator(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun supportsNotes(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
external override fun getName(): String
|
||||
|
||||
external override fun getCode(): String
|
||||
|
||||
external override fun getUserDefined(): Boolean
|
||||
|
||||
external override fun getEnabled(): Boolean
|
||||
|
||||
external override fun setCheatImpl(
|
||||
name: String,
|
||||
creator: String,
|
||||
notes: String,
|
||||
code: String
|
||||
): Int
|
||||
|
||||
external override fun setEnabledImpl(enabled: Boolean)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
external fun loadCodes(gameId: String, revision: Int): Array<PatchCheat>
|
||||
|
||||
@JvmStatic
|
||||
external fun saveCodes(gameId: String, revision: Int, codes: Array<PatchCheat>)
|
||||
}
|
||||
}
|
@ -514,7 +514,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
const jclass patch_cheat_class =
|
||||
env->FindClass("org/dolphinemu/dolphinemu/features/cheats/model/PatchCheat");
|
||||
s_patch_cheat_class = reinterpret_cast<jclass>(env->NewGlobalRef(patch_cheat_class));
|
||||
s_patch_cheat_pointer = env->GetFieldID(patch_cheat_class, "mPointer", "J");
|
||||
s_patch_cheat_pointer = env->GetFieldID(patch_cheat_class, "pointer", "J");
|
||||
s_patch_cheat_constructor = env->GetMethodID(patch_cheat_class, "<init>", "(J)V");
|
||||
env->DeleteLocalRef(patch_cheat_class);
|
||||
|
||||
|
@ -79,7 +79,7 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_PatchCheat_getEnabled(JNIEn
|
||||
return static_cast<jboolean>(GetPointer(env, obj)->enabled);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_PatchCheat_trySetImpl(
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_cheats_model_PatchCheat_setCheatImpl(
|
||||
JNIEnv* env, jobject obj, jstring name, jstring creator, jstring notes, jstring code_string)
|
||||
{
|
||||
PatchEngine::Patch* patch = GetPointer(env, obj);
|
||||
|
Loading…
Reference in New Issue
Block a user