Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dab4474
Copy 8 functions from gynt's catch-all branches to reimpl/ui-menuview…
gynt Nov 28, 2026
05d7ccf
Fix compile errors against main's headers
gynt Nov 28, 2026
18140ef
reimplement: status of 8 ported functions
gynt Nov 28, 2026
4479e4e
UI menu views: HistoricMissionIntro and ScenarioDescription_Prepare
gynt Nov 28, 2026
455e546
UI menu views: CampaignUnk_Prepare and ScenarioDescription_DoEveryFrame
gynt Nov 28, 2026
3926541
UI: reimplement SomeFearFactorComputation
gynt Nov 28, 2026
e256b61
UI: CampaignUnk_Prepare counts changed missions in the global itself
gynt Nov 29, 2026
1554ece
UI: HistoricMissionIntro adds the border after the text offset
gynt Nov 29, 2026
10e1741
UI: ScenarioDescription frame reset falls into the shared render
gynt Nov 29, 2026
34e57b5
UI: rewrite RenderStatusMenu_Overview from the original's evaluation …
gynt Nov 29, 2026
625b3b1
UI: rewrite CrusadeMap_DoEveryFrame from the original control flow
gynt Nov 29, 2026
0fe08e7
UI: rewrite RankingGames_DoEveryFrame from the original control flow
gynt Nov 29, 2026
543a657
UI: RankingGames row offsets start from the row y, x advances in place
gynt Nov 29, 2026
284b1e5
UI: PlayerInfoOnHover resets aiIndex in the blended branch
gynt Nov 29, 2026
baa8c88
types: SkMasters2 version, count and entries as one SkMasters2Data gl…
gynt Nov 29, 2026
fa984d8
UI: RankingGames row advances x to the number column before the hover…
gynt Nov 29, 2026
2bf42c4
UI: RankingGames trail-filter label position read before the turn-off…
gynt Nov 29, 2026
e3e5c0d
UI: RankingGames skips empty rows with their own row advance
gynt Nov 29, 2026
a9afcb1
UI: CrusadeMap shows the extreme trail's mission number as progress + 1
gynt Nov 29, 2026
038cf2d
Merge origin/main into reimpl/ui-menuviews-modals-development
gynt Dec 2, 2026
39e8f58
Merge origin/main into reimpl/ui-menuviews-modals-development
gynt Dec 3, 2026
59aefc6
status: HistoricMissionIntro_DoEveryFrame at 92.5 after the main merge
gynt Dec 3, 2026
a2a3722
reimplement: SHC_3BB0A8C1_0x0043E5A0 100.00% SomeFearFactorComputation
gynt Dec 4, 2026
2e50e5a
reimplement: SHC_3BB0A8C1_0x00447DC0 100.00% RenderStatusMenu_Overview
gynt Dec 4, 2026
eb160b5
reimplement: SHC_3BB0A8C1_0x004DB8B0 96.23% HistoricMissionIntro sums
gynt Dec 4, 2026
01770ef
reimplement: SHC_3BB0A8C1_0x004DD350 90.69% ScenarioDescription_DoEve…
gynt Dec 4, 2026
dba5943
reimplement: SHC_3BB0A8C1_0x004DFB90 80.42% RankingGames row-loop locals
gynt Dec 4, 2026
b3a0a73
reimplement: SHC_3BB0A8C1_0x004DE300 75.3% CrusadeMap volatile post-l…
gynt Dec 4, 2026
0c9caa5
reimplement: SHC_3BB0A8C1_0x004DCC90 98.25% CampaignUnk row loop via …
gynt Dec 4, 2026
94e72b9
Merge remote-tracking branch 'origin/main' into reimpl/ui-menuviews-m…
gynt Dec 5, 2026
92e3955
Status lines for the #529 rows after the main merge
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
2 changes: 2 additions & 0 deletions cmake/compiler-flags-gl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ src/OpenSHC/Map/Units/UpdateHunter.cpp
src/OpenSHC/Map/Units/UpdateAppleFarmer.cpp
src/OpenSHC/Map/Units/UpdateJester.cpp
src/OpenSHC/Map/Units/UpdateSlave.cpp
src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Overview.cpp
src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp
src/OpenSHC/Map/Units/UpdateHealer.cpp
src/OpenSHC/Map/Units/UpdateSpearman.cpp
src/OpenSHC/Map/Units/UpdateSlinger.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
#include "../DisplayElements.func.hpp"

#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp"
#include "OpenSHC/DE/SHCDE/eGM.hpp"
#include "OpenSHC/DE/SHCDE/eTextSections.hpp"
#include "OpenSHC/Game/GameMode.hpp"
#include "OpenSHC/Game/GameMode2.hpp"
#include "OpenSHC/IO/Graphics/GmID.hpp"
#include "OpenSHC/Map/Buildings/BuildingType.hpp"
#include "OpenSHC/Map/Buildings/BuildingTypeShort.hpp"
#include "OpenSHC/Text/TextAlignment.hpp"
#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp"
#include "OpenSHC/UI/Enums/MenuModalType.hpp"
#include "OpenSHC/UI/Enums/MenuViewType.hpp"
#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp"

#include "OpenSHC/Globals/DAT_00df5530.hpp"
#include "OpenSHC/Globals/DAT_BuildingsState.hpp"
#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_GameState.hpp"
#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp"
#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"
#include "OpenSHC/Globals/DAT_TileMapState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"
#include "OpenSHC/Globals/INT_00df552c.hpp"

namespace OpenSHC {
namespace UI {

using OpenSHC::DE::SHCDE::eGM;
using OpenSHC::DE::SHCDE::eTextSections;
using OpenSHC::Game::GameMode;
using OpenSHC::Game::GameMode2;
using OpenSHC::IO::Graphics::GmID;
using OpenSHC::Map::Buildings::BuildingType;
using OpenSHC::Map::Buildings::BuildingTypeShort;
using OpenSHC::Text::TextAlignment;
using OpenSHC::UI::Enums::BuildingsAndStatusMenuTabType;
using OpenSHC::UI::Enums::MenuModalType;
using OpenSHC::UI::Enums::MenuViewType;
using OpenSHC::WindowsHelper::Enums::BOOLEnum;

// FUNCTION: STRONGHOLDCRUSADER 0x004B0390
void DisplayElements::RenderPlayerInfoOnHoverDisplayElement(int posX, int posY, DWORD elementState)
{
int aiIndex = 0;
if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) {
if (DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_BUILD_MENU)
return;
if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR)
return;
}
int hoveredOwner = 0;
if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU) {
if (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM) {
posY = posY + -0x28;
} else if (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_MERCENARYPOST) {
posY = posY + -0x28;
} else {
posY = posY + -0x14;
}
}
if ((DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID == 0)
|| (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0)) {
if (DAT_ViewportRenderState::instance.viewportState.cursorWallTile != 0
&& DAT_ViewportRenderState::instance.viewportState.field_0x0 != 0
&& (hoveredOwner
= (DAT_TileMapState::instance
.WallOwnerLayer[DAT_ViewportRenderState::instance.viewportState.cursorWallTile]
& 7)
+ 1,
DAT_GameCore::instance.mapU4Int0 != 0)
&& hoveredOwner == DAT_GameState::instance.mapAndTime.somePlayerID)
return;
} else {
BuildingTypeShort _buildingType
= DAT_BuildingsState::instance
.buildings[DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID]
.buildingType;
if (_buildingType == OpenSHC::Map::Buildings::BT_PITCHDITCH)
return;
if (_buildingType == OpenSHC::Map::Buildings::BT_KILLINGPIT)
return;
if (_buildingType == OpenSHC::Map::Buildings::BT_SIGNPOST)
return;
if ((DAT_GameCore::instance.mapU4Int0 != 0)
&& (DAT_BuildingsState::instance
.buildings[DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID]
.owner
== DAT_GameState::instance.mapAndTime.somePlayerID))
return;
hoveredOwner = (int)DAT_BuildingsState::instance
.buildings[DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID]
.owner;
}
if (DAT_MenuModalComposition2::instance.activeModalDialogID
== OpenSHC::UI::Enums::MMT_DISPLAY_AI_LORD_MESSAGE) {
DAT_00df5530::instance = 0;
return;
}
uint blendStrength = 0;
if (hoveredOwner != 0) {
DAT_00df5530::instance = hoveredOwner;
INT_00df552c::instance = timeGetTime();
} else if (DAT_00df5530::instance != 0) {
uint elapsed = timeGetTime() - INT_00df552c::instance;
if (0x2d0 <= elapsed) {
DAT_00df5530::instance = 0;
} else if (400 < elapsed) {
blendStrength = (elapsed - 400) / 10;
}
}
if ((DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU)
&& (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR)) {
if (DAT_00df5530::instance == 0)
return;
MACRO_CALL_MEMBER(
OpenSHC::Text::TextManager_Func::computeTextWidthForTextGroup, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, DAT_00df5530::instance + 0xcc, 0x10);
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, DAT_00df5530::instance + 0xcc, posX, posY + -0x14,
OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 0, 0x10, FALSE);
return;
}
if (DAT_00df5530::instance == 0)
return;
int textWidth = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth,
DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[DAT_00df5530::instance], 0x10);
int halfWidth = textWidth / 2;
if (blendStrength == 0) {
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)(
DAT_GameSynchronyState::instance.DAT_PlayerNames[DAT_00df5530::instance], posX + 0x28, posY,
OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 0, 0x10, FALSE, 0);
int iconX = posX + (-0x30 - halfWidth);
if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[DAT_00df5530::instance] == -1) {
aiIndex = DAT_GameSynchronyState::instance.currentAIArray[DAT_00df5530::instance];
}
int iconY = posY + -0x26;
MACRO_CALL_MEMBER(
OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, DAT_00df5530::instance + 0x222, iconX, iconY);
if (aiIndex == 0) {
if (DAT_GameCore::instance.lordIcons[DAT_00df5530::instance] == 0) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 0x21b, iconX, iconY);
} else if (DAT_GameCore::instance.lordIcons[DAT_00df5530::instance] == 1) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 0x21c, iconX, iconY);
} else if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[DAT_00df5530::instance + 0x13]) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 0x21d, iconX, iconY);
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFace,
DAT_TextureRenderCoreObject::ptr)(DAT_00df5530::instance + 0x13, iconX + 4, posY + -0x22);
}
} else {
MACRO_CALL_MEMBER(
OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, aiIndex + 0x20a, iconX, iconY);
}
int playerGroup = DAT_GameState::instance.mapAndTime.playerGroupArray[DAT_00df5530::instance];
if (playerGroup <= 0)
return;
MACRO_CALL_MEMBER(
OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, playerGroup * 2 + 0x1ed, iconX + 0x4c, iconY);
} else {
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)(
DAT_GameSynchronyState::instance.DAT_PlayerNames[DAT_00df5530::instance], posX + 0x28, posY,
OpenSHC::Text::TTA_CENTER, 0xc2f0eb, 0, 0x10, FALSE, (int)(blendStrength));
int iconX = posX + (-0x30 - halfWidth);
aiIndex = 0;
if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[DAT_00df5530::instance] == -1) {
aiIndex = DAT_GameSynchronyState::instance.currentAIArray[DAT_00df5530::instance];
}
int iconY = posY + -0x26;
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2,
DAT_00df5530::instance + 0x222, iconX, iconY, (int)(blendStrength));
if (aiIndex == 0) {
if (DAT_GameCore::instance.lordIcons[DAT_00df5530::instance] == 0) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(
OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 0x21b, iconX, iconY, (int)(blendStrength));
} else if (DAT_GameCore::instance.lordIcons[DAT_00df5530::instance] == 1) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(
OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 0x21c, iconX, iconY, (int)(blendStrength));
} else if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[DAT_00df5530::instance + 0x13]) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(
OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 0x21d, iconX, iconY, (int)(blendStrength));
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFaceWithBlendUnk,
DAT_TextureRenderCoreObject::ptr)(
DAT_00df5530::instance + 0x13, iconX + 4, posY + -0x22, (int)(blendStrength));
}
} else {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(
OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, aiIndex + 0x20a, iconX, iconY, (int)(blendStrength));
}
int playerGroup = DAT_GameState::instance.mapAndTime.playerGroupArray[DAT_00df5530::instance];
if (playerGroup <= 0)
return;
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, playerGroup * 2 + 0x1ed,
iconX + 0x4c, iconY, (int)(blendStrength));
}
}
}
}
40 changes: 40 additions & 0 deletions src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "../Helpers.func.hpp"

#include "OpenSHC/Globals/DAT_GameState.hpp"
#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp"

namespace OpenSHC {
namespace UI {

// FUNCTION: STRONGHOLDCRUSADER 0x0043E5A0
undefined4 Helpers::SomeFearFactorComputation()
{
// Picks a message number from the player's fear factor level (-5 .. 5).
int const fearFactor
= DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID]
.fearFactorLevel;
if (fearFactor <= -5) {
return 14;
}
if (fearFactor <= -3) {
return 15;
}
if (fearFactor <= -1) {
return 16;
}
if (fearFactor >= 5) {
return 19;
}
if (fearFactor >= 3) {
return 18;
}
// 0 .. 2. The test is always true here, but it is what keeps MSVC from folding the
// 17/18 pair above into a setge (the original loads 18 before the jge).
if (fearFactor >= 0) {
return 17;
}
return 17;
}

}
}
Loading