Repository navigation
Reimplement 5 UI menu-item engine functions from gynt's drafts (100%) - #383
Merged
Merged
Conversation
BottomLeftTextDisplayState::setBottomLeftTextDisplayText, from gynt's draft (4320604, 35.93%, and c7ba75f, 32.7%, in his closed sourcehold#256; restyled up to cf563c2 on his fork's archive/UI-MenuViews-development-second-pass and in 10280b1 on reimpl/UI-Core-development), rewritten from the binary: a message type of 0 clears the text and returns, a less important text returns early (the draft's check was empty), the countdown restarts unless the same text is shown again, and a duration of -1 stores 0 and skips timeGetTime. The parameter stays main's int param_4 (the draft used the union); it is compared with and stored as the union's buildingType. The lookup loop's index is set before the message type (declared in the for it measures lower; the numbers are in the PR text), and the sound is s_placement_warning1_wav_005ab8f4 rather than a string literal. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a BOOLEnum The original pushes it as a 4-byte value: prepareAndRenderMenuItems (0x004F49D0, next commit) keeps the flag in a stack slot (mov dword ptr [esp + 8], 1 at 0x004F4BB4) and pushes it with mov ecx, dword ptr [esp + 8] / push ecx, where a bool parameter makes MSVC compare and setne first. MenuItemRenderFunction_0x20, the same callback in Ghidra's other copy, already has BOOLEnum there. SliderRenderFunction is only used by MenuItemRenderFunctionUnion's slider member, so nothing else changes. With it prepareAndRenderMenuItems is at reccmp 100.0%. Main's six slider render functions take BOOL isDragged (five of them) or BOOLEnum (NewInvasion_RepeatSlider). ScrollbarRenderFunction, the union's scrollbar member, gets the same type: every scrollbar render function on main takes BOOLEnum isDragged. The scrollbar items are drawn through the slider member, and no .cpp uses the scrollbar member. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItem::prepareAndRenderMenuItems, from gynt's draft (ab38baa, 59.83%, and 95757c6, 59.8%, in his closed sourcehold#256; restyled up to 71eb42a on his fork's archive/UI-MenuViews-development-second-pass and in 10280b1 on reimpl/UI-Core-development), with these changes from the binary. While the build menu slides, an item outside the menu area, or any item between 45 and 55 percent of the slide, returns without being drawn (the draft only zeroed the blend strength there). The slider's clamp is written on its fields, the flag it passes is a BOOLEnum that starts FALSE next to the thumb position (the previous commit makes the callback take it), and the range is written out at each use (a local measures lower; the numbers are in the PR text). The picture's first index is main's GMFirstPictureIndex (the draft's GMTotalPicturesProcessed isn't on main), and the gmDataIndex mask is a named local. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Menu::handleMenuItems, from gynt's draft (b7ae11d, 14.41%, the ActiveMenuTab compare, 7672ad2, 14.4%, and 2e7d6fd, 19.8%, the infinite loop fixed, in his closed sourcehold#256; 20.8% in 10280b1 on his fork's reimpl/UI-Core-development), rewritten from the binary as one for-loop over the items up to MIT_LAST_ENTRY with an if/else chain on the item type. The draft's empty ifs are the returns the original has: on the current tab's stop item, on MIT_STOP_HANDLING, during a build-menu slide while handling input, while a modal dialog is open, and when an item's input callback asks to stop. The build-menu shift toggles between 0 and buildMenuItemsLeftShift_0x28, and the switch sends both render passes to prepareAndRenderMenuItems. The item types and flags MenuItemType doesn't name are local constants written as the bits they set, and the sign bit is tested with & (>= 0 measures lower; the numbers are in the PR text). reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Menu::Constructor_Menu, from gynt's draft (8a20e11, 21.49%, and b357877, 21.5%, in his closed sourcehold#256; restyled up to 71eb42a on his fork's archive/UI-MenuViews-development-second-pass and in 10280b1 on reimpl/UI-Core-development), rewritten from the binary as one for-loop over the items: each item gets its menu pointer, its UC index (or -1) and a cleared unknownZero; a tab counts its items up to the next tab, the end or past a stop item; an interaction group hands its callbacks to members that have none, then does the same for each option that follows it and marks itself an option group; and the item before a run of alternatives is flagged as its head. The draft walked the items through a pointer offset by the position field (+4), reached ucIndex_0x4 through a cast, and counted the members with GmDataIndex values; the counts are ints in itemsToSkip here. The flags MenuItemType doesn't name are local constants written as the bits they set, as in handleMenuItems (0x004F6280, previous commit). reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Menu::renderConstructionMenu, from gynt's draft (65e9021, 63.31%, and 1791e0a, 62.7%, in his closed sourcehold#256; 64.0% in 10280b1 on his fork's reimpl/UI-Core-development, names in 7069ca9), rewritten from the binary. The hovered item's text index is looked up in TextMessageLookupTable, and the message type is one switch: 0 returns, twelve types show the text bottom-left with setBottomLeftTextDisplayText (most of them only with bubble help on) and each clears zero and returns on its own, as the original does (with a break to one shared store: quick_diff 0.9559 -> 0.8475, as 0 no longer gets a register), and every other type shows the tooltip once the mouse has rested on the item for 200 ms. The index is the dword's low word, read whole and masked as handleMenuElementsCallbacks does on gynt's branch (*(int*)&this->textMessageLookupIndex); the ushort field_0x0 loads a word (the numbers are in the PR text). Tab, view and message types are main's enum names where it has them (types 7 to 13 have none), and the tooltip's colour is COL_C2F0EB. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 7 to 13 Menu::renderConstructionMenu (0x004F64A0) switches on TextMessageLookupTable[index].messageType with cases for 0 (it returns at once) and for 7 to 13 besides the five named types, and matches at reccmp 100.0 with them; each of the cases for 7 to 13 passes its own number on to setBottomLeftTextDisplayText as its message type. The enum has no names for them, so they get <PREFIX>_UNKNOWN_<n> (TheRedDaemon's ask on sourcehold#300); setBottomLeftTextDisplayText starts its lookup type at 0. Used in the next commits; code generation is the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…TypeUnk BottomLeftTextDisplayState::setBottomLeftTextDisplayText (0x004F4E00) compares its fourth parameter with TextMessageLookupTable[i].associatedType.buildingType and stores it in currentlyDisplayedUnktextExtraObject, so it is the associated type of the text (a building, button or unit type, after TextMessageBLLookupStruct's union); param_4 becomes associatedTypeUnk, as the definition calls it from the next commit on. Only the name changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…MenuItems - prepareAndRenderMenuItems' slider branch reads secondItemTypeData.scrollbarOrSliderState (minValue, maxValue, currentValue, dragTiming), main's names for the same four ints, where it read them through buttonState; the GM image line stays on buttonState. isDragged/thumbPos/thumbLength after main's render-function parameters, the set-up call's 1 commented, no (BOOLEnum) cast on clicked | hovering. - renderConstructionMenu: TMBLLSTE_UNKNOWN_0 and 7 to 13 (previous commits) for the case labels, the union's buttonText and unitsAndWeaponsType for those two cases, TEXT_BUBBLE_HELP_TEXT and TEXT_GAME_OPTIONS for 8 and 74, and one line above the switch on why each case stores and returns. - handleMenuItems: the sign bit as hiddenFlag, `continue` for hidden items and for items that aren't handled now (one level of nesting instead of three), parentheses around each && pair, no cast on the click handler, and `alternative` for the loop over alternatives. - Constructor_Menu: the item before a run of alternatives is marked as its head (the old comment had it the other way round), and the unused UserControlID include goes. - setBottomLeftTextDisplayText: associatedTypeUnk (previous commit), TEXT_PANEL_FEEDBACK and BFRE_NOT_ENOUGH_WORKERS for 77 and 1, TMBLLSTE_UNKNOWN_0, and MappersEnum's include and using go (they come with TextMessageBLLookupStructUnion.hpp). - The comments keep only the reasons; the quick_diff numbers go to the PR text. Kept, measured (quick_diff): renderConstructionMenu's second masking of the index and its two hoverTextX stores (reusing index and one store: 0.9559 -> 0.8393 together; each alone in the next commit), Constructor_Menu's while over the options (a for: 0.8787 -> 0.6025), prepareAndRenderMenuItems' isDragged declared early (at its use: 0.9645 -> 0.7980), each with a line in the code. Everything else is quick_diff-identical, and all five functions are reccmp 100.0 in a full build. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
renderConstructionMenu's second masking of the index and its two hoverTextX stores, and Constructor_Menu's while over the options, say what the cleaner form measures, each alone, in main's one-line form: reusing index 0.9559 -> 0.8883, one hoverTextX store 0.9559 -> 0.9046, a for 0.8787 -> 0.6025. handleMenuItems no longer includes MenuItemHandleState.hpp twice (Menu.func.hpp brings it); quick_diff identical. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Style guide reading (advisory, posted once) 3 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 3 of the 5 reimplemented The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.
WhereRule 9 — Prefer
Rule 18 — Use the name, not the number
|
This was referenced Nov 9, 2026
Main's Ghidra sync 6c1e0bd brought this branch's header changes; main's versions are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 10, 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 functions of the menu-item engine, the code that builds, steps through and draws a menu's items, all at 100%. Each was written from gynt's draft, which was below 100% (his closed #256, restyled later on his fork), and each commit cites the drafts it builds on and credits him as co-author. This is part of the rest of UI that gynt OK'd on 2026-11-09.
BottomLeftTextDisplayState::setBottomLeftTextDisplayTextMenuItem::prepareAndRenderMenuItemsMenu::handleMenuItemsMenu::Constructor_MenuMenu::renderConstructionMenuMeasured on today's main (9528350).
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), resolvers enabled locally (not committed), sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie.openshc-pr-checkgives no errors, andstatus_regression.pyfinds no score lower than before.What changed from the drafts
secondItemTypeData.scrollbarOrSliderState(minValue, maxValue, currentValue, dragTiming) where the draft read the same four ints throughbuttonState.forover the items up toMIT_LAST_ENTRY, with an if/else chain on the item type. The draft's empty ifs are the returns the original has: on the current tab's stop item, onMIT_STOP_HANDLING, during a build-menu slide while handling input, while a modal dialog is open, and when an item's input callback asks to stop.Header changes (each in a commit of its own)
Main's Ghidra sync (6c1e0bd) brought these header lines, and main (d5d965d) is merged in, with our code following main's spellings (
TAIT_UNKNOWNfor text index 4,INT_00b9840c), so the declaration check passes now.SliderRenderFunctionandScrollbarRenderFunction: the last parameterbool→BOOLEnum(bffeb07).mov dword ptr [esp + 8], 1at 0x004F4BB4) and pushes it as a dword. Aboolparameter makes MSVC compare andsetnefirst.MenuItemRenderFunction_0x20, the same callback in Ghidra's other copy, already hasBOOLEnum.BOOL isDragged(five) orBOOLEnum(NewInvasion_RepeatSlider), and every scrollbar render function takesBOOLEnum.MenuItemRenderFunctionUnionuses the two typedefs, and no.cppon main uses its.slider/.scrollbarmembers, so nothing else changes.TextMessageBLLookupStructTypeEnumgetsTMBLLSTE_UNKNOWN_0and_7to_13(e94e6ea)..cppon main uses the enum's names.setBottomLeftTextDisplayText'sparam_4isassociatedTypeUnk(28ded95).associatedType..func.hpptakes only the member pointer, so nothing depends on the name.Kept as they are, measured with quick_diff (each has a one-line comment)
index: 0.9559 → 0.8883hoverTextXstored in both branchesbreakto one shared store: 0.9559 → 0.8475whileover the options (the pointer advances in the inner loop)for: 0.8787 → 0.6025isDraggeddeclared earlyfor: 0.9884 → 0.9767&>= 0: 0.9191 → 0.9118The style-lint bot's three findings:
whileis the measured row above.0xffff(renderConstructionMenu) and0x7fffff(prepareAndRenderMenuItems) are masks used with&. gynt's rule (Reimplement 32 rendering and UI rendering functions at 100% #311) allows hex there. The second isMIT_MENU_ITEM_TYPE_ID_PARTUnk's 23-bit index mask, not a colour.renderConstructionMenu reads the text index as
*(int*)&item->textMessageLookupIndex & 0xffff, the whole dword masked, as the original does. gynt's handleMenuElementsCallbacks makes the same read and takes the high word as a sound ID, so the field looks like a union (see below).Proposed, not changed here
MIT_OPTION_GROUPUnkandMIT_OPTIONUnk;MIT_CLICK_HANDLERUnk= 7;MIT_ALTERNATIVEUnk(1 << 26) andMIT_ALTERNATIVES_HEADUnk(1 << 27);MIT_RENDER_SEPARATELYUnk= 0x800000, which matchesMIHS_…_FOR_FLAG_0X800000;hiddenFlag(a guess).MenuHandlerState::const017/const516dword→int. prepareAndRenderMenuItems casts them, and setupBuildMenuState only stores them.minThumbLengthUnkmember inMenuItemFirstItemTypeData: for a slider,itemsToSkipholds the minimum thumb length.MenuItem::textMessageLookupIndexas a union: anint, plus the low word (the text index) and the high word (a sound ID).buttonState, the same mix-up the draft had here.What some fields hold
Menu::zero: the tooltip state (0 none, 1 waiting, 2 shown).someTimestampUnk: when the hover started.someMenuItemPtr_0x3c: the tooltip's item.Other PRs
drawHeaderTextBanner's text group aseTextSections) follows.🤖 Generated with Claude Code