Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b3ef7ec
Copy 8 functions from gynt's catch-all branches to reimpl/ui-menuitem…
gynt Nov 28, 2026
95331bf
Fix compile errors against main's headers
gynt Nov 28, 2026
acf1351
reimplement: status of 8 ported functions
gynt Nov 28, 2026
f824fb4
UI menu items: three handlers rebuilt from the original layout
gynt Nov 28, 2026
1dbe810
UI: TextEditor scrollbar computes the top edge before the scrollbar call
gynt Nov 29, 2026
e4741e1
UI: BuildingWorkStatus fixes two decompiler bugs, rebuilt from the asm
gynt Nov 29, 2026
0ddf73a
UI: Roundtable_Main rebuilt from the asm, fixing three decompiler bugs
gynt Nov 29, 2026
dcfb284
UI: handleMenuElementsCallbacks restructured after the original layout
gynt Nov 29, 2026
b82df1e
UI: CreateEventCallback rebuilt per case, fixing a doubled dialog call
gynt Nov 29, 2026
d98e49d
UI: handleMenuElementsCallbacks drag reads the slider minimum once
gynt Nov 29, 2026
8c057dc
UI: handleMenuElementsCallbacks tests the click per item type
gynt Nov 30, 2026
c7af031
Merge origin/main into reimpl/ui-menuitems-development
gynt Dec 3, 2026
2c32f17
status: CreateEventCallbackFunction at 86.0 after the main merge
gynt Dec 3, 2026
cf7ee0c
reimplement: SHC_3BB0A8C1_0x004476B0 89.0% one renderText2 call, orig…
gynt Dec 4, 2026
c79fc33
reimplement: SHC_3BB0A8C1_0x004F4290 70.7% slider regs/frame 0x28 vs …
gynt Dec 4, 2026
16031bd
reimplement: SHC_3BB0A8C1_0x004C1770 86.98% zero reg ebp vs ebx
gynt Dec 4, 2026
bca929c
reimplement: SHC_3BB0A8C1_0x004C1770 89.96% CreateEvent shared spawnX…
gynt Dec 4, 2026
c3f7455
Merge remote-tracking branch 'origin/main' into reimpl/ui-menuitems-d…
gynt Dec 5, 2026
83efc36
CreateEventCallbackFunction: block-scoped spawn locals, inner cases b…
gynt Dec 5, 2026
9b5ea58
Status remarks for the remaining #530 rows
gynt Dec 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 366 additions & 0 deletions src/OpenSHC/UI/MenuItem/handleMenuElementsCallbacks.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
#include "../BuildingAndStatusMenu.func.hpp"

#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/UI/Rendering.func.hpp"
#include "OpenSHC/DE/SHCDE/eTextSections.hpp"
#include "OpenSHC/Map/Buildings/BuildingTypeShort.hpp"
#include "OpenSHC/Map/Units/States/UnitState.hpp"
#include "OpenSHC/Map/Units/UnitType.hpp"
#include "OpenSHC/Text/TextAlignment.hpp"
#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp"
#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp"

#include "OpenSHC/Globals/DAT_BuildingsState.hpp"
#include "OpenSHC/Globals/DAT_ButtonX.hpp"
#include "OpenSHC/Globals/DAT_ButtonY.hpp"
#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_UnitsState.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

using OpenSHC::DE::SHCDE::eTextSections;
using OpenSHC::Map::Buildings::BuildingTypeShort;
using OpenSHC::Map::Units::UnitType;
using OpenSHC::Map::Units::States::UnitState;
using OpenSHC::Text::TextAlignment;
using OpenSHC::UI::Enums::BuildingsAndStatusMenuTabType;
using OpenSHC::WindowsHelper::Enums::BOOLEnum;

// FUNCTION: STRONGHOLDCRUSADER 0x004476B0
void BuildingAndStatusMenu::MenuItemRenderFunction_BuildingAndStatusMenu_BuildingWorkStatus(int param_1, ...)
{
if (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_PEASANT) {
return;
}
short const employees
= DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.currentEmployeeCount;
BOOLEnum noPeasantWalking = TRUE;
if (employees == 0
&& DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.currentlyNeededEmployeeCount
== 0) {
return;
}
if (DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.buildingTypeBasedEmployeeCount
<= 0) {
return;
}
if (DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID].buildingType
>= 0x28
&& DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.buildingType
<= 0x2c) {
return;
}
if (DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID].buildingType
>= 0x24
&& DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.buildingType
<= 0x26) {
return;
}
if (DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.hasAccessToKeep
== 0) {
// "No access to keep"
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_IN_GENERAL_BUILDINGS, 9, DAT_ButtonX::instance + 0x96,
DAT_ButtonY::instance, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE);
return;
}
if (DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID].sleeping) {
// "Turned off"
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_IN_GENERAL_BUILDINGS, 7, DAT_ButtonX::instance + 0x96,
DAT_ButtonY::instance, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE);
return;
}
short needed = DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.currentlyNeededEmployeeCount;
if (needed != 0) {
int textID;
if (employees == 0) {
textID = 3;
} else {
textID = needed + 4;
}
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_IN_GENERAL_BUILDINGS, textID, DAT_ButtonX::instance + 0x96,
DAT_ButtonY::instance, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE);
return;
}
int unit;
for (int i = 0; i < employees; i++) {
unit = DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.workerID[i];
if (DAT_UnitsState::instance.units[unit].unitType == OpenSHC::Map::Units::UT_PEASANT) {
noPeasantWalking = FALSE;
}
}
if (!noPeasantWalking) {
// "Peasant on his way"
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_IN_GENERAL_BUILDINGS, 4, DAT_ButtonX::instance + 0x96,
DAT_ButtonY::instance, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE);
return;
}
switch (DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.buildingType) {
case OpenSHC::Map::Buildings::BT_MILL: {
int status = 100;
for (int i = 0; i < employees; i++) {
switch (DAT_UnitsState::instance
.units[DAT_BuildingsState::instance
.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.workerID[i]]
.state.generic) {
case OpenSHC::Map::Units::States::US_AIM_WEAPONUnk:
status = 0;
break;
case OpenSHC::Map::Units::States::US_STAND_UPUnk:
if (status > 1) {
status = 1;
}
break;
case OpenSHC::Map::Units::States::US_RELOAD_WEAPONUnk:
if (status > 2) {
status = 2;
}
break;
case ((UnitState)3):
if (status > 3) {
status = 3;
}
break;
case OpenSHC::Map::Units::States::US_DETERMINE_NEXT_STATEUnk:
case ((UnitState)2):
case OpenSHC::Map::Units::States::US_FIRE_WEAPONUnk:
case OpenSHC::Map::Units::States::US_LOOK_AROUNDUnk:
if (status > 4) {
status = 4;
}
break;
case OpenSHC::Map::Units::States::US_IDLEUnk:
if (status > 5) {
status = 5;
}
break;
}
}
if (status < 100) {
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_IN_MILL, status + 3, DAT_ButtonX::instance + 0x96,
DAT_ButtonY::instance, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE);
}
return;
}
case OpenSHC::Map::Buildings::BT_QUARRY:
// "Currently Functioning"
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_IN_GENERAL_BUILDINGS, 2, DAT_ButtonX::instance + 0x96,
DAT_ButtonY::instance, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE);
return;
case OpenSHC::Map::Buildings::BT_FLETCHER:
case OpenSHC::Map::Buildings::BT_BLACKSMITH:
case OpenSHC::Map::Buildings::BT_POLETURNER:
// "Worker:"
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_IN_GENERAL_BUILDINGS, 10, DAT_ButtonX::instance + 0x96,
DAT_ButtonY::instance - 10, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE);
MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderPeasantMenu_CurrentActionUnk)(
unit, DAT_ButtonX::instance + 0x96, DAT_ButtonY::instance + 10);
return;
case OpenSHC::Map::Buildings::BT_IRONMINE:
unit = DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.workerID[1];
default:
// "Worker:"
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_IN_GENERAL_BUILDINGS, 10, DAT_ButtonX::instance + 0x96,
DAT_ButtonY::instance - 20, OpenSHC::Text::TTA_LEFT, 0, 0x12, FALSE);
MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderPeasantMenu_CurrentActionUnk)(
unit, DAT_ButtonX::instance + 0x96, DAT_ButtonY::instance);
return;
}
}

}
}
}
Loading