mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-15 10:37:04 +00:00
changed comments to english
This commit is contained in:
parent
997c43ef50
commit
c3ec63e18e
2 changed files with 41 additions and 45 deletions
|
|
@ -9,7 +9,7 @@ data class CheatItem(val buildId: String, val name: String) {
|
||||||
val key get() = "$buildId-$name"
|
val key get() = "$buildId-$name"
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------- Pfade -------- */
|
/* -------- Paths -------- */
|
||||||
|
|
||||||
private fun cheatsDirExternal(activity: Activity, titleId: String): File {
|
private fun cheatsDirExternal(activity: Activity, titleId: String): File {
|
||||||
val base = activity.getExternalFilesDir(null) // /storage/emulated/0/Android/data/<pkg>/files
|
val base = activity.getExternalFilesDir(null) // /storage/emulated/0/Android/data/<pkg>/files
|
||||||
|
|
@ -22,7 +22,7 @@ private fun cheatsDirInternal(activity: Activity, titleId: String): File {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun allCheatDirs(activity: Activity, titleId: String): List<File> {
|
private fun allCheatDirs(activity: Activity, titleId: String): List<File> {
|
||||||
// Reihenfolge: internal zuerst (hier schreibt LibKenjinx i.d.R.), dann external
|
// Order: internal first (LibKenjinx usually writes here), then external
|
||||||
return listOf(cheatsDirInternal(activity, titleId), cheatsDirExternal(activity, titleId))
|
return listOf(cheatsDirInternal(activity, titleId), cheatsDirExternal(activity, titleId))
|
||||||
.distinct()
|
.distinct()
|
||||||
.filter { it.exists() && it.isDirectory }
|
.filter { it.exists() && it.isDirectory }
|
||||||
|
|
@ -40,7 +40,7 @@ private fun parseCheatNames(text: String): List<String> {
|
||||||
.toList()
|
.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------- Public: Cheats laden -------- */
|
/* -------- Public: Load cheats -------- */
|
||||||
|
|
||||||
fun loadCheatsFromDisk(activity: Activity, titleId: String): List<CheatItem> {
|
fun loadCheatsFromDisk(activity: Activity, titleId: String): List<CheatItem> {
|
||||||
val dirs = allCheatDirs(activity, titleId)
|
val dirs = allCheatDirs(activity, titleId)
|
||||||
|
|
@ -65,10 +65,10 @@ fun loadCheatsFromDisk(activity: Activity, titleId: String): List<CheatItem> {
|
||||||
.sortedWith(compareBy({ it.buildId.lowercase() }, { it.name.lowercase() }))
|
.sortedWith(compareBy({ it.buildId.lowercase() }, { it.name.lowercase() }))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------- Public: Auswahl SOFORT auf Disk anwenden -------- */
|
/* -------- Public: Apply selection to disk immediately -------- */
|
||||||
|
|
||||||
fun applyCheatSelectionOnDisk(activity: Activity, titleId: String, enabledKeys: Set<String>) {
|
fun applyCheatSelectionOnDisk(activity: Activity, titleId: String, enabledKeys: Set<String>) {
|
||||||
// Wir wählen genau EINE BUILDID-Datei (die „beste“), und schalten darin Sections.
|
// We pick exactly ONE BUILDID file (the "best") and toggle sections inside it.
|
||||||
val dirs = allCheatDirs(activity, titleId)
|
val dirs = allCheatDirs(activity, titleId)
|
||||||
val allTxt = dirs.flatMap { d ->
|
val allTxt = dirs.flatMap { d ->
|
||||||
d.listFiles { f -> f.isFile && f.name.endsWith(".txt", ignoreCase = true) }?.toList() ?: emptyList()
|
d.listFiles { f -> f.isFile && f.name.endsWith(".txt", ignoreCase = true) }?.toList() ?: emptyList()
|
||||||
|
|
@ -82,7 +82,7 @@ fun applyCheatSelectionOnDisk(activity: Activity, titleId: String, enabledKeys:
|
||||||
val text = runCatching { buildFile.readText(Charset.forName("UTF-8")) }.getOrElse { "" }
|
val text = runCatching { buildFile.readText(Charset.forName("UTF-8")) }.getOrElse { "" }
|
||||||
if (text.isEmpty()) return
|
if (text.isEmpty()) return
|
||||||
|
|
||||||
// Enabled-Set normalisieren: Keys sind "<BUILDID>-<SectionName>"
|
// Normalize enabled set: keys are "<BUILDID>-<SectionName>"
|
||||||
val enabledSections = enabledKeys.asSequence()
|
val enabledSections = enabledKeys.asSequence()
|
||||||
.mapNotNull { key ->
|
.mapNotNull { key ->
|
||||||
val dash = key.indexOf('-')
|
val dash = key.indexOf('-')
|
||||||
|
|
@ -100,7 +100,7 @@ fun applyCheatSelectionOnDisk(activity: Activity, titleId: String, enabledKeys:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------- Implementierung: Auswahl anwenden (nur ';' als Kommentar) -------- */
|
/* -------- Implementation: apply selection (using only ';' as comment) -------- */
|
||||||
|
|
||||||
private fun pickBestBuildFile(files: List<File>): File {
|
private fun pickBestBuildFile(files: List<File>): File {
|
||||||
fun looksHexName(p: File): Boolean {
|
fun looksHexName(p: File): Boolean {
|
||||||
|
|
@ -124,8 +124,8 @@ private fun sectionNameFromHeader(line: String): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entfernt EIN führendes Kommentarzeichen (';') + optionales Leerzeichen.
|
* Removes ONE leading comment marker (';') + optional space.
|
||||||
* Nur am absoluten Zeilenanfang (keine führenden Spaces erlaubt).
|
* Only at absolute column 0 (no leading spaces allowed).
|
||||||
*/
|
*/
|
||||||
private fun uncommentOnce(raw: String): String {
|
private fun uncommentOnce(raw: String): String {
|
||||||
if (raw.isEmpty()) return raw
|
if (raw.isEmpty()) return raw
|
||||||
|
|
@ -135,8 +135,8 @@ private fun uncommentOnce(raw: String): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kommentiert die Zeile aus, wenn sie nicht bereits mit ';' beginnt.
|
* Comments out the line if it does not already start with ';'.
|
||||||
* Atmosphère nutzt ';' – das verwenden wir ausschließlich.
|
* Atmosphère uses ';' — we use that exclusively.
|
||||||
*/
|
*/
|
||||||
private fun commentOut(raw: String): String {
|
private fun commentOut(raw: String): String {
|
||||||
val t = raw.trimStart()
|
val t = raw.trimStart()
|
||||||
|
|
@ -146,12 +146,12 @@ private fun commentOut(raw: String): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schreibt die Datei neu:
|
* Rewrites the file:
|
||||||
* - Keine Marker einfügen
|
* - Do not insert markers
|
||||||
* - Pro Section den Body gemäß enabled/disabled (enabledSections) kommentieren/entkommentieren
|
* - For each section, comment/uncomment the body according to enabled/disabled (enabledSections)
|
||||||
* - Reine Kommentar-/Leerzeilen (nur ';') bleiben erhalten
|
* - Keep pure comment/empty lines (only ';') intact
|
||||||
*/
|
*/
|
||||||
// Hilfsfunktionen: trailing Blankzeilen trimmen / Header normalisieren
|
// Helpers: trim trailing blank lines / normalize header
|
||||||
private fun trimTrailingBlankLines(lines: MutableList<String>) {
|
private fun trimTrailingBlankLines(lines: MutableList<String>) {
|
||||||
while (lines.isNotEmpty() && lines.last().trim().isEmpty()) {
|
while (lines.isNotEmpty() && lines.last().trim().isEmpty()) {
|
||||||
lines.removeAt(lines.lastIndex)
|
lines.removeAt(lines.lastIndex)
|
||||||
|
|
@ -159,18 +159,18 @@ private fun trimTrailingBlankLines(lines: MutableList<String>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun joinHeaderBufferOnce(header: List<String>): String {
|
private fun joinHeaderBufferOnce(header: List<String>): String {
|
||||||
// Header-Zeilen unverändert, aber trailing Blanks entfernen und genau 1 Leerzeile danach
|
// Keep header lines unchanged, but remove trailing blanks and add exactly one blank line after
|
||||||
val buf = header.toMutableList()
|
val buf = header.toMutableList()
|
||||||
trimTrailingBlankLines(buf)
|
trimTrailingBlankLines(buf)
|
||||||
return if (buf.isEmpty()) "" else buf.joinToString("\n") + "\n\n"
|
return if (buf.isEmpty()) "" else buf.joinToString("\n") + "\n\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schreibt die Datei neu:
|
* Rewrites the file:
|
||||||
* - Keine Marker einfügen
|
* - Do not insert markers
|
||||||
* - Pro Section den Body gemäß enabled/disabled (enabledSections) kommentieren/entkommentieren
|
* - For each section, comment/uncomment the body according to enabled/disabled (enabledSections)
|
||||||
* - Reine Kommentar-/Leerzeilen bleiben erhalten
|
* - Keep pure comment/empty lines intact
|
||||||
* - Zwischen Sections genau EINE Leerzeile, am Ende genau EIN Newline.
|
* - Exactly ONE blank line between sections, exactly ONE newline at the end.
|
||||||
*/
|
*/
|
||||||
private fun rewriteCheatFile(original: String, enabledSections: Set<String>): String {
|
private fun rewriteCheatFile(original: String, enabledSections: Set<String>): String {
|
||||||
val lines = original.replace("\uFEFF", "").lines()
|
val lines = original.replace("\uFEFF", "").lines()
|
||||||
|
|
@ -186,18 +186,18 @@ private fun rewriteCheatFile(original: String, enabledSections: Set<String>): St
|
||||||
fun flushCurrent() {
|
fun flushCurrent() {
|
||||||
val sec = currentSection ?: return
|
val sec = currentSection ?: return
|
||||||
|
|
||||||
// trailing Blankzeilen im Block entfernen, damit keine doppelten Abstände wachsen
|
// Remove trailing blank lines from the block so spacing doesn't grow
|
||||||
trimTrailingBlankLines(currentBlock)
|
trimTrailingBlankLines(currentBlock)
|
||||||
|
|
||||||
val enabled = enabledSections.contains(sec.lowercase())
|
val enabled = enabledSections.contains(sec.lowercase())
|
||||||
|
|
||||||
// Zwischen Sections genau eine Leerzeile einfügen (aber nicht vor der ersten)
|
// Insert exactly one blank line between sections (but not before the first)
|
||||||
if (wroteAnySection) out.append('\n')
|
if (wroteAnySection) out.append('\n')
|
||||||
|
|
||||||
out.append('[').append(sec).append(']').append('\n')
|
out.append('[').append(sec).append(']').append('\n')
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
// Entkommentieren (nur ein führendes ';' an Spalte 0)
|
// Uncomment (only a single leading ';' at column 0)
|
||||||
for (l in currentBlock) {
|
for (l in currentBlock) {
|
||||||
val trimmed = l.trim()
|
val trimmed = l.trim()
|
||||||
if (trimmed.isEmpty() || (trimmed.startsWith(";") && trimmed.length <= 1)) {
|
if (trimmed.isEmpty() || (trimmed.startsWith(";") && trimmed.length <= 1)) {
|
||||||
|
|
@ -213,7 +213,7 @@ private fun rewriteCheatFile(original: String, enabledSections: Set<String>): St
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Disablen: alles, was nicht schon mit ';' beginnt und nicht leer ist, auskommentieren
|
// Disable: comment out anything that doesn't already start with ';' and isn't empty
|
||||||
for (l in currentBlock) {
|
for (l in currentBlock) {
|
||||||
val t = l.trim()
|
val t = l.trim()
|
||||||
if (t.isEmpty() || t.startsWith(";")) {
|
if (t.isEmpty() || t.startsWith(";")) {
|
||||||
|
|
@ -245,16 +245,16 @@ private fun rewriteCheatFile(original: String, enabledSections: Set<String>): St
|
||||||
}
|
}
|
||||||
flushCurrent()
|
flushCurrent()
|
||||||
|
|
||||||
// Header vorn einsetzen (mit genau einer Leerzeile danach, falls vorhanden)
|
// Prepend header (with exactly one blank line after it, if present)
|
||||||
val headerText = joinHeaderBufferOnce(headerBuffer)
|
val headerText = joinHeaderBufferOnce(headerBuffer)
|
||||||
if (headerText.isNotEmpty()) {
|
if (headerText.isNotEmpty()) {
|
||||||
out.insert(0, headerText)
|
out.insert(0, headerText)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Globale Normalisierung: 3+ Newlines -> 2, und am Ende genau EIN '\n'
|
// Global normalization: 3+ newlines -> 2, and exactly ONE '\n' at the end
|
||||||
var result = out.toString()
|
val result = out.toString()
|
||||||
.replace(Regex("\n{3,}"), "\n\n") // nie mehr als 1 Leerzeile zwischen Abschnitten
|
.replace(Regex("\n{3,}"), "\n\n") // never more than 1 blank line between sections
|
||||||
.trimEnd() + "\n" // genau ein Newline am Ende
|
.trimEnd() + "\n" // exactly one newline at the end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ class HomeViews {
|
||||||
val cheatsForSelected = remember { mutableStateOf(listOf<CheatItem>()) }
|
val cheatsForSelected = remember { mutableStateOf(listOf<CheatItem>()) }
|
||||||
val enabledCheatKeys = remember { mutableStateOf(mutableSetOf<String>()) }
|
val enabledCheatKeys = remember { mutableStateOf(mutableSetOf<String>()) }
|
||||||
|
|
||||||
// Shortcut-Dialog-State
|
// Shortcut dialog state
|
||||||
val showShortcutDialog = remember { mutableStateOf(false) }
|
val showShortcutDialog = remember { mutableStateOf(false) }
|
||||||
val shortcutName = remember { mutableStateOf("") }
|
val shortcutName = remember { mutableStateOf("") }
|
||||||
|
|
||||||
|
|
@ -402,12 +402,11 @@ class HomeViews {
|
||||||
thread {
|
thread {
|
||||||
showLoading.value = true
|
showLoading.value = true
|
||||||
|
|
||||||
// NEW: Push Cheats vor dem Start (Auto-Start Pfad)
|
// NEW: Push cheats before launch (auto-start path)
|
||||||
val gm = viewModel.mainViewModel.loadGameModel.value!!
|
val gm = viewModel.mainViewModel.loadGameModel.value!!
|
||||||
val tId = gm.titleId ?: ""
|
val tId = gm.titleId ?: ""
|
||||||
val act = viewModel.activity
|
val act = viewModel.activity
|
||||||
|
|
||||||
|
|
||||||
val success = viewModel.mainViewModel.loadGame(
|
val success = viewModel.mainViewModel.loadGame(
|
||||||
gm,
|
gm,
|
||||||
true,
|
true,
|
||||||
|
|
@ -438,12 +437,11 @@ class HomeViews {
|
||||||
IconButton(onClick = {
|
IconButton(onClick = {
|
||||||
if (viewModel.mainViewModel?.selected != null) {
|
if (viewModel.mainViewModel?.selected != null) {
|
||||||
|
|
||||||
// NEW: Push Cheats vor dem Start (Run-Button)
|
// NEW: Push cheats before launch (Run button)
|
||||||
val gmSel = viewModel.mainViewModel!!.selected!!
|
val gmSel = viewModel.mainViewModel!!.selected!!
|
||||||
val tId = gmSel.titleId ?: ""
|
val tId = gmSel.titleId ?: ""
|
||||||
val act = viewModel.activity
|
val act = viewModel.activity
|
||||||
|
|
||||||
|
|
||||||
thread {
|
thread {
|
||||||
showLoading.value = true
|
showLoading.value = true
|
||||||
val success = viewModel.mainViewModel.loadGame(
|
val success = viewModel.mainViewModel.loadGame(
|
||||||
|
|
@ -564,13 +562,13 @@ class HomeViews {
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
val act2 = act
|
val act2 = act
|
||||||
if (act2 != null && titleId.isNotEmpty()) {
|
if (act2 != null && titleId.isNotEmpty()) {
|
||||||
// 1) Auswahl persistent speichern (UI-State)
|
// 1) Persist selection (UI state)
|
||||||
CheatPrefs(act2).setEnabled(titleId, enabledCheatKeys.value)
|
CheatPrefs(act2).setEnabled(titleId, enabledCheatKeys.value)
|
||||||
|
|
||||||
// 2) SOFORT die .txt umschreiben
|
// 2) Immediately rewrite the .txt on disk
|
||||||
applyCheatSelectionOnDisk(act2, titleId, enabledCheatKeys.value)
|
applyCheatSelectionOnDisk(act2, titleId, enabledCheatKeys.value)
|
||||||
|
|
||||||
// 3) Liste neu laden (damit disabled Einträge sichtbar bleiben)
|
// 3) Reload list (so disabled entries remain visible)
|
||||||
cheatsForSelected.value = loadCheatsFromDisk(act2, titleId)
|
cheatsForSelected.value = loadCheatsFromDisk(act2, titleId)
|
||||||
}
|
}
|
||||||
openCheatsDialog.value = false
|
openCheatsDialog.value = false
|
||||||
|
|
@ -633,7 +631,7 @@ class HomeViews {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Shortcut-Dialog
|
// --- Shortcut dialog
|
||||||
if (showShortcutDialog.value) {
|
if (showShortcutDialog.value) {
|
||||||
val gm = viewModel.mainViewModel?.selected
|
val gm = viewModel.mainViewModel?.selected
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
|
|
@ -658,7 +656,7 @@ class HomeViews {
|
||||||
.padding(top = 8.dp)
|
.padding(top = 8.dp)
|
||||||
) {
|
) {
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
// App icon (Grid image)
|
// App icon (grid image)
|
||||||
if (gm != null && activity != null) {
|
if (gm != null && activity != null) {
|
||||||
val gameUri = resolveGameUri(gm)
|
val gameUri = resolveGameUri(gm)
|
||||||
if (gameUri != null) {
|
if (gameUri != null) {
|
||||||
|
|
@ -740,11 +738,10 @@ class HomeViews {
|
||||||
thread {
|
thread {
|
||||||
showLoading.value = true
|
showLoading.value = true
|
||||||
|
|
||||||
// NEW: Push Cheats vor dem Start
|
// NEW: Push cheats before launch
|
||||||
val tId = gameModel.titleId ?: ""
|
val tId = gameModel.titleId ?: ""
|
||||||
val act = viewModel.activity
|
val act = viewModel.activity
|
||||||
|
|
||||||
|
|
||||||
val success = viewModel.mainViewModel?.loadGame(gameModel) ?: false
|
val success = viewModel.mainViewModel?.loadGame(gameModel) ?: false
|
||||||
if (success == 1) {
|
if (success == 1) {
|
||||||
launchOnUiThread { viewModel.mainViewModel?.navigateToGame() }
|
launchOnUiThread { viewModel.mainViewModel?.navigateToGame() }
|
||||||
|
|
@ -837,11 +834,10 @@ class HomeViews {
|
||||||
thread {
|
thread {
|
||||||
showLoading.value = true
|
showLoading.value = true
|
||||||
|
|
||||||
// NEW: Push Cheats vor dem Start
|
// NEW: Push cheats before launch
|
||||||
val tId = gameModel.titleId ?: ""
|
val tId = gameModel.titleId ?: ""
|
||||||
val act = viewModel.activity
|
val act = viewModel.activity
|
||||||
|
|
||||||
|
|
||||||
val success = viewModel.mainViewModel?.loadGame(gameModel) ?: false
|
val success = viewModel.mainViewModel?.loadGame(gameModel) ?: false
|
||||||
if (success == 1) {
|
if (success == 1) {
|
||||||
launchOnUiThread { viewModel.mainViewModel?.navigateToGame() }
|
launchOnUiThread { viewModel.mainViewModel?.navigateToGame() }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue