Repository navigation
Reimplement 5 UI::MenuItems editor and building menu renders at 100% - #346
Merged
Merged
Conversation
MenuItemRenderFunction_DisableWeapon_Main, rebuilt from the original; gynt's draft on the fork branch reimpl/UI-MenuItems-development (59.1% there) is Ghidra's output with gotos and behaves the same. Buttons 0 to 7 draw their button and, for weapons 0 to 5 only while they cannot be made, the disabled icon (GID_INTERFACE_ICONS_2, picture 45); button 1 moves down a pixel while hovered with its icon held in place. -3 is "Exit". The menu only has buttons 0 to 5 and -3, so 6 and 7 of the original's 0..7 range never occur. Shape: each weapon case breaks to the icon when its Producible flag (only ever 0 or 1) is clear and returns otherwise (the return first: quick_diff 0.8889 -> 0.7527), with an explicit `default: break;` (without it: 0.8673); one unsigned test for 0..7 (`button >= 0 && button <= 7`, `< 8`, `!(x < 0 || x > 7)` or `0 <= x`: 0.8673, reccmp 100.0% -> 90.0%) guarding the weapon block rather than an early return (0.8673), with iconOffsetY zeroed before it, as the Exit block reuses that zero (inside the if: 0.7273); the X shift after the switch as `if (button != 0)`; the Exit text's position worked out in each branch, y then x, as in SaveLoadMap's Buttons render on main (once, before the test: 0.8889 -> 0.8788); one call per colour (one call with a colour local: 0.8889 -> 0.7839). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_EditScenario_UpDownButtons, rebuilt from the original; gynt's draft on the fork branch reimpl/UI-MenuItems (66.7% there, the same on -development and -100) had no return after the text and no else for the arrows. Fixed against the draft (the code follows the original): - buttons from 0 up draw their scenario text and return; the draft then drew the down arrow (renderUpDownButtonUnk(1, 0)) as well; - -1 draws only the up arrow (0) and the other negative buttons the down arrow (1); the draft drew both for -1. The colours are COL_00A2FF on COL_003E66, or COL_FFFFFF on COL_000000 while hovered. Shape: the text position worked out in each branch, y then x (once, before the test: quick_diff 0.9231 -> 0.9038); one call per colour pair (one call with colour locals: 0.9231 -> 0.5455; with two ternaries: 0.5766). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_EditScenario_StartDateMonth, from gynt's draft on the fork branch reimpl/UI-MenuItems (59.4% there), in main's namespace form with the ColorsEnum names. TEXT_MONTHS 12 to 23 are the full month names. Shape: the position and the month's text number worked out in each branch, y, x, then the month (once, before the test: quick_diff 0.9062 -> 0.8438; month first: 0.6970; between y and x: 0.7576; the month in the call: 0.6857); one call per colour (one call with a colour local: 0.9062 -> 0.5373; the draft's ternary compiles branch-free). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_BuildingAndStatusMenu_OutpostUnitSelection, from gynt's draft on the fork branch reimpl/UI-MenuItems (76.8% there), in main's namespace form: the parameter named bitIndex, as main's action handler for the same buttons (0x00466710) names it; the unit bit as a plain shift; the text number as the outpost's text offset + 1 + bitIndex (TEXT_IN_OUTPOST: each outpost's title, then its units, the Arabian ones from 9); the pressed state as an if/else per arm; and the colours by their ColorsEnum names: COL_C2F0EB on COL_003E66, COL_CCFAFF on COL_000000 while hovered. Shape: the pressed test and the draw in each branch, as the binary has them twice (once, before the hover test: quick_diff 0.9206 -> 0.5854); the text position worked out in each branch, y then x (in the calls: 0.9206 -> 0.8730); one call per colour pair (one call with colour locals: 0.9206 -> 0.4615). quick_diff still shows `test eax, edx` where the binary has `test edx, eax`; reccmp, which compares the linked code, has no difference there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_BuildingAvailability_TableRows, from gynt's draft on the fork branch reimpl/UI-MenuItems-development (63.5% there), in main's namespace form with the colours by their ColorsEnum names (COL_CCFAFF hovered, COL_7F7F7F for a building that is not available, COL_C2F0EB otherwise); the availability flag (only ever 0 or 1) is tested for truth, and buildingIndex is the row's index into the building tables. Shape: one call per colour, which MSVC merges after the colour push as the binary does (one call with a colour local, or a ternary in the call, compiles branch-free: quick_diff 0.9048 -> 0.5882); the text position and the name number worked out in each branch, y, x, then the name (the position once, before the test: 0.7857; x first: 0.8095; the name once, before the test: 0.7381; the name first: 0.7045; the name in the call: 0.5208). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 6, 2026
This was referenced Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Five UI::MenuItems render functions at 100%, each with its status line: the weapon-disabling screen and two scenario editor controls (the up/down buttons and the start month), the outpost's unit buttons and the rows of the building availability table.
All five continue gynt's drafts on his fork (
reimpl/UI-MenuItemsand-development). Every commit body says what changed against the draft and why. No header changes.Other PRs: the ready #342, #343 (the fix for main's 15 files), #344 and #345, and the drafts #313, #318, #321, #327 and #328.
Built on top of
main(57d3334) with the bundled MSVC1400-SP1, natively on Windows, against the SteamStronghold Crusader.exe(3bb0a8c1…5387ac5a). The branch was built and measured on its own, with the struct and function resolvers enabled locally (not committed), using sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie. None of it has been run in game.It went through the same checks as #344: a fresh-eyes review of every file (behaviour checked against the original's disassembly, texts against cr.tex; its points applied and measured),
openshc-pr-check, andstatus_regression.py, which finds nothing below a known score on main or any fork.Behaviour fixed compared with the draft
elsefor the arrows. Buttons from 0 up now draw their text and return, where the draft also drew the down arrow (renderUpDownButtonUnk(1, 0)) after it; -1 now draws only the up arrow, where the draft drew both; other negatives (-2) draw the down arrow.The other four do what their drafts did, which matches the original.
MenuItemRenderFunction_DisableWeapon_MainMenuItemRenderFunction_EditScenario_UpDownButtonsTEXT_SCENARIO[button]).MenuItemRenderFunction_EditScenario_StartDateMonthMenuItemRenderFunction_BuildingAndStatusMenu_OutpostUnitSelectionbitIndex, as main's handler for the same buttons (0x00466710) names it.MenuItemRenderFunction_BuildingAvailability_TableRowsKept as they are, and why
Each was measured; a one-line comment in the code says why. Most of these are the per-branch shape: MSVC hoists or merges the code each branch writes out the way the original has it.
(uint)button <= 7, the original's unsigned compare (button >= 0 && button <= 7,< 8,!(button < 0 || button > 7)and0 <= buttonall measure reccmp 100.0% -> 90.0%: MSVC then merges one of the returns);if, not an early return (early return: quick_diff 0.8889 -> 0.8673);iconOffsetYdeclared before the test, because the Exit block reuses its zero (inside theif: 0.8889 -> 0.7273);default: break;(without it: 0.8889 -> 0.8673);Proposed, not changed here
Building::outpostRelatedUnk1(a short) is the outpost's selected-units mask: bit i is unit i of TEXT_IN_OUTPOST, the action handler 0x00466710 toggles it, and 0x00466620 shows the button pressed while the bit is set. Something likeoutpostSelectedUnitsMask?PencilRenderCore::renderUpDownButtonUnk(int isDownButtonUnk, ...): confirmed, 0 is the up arrow (it scrolls up in 0x004B9020 and SaveLoadMap) and 1 the down arrow, so the first parameter could beBOOLEnum isDownButton.MenuItemRenderFunction_EditScenario_UpDownButtonsalso draws the editor's text buttons, so the name is narrower than what it does.🤖 Generated with Claude Code