Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11614 from t895/kotlin-cheats
Android: Convert Cheats Activity to Kotlin
  • Loading branch information
lioncash committed Mar 2, 2023
2 parents 1b7969b + 3935449 commit 78e8669
Show file tree
Hide file tree
Showing 48 changed files with 1,511 additions and 1,917 deletions.

This file was deleted.

@@ -0,0 +1,52 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.cheats.model

import androidx.annotation.Keep

class ARCheat : 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 = false

override fun supportsNotes(): Boolean = false

external override fun getName(): String

external override fun getCode(): String

external override fun getUserDefined(): Boolean

external override fun getEnabled(): Boolean

external override fun setEnabledImpl(enabled: Boolean)

external override fun setCheatImpl(
name: String,
creator: String,
notes: String,
code: String
): Int

companion object {
@JvmStatic
external fun loadCodes(gameId: String, revision: Int): Array<ARCheat>

@JvmStatic
external fun saveCodes(gameId: String, revision: Int, codes: Array<ARCheat>)
}
}

This file was deleted.

@@ -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
}

This file was deleted.

@@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.cheats.model

interface Cheat {
fun supportsCreator(): Boolean

fun supportsNotes(): Boolean

fun supportsCode(): Boolean

fun getName(): String = ""

fun getCreator(): String = ""

fun getNotes(): String = ""

fun getCode(): String = ""

fun setCheat(
name: String,
creator: String,
notes: String,
code: String
): Int

fun getUserDefined(): Boolean

fun getEnabled(): Boolean

fun setEnabled(isChecked: Boolean)

fun setChangedCallback(callback: Runnable?)

companion object {
// Result codes greater than 0 represent an error on the corresponding code line (one-indexed)
const val TRY_SET_FAIL_CODE_MIXED_ENCRYPTION = -3
const val TRY_SET_FAIL_NO_CODE_LINES = -2
const val TRY_SET_FAIL_NO_NAME = -1
const val TRY_SET_SUCCESS = 0
}
}

0 comments on commit 78e8669

Please sign in to comment.