Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c8ff9d9
reimplement: SHC_3BB0A8C1_0x0047C860 65.3% Reimplemented
kotijekriv Nov 7, 2026
be9edd1
reimplement: SHC_3BB0A8C1_0x004AAB50 41.0% Reimplemented
kotijekriv Nov 7, 2026
e01e709
reimplement: SHC_3BB0A8C1_0x0047D190 66.9% Reimplemented
kotijekriv Nov 7, 2026
f860f20
reimplement: SHC_3BB0A8C1_0x00493560 96.3% Reimplemented
kotijekriv Nov 7, 2026
8f2719d
reimplement: SHC_3BB0A8C1_0x004B1AC0 76.1% Reimplemented
kotijekriv Nov 7, 2026
2ec470f
reimplement: SHC_3BB0A8C1_0x004AF860 78.7% Reimplemented
kotijekriv Nov 7, 2026
d0fbcd5
reimplement: SHC_3BB0A8C1_0x004AFB30 82.0% Reimplemented
kotijekriv Nov 7, 2026
8aa5e9c
reimplement: SHC_3BB0A8C1_0x004B0390 62.0% Reimplemented
kotijekriv Nov 7, 2026
8543e6b
reimplement: SHC_3BB0A8C1_0x00471340 32.8% Reimplemented
kotijekriv Nov 7, 2026
ea42833
reimplement: SHC_3BB0A8C1_0x004710A0 38.9% Reimplemented
kotijekriv Nov 7, 2026
3e7ec7e
reimplement: SHC_3BB0A8C1_0x00468F20 4.5% Reimplemented
kotijekriv Nov 7, 2026
402dc08
reimplement: SHC_3BB0A8C1_0x00468FE0 52.0% Reimplemented
kotijekriv Nov 7, 2026
9c437b0
reimplement: SHC_3BB0A8C1_0x00475CC0 52.4% Reimplemented
kotijekriv Nov 7, 2026
cfbab8e
reimplement: SHC_3BB0A8C1_0x00472B20 56.3% Reimplemented
kotijekriv Nov 7, 2026
2c99182
reimplement: SHC_3BB0A8C1_0x00468F70 9.3% Reimplemented
kotijekriv Nov 7, 2026
074c788
reimplement: SHC_3BB0A8C1_0x004690E0 60.1% Reimplemented
kotijekriv Nov 7, 2026
4d8dc93
reimplement: SHC_3BB0A8C1_0x004692E0 78.4% Reimplemented
kotijekriv Nov 7, 2026
7736f7e
status: the draft's remarks say what is left, not Reimplemented
kotijekriv Nov 7, 2026
d00cf56
Merge main (eef6f667a, gynt's header sync) into reimpl/UI-A-areas-dev…
kotijekriv Nov 7, 2026
afe0a5b
drafts: drop five PencilRenderCore drafts that reimpl/UI-PencilRender…
kotijekriv Nov 7, 2026
6e510e6
drafts: drop three PencilRenderCore drafts that reimpl/UI-PencilRende…
kotijekriv Nov 7, 2026
be147ca
reimplement: SHC_3BB0A8C1_0x004692E0 89.7% drawTableCellBackground
kotijekriv Nov 7, 2026
a204486
drafts: move the Roundtable render to the ready PR
kotijekriv Nov 19, 2026
2b09210
drafts: move MenuModalRenderFunction_CreditsScroll to the ready PR
kotijekriv Nov 20, 2026
d3f9831
drafts: move RenderInGameWinDefeatWindowDisplayElement to the ready PR
kotijekriv Nov 20, 2026
5485692
reimplement: SHC_3BB0A8C1_0x0047C860 65.1% the modem box's top was 34…
kotijekriv Nov 20, 2026
68b56e4
reimplement: SHC_3BB0A8C1_0x004692E0 95.2% the right piece in the fir…
kotijekriv Nov 20, 2026
a8d6492
drafts: move the load and save progress bar's box to the ready PR
kotijekriv Nov 22, 2026
cd54c52
drafts: move the network service provider modal to the ready PR
kotijekriv Nov 22, 2026
e58da0e
drafts: move the finding-sessions modal to the ready PR
kotijekriv Nov 23, 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
107 changes: 107 additions & 0 deletions src/OpenSHC/UI/DisplayElements/RenderDebugNumbersDisplayElement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include "../DisplayElements.func.hpp"

#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp"
#include "OpenSHC/Text/TextAlignment.hpp"
#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp"

#include "OpenSHC/Globals/DAT_CurrentFramerate.hpp"
#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_GameLoopDurationBuffer.hpp"
#include "OpenSHC/Globals/DAT_GameLoopStopwatch.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_TickRateBuffer.hpp"
#include "OpenSHC/Globals/INT_GameLoopTimeDataIndex.hpp"

namespace OpenSHC {
namespace UI {

// FUNCTION: STRONGHOLDCRUSADER 0x004AF860
void DisplayElements::RenderDebugNumbersDisplayElement(int posX, int posY, DWORD elementState)
{
int* _millisecLoopPointer;
int _tickRateSum;
int _averageMillisecLoopMain;
dword _lastGameLoopDuration;
dword _lastGameTickRate;
int _loopAddressByteCounter;
_lastGameTickRate = DAT_GameCore::instance.gameTicksThisLoop;
_lastGameLoopDuration = DAT_GameLoopStopwatch::instance.duration_0x0;
DAT_GameLoopDurationBuffer::instance[INT_GameLoopTimeDataIndex::instance] = _lastGameLoopDuration;
DAT_TickRateBuffer::instance[INT_GameLoopTimeDataIndex::instance] = _lastGameTickRate;
++INT_GameLoopTimeDataIndex::instance;
_tickRateSum = 0;
int _gameLoopDurationBufferSum = 0;
if (INT_GameLoopTimeDataIndex::instance == 100) {
INT_GameLoopTimeDataIndex::instance = 0;
}
// Maybe this is an enrolled loop? -TheRedDaemon
int _loopIndex = 0;
do {
_gameLoopDurationBufferSum = _gameLoopDurationBufferSum + DAT_GameLoopDurationBuffer::instance[_loopIndex]
+ DAT_GameLoopDurationBuffer::instance[_loopIndex + 1]
+ DAT_GameLoopDurationBuffer::instance[_loopIndex + 2]
+ DAT_GameLoopDurationBuffer::instance[_loopIndex + 4]
+ DAT_GameLoopDurationBuffer::instance[_loopIndex + 3];
_tickRateSum = _tickRateSum + DAT_TickRateBuffer::instance[_loopIndex + 4]
+ DAT_TickRateBuffer::instance[_loopIndex + 3] + DAT_TickRateBuffer::instance[_loopIndex + 2]
+ DAT_TickRateBuffer::instance[_loopIndex + 1] + DAT_TickRateBuffer::instance[_loopIndex];
_loopIndex += 5;
} while (_loopIndex < 100);
_averageMillisecLoopMain = _gameLoopDurationBufferSum / 100;
if ((int)elementState != -1000) {
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(
_lastGameLoopDuration, posX, posY + 5, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_0080FF,
0, 15, FALSE, 0);
}
int _maxLoopDurationOfTheLast100 = -1;
_millisecLoopPointer = DAT_GameLoopDurationBuffer::instance;
do {
if (_millisecLoopPointer[0] > _maxLoopDurationOfTheLast100) {
_maxLoopDurationOfTheLast100 = _millisecLoopPointer[0];
}
if (_millisecLoopPointer[1] > _maxLoopDurationOfTheLast100) {
_maxLoopDurationOfTheLast100 = _millisecLoopPointer[1];
}
if (_millisecLoopPointer[2] > _maxLoopDurationOfTheLast100) {
_maxLoopDurationOfTheLast100
= _millisecLoopPointer[2]; // written out as in the draft; not tried as a loop
}
if (_millisecLoopPointer[3] > _maxLoopDurationOfTheLast100) {
_maxLoopDurationOfTheLast100 = _millisecLoopPointer[3];
}
if (_millisecLoopPointer[4] > _maxLoopDurationOfTheLast100) {
_maxLoopDurationOfTheLast100 = _millisecLoopPointer[4];
}
_millisecLoopPointer += 5;
} while (_millisecLoopPointer < DAT_GameLoopDurationBuffer::instance + 100);
if ((int)elementState != -1000) {
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(
_averageMillisecLoopMain, posX + 48, posY, OpenSHC::Text::TTA_LEFT,
OpenSHC::Rendering::Colors::COL_0080FF, 0, 17, FALSE, 0);
}
if (_averageMillisecLoopMain == 0) {
_averageMillisecLoopMain = 1;
}
if ((int)elementState != -1000) {
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(
1000 / _averageMillisecLoopMain, posX + 48, posY + 20, OpenSHC::Text::TTA_LEFT,
OpenSHC::Rendering::Colors::COL_0080FF, 0, 17, FALSE, 0);
}
DAT_CurrentFramerate::instance = 1000 / _averageMillisecLoopMain;
if (_tickRateSum == 0) {
_tickRateSum = 1;
}
int _someRelationBetweenLoopDurationAndTickrate = _gameLoopDurationBufferSum / _tickRateSum;
if (_someRelationBetweenLoopDurationAndTickrate == 0) {
_someRelationBetweenLoopDurationAndTickrate = 1;
}
if ((int)elementState != -1000) {
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(
1000 / _someRelationBetweenLoopDurationAndTickrate, posX + 48, posY + 40, OpenSHC::Text::TTA_LEFT,
OpenSHC::Rendering::Colors::COL_0080FF, 0, 17, FALSE, 0);
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
#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/Rendering/Colors/ColorsEnum.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::Map::Buildings::BuildingTypeShort;

// 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 -= 40;
} else if (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_MERCENARYPOST) {
posY -= 40;
} else {
posY -= 20;
}
}
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 (720 <= 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 + 204, 16);
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)(
OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, DAT_00df5530::instance + 204, posX, posY - 20,
OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, 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], 16);
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 + 40, posY,
OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0);
int iconX = posX + (-48 - halfWidth);
if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[DAT_00df5530::instance] == -1) {
aiIndex = DAT_GameSynchronyState::instance.currentAIArray[DAT_00df5530::instance];
}
int iconY = posY - 38;
MACRO_CALL_MEMBER(
OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, DAT_00df5530::instance + 546, 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, 539, 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, 540, iconX, iconY);
} else if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[DAT_00df5530::instance + 19]) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 541, iconX, iconY);
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFace,
DAT_TextureRenderCoreObject::ptr)(DAT_00df5530::instance + 19, iconX + 4, posY - 34);
}
} else {
MACRO_CALL_MEMBER(
OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, aiIndex + 522, 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 + 493, iconX + 76, iconY);
} else {
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)(
DAT_GameSynchronyState::instance.DAT_PlayerNames[DAT_00df5530::instance], posX + 40, posY,
OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, (int)(blendStrength));
int iconX = posX + (-48 - halfWidth);
if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[DAT_00df5530::instance] == -1) {
aiIndex = DAT_GameSynchronyState::instance.currentAIArray[DAT_00df5530::instance];
}
int iconY = posY - 38;
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2,
DAT_00df5530::instance + 546, 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, 539, 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, 540, iconX, iconY, (int)(blendStrength));
} else if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[DAT_00df5530::instance + 19]) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(
OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 541, iconX, iconY, (int)(blendStrength));
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFaceWithBlendUnk,
DAT_TextureRenderCoreObject::ptr)(
DAT_00df5530::instance + 19, iconX + 4, posY - 34, (int)(blendStrength));
}
} else {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(
OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, aiIndex + 522, 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 + 493,
iconX + 76, iconY, (int)(blendStrength));
}
}
}
}
Loading