7ee04c78cd
The old UI system (X-macro static element list, hand-authored C screens/widgets/focus stack) is archived under archive/ rather than deleted, since it's a useful reference during the rewrite. New native UI element pool (src/dusk/ui): a flat UI_ELEMENTS[128] pool of tagged-union elements (Label, Rectangle, Scripted), a real persistent parent/child tree (children[8] per element, cycle- and capacity-checked uiElementSetParent), always-fresh worldX/worldY (cheap enough to recompute on every read, no dirty-flag cache needed), and cascading dispose. Rendering stays manual/immediate: a scripted element with no render() override auto-renders its children by default, but overriding render() takes full control (an override must call renderChildren() itself to opt back in) -- this is deliberately preserved end to end via a render()-shadow trampoline so overriding render() always keeps working the same way regardless of how a node is reached. New scripting layer (src/dusk/script/module/ui): UIElement/Label/ Rectangle JS classes (Label/Rectangle share UIElement's prototype via manual chaining, not JS `extends`), exposing x/y/worldX/worldY/parent/ add()/remove()/render()/renderChildren()/dispose(). UI.add()/ UI.remove() manage top-level render roots, mutually exclusive with being someone's child. Also: Scene gains a lateUpdate() hook (called once per frame after every other update, for things like camera-follow that need to react to where everything else ended up); several duskrpg call sites (cutscene items, entityinteractable, entityplayer) that depended on the now-archived RPG textbox are stubbed to console output instead of a dialogue box, pending the new UI reaching that far. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
68 lines
1.9 KiB
C
68 lines
1.9 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "error/error.h"
|
|
#include "ui/widget/uimenu.h"
|
|
|
|
#define UI_SETTINGS_GENERAL_ITEM_COUNT 3
|
|
#define UI_SETTINGS_GENERAL_INDEX_LANGUAGE 0
|
|
#define UI_SETTINGS_GENERAL_INDEX_LANGUAGE_DETAIL 1
|
|
#define UI_SETTINGS_GENERAL_INDEX_APPLY 2
|
|
#define UI_SETTINGS_GENERAL_LOCALE_COUNT 3
|
|
#define UI_SETTINGS_GENERAL_LABEL_MAX 32
|
|
#define UI_SETTINGS_GENERAL_INFO_MAX 64
|
|
|
|
typedef struct {
|
|
uimenu_t menu;
|
|
uimenuitem_t items[UI_SETTINGS_GENERAL_ITEM_COUNT];
|
|
const char_t *localeNames[UI_SETTINGS_GENERAL_LOCALE_COUNT];
|
|
char_t languageLabel[UI_SETTINGS_GENERAL_LABEL_MAX];
|
|
char_t labelInfo[UI_SETTINGS_GENERAL_INFO_MAX];
|
|
} uisettingsgeneral_t;
|
|
|
|
#define UI_SETTINGS_INPUT_ITEM_COUNT 2
|
|
#define UI_SETTINGS_INPUT_LABEL_MAX 32
|
|
#define UI_SETTINGS_INPUT_INDEX_DEADZONE 0
|
|
#define UI_SETTINGS_INPUT_INDEX_APPLY 1
|
|
|
|
typedef struct {
|
|
uimenu_t menu;
|
|
uimenuitem_t items[UI_SETTINGS_INPUT_ITEM_COUNT];
|
|
char_t deadzoneLabel[UI_SETTINGS_INPUT_LABEL_MAX];
|
|
} uisettingsinput_t;
|
|
|
|
#define UI_SETTINGS_DISPLAY_ITEM_COUNT 2
|
|
#define UI_SETTINGS_DISPLAY_INDEX_APPLY 1
|
|
|
|
typedef struct {
|
|
uimenu_t menu;
|
|
uimenuitem_t items[UI_SETTINGS_DISPLAY_ITEM_COUNT];
|
|
} uisettingsdisplay_t;
|
|
|
|
#define UI_SETTINGS_AUDIO_ITEM_COUNT 2
|
|
#define UI_SETTINGS_AUDIO_INDEX_APPLY 1
|
|
|
|
typedef struct {
|
|
uimenu_t menu;
|
|
uimenuitem_t items[UI_SETTINGS_AUDIO_ITEM_COUNT];
|
|
} uisettingsaudio_t;
|
|
|
|
/**
|
|
* Shared, overlapping storage for every settings tab's page data. Only
|
|
* one member is ever live at a time -- the active tab's Init writes
|
|
* into it, overwriting whatever the previously active tab left there.
|
|
* This trades simultaneous access to every tab for a memory footprint
|
|
* of only the single largest page.
|
|
*/
|
|
typedef union {
|
|
uisettingsgeneral_t general;
|
|
uisettingsinput_t input;
|
|
uisettingsdisplay_t display;
|
|
uisettingsaudio_t audio;
|
|
} uisettingsdata_t;
|