From 972f8c9f8826d668413467bfd2de322137e2403b Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 11:11:49 +0100 Subject: [PATCH 1/5] reimplement: SHC_3BB0A8C1_0x004BB7B0 100.0% Reimplemented 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 --- ...uItemRenderFunction_DisableWeapon_Main.cpp | 122 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/DisableWeapon/MenuItemRenderFunction_DisableWeapon_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/DisableWeapon/MenuItemRenderFunction_DisableWeapon_Main.cpp b/src/OpenSHC/UI/MenuItems/DisableWeapon/MenuItemRenderFunction_DisableWeapon_Main.cpp new file mode 100644 index 0000000000..f5389bdfdc --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/DisableWeapon/MenuItemRenderFunction_DisableWeapon_Main.cpp @@ -0,0 +1,122 @@ +#include "../DisableWeapon.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace DisableWeapon { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BB7B0 + void MenuItemRenderFunction_DisableWeapon_Main(int button, ...) + { + // Before the range test: the Exit block reuses its zero (inside the if: quick_diff 0.8889 -> 0.7273) + int iconOffsetY = 0; + // Guarded, not an early return (early return: quick_diff 0.8889 -> 0.8673) + // One unsigned test for 0..7 (button >= 0 && button <= 7: reccmp 100.0% -> 90.0%) + if ((uint)button <= 7) { + // Button 1 moves down a pixel while hovered; its icon stays where it was. + if (button == 1 && DAT_ButtonCurrentlyInteracting::instance) { + ++DAT_ButtonY::instance; + iconOffsetY = -1; + } + MACRO_CALL(General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + // The weapons 0 to 5 get the disabled icon only while they cannot be made. + // Break to the icon, then return (the return first: quick_diff 0.8889 -> 0.7527) + switch (button) { + case 0: + if (!DAT_MapPropertiesState::instance.SEC_XbowProducible_save) { + break; + } + return; + case 1: + if (!DAT_MapPropertiesState::instance.SEC_PikeProducible_save) { + break; + } + return; + case 2: + if (!DAT_MapPropertiesState::instance.SEC_SwordProducible_save) { + break; + } + return; + case 3: + if (!DAT_MapPropertiesState::instance.SEC_BowProducible_save) { + break; + } + return; + case 4: + if (!DAT_MapPropertiesState::instance.SEC_SpearProducible_save) { + break; + } + return; + case 5: + if (!DAT_MapPropertiesState::instance.SEC_MaceProducible_save) { + break; + } + return; + // An explicit default keeps every return's epilogue (without it: quick_diff 0.8889 -> 0.8673) + default: + break; + } + if (button != 0) { + DAT_ButtonX::instance -= 4; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 45, + DAT_ButtonX::instance + 6, DAT_ButtonY::instance + iconOffsetY - 5, 12); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (button == -3) { + // "Exit" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // One call per colour (one call with a colour local: quick_diff 0.8889 -> 0.7839) + // The position in each branch (once, before the test: quick_diff 0.8889 -> 0.8788) + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, + 0); + } else { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, + 0); + } + } + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e90b860d04..e5835176f0 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29297,7 +29297,7 @@ SHC_3BB0A8C1_0x004BB680 | 0.0% | Pending SHC_3BB0A8C1_0x004BB740 | 0.0% | Pending -SHC_3BB0A8C1_0x004BB7B0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BB7B0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BB8E8 | 0.0% | Pending From b1ee78d9ccde95d0d6561dc716505a949e5d40c9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 11:11:49 +0100 Subject: [PATCH 2/5] reimplement: SHC_3BB0A8C1_0x004B9060 100.0% Reimplemented 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 --- ...derFunction_EditScenario_UpDownButtons.cpp | 70 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_UpDownButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_UpDownButtons.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_UpDownButtons.cpp new file mode 100644 index 0000000000..08a322808c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_UpDownButtons.cpp @@ -0,0 +1,70 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace EditScenario { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B9060 + void MenuItemRenderFunction_EditScenario_UpDownButtons(int button, ...) + { + // -1 is the event list's up arrow, the other negative buttons its down arrow. + if (button < 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (button == -1) { + MACRO_CALL_MEMBER( + Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, DAT_PencilRenderCore::ptr)(0, 0); + } else { + MACRO_CALL_MEMBER( + Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, DAT_PencilRenderCore::ptr)(1, 0); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + // The other buttons show their scenario text, in white while hovered. + MACRO_CALL_MEMBER(Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // One call per colour pair (one call with colour locals: quick_diff 0.9231 -> 0.5455) + // The position in each branch (once, before the test: quick_diff 0.9231 -> 0.9038) + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_SCENARIO, button), + textX, textY, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_00A2FF, + OpenSHC::Rendering::Colors::COL_003E66, 18, FALSE, 0); + return; + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + DE::SHCDE::TEXT_SCENARIO, button), + textX, textY, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_FFFFFF, + OpenSHC::Rendering::Colors::COL_000000, 18, FALSE, 0); + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e5835176f0..1b2153b0fa 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -27525,7 +27525,7 @@ SHC_3BB0A8C1_0x004B8BF0 | 0.0% | Pending SHC_3BB0A8C1_0x004B9020 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B9060 | 0.0% | Pending +SHC_3BB0A8C1_0x004B9060 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B9110 | 0.0% | Pending From e8323a5ac5fb7258c72dcccd8a6eef054ebef9fd Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 11:11:50 +0100 Subject: [PATCH 3/5] reimplement: SHC_3BB0A8C1_0x004BAC20 100.0% Reimplemented 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 --- ...erFunction_EditScenario_StartDateMonth.cpp | 53 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_StartDateMonth.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_StartDateMonth.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_StartDateMonth.cpp new file mode 100644 index 0000000000..40584b32ac --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_StartDateMonth.cpp @@ -0,0 +1,53 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace EditScenario { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BAC20 + void MenuItemRenderFunction_EditScenario_StartDateMonth(int param_1, ...) + { + MACRO_CALL_MEMBER(Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // One call per colour (one call with a colour local: quick_diff 0.9062 -> 0.5373) + // y, x, then the month, in each branch (once, before the test: quick_diff 0.9062 -> 0.8438) + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + // The month's full name, read last (first: quick_diff 0.9062 -> 0.6970; in the call: 0.6857) + int const monthTextIndex = DAT_MapPropertiesState::instance.SEC_StartingMonth + 12; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_MONTHS, monthTextIndex), + textX, textY, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + return; + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const monthTextIndex = DAT_MapPropertiesState::instance.SEC_StartingMonth + 12; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + DE::SHCDE::TEXT_MONTHS, monthTextIndex), + textX, textY, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 1b2153b0fa..60aeb08fa2 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29093,7 +29093,7 @@ SHC_3BB0A8C1_0x004BA910 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BA980 | 0.0% | Pending -SHC_3BB0A8C1_0x004BAC20 | 0.0% | Pending +SHC_3BB0A8C1_0x004BAC20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BAC90 | 0.0% | Pending From 3937e8996c813944d0788de9e468389c97156b56 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 11:19:51 +0100 Subject: [PATCH 4/5] reimplement: SHC_3BB0A8C1_0x00466620 100.0% Reimplemented 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 --- ...dingAndStatusMenu_OutpostUnitSelection.cpp | 82 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_OutpostUnitSelection.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_OutpostUnitSelection.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_OutpostUnitSelection.cpp new file mode 100644 index 0000000000..d4417d6a43 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_OutpostUnitSelection.cpp @@ -0,0 +1,82 @@ +#include "../BuildingAndStatusMenu.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/Buildings/BuildingType.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace BuildingAndStatusMenu { + + // FUNCTION: STRONGHOLDCRUSADER 0x00466620 + void MenuItemRenderFunction_BuildingAndStatusMenu_OutpostUnitSelection(int bitIndex, ...) + { + int const unitBit = 1 << bitIndex; + // Each outpost's title comes before its unit names; the Arabian outpost's follow the European ones. + int textOffset = 0; + if (DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID] + .buildingType + == Map::Buildings::BT_OUTPOST_ARABIAN) { + textOffset = 9; + } + // The button shows pressed while the outpost has this unit selected. + // The test and the draw in each branch (once, before the hover test: quick_diff 0.9206 -> 0.5854) + if (!DAT_ButtonCurrentlyInteracting::instance) { + if (DAT_BuildingsState::instance.menuSelectedBuildingID != 0 + && (unitBit + & DAT_BuildingsState::instance + .buildings[DAT_BuildingsState::instance.menuSelectedBuildingID] + .outpostRelatedUnk1) + != 0) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + } else { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + MACRO_CALL(General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + // One call per colour pair (one call with colour locals: quick_diff 0.9206 -> 0.4615) + // The position in each branch (in the calls: quick_diff 0.9206 -> 0.8730) + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_IN_OUTPOST, textOffset + 1 + bitIndex), + textX, textY, Text::TTA_CENTER, Rendering::Colors::COL_C2F0EB, Rendering::Colors::COL_003E66, + 18, FALSE, 0); + return; + } + if (DAT_BuildingsState::instance.menuSelectedBuildingID != 0 + && (unitBit + & DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID] + .outpostRelatedUnk1) + != 0) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + } else { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + MACRO_CALL(General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + DE::SHCDE::TEXT_IN_OUTPOST, textOffset + 1 + bitIndex), + textX, textY, Text::TTA_CENTER, Rendering::Colors::COL_CCFAFF, Rendering::Colors::COL_000000, 18, + FALSE, 0); + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 60aeb08fa2..659e8b17a3 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -19943,7 +19943,7 @@ SHC_3BB0A8C1_0x00466430 | 0.0% | Pending SHC_3BB0A8C1_0x00466480 | 0.0% | Pending -SHC_3BB0A8C1_0x00466620 | 0.0% | Pending +SHC_3BB0A8C1_0x00466620 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00466710 | 100.0% | Reimplemented From 9789a1d8402bdf112d1e159019dac2f0cfb01bb7 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 11:55:53 +0100 Subject: [PATCH 5/5] reimplement: SHC_3BB0A8C1_0x004BB3E0 100.0% Reimplemented 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 --- ...unction_BuildingAvailability_TableRows.cpp | 74 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/BuildingAvailability/MenuItemRenderFunction_BuildingAvailability_TableRows.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildingAvailability/MenuItemRenderFunction_BuildingAvailability_TableRows.cpp b/src/OpenSHC/UI/MenuItems/BuildingAvailability/MenuItemRenderFunction_BuildingAvailability_TableRows.cpp new file mode 100644 index 0000000000..0cc8b5b13c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildingAvailability/MenuItemRenderFunction_BuildingAvailability_TableRows.cpp @@ -0,0 +1,74 @@ +#include "../BuildingAvailability.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace BuildingAvailability { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BB3E0 + void MenuItemRenderFunction_BuildingAvailability_TableRows(int row, ...) + { + int const buildingIndex + = DAT_MissionAestheticsDefinedData::instance.BuildingAvailabilityStructIndexForNameArray + [DAT_MapPropertiesState::instance.DAT_BuildingAvailabilityScrollbarOffset + row]; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(FALSE, row, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + // The building's name: highlighted while hovered, grey when the building is not available. + // One call per colour (one call with a colour local: quick_diff 0.9048 -> 0.5882) + if (DAT_ButtonCurrentlyInteracting::instance) { + // y then x in each branch (once, before the test: quick_diff 0.9048 -> 0.7857; x first: 0.8095) + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 20; + // The name last (before the test: quick_diff 0.9048 -> 0.7381; first: 0.7045; in the call: 0.5208) + int const nameNumber + = DAT_MissionAestheticsDefinedData::instance.BuildingNameRelatedStructArray[buildingIndex] + .nameNumberInTextGroup; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, nameNumber), + textX, textY, Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); + } else if (!DAT_MapPropertiesState::instance.buildingAvailability[buildingIndex]) { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 20; + int const nameNumber + = DAT_MissionAestheticsDefinedData::instance.BuildingNameRelatedStructArray[buildingIndex] + .nameNumberInTextGroup; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, nameNumber), + textX, textY, Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_7F7F7F, 19, FALSE, 0); + } else { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 20; + int const nameNumber + = DAT_MissionAestheticsDefinedData::instance.BuildingNameRelatedStructArray[buildingIndex] + .nameNumberInTextGroup; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, nameNumber), + textX, textY, Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); + } + } + + } + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 659e8b17a3..b7d99d3c27 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29271,7 +29271,7 @@ SHC_3BB0A8C1_0x004BB3D8 | 0.0% | Pending SHC_3BB0A8C1_0x004BB3D9 | 0.0% | Pending -SHC_3BB0A8C1_0x004BB3E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BB3E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BB480 | 100.0% | Reimplemented