From 1dc26047491be3ee6af185e5097c01317008684f Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Fri, 4 Oct 2024 19:49:20 +0200 Subject: [PATCH] Translatable keybinds + fixed typos --- assets/languages/en/Options.xml | 28 ++- source/funkin/editors/DebugOptions.hx | 6 +- source/funkin/editors/charter/Charter.hx | 6 +- source/funkin/options/Options.hx | 2 +- .../funkin/options/keybinds/KeybindSetting.hx | 4 +- .../options/keybinds/KeybindsOptions.hx | 172 +++++++++--------- 6 files changed, 124 insertions(+), 94 deletions(-) diff --git a/assets/languages/en/Options.xml b/assets/languages/en/Options.xml index 7ce98f01..ba4315b4 100644 --- a/assets/languages/en/Options.xml +++ b/assets/languages/en/Options.xml @@ -24,6 +24,28 @@ + + Left + Down + Up + Right + + Notes + + UI + + Accept + Back + Reset + Pause + + + Engine + + Switch Mod + + + Framerate Pretty self explanatory, isn't it? @@ -32,7 +54,7 @@ If unchecked, will disable antialiasing on every sprite. Can boost performances at the cost of sharper, more pixely sprites. Colored Healthbar - If unchecked, the game will use the orginal red/green health bar from the week 6 fnf game. + If unchecked, the game will use the original red/green health bar from the week 6 fnf game. Pixel Perfect Effect If checked, Week 6 will have a pixel perfect effect to it enabled, aligning every pixel on the screen. @@ -115,8 +137,8 @@ Save Warning Time This controls how long the editor will warn you before it autosaves (in seconds..., 0 to disable) - Autosaves Folder - If checked, this will autosave your file in a seperate folder with a time stamp instead of overriding your current file. (song/autosaves/) + Autosaves Folder + If checked, this will autosave your file in a separate folder with a time stamp instead of overriding your current file. (song/autosaves/) \ No newline at end of file diff --git a/source/funkin/editors/DebugOptions.hx b/source/funkin/editors/DebugOptions.hx index 52ff060c..a79c6898 100644 --- a/source/funkin/editors/DebugOptions.hx +++ b/source/funkin/editors/DebugOptions.hx @@ -65,8 +65,8 @@ class DebugOptionsScreen extends OptionsScreen { "charterAutoSaveWarningTime" )); add(new Checkbox( - getName("charterAutoSavesSeperateFolder"), - getDesc("charterAutoSavesSeperateFolder"), - "charterAutoSavesSeperateFolder")); + getName("charterAutoSavesSeparateFolder"), + getDesc("charterAutoSavesSeparateFolder"), + "charterAutoSavesSeparateFolder")); } } \ No newline at end of file diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index e11ce49a..d7ebf584 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -695,9 +695,9 @@ class Charter extends UIState { autoSaveTimer -= elapsed; if (autoSaveTimer < Options.charterAutoSaveWarningTime && !autoSaveNotif.cancelled && !autoSaveNotif.showedAnimation) { - if (Options.charterAutoSavesSeperateFolder) + if (Options.charterAutoSavesSeparateFolder) __autoSaveLocation = __diff.toLowerCase() + DateTools.format(Date.now(), "%m-%d_%H-%M"); - var filename = !Options.charterAutoSavesSeperateFolder ? '${__diff.toLowerCase()}.json' : '${__autoSaveLocation}.json'; + var filename = !Options.charterAutoSavesSeparateFolder ? '${__diff.toLowerCase()}.json' : '${__autoSaveLocation}.json'; autoSaveNotif.startAutoSave(autoSaveTimer, TU.translate("charter.popup.savedChartAt", [filename]) ); @@ -708,7 +708,7 @@ class Charter extends UIState { buildChart(); var songPath:String = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}'; - if (Options.charterAutoSavesSeperateFolder) + if (Options.charterAutoSavesSeparateFolder) Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: false, folder: "autosaves", prettyPrint: Options.editorPrettyPrint}); else Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, prettyPrint: Options.editorPrettyPrint}); diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx index 046adf10..6961ab06 100644 --- a/source/funkin/options/Options.hx +++ b/source/funkin/options/Options.hx @@ -67,7 +67,7 @@ class Options public static var charterAutoSaves:Bool = true; public static var charterAutoSaveTime:Float = 60*5; public static var charterAutoSaveWarningTime:Float = 5; - public static var charterAutoSavesSeperateFolder:Bool = false; + public static var charterAutoSavesSeparateFolder:Bool = false; /** * PLAYER 1 CONTROLS diff --git a/source/funkin/options/keybinds/KeybindSetting.hx b/source/funkin/options/keybinds/KeybindSetting.hx index 8201f013..191c3233 100644 --- a/source/funkin/options/keybinds/KeybindSetting.hx +++ b/source/funkin/options/keybinds/KeybindSetting.hx @@ -94,7 +94,7 @@ class KeybindSetting extends FlxTypedSpriteGroup { } public function updateText() { - bind1.text = '${CoolUtil.keyToString(option1)}'; - bind2.text = '${CoolUtil.keyToString(option2)}'; + bind1.text = CoolUtil.keyToString(option1); + bind2.text = CoolUtil.keyToString(option2); } } \ No newline at end of file diff --git a/source/funkin/options/keybinds/KeybindsOptions.hx b/source/funkin/options/keybinds/KeybindsOptions.hx index e4e7d26c..b7ced2ee 100644 --- a/source/funkin/options/keybinds/KeybindsOptions.hx +++ b/source/funkin/options/keybinds/KeybindsOptions.hx @@ -4,78 +4,22 @@ import flixel.util.FlxColor; using StringTools; +typedef KeybindCategory = { + var name:String; + var settings:Array<{ + var name:String; + var control:String; + var ?icon:Array; + }>; +} + class KeybindsOptions extends MusicBeatSubstate { public static var instance:KeybindsOptions; - public var categories = [ - { - name: 'Notes', - settings: [ - { - name: '{noteLeft}', - control: 'NOTE_LEFT' - }, - { - name: '{noteDown}', - control: 'NOTE_DOWN' - }, - { - name: '{noteUp}', - control: 'NOTE_UP' - }, - { - name: '{noteRight}', - control: 'NOTE_RIGHT' - }, - ] - }, - { - name: 'UI', - settings: [ - { - name: 'Left', - control: 'LEFT' - }, - { - name: 'Down', - control: 'DOWN' - }, - { - name: 'Up', - control: 'UP' - }, - { - name: 'Right', - control: 'RIGHT' - }, - { - name: 'Accept', - control: 'ACCEPT' - }, - { - name: 'Back', - control: 'BACK' - }, - { - name: 'Reset', - control: 'RESET' - }, - { - name: 'Pause', - control: 'PAUSE' - }, - ] - }, - { - name: 'Engine', - settings: [ - { - name: 'Switch Mod', - control: 'SWITCHMOD' - }, - ] - } - ]; + public var categories:Array = []; + + public function translate(id:String, ?args:Array) + return TU.translate("Keybinds." + id, args); public var settingCam:FlxCamera; @@ -96,6 +40,80 @@ class KeybindsOptions extends MusicBeatSubstate { var isSubState:Bool = false; public override function create() { + categories = [ + { + name: translate("category.notes"), + settings: [ + { + icon: ["game/notes/default", "purple0"], + name: translate("left"), + control: 'NOTE_LEFT' + }, + { + icon: ['game/notes/default', 'blue0'], + name: translate("down"), + control: 'NOTE_DOWN' + }, + { + icon: ['game/notes/default', 'green0'], + name: translate("up"), + control: 'NOTE_UP' + }, + { + icon: ['game/notes/default', '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("category.engine"), + settings: [ + { + name: translate("engine.switchMod"), + control: 'SWITCHMOD' + }, + ] + } + ]; + super.create(); instance = this; @@ -138,19 +156,9 @@ class KeybindsOptions extends MusicBeatSubstate { for(e in category.settings) { var sparrowIcon:String = null; var sparrowAnim:String = null; - if (e.name.startsWith('{note')) {// is actually a note!! - sparrowIcon = "game/notes/default"; - sparrowAnim = switch(e.name) { - case '{noteLeft}': - "purple0"; - case '{noteDown}': - "blue0"; - case '{noteUp}': - "green0"; - default: - "red0"; - }; - e.name = e.name.substring(5, e.name.length - 1); + if(e.icon != null) { + sparrowIcon = e.icon[0]; + sparrowAnim = e.icon[1]; } var text = new KeybindSetting(100, k * 75, e.name, e.control, sparrowIcon, sparrowAnim);