Skip to content
Merged
41 changes: 41 additions & 0 deletions src/OpenSHC/UI/Helpers/InitTutorialState.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "../Helpers.func.hpp"

#include "OpenSHC/Globals/DAT_00df5558.hpp"
#include "OpenSHC/Globals/DAT_00df555c.hpp"
#include "OpenSHC/Globals/DAT_00df5560.hpp"
#include "OpenSHC/Globals/DAT_00df556c.hpp"
#include "OpenSHC/Globals/DAT_DisableTutorialRestrictions.hpp"
#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp"
#include "OpenSHC/Globals/DAT_TutorialCurrentStep.hpp"
#include "OpenSHC/Globals/INT_00df5554.hpp"
#include "OpenSHC/Globals/INT_00df5564.hpp"
#include "OpenSHC/Globals/INT_ARRAY_00df5598.hpp"

namespace OpenSHC {
namespace UI {

// FUNCTION: STRONGHOLDCRUSADER 0x004BC6F0
void Helpers::InitTutorialState()
{
// The main menu's tutorial button calls this once the tutorial map is loaded
MACRO_CALL(OpenSHC::UI::Helpers_Func::InitTutorialStepTransition)(1);
DAT_00df555c::instance = DAT_MissionAestheticsDefinedData::instance.TutorialStepActionCount[0];
DAT_DisableTutorialRestrictions::instance = FALSE;
DAT_TutorialCurrentStep::instance = 0;
INT_00df5554::instance = 32;
DAT_00df5558::instance = 0;
DAT_00df5560::instance = 0;
INT_00df5564::instance = 0;
DAT_00df556c::instance = 36;
// Where each step starts: two past the previous start, plus the previous step's action count
int start = 1;
for (int step = 0; step < countof(INT_ARRAY_00df5598::instance); ++step) {
++start;
INT_ARRAY_00df5598::instance[step] = start;
start += DAT_MissionAestheticsDefinedData::instance.TutorialStepActionCount[step] + 1;
}
MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetTutorialActionTrackers)();
}

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

#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp"
#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/Text/UserTextHandler.func.hpp"
#include "OpenSHC/UI/Helpers.func.hpp"
#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp"
#include "OpenSHC/DE/SHCDE/eTextSections.hpp"
#include "OpenSHC/Game/GameMode.hpp"
#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp"
#include "OpenSHC/Rendering/Enums/RenderTarget.hpp"
#include "OpenSHC/Text/TextAlignment.hpp"
#include "OpenSHC/UI/Enums/MenuModalType.hpp"

#include "OpenSHC/Globals/COL_DARK_LIME.hpp"
#include "OpenSHC/Globals/DAT_00b960dc.hpp"
#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.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_GameSynchronyState.hpp"
#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp"
#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"
#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

// FUNCTION: STRONGHOLDCRUSADER 0x0042AC90
void LobbyMenu::MenuItemRenderFunction_LobbyMenu_ChatBox(int buttonID, ...)
{
if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) {
return;
}
if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE
&& DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_SEND_MAP_TO
&& DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_RECEIVE_MAP_FROM
&& MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) {
return;
}
int const blend = DAT_ButtonBackgroundBlendStrength::instance - 32;
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU;
// Nested, not early returns (early returns: quick_diff 0.9671 -> 0.6184)
if (buttonID != -3) {
if (buttonID != -2) {
// the waiting room's texts, and for -1 the player's own name
if (buttonID != -1) {
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2,
DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, buttonID,
DAT_ButtonX::instance, DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_LEFT,
OpenSHC::Rendering::Colors::COL_00A2FF, OpenSHC::Rendering::Colors::COL_003E66, 17, FALSE,
blend * 32 / 32 + 32);
return;
}
MACRO_CALL_MEMBER(
OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)(
DAT_GameSynchronyState::instance
.DAT_PlayerNames[DAT_GameSynchronyState::instance.currentPlayerSlotID],
DAT_ButtonX::instance, DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_LEFT,
OpenSHC::Rendering::Colors::COL_00A2FF, OpenSHC::Rendering::Colors::COL_003E66, 17, FALSE,
blend * 32 / 32 + 32);
return;
}
// -2: the line being typed, with the cursor behind it
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox,
DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance + 2,
DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance - 2,
blend * 16 / 32 + 32);
int const cursorX
= MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextWidthUntilCurrentCursor,
DAT_UserTextHandlerState::ptr)();
if (DAT_00b960dc::instance == 0) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox,
DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 2,
DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonH::instance + DAT_ButtonY::instance - 2,
COL_DARK_LIME::instance.shortValue);
}
// the blend strength read again after the calls (the blend local: quick_diff 0.9671 -> 0.8803)
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow,
DAT_TextManagerObject::ptr)(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getCurrentText,
DAT_UserTextHandlerState::ptr)(),
DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT,
OpenSHC::Rendering::Colors::COL_FFFFFF, OpenSHC::Rendering::Colors::COL_000000, 19, FALSE,
(DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32);
return;
}
// -3: the chat messages
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox,
DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance + 3,
DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance,
blend * 16 / 32 + 32);
MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::renderChatMessageList,
DAT_GameSynchronyState::ptr)(DAT_ButtonX::instance + 8,
DAT_ButtonH::instance + DAT_ButtonY::instance - 31, DAT_GameSynchronyState::instance.chatScrollOffset);
}

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

#include "OpenSHC/Global.func.hpp"
#include "OpenSHC/IO/ResourceManager.func.hpp"
#include "OpenSHC/OS.func.hpp"
#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/UI/Helpers.func.hpp"
#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp"
#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp"
#include "OpenSHC/IO/Graphics/GmID.hpp"
#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp"
#include "OpenSHC/Rendering/Enums/RenderTarget.hpp"
#include "OpenSHC/Text/TextAlignment.hpp"
#include "OpenSHC/UI/Enums/MenuModalType.hpp"

#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.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_GameSynchronyState.hpp"
#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp"
#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp"
#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp"
#include "OpenSHC/Globals/DAT_ResourceManager.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

// FUNCTION: STRONGHOLDCRUSADER 0x0042B4C0
void LobbyMenu::MenuItemRenderFunction_LobbyMenu_MapSelectTable(int row, ...)
{
if (MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) {
return;
}
// TRUE for the host while an AI setup dialog is open (no flag: quick_diff 0.9781 -> 0.9607)
BOOLEnum const aiSetupOpen
= DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE
|| DAT_MenuModalComposition1::instance.activeModalDialogID
== OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT
|| DAT_MenuModalComposition1::instance.activeModalDialogID
== OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT;
if (aiSetupOpen) {
DAT_ButtonUnknownZero::instance = TRUE;
}
if (!aiSetupOpen || !DAT_GameSynchronyState::instance.isHost) {
DAT_ButtonUnknownZero::instance = FALSE;
}
// for a guest, -1 marks another map than the host's and 1 the host's map
int hostMap = 0;
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU;
if (!DAT_GameSynchronyState::instance.isHost) {
hostMap = -1;
DAT_ButtonCurrentlyInteracting::instance = FALSE;
if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row
< DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber
&& MACRO_CALL(OpenSHC::OS_Func::__stricmp)(
MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex,
DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance
.DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset
+ row]),
DAT_GameSynchronyState::instance.mapName)
== 0) {
hostMap = 1;
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground,
DAT_PencilRenderCore::ptr)(TRUE, row, DAT_ButtonBackgroundBlendStrength::instance);
} else {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground,
DAT_PencilRenderCore::ptr)(FALSE, row, DAT_ButtonBackgroundBlendStrength::instance);
}
} else {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground,
DAT_PencilRenderCore::ptr)(row == DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected,
row, DAT_ButtonBackgroundBlendStrength::instance);
}
if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row
>= DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber) {
return;
}
int iconsWidth = 0;
uint color;
if (DAT_GameSynchronyState::instance.unknownMapRelatedReceivedDataArray[DAT_MenuTextInputState::instance
.DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]]
<= 0) {
color = OpenSHC::Rendering::Colors::COL_7F7F7F;
} else if ((row == DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected
|| DAT_ButtonCurrentlyInteracting::instance || hostMap == 1)
&& hostMap >= 0) {
color = OpenSHC::Rendering::Colors::COL_CCFAFF;
} else {
color = OpenSHC::Rendering::Colors::COL_C2F0EB;
}
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(
DAT_GameSynchronyState::instance.mapPlayerCountArray[DAT_MenuTextInputState::instance
.DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]],
DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, color, 18, FALSE,
(DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32);
if (DAT_GameSynchronyState::instance.mapBalanceArray[DAT_MenuTextInputState::instance
.DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]]
!= 0) {
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU;
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 210,
DAT_ButtonX::instance + 24, DAT_ButtonY::instance + 5, DAT_ButtonBackgroundBlendStrength::instance);
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME;
iconsWidth = 20;
}
// declared once for both calls (at each call: quick_diff 0.9781 -> 0.9649)
int descriptionGroup;
if (DAT_GameSynchronyState::instance.mapU4Int0_2Array[DAT_MenuTextInputState::instance
.DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]]
!= 0) {
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU;
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 394,
DAT_ButtonX::instance + 24 + iconsWidth, DAT_ButtonY::instance + 5,
DAT_ButtonBackgroundBlendStrength::instance);
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME;
// The file name in a local (as an argument: quick_diff 0.9781 -> 0.9518)
char* const loadedName = MACRO_CALL_MEMBER(
OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, DAT_ResourceManager::ptr)(
DAT_MenuTextInputState::instance
.DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]);
char* const mapName
= MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)(loadedName, &descriptionGroup);
DAT_TextManagerObject::instance.field_0x30 = 1;
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)(
mapName, DAT_ButtonX::instance + 44 + iconsWidth, DAT_ButtonY::instance + 3, 150 - iconsWidth,
color, 18, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32);
return;
}
char* const loadedName
= MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex,
DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance
.DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]);
char* const mapName
= MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)(loadedName, &descriptionGroup);
DAT_TextManagerObject::instance.field_0x30 = 1;
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)(
mapName, DAT_ButtonX::instance + 24 + iconsWidth, DAT_ButtonY::instance + 3, 170 - iconsWidth, color,
18, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32);
}

}
}
}
Loading
Loading