From e32e2b828f24c451b3d2d5e3e746a02dcd291cf7 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 12 Nov 2026 17:31:06 +0100 Subject: [PATCH 01/13] fix(map): pass the future orientation as a MapOrientation Main's Ghidra sync c67521e1f changed changeMapOrientation's parameter from int to MapOrientation. processMapOrientationChange passes DAT_FutureMapOrientation, which is still undefined4, so the file stopped compiling (C2664). The cast restores it; quick_diff is 1.0000 before the sync and after the fix. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp b/src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp index 3c44508739..967bd96d43 100644 --- a/src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp +++ b/src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp @@ -8,7 +8,7 @@ namespace Map { { if ((int)this->DAT_FutureMapOrientation < 8) { MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::changeMapOrientation, this)( - this->DAT_FutureMapOrientation); + (MapOrientation)this->DAT_FutureMapOrientation); this->DAT_FutureMapOrientation = 8; } } From 4cf692642bcfe7fed830109f3c4a46e26c0ec09f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 12 Nov 2026 17:31:20 +0100 Subject: [PATCH 02/13] style(map): processMapOrientationChange includes its own func header first Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp b/src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp index 967bd96d43..b1afd2b135 100644 --- a/src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp +++ b/src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp @@ -1,4 +1,4 @@ -#include "OpenSHC/Map/TileMapState.func.hpp" +#include "../TileMapState.func.hpp" namespace OpenSHC { namespace Map { From 0cab9d6986dab4a66963dec08863675b68866a33 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 10:48:40 +0100 Subject: [PATCH 03/13] headers: DAT_ButtonBlendStrength is an int The button's blend strength at 0x00ED31C4 was undefined4. MenuItemRenderFunction_TacticalPowerBar_Main (0x004D9EC0) dims its icons during a multiplayer game's no-rush time by 32 - (32 - strength) / 2, and the original divides that signed (mov eax, 0x20; sub eax, [0xed31c4]; cdq; sub eax, edx; sar eax, 1), where the unsigned field gives shr. Every reader passes it on as a renderGMWithBlending blend strength, which is an int. The four files on main that read it (MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface, MenuItemRenderFunction_MapEditorLandscaping_GeneralButtons, RenderButtonImageWithBlending, RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk) give the same quick_diff output with it. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_ButtonBlendStrength.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_ButtonBlendStrength.hpp b/src/OpenSHC/Globals/DAT_ButtonBlendStrength.hpp index 62e5419604..0418982134 100644 --- a/src/OpenSHC/Globals/DAT_ButtonBlendStrength.hpp +++ b/src/OpenSHC/Globals/DAT_ButtonBlendStrength.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00ED31C4 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00ED31C4) DAT_ButtonBlendStrength; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00ED31C4) DAT_ButtonBlendStrength; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00ED31C4); From 90af173d5cc3f6f9c8e6bf64dfed0aadb5863319 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 10:48:41 +0100 Subject: [PATCH 04/13] data: DAT_ButtonBlendStrength's symbol as an int data.asm names the instance at 0x00ED31C4 with the int type (H instead of I), as it does for main's other int globals, to go with the header commit before it. With the old name the original's references to the address show the unsigned instance in reccmp, and MenuItemRenderFunction_TacticalPowerBar_Main reads 96.4% raw where it is 100.0% normalized. Co-Authored-By: Claude Opus 5.5 --- src/symbols/data.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/symbols/data.asm b/src/symbols/data.asm index d39085272d..d2f5dad9f1 100644 --- a/src/symbols/data.asm +++ b/src/symbols/data.asm @@ -987,7 +987,7 @@ PUBLIC ?instance@?$Extern@I$0ONDBLM@@StructResolver@@2IA PUBLIC ?instance@?$Extern@H$0ONDBMA@@StructResolver@@2HA -PUBLIC ?instance@?$Extern@I$0ONDBME@@StructResolver@@2IA +PUBLIC ?instance@?$Extern@H$0ONDBME@@StructResolver@@2HA PUBLIC ?instance@?$Extern@I$0ONDBMI@@StructResolver@@2IA @@ -2674,7 +2674,7 @@ _TEXT SEGMENT ?instance@?$Extern@H$0ONDBMA@@StructResolver@@2HA EQU 00ED31C0h -?instance@?$Extern@I$0ONDBME@@StructResolver@@2IA EQU 00ED31C4h +?instance@?$Extern@H$0ONDBME@@StructResolver@@2HA EQU 00ED31C4h ?instance@?$Extern@I$0ONDBMI@@StructResolver@@2IA EQU 00ED31C8h From a7d91e9a784551754af4988a22c56b4493a90dab Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 09:52:00 +0100 Subject: [PATCH 05/13] reimplement: SHC_3BB0A8C1_0x00438B60 100.0% Reimplemented MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets handles the right mouse button in game: with no right click started, or a siege tent's battering ram or shield tab open in the build menu, a right drag moves the camera; otherwise, with no mapper command active, it stores the mouse position and turns the preview on. Written from the original's instructions, with gynt's draft (b05c784ff on his fork's reimpl/UI-MenuItems, 49.12% there, and his batch pass 8725ec523; earlier 357b379d3 at 35.7%) for the reads. Behaviour fix: the original tail-calls updateRightDragCameraControl and returns, where the draft went on to clear previewEnabled after it. Also: an early return for a viewport that is not active, main's names (field_0x0, editorPlacementPlayerID), truth tests on the two BOOL fields, no decompiler comments. The handler's int parameter is unused and keeps the header's name. quick_diff leaves only ret / ret 0. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...nGameMenu_RightClickMenuAndMaybeResets.cpp | 47 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp new file mode 100644 index 0000000000..bc73998a9b --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp @@ -0,0 +1,47 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00438B60 + void InGameMenu::MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets(int param_1, ...) + { + DAT_MouseState::instance.mouseBasedEvent = 0; + if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { + return; + } + if (!DAT_MouseState::instance.rightClickStart + || (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU + && (DAT_GameCore::instance.activeMenuTab.tabType + == OpenSHC::UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM + || DAT_GameCore::instance.activeMenuTab.tabType + == OpenSHC::UI::Enums::BASMTT_SIEGETENT_SHIELD))) { + if (DAT_MouseState::instance.rightClickState && DAT_MouseState::instance.previewEnabled != 0) { + MACRO_CALL_MEMBER( + OpenSHC::Input::MouseState_Func::updateRightDragCameraControl, DAT_MouseState::ptr)(); + return; + } + } else if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_NULL) { + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); + DAT_MouseState::instance.previewEnabled = 1; + DAT_GameSynchronyState::instance.editorPlacementPlayerID = 1; + return; + } + DAT_MouseState::instance.previewEnabled = 0; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a70f614bd4..478553776c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -12941,7 +12941,7 @@ SHC_3BB0A8C1_0x004387CF | 0.0% | Pending SHC_3BB0A8C1_0x004387D0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00438B60 | 0.0% | Pending +SHC_3BB0A8C1_0x00438B60 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00438BE0 | 0.0% | Pending From cd543ed03a3cc12dbad04e265dd083a4c3bd8e05 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 09:52:00 +0100 Subject: [PATCH 06/13] reimplement: SHC_3BB0A8C1_0x004B1410 100.0% Reimplemented MenuItemActionHandler_AlliesOrder_Main sends the order of one of the allies dialog's buttons to the ally shown: buttons 1 to 6 ask for the goods of the enemy listed there, and only exist up to the number of enemies. Button -2 opens the allies dialog again; 10 opens it again after its order, the others close it. From gynt's draft (36d9d19f9 on his fork's reimpl/UI-MenuItems-development, 80.00% there; earlier 92e78158d at 66.67%) with our earlier behaviour fixes: the dialog opens again only for -2 and 10. The shape the original needs: -2 opens the dialog and returns at the top, and 10 has its own activateModalDialog call in an if / else with the close-dialog store (one shared call: quick_diff 0.8750, the store before it). quick_diff leaves only ret / ret 0. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...MenuItemActionHandler_AlliesOrder_Main.cpp | 60 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemActionHandler_AlliesOrder_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemActionHandler_AlliesOrder_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemActionHandler_AlliesOrder_Main.cpp new file mode 100644 index 0000000000..00c73d2d84 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemActionHandler_AlliesOrder_Main.cpp @@ -0,0 +1,60 @@ +#include "../AlliesOrder.func.hpp" + +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_EnemyArrayIndex.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_LastTeamMemberIndex.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_RequestedGoodsByWhoArray.hpp" +#include "OpenSHC/Globals/DAT_SomeTeamMemberPlayerIDArray.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B1410 + void AlliesOrder::MenuItemActionHandler_AlliesOrder_Main(int button, ...) + { + // -2 shows the allies dialog again + if (button == -2) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + return; + } + // buttons 1 to 6 name an enemy from the list BuildEnemyPlayerList made + if (button <= 6 && button - 1 >= DAT_EnemyArrayIndex::instance) { + return; + } + int const allyPlayerID = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[allyPlayerID] == -1 + && DAT_GameSynchronyState::instance.currentAIArray[allyPlayerID] == 0) { + return; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + if (button <= 6) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = DAT_RequestedGoodsByWhoArray::instance[button]; + } else { + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = 0; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = allyPlayerID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = button; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); + // 10 shows the allies dialog again after its order, the others close it + if (button == 10) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + } else { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 478553776c..13feb29c98 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25975,7 +25975,7 @@ SHC_3BB0A8C1_0x004B11A0 | 0.0% | Pending SHC_3BB0A8C1_0x004B12D0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B1410 | 0.0% | Pending +SHC_3BB0A8C1_0x004B1410 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B1471 | 0.0% | Pending From 70bc6bdb3051eb3fc4f9af15a9046815093a63fa Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 09:52:01 +0100 Subject: [PATCH 07/13] reimplement: SHC_3BB0A8C1_0x004BA3C0 100.0% Reimplemented MenuItemRenderFunction_General_EventSlider draws a scenario event's slider: its thumb, in dark lime while it is dragged and greyish yellow otherwise, and the value beside it, or "-" for slider -2 at 10. Sliders -2 and -1 only show for the events that last a while (the travelling fair, the plagues and pests, bandits to archers, theft and fire), the others only for the event one below their number. Written from the original's instructions, with gynt's draft (a35032b4e on his fork's reimpl/UI-MenuItems, 74.47% there, and his batch pass 8725ec523; earlier 48ef385b5 at 60.4%) for the reads. Behaviour fix: in the draft the -2 and -1 cases fell from the inner switch into the next case's event test, which -2 and -1 never pass, so those sliders were never drawn; the original goes straight to drawing. The two thumb colours are two drawColorBox calls, as in the original, which shares their tail. Also: the parameters named slider and value (the outer switch's cases are slider numbers, which have no enum), the inner switch's cases by their ScenarioEventType names, s___005a2280 for "-", COL_CCFAFF, decimals. quick_diff leaves the jump tables' labels, the colour immediate and ret / ret 0. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...ItemRenderFunction_General_EventSlider.cpp | 98 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp new file mode 100644 index 0000000000..8725899019 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp @@ -0,0 +1,98 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventType.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/COL_GREYISH_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.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_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BA3C0 + void General::MenuItemRenderFunction_General_EventSlider( + int slider, int thumbYPos, int value, int thumbHeight, BOOL isDragged) + { + switch (slider) { + case -2: + case -1: + // these two sliders belong to the events that have a duration + switch (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType) { + case OpenSHC::Game::ScenarioEvents::Enums::SET_TRAVELING_FAIR: + case OpenSHC::Game::ScenarioEvents::Enums::SET_PLAGUE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_WHEAT_DISEASE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_HOPS_WEEVIL: + case OpenSHC::Game::ScenarioEvents::Enums::SET_APPLE_BLIGHT: + case OpenSHC::Game::ScenarioEvents::Enums::SET_TREE_FUNGUS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_RABBIT_EXPLOSION: + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_ATTACK: + case OpenSHC::Game::ScenarioEvents::Enums::SET_BANDITS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_MAD_COWS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_ARCHERS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_THEFT_FROM_GRANARY: + case OpenSHC::Game::ScenarioEvents::Enums::SET_FIRE: + break; + default: + return; + } + break; + case 5: + case 12: + case 18: + case 19: + case 21: + // the other sliders belong to the event one below their number + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + != slider - 1) { + return; + } + break; + } + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(-1, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!isDragged) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + thumbYPos + 1, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + thumbYPos + thumbHeight - 2, + DAT_ButtonY::instance + DAT_ButtonH::instance - 4, COL_GREYISH_YELLOW::instance.shortValue); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + thumbYPos + 1, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + thumbYPos + thumbHeight - 2, + DAT_ButtonY::instance + DAT_ButtonH::instance - 4, COL_DARK_LIME::instance.shortValue); + } + if (slider == -2 && value == 10) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + // "-" + DAT_TextManagerObject::ptr)(s___005a2280, DAT_ButtonX::instance + DAT_ButtonW::instance + 12, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, + FALSE, 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(value, + DAT_ButtonX::instance + DAT_ButtonW::instance + 12, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 13feb29c98..bf88b54bdb 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -28967,7 +28967,7 @@ SHC_3BB0A8C1_0x004BA3B0 | 0.0% | Pending SHC_3BB0A8C1_0x004BA3B4 | 0.0% | Pending -SHC_3BB0A8C1_0x004BA3C0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BA3C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BA514 | 0.0% | Pending From 2590d7327161e03f7aadb1f06986b6ccda4872f6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 09:52:01 +0100 Subject: [PATCH 08/13] reimplement: SHC_3BB0A8C1_0x004AA800 100.0% Reimplemented MenuItemRenderFunction_OverlaySlider_Slider draws a modal dialog's slider: a dark box, the slider's title from the dialog's text group and index, and the thumb in dark lime while it is dragged and greyish yellow otherwise. A thumb as wide as the slider covers the title, so the title is drawn again over it. Written from the original's instructions, with gynt's draft (71f7285af on his fork's reimpl/UI-MenuItems-development, 53.63% there; earlier 31447479b at 40.70%) for the reads. Two forms are kept for the register allocation: the title's position in two locals, y first, in both title blocks (inline: quick_diff 0.6816, and MSVC then merges the thumb's two drawColorBox calls; one block only: 0.8696), and the thumb's two colours as two calls. Also: the parameters named slider and value as in the event slider (both unused here), COL_C2F0EB and COL_CCFAFF, decimals, no decompiler locals. quick_diff leaves the colour immediates and ret / ret 0. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...temRenderFunction_OverlaySlider_Slider.cpp | 67 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp diff --git a/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp new file mode 100644 index 0000000000..86cf4516ec --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp @@ -0,0 +1,67 @@ +#include "../OverlaySlider.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/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/COL_GREYISH_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004AA800 + void OverlaySlider::MenuItemRenderFunction_OverlaySlider_Slider( + int slider, int thumbYPos, int value, int thumbHeight, BOOL isDragged) + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonX::instance + DAT_ButtonW::instance, DAT_ButtonY::instance + DAT_ButtonH::instance, 12); + // the slider's title, drawn under the thumb + if (DAT_MenuModalComposition2::instance.textGroup >= 0) { + int const textY = DAT_ButtonY::instance + 4; + 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::eTextSections)DAT_MenuModalComposition2::instance.textGroup, + DAT_MenuModalComposition2::instance.textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); + } + if (!isDragged) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + thumbYPos, DAT_ButtonY::instance, + DAT_ButtonX::instance + thumbYPos + thumbHeight, DAT_ButtonY::instance + DAT_ButtonH::instance, + COL_GREYISH_YELLOW::instance.shortValue); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + thumbYPos, DAT_ButtonY::instance, + DAT_ButtonX::instance + thumbYPos + thumbHeight, DAT_ButtonY::instance + DAT_ButtonH::instance, + COL_DARK_LIME::instance.shortValue); + } + // a thumb as wide as the slider covers the title, so it is drawn again over it + if (thumbHeight == DAT_ButtonW::instance && DAT_MenuModalComposition2::instance.textGroup >= 0) { + int const textY = DAT_ButtonY::instance + 4; + 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::eTextSections)DAT_MenuModalComposition2::instance.textGroup, + DAT_MenuModalComposition2::instance.textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index bf88b54bdb..2ecb27ab97 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25513,7 +25513,7 @@ SHC_3BB0A8C1_0x004AA7EC | 0.0% | Pending SHC_3BB0A8C1_0x004AA7F0 | 0.0% | Pending -SHC_3BB0A8C1_0x004AA800 | 0.0% | Pending +SHC_3BB0A8C1_0x004AA800 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AA930 | 0.0% | Pending From 6e3390c802b0290b943a982729c289e1b993041c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 09:52:01 +0100 Subject: [PATCH 09/13] reimplement: SHC_3BB0A8C1_0x004D9EC0 100.0% Reimplemented MenuItemRenderFunction_TacticalPowerBar_Main draws one slot of the tactical powers bar: a short line, and the power's icon, bright once the bar's level has filled the slot (636 points a slot) with a highlight while the mouse is over it, dimmed otherwise. The first time a power is ready the help text is shown. During the no-rush time of a multiplayer game the icons are dimmed further and never bright. Written from the original's instructions, with gynt's draft (643ea4208 on his fork's reimpl/UI-MenuItems, 36.70% there, and his batch pass 8725ec523; earlier 477e2bbe7 at 30.8%) for the reads. Behaviour fix: once the slot is full the original draws the bright icon and returns; the draft went on to draw the dimmed icon over it. Needs the header commit before it: the no-rush blend strength is a signed division. The forms the original needs: the button's y and x read into locals, y first, before the level (inline: quick_diff 0.7919), level >= ... rather than ... <= level, and the dimmed icon as one call in each branch, which MSVC merges at the tail (one call with a blend local: 0.9137). Also: the parameter named slot; the slot to icon switch (slot numbers, no enum) with the 4 / 8 / 9 case last as in the original, decimals, no decompiler comments. quick_diff leaves the jump table's label and ret / ret 0. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...emRenderFunction_TacticalPowerBar_Main.cpp | 96 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp b/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp new file mode 100644 index 0000000000..8c0bd8a055 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp @@ -0,0 +1,96 @@ +#include "../TacticalPowerBar.func.hpp" + +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_ButtonBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TacticalPowersHelpTextDisplayBool.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D9EC0 + void TacticalPowerBar::MenuItemRenderFunction_TacticalPowerBar_Main(int slot, ...) + { + int const buttonY = DAT_ButtonY::instance; + int const buttonX = DAT_ButtonX::instance; + int const level + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .tacticalPowersBarLevel; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + buttonX + 20, buttonY + 10, buttonX + 30, buttonY + 10, COL_VERY_SOFT_YELLOW::instance.shortValue); + // the bar's ten slots show the powers' icons in this order + int icon = slot; + switch (slot) { + case 0: + icon = 5; + break; + case 1: + icon = 6; + break; + case 2: + icon = 1; + break; + case 3: + icon = 3; + break; + case 5: + icon = 7; + break; + case 6: + icon = 2; + break; + case 7: + icon = 4; + break; + case 4: + case 8: + case 9: + icon = 0; + break; + } + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY + || DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + || DAT_GameState::instance.mapAndTime.skirmishNoRushTicks == 0) { + // each slot fills over 636 points of the bar + if (level >= (slot + 1) * 636) { + if (!DAT_GameCore::instance.tacticalPowersDisplayFlag) { + DAT_TacticalPowersHelpTextDisplayBool::instance = true; + DAT_GameCore::instance.tacticalPowersDisplayFlag = 1; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, icon + 289, + DAT_ButtonX::instance, DAT_ButtonY::instance, DAT_ButtonBlendStrength::instance); + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 297, + DAT_ButtonX::instance, DAT_ButtonY::instance, DAT_ButtonBlendStrength::instance); + } + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, icon + 298, + DAT_ButtonX::instance, DAT_ButtonY::instance, DAT_ButtonBlendStrength::instance); + } else { + // during the no-rush time of a multiplayer game the icons are dimmed further + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, icon + 298, + DAT_ButtonX::instance, DAT_ButtonY::instance, 32 - (32 - DAT_ButtonBlendStrength::instance) / 2); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 2ecb27ab97..2266cc4481 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36059,7 +36059,7 @@ SHC_3BB0A8C1_0x004D9D90 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D9DB0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D9EC0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D9EC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DA024 | 0.0% | Pending From 445bc1c94ac5dde9daa4d2449c3d10589461cf00 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 10:09:14 +0100 Subject: [PATCH 10/13] reimplement: SHC_3BB0A8C1_0x004D6D20 100.0% Reimplemented MenuItemRenderFunction_MissionEndscreen_Main draws the buttons of a skirmish or multiplayer game's end screen: the two tabs -100 and -101, drawn pressed when they are the one INT_00ec082c selects (0 or 2 for the first, 1 or 3 for the second); the results table's column headers 0 to 15, the one the table is sorted by drawn pressed, and the column under the mouse stored in DAT_00eb9af8; and everything else as a normal button. Written from the original's instructions, with gynt's draft (aa394fe55 on his fork's reimpl/UI-MenuItems, 43.10% there, and his batch pass 8725ec523; earlier 20d79c530 at 27.27% and 77ed5e066 at 19.9%) for the reads. Behaviour fixes: the draft drew the normal button twice for button -1, and returned after storing the column under the mouse where the original goes on to draw that column's header. The forms the original needs: the two tab tests in one condition, so their pressed drawing is one block that MSVC shares with the column header's (separate blocks: 15 instructions more); the -10 and -1 stores as a switch (an if / else-if lays them out the other way round). Also: the parameter named buttonID as in the sibling handler, CHAR_00eb0e44 and INT_00ec082c by main's names, TRUE / FALSE for the BOOL stores, no decompiler locals or gotos. quick_diff leaves only ret / ret 0. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...emRenderFunction_MissionEndscreen_Main.cpp | 113 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp b/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp new file mode 100644 index 0000000000..390ad08f91 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp @@ -0,0 +1,113 @@ +#include "../MissionEndscreen.func.hpp" + +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/ButtonGmData.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" + +#include "OpenSHC/Globals/CHAR_00eb0e44.hpp" +#include "OpenSHC/Globals/DAT_00eb9af8.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_FinalResultsOrderByColumn.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/INT_00ec082c.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D6D20 + void MissionEndscreen::MenuItemRenderFunction_MissionEndscreen_Main(int buttonID, ...) + { + DAT_ButtonUnknownZero::instance = TRUE; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) { + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + if (CHAR_00eb0e44::instance != 0 && (buttonID == -100 || buttonID == -101)) { + return; + } + if (buttonID == -2) { + return; + } + // the two tabs, -100 and -101: the selected one (0 or 2 for the first, 1 or 3 for the second) is drawn + // pressed + if ((buttonID == -100 && (INT_00ec082c::instance == 0 || INT_00ec082c::instance == 2)) + || (buttonID == -101 && (INT_00ec082c::instance == 1 || INT_00ec082c::instance == 3))) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0, + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, + &DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance])( + FALSE) + + 2, + DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (buttonID >= 0 && buttonID <= 15) { + // the results table's column headers: the one the table is sorted by is drawn pressed + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_00eb9af8::instance = buttonID; + } + if (buttonID == DAT_FinalResultsOrderByColumn::instance) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_FinalResultsOrderByColumn::instance < 13) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + (OpenSHC::DE::SHCDE::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0, + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, + &DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance])(TRUE) + + 14, + DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0, + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, + &DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance])(TRUE) + + 1, + DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + } + if (DAT_ButtonCurrentlyInteracting::instance) { + switch (buttonID) { + case -10: + DAT_00eb9af8::instance = 17; + break; + case -1: + DAT_00eb9af8::instance = 16; + break; + } + } + MACRO_CALL(General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 2266cc4481..90dc3d1fc1 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35831,7 +35831,7 @@ SHC_3BB0A8C1_0x004D6D13 | 0.0% | Pending SHC_3BB0A8C1_0x004D6D14 | 0.0% | Pending -SHC_3BB0A8C1_0x004D6D20 | 0.0% | Pending +SHC_3BB0A8C1_0x004D6D20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D6EF0 | 100.0% | Reimplemented From 8106d5706bd1250654a50f8e8a0cccbce83b4818 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 10:09:15 +0100 Subject: [PATCH 11/13] reimplement: SHC_3BB0A8C1_0x0045EDF0 100.0% Reimplemented MenuItemActionHandler_TextEditor_Scrollbar handles the help text's scroll bar: its range is how far the text reaches past the view (never below 0), its arrows move a twentieth of that, at least one, and the value is the text's scroll offset. Written from the original's instructions, with gynt's draft (77036d2ba on his fork's reimpl/UI-MenuItems-development, 43.44% there, and his style pass dd1a7c48c; earlier c1f0ea647 at 41.63% and 8d5d29007 at 22.67%) for the reads. The draft's mask expressions ((x <= 0) - 1 & x) are max(x, 0): the original computes it again at each use and from the step's division twice, which is how Windows' max macro, already used on main, expands. The forms the original needs: both arrows as an if / else on an offset local with one store pair after it, which MSVC copies into each arm (the stores in the arms: quick_diff 0.8702). Also: the parameter named action, decimals. quick_diff leaves the jump table's label and ret / ret 0. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...ItemActionHandler_TextEditor_Scrollbar.cpp | 84 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp new file mode 100644 index 0000000000..03de6a346d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp @@ -0,0 +1,84 @@ +#include "../TextEditor.func.hpp" + +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0045EDF0 + void TextEditor::MenuItemActionHandler_TextEditor_Scrollbar( + int param_1, int action, int* minValue, int* maxValue, int* currentValue) + { + // the arrows scroll a twentieth of the text, at least one line + int const step = max(max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0) + / 20, + 1); + switch (action) { + case 1: + *minValue = 0; + *maxValue = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); + if (*maxValue < 0) { + *maxValue = 0; + } + *currentValue = DAT_TextEditorState::instance.helpContentScrollOffsetY; + return; + case 2: + case 3: + DAT_TextEditorState::instance.helpContentScrollOffsetY = *currentValue; + return; + case 4: + *currentValue = DAT_TextEditorState::instance.helpContentScrollOffsetY; + *maxValue = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); + return; + case 7: + *currentValue = DAT_TextEditorState::instance.dialogContentHeight - 20; + return; + case 5: { + // one step up + int offset = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (offset >= step) { + offset -= step; + } else { + offset = 0; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = offset; + *currentValue = offset; + return; + } + case 6: { + // one step down + int offset = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (offset < max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0) + - step) { + offset += step; + if (offset > max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0)) { + offset = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); + } + } else { + offset = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = offset; + *currentValue = offset; + return; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 90dc3d1fc1..990edba974 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -18691,7 +18691,7 @@ SHC_3BB0A8C1_0x0045EDEA | 0.0% | Pending SHC_3BB0A8C1_0x0045EDEB | 0.0% | Pending -SHC_3BB0A8C1_0x0045EDF0 | 0.0% | Pending +SHC_3BB0A8C1_0x0045EDF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0045EF6C | 0.0% | Pending From 2755aa67e5c448bcffa2a877288194da61224939 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 12 Nov 2026 22:05:08 +0100 Subject: [PATCH 12/13] style: truth tests, parameter names and measured comments in round 10 From the fresh-eyes review. quick_diff is unchanged for all six files (1.0000, and the RightClick handler's 0.9655 both before and after, where it prints one global's address operand differently; reccmp reads it 100.0). - RightClickMenuAndMaybeResets: viewportState.field_0x0 and previewEnabled tested by truth, as main's other readers test them; the unused int parameter named unused. - TextEditor_Scrollbar: the parameters named unused and scrollbarEvent, as main's sibling Scrollbar handlers have them. - Why-comments on the three forms kept for the match, measured again on main c67521e1f: the scrollbar's second clamp after max (without it: 0.7126; the original tests again, test eax, eax; jge at 0x0045EE81), TacticalPowerBar's x and y read into locals while the icon calls re-read the globals (inline: 0.8776), and OverlaySlider's title position in locals, y first (inline: 0.7039). - MissionEndscreen's tab comment on one line; EventSlider's "-" comment moved off the macro's argument list, to the line above the call. Co-Authored-By: Claude Opus 5.5 --- .../General/MenuItemRenderFunction_General_EventSlider.cpp | 2 +- ...ctionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp | 6 +++--- .../MenuItemRenderFunction_MissionEndscreen_Main.cpp | 3 +-- .../MenuItemRenderFunction_OverlaySlider_Slider.cpp | 2 ++ .../MenuItemRenderFunction_TacticalPowerBar_Main.cpp | 1 + .../MenuItemActionHandler_TextEditor_Scrollbar.cpp | 5 +++-- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp index 8725899019..301caac4df 100644 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp @@ -81,8 +81,8 @@ namespace UI { DAT_ButtonY::instance + DAT_ButtonH::instance - 4, COL_DARK_LIME::instance.shortValue); } if (slider == -2 && value == 10) { + // "-" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, - // "-" DAT_TextManagerObject::ptr)(s___005a2280, DAT_ButtonX::instance + DAT_ButtonW::instance + 12, DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE, 0); diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp index bc73998a9b..589b9cb1df 100644 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp @@ -16,10 +16,10 @@ namespace UI { namespace MenuItems { // FUNCTION: STRONGHOLDCRUSADER 0x00438B60 - void InGameMenu::MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets(int param_1, ...) + void InGameMenu::MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets(int unused, ...) { DAT_MouseState::instance.mouseBasedEvent = 0; - if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { + if (!DAT_ViewportRenderState::instance.viewportState.field_0x0) { return; } if (!DAT_MouseState::instance.rightClickStart @@ -28,7 +28,7 @@ namespace UI { == OpenSHC::UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM || DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_SIEGETENT_SHIELD))) { - if (DAT_MouseState::instance.rightClickState && DAT_MouseState::instance.previewEnabled != 0) { + if (DAT_MouseState::instance.rightClickState && DAT_MouseState::instance.previewEnabled) { MACRO_CALL_MEMBER( OpenSHC::Input::MouseState_Func::updateRightDragCameraControl, DAT_MouseState::ptr)(); return; diff --git a/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp b/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp index 390ad08f91..ff8a3e5882 100644 --- a/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp @@ -37,8 +37,7 @@ namespace UI { if (buttonID == -2) { return; } - // the two tabs, -100 and -101: the selected one (0 or 2 for the first, 1 or 3 for the second) is drawn - // pressed + // tabs -100 and -101: the selected one (0 or 2 for -100, 1 or 3 for -101) is drawn pressed if ((buttonID == -100 && (INT_00ec082c::instance == 0 || INT_00ec082c::instance == 2)) || (buttonID == -101 && (INT_00ec082c::instance == 1 || INT_00ec082c::instance == 3))) { DAT_ButtonUnknownZero::instance = TRUE; diff --git a/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp index 86cf4516ec..58acd7eb8e 100644 --- a/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp +++ b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp @@ -29,6 +29,7 @@ namespace UI { DAT_ButtonX::instance + DAT_ButtonW::instance, DAT_ButtonY::instance + DAT_ButtonH::instance, 12); // the slider's title, drawn under the thumb if (DAT_MenuModalComposition2::instance.textGroup >= 0) { + // the title's position in locals, y first (inline: quick_diff 1.0000 -> 0.7039) int const textY = DAT_ButtonY::instance + 4; int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( @@ -51,6 +52,7 @@ namespace UI { } // a thumb as wide as the slider covers the title, so it is drawn again over it if (thumbHeight == DAT_ButtonW::instance && DAT_MenuModalComposition2::instance.textGroup >= 0) { + // the title's position in locals, y first (inline: quick_diff 1.0000 -> 0.7039) int const textY = DAT_ButtonY::instance + 4; int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( diff --git a/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp b/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp index 8c0bd8a055..1cfb9b8f56 100644 --- a/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp @@ -24,6 +24,7 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x004D9EC0 void TacticalPowerBar::MenuItemRenderFunction_TacticalPowerBar_Main(int slot, ...) { + // y, then x, into locals; the icon calls re-read the globals (inline: quick_diff 1.0000 -> 0.8776) int const buttonY = DAT_ButtonY::instance; int const buttonX = DAT_ButtonX::instance; int const level diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp index 03de6a346d..e3389e74dd 100644 --- a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp @@ -8,7 +8,7 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x0045EDF0 void TextEditor::MenuItemActionHandler_TextEditor_Scrollbar( - int param_1, int action, int* minValue, int* maxValue, int* currentValue) + int unused, int scrollbarEvent, int* minValue, int* maxValue, int* currentValue) { // the arrows scroll a twentieth of the text, at least one line int const step = max(max(DAT_TextEditorState::instance.topVisibleLineIndex @@ -16,12 +16,13 @@ namespace UI { 0) / 20, 1); - switch (action) { + switch (scrollbarEvent) { case 1: *minValue = 0; *maxValue = max(DAT_TextEditorState::instance.topVisibleLineIndex - DAT_TextEditorState::instance.dialogContentHeight, 0); + // clamped again after max, as the original does (without it: quick_diff 1.0000 -> 0.7126) if (*maxValue < 0) { *maxValue = 0; } From 9f7516ea68576e123937c02ce6baeb8740cb41cb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 16:39:09 +0100 Subject: [PATCH 13/13] style: comments give the reason without measurements in round 10 Four comments carried quick_diff numbers; the numbers belong in the PR text, so the comments keep only the reason: the OverlaySlider render's title positions (two), the TacticalPowerBar render's icon positions and the TextEditor scrollbar handler's second clamp. Comments only, no code change. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_OverlaySlider_Slider.cpp | 4 ++-- .../MenuItemRenderFunction_TacticalPowerBar_Main.cpp | 2 +- .../TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp index 58acd7eb8e..378da24b63 100644 --- a/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp +++ b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp @@ -29,7 +29,7 @@ namespace UI { DAT_ButtonX::instance + DAT_ButtonW::instance, DAT_ButtonY::instance + DAT_ButtonH::instance, 12); // the slider's title, drawn under the thumb if (DAT_MenuModalComposition2::instance.textGroup >= 0) { - // the title's position in locals, y first (inline: quick_diff 1.0000 -> 0.7039) + // the title's position in locals, y first, as the original reads it int const textY = DAT_ButtonY::instance + 4; int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( @@ -52,7 +52,7 @@ namespace UI { } // a thumb as wide as the slider covers the title, so it is drawn again over it if (thumbHeight == DAT_ButtonW::instance && DAT_MenuModalComposition2::instance.textGroup >= 0) { - // the title's position in locals, y first (inline: quick_diff 1.0000 -> 0.7039) + // the title's position in locals, y first, as the original reads it int const textY = DAT_ButtonY::instance + 4; int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( diff --git a/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp b/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp index 1cfb9b8f56..31f9083cec 100644 --- a/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp @@ -24,7 +24,7 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x004D9EC0 void TacticalPowerBar::MenuItemRenderFunction_TacticalPowerBar_Main(int slot, ...) { - // y, then x, into locals; the icon calls re-read the globals (inline: quick_diff 1.0000 -> 0.8776) + // y, then x, into locals; the icon calls re-read the globals, as the original does int const buttonY = DAT_ButtonY::instance; int const buttonX = DAT_ButtonX::instance; int const level diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp index e3389e74dd..15c5151399 100644 --- a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp @@ -22,7 +22,7 @@ namespace UI { *maxValue = max(DAT_TextEditorState::instance.topVisibleLineIndex - DAT_TextEditorState::instance.dialogContentHeight, 0); - // clamped again after max, as the original does (without it: quick_diff 1.0000 -> 0.7126) + // clamped again after max, as the original does if (*maxValue < 0) { *maxValue = 0; }