diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches.java deleted file mode 100644 index 6d2ff51b6b..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches.java +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.features.riivolution.model; - -import androidx.annotation.Keep; - -public class RiivolutionPatches -{ - private String mGameId; - private int mRevision; - private int mDiscNumber; - - private boolean mUnsavedChanges = false; - - @Keep - private long mPointer; - - public RiivolutionPatches(String gameId, int revision, int discNumber) - { - mGameId = gameId; - mRevision = revision; - mDiscNumber = discNumber; - - mPointer = initialize(); - } - - @Override - public native void finalize(); - - private static native long initialize(); - - public native int getDiscCount(); - - public native String getDiscName(int discIndex); - - public native int getSectionCount(int discIndex); - - public native String getSectionName(int discIndex, int sectionIndex); - - public native int getOptionCount(int discIndex, int sectionIndex); - - public native String getOptionName(int discIndex, int sectionIndex, int optionIndex); - - public native int getChoiceCount(int discIndex, int sectionIndex, int optionIndex); - - public native String getChoiceName(int discIndex, int sectionIndex, int optionIndex, - int choiceIndex); - - /** - * @return 0 if no choice is selected, otherwise the index of the selected choice plus one. - */ - public native int getSelectedChoice(int discIndex, int sectionIndex, int optionIndex); - - /** - * @param choiceIndex 0 to select no choice, otherwise the choice index plus one. - */ - public void setSelectedChoice(int discIndex, int sectionIndex, int optionIndex, int choiceIndex) - { - mUnsavedChanges = true; - setSelectedChoiceImpl(discIndex, sectionIndex, optionIndex, choiceIndex); - } - - /** - * @param choiceIndex 0 to select no choice, otherwise the choice index plus one. - */ - private native void setSelectedChoiceImpl(int discIndex, int sectionIndex, int optionIndex, - int choiceIndex); - - public void loadConfig() - { - loadConfigImpl(mGameId, mRevision, mDiscNumber); - } - - private native void loadConfigImpl(String gameId, int revision, int discNumber); - - public void saveConfig() - { - if (mUnsavedChanges) - { - mUnsavedChanges = false; - saveConfigImpl(mGameId); - } - } - - private native void saveConfigImpl(String gameId); -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches.kt new file mode 100644 index 0000000000..ba3fd41d64 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches.kt @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.riivolution.model + +import androidx.annotation.Keep + +class RiivolutionPatches( + private val gameId: String, + private val revision: Int, + private val discNumber: Int +) { + private var unsavedChanges = false + + @Keep + private val pointer: Long = initialize() + + external fun finalize() + + external fun getDiscCount(): Int + + external fun getDiscName(discIndex: Int): String + + external fun getSectionCount(discIndex: Int): Int + + external fun getSectionName(discIndex: Int, sectionIndex: Int): String + + external fun getOptionCount(discIndex: Int, sectionIndex: Int): Int + + external fun getOptionName(discIndex: Int, sectionIndex: Int, optionIndex: Int): String + + external fun getChoiceCount(discIndex: Int, sectionIndex: Int, optionIndex: Int): Int + + external fun getChoiceName( + discIndex: Int, + sectionIndex: Int, + optionIndex: Int, + choiceIndex: Int + ): String + + /** + * @return 0 if no choice is selected, otherwise the index of the selected choice plus one. + */ + external fun getSelectedChoice(discIndex: Int, sectionIndex: Int, optionIndex: Int): Int + + /** + * @param choiceIndex 0 to select no choice, otherwise the choice index plus one. + */ + fun setSelectedChoice(discIndex: Int, sectionIndex: Int, optionIndex: Int, choiceIndex: Int) { + unsavedChanges = true + setSelectedChoiceImpl(discIndex, sectionIndex, optionIndex, choiceIndex) + } + + /** + * @param choiceIndex 0 to select no choice, otherwise the choice index plus one. + */ + private external fun setSelectedChoiceImpl( + discIndex: Int, sectionIndex: Int, optionIndex: Int, + choiceIndex: Int + ) + + fun loadConfig() { + loadConfigImpl(gameId, revision, discNumber) + } + + private external fun loadConfigImpl(gameId: String, revision: Int, discNumber: Int) + + fun saveConfig() { + if (unsavedChanges) { + unsavedChanges = false + saveConfigImpl(gameId) + } + } + + private external fun saveConfigImpl(gameId: String) + + companion object { + @JvmStatic + private external fun initialize(): Long + } +} diff --git a/Source/Android/jni/AndroidCommon/IDCache.cpp b/Source/Android/jni/AndroidCommon/IDCache.cpp index 31511b485c..6d23727953 100644 --- a/Source/Android/jni/AndroidCommon/IDCache.cpp +++ b/Source/Android/jni/AndroidCommon/IDCache.cpp @@ -539,7 +539,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) env->FindClass("org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches"); s_riivolution_patches_class = reinterpret_cast(env->NewGlobalRef(riivolution_patches_class)); - s_riivolution_patches_pointer = env->GetFieldID(riivolution_patches_class, "mPointer", "J"); + s_riivolution_patches_pointer = env->GetFieldID(riivolution_patches_class, "pointer", "J"); env->DeleteLocalRef(riivolution_patches_class); const jclass wii_update_cb_class =