summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.java45
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.kt47
2 files changed, 47 insertions, 45 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.java
deleted file mode 100644
index d672013b4e..0000000000
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.java
+++ /dev/null
@@ -1,45 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-package org.dolphinemu.dolphinemu.features.cheats.model;
-
-import androidx.annotation.NonNull;
-
-public abstract class AbstractCheat extends ReadOnlyCheat
-{
- public boolean supportsCode()
- {
- return true;
- }
-
- public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes,
- @NonNull String code)
- {
- if (!code.isEmpty() && code.charAt(0) == '$')
- {
- int firstLineEnd = code.indexOf('\n');
- if (firstLineEnd == -1)
- {
- name = code.substring(1);
- code = "";
- }
- else
- {
- name = code.substring(1, firstLineEnd);
- code = code.substring(firstLineEnd + 1);
- }
- }
-
- if (name.isEmpty())
- return TRY_SET_FAIL_NO_NAME;
-
- int result = trySetImpl(name, creator, notes, code);
-
- if (result == TRY_SET_SUCCESS)
- onChanged();
-
- return result;
- }
-
- protected abstract int trySetImpl(@NonNull String name, @NonNull String creator,
- @NonNull String notes, @NonNull String code);
-}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.kt
new file mode 100644
index 0000000000..d9e17ffd41
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/model/AbstractCheat.kt
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package org.dolphinemu.dolphinemu.features.cheats.model
+
+import org.dolphinemu.dolphinemu.features.cheats.model.Cheat.Companion.TRY_SET_FAIL_NO_NAME
+import org.dolphinemu.dolphinemu.features.cheats.model.Cheat.Companion.TRY_SET_SUCCESS
+
+abstract class AbstractCheat : ReadOnlyCheat() {
+ override fun supportsCode(): Boolean {
+ return true
+ }
+
+ override fun setCheat(
+ name: String,
+ creator: String,
+ notes: String,
+ code: String
+ ): Int {
+ var finalName = name
+ var finalCode = code
+ if (finalCode.isNotEmpty() && finalCode[0] == '$') {
+ val firstLineEnd = finalCode.indexOf('\n')
+ if (firstLineEnd == -1) {
+ finalName = finalCode.substring(1)
+ finalCode = ""
+ } else {
+ finalName = finalCode.substring(1, firstLineEnd)
+ finalCode = finalCode.substring(firstLineEnd + 1)
+ }
+ }
+
+ if (finalName.isEmpty()) return TRY_SET_FAIL_NO_NAME
+
+ val result = setCheatImpl(finalName, creator, notes, finalCode)
+
+ if (result == TRY_SET_SUCCESS) onChanged()
+
+ return result
+ }
+
+ protected abstract fun setCheatImpl(
+ name: String,
+ creator: String,
+ notes: String,
+ code: String
+ ): Int
+}