-
Notifications
You must be signed in to change notification settings - Fork 1k
Make hotkeys great again #2946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make hotkeys great again #2946
Changes from all commits
9ec190e
137ee08
92b455f
b05611c
1edb1f1
6b552a3
8beae18
9d4de1a
653dc5e
28a4d99
3f29cf3
1ef3bc6
592c453
e8c5856
fbc3a6d
12899bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,7 @@ | ||||||||||||||||||||||||||||||||||||||||||
| import { html } from "lit"; | ||||||||||||||||||||||||||||||||||||||||||
| import { customElement, state } from "lit/decorators.js"; | ||||||||||||||||||||||||||||||||||||||||||
| import { getDefaultKeybinds } from "../client/Keybinds"; | ||||||||||||||||||||||||||||||||||||||||||
| import { translateText } from "../client/Utils"; | ||||||||||||||||||||||||||||||||||||||||||
| import { customElement, query, state } from "lit/decorators.js"; | ||||||||||||||||||||||||||||||||||||||||||
| import { translateText, TUTORIAL_VIDEO_URL } from "../client/Utils"; | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2
to
6
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate imports break the build. Lines 2–4 duplicate the imports already on lines 5–6. The CI pipeline fails with 🐛 Fix: merge into two clean imports-import { customElement, state } from "lit/decorators.js";
-import { getDefaultKeybinds } from "../client/Keybinds";
-import { translateText } from "../client/Utils";
-import { customElement, query, state } from "lit/decorators.js";
-import { translateText, TUTORIAL_VIDEO_URL } from "../client/Utils";
+import { customElement, query, state } from "lit/decorators.js";
+import { getDefaultKeybinds } from "../client/Keybinds";
+import { translateText, TUTORIAL_VIDEO_URL } from "../client/Utils";📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (2.3.13)[error] 5-5: Shouldn't redeclare 'customElement'. Consider to delete it or rename it. 'customElement' is defined here: (lint/suspicious/noRedeclare) [error] 5-5: Shouldn't redeclare 'state'. Consider to delete it or rename it. 'state' is defined here: (lint/suspicious/noRedeclare) [error] 6-6: Shouldn't redeclare 'translateText'. Consider to delete it or rename it. 'translateText' is defined here: (lint/suspicious/noRedeclare) 🪛 GitHub Actions: 🧪 CI[error] 2-2: Duplicate identifier 'customElement'. 🪛 GitHub Actions: 🚀 Deploy[error] 2-6: Duplicate identifier 'customElement'. Duplicate identifier 'state'. Duplicate identifier 'translateText'. [error] 2-6: TS2300: Duplicate identifier errors detected during TypeScript compilation in HelpModal.ts. 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| import { BaseModal } from "./components/BaseModal"; | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -29,39 +32,44 @@ export class HelpModal extends BaseModal { | |||||||||||||||||||||||||||||||||||||||||
| saved = Object.fromEntries( | ||||||||||||||||||||||||||||||||||||||||||
| Object.entries(parsed) | ||||||||||||||||||||||||||||||||||||||||||
| .map(([k, v]) => { | ||||||||||||||||||||||||||||||||||||||||||
| if (this.isKeybindObject(v)) return [k, v.value]; | ||||||||||||||||||||||||||||||||||||||||||
| if (this.isKeybindObject(v)) return [k, (v as any).value]; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||
| typeof v === "object" && | ||||||||||||||||||||||||||||||||||||||||||
| v !== null && | ||||||||||||||||||||||||||||||||||||||||||
| "value" in (v as any) && | ||||||||||||||||||||||||||||||||||||||||||
| Array.isArray((v as any).value) | ||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||
| return [k, (v as any).value.join(" ")]; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if (Array.isArray(v)) return [k, v.join(" ")]; | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+37
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cd src/client && head -100 HelpModal.ts | tail -80Repository: openfrontio/OpenFrontIO Length of output: 2247 🏁 Script executed: # Find the full HelpModal.ts file and check its size
wc -l src/client/HelpModal.tsRepository: openfrontio/OpenFrontIO Length of output: 95 🏁 Script executed: # Look for getKeyLabel function
rg "getKeyLabel" src/client/HelpModal.ts -A 15Repository: openfrontio/OpenFrontIO Length of output: 1194 🏁 Script executed: # Look for getDefaultKeybinds
rg "getDefaultKeybinds\|DEFAULT_KEYBINDS" src/client/ -A 10Repository: openfrontio/OpenFrontIO Length of output: 49 🏁 Script executed: # Check the full getKeybinds method
rg "getKeybinds\(\)" src/client/HelpModal.ts -A 40Repository: openfrontio/OpenFrontIO Length of output: 1938 🏁 Script executed: # Search for getDefaultKeybinds function definition
rg "function getDefaultKeybinds|const getDefaultKeybinds|export.*getDefaultKeybinds" src/client/ -A 20Repository: openfrontio/OpenFrontIO Length of output: 222 🏁 Script executed: # Look in the entire src/client directory for DEFAULT_KEYBINDS or getDefaultKeybinds
rg "getDefaultKeybinds" src/ -B 2 -A 25Repository: openfrontio/OpenFrontIO Length of output: 8863 🏁 Script executed: # Check the Keybinds.ts file to see DEFAULT_KEYBINDS
cat -n src/client/Keybinds.ts | head -60Repository: openfrontio/OpenFrontIO Length of output: 1751 Array values joined with space, but When a stored keybind value is an array (e.g. Join arrays with Fix: use "+" as the join delimiter Array.isArray((v as any).value)
) {
- return [k, (v as any).value.join(" ")];
+ return [k, (v as any).value.join("+")];
}
- if (Array.isArray(v)) return [k, v.join(" ")];
+ if (Array.isArray(v)) return [k, v.join("+")];📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| if (typeof v === "string") return [k, v]; | ||||||||||||||||||||||||||||||||||||||||||
| return [k, undefined]; | ||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||
| .filter(([, v]) => typeof v === "string" && v !== "Null"), | ||||||||||||||||||||||||||||||||||||||||||
| .filter(([, v]) => typeof v === "string"), | ||||||||||||||||||||||||||||||||||||||||||
| ) as Record<string, string>; | ||||||||||||||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||||||||||||||
| console.warn("Invalid keybinds JSON:", e); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const isMac = /Mac/.test(navigator.userAgent); | ||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||
| toggleView: "Space", | ||||||||||||||||||||||||||||||||||||||||||
| centerCamera: "KeyC", | ||||||||||||||||||||||||||||||||||||||||||
| moveUp: "KeyW", | ||||||||||||||||||||||||||||||||||||||||||
| moveDown: "KeyS", | ||||||||||||||||||||||||||||||||||||||||||
| moveLeft: "KeyA", | ||||||||||||||||||||||||||||||||||||||||||
| moveRight: "KeyD", | ||||||||||||||||||||||||||||||||||||||||||
| zoomOut: "KeyQ", | ||||||||||||||||||||||||||||||||||||||||||
| zoomIn: "KeyE", | ||||||||||||||||||||||||||||||||||||||||||
| attackRatioDown: "KeyT", | ||||||||||||||||||||||||||||||||||||||||||
| attackRatioUp: "KeyY", | ||||||||||||||||||||||||||||||||||||||||||
| swapDirection: "KeyU", | ||||||||||||||||||||||||||||||||||||||||||
| shiftKey: "ShiftLeft", | ||||||||||||||||||||||||||||||||||||||||||
| modifierKey: isMac ? "MetaLeft" : "ControlLeft", | ||||||||||||||||||||||||||||||||||||||||||
| altKey: "AltLeft", | ||||||||||||||||||||||||||||||||||||||||||
| resetGfx: "KeyR", | ||||||||||||||||||||||||||||||||||||||||||
| ...getDefaultKeybinds(), | ||||||||||||||||||||||||||||||||||||||||||
| ...saved, | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| private getKeyLabel(code: string): string { | ||||||||||||||||||||||||||||||||||||||||||
| if (!code) return ""; | ||||||||||||||||||||||||||||||||||||||||||
| if (code === "Null") return translateText("common.none"); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if (code.includes("+")) { | ||||||||||||||||||||||||||||||||||||||||||
| return code | ||||||||||||||||||||||||||||||||||||||||||
| .split("+") | ||||||||||||||||||||||||||||||||||||||||||
| .map((part) => this.getKeyLabel(part.trim())) | ||||||||||||||||||||||||||||||||||||||||||
| .filter(Boolean) | ||||||||||||||||||||||||||||||||||||||||||
| .join(" + "); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const specialLabels: Record<string, string> = { | ||||||||||||||||||||||||||||||||||||||||||
| ShiftLeft: "⇧ Shift", | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -72,6 +80,10 @@ export class HelpModal extends BaseModal { | |||||||||||||||||||||||||||||||||||||||||
| AltRight: "Alt", | ||||||||||||||||||||||||||||||||||||||||||
| MetaLeft: "⌘", | ||||||||||||||||||||||||||||||||||||||||||
| MetaRight: "⌘", | ||||||||||||||||||||||||||||||||||||||||||
| MouseLeft: "Left Click", | ||||||||||||||||||||||||||||||||||||||||||
| MouseMiddle: "Middle Click", | ||||||||||||||||||||||||||||||||||||||||||
| ScrollUp: "Scroll Up", | ||||||||||||||||||||||||||||||||||||||||||
| ScrollDown: "Scroll Down", | ||||||||||||||||||||||||||||||||||||||||||
| Space: "Space", | ||||||||||||||||||||||||||||||||||||||||||
| ArrowUp: "↑", | ||||||||||||||||||||||||||||||||||||||||||
| ArrowDown: "↓", | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -275,62 +287,23 @@ export class HelpModal extends BaseModal { | |||||||||||||||||||||||||||||||||||||||||
| </tr> | ||||||||||||||||||||||||||||||||||||||||||
| <tr class="hover:bg-white/5 transition-colors"> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 pl-4 border-b border-white/5"> | ||||||||||||||||||||||||||||||||||||||||||
| <div class="inline-flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.shiftKey)} | ||||||||||||||||||||||||||||||||||||||||||
| <span class="text-white/40 font-bold">+</span> | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-5 h-8 border border-white/40 rounded-full relative" | ||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="absolute top-0 left-0 w-1/2 h-1/2 bg-red-500/80 rounded-tl-full" | ||||||||||||||||||||||||||||||||||||||||||
| ></div> | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-0.5 h-1.5 bg-white/40 rounded-full absolute top-1.5 left-1/2 -translate-x-1/2" | ||||||||||||||||||||||||||||||||||||||||||
| ></div> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.attackModifier)} | ||||||||||||||||||||||||||||||||||||||||||
| </td> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 border-b border-white/5 text-white/70"> | ||||||||||||||||||||||||||||||||||||||||||
| ${translateText("help_modal.action_attack_altclick")} | ||||||||||||||||||||||||||||||||||||||||||
| </td> | ||||||||||||||||||||||||||||||||||||||||||
| </tr> | ||||||||||||||||||||||||||||||||||||||||||
| <tr class="hover:bg-white/5 transition-colors"> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 pl-4 border-b border-white/5"> | ||||||||||||||||||||||||||||||||||||||||||
| <div class="inline-flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.modifierKey)} | ||||||||||||||||||||||||||||||||||||||||||
| <span class="text-white/40 font-bold">+</span> | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-5 h-8 border border-white/40 rounded-full relative" | ||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="absolute top-0 left-0 w-1/2 h-1/2 bg-red-500/80 rounded-tl-full" | ||||||||||||||||||||||||||||||||||||||||||
| ></div> | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-0.5 h-1.5 bg-white/40 rounded-full absolute top-1.5 left-1/2 -translate-x-1/2" | ||||||||||||||||||||||||||||||||||||||||||
| ></div> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.modifierKey)} | ||||||||||||||||||||||||||||||||||||||||||
| </td> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 border-b border-white/5 text-white/70"> | ||||||||||||||||||||||||||||||||||||||||||
| ${translateText("help_modal.action_build")} | ||||||||||||||||||||||||||||||||||||||||||
| </td> | ||||||||||||||||||||||||||||||||||||||||||
| </tr> | ||||||||||||||||||||||||||||||||||||||||||
| <tr class="hover:bg-white/5 transition-colors"> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 pl-4 border-b border-white/5"> | ||||||||||||||||||||||||||||||||||||||||||
| <div class="inline-flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.altKey)} | ||||||||||||||||||||||||||||||||||||||||||
| <span class="text-white/40 font-bold">+</span> | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-5 h-8 border border-white/40 rounded-full relative" | ||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="absolute top-0 left-0 w-1/2 h-1/2 bg-red-500/80 rounded-tl-full" | ||||||||||||||||||||||||||||||||||||||||||
| ></div> | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-0.5 h-1.5 bg-white/40 rounded-full absolute top-1.5 left-1/2 -translate-x-1/2" | ||||||||||||||||||||||||||||||||||||||||||
| ></div> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.altKey)} | ||||||||||||||||||||||||||||||||||||||||||
| </td> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 border-b border-white/5 text-white/70"> | ||||||||||||||||||||||||||||||||||||||||||
| ${translateText("help_modal.action_emote")} | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -381,22 +354,9 @@ export class HelpModal extends BaseModal { | |||||||||||||||||||||||||||||||||||||||||
| </tr> | ||||||||||||||||||||||||||||||||||||||||||
| <tr class="hover:bg-white/5 transition-colors"> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 pl-4 border-b border-white/5"> | ||||||||||||||||||||||||||||||||||||||||||
| <div class="inline-flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.shiftKey)} | ||||||||||||||||||||||||||||||||||||||||||
| <span class="text-white/40 font-bold">+</span> | ||||||||||||||||||||||||||||||||||||||||||
| <div class="flex items-center gap-1"> | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-5 h-8 border border-white/40 rounded-full relative" | ||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-0.5 h-2 bg-red-400 rounded-full absolute top-1.5 left-1/2 -translate-x-1/2" | ||||||||||||||||||||||||||||||||||||||||||
| ></div> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| <div class="flex flex-col text-[10px] text-white/50"> | ||||||||||||||||||||||||||||||||||||||||||
| <span>↑</span> | ||||||||||||||||||||||||||||||||||||||||||
| <span>↓</span> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| <div class="flex flex-wrap gap-2"> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.attackRatioScrollDown)} | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.attackRatioScrollUp)} | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| </td> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 border-b border-white/5 text-white/70"> | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -406,8 +366,6 @@ export class HelpModal extends BaseModal { | |||||||||||||||||||||||||||||||||||||||||
| <tr class="hover:bg-white/5 transition-colors"> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 pl-4 border-b border-white/5"> | ||||||||||||||||||||||||||||||||||||||||||
| <div class="inline-flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.altKey)} | ||||||||||||||||||||||||||||||||||||||||||
| <span class="text-white/40 font-bold">+</span> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.resetGfx)} | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| </td> | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -417,13 +375,7 @@ export class HelpModal extends BaseModal { | |||||||||||||||||||||||||||||||||||||||||
| </tr> | ||||||||||||||||||||||||||||||||||||||||||
| <tr class="hover:bg-white/5 transition-colors"> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 pl-4 border-b border-white/5"> | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-5 h-8 border border-white/40 rounded-full relative" | ||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| class="w-0.5 h-2 bg-red-400 rounded-full absolute top-1.5 left-1/2 -translate-x-1/2" | ||||||||||||||||||||||||||||||||||||||||||
| ></div> | ||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||
| ${this.renderKey(keybinds.autoUpgrade)} | ||||||||||||||||||||||||||||||||||||||||||
| </td> | ||||||||||||||||||||||||||||||||||||||||||
| <td class="py-3 border-b border-white/5 text-white/70"> | ||||||||||||||||||||||||||||||||||||||||||
| ${translateText("help_modal.action_auto_upgrade")} | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.