From d358ebd70abad24e87065e748c18fe448cc91598 Mon Sep 17 00:00:00 2001 From: Bitto Date: Tue, 23 Sep 2025 22:34:33 +0100 Subject: [PATCH] Update KeybindsOptions.hx --- .../options/keybinds/KeybindsOptions.hx | 231 +++++++++--------- 1 file changed, 120 insertions(+), 111 deletions(-) diff --git a/source/funkin/options/keybinds/KeybindsOptions.hx b/source/funkin/options/keybinds/KeybindsOptions.hx index 0ae12058e..2eca496ff 100644 --- a/source/funkin/options/keybinds/KeybindsOptions.hx +++ b/source/funkin/options/keybinds/KeybindsOptions.hx @@ -9,9 +9,7 @@ class KeybindsOptions extends MusicBeatSubstate { public static var instance:KeybindsOptions; public function translate(id:String, ?args:Array) - return TU.translate("KeybindsOptions." + id, args); - - public var categories:Array = []; + return TU.translate(id, args); public var settingCam:FlxCamera; @@ -29,126 +27,127 @@ class KeybindsOptions extends MusicBeatSubstate { ]; public var camFollow:FlxObject = new FlxObject(0, 0, 2, 2); - var isSubState:Bool = false; - - public override function create() { - categories = [ - { - name: translate("category.notes"), - settings: [ - { - sparrowIcon: "game/notes/default", - sparrowAnim: "purple0", - name: translate("left"), - control: 'NOTE_LEFT' - }, - { - sparrowIcon: "game/notes/default", - sparrowAnim: "blue0", - name: translate("down"), - control: 'NOTE_DOWN' - }, - { - sparrowIcon: "game/notes/default", - sparrowAnim: "green0", - name: translate("up"), - control: 'NOTE_UP' - }, - { - sparrowIcon: "game/notes/default", - sparrowAnim: "red0", - name: translate("right"), - control: 'NOTE_RIGHT' - }, - ] - }, - { - name: translate("category.ui"), - settings: [ - { - name: translate("left"), - control: 'LEFT' - }, - { - name: translate("down"), - control: 'DOWN' - }, - { - name: translate("up"), - control: 'UP' - }, - { - name: translate("right"), - control: 'RIGHT' - }, - { - name: translate("ui.accept"), - control: 'ACCEPT' - }, - { - name: translate("ui.back"), - control: 'BACK' - }, - { - name: translate("ui.reset"), - control: 'RESET' - }, - { - name: translate("ui.pause"), - control: 'PAUSE' - }, - { - name: translate("ui.changeMode"), - control: 'CHANGE_MODE' - }, - ] - }, + public var categories:Array = []; + public static var defaultCategories:Array = [ + { + name: "category.notes", + settings: [ + { + sparrowIcon: "game/notes/default", + sparrowAnim: "purple0", + name: "left", + control: 'NOTE_LEFT' + }, + { + sparrowIcon: "game/notes/default", + sparrowAnim: "blue0", + name: "down", + control: 'NOTE_DOWN' + }, + { + sparrowIcon: "game/notes/default", + sparrowAnim: "green0", + name: "up", + control: 'NOTE_UP' + }, + { + sparrowIcon: "game/notes/default", + sparrowAnim: "red0", + name: "right", + control: 'NOTE_RIGHT' + }, + ] + }, + { + name: "category.ui", + settings: [ + { + name: "left", + control: 'LEFT' + }, + { + name: "down", + control: 'DOWN' + }, + { + name: "up", + control: 'UP' + }, + { + name: "right", + control: 'RIGHT' + }, + { + name: "ui.accept", + control: 'ACCEPT' + }, + { + name: "ui.back", + control: 'BACK' + }, + { + name: "ui.reset", + control: 'RESET' + }, + { + name: "ui.pause", + control: 'PAUSE' + }, + { + name: "ui.changeMode", + control: 'CHANGE_MODE' + }, + ] + }, { - name: translate("category.volume"), + name: "category.volume", settings: [ { - name: translate("volume.up"), + name: "volume.up", control: 'VOLUME_UP' }, { - name: translate("volume.down"), + name: "volume.down", control: 'VOLUME_DOWN' }, { - name: translate("volume.mute"), + name: "volume.mute", control: 'VOLUME_MUTE' }, ] }, - { - name: translate("category.engine"), - settings: [ - { - name: translate("engine.switchMod"), - control: 'SWITCHMOD' - }, - ] - }, - { - name: translate("category.developer"), - devModeOnly: true, - settings: [ - { - name: translate("developer.devMenus"), - control: 'DEV_ACCESS' - }, - { - name: translate("developer.openConsole"), - control: 'DEV_CONSOLE' - }, - { - name: translate("developer.reloadState"), - control: 'DEV_RELOAD' - }, - ] - } - ]; + { + name: "category.engine", + settings: [ + { + name: "engine.switchMod", + control: 'SWITCHMOD' + }, + ] + }, + { + name: "category.developer", + devModeOnly: true, + settings: [ + { + name: "developer.devMenus", + control: 'DEV_ACCESS' + }, + { + name: "developer.openConsole", + control: 'DEV_CONSOLE' + }, + { + name: "developer.reloadState", + control: 'DEV_RELOAD' + }, + ] + } + ]; + public var isSubState:Bool = false; + + public override function create() { super.create(); instance = this; @@ -180,6 +179,8 @@ class KeybindsOptions extends MusicBeatSubstate { FlxG.camera.follow(camFollow, LOCKON, 0.125); } + for (category in defaultCategories) categories.push(category); + var customCategories = loadCustomCategories(); for (i in customCategories) categories.push(i); @@ -188,7 +189,11 @@ class KeybindsOptions extends MusicBeatSubstate { if (category.devModeOnly && !Options.devMode) continue; k++; - var title = new Alphabet(0, k * 75, category.name, "bold"); + var translationPrefix:String = (category.custom != null) ? '' : 'KeybindsOptions.'; + + var categoryToTranslate:String = translationPrefix + category.name; + var translatedCategory:String = TU.exists(categoryToTranslate) ? translate(categoryToTranslate) : category.name; + var title = new Alphabet(0, k * 75, translatedCategory, "bold"); title.screenCenter(X); add(title); @@ -199,7 +204,9 @@ class KeybindsOptions extends MusicBeatSubstate { if (e.sparrowIcon != null) sparrowIcon = e.sparrowIcon; if (e.sparrowAnim != null) sparrowAnim = e.sparrowAnim; - var text = new KeybindSetting(100, k * 75, e.name, e.control, sparrowIcon, sparrowAnim, e.custom == null ? false : e.custom); + var nameToTranslate:String = translationPrefix + e.name; + var translatedName:String = TU.exists(nameToTranslate) ? translate(nameToTranslate) : e.name; + var text = new KeybindSetting(100, k * 75, translatedName, e.control, sparrowIcon, sparrowAnim, e.custom == null ? false : e.custom); if (!isSubState) text.bind1.color = text.bind2.color = FlxColor.BLACK; alphabets.add(text); @@ -318,6 +325,7 @@ class KeybindsOptions extends MusicBeatSubstate { var cat:ControlsCategory = { name: category.getAtt("name"), + custom: true, settings: [] }; @@ -354,4 +362,5 @@ typedef ControlsCategory = { var name:String; var settings:Array; var ?devModeOnly:Bool; + var ?custom:Bool; } \ No newline at end of file