Files
jakub d5464f7438
continuous-integration/drone/push Build is passing
Reorganize mission menu and separate design from logic
2026-10-17 18:27:31 +02:00

75 lines
4.0 KiB
Markdown

# Editing the mission menu
The menu has main sections across the top and a sidebar for each section's pages.
Design sources live here; the game loads the generated native layouts in
`addons/core/UI/layouts/ERR`. Their existing resource GUIDs stay unchanged.
| Change | Edit |
| --- | --- |
| Colors, font, text sizes, button state colors | `theme.json` |
| Main sections, sidebar grouping, order and labels | `navigation.json` |
| A page's controls, wording and spacing | `pages/<PageName>.layout.in` |
| Window, title, connection line and feedback area | `shell.layout.in` |
| Repeated item/mod rows and value controls | `components/*.layout.in` |
| Which layout resources are built | `layouts.json` |
After editing, run from the repository root:
```sh
python3 tools/build_admin_menu.py
python3 tools/build_admin_menu.py --check
python3 -m unittest discover -s tests -p test_admin_menu_sources.py
python3 tests/test_admin_menu.py
```
Commit both the design sources and generated files. Workbench can open the
generated `.layout` resources for inspection. Make lasting edits in these sources:
the builder replaces generated output. `tools/check.py` and Drone reject stale
output, missing includes, invalid colors and broken navigation membership.
The generated layout initially shows only Mission / General, its sidebar and
its selection indicators, so opening it in Workbench does not stack every page.
The builder supplies each page's `{{VISIBLE_<PageWidgetName>}}` token from its
stable navigation key. Runtime navigation overrides these initial visibility
values. To inspect another page in the layout editor, hide `SettingsPage` and
`Sidebar_Mission`, then enable **Is Visible** on the desired page and sidebar.
Do not save these temporary preview changes over the generated layout.
Theme tokens use `{{COLOR_TEXT}}`, `{{SIZE_BODY}}`, and `{{FONT}}`. Colors in native
layouts are four RGBA numbers from 0 to 1. Runtime button colors use eight-digit
ARGB hex values. Includes use `{{include:pages/SettingsPage.layout.in}}` and resolve
relative to this directory. Includes cannot escape this directory or form cycles.
Keep page IDs stable in `navigation.json`: existing scripts and native tests use
them. Reorder a group's `pages` list to reorder its sidebar; reorder `groups` to
reorder main tabs. Each page belongs to exactly one group, whose first page opens
when its main tab is clicked. The shell currently accommodates up to eight main
sections and eight sidebar entries per section. Navigation button geometry lives
in the presentation builder's `navigation()` function; page geometry stays in its
layout fragment. Main tabs occupy the top strip; sidebar controls stay left of
the full-width content area.
To add a page, append a stable ID/key/widget/button/label entry, add its key to a
group, create its page fragment, and include it in the shell. Give controls unique
widget names. Changing a widget name also requires updating its code bindings.
## Where behavior lives
All script paths below are under `addons/core/Scripts/Game/ERR/00_Core/`.
| Responsibility | File |
| --- | --- |
| Field keys, display formatting, capability gates, command mapping | `ERR_AdminMenuFields.c` |
| Page IDs and navigation data (generated) | `ERR_AdminMenuPages.c` |
| Page/sidebar visibility and selected navigation | `ERR_AdminMenuView.c` |
| Runtime palette (generated) | `ERR_MenuTheme.c` |
| Selected/action/status button styling | `ERR_SelectionStyle.c` |
| Dialog lifetime, polling, drafts, snapshots and command submission | `ERR_AdminMenu.c` |
| Item, terrain, faction, speech and backpack behavior | Their existing `*Menu.c` modules |
| Authorization, validation and persistence | `ERR_AdminSession.c`, `ERR_AdminService.c`, `ERR_Settings.c` |
Use `ERR_AdminPage.SARKA` or another named page when linking from code. Visual
changes do not belong in settings persistence or mission gameplay services.
An editable field still needs an authorized command and validated setting; a new
layout control alone does not grant permission or create a setting.