From 0b50b26445d9865f29a01027872792b33591a6a1 Mon Sep 17 00:00:00 2001 From: David Malchin Date: Tue, 10 Sep 2024 21:23:00 +0300 Subject: [PATCH] Refactor dev menu to be runtime generated --- CHANGELOG.md | 1 + html/assets/icons/arrow_back.svg | 1 + html/dev.css | 113 ++++---- html/index.html | 409 +++------------------------- html/js/config/generator.js | 70 ----- html/js/config/index.js | 2 - html/js/config/style.js | 35 ++- html/js/dev/elements/config.js | 90 ------ html/js/dev/elements/events.js | 102 ------- html/js/dev/elements/menu.js | 9 - html/js/dev/elements/variables.js | 6 - html/js/dev/event-handlers.js | 128 +++++++++ html/js/dev/events/custom-events.js | 6 + html/js/dev/events/events.js | 144 ++++++++++ html/js/dev/handlers/config.js | 209 -------------- html/js/dev/handlers/events.js | 172 ------------ html/js/dev/handlers/index.js | 84 ------ html/js/dev/handlers/variables.js | 22 -- html/js/dev/index.js | 71 ++++- html/js/dev/value-handlers.js | 122 +++++++++ html/js/util/elements.js | 43 +++ 21 files changed, 635 insertions(+), 1204 deletions(-) create mode 100644 html/assets/icons/arrow_back.svg delete mode 100644 html/js/config/generator.js delete mode 100644 html/js/dev/elements/config.js delete mode 100644 html/js/dev/elements/events.js delete mode 100644 html/js/dev/elements/menu.js delete mode 100644 html/js/dev/elements/variables.js create mode 100644 html/js/dev/event-handlers.js create mode 100644 html/js/dev/events/custom-events.js create mode 100644 html/js/dev/events/events.js delete mode 100644 html/js/dev/handlers/config.js delete mode 100644 html/js/dev/handlers/events.js delete mode 100644 html/js/dev/handlers/index.js delete mode 100644 html/js/dev/handlers/variables.js create mode 100644 html/js/dev/value-handlers.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dbc2fc..6166605 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Removed some lines of code that don't do anything. - Moved the audio controls to the bottom center to avoid conflicts with the`Loading game` prompt in different resolutions. - Slightly increased the audio volume slider in width. +- Refactored the dev menu to be generated on runtime. ### Fixed diff --git a/html/assets/icons/arrow_back.svg b/html/assets/icons/arrow_back.svg new file mode 100644 index 0000000..16aa612 --- /dev/null +++ b/html/assets/icons/arrow_back.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/html/dev.css b/html/dev.css index c8babd8..e2aef2b 100644 --- a/html/dev.css +++ b/html/dev.css @@ -5,18 +5,28 @@ background-color: black !important; } -#dev-menu h3 { - padding-top: 1rem; -} +#dev-menu { + position: fixed; + right: 1rem; + top: 1rem; + overflow-y: scroll; -#dev-menu h3::before { - content: ''; - position: absolute; - left: 0; - transform: translateY(-1rem); - width: 100%; - height: 1rem; - border-top: 1px solid var(--secondary-color); + width: 18rem; + height: calc(100vh - 4rem); + padding: 1rem; + + display: flex; + flex-direction: column; + gap: 2rem; + + background-color: black; + color: whitesmoke; + border: 1px solid var(--secondary-color); + border-radius: var(--border-round); + + transition: + right 0.5s ease-in-out, + var(--hover-transition); } #dev-open, @@ -74,69 +84,62 @@ appearance: none; } -#dev-menu { - position: fixed; - right: 1rem; - top: 1rem; - overflow-y: scroll; - - width: 18rem; - height: calc(100vh - 4rem); - padding: 1rem; - +#dev-options, +#dev-cfg-wrapper, +#dev-section, +.dev-value { display: flex; flex-direction: column; - gap: 1rem; - - background-color: black; - color: whitesmoke; - border: 1px solid var(--secondary-color); - border-radius: var(--border-round); - - transition: - right 0.5s ease-in-out, - var(--hover-transition); + gap: 2rem; } -#dev-menu > header { - width: 100%; +#dev-section { + gap: 1rem; + overflow-y: scroll; + min-height: 10rem; } -#dev-menu .col { - display: flex; - flex-direction: column; +#dev-cfg-wrapper, +.dev-value { gap: 0.25rem; } -#dev-menu .row { +#dev-menu > header, +#dev-options > div { display: flex; align-items: center; justify-content: space-between; - gap: 0.25rem; } -#dev-menu .grow { - flex-grow: 1; +#dev-options > div > * { + opacity: 0.75; + transition: var(--hover-transition); } -#dev-menu .icon { - width: 2.1rem; - height: 2.1rem; - background-color: transparent; - color: white; - padding: 0.5rem; - transition: var(--hover-transition); +#dev-options > div:hover > * { + opacity: 1; +} - border: 1px solid var(--secondary-color); - border-radius: var(--border-round); +#dev-options > div:hover { + cursor: pointer; +} + +#dev-menu > header::after { + height: 0.5rem; } -#dev-menu .icon img { +#dev-menu > header::after, +#dev-options > div::after { + opacity: 1.25 !important; + content: ''; + position: absolute; + left: 0; width: 100%; - height: 100%; + transform: translateY(1.8rem); + border-bottom: 1px solid var(--secondary-color); } -#dev-menu .event { +.dev-event { padding: 0.75rem; display: flex; @@ -146,3 +149,9 @@ border: 1px solid var(--secondary-color); border-radius: var(--border-round); } + +.dev-event > div { + display: flex; + flex-direction: column; + gap: 0.25rem; +} diff --git a/html/index.html b/html/index.html index d31d800..c4f1780 100644 --- a/html/index.html +++ b/html/index.html @@ -86,23 +86,36 @@