The Insert menu as a model: settings described once, modules place their own rows, the ImGui menu one presenter #1633
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot#1633
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: refactor · Area: the Insert menu (
gpu/vk/vk_menu.cpp), settings, translations · Related: #1493TL;DR
Every setting, page and one-off widget of the Insert menu lives in one 6,800-line file, and its behaviour is found by pointer and by name all over it, so nearly every feature that adds a row edits that file. This proposes a menu model with no ImGui in it: each setting described once with its own hooks, each module registering its own rows and saying where they go, an order worked out from those wishes, and the ImGui menu as one presenter of the model. The same model could later be shown inside the game's own menu.
Breakdown
longshot_options.iniholds, at every step.vk_menu.cppby its text and have to move with it.Evidence
Read at
mainc507b98c.mainchangedvk_menu.cpp, and only about a third werefeat(menu)orfix(menu): the rest were features fromvk,inputandaudiothat needed a row. Five open PRs add to it now (#1616, #1585, #1629, #1411, #1426), and 89 checks reference it.rows[]table (about 130 rows) holds a row's tab, label, value, range, text and help. Most of what a row does is decided elsewhere, by about 70 checks of the formr.value == &opts.xand 13strcmp(r.name, "..."): inrow_shown,is_slider,stops_at_ends, the locked rows, the step and apply code,ini_key, and the button rows (NFC, Motion, FPS counter details, the laptop setup, the microphone). One row's behaviour can be in six places.TAB_MOTION,TAB_FPS_DEVandTAB_PAGE, numbered pastTAB_COUNT, mapped back to their parent tab by hand.ini_keylowercases the row's name unless the row is listed there by hand, so renaming a row renames its setting inlongshot_options.iniand loses the player's value.menu_i18n.hholds 14 languages as{English, translation}pairs;ui::text,ui::para,ui::size_ofandui::spacedlook every string up as it is drawn. Editing a row's English drops its translations until every table follows; another presenter would have to calltr()itself.HOS_OPT_*id throught.optioninvk_replay.cpp, a chain apart from the rows.Proposed change
A model with no ImGui or Vulkan in it, which the ImGui menu presents, and which the game's menu could present later.
A module configures itself in its own file and says where its rows go; nothing in the menu's code names it:
Order: collect, then sort. Every module registers at start-up; the menu then works the order out once:
order(300)); the core's get round numbers with gaps, so a new section lands predictably without naming its neighbours.after(key)andbefore(key)are edges of a graph, sorted topologically;first()andlast()are fixed ends;at(n)is a soft hint.place(key, page, after(...))), so a layout decision is made in one place.Presenters read a snapshot.
menu::snapshot(page)gives the page's items already filtered and translated (label, value text, hint, kind, locked);menu::input(page, index, action)takes Up/Down/Left/Right/Activate/Back. The ImGui menu becomes a loop over it plus the custom items'draw; the game's menu would be another loop over the same call.Text gets a stable id per string. The first step keeps the English text as the id, so the 7,800 lines of tables do not move; separate ids can come later if wording changes get common.
Steps, each with nothing visible changed and its checks updated in the same PR:
step_fnandon_change;t.optionfromhost_option.Custom, then features' rows moved into their own modules.How we would test it
longshot_options.inicompared before and after.Related
Searched all issues and pull requests, open and closed, for: menu builder, vk_menu split, menu refactor, menu rows, row table, settings registry, menu declarative. None proposes this.
Possibly related, for context: