Skip to content
Merged
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
50e92ca
reimplement: SHC_3BB0A8C1_0x004BBF40 100.0% Reimplemented
kotijekriv Nov 6, 2026
181b559
headers: MenuItemActionHandler_InGameMenu_Scrolling takes no parameters
kotijekriv Nov 6, 2026
1572310
headers: SoundEffectID values 254 to 256 as SEID_UNKNOWN_<hex>
kotijekriv Nov 6, 2026
af487f0
reimplement: SHC_3BB0A8C1_0x0042A840 100.0% Reimplemented
kotijekriv Nov 6, 2026
8a87286
reimplement: SHC_3BB0A8C1_0x004D99F0 100.0% Reimplemented
kotijekriv Nov 6, 2026
9904af3
reimplement: SHC_3BB0A8C1_0x00442C30 100.0% Reimplemented
kotijekriv Nov 6, 2026
463995c
reimplement: SHC_3BB0A8C1_0x0047E420 100.0% Reimplemented
kotijekriv Nov 6, 2026
9af1b9a
reimplement: SHC_3BB0A8C1_0x00434120 100.0% Reimplemented
kotijekriv Nov 6, 2026
4b5ead5
reimplement: SHC_3BB0A8C1_0x00442F40 100.0% Reimplemented
kotijekriv Nov 6, 2026
26e26d4
reimplement: SHC_3BB0A8C1_0x0047CCA0 100.0% Reimplemented
kotijekriv Nov 6, 2026
73c2f57
Merge main (8125c61c2, gynt's header sync with our Scrolling() and SE…
kotijekriv Nov 6, 2026
3e4c4c1
Merge main (1c294596c, #355) into reimpl/UI-MenuItems-9-100
kotijekriv Nov 7, 2026
0bc6102
headers: DAT_SH1_SiegeAdvancedMode is a BOOLEnum
kotijekriv Nov 7, 2026
d4c1b5e
headers: DAT_StoredGameMode is a GameModeInt
kotijekriv Nov 7, 2026
18f83c2
headers: DAT_SkirmishTrailRelated1 is an int
kotijekriv Nov 7, 2026
b78dc7c
headers: MissionDefinedData.descending is a BOOLEnum
kotijekriv Nov 7, 2026
67b91e0
headers: TileMapState.wallDragButtonUp is a BOOLEnum
kotijekriv Nov 7, 2026
df6428e
CrusadeMapAndEndscreen: drop the (int) cast DAT_SkirmishTrailRelated1…
kotijekriv Nov 7, 2026
9b3d5a0
SingleplayerMapChoice_MapTable: store TRUE in DAT_SH1_SiegeAdvancedMode
kotijekriv Nov 7, 2026
e5c6b15
Merge main (eef6f667a, gynt's header sync) into reimpl/UI-MenuItems-9…
kotijekriv Nov 7, 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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace UI {
int const textY = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 583;
int const textX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 400;
// one call per caption, merged but for the index (an index local: quick_diff 0.9464 -> 0.8468)
if ((int)DAT_SkirmishTrailRelated1::instance > 0) {
if (DAT_SkirmishTrailRelated1::instance > 0) {
// "Skip Current Mission"
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#include "../General.func.hpp"

#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/Text/UserTextHandler.func.hpp"
#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp"
#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp"
#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp"
#include "OpenSHC/Rendering/Enums/RenderTarget.hpp"
#include "OpenSHC/Text/TextAlignment.hpp"
#include "OpenSHC/Text/TextArrayIndexType.hpp"
#include "OpenSHC/UI/Enums/MenuViewType.hpp"

#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp"
#include "OpenSHC/Globals/COL_DARK_LIME.hpp"
#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp"
#include "OpenSHC/Globals/DAT_ButtonH.hpp"
#include "OpenSHC/Globals/DAT_ButtonX.hpp"
#include "OpenSHC/Globals/DAT_ButtonY.hpp"
#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

// FUNCTION: STRONGHOLDCRUSADER 0x0047CCA0
void General::MenuItemRenderFunction_General_TextInputDisplay(int field, ...)
{
// == TRUE: the original compares with 1 (a truthiness test: quick_diff 0.9664 -> 0.9365); field 3, the
// title box, is hidden while a title is set
if (field == 3 && DAT_GameCore::instance.isNameEntryActive == TRUE) {
return;
}
int const cursorX = MACRO_CALL_MEMBER(
OpenSHC::Text::UserTextHandler_Func::getTextWidthUntilCurrentCursor, DAT_UserTextHandlerState::ptr)();
DAT_ButtonCurrentlyInteracting::instance = FALSE;
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton,
AlphaAndButtonSurfaceObj::ptr)(-1, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED);
// the cursor at the typing position, then the text 6 pixels in from the corner
// the text in each case, merged but for the index (one call after the switch: quick_diff 0.9664 -> 0.9365)
switch (field) {
case 0: {
// fields 0 and 1 show the cursor only while their text is the one being typed
if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_FIVE__NUMERIC_DOT) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox,
DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3,
DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4,
COL_DARK_LIME::instance.shortValue);
}
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonX::instance + 6;
char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer,
DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_FIVE__NUMERIC_DOT);
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(
text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0);
break;
}
case 1: {
if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_SIX__NUMERIC_ONLY) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox,
DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3,
DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4,
COL_DARK_LIME::instance.shortValue);
}
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonX::instance + 6;
char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer,
DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_SIX__NUMERIC_ONLY);
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(
text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0);
break;
}
case 2: {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox,
DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3,
DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4,
COL_DARK_LIME::instance.shortValue);
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonX::instance + 6;
char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer,
DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_SEVEN__NUMERIC_ONLY);
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(
text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0);
break;
}
case 3: {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox,
DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3,
DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4,
COL_DARK_LIME::instance.shortValue);
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonX::instance + 6;
char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer,
DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_ZERO);
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(
text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0);
break;
}
case 4: {
// outside the main menu this field is drawn on the map's surface
if (DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_MAIN_MENU) {
DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME;
DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME;
}
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox,
DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3,
DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4,
COL_DARK_LIME::instance.shortValue);
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonX::instance + 6;
char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer,
DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_ZERO);
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(
text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0);
DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU;
DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU;
break;
}
}
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include "../InGameMenu.func.hpp"

#include "OpenSHC/Rendering/ViewportRenderState.func.hpp"
#include "OpenSHC/UI/DisplayElements.func.hpp"
#include "OpenSHC/UI/Helpers.func.hpp"
#include "OpenSHC/UI/ScrollingHandler.func.hpp"
#include "OpenSHC/Game/GameMode2.hpp"
#include "OpenSHC/UI/Enums/DisplayElementID.hpp"

#include "OpenSHC/Globals/DAT_CurrentFramerate.hpp"
#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_MouseState.hpp"
#include "OpenSHC/Globals/DAT_ScrollingHandler.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

// FUNCTION: STRONGHOLDCRUSADER 0x00434120
void InGameMenu::MenuItemActionHandler_InGameMenu_Scrolling()
{
if (!MACRO_CALL(OpenSHC::UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)(
OpenSHC::UI::Enums::DEID_DEBUG_NUMBERS)) {
// element state -1000 updates the frame rate below without drawing the debug numbers
MACRO_CALL(OpenSHC::UI::DisplayElements_Func::RenderDebugNumbersDisplayElement)(0, 0, -1000);
}
if (DAT_MouseState::instance.selectionBoxMode != 0) {
return;
}
if (DAT_MouseState::instance.rightClickState) {
return;
}
int scrollDistance = MACRO_CALL_MEMBER(
OpenSHC::UI::ScrollingHandler_Func::getScrollDistanceBaseUnk, DAT_ScrollingHandler::ptr)();
if (scrollDistance == 0) {
return;
}
// below the game speed's frame rate the step grows by speed / ((speed + frame rate) / 2), making up for
// part of the slowdown
if (DAT_CurrentFramerate::instance < DAT_GameCore::instance.gameSpeedLevel
&& DAT_CurrentFramerate::instance != 0) {
scrollDistance = DAT_GameCore::instance.gameSpeedLevel * scrollDistance
/ ((DAT_GameCore::instance.gameSpeedLevel - DAT_CurrentFramerate::instance) / 2
+ DAT_CurrentFramerate::instance);
}
switch (DAT_ScrollingHandler::instance.scrollDirection_0x4) {
case OpenSHC::UI::SD_UP:
DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance;
break;
case OpenSHC::UI::SD_UP_RIGHT:
DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance;
// falls through to the step right
case OpenSHC::UI::SD_RIGHT:
DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance;
break;
case OpenSHC::UI::SD_DOWN_RIGHT:
DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance;
DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance;
break;
case OpenSHC::UI::SD_DOWN:
DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance;
break;
case OpenSHC::UI::SD_DOWN_LEFT:
DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance;
DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance;
break;
case OpenSHC::UI::SD_UP_LEFT:
DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance;
// falls through to the step left
case OpenSHC::UI::SD_LEFT:
DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance;
break;
}
MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::setViewportBasedOnMapSize,
DAT_ViewportRenderState::ptr)();
// tutorial action 1: the player scrolled the view
if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) {
MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(1);
}
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "../LobbyMenu.func.hpp"

#include "OpenSHC/Audio/SFX/SFXState.func.hpp"
#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp"
#include "OpenSHC/Audio/SFX/SoundEffectID.hpp"
#include "OpenSHC/Commands/GameCommandType.hpp"

#include "OpenSHC/Globals/DAT_00b960dc.hpp"
#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp"
#include "OpenSHC/Globals/DAT_SFXState.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

// FUNCTION: STRONGHOLDCRUSADER 0x0042A840
void LobbyMenu::MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance(int button, ...)
{
if (DAT_00b960dc::instance != 0) {
return;
}
// only the host changes the game type and the balance
if (!DAT_GameSynchronyState::instance.isHost) {
return;
}
// button 4 draws the balance bar and button 20 the game type panel: clicking them changes nothing
if (button == 4 || button == 20) {
return;
}
// buttons 1 to 3 pick the game type
if (button >= 1 && button <= 3) {
DAT_GameSynchronyState::instance.skirmishGameIntensityType = button;
}
// the balance buttons start at 10 and set balance 1 from there, 3 (button 12) being even
if (button >= 10) {
DAT_GameSynchronyState::instance.skirmishCurrentAdvantageBalance = button - 9;
// 256 at either end, 255 one step from even, 254 at even
if (button == 10 || button == 14) {
MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)(
OpenSHC::Audio::SFX::SEID_UNKNOWN_0x100);
}
if (button == 11 || button == 13) {
MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)(
OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFF);
}
if (button == 12) {
MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)(
OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFE);
}
}
MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)(
OpenSHC::Commands::GCT_CHANGE_GAME_INTENSITY_OR_BALANCE);
}

}
}
}
Loading
Loading