1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

inject KeybindingsState into SettingsState

This commit is contained in:
Dimava 2020-08-06 20:36:58 +03:00
parent 79158e2b56
commit 59d849debc
6 changed files with 40 additions and 19 deletions

View File

@ -1,4 +1,4 @@
#state_KeybindingsState { #state_SettingsState {
.content { .content {
.topEntries { .topEntries {
display: grid; display: grid;
@ -14,7 +14,7 @@
@include PlainText; @include PlainText;
} }
.category { .keyCategory {
.entry { .entry {
display: grid; display: grid;
@include S(margin-top, 2px); @include S(margin-top, 2px);

View File

@ -145,7 +145,7 @@ export class Application {
MobileWarningState, MobileWarningState,
MainMenuState, MainMenuState,
InGameState, InGameState,
SettingsState, // SettingsState,
KeybindingsState, KeybindingsState,
AboutState, AboutState,
ChangelogState, ChangelogState,

View File

@ -20,6 +20,7 @@ export const enumCategories = {
general: "general", general: "general",
userInterface: "userInterface", userInterface: "userInterface",
advanced: "advanced", advanced: "advanced",
keybindings: "keybindings",
}; };
export const uiScales = [ export const uiScales = [

View File

@ -4,39 +4,56 @@ import { T } from "../translations";
import { KEYMAPPINGS, getStringForKeyCode } from "../game/key_action_mapper"; import { KEYMAPPINGS, getStringForKeyCode } from "../game/key_action_mapper";
import { Dialog } from "../core/modal_dialog_elements"; import { Dialog } from "../core/modal_dialog_elements";
import { IS_DEMO } from "../core/config"; import { IS_DEMO } from "../core/config";
import { SettingsState } from "./settings";
export class KeybindingsState extends TextualGameState { export class KeybindingsState extends SettingsState {
constructor() { // constructor() {
super("KeybindingsState"); // super("KeybindingsState");
} // }
getStateHeaderTitle() { // getStateHeaderTitle() {
return T.keybindings.title; // return T.keybindings.title;
} // }
getMainContentHTML() { getMainContentHTML() {
return ` return `
<div class="sidebar">
${this.getCategoryButtonsHtml()}
<div class="topEntries"> <div class="other">
<span class="hint">${T.keybindings.hint}</span> <button class="styledButton about">${T.about.title}</button>
<button class="styledButton resetBindings">${T.keybindings.resetKeybindings}</button>
<div class="versionbar">
<div class="buildVersion">${T.global.loading} ...</div>
</div>
</div>
</div> </div>
<div class="keybindings"> <div class="categoryContainer">
<div class="category keybindings" data-category="keybindings">
<div class="topEntries">
<span class="hint">${T.keybindings.hint}</span>
<button class="styledButton resetBindings">${T.keybindings.resetKeybindings}</button>
</div>
</div>
${this.getSettingsHtml()}
</div> </div>
`; `;
} }
onEnter() { onEnter() {
super.onEnter();
const keybindingsElem = this.htmlElement.querySelector(".keybindings"); const keybindingsElem = this.htmlElement.querySelector(".keybindings");
this.trackClicks(this.htmlElement.querySelector(".resetBindings"), this.resetBindings); this.trackClicks(this.htmlElement.querySelector(".resetBindings"), this.resetBindings);
for (const category in KEYMAPPINGS) { for (const category in KEYMAPPINGS) {
const categoryDiv = document.createElement("div"); const categoryDiv = document.createElement("div");
categoryDiv.classList.add("category"); categoryDiv.classList.add("keyCategory");
keybindingsElem.appendChild(categoryDiv); keybindingsElem.appendChild(categoryDiv);
const labelDiv = document.createElement("strong"); const labelDiv = document.createElement("strong");
@ -173,7 +190,7 @@ export class KeybindingsState extends TextualGameState {
}); });
} }
getDefaultPreviousState() { // getDefaultPreviousState() {
return "SettingsState"; // return "SettingsState";
} // }
} }

View File

@ -109,6 +109,8 @@ export class SettingsState extends TextualGameState {
this.htmlElement.querySelector(".category").classList.add("active"); this.htmlElement.querySelector(".category").classList.add("active");
this.htmlElement.querySelector(".categoryButton").classList.add("active"); this.htmlElement.querySelector(".categoryButton").classList.add("active");
this.setActiveCategory(enumCategories.general);
} }
setActiveCategory(category) { setActiveCategory(category) {

View File

@ -650,6 +650,7 @@ settings:
general: General general: General
userInterface: User Interface userInterface: User Interface
advanced: Advanced advanced: Advanced
keybindings: Keybindings
versionBadges: versionBadges:
dev: Development dev: Development