diff --git a/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp new file mode 100644 index 0000000000..74127600a8 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp @@ -0,0 +1,438 @@ +#include "../Allies.func.hpp" + +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.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/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_00df42b0.hpp" +#include "OpenSHC/Globals/DAT_00df51f0.hpp" +#include "OpenSHC/Globals/DAT_00df51f4.hpp" +#include "OpenSHC/Globals/DAT_AlliesCount.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_LastTeamMemberIndex.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_SomeTeamMemberPlayerIDArray.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004AC7A0 + void Allies::MenuItemRenderFunction_Allies_Main(int param_1, ...) + { + BOOLEnum BVar1; + int iVar4; + int iVar5; + int iVar6; + int iVar7; + eTextSections textOffsetIndex; + int xParam; + int iVar2; + int iVar3; + if (param_1 == 100) { + return; + } + if (DAT_AlliesCount::instance < 1 && param_1 != -1) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + if ((param_1 == 110) || (param_1 == 111)) { + if (((DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestStateUnk + != 1) + || ((iVar3 = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerID_askerUnk, + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1 + || (iVar3 + != DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance])))) + && DAT_GameState::instance + .playerDataArray + [DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]] + .isNotNervousByEnemyTroopValue + == 0) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderButtonImageWithBlending)(); + } + if (param_1 == 200) { + if (DAT_00df51f4::instance == 0) { + return; + } + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, DAT_00df51f0::instance, (int)(DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_B8EEFB, 0, + 18, FALSE); + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + } + DAT_ButtonUnknownZero::instance = FALSE; + if (19 < (uint)param_1) { + MACRO_CALL( + OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); + if (!DAT_ButtonCurrentlyInteracting::instance) { + return; + } + if (param_1 == 20) { + DAT_00df51f4::instance = 1; + DAT_00df51f0::instance = 5; + } + if (param_1 == 21) { + DAT_00df51f4::instance = 1; + DAT_00df51f0::instance = 6; + } + if (param_1 != 22) { + return; + } + DAT_00df51f4::instance = 1; + DAT_00df51f0::instance = 7; + } + if (6 >= param_1) { + if (param_1 == 1) { + DAT_00df51f4::instance = 0; + } + iVar3 = param_1 - 1; + if (DAT_AlliesCount::instance <= iVar3) { + DAT_ButtonUnknownZero::instance = FALSE; + } + iVar6 = 0; + iVar2 = DAT_SomeTeamMemberPlayerIDArray::instance[iVar3]; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar2] == -1) { + iVar6 = DAT_GameSynchronyState::instance.currentAIArray[iVar2]; + } + if (iVar3 == DAT_LastTeamMemberIndex::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar2 + 546, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + if (iVar6 == 0) { + if (DAT_GameCore::instance.lordIcons[iVar2] == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 539, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + } else if (DAT_GameCore::instance.lordIcons[iVar2] == 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 540, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + } else if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[iVar2 + 19]) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 541, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFace, + DAT_TextureRenderCoreObject::ptr)( + iVar2 + 19, (int)(DAT_ButtonX::instance + 4), (int)(DAT_ButtonY::instance + 4)); + } + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar6 + 522, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + } + } else { + if (iVar6 == 0) { + if (DAT_GameCore::instance.lordIcons[iVar2] == 0) { + iVar6 = 539; + } else { + if (DAT_GameCore::instance.lordIcons[iVar2] != 1) { + if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[iVar2 + 19]) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, + 541, (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance), 12); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFaceWithBlendUnk, + DAT_TextureRenderCoreObject::ptr)(iVar2 + 19, (int)(DAT_ButtonX::instance + 4), + (int)(DAT_ButtonY::instance + 4), 12); + } + goto LAB_004aca47; + } + iVar6 = 540; + } + } else { + iVar6 += 522; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar6, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance), 12); + return; + } + LAB_004aca47: + if (iVar3 == DAT_LastTeamMemberIndex::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 514, + (int)(DAT_ButtonX::instance - 6), (int)(DAT_ButtonY::instance - 6), + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 513, 0); + return; + } + iVar6 = 0; + if (iVar3 != DAT_LastTeamMemberIndex::instance) { + iVar6 = 8; + } + iVar3 + = (int)DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestedGoodsArray1Unk[iVar2]; + if (iVar3 == 7) { + iVar3 = 8; + } + if (-1 < iVar3 - 2) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar3 + 578, + (int)(DAT_ButtonX::instance + 60), (int)(DAT_ButtonY::instance - 12), + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, iVar6); + } + if (DAT_GameState::instance.playerDataArray[iVar2].isNotNervousByEnemyTroopValue != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, + DAT_00df42b0::instance + 578, (int)(DAT_ButtonX::instance + 60), + (int)(DAT_ButtonY::instance + 60), OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, iVar6); + } + if (DAT_GameState::instance.playerDataArray[iVar2].requestStateUnk == 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 576, + (int)(DAT_ButtonX::instance - 15), (int)(DAT_ButtonY::instance + 57), + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 577, iVar6); + } + if (DAT_GameState::instance.playerDataArray[iVar2].requestStateUnk == 2) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 604, + (int)(DAT_ButtonX::instance - 15), (int)(DAT_ButtonY::instance + 57), + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 605, iVar6); + } + return; + } + if (param_1 != 10) { + DAT_ButtonUnknownZero::instance = FALSE; + } + iVar3 = DAT_ButtonX::instance; + iVar2 = DAT_ButtonY::instance; + iVar6 = 0; + if (0 < (int)DAT_ButtonH::instance) { + do { + if (iVar6 == 0) { + iVar5 = 1; + } else { + if (iVar6 == DAT_ButtonH::instance - 24) { + iVar5 = 13; + } else { + iVar5 = 7; + } + } + iVar7 = 0; + do { + iVar4 = iVar5; + if (iVar7 == 0) { + LAB_004acbeb: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, iVar4, + iVar7 + iVar3, iVar2 + iVar6, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, iVar4 + 3, + 0); + } else { + if (iVar7 == 624) { + iVar4 = iVar5 + 2; + goto LAB_004acbeb; + return; + } + if (iVar5 != 7) { + iVar4 = iVar5 + 1; + goto LAB_004acbeb; + } + } + iVar7 += 24; + } while (iVar7 < 648); + iVar6 += 24; + } while (iVar6 < (int)DAT_ButtonH::instance); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(iVar3 + 24, iVar2 + 24, iVar3 + 623, DAT_ButtonH::instance - 25 + iVar2, 20); + iVar3 = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; + iVar2 = DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3]; + if ((iVar2 == -1) + && (BVar1 = MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, DAT_GameSynchronyState::ptr)(iVar3), + !BVar1)) { + return; + } + iVar7 = DAT_ButtonY::instance; + iVar5 = DAT_ButtonX::instance; + iVar6 = DAT_ButtonX::instance + 24; + if (iVar2 == -1) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)(DAT_GameSynchronyState::instance.aiVariationArray[iVar3] + 103 + + DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 8), + iVar6, (int)(DAT_ButtonY::instance + 24), OpenSHC::Text::TTA_LEFT, + (uint)(DAT_RenderingDefinedData::instance + .ColorTable1[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[iVar3]]), + 0, 17, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], iVar6, (int)(DAT_ButtonY::instance + 24), + OpenSHC::Text::TTA_LEFT, + (uint)(DAT_RenderingDefinedData::instance + .ColorTable1[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[iVar3]]), + 0, 17, FALSE); + } + iVar2 = (int)DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestedGoodsArray1Unk[iVar3]; + if (iVar2 == 7) { + iVar2 = 8; + } + iVar4 = iVar7 + 56; + int bVar8 = -1 < iVar2 - 2; + if (bVar8) { + // added by script: "Requests" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 12, iVar6, iVar4, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderLeftAlignedNumberToScreen, DAT_TextManagerObject::ptr)( + (int)DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestedGoodsArray2Unk[iVar3], + iVar5 + 29, iVar4, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, 1); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar2 + 578, + DAT_TextManagerObject::instance.currentXOffset_0x0 + 10 + iVar6, iVar7 + 48, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, 0); + xParam = iVar5 + 69; + textOffsetIndex = OpenSHC::DE::SHCDE::TEXT_GOODS; + } else { + iVar2 = 1; + xParam = iVar6; + textOffsetIndex = OpenSHC::DE::SHCDE::TEXT_ALLIES; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(textOffsetIndex, + iVar2, xParam, iVar4, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, + (BOOLEnum)bVar8); + iVar2 = iVar7 + 88; + if (DAT_GameState::instance.playerDataArray[iVar3].requestStateUnk == 0) { + // added by script: "No Orders" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 2, iVar6, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } else { + // added by script: "Orders:" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 16, iVar6, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + if (DAT_GameState::instance.playerDataArray[iVar3].requestStateUnk == 1) { + // added by script: "Attack" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 10, iVar5 + 29, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } + if (DAT_GameState::instance.playerDataArray[iVar3].requestStateUnk == 2) { + // added by script: "Defend" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 17, iVar5 + 29, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } else { + iVar4 = DAT_GameState::instance.playerDataArray[iVar3].requestedAttackTargetUnk; + if (iVar4 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + // added by script: "You" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 18, iVar5 + 34, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } else { + iVar2 = iVar7 + 76; + iVar5 = DAT_TextManagerObject::instance.currentXOffset_0x0 + 10 + iVar6; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar4] == -1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar4 + 718, iVar5, iVar2); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + (int)(DAT_GameSynchronyState::instance.currentAIArray + [DAT_GameState::instance.playerDataArray[iVar3].requestedAttackTargetUnk] + + 700), + iVar5, iVar2); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar4 + 718, iVar5, iVar2); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, + DAT_TextureRenderCoreObject::ptr)( + DAT_GameState::instance.playerDataArray[iVar3].requestedAttackTargetUnk + 19, iVar5 + 2, + iVar7 + 78); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, + DAT_PencilRenderCore::ptr)( + iVar5, iVar2, iVar5 + 35, iVar7 + 111, (ushort)(COL_BLACK::instance.shortValue)); + } + } + } + } + if (DAT_GameState::instance.playerDataArray[iVar3].isNotNervousByEnemyTroopValue != 0) { + // added by script: "Help Needed!" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 4, iVar6, iVar7 + 120, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } + iVar2 = DAT_GameSynchronyState::instance.currentPlayerSlotID; + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestStateUnk + != 1) { + return; + } + iVar5 = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerID_askerUnk; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar5] == -1) { + return; + } + if (iVar5 != iVar3) { + return; + } + // added by script: "Attack" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 10, iVar6, iVar7 + 120, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + iVar6 += DAT_TextManagerObject::instance.currentXOffset_0x0 + 10; + iVar3 = DAT_GameState::instance.playerDataArray[iVar2].requestedAttackTargetUnk; + iVar5 = iVar7 + 115; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar3 + 718, iVar6, iVar5); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, + DAT_TextureRenderCoreObject::ptr)( + DAT_GameState::instance.playerDataArray[iVar2].requestedAttackTargetUnk + 19, iVar6 + 2, + iVar7 + 117); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + iVar6, iVar5, iVar6 + 35, iVar7 + 150, (ushort)(COL_BLACK::instance.shortValue)); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar3 + 718, iVar6, iVar5); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + (int)(DAT_GameSynchronyState::instance + .currentAIArray[DAT_GameState::instance.playerDataArray[iVar2].requestedAttackTargetUnk] + + 700), + iVar6, iVar5); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp new file mode 100644 index 0000000000..e913b4a295 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp @@ -0,0 +1,263 @@ +#include "../AlliesSendAndRequestGoods.func.hpp" + +#include "OpenSHC/AI/AICState.func.hpp" +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/Game/Resources/ResourceTypeInt.hpp" +#include "OpenSHC/Game/Resources/ResourceTypeMin1.hpp" +#include "OpenSHC/Game/Resources/ResourceTypeMin1Int.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00df4284.hpp" +#include "OpenSHC/Globals/DAT_AICState.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_LastTeamMemberIndex.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_RequestedGoodsByWhoArray.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SentOrRequestedGoodsAmount.hpp" +#include "OpenSHC/Globals/DAT_SomeTeamMemberPlayerIDArray.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Game::Resources::ResourceType; + using OpenSHC::Game::Resources::ResourceTypeInt; + using OpenSHC::Game::Resources::ResourceTypeMin1Int; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004B14C0 + void AlliesSendAndRequestGoods::MenuItemActionHandler_AlliesSendAndRequestGoods_Main(int param_1, ...) + { + BOOLEnum BVar1; + int iVar2; + int _space; + int playerID = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; + if (param_1 == 40) { + return; + } + if (param_1 < 21) { + DAT_RequestedGoodsByWhoArray::instance[0] = param_1; + if (4 <= param_1) { + DAT_RequestedGoodsByWhoArray::instance[0] = param_1 + 1; + } + if (5 <= param_1) { + ++DAT_RequestedGoodsByWhoArray::instance[0]; + } + if (DAT_RequestedGoodsByWhoArray::instance[0] != 14) { + return; + } + DAT_RequestedGoodsByWhoArray::instance[0] = 23; + return; + } + if (param_1 == 21) { + DAT_RequestedGoodsByWhoArray::instance[0] = 14; + } + if (param_1 == 50) { + DAT_SentOrRequestedGoodsAmount::instance += 10; + } + if (param_1 == 51) { + DAT_SentOrRequestedGoodsAmount::instance += 25; + } + if (param_1 == 52) { + DAT_SentOrRequestedGoodsAmount::instance += 100; + } + if (param_1 == 53) { + DAT_SentOrRequestedGoodsAmount::instance += 5; + } + if (param_1 != 54) { + if (param_1 == 102) { + DAT_RequestedGoodsByWhoArray::instance[0] = -1; + DAT_SentOrRequestedGoodsAmount::instance = 0; + if (DAT_MenuModalComposition1::instance.activeModalDialogID + != OpenSHC::UI::Enums::MMT_ALLIES_SEND_GOODS) { + DAT_RequestedGoodsByWhoArray::instance[0] = -1; + DAT_SentOrRequestedGoodsAmount::instance = 0; + } + if (DAT_00df4284::instance == 0) { + DAT_RequestedGoodsByWhoArray::instance[0] = -1; + DAT_SentOrRequestedGoodsAmount::instance = 0; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 3; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); + return; + } + if (param_1 != 100) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + } + if (0 <= DAT_RequestedGoodsByWhoArray::instance[0]) { + if ((int)DAT_SentOrRequestedGoodsAmount::instance <= 0) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_ALLIES_REQUEST_GOODS) { + if ((int*)(DAT_RequestedGoodsByWhoArray::instance[0] + 1) == (int*)15) { + BVar1 = MACRO_CALL_MEMBER( + OpenSHC::AI::AICState_Func::isResourceLargerOrEqualThanMinimumGoodsRequiredAfterTrade, + DAT_AICState::ptr)(playerID, OpenSHC::Game::Resources::RT_GOLD, + (int)(DAT_SentOrRequestedGoodsAmount::instance)); + } else { + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::getResourceSpace, + DAT_BuildingsState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + (OpenSHC::Game::Resources::ResourceType)(( + DAT_RequestedGoodsByWhoArray::instance[0] + 1))); + if (iVar2 == -1) { + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)( + 3, (ResourceType)((int)(DAT_RequestedGoodsByWhoArray::instance[0]))); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 6) { + // "No stockpile built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "space_warning2.wav" + DAT_SFXState::ptr)(s_space_warning2_wav_005a5950); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 5) { + // "No granary built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "space_warning1.wav" + DAT_SFXState::ptr)(s_space_warning1_wav_005a593c); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + != 7) { + DAT_MenuModalComposition1::instance.activeModalDialogID + = OpenSHC::UI::Enums::MMT_NONE; + } + // "No armory built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning3.wav" + s_space_warning3_wav_005a5928); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + if (iVar2 < (int)DAT_SentOrRequestedGoodsAmount::instance) { + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)( + 4, (ResourceType)((int)(DAT_RequestedGoodsByWhoArray::instance[0]))); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 9) { + // "No space in the stockpile" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "space_warning5.wav" + DAT_SFXState::ptr)(s_space_warning5_wav_005a50b0); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 8) { + // "No space in the granary" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "space_warning4.wav" + DAT_SFXState::ptr)(s_space_warning4_wav_005a5914); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + != 10) { + DAT_MenuModalComposition1::instance.activeModalDialogID + = OpenSHC::UI::Enums::MMT_NONE; + } + // "No space in the armory" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning6.wav" + s_space_warning6_wav_005a5900); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + return; + } + BVar1 = MACRO_CALL_MEMBER( + OpenSHC::AI::AICState_Func::isResourceLargerOrEqualThanMinimumGoodsRequiredAfterTrade, + DAT_AICState::ptr)(playerID, + (ResourceType)((int)(DAT_RequestedGoodsByWhoArray::instance[0] + + OpenSHC::Game::Resources::RT_LOGS)), + (int)(DAT_SentOrRequestedGoodsAmount::instance)); + } + if (BVar1) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 + = DAT_RequestedGoodsByWhoArray::instance[0]; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 + = DAT_SentOrRequestedGoodsAmount::instance; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::AI::AICState_Func::playGoodsNotSentBikFromPlayer, DAT_AICState::ptr)( + playerID); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + int _sendAmount = DAT_SentOrRequestedGoodsAmount::instance; + ResourceTypeMin1Int _resource + = DAT_RequestedGoodsByWhoArray::instance[0] + OpenSHC::Game::Resources::RTM_WOOD; + ResourceTypeInt _resourceType = _resource; + if (_resource == OpenSHC::Game::Resources::RTM_WHEAT) { + _resourceType = DAT_RequestedGoodsByWhoArray::instance[0]; + } + if (_resource == OpenSHC::Game::Resources::RTM_FLOUR) { + // gold + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[OpenSHC::Game::Resources::RT_GOLD] + < (int)DAT_SentOrRequestedGoodsAmount::instance) { + return; + } + } else { + _space = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::getResourceSpace, + DAT_BuildingsState::ptr)(playerID, (OpenSHC::Game::Resources::ResourceType)(_resourceType)); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[_resourceType] + < _sendAmount) { + return; + } + if (_space < 0) { + return; + } + if (_space < _sendAmount) { + _sendAmount = _space; + } + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 2; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = _resource; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = _sendAmount; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + } + return; + } + DAT_SentOrRequestedGoodsAmount::instance += 500; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp new file mode 100644 index 0000000000..9846cf7807 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp @@ -0,0 +1,221 @@ +#include "../AlliesSendAndRequestGoods.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.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_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_RequestedGoodsByWhoArray.hpp" +#include "OpenSHC/Globals/DAT_SentOrRequestedGoodsAmount.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004AD920 + void AlliesSendAndRequestGoods::MenuItemRenderFunction_AlliesSendAndRequestGoods_Main(int actionParam, ...) + { + int iVar1; + int iVar2; + int iVar3; + int iVar4; + eTextSections offsetIndex; + BOOLEnum keepOffsetX; + // first render resource type in condensed form + if (actionParam < 20) { + int _xOffset = 0; + if (actionParam == 6 || actionParam == 11 || actionParam == 20) { + _xOffset = 8; + } + // skip unusable resources + if (4 <= actionParam) { + ++actionParam; + } + if (6 <= actionParam) { + ++actionParam; + } + if (actionParam == 14) { + actionParam = 23; + } + int _gmID = actionParam * 2 + 617; + if (DAT_ButtonCurrentlyInteracting::instance) { + _gmID = actionParam * 2 + 618; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, _gmID, + DAT_ButtonX::instance + _xOffset, (int)(DAT_ButtonY::instance)); + if (actionParam == 7) { + actionParam = 6; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[actionParam + 1], + (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 19, FALSE, 0); + } else if (actionParam == 21) { + if (!DAT_ButtonCurrentlyInteracting::instance) { + iVar1 = 645; + } else { + iVar1 = 646; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[OpenSHC::Game::Resources::RT_GOLD], + (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 20), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 19, FALSE, 0); + return; + } + iVar1 = DAT_ButtonX::instance; + int iVar5 = DAT_ButtonY::instance; + // then draw the rest + if (actionParam == 40) { + // everything below belongs to actionParam == 40 only + if (0 < (int)DAT_ButtonH::instance) { + for (int iVar2 = 0; iVar2 < (int)DAT_ButtonH::instance; iVar2 = iVar2 + 24) { + if (iVar2 == 0) { + iVar3 = 1; + } else { + if (iVar2 == DAT_ButtonH::instance - 24) { + iVar3 = 13; + } else { + iVar3 = 7; + } + } + iVar4 = 0; + do { + int imageID = iVar3; + if (iVar4 == 0) { + LAB_004adacf: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + imageID, iVar4 + iVar1, iVar2 + iVar5, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + imageID + 3, 0); + } else { + if (iVar4 == 528) { + imageID = iVar3 + 2; + goto LAB_004adacf; + } + if (iVar3 != 7) { + imageID = iVar3 + 1; + goto LAB_004adacf; + } + return; + } + iVar4 += 24; + } while (iVar4 < 552); + } + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( + iVar1 + 24, iVar5 + 24, iVar1 + 527, DAT_ButtonH::instance - 25 + iVar5, 20); + if (DAT_RequestedGoodsByWhoArray::instance[0] == 6) { + iVar1 = 7; + LAB_004adb48: + if (DAT_SentOrRequestedGoodsAmount::instance != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_SentOrRequestedGoodsAmount::instance, (int)(DAT_ButtonX::instance + 36), + (int)(DAT_ButtonY::instance + 36), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 17, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1 * 2 + 618, + (int)(DAT_TextManagerObject::instance.currentXOffset_0x0 + 46 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 24)); + keepOffsetX = TRUE; + iVar1 = DAT_ButtonX::instance + 96; + iVar5 = DAT_RequestedGoodsByWhoArray::instance[0] + 1; + offsetIndex = OpenSHC::DE::SHCDE::TEXT_GOODS; + goto LAB_004adbc8; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1 * 2 + 618, + (int)(DAT_ButtonX::instance + 36), (int)(DAT_ButtonY::instance + 24)); + iVar1 = DAT_ButtonX::instance + 84; + iVar5 = 14; + } else { + iVar1 = DAT_RequestedGoodsByWhoArray::instance[0]; + if (0 < DAT_RequestedGoodsByWhoArray::instance[0]) + goto LAB_004adb48; + iVar1 = DAT_ButtonX::instance + 36; + iVar5 = 13; + } + keepOffsetX = FALSE; + offsetIndex = OpenSHC::DE::SHCDE::TEXT_ALLIES; + LAB_004adbc8: + iVar2 = DAT_ButtonY::instance + 36; + iVar4 = 0; + iVar3 = 17; + // added by script: "Choose Goods" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(offsetIndex, iVar5), + iVar1, iVar2, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, iVar3, keepOffsetX, + iVar4); + return; + } + if (100 <= actionParam) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderButtonImageWithBlending)(); + return; + } + // the original ends this bound with `jl`, so 0x32 is inside it; written as + // `50 <` the `actionParam == 0x32` test below could never be true + if (50 <= actionParam) { + MACRO_CALL( + OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); + if (actionParam == 50) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(10, + (int)(DAT_ButtonX::instance + 18), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 51) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(25, + (int)(DAT_ButtonX::instance + 15), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 52) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(100, + (int)(DAT_ButtonX::instance + 12), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 53) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(5, + (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 54) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(500, + (int)(DAT_ButtonX::instance + 11), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp new file mode 100644 index 0000000000..53a980eb96 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp @@ -0,0 +1,313 @@ +#include "../BuildMenu.func.hpp" + +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/Units/Behavior/UnitStanceEnum.hpp" +#include "OpenSHC/Map/Units/UnitType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_00ee1090.hpp" +#include "OpenSHC/Globals/DAT_00ee1094.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_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TribesState.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Map::Units::UnitType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00438BE0 + void BuildMenu::MenuItemRenderFunction_BuildMenu_UnitActionButtons(int mapperValue, ...) + { + BOOLEnum BVar1; + int iVar2; + int yPosition; + uint uVar3; + UnitType UVar4; + int xPosition; + uint color2; + int fontSize; + BVar1 = MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::isMapperAvailable, + DAT_MapPropertiesState::ptr)((OpenSHC::Commands::MappersEnum)mapperValue); + if (!BVar1) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + switch ((int)DAT_CurrentButtonGmDataIndex::instance) { + case 376: + // Without an engineer selected the button hides, as in the original (jne to the shared hide). + if (DAT_UnitsState::instance.hasEngineerSelected == TRUE) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + return; + } + break; + case 374: + DAT_00ee1094::instance = 291; + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) + && (!DAT_UnitsState::instance.hasEngineerSelected)) { + uVar3 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)(); + if (uVar3 != 0) + goto LAB_00438ec1; + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::countSelectedCatapultsAndTrebuchets, + DAT_UnitsState::ptr)(); + if (iVar2 != 0) { + DAT_00ee1094::instance = 308; + DAT_CurrentButtonGmDataIndex::instance = 377; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + } + break; + case 218: + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT + && !DAT_UnitsState::instance.hasEngineerSelected + && (uVar3 + = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getTunnelerIDOnlyIfFirstSelected, + DAT_UnitsState::ptr)(), + uVar3 != 0)) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + break; + case 220: + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT + && (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY + || (( + DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + || (DAT_GameState::instance.mapAndTime.skirmishNoCowThrowing == 0)))) + && !DAT_UnitsState::instance.hasEngineerSelected + && (uVar3 + = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getFirstSelectedUnitOfEitherType, + DAT_UnitsState::ptr)(39, 40), + uVar3 != 0 + && (0 < DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .availableCows))) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + BVar1 = FALSE; + yPosition = DAT_ButtonY::instance + 2; + xPosition = DAT_ButtonX::instance + 2; + fontSize = 19; + color2 = 0; + uVar3 = 16777215; + iVar2 + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .availableCows; + LAB_00438e95: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber, DAT_TextManagerObject::ptr)( + iVar2, xPosition, yPosition, uVar3, color2, fontSize, BVar1); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + break; + case 219: + DAT_00ee1090::instance = 202; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT + && !DAT_UnitsState::instance.hasEngineerSelected) { + BVar1 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::selectionContainsEngineersOnly, DAT_UnitsState::ptr)(); + if (BVar1) { + uVar3 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getSelectedEngineerCarryingResource, + DAT_UnitsState::ptr)(); + if (uVar3 != 0) { + DAT_CurrentButtonGmDataIndex::instance = 210; + DAT_00ee1090::instance = 198; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + } else { + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::selectionContainsTunnelersOnly, + DAT_UnitsState::ptr)(); + if (iVar2 != 0) { + DAT_CurrentButtonGmDataIndex::instance = 218; + DAT_00ee1090::instance = 201; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + uVar3 + = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getFirstSelectedUnitOfEitherType, + DAT_UnitsState::ptr)(39, 40); + if (uVar3 != 0) { + DAT_CurrentButtonGmDataIndex::instance = 375; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + BVar1 = FALSE; + fontSize = 19; + color2 = 0; + uVar3 = 16777215; + yPosition = DAT_ButtonY::instance + 2; + xPosition = DAT_ButtonX::instance + 2; + iVar2 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getMaxStoneAmmoInSelectedSiegeEngines, + DAT_UnitsState::ptr)(); + goto LAB_00438e95; + } + BVar1 + = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::selectionContainsRangedOnlyUnits, + DAT_UnitsState::ptr)(); + if (BVar1) { + DAT_CurrentButtonGmDataIndex::instance = 375; + goto LAB_00438ec1; + } + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::selectionContainsLaddermenOnly, + DAT_UnitsState::ptr)(); + if ((iVar2 == 0) + && (iVar2 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::selectionContainsShieldmenOnly, + DAT_UnitsState::ptr)(), + iVar2 == 0)) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + } + } + break; + case 370: + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance + == OpenSHC::Map::Units::Behavior::USE_STAND_GROUND) { + DAT_ButtonY::instance -= 5; + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + goto LAB_00438f47; + case 371: + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance + == OpenSHC::Map::Units::Behavior::USE_DEFENSIVE) { + --DAT_ButtonY::instance; + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + goto LAB_00438f47; + case 372: + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance + == OpenSHC::Map::Units::Behavior::USE_AGGRESSIVE) { + --DAT_ButtonY::instance; + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + LAB_00438f47: + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + case 216: + if (DAT_UnitsState::instance.hasEngineerSelected) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_TribesState::instance.patrolButtonPressed) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + goto LAB_00438ec1; + case 211: + case 212: + case 213: + case 214: + case 215: + case 558: + if (DAT_UnitsState::instance.hasEngineerSelected != TRUE) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + uVar3 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)(); + if (uVar3 == 0) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + goto LAB_00438ec1; + default: + if (DAT_UnitsState::instance.hasEngineerSelected) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + LAB_00438ec1: + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + DAT_ButtonUnknownZero::instance = TRUE; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp new file mode 100644 index 0000000000..48c6068ed9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp @@ -0,0 +1,173 @@ +#include "../BuildingAndStatusMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/BOOL_CurrentMenuClickState.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace BuildingAndStatusMenu { + + using Game::Resources::ResourceType; + + // FUNCTION: STRONGHOLDCRUSADER 0x00467040 + void MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands(int param_1, ...) + { + // Buttons 2 and 3 step through the goods (partial pitch shows as pitch), 0 buys and 1 sells. + if (param_1 == 2) { + int resource = MACRO_CALL_MEMBER(Game::GameStateStructures_Func::getPreviousGoodsFilteringUnallowed, + DAT_GameState::ptr)((ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (resource == Game::Resources::RT_PARTIALPITCH) { + resource = Game::Resources::RT_PITCH; + } + MACRO_CALL( + BuildingAndStatusMenu_Func::MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)( + resource); + return; + } + if (param_1 == 3) { + int resource = MACRO_CALL_MEMBER(Game::GameStateStructures_Func::getNextGoodFilteringUnallowed, + DAT_GameState::ptr)((ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (resource == Game::Resources::RT_PARTIALPITCH) { + resource = Game::Resources::RT_PITCH; + } + MACRO_CALL( + BuildingAndStatusMenu_Func::MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)( + resource); + return; + } + BOOL_CurrentMenuClickState::instance = FALSE; + if (param_1 == 0) { + int const price = MACRO_CALL_MEMBER(Game::GameStateStructures_Func::getBatchBuyPrice, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[Game::Resources::RT_GOLD] + < price) { + MACRO_CALL(Actions_Func::SetStorageMarketFailState)(1, + (ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + // "space_warning8.wav": not enough gold + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning8_wav_005a5964); + return; + } + int const space = MACRO_CALL_MEMBER(Map::Buildings::BuildingsState_Func::getResourceSpace, + DAT_BuildingsState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + (ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (space == -1) { + MACRO_CALL(Actions_Func::SetStorageMarketFailState)(3, + (ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 6) { + // "space_warning2.wav": no stockpile built + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning2_wav_005a5950); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 5) { + // "space_warning1.wav": no granary built + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning1_wav_005a593c); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 7) { + // "space_warning3.wav": no armory built + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning3_wav_005a5928); + } + return; + } + if (space < 5) { + MACRO_CALL(Actions_Func::SetStorageMarketFailState)(4, + (ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 9) { + // "space_warning5.wav": no space in the stockpile + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning5_wav_005a50b0); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 8) { + // "space_warning4.wav": no space in the granary + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning4_wav_005a5914); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 10) { + // "space_warning6.wav": no space in the armory + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning6_wav_005a5900); + } + return; + } + } else if (param_1 == 1) { + ResourceType const resource + = (ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType; + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[resource] + <= 0) { + MACRO_CALL(Actions_Func::SetStorageMarketFailState)(2, resource); + // "space_warning7.wav": not enough goods + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning7_wav_005a58ec); + return; + } + } + if (param_1 == 0 || param_1 == 1) { + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + Audio::SFX::SEID_DRAWBRIDGE_CONTROL); + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState = 0; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = param_1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_BUY_OR_SELL); + } + + } + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp new file mode 100644 index 0000000000..e0a9ade9ca --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp @@ -0,0 +1,370 @@ +// disable deprecation warnings for strcpy and strcat +#pragma warning(disable : 4996) + +#include "../General.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/Skirmish.func.hpp" +#include "OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure.func.hpp" +#include "OpenSHC/IO/FilePackager.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/MenuItems/CustomScenarios.func.hpp" +#include "OpenSHC/UI/MenuItems/HistoricCampaignSelect.func.hpp" +#include "OpenSHC/UI/MenuItems/MainMenu.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/DE/SHCDE/eMusicIDs.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/GameModeInt.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" +#include "OpenSHC/string-macros.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_SoundEffectsHelperData1.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/FilePackagerObj.hpp" +#include "OpenSHC/Globals/SEC_SkirmishLobbySetupStructure.hpp" +#include "OpenSHC/Globals/UI_MissionModeIntent.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using UI::Enums::MenuViewType; + + // FUNCTION: STRONGHOLDCRUSADER 0x00494950 + void General::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk(int param_1, ...) + { + OpenSHC::Game::GameModeInt GVar1; + char* pcVar2; + char* pcVar3; + MenuViewType menuID; + GVar1 = DAT_GameSynchronyState::instance.currentGameMode; + if (param_1 != 22) { + if (param_1 == 23) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 2000) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 1; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(Commands::GCT_START_OR_STOP_SEND_MAP_FILEUnk); + } + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47) { + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerDeathRelated = 0; + MACRO_CALL_MEMBER( + Map::MapPropertiesState_Func::activateScenarioTypeEvents, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::createScenarioEventForNextMonth, + DAT_MapPropertiesState::ptr)(); + DAT_GameCore::instance.section1095 = 2; + } + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + goto LAB_00495061; + } + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter < 44) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 43) { + DAT_GameCore::instance.isTimeHalted2 = 0; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_CUSTOM_SCENARIOS, 0); + goto LAB_00494b4a; + } + switch (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter) { + case 7: + break; + case 9: + MACRO_CALL_MEMBER( + Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); + DAT_WindowAndDirectDraw::instance.postWindowCloseMessage = 1; + DAT_GameCore::instance.currentlyInGameUnk_0xa4 = FALSE; + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case 30: + if ((DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY) + && (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SKIRMISH_SINGLE_PLAYER)) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = DAT_GameCore::instance.mapTimeInTicks; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 + = MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::computeSomeHashOnUnitArray, + DAT_GameSynchronyState::ptr)(); + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = 0; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(Commands::GCT_SAVE); + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 32; + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(UI::Enums::MMT_PROGRESS_BAR_BOX); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case -7: + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + break; + default: + goto switchD_00494a01_caseD_fffffffa; + } + } else { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter < 50) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 49) { + MACRO_CALL_MEMBER( + Map::MapPropertiesState_Func::spawnInvasionEventAttackWave, DAT_MapPropertiesState::ptr)(); + } else { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 44) { + // restart game + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition3::ptr)(UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER( + Audio::MSS::SoundSystem_Func::stopAllActiveSounds, DAT_SoundSystemState::ptr)(); + DAT_SoundEffectsHelperData1::instance.SEC_Section1079.musicState = 1; + MACRO_CALL_MEMBER( + Audio::MSS::SoundSystem_Func::setSomeSoundTime, DAT_SoundSystemState::ptr)(); + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::setupVolumeAndSoundID, + DAT_SoundSystemState::ptr)(DE::SHCDE::MUSIC_TUNE_NARR1); + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_SKIRMISH_SINGLE_PLAYER) { + if (DAT_GameCore::instance.gameMode_2 != Game::GM_CAMPAIGN_MISSION) { + if (DAT_GameCore::instance.isSkirmishTrail != TRUE) { + MACRO_CALL_MEMBER( + Game::Skirmish::SkirmishLobbySetupStructure_Func::restoreSkirmishLobbySetup, + SEC_SkirmishLobbySetupStructure::ptr)(); + MACRO_CALL(UI::Actions_Func::LaunchSkirmishGame)(0); + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + MACRO_CALL_MEMBER( + Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + if (DAT_GameCore::instance.currentTrailType == Game::TT_EXTREME) { + if (DAT_GameCore::instance.extremeTrailProgress < 20) { + MACRO_CALL(Game::Skirmish_Func::SetupSkirmishMode)( + DAT_GameCore::instance.extremeTrailProgress); + MACRO_CALL_MEMBER( + Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + } else if (DAT_GameCore::instance.currentTrailType == Game::TT_WARCHEST) { + if (DAT_GameCore::instance.warchestTrailProgress < 30) { + MACRO_CALL(Game::Skirmish_Func::SetupSkirmishMode)( + DAT_GameCore::instance.warchestTrailProgress); + MACRO_CALL_MEMBER( + Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + } else if (DAT_GameCore::instance.skirmishTrailProgress < 50) { + MACRO_CALL(Game::Skirmish_Func::SetupSkirmishMode)( + DAT_GameCore::instance.skirmishTrailProgress); + MACRO_CALL_MEMBER( + Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + goto LAB_00495061; + } + } else { + if (DAT_GameCore::instance.gameMode_2 == Game::GM_BUILDERUnk) { + DAT_GameCore::instance.currentMenuViewType + = UI::Enums::MVT_UNKNOWN_49_DOES_NOTHINGUnk; + MACRO_CALL(Map_Func::ResetSomeValuesFunctionUnk)(); + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, + DAT_WindowAndDirectDraw::instance.resolutionY, + (ushort)((int)(COL_BLACK::instance.shortValue))); + MACRO_CALL(UI::Actions_Func::LaunchSinglePlayerGameUnk)(1); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + if (DAT_GameCore::instance.gameMode_2 == Game::GM_CAMPAIGN_MISSION) { + MACRO_CALL_MEMBER(Game::GameCore_Func::removeJesterAndLadyUnitsInCertainMissions, + DAT_GameCore::ptr)(); + } + if (DAT_GameCore::instance.gameMode_2 == Game::GM_ECONOMIC_CAMPAIGN_SH1) { + MACRO_CALL_MEMBER(Game::GameCore_Func::removeLadyAndJester, DAT_GameCore::ptr)(); + } + } + DAT_GameCore::instance.gameSuspended = 0; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47) { + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MISSION_FINISHED_TRANSITION, 0); + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + DAT_GameCore::instance.section1095 = 0; + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + } + switchD_00494a01_caseD_fffffffa: + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter != 1000) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 2000) { + // ".map" + strcat(DAT_GameSynchronyState::instance.unknownMapName_01, S__MAP_005A2294); + MACRO_CALL_MEMBER(IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + IO::FRT_MAPS, (char const*)((int)(DAT_GameSynchronyState::instance.unknownMapName_01))); + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(Commands::GCT_START_OR_STOP_SEND_MAP_FILEUnk); + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + goto switchD_00494a01_caseD_fffffffa; + } + } + if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_MULTIPLAYER) { + MACRO_CALL_MEMBER( + Synchrony::GameSynchronyState_Func::initMultiplayerLobbyState, DAT_GameSynchronyState::ptr)(); + return; + } + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( + UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition2::ptr)( + UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition3::ptr)( + UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::stopAllActiveSounds, DAT_SoundSystemState::ptr)(); + DAT_GameCore::instance.currentlyInGameUnk_0xa4 = FALSE; + if (DAT_GameCore::instance.field_0x6c) { + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 31; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( + UI::Enums::MMT_PROGRESS_BAR_BOX, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::renderMenuModal, DAT_MenuModalComposition1::ptr)(); + DAT_WindowAndDirectDraw::instance.pendingBltMode = 1; + MACRO_CALL_MEMBER( + UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, DAT_WindowAndDirectDraw::ptr)(0); + MACRO_CALL_MEMBER(IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + IO::FRT_MAPS, STR_AutoBackupMap); + FilePackagerObj::instance.loadAndSaveBarFunc = MACRO_CALL(UI::Rendering_Func::RenderLoadAndSaveBar); + MACRO_CALL_MEMBER(IO::FilePackager_Func::readMapOrSavFile, FilePackagerObj::ptr)( + DAT_MapDefinedData::instance.MapSectionAddressArray); + MACRO_CALL_MEMBER(Map::TileMapState_Func::prepareMap, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); + DAT_GameCore::instance.field_0x6c = 0; + goto LAB_0049504b; + } + if (!UI_MissionModeIntent::instance) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter != 7) { + menuID = UI::Enums::MVT_SINGLEPLAYER_MAP_CHOICE; + goto LAB_00495046; + } + if (GVar1 == Game::GM_SOLITARY) { + if (DAT_GameCore::instance.gameMode_2 != Game::GM_BUILDERUnk) { + menuID = UI::Enums::MVT_MAIN_MENU; + goto LAB_00495046; + } + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_INVASION) { + MACRO_CALL(UI::MenuItems::CustomScenarios_Func::MenuItemActionHandler_CustomScenarios_Main)(4); + } else { + MACRO_CALL(UI::MenuItems::MainMenu_Func::MenuItemActionHandler_MainMenu_Main)(3); + } + } else if (GVar1 == Game::GM_SKIRMISH_SINGLE_PLAYER) { + if (DAT_GameCore::instance.gameMode_2 != Game::GM_CAMPAIGN_MISSION) { + if (!DAT_GameCore::instance.isSkirmishTrail) { + menuID = UI::Enums::MVT_UNKNOWN_61_RETURN_TO_SKIRMISH_MENUUnk; + } else { + DAT_GameCore::instance.gameSuspended = 0; + menuID = UI::Enums::MVT_CRUSADE_MAP; + } + goto LAB_00495046; + } + MACRO_CALL( + UI::MenuItems::HistoricCampaignSelect_Func::MenuItemActionHandler_HistoricCampaignSelect_Main)( + 4); + } else { + DAT_GameSynchronyState::instance.nextModalDialog = UI::Enums::MMT_CHOOSE_NETWORK_SERVICE_PROVIDER; + DAT_GameCore::instance.gameMode_2 = Game::GM_SKIRMISH_AND_MULTIPLAYER; + DAT_GameCore::instance.xbowProducible_logic = 1; + DAT_GameCore::instance.pikeProducible_logic = 1; + DAT_GameCore::instance.swordProducible_logic = 1; + DAT_GameCore::instance.bowProducible_logic = 1; + DAT_GameCore::instance.spearProducible_logic = 1; + DAT_GameCore::instance.maceProducible_logic = 1; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MP_CONNECTION, 0); + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + } + } else { + if (DAT_GameCore::instance.gameMode_2 == Game::GM_CAMPAIGN_MISSION) { + menuID = UI::Enums::MVT_HISTORIC_MISSION_SELECT; + } else { + menuID = UI::Enums::MVT_UNUSED_ECONOMIC_MISSION_SELECTUnk; + } + LAB_00495046: + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(menuID, 0); + } + LAB_0049504b: + if (DAT_MenuTextInputState::instance.currentModalDialog != UI::Enums::MMT_NO_MENU) { + LAB_00494b4a: + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::meth_0x4917c0, DAT_MenuTextInputState::ptr)(); + LAB_00495061: + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp new file mode 100644 index 0000000000..b6a8ef527c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp @@ -0,0 +1,424 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // The 23 `((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 0x20` below are each a signed + // `iVar1 / 32`, and undiv.py rewrites them, but measured: raw match 40.4% -> 24.6%. The + // opcodes are unchanged - the division frees a register, MSVC then picks ebx where the + // original uses edi, and every instruction after it is renamed. Normalized match rises + // 41.1% -> 48.1%, so the division is arguably the closer stream; it is kept in the shift + // form only because the raw percentage is the gate. Retry together with whatever fixes + // this function's register allocation. + // FUNCTION: STRONGHOLDCRUSADER 0x00428AC0 + void General::MenuItemRenderFunction_General_AdvancedGameOptions(int param_1, ...) + { + int iVar1; + uint _color; + int iVar2; + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_LOAD_MAP + || DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_SEND_MAP_TO + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_RECEIVE_MAP_FROM) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_SKIRMISH_PLAY_OPTIONS) { + if (param_1 != -1000 && param_1 != -10 && param_1 != -11 && param_1 != -12 && param_1 != -13 + && param_1 != -14 && param_1 != 99 && param_1 != 100 && param_1 != 83 && param_1 != 109 + && param_1 != 82 && param_1 != 94) { + return; + } + } else { + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { + return; + } + } + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + if (param_1 == 93) { + return; + } + if (param_1 == 31) { + return; + } + } + if ((param_1 == 103) + && (DAT_ButtonUnknownZero::instance = 0, + DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER)) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (!DAT_GameSynchronyState::instance.isHost) { + if (param_1 == 103) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (param_1 == 93) { + return; + } + } + if (param_1 == -1) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (param_1 != 103) { + if ((!DAT_ButtonCurrentlyInteracting::instance) || (!DAT_GameSynchronyState::instance.isHost)) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderNonInteractingButtonBackground, + AlphaAndButtonSurfaceObj::ptr)(DAT_ButtonBackgroundBlendStrength::instance); + _color = OpenSHC::Rendering::Colors::COL_C2F0EB; + } else { + _color = OpenSHC::Rendering::Colors::COL_CCFAFF; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + } + } + if (param_1 == 31) { + iVar2 = DAT_GameSynchronyState::instance.skirmishTechLevel / 2; + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Tech Level" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 85, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Early" "Middle" "Late" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar2 + 79, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 36) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Win: Regicide" / "Win: 10000 Gold" / "Win: 3" / "Win: 4" / "Win: 5" / .... + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)(DAT_GameSynchronyState::instance.skirmishWinCondition + 36), + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_CENTER, _color, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 83) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 86, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + iVar1 = 83; + // "Free" + if (DAT_GameSynchronyState::instance.skirmishTroopsCostGold != 0) { + // "Cost Gold" + iVar1 = 84; + } + iVar2 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar1, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar2 + (iVar2 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 109) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // Fog of War + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 109, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + if (DAT_GameState::instance.mapAndTime.skirmishFogOfWar == 0) { + // OFF + iVar1 = 95; + } else { + // Please Wait + iVar1 = (DAT_GameState::instance.mapAndTime.skirmishFogOfWar != 1) + 109; + } + iVar2 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar1, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar2 + (iVar2 >> 0x1f & 0x1fU)) >> 5) + 32); + return; + } + if (param_1 == -1000) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, 17, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_CENTER, _color, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 103) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 = ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32; + if (param_1 == -10) { + // No Cow Throwing + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 5, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); + iVar1 = DAT_GameSynchronyState::instance.skirmishNoCowThrowing; + LAB_00428ffd: + if (iVar1 != 0) { + iVar1 = DAT_ButtonW::instance - 50 + DAT_ButtonX::instance; + iVar2 = 206; + goto LAB_00429039; + } + } else { + if (param_1 == -11) { + // "No Dogs" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 6, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, + _color, 18, FALSE, iVar1); + iVar1 = DAT_GameSynchronyState::instance.skirmishNoDogs; + LAB_00429086: + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (iVar1 == 0) { + iVar1 = 208; + } else { + iVar1 = 206; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, iVar1, + (int)(DAT_ButtonW::instance - 50 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + if (param_1 == -13) { + // "Extreme mode" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 13, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, + _color, 18, FALSE, iVar1); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_GameSynchronyState::instance.skirmishExtremeMode == 0) { + iVar1 = 208; + } else { + iVar1 = 206; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, iVar1, + (int)(DAT_ButtonW::instance - 50 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + if (param_1 != -14) { + if (param_1 != 99) { + if (param_1 == -12) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 7, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 0) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 95, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 1) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 96, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 2) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 97, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 3) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 98, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 4) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 8, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting != 5) { + return; + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "1 Hour" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 9, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, param_1, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); + if (param_1 == 14) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishStartGold, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 15) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishDefaultPopularity, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 82) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishGameSpeedLevel, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 94) { + if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 0) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 95, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 5) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 96, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 10) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 97, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes != 20) { + return; + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 98, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 != 100) { + return; + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 = ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32; + // "Alliances" + if (DAT_GameSynchronyState::instance.skirmishAlliances == 0) { + // "Anytime" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 101, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, iVar1); + } + // "Start only" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 102, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, iVar1); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 99, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, + _color, 18, FALSE, iVar1); + iVar1 = DAT_GameSynchronyState::instance.skirmishStrongWalls; + goto LAB_00429086; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 14, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); + iVar1 = DAT_GameSynchronyState::instance.skirmishExtremeMode; + if (DAT_GameSynchronyState::instance.skirmishExtremeMode2 != 0) + goto LAB_00428ffd; + } + iVar2 = 208; + iVar1 = DAT_ButtonW::instance - 50 + DAT_ButtonX::instance; + LAB_00429039: + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, iVar2, iVar1, (int)(DAT_ButtonY::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp new file mode 100644 index 0000000000..437f7c96cf --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp @@ -0,0 +1,271 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/Player/Enums/BuildingEntryInfoEnum.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_00b960f8.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_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_ModifierKeyState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00b960f0.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00434350 + void InGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection(int param_1, ...) + { + DWORD DVar1; + int iVar2; + BOOLEnum BVar3; + dword elementState; + if (DAT_GameSynchronyState::instance.syncStatus != 0) { + return; + } + if (DAT_GameSynchronyState::instance.saveRelated != 0) { + return; + } + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY + && DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + && DAT_00b960f8::instance != 66) { + if (INT_00b960f0::instance == 0) { + DVar1 = timeGetTime(); + INT_00b960f0::instance = DVar1 + 20000; + } else { + DVar1 = timeGetTime(); + if (1500 < (int)(DVar1 - INT_00b960f0::instance)) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = DAT_00b960f8::instance; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + INT_00b960f0::instance = DVar1; + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + OpenSHC::Commands::GCT_UPDATE_LOBBY_FACE_BITMAPSPECIALTRANSMITLOGIC); + ++DAT_00b960f8::instance; + } + } + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + LAB_004344b0: + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, + (dword)((int)(2299 < (int)DAT_UnitsState::instance.unitCount))); + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { + LAB_004344a8: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) + goto LAB_004344b0; + } else if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) + || (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE)) { + if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) { + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getArmySize, DAT_UnitsState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID); + if (iVar2 == 0) { + if (DAT_GameCore::instance.activeMenuTab.buildMenuTab + == OpenSHC::UI::Enums::BMTT_CASTLE_KEEPS) { + if (DAT_GameCore::instance.menuSwitchDelay == -1) { + iVar2 = MACRO_CALL_MEMBER( + OpenSHC::Game::GameStateStructures_Func::singlePlayerHasKeepAndGranaryCheck, + DAT_GameState::ptr)(); + if (iVar2 == 1) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func:: + CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + = OpenSHC::UI::Enums::BASMTT_HUNTERSHUT; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, + DAT_GameCore::ptr)(OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + goto LAB_004344a8; + } + elementState = 1; + goto LAB_00434498; + } + } else if (DAT_GameCore::instance.activeMenuTab.buildMenuTab + == OpenSHC::UI::Enums::BMTT_UNKNOWN_49) + goto LAB_00434497; + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); + } else if (DAT_GameCore::instance.activeMenuTab.tabType + == OpenSHC::UI::Enums::BASMTT_UNUSED_WITCHHOIST) { + LAB_00434497: + elementState = 2; + LAB_00434498: + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, (dword)((int)(elementState))); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } + } + goto LAB_004344a8; + } + if (DAT_MouseState::instance.mouseBasedEvent == 1) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(3); + DAT_GameCore::instance.field_0x15c = 1; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 4; + } else if (((!DAT_MouseState::instance.rightClickState) || (DAT_MouseState::instance.mouseBasedEvent == 2)) + && (DAT_ModifierKeyState::instance.ctrl == 0 || (DAT_ModifierKeyState::instance.downArrow == 0)) + && DAT_ModifierKeyState::instance.v == 0) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(4); + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 5; + } else if (DAT_MouseState::instance.mouseBasedEvent == 3) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setMapRotation, DAT_TileMapState::ptr)( + DAT_MouseState::instance.mapOrientationCopy3); + DAT_GameCore::instance.field_0x15c = 1; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 2; + } else if (DAT_MouseState::instance.mouseBasedEvent == 4) { + DAT_MouseState::instance.field_0x198 = 2; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)( + (uint)(DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk == 0)); + DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + DAT_GameCore::instance.field_0x15c = 1; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 3; + } else { + if (DAT_MouseState::instance.mouseBasedEvent != 5) + goto LAB_004345e4; + DAT_MouseState::instance.field_0x19c = 2; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::toggleFlatView, DAT_TileMapState::ptr)( + DAT_TileMapState::instance.flatViewToggleValue1 ^ 1); + DAT_GameCore::instance.field_0x15c = 1; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 17; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(iVar2); + LAB_004345e4: + if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { + if (DAT_MouseState::instance.rightClickStart != 0) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + DAT_GameCore::instance.field_0x15c = 0; + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); + } + if (DAT_MouseState::instance.rightClickStart != 0) { + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_MOAT) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + } + DAT_GameCore::instance.field_0x15c = 0; + } else { + if (DAT_MouseState::instance.rightClickStop != 0 + && DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_MOAT + && DAT_GameCore::instance.field_0x15c == 0) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseFlatTile); + if (!DAT_MouseState::instance.leftClickState) { + if (DAT_UnitsState::instance + .unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + <= 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::processBuildingClickBonus, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID); + } + if (!DAT_MouseState::instance.draggingStopped) { + return; + } + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { + return; + } + } else if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { + if ((DAT_MouseState::instance.leftClickStart == 0) + && (DAT_ViewportRenderState::instance.viewportState.previousMouseTile + == DAT_ViewportRenderState::instance.viewportState.mouseFlatTile)) { + return; + } + DAT_ViewportRenderState::instance.viewportState.previousMouseTile + = DAT_ViewportRenderState::instance.viewportState.mouseFlatTile; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); + } + if (DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + < 1 + && DAT_UnitsState::instance.totalUnitsInSelection < 1 + && (DVar1 = timeGetTime(), + DAT_MouseState::instance.draggingStopped + && ((((DAT_MouseState::instance.selectionBoxState == 0 + && (DAT_MouseState::instance.savedSelectionBoxState == 0)) + && (BVar3 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func:: + selectUnitAndOpenStatusMenu, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayUnitID), + !BVar3)) + && ((199 < (int)(DVar1 - DAT_ViewportRenderState::instance.viewportState.field_0x34) + || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func:: + selectUnitAndOpenStatusMenu, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayLastUnitID), + !BVar3)))))) + && (BVar3 = MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::openBuildingStatusMenuForBuildingID, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID), + !BVar3 + && (((DAT_TileMapState::instance.LogicLayer[DAT_ViewportRenderState::instance.viewportState + .mouseAtomRefFloorTile] + & 2) + != 0 + && ((DAT_TileMapState::instance.WallOwnerLayer[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile] + & 7) + + 1 + == DAT_GameSynchronyState::instance.currentPlayerSlotID)))) + && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] + .id + != 0) { + DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = 11; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU, 0); + DAT_BuildingsState::instance.newSelectedUnitID = 0; + DAT_BuildingsState::instance.newSelectedBuildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] + .id; + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp new file mode 100644 index 0000000000..4705b3d7b0 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp @@ -0,0 +1,300 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/ButtonGmData.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/DAT_WallAndPitchState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004643F0 + void InGameMenu::MenuItemRenderFunction_InGameMenu_MainButtons(int param_1, ...) + { + ButtonGmData* buttonGmData; + int iVar1; + int iVar2; + int iVar3; + bool bVar4; + iVar3 = 0; + DAT_ButtonUnknownZero::instance = FALSE; + if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU + && (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM + || (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_MERCENARYPOST)) + && param_1 != 71 && param_1 != -4 && param_1 <= -10) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameCore::instance.activeMenuTab.tabType == param_1) { + if (param_1 != 71) { + iVar3 = 2; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + goto LAB_00464449; + } + LAB_0046444e: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + } else { + LAB_00464449: + if (param_1 == 71) + goto LAB_0046444e; + } + if (param_1 == -4) { + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT)) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + goto LAB_00464732; + } + if (param_1 == -5) { + if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) + && (DAT_GameCore::instance.field_0x6c != 0)) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } else if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL + || (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk))) { + LAB_004644dc: + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + return; + } + } else { + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) + goto LAB_004644dc; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION) { + bVar4 = DAT_GameCore::instance.isSkirmishTrail == TRUE; + goto LAB_004644d6; + } + } + LAB_004645b6: + if ((DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) + && (DAT_GameCore::instance.activeMenuTab.tabType + == OpenSHC::UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM)) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + LAB_004645c8: + if ((param_1 == -90) || (param_1 == -91)) { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION) + || (DAT_GameSynchronyState::instance.currentGameMode + != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER)) + goto LAB_004645f5; + if (param_1 == -90) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + } else { + LAB_004645f5: + if (param_1 == -90) + goto LAB_00464611; + } + if (param_1 == -91 || (10 <= param_1 && (param_1 <= 49))) + goto LAB_00464611; + } else { + if (param_1 <= -10 && param_1 != -90 && param_1 != -91) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (-100 < param_1) { + iVar1 = -9 - param_1; + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_INVASION) { + if (5 < iVar1) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + } else if (iVar1 != 1) { + DAT_ButtonUnknownZero::instance = TRUE; + } + } + if (iVar1 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + iVar3 = 8; + } + } + } + if (param_1 == -1) { + if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT)) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + return; + } + if ((DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_QUIT_DIALOG) + && (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47)) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + return; + } + goto LAB_004645b6; + } + if (param_1 == -6) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) { + bVar4 = DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT; + LAB_004644d6: + if (!bVar4) + goto LAB_004644dc; + } + goto LAB_004645b6; + } + if ((param_1 == 29) || (param_1 == 26)) { + LAB_004645a4: + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT)) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + LAB_004645ad: + if ((param_1 <= -1) && (-10 < param_1)) + goto LAB_004645b6; + goto LAB_004645c8; + } + if (param_1 != 27) + goto LAB_004645ad; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT) + goto LAB_004645a4; + LAB_00464611: + if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT)) { + if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_SOLDIERS) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + } else { + if ((DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) + && (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_SOLDIERS)) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + iVar1 + = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::singlePlayerHasKeepAndGranaryCheck, + DAT_GameState::ptr)(); + if (iVar1 < 1 + || (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU + && (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_STOCKS))) { + if ((param_1 != -90) && (param_1 != -91)) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + iVar3 = 1; + switch (param_1) { + case 10: + iVar3 = 54; + break; + case 20: + iVar3 = 55; + break; + case 40: + iVar3 = 56; + break; + case 30: + iVar3 = 57; + break; + case 28: + iVar3 = 58; + break; + case 25: + iVar3 = 59; + break; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)( + (OpenSHC::DE::SHCDE::eGM)(DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0), + iVar3, (int)(DAT_ButtonX::instance), DAT_ButtonY::instance); + DAT_CurrentButtonPictureInGm::instance = iVar3; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + } + } + if ((param_1 == -2) && (DAT_WallAndPitchState::instance.countdown == 0)) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + iVar3 = 2; + } + LAB_00464732: + buttonGmData = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + DAT_CurrentButtonGmDataIndex::instance; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + iVar2 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, buttonGmData)( + DAT_ButtonCurrentlyInteracting::instance); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)(buttonGmData->gmId_0x0), iVar2 + iVar3, + DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4 + + iVar3; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (param_1 == -4) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + DAT_ButtonX::instance - 1, (int)(DAT_ButtonY::instance + 17), (int)(DAT_ButtonX::instance - 1), + (int)(DAT_ButtonH::instance - 1 + DAT_ButtonY::instance), (ushort)(COL_BLACK::instance.shortValue)); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + DAT_ButtonX::instance - 2, (int)(DAT_ButtonY::instance + 17), (int)(DAT_ButtonX::instance - 2), + (int)(DAT_ButtonH::instance - 1 + DAT_ButtonY::instance), (ushort)(COL_BLACK::instance.shortValue)); + return; + } + if (param_1 == 71) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScribeFrame)(); + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderGoldValue)(); + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp new file mode 100644 index 0000000000..726745dd0c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp @@ -0,0 +1,218 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapNameCache.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/INT_00b95ab8.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00440A50 + void LobbyMenu::MenuItemActionHandler_LobbyMenu_MapSelectHeader(int param_1, ...) + { + int iVar1; + int iVar2; + int iVar3; + int iVar4; + uint uVar5; + uint uVar6; + int iVar7; + int iVar8; + int iVar9; + iVar8 = param_1; + iVar2 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber; + DAT_GameSynchronyState::instance.mapExistenceAckCountdown = 0; + if (param_1 < 0) { + iVar1 = -param_1; + if (param_1 == -1) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 2; + iVar1 = 0; + } else if (param_1 == -2) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 1; + iVar1 = 0; + } else if (param_1 == -3) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 4; + iVar1 = 2; + } else if (param_1 == -4) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 3; + iVar1 = 2; + } else if (4 < iVar1) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = iVar1 - 1; + if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 4) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 11; + } + iVar1 = 1; + } + } else { + if (DAT_00b960dc::instance != 0) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT) { + return; + } + iVar1 = param_1; + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { + return; + } + } + // the original dispatches the sort column with a `sub eax, K; je` chain + // (0x440a9e), MSVC's sparse switch, and the arm bodies sit in the order + // 2, 1, 0 + switch (iVar1) { + case 2: + iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 3) { + do { + iVar7 = 0; + for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { + iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; + if (DAT_GameSynchronyState::instance.mapBalanceArray[iVar4] + < DAT_GameSynchronyState::instance.mapBalanceArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[iVar3 + 1]]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; + ++iVar7; + } + } + } while (iVar7 != 0); + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 4; + } else { + do { + iVar7 = 0; + for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { + iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; + if (DAT_GameSynchronyState::instance + .mapBalanceArray[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]] + < DAT_GameSynchronyState::instance.mapBalanceArray[iVar4]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; + ++iVar7; + } + } + } while (iVar7 != 0); + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 3; + } + break; + case 1: + if ((int)DAT_GameSynchronyState::instance.lobbyMapSortOrder < 5) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 5; + } + param_1 = 7; + iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + do { + iVar3 = DAT_GameSynchronyState::instance.lobbyMapSortOrder - 5; + do { + iVar9 = 0; + iVar7 = DAT_GameSynchronyState::instance.lobbyMapSortOrder; + for (iVar4 = 0; iVar4 < iVar1; ++iVar4) { + iVar2 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4]; + uVar5 = (DAT_GameSynchronyState::instance.mapPlayerCountArray[iVar2] + iVar3) % 8; + uVar6 + = (DAT_GameSynchronyState::instance.mapPlayerCountArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[iVar4 + 1]] + + iVar3) + % 8; + if ((int)uVar6 < (int)uVar5) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4 + 1] = iVar2; + ++iVar9; + } + iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + } + iVar7 = DAT_GameSynchronyState::instance.lobbyMapSortOrder; + iVar2 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber; + } while (iVar9 != 0); + --param_1; + DAT_GameSynchronyState::instance.lobbyMapSortOrder = iVar7 + 1; + if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 12) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 5; + } + } while ((DAT_GameSynchronyState::instance + .mapPlayerCountArray[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[0]] + != 13 - iVar7) + && (0 < param_1)); + break; + case 0: + iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 1) { + do { + iVar7 = 0; + for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { + iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; + if (iVar4 < (int)DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; + ++iVar7; + } + } + } while (iVar7 != 0); + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 2; + } else { + do { + iVar7 = 0; + for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { + iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; + if ((int)DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] < iVar4) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; + ++iVar7; + } + } + } while (iVar7 != 0); + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 1; + } + break; + } + if (0 <= iVar8) { + INT_00b95ab8::instance = 1; + MACRO_CALL(OpenSHC::UI::MenuItems::LobbyMenu_Func::MenuItemActionHandler_LobbyMenu_MapSelectTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + return; + } + iVar8 = 0; + if (0 < iVar2) { + while (MACRO_CALL(OpenSHC::OS_Func::__stricmp)(DAT_MapNameCache::instance, + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar8])) + != 0) { + ++iVar8; + if (iVar8 >= (int)DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber) { + return; + } + } + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = 0; + if (iVar8 < 0) { + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = iVar8; + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = 0; + return; + } + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = iVar8; + if (7 < iVar8) { + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = iVar8 - 7; + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = 7; + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp new file mode 100644 index 0000000000..8263d7eec2 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp @@ -0,0 +1,357 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/AI/AITypeA.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/BGR24.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/WindowsHelper/Enums/BOOLEnum.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_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Rendering::Colors::BGR24; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00427810 + void LobbyMenu::MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons(int param_1, ...) + { + int iVar3; + int iVar4; + int iVar6; + BOOLEnum BVar2 = MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)(); + if (BVar2) { + return; + } + if (param_1 == 0) { + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar4 = (iVar3 / 32) + 32; + BVar2 = FALSE; + int iVar10 = 19; + BGR24 BVar9 = OpenSHC::Rendering::Colors::COL_C2F0EB; + TextAlignment TVar7 = OpenSHC::Text::TTA_LEFT; + iVar3 = DAT_ButtonX::instance; + iVar6 = DAT_ButtonY::instance; + // added by script: "Players" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 28), + iVar3, iVar6, TVar7, BVar9, iVar10, BVar2, iVar4); + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar6 = (iVar3 / 32) + 32; + BVar2 = FALSE; + iVar10 = 19; + BVar9 = OpenSHC::Rendering::Colors::COL_C2F0EB; + TVar7 = OpenSHC::Text::TTA_CENTER; + iVar4 = DAT_ButtonX::instance + 335; + iVar3 = DAT_ButtonY::instance; + // added by script: "Status" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 29), + iVar4, iVar3, TVar7, BVar9, iVar10, BVar2, iVar6); + } + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar6 = (iVar3 / 32) + 32; + BVar2 = FALSE; + iVar10 = 19; + BVar9 = OpenSHC::Rendering::Colors::COL_C2F0EB; + TVar7 = OpenSHC::Text::TTA_CENTER; + iVar4 = DAT_ButtonX::instance + 370; + iVar3 = DAT_ButtonY::instance; + // added by script: "Eject" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 91), + iVar4, iVar3, TVar7, BVar9, iVar10, BVar2, iVar6); + } + if (10 < param_1) { + iVar3 + = (int)*(char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 + 26); + DAT_ButtonUnknownZero::instance = TRUE; + if (iVar3 < 1) { + return; + } + byte bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[iVar3]; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if ('\0' < (char)bVar1) { + if ((bVar1 == 1) || (bVar1 == 3)) { + iVar6 = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 28; + while (iVar6 < DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 350) { + iVar4 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 22; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 204, + iVar6, (int)(DAT_ButtonY::instance), OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 72, + (iVar4 / 32) + 32); + iVar6 += 20; + } + } else { + iVar6 = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 28; + while (iVar6 < DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 350) { + iVar4 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 22; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 205, + iVar6, (int)(DAT_ButtonY::instance), OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 72, + (iVar4 / 32) + 32); + iVar6 += 20; + } + } + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE + && 27 + < DAT_MouseState::instance.screenSpaceX - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + && DAT_MouseState::instance.screenSpaceX - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + < 350 + && (int)DAT_ButtonY::instance <= DAT_MouseState::instance.screenSpaceY + && DAT_MouseState::instance.screenSpaceY < (int)DAT_ButtonY::instance + 20) { + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + iVar6 = 403; + } else if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1) { + iVar6 = 405; + } else { + iVar6 = 404; + } + // added by script: "Computer Opponent" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar6, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 135, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 192, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE); + if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[iVar3]) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)((char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[iVar3] + 405), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 145, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 192, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, TRUE); + } + } + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, (iVar6 / 32) + 32); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); + } + } + if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { + return; + } + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)(DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 9 + 230), + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 70, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); + return; + } + if (0 < param_1) { + iVar3 = (int)(char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[param_1]; + DAT_ButtonUnknownZero::instance = TRUE; + if (iVar3 < 1) { + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + && (iVar3 == DAT_GameSynchronyState::instance.DAT_HostPlayerSlotID + || ((DAT_GameSynchronyState::instance.isHost + && (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID))))) { + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 138, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 36, (int)(DAT_ButtonY::instance - 2), + (iVar6 / 32) + 32); + } + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar3 + 469, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, (int)(DAT_ButtonY::instance), + (iVar6 / 32) + 32); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1) { + if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)(DAT_GameSynchronyState::instance.aiVariationArray[iVar3] + 231 + + DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 9), + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); + } + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + DAT_TextManagerObject::instance.field_0x30 = 1; + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, (iVar6 / 32) + 32); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); + } + } + if (-10 < param_1) { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + return; + } + iVar3 = (int)*(char*)((int)DAT_GameSynchronyState::ptr + (1089092 - param_1)); + DAT_ButtonUnknownZero::instance = FALSE; + if (iVar3 < 1) { + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { + if (iVar3 != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + DAT_CurrentButtonGmDataIndex::instance + = 207 - (uint)(DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[iVar3] != 0); + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (iVar3 / 32) + 32); + return; + } + if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + DAT_CurrentButtonGmDataIndex::instance = 627; + switch (DAT_GameSynchronyState::instance.currentAIArray[iVar3]) { + case OpenSHC::AI::AITA_RAT: + case OpenSHC::AI::AITA_SNAKE: + case OpenSHC::AI::AITA_PIG: + case OpenSHC::AI::AITA_WOLF: + case OpenSHC::AI::AITA_RICHARD: + case OpenSHC::AI::AITA_FREDERICK: + case OpenSHC::AI::AITA_PHILIPP: + case OpenSHC::AI::AITA_SHERIFF: + case OpenSHC::AI::AITA_MARSHAL: + case OpenSHC::AI::AITA_ABBOT: + DAT_CurrentButtonGmDataIndex::instance = 626; + } + DAT_ButtonX::instance -= 6; + DAT_ButtonY::instance -= 3; + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (iVar3 / 32) + 32); + } + if (param_1 < -199) { + DAT_ButtonUnknownZero::instance = FALSE; + if (!DAT_GameSynchronyState::instance.isHost) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + iVar3 = (int)*(char*)((int)DAT_GameSynchronyState::ptr + (1088892 - param_1)); + if (iVar3 < 1) { + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameSynchronyState::instance.slotActionPending[iVar3] != 0) { + DAT_ButtonUnknownZero::instance = FALSE; + return; + } + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (iVar3 / 32) + 32); + } + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + BVar2 = MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, DAT_GameSynchronyState::ptr)(iVar3); + if (!BVar2) { + return; + } + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (iVar3 / 32) + 32); + } + if (param_1 == -101) { + DAT_ButtonUnknownZero::instance = TRUE; + if ((DAT_GameSynchronyState::instance.isHost) + && (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE)) { + for (int iVar3 = 1; iVar3 < countof(DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray); + ++iVar3) { + if ((char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[iVar3] < '\x01') + goto LAB_00427f46; + } + } + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } else { + if (param_1 == -102) { + if (!DAT_GameSynchronyState::instance.isHost) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE + && DAT_MenuModalComposition1::instance.activeModalDialogID + != OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT + && DAT_MenuModalComposition1::instance.activeModalDialogID + != OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) + goto LAB_00427f4c; + } else { + if (param_1 != -103) + goto LAB_00427f4c; + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + DAT_ButtonUnknownZero::instance = TRUE; + } + } + LAB_00427f46: + DAT_ButtonUnknownZero::instance = FALSE; + } + LAB_00427f4c: + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)((iVar3 / 32) + 32); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp new file mode 100644 index 0000000000..543fe2a970 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp @@ -0,0 +1,444 @@ +#include "../MapEditorLandscaping.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/Commands/MappersEnumInt.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_ModifierKeyState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00b9844c.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Commands::GameCommandType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00443A30 + void MapEditorLandscaping::MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback() + { + BOOLEnum BVar3; + bool bVar4; + GameCommandType commandType; + if (DAT_MouseState::instance.mouseBasedEvent == 1) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(3); + LAB_00443aed: + INT_00b9844c::instance = 1; + } else { + if (((DAT_MouseState::instance.rightClickState) && (DAT_MouseState::instance.mouseBasedEvent != 2)) + || (DAT_ModifierKeyState::instance.ctrl != 0 && (DAT_ModifierKeyState::instance.downArrow != 0)) + || DAT_ModifierKeyState::instance.v != 0) { + if (DAT_MouseState::instance.mouseBasedEvent == 3) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setMapRotation, DAT_TileMapState::ptr)( + DAT_MouseState::instance.mapOrientationCopy3); + } else if (DAT_MouseState::instance.mouseBasedEvent == 4) { + DAT_MouseState::instance.field_0x198 = 2; + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, + DAT_ViewportRenderState::ptr)( + (uint)(DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk == 0)); + DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } else { + if (DAT_MouseState::instance.mouseBasedEvent != 5) + goto LAB_00443af3; + DAT_MouseState::instance.field_0x19c = 2; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::toggleFlatView, DAT_TileMapState::ptr)( + DAT_TileMapState::instance.flatViewToggleValue1 ^ 1); + return; + } + goto LAB_00443aed; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(4); + } + LAB_00443af3: + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, + (dword)((int)(2300 < (int)DAT_UnitsState::instance.unitCount))); + if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_RIPPLE) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::HandleWallTerrainMouseDrag)(); + } + if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); + } + if (DAT_MouseState::instance.rightClickStop != 0) { + if (INT_00b9844c::instance == 0) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + return; + } + INT_00b9844c::instance = 0; + } + if (!DAT_MouseState::instance.leftClickState) { + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseFlatTile); + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_BIGROCK1 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_BIGROCK2 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_BIGROCK3 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_BIGROCK4 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_BIGROCK5) { + if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_NULL) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::renderPreviewMapperWithBrush, + DAT_TileMapState::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseTileX, + (uint)(DAT_ViewportRenderState::instance.viewportState.mouseTileY), + DAT_TileMapState::instance.currentMapperCommand); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::renderWallPlacementPreview, DAT_TileMapState::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseTileX, + (uint)(DAT_ViewportRenderState::instance.viewportState.mouseTileY), + (short)(DAT_TileMapState::instance.rockFlagStartNumber + + DAT_TileMapState::instance.unknownBrushRelated * 4)); + } + if ((DAT_MouseState::instance.leftClickStart == 0) + && (DAT_ViewportRenderState::instance.viewportState.previousMouseTile + == DAT_ViewportRenderState::instance.viewportState.mouseFlatTile)) { + return; + } + DAT_ViewportRenderState::instance.viewportState.previousMouseTile + = DAT_ViewportRenderState::instance.viewportState.mouseFlatTile; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); + int iVar2 = DAT_ViewportRenderState::instance.viewportState.mouseTileY; + int _clickedX = DAT_ViewportRenderState::instance.viewportState.mouseTileX; + int iVar1 = DAT_TileMapState::instance.editorSnapToMode; + int _orientation = DAT_TileMapState::instance.mapOrientation; + if (DAT_MouseState::instance.leftClickStart != 0) { + DAT_TileMapState::instance.DAT_ClickedTileX + = DAT_ViewportRenderState::instance.viewportState.mouseTileX; + DAT_TileMapState::instance.DAT_ClickedTileY + = DAT_ViewportRenderState::instance.viewportState.mouseTileY; + BVar3 = MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::xyAreValid, + DAT_ViewportRenderState::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseTileX, + (uint)(DAT_ViewportRenderState::instance.viewportState.mouseTileY)); + if ((BVar3) + && (DAT_TileMapState::instance.editorAffectType = 0, + (DAT_TileMapState::instance + .LogicLayer[DAT_ViewportRenderState::instance.translationMatrix[iVar2].addXgetTile + + _clickedX] + & 0x41) + != 0)) { + DAT_TileMapState::instance.editorAffectType = 1; + } + } + int _clickedY = DAT_TileMapState::instance.DAT_ClickedTileY; + if ((_orientation == 0) || (_orientation == 4)) { + if (iVar1 != 1) { + bVar4 = iVar1 == 2; + goto LAB_00443cb1; + } + } else if (iVar1 != 2) { + bVar4 = iVar1 == 1; + LAB_00443cb1: + _clickedY = iVar2; + if (bVar4) { + _clickedX = DAT_TileMapState::instance.DAT_ClickedTileX; + } + } + if (340 < (int)DAT_TileMapState::instance.currentMapperCommand) { + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_SCRUBGRASS) { + return; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = -128; + goto LAB_00444270; + } + if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_DUNES) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 64; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + } + switch (DAT_TileMapState::instance.currentMapperCommand) { + case OpenSHC::Commands::M_MAPPER_DELETE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNIT_ERASE); + return; + case OpenSHC::Commands::M_MAPPER_RAISE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_RAISE_LAND); + return; + case OpenSHC::Commands::M_MAPPER_MOUNTAIN: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_LAND; + commandType = OpenSHC::Commands::GCT_RAISE_LAND2Unk; + break; + case OpenSHC::Commands::M_MAPPER_HILL: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_LOWER; + commandType = OpenSHC::Commands::GCT_RAISE_LAND2Unk; + break; + case OpenSHC::Commands::M_MAPPER_LOWER: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = -1; + commandType = OpenSHC::Commands::GCT_RAISE_LAND; + goto LAB_0044427c; + case OpenSHC::Commands::M_MAPPER_LAND: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_LAND); + return; + case OpenSHC::Commands::M_MAPPER_SEA: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_BEACH: + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 32; + goto LAB_00444270; + case OpenSHC::Commands::M_MAPPER_EQUALISE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_TERRAIN_EQUALIZE); + return; + case OpenSHC::Commands::M_MAPPER_PLAIN1: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 4; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CREATE_PLATEAU); + return; + case OpenSHC::Commands::M_MAPPER_PLAIN2: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 8; + commandType = OpenSHC::Commands::GCT_CREATE_PLATEAU; + goto LAB_0044427c; + case OpenSHC::Commands::M_MAPPER_MIN: + case OpenSHC::Commands::M_MAPPER_MAX: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = DAT_TileMapState::instance.mapperMax; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_TERRAIN_MIN_MAX); + return; + case OpenSHC::Commands::M_MAPPER_BIGROCK1: + case OpenSHC::Commands::M_MAPPER_BIGROCK2: + case OpenSHC::Commands::M_MAPPER_BIGROCK3: + case OpenSHC::Commands::M_MAPPER_BIGROCK4: + case OpenSHC::Commands::M_MAPPER_BIGROCK5: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = DAT_TileMapState::instance.rockFlagStartNumber + + DAT_TileMapState::instance.unknownBrushRelated * 4; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = 20; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk); + ++DAT_TileMapState::instance.rockFlagStartNumber; + if (4 <= (int)DAT_TileMapState::instance.rockFlagStartNumber) { + DAT_TileMapState::instance.rockFlagStartNumber = 0; + } + return; + case OpenSHC::Commands::M_MAPPER_ROCKY: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 128; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + goto LAB_0044427a; + case OpenSHC::Commands::M_MAPPER_STONES: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 64; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_RIVER: + case OpenSHC::Commands::M_MAPPER_FOAM: + case OpenSHC::Commands::M_MAPPER_RIPPLE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1048576; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_FOAM) { + if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_RIPPLE) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 32; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_AREA; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 16; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_FORD: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 2097152; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + goto LAB_0044427a; + case OpenSHC::Commands::M_MAPPER_BOULDERS: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 131072; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_PEBBLES: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 262144; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_IRON: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 524288; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + goto LAB_0044427a; + case OpenSHC::Commands::M_MAPPER_OIL: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = -2147483648; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_MARSH: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 536870912; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_DUGMOAT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1073741824; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 2; + LAB_0044427a: + commandType = OpenSHC::Commands::GCT_SET_TERRAIN; + LAB_0044427c: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + break; + case OpenSHC::Commands::M_MAPPER_UNDUGMOAT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1073741824; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 3; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_DIRT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 2; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_GRASS: + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 16; + LAB_00444270: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + goto LAB_0044427a; + case OpenSHC::Commands::M_MAPPER_SCRUB: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_CHESTNUT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_CHESTNUT; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_OAK: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_OAK; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_SHRUB1A: + case OpenSHC::Commands::M_MAPPER_SHRUB1B: + case OpenSHC::Commands::M_MAPPER_SHRUB1C: + case OpenSHC::Commands::M_MAPPER_SHRUB1D: + case OpenSHC::Commands::M_MAPPER_SHRUB1E: + case OpenSHC::Commands::M_MAPPER_SHRUB2A: + case OpenSHC::Commands::M_MAPPER_SHRUB2B: + case OpenSHC::Commands::M_MAPPER_SHRUB2C: + case OpenSHC::Commands::M_MAPPER_SHRUB2D: + case OpenSHC::Commands::M_MAPPER_SHRUB2E: + case OpenSHC::Commands::M_MAPPER_SHRUB3A: + case OpenSHC::Commands::M_MAPPER_SHRUB3B: + case OpenSHC::Commands::M_MAPPER_SHRUB3C: + case OpenSHC::Commands::M_MAPPER_SHRUB3D: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 + = DAT_TileMapState::instance.currentMapperCommand; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_PINE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_PINE; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_BIRCH: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_BIRCH; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_DEER: + case OpenSHC::Commands::M_MAPPER_LION: + case OpenSHC::Commands::M_MAPPER_RABBIT: + case OpenSHC::Commands::M_MAPPER_CAMEL: + case OpenSHC::Commands::M_MAPPER_CROW_SEAGULL: + case OpenSHC::Commands::M_MAPPER_SEAGULL: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 + = DAT_TileMapState::instance.currentMapperCommand; + commandType = OpenSHC::Commands::GCT_CREATE_ANIMAL; + break; + default: + return; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + commandType); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp new file mode 100644 index 0000000000..b1e7e60586 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp @@ -0,0 +1,380 @@ +#include "../MapEditorProperties.func.hpp" + +#include "OpenSHC/AI/AICState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/IO/FilePackager.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Map/Units/TroopValueState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00b960f4.hpp" +#include "OpenSHC/Globals/DAT_AICState.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_TroopValueState.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/FilePackagerObj.hpp" +#include "OpenSHC/Globals/INT_00b95b74.hpp" +#include "OpenSHC/Globals/INT_00b95f68.hpp" +#include "OpenSHC/Globals/INT_00b960e4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00443070 + void MapEditorProperties::MenuItemActionHandler_MapEditorProperties_MainButtons(int param_1, ...) + { + byte(*pabVar1)[10]; + byte* pbVar2; + char cVar3; + char cVar4; + char cVar5; + int iVar6; + int* piVar7; + int* piVar8; + if ((DAT_MenuTextInputState::instance.currentModalDialog == UI::Enums::MMT_NO_MENU) + && (DAT_MenuModalComposition1::instance.activeModalDialogID == UI::Enums::MMT_NONE)) { + DAT_TileMapState::instance.unitPlacementCount = 1; + switch (param_1) { + case 2: + DAT_MenuTextInputState::instance.field_0x9c = 1; + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateLoadOrSaveMapUI, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_LOAD_MAP); + return; + case 3: + if ((!DAT_GameCore::instance.U2_mapType_singleOrMulti) + || (DAT_GameCore::instance.mapLoadedForEditor)) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::determineScenarioMissionTypeAndResetEvents, + DAT_MapPropertiesState::ptr)(); + DAT_MenuTextInputState::instance.field_0x9c = 1; + DAT_MenuTextInputState::instance.field_0xa4 = 0; + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateLoadOrSaveMapUI, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_SAVE_MAP); + INT_00b960e4::instance = 1; + return; + } + break; + case 4: + INT_00b960e4::instance = 0; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_NEW_MAP_MAPTYPE, 0); + return; + case 5: + if (INT_00b95f68::instance) { + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 43; + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(UI::Enums::MMT_QUIT_DIALOG); + return; + } + DAT_GameCore::instance.isTimeHalted2 = 0; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_CUSTOM_SCENARIOS, 0); + return; + case 6: + if (DAT_GameCore::instance.mapLoadedForEditor) { + INT_00b95f68::instance = 1; + DAT_TileMapState::instance.currentMapperCommand = Commands::M_MAPPER_NULL; + DAT_GameCore::instance.gameMode_2 = Game::GM_EDITOR; + DAT_GameCore::instance.missionNumber1to20 = 27; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); + for (int i = 0; i < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); ++i) { + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[i] = -1; + } + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; + if (DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType == 237) { + if (DAT_GameCore::instance.U2_mapType_singleOrMulti < 1) + goto LAB_00443214; + DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType = 239; + } else if (DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType != 239) + goto LAB_00443214; + if (!DAT_GameCore::instance.U2_mapType_singleOrMulti) { + DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType = 237; + } + LAB_00443214: + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MAP_EDITOR_LANDSCAPING, 0); + return; + } + break; + case 9: + MACRO_CALL(UI::MenuItems::MapEditorProperties_Func:: + MenuItemActionHandler_MapEditorProperties_MapDescriptionBox)(); + return; + case 25: + if ((DAT_GameCore::instance.U2_mapType_singleOrMulti != 1) + && (DAT_GameCore::instance.mapLoadedForEditor)) { + INT_00b95f68::instance = 1; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_EDIT_SCENARIO, 0); + return; + } + break; + case 31: + if (DAT_GameCore::instance.mapLoadedForEditor) { + DAT_GameCore::instance.missionNumber1to20 = 27; + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 32; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_PROGRESS_BAR_BOX, FALSE); + MACRO_CALL_MEMBER( + UI::MenuModalComposition_Func::renderMenuModal, DAT_MenuModalComposition1::ptr)(); + MACRO_CALL_MEMBER( + UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, DAT_WindowAndDirectDraw::ptr)(0); + MACRO_CALL_MEMBER(IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + IO::FRT_MAPS, STR_AutoBackupMap); + FilePackagerObj::instance.loadAndSaveBarFunc + = MACRO_CALL(UI::Rendering_Func::RenderLoadAndSaveBar); + MACRO_CALL_MEMBER(IO::FilePackager_Func::writeMapOrSaveFile, FilePackagerObj::ptr)( + DAT_MapDefinedData::instance.MapSectionAddressArray); + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_SIEGE) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[1] = 1; + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[2] = 2; + } + DAT_MenuTextInputState::instance.DAT_SomeTextArrayIndex = 9; + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; + DAT_TileMapState::instance.currentMapperCommand = Commands::M_MAPPER_NULL; + DAT_GameCore::instance.gameMode_2 = Game::GM_BUILDERUnk; + DAT_GameCore::instance.field_0x6c = 1; + DAT_GameState::instance.mapAndTime.difficulty = 1; + DAT_GameCore::instance.section1095 = 0; + MACRO_CALL_MEMBER( + Map::Units::TroopValueState_Func::clearAttackInfo, DAT_TroopValueState::ptr)(); + MACRO_CALL_MEMBER(AI::AICState_Func::recomputeAIZonerLayer, DAT_AICState::ptr)(); + ++DAT_TroopValueState::instance.attackInfo.inv_count; + if (49 < DAT_TroopValueState::instance.attackInfo.inv_count) { + DAT_TroopValueState::instance.attackInfo.inv_count = 1; + } + MACRO_CALL_MEMBER(Map::Units::TroopValueState_Func::initializeAttackWaveSlot, + DAT_TroopValueState::ptr)(DAT_TroopValueState::instance.attackInfo.inv_count, 1); + cVar3 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[0]; + DAT_TroopValueState::instance.attackInfo + .attackWavePlayerIDArray[DAT_TroopValueState::instance.attackInfo.inv_count] = 2; + cVar4 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[1]; + pabVar1 = DAT_TroopValueState::instance.attackInfo.someSinglePlayerScore + + DAT_TroopValueState::instance.attackInfo.inv_count; + (*pabVar1)[0] = (*pabVar1)[0] + cVar3; + cVar5 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[3]; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 1; + *pbVar2 += cVar4; + cVar3 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[2]; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 2; + *pbVar2 += cVar5; + cVar4 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[4]; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 3; + *pbVar2 += cVar3; + cVar3 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[5]; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 4; + *pbVar2 += cVar4; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 8; + *pbVar2 += cVar3; + DAT_GameState::instance.mapAndTime.siegeInformation.archers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[0]; + piVar7 = DAT_MapPropertiesState::instance.SEC_StartingResources; + piVar8 = DAT_GameState::instance.mapAndTime.startGoods; + for (iVar6 = 25; iVar6 != 0; --iVar6) { + *piVar8 = *piVar7; + ++piVar7; + ++piVar8; + } + DAT_GameState::instance.mapAndTime.startGoods[7] + = DAT_GameState::instance.mapAndTime.startGoods[8]; + DAT_GameState::instance.mapAndTime.siegeInformation.pikemen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[3]; + DAT_GameState::instance.mapAndTime.siegeInformation.spearmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[2]; + DAT_GameState::instance.mapAndTime.siegeInformation.crossbowmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[1]; + DAT_GameState::instance.mapAndTime.siegeInformation.knights + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[6]; + DAT_GameState::instance.mapAndTime.siegeInformation.swordsmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[5]; + DAT_GameState::instance.mapAndTime.siegeInformation.macemen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[4]; + DAT_GameState::instance.mapAndTime.siegeInformation.monks + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[9]; + DAT_GameState::instance.mapAndTime.siegeInformation.engineers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[8]; + DAT_GameState::instance.mapAndTime.siegeInformation.laddermen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[7]; + DAT_GameState::instance.mapAndTime.siegeInformation.slingers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[12]; + DAT_GameState::instance.mapAndTime.siegeInformation.slaves + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[11]; + DAT_GameState::instance.mapAndTime.siegeInformation.arabianArchers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[10]; + DAT_GameState::instance.mapAndTime.siegeInformation.arabianSwordsmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[15]; + DAT_GameState::instance.mapAndTime.siegeInformation.horseArchers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[14]; + DAT_GameState::instance.mapAndTime.siegeInformation.assassins + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[13]; + DAT_GameState::instance.mapAndTime.siegeInformation.field_0x48 + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[18]; + DAT_GameState::instance.mapAndTime.siegeInformation.fireBallistas + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[17]; + DAT_GameState::instance.mapAndTime.siegeInformation.fireThrowers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[16]; + DAT_GameState::instance.mapAndTime.startGoods[8] = 0; + DAT_GameState::instance.mapAndTime.siegeInformation.field_0x4c + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[19]; + DAT_GameState::instance.mapAndTime.startingPopularity + = DAT_MapPropertiesState::instance.SEC_StartingPopularity * 10; + MACRO_CALL_MEMBER(Game::GameStateStructures_Func::setMonthAndYear, DAT_GameState::ptr)( + DAT_MapPropertiesState::instance.SEC_StartingMonth, + DAT_MapPropertiesState::instance.SEC_StartingYear); + MACRO_CALL_MEMBER( + Game::GameStateStructures_Func::clearEnemyRelatedStructures, DAT_GameState::ptr)(); + DAT_GameState::instance.mapAndTime.mercRecruitable[3] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[3]; + DAT_GameCore::instance.xbowProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_XbowProducible_save; + DAT_GameCore::instance.bowProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_BowProducible_save; + DAT_GameCore::instance.pikeProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_PikeProducible_save; + DAT_GameState::instance.mapAndTime.mercRecruitable[2] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[2]; + DAT_GameState::instance.mapAndTime.euroRecruitable[4] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.macemen; + DAT_GameState::instance.mapAndTime.mercRecruitable[4] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[4]; + DAT_GameState::instance.mapAndTime.euroRecruitable[5] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.swordsmen; + DAT_GameCore::instance.spearProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_SpearProducible_save; + DAT_GameState::instance.mapAndTime.mercRecruitable[5] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[5]; + DAT_GameState::instance.mapAndTime.mercRecruitable[0] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[0]; + DAT_GameState::instance.mapAndTime.euroRecruitable[6] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.knights; + DAT_GameCore::instance.swordProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_SwordProducible_save; + DAT_GameCore::instance.maceProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_MaceProducible_save; + DAT_GameState::instance.mapAndTime.mercRecruitable[1] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[1]; + DAT_GameState::instance.mapAndTime.mercRecruitable[6] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[6]; + DAT_GameState::instance.mapAndTime.euroRecruitable[0] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.archers; + DAT_GameState::instance.mapAndTime.euroRecruitable[1] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.crossbowmen; + DAT_GameState::instance.mapAndTime.euroRecruitable[2] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.spearmen; + DAT_GameState::instance.mapAndTime.euroRecruitable[3] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.pikemen; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_0 + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[0] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_a + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[1] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_b + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[1] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_2 + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[2] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[3] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_b + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[3] != 0); + if (DAT_GameState::instance.mapAndTime.euroRecruitable[4] != 0) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_a = 1; + } + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_4 + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[4] != 0); + if (DAT_GameState::instance.mapAndTime.euroRecruitable[5] != 0) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b = 1; + } + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_a + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[5] != 0); + if (DAT_GameState::instance.mapAndTime.euroRecruitable[6] != 0) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_a = 1; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b = 1; + } + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_c + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[6] != 0); + DAT_GameState::instance.mapAndTime.countUpTo201 = 0; + MACRO_CALL_MEMBER( + Map::MapPropertiesState_Func::importTradingCosts, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType = UI::Enums::BASMTT_HUNTERSHUT; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + return; + } + break; + case -6: + DAT_GameCore::instance.mapU3EndInt = 1; + break; + case -5: + DAT_GameCore::instance.mapU3EndInt = 0; + return; + case -4: + DAT_GameCore::instance.mapU4Int3_balanced = 1; + return; + case -3: + DAT_GameCore::instance.mapU4Int3_balanced = 0; + return; + case -2: + iVar6 = INT_00b95b74::instance - 231; + if ((DAT_00b960f4::instance < iVar6) + && (DAT_00b960f4::instance = DAT_00b960f4::instance + 14, iVar6 < DAT_00b960f4::instance)) { + DAT_00b960f4::instance = iVar6; + return; + } + break; + case -1: + DAT_00b960f4::instance -= 14; + if (DAT_00b960f4::instance < 0) { + DAT_00b960f4::instance = 0; + return; + } + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp new file mode 100644 index 0000000000..21fb189c27 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp @@ -0,0 +1,384 @@ +#include "../NewEventCondition.func.hpp" + +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_UnknownTime_01.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B9620 + void NewEventCondition::MenuItemActionHandler_NewEventCondition_Main(int param_1, ...) + { + ushort* puVar1; + short* destination; + byte* pbVar2; + short sVar3; + byte(*pabVar4)[100]; + DWORD DVar5; + char* pcVar6; + int iVar7; + int iVar8; + if (param_1 < 1001) { + if (param_1 == 1000) { + sVar3 = *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12); + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + < (int)sVar3) { + *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) = sVar3 - 1; + return; + } + } else { + switch (param_1) { + case 19: + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 15) = 0; + return; + case 37: + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 15) + != '\0') { + iVar8 = 1; + pcVar6 = (char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 19); + while (*pcVar6 == '\0') { + ++iVar8; + pcVar6 += 4; + if (39 < iVar8) { + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_EVENT, FALSE); + return; + } + } + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 15) = 0; + } + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_EVENT, FALSE); + return; + case 104: + puVar1 = (ushort*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 8); + *puVar1 ^= 1; + return; + case 190: + case 191: + case 192: + case 193: + case 194: + case 195: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 202: + case 203: + case 204: + case 205: + case 206: + case 207: + case 208: + case 209: + param_1 -= 64; + case 106: + case 107: + case 108: + case 109: + case 110: + case 111: + case 112: + case 113: + case 114: + case 115: + case 116: + case 117: + case 118: + case 119: + case 120: + case 121: + case 122: + case 123: + case 124: + case 125: + DAT_MapPropertiesState::instance.invasionTroopIndex = param_1 - 106; + *(undefined1*)((int)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags + + DAT_MapPropertiesState::instance.currentEventID * 228 + param_1 * 4 + 511) = 1; + DAT_UnknownTime_01::instance = 0; + if ((int)*(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) + < DAT_MissionAestheticsDefinedData::instance + .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex]) { + *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) + = (short)DAT_MissionAestheticsDefinedData::instance + .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex]; + } + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + != 0) { + destination = (short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12); + MACRO_CALL_MEMBER( + UI::MenuModalComposition_Func::setSliderParameters2, DAT_MenuModalComposition2::ptr)( + DAT_MissionAestheticsDefinedData::instance + .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex], + (dword)((int)(DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex])), + (dword)((int)((int)*destination)), (dword)((int)(destination)), + MACRO_CALL(UI::Helpers_Func::CaptureCurrentTimeToUnknownTime01)); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_OVERLAY_SLIDER, + (int)((int)(DAT_ButtonX::instance + 58)), (int)((int)(DAT_ButtonY::instance + 28))); + return; + } + } + } + } else if (param_1 < 2003) { + if (param_1 < 2001) { + if (param_1 == 1001) { + sVar3 = *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12); + if ((int)sVar3 < DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex]) { + *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) = sVar3 + 1; + return; + } + } else if (param_1 == 2000) { + iVar8 = 0; + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + != 0) { + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 1) { + iVar7 + = (int)*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + pbVar2 = (byte*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + if (*(int*)DAT_MissionAestheticsDefinedData::instance + .EventConditionOptionValues[DAT_MapPropertiesState::instance.invasionTroopIndex] + != iVar7) { + pabVar4 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + + DAT_MapPropertiesState::instance.invasionTroopIndex; + do { + pabVar4 = (byte(*)[100])(*pabVar4 + 4); + ++iVar8; + } while (*(int*)*pabVar4 != iVar7); + } + if (iVar8 - 1 < 0) { + pabVar4 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + + DAT_MapPropertiesState::instance.invasionTroopIndex; + iVar8 = 0; + do { + iVar7 = iVar8; + if (*(int*)*pabVar4 == -1) { + *pbVar2 + = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex - 1] + [iVar7 * 4 + 96]; + goto LAB_004b98bd; + } + pabVar4 = (byte(*)[100])(*pabVar4 + 4); + iVar8 = iVar7 + 1; + } while (iVar7 + 1 < 100); + *pbVar2 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex][iVar7 * 4 + 4]; + } else { + *pbVar2 + = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex - 1][iVar8 * 4 + 96]; + } + } + LAB_004b98bd: + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 2) { + pcVar6 = (char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + --*pcVar6; + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) + < '\0') { + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) = 4; + } + } + } + } + } else { + iVar8 = 0; + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + != 0) { + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 1) { + iVar7 = (int)*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + if (!iVar7) { + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) = 10; + iVar7 = 10; + } + if (*(int*)DAT_MissionAestheticsDefinedData::instance + .EventConditionOptionValues[DAT_MapPropertiesState::instance.invasionTroopIndex] + != iVar7) { + pabVar4 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + + DAT_MapPropertiesState::instance.invasionTroopIndex; + do { + pabVar4 = (byte(*)[100])(*pabVar4 + 4); + ++iVar8; + } while (*(int*)*pabVar4 != iVar7); + } + if (*(int*)(DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex] + + iVar8 * 4 + 4) + == -1) { + *(byte*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) + = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex][0]; + } else { + *(byte*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) + = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex][iVar8 * 4 + 4]; + } + } + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 2) { + pcVar6 = (char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + *pcVar6 += '\x01'; + if ('\x04' < *(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14)) { + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) = 0; + return; + } + } + } + } + } else { + switch (param_1) { + case 5190: + case 5191: + case 5192: + case 5193: + case 5194: + case 5195: + case 5196: + case 5197: + case 5198: + case 5199: + case 5200: + case 5201: + case 5202: + case 5203: + case 5204: + case 5205: + case 5206: + case 5207: + case 5208: + case 5209: + param_1 -= 64; + case 5106: + case 5107: + case 5108: + case 5109: + case 5110: + case 5111: + case 5112: + case 5113: + case 5114: + case 5115: + case 5116: + case 5117: + case 5118: + case 5119: + case 5120: + case 5121: + case 5122: + case 5123: + case 5124: + case 5125: + if ((DAT_MenuModalComposition2::instance.activeModalDialogID == UI::Enums::MMT_NONE) + && ((DVar5 = timeGetTime(), + 1000 < DVar5 - DAT_UnknownTime_01::instance || (!DAT_UnknownTime_01::instance)))) { + DAT_UnknownTime_01::instance = 0; + ((char*)&DAT_UnitsState::instance.units[2491] + + 995)[(DAT_MapPropertiesState::instance.currentEventID * 57 + param_1) * 4] = 0; + return; + } + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp b/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp new file mode 100644 index 0000000000..a65b4ba587 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp @@ -0,0 +1,230 @@ +#include "../Roundtable.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/AI/AITypeA.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00df423c.hpp" +#include "OpenSHC/Globals/DAT_00df4240.hpp" +#include "OpenSHC/Globals/DAT_00df4298.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/INT_00df4244.hpp" +#include "OpenSHC/Globals/SEC_RNG.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004AEA50 + void Roundtable::MenuItemActionHandler_Roundtable_Main(int param_1, ...) + { + BOOLEnum BVar3; + int playerID_01; + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + if (param_1 < 9) { + if (DAT_00df423c::instance != 0) { + param_1 += 10; + } + if (param_1 < 9) { + DAT_00df423c::instance = param_1; + INT_00df4244::instance = 0; + } + } + if ((param_1 - 0xbU < 8) && (DAT_00df423c::instance != 0)) { + int playerID + = (int)*(char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 + 26); + playerID_01 + = (int)(char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance]; + if (0 < playerID_01 && 0 < playerID && playerID != playerID_01 + && (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID_01] != -1 + || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, + DAT_GameSynchronyState::ptr)(playerID_01), + BVar3)) + && (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID] != -1 + || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, + DAT_GameSynchronyState::ptr)(playerID), + BVar3))) { + int iVar4 = 0; + for (int playerID_00 = 1; + playerID_00 < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++playerID_00) { + if ((DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID_00] != -1) + || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, + DAT_GameSynchronyState::ptr)(playerID_00), + BVar3)) { + ++iVar4; + } + } + if (2 < iVar4) { + if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == OpenSHC::AI::AITA_RAT) + && (DAT_00df4240::instance == 0)) { + if (DAT_GameCore::instance.genieVoiceActive) { + // "Not the rodent" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "Genie_13.wav" + s_Genie_13_wav_005a7710); + } + DAT_00df4240::instance = 1; + } + if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == OpenSHC::AI::AITA_SULTAN) + && (DAT_00df4298::instance == 0)) { + if (DAT_GameCore::instance.genieVoiceActive) { + // "Oh no" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "Genie_14.wav" + s_Genie_14_wav_005a7700); + } + DAT_00df4298::instance = 1; + } + } + int bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID]; + if ((DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] != bVar1) + || (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] == 0)) { + if (bVar1 == 0) { + bVar1 = 0; + for (int i = 1; i < countof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray); ++i) { + if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i] + && (char)bVar1 < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]) { + bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]; + } + } + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[( + char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance]] + = bVar1 + 1; + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[*( + char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 + + 26)] = bVar1 + 1; + MACRO_CALL_MEMBER( + OpenSHC::Audio::SFX::SFXState_Func::scheduleSFXVariation, DAT_SFXState::ptr)(7, 1); + BVar3 = MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::shouldSoundXNotBePlaying, + DAT_SoundSystemState::ptr)(); + if (!BVar3 && 2 < iVar4 && DAT_GameCore::instance.genieVoiceActive) { + MACRO_CALL_MEMBER(OpenSHC::Random::RNG_Func::nextRandomNumber1, SEC_RNG::ptr)(); + switch ((int)SEC_RNG::instance.currentNumber1 % 7) { + case 0: + // "We will be invincible" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_05.wav" + DAT_SFXState::ptr)(s_genie_05_wav_005a76f0); + break; + case 1: + // "A worthy ally" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_06.wav" + DAT_SFXState::ptr)(s_genie_06_wav_005a76e0); + break; + case 2: + // "Watch my back" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_07.wav" + DAT_SFXState::ptr)(s_genie_07_wav_005a76d0); + break; + case 3: + // "Yeeees" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_08.wav" + DAT_SFXState::ptr)(s_genie_08_wav_005a76c0); + break; + case 4: + // "On my honour" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_09.wav" + DAT_SFXState::ptr)(s_genie_09_wav_005a76b0); + break; + case 5: + // "We rule" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_10.wav" + DAT_SFXState::ptr)(s_genie_10_wav_005a76a0); + break; + case 6: + // "I pledge allegiance" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_04.wav" + DAT_SFXState::ptr)(s_genie_04_wav_005a7690); + } + } + } else { + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] = bVar1; + MACRO_CALL_MEMBER( + OpenSHC::Audio::SFX::SFXState_Func::scheduleSFXVariation, DAT_SFXState::ptr)(7, 1); + } + } + } + if ((param_1 - 10 == DAT_00df423c::instance) && (INT_00df4244::instance == 0)) { + INT_00df4244::instance = 1; + } else { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + DAT_00df423c::instance = 0; + } + } + if (param_1 == 21) { + if ((DAT_00df423c::instance != 0) + && (DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance] != 0)) { + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[( + char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance]] = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + DAT_00df423c::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::scheduleSFXVariation, DAT_SFXState::ptr)( + 7, 0); + } + } else if (param_1 == 100) { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + int cVar2 = 0; + for (int i = 1; i < countof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray); ++i) { + if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]) { + cVar2 += '\x01'; + } + } + if (cVar2 != '\0') { + // "The sides are drawn" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "Genie_02.wav" + s_Genie_02_wav_005a7680); + } + } else { + if (param_1 == 101) { + memcpy(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray, + DAT_GameSynchronyState::instance.playerGroupArray2Unk, + sizeof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray)); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + } + if (param_1 == 200) { + if (DAT_00df423c::instance != 0) { + DAT_00df423c::instance = 0; + } + } else if (((param_1 == 201) || (param_1 == 202)) && DAT_00df423c::instance != 0 + && (INT_00df4244::instance != 1 || (param_1 == 201))) { + DAT_00df423c::instance = 0; + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp new file mode 100644 index 0000000000..43dc7c924c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp @@ -0,0 +1,220 @@ +#include "../ScenarioDescription.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_00ed2798.hpp" +#include "OpenSHC/Globals/DAT_ARRAY_00ed26d0.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/INT_00ed27bc.hpp" +#include "OpenSHC/Globals/INT_00ed27c4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8250 + void ScenarioDescription::MenuItemRenderFunction_ScenarioDescription_Main(int param_1, ...) + { + bool bVar1; + uint uVar2; + DAT_ButtonUnknownZero::instance = TRUE; + DAT_StopHandlingMenuItems::instance = 0; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk && param_1 != 10 && param_1 != 12 + && param_1 != 13 && param_1 != -3 && param_1 != -4 && param_1 != -1) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if ((INT_00ed27bc::instance == 1) && (param_1 != 12)) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (param_1 == -1) { + if ((DAT_00ed2798::instance) && (DAT_00ed2798::instance != 1)) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + if (DAT_GameCore::instance.missionNumber1to20 < 4) { + return; + } + } else if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk)) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameCore::instance.mapU4Int1) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameCore::instance.gameSuspended == 1) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + } else { + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, (int)(DAT_ButtonX::instance + 10), + (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, uVar2, 18, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, DAT_GameState::instance.mapAndTime.difficulty + 19, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_00FF00, 18, FALSE); + return; + } + if (param_1 == -2) { + if (DAT_00ed2798::instance) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_ARRAY_00ed26d0::instance[0].y == 0) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (INT_00ed27bc::instance) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + } else { + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 10, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_CENTER, uVar2, 18, FALSE); + return; + } + if (param_1 == -3) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameCore::instance.gameSuspended != 1) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + } else { + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 11, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_CENTER, uVar2, 18, FALSE); + return; + } + if (param_1 == -4) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (INT_00ed27c4::instance < 2) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + } else { + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 10, (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_CENTER, uVar2, 18, FALSE); + return; + } + if (((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) + && INT_00ed27bc::instance != 1) { + if (param_1 == 12) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + LAB_004d8543: + if (param_1 == 13) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) + goto LAB_004d8563; + if (param_1 == 12) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + bVar1 = param_1 == 13; + } else { + if (param_1 == 11) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) + || (DAT_GameCore::instance.gameSuspended != 1)) + goto LAB_004d8543; + bVar1 = param_1 == 12; + } + if (bVar1) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_StopHandlingMenuItems::instance = 0; + return; + } + LAB_004d8563: + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp new file mode 100644 index 0000000000..7e93925911 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp @@ -0,0 +1,194 @@ +#include "../SiegeAttackingForceAndStartGoods.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/RoundedBoxEdgeRoundingLevel.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_BLUE.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" +#include "OpenSHC/Globals/PTR_ARRAY_Unknown_UnitGMHeights.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004C0CF0 + void SiegeAttackingForceAndStartGoods::MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main( + int param_1, ...) + { + int iVar2; + uint uVar4; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (param_1 < 0) { + int iVar1 = -param_1; + int iVar3 = iVar1 - 1; + if (iVar3 < 20) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance.SEC_StartingResources + [DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3]], + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance.SEC_StartingResources + [DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3]], + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + iVar1 = DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3] * 2 + 141; + if (iVar1 == 157) { + iVar1 = 155; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1, + (int)(DAT_ButtonX::instance + 10), + (DAT_ButtonY::instance + - (int)*(short*)((int)PTR_ARRAY_Unknown_UnitGMHeights::instance + + (GMFirstPictureIndex::instance[46] + iVar1) * 16 + 114) + / 2) + + 15); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + return; + } + if (iVar3 < 30) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar4 = OpenSHC::Rendering::Colors::COL_C2F0EB; + iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; + } else { + uVar4 = OpenSHC::Rendering::Colors::COL_CCFAFF; + iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(iVar2, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, uVar4, 18, FALSE, 0); + iVar2 = iVar1 - 20; + if (iVar3 == 29) { + iVar2 = iVar1 - 19; + } + } else { + if (iVar3 == 30) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + // added by script: "Popularity" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); + } else { + // added by script: "Popularity" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (iVar1 > 9 - 0x29U) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(iVar2, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(iVar2, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + iVar2 = iVar1 - 29; + if (iVar3 == 45) { + iVar2 = 10; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_ARMY_UNITS, iVar2, + (int)(DAT_ButtonX::instance), + (DAT_ButtonY::instance + - (int)*(short*)((int)PTR_ARRAY_Unknown_UnitGMHeights::instance + + (GMFirstPictureIndex::instance[174] + iVar2) * 16 + 114) + / 2) + + 15); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (param_1 < 1000) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), + OpenSHC::UI::Enums::RBERL_SLIGHT); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp new file mode 100644 index 0000000000..3fdd2e5b98 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp @@ -0,0 +1,214 @@ +#include "../SinglePlayerMapChoice.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042D140 + void SinglePlayerMapChoice::MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands(int param_1, ...) + { + int iVar1; + int yParam; + uint uVar2; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + switch (param_1) { + case -10: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(0, (int)(DAT_ButtonBackgroundBlendStrength::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case -11: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(1, (int)(DAT_ButtonBackgroundBlendStrength::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case -100: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(0, (int)(DAT_ButtonBackgroundBlendStrength::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case -101: + // scroll arrows + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(1, (int)(DAT_ButtonBackgroundBlendStrength::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case 2: + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 /= 32; + break; + case 69: + if (DAT_MapMissionType::instance == 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_GameCore::instance.mapU4Int1_2 != 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + if (DAT_ButtonCurrentlyInteracting::instance) { + // Difficulty + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, (iVar1 / 32) + 32); + } else { + // Difficulty + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, (iVar1 / 32) + 32); + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "easy, normal, hard, very hard" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, DAT_GameState::instance.mapAndTime.difficulty + 19, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_00FF00, 18, FALSE, (iVar1 / 32) + 32); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case 74: + if (DAT_MapMissionType::instance != 2) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerSlotID != 2) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_GameCore::instance.mapU4Int1_2 != 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if ((DAT_SH1_SiegeAdvancedMode::instance != 0) && (DAT_00b960dc::instance == 0)) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 = (iVar1 / 32) + 32; + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + yParam = DAT_ButtonY::instance + 7; + goto LAB_0042d4cd; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Advanced" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, param_1, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, + (iVar1 / 32) + 32); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 += (iVar1 >> 0x1f & 0x1fU); + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + goto LAB_0042d4c2; + case 77: + if (DAT_MapMissionType::instance != 2) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerSlotID == 1) { + param_1 = 78; + } + if (DAT_GameCore::instance.mapU4Int1_2 != 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 = (iVar1 / 32) + 32; + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + yParam = DAT_ButtonY::instance + 7; + goto LAB_0042d4cd; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 += (iVar1 >> 0x1f & 0x1fU); + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + LAB_0042d4c2: + yParam = DAT_ButtonY::instance + 7; + iVar1 = (iVar1 >> 5) + 32; + LAB_0042d4cd: + // "Attacking" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, param_1, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), yParam, OpenSHC::Text::TTA_CENTER, uVar2, + 18, FALSE, iVar1); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case 65: + iVar1 = 32; + if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + < 0) { + iVar1 = 16; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + iVar1 *= 32 - DAT_ButtonBackgroundBlendStrength::instance; + iVar1 = -(iVar1 / 32); + break; + default: + goto switchD_0042d163_caseD_ffffff9d; + } + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)(iVar1 + 32); + switchD_0042d163_caseD_ffffff9d: + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp new file mode 100644 index 0000000000..69e087597b --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp @@ -0,0 +1,255 @@ +#include "../TextEditor.func.hpp" + +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/Util/WideCharMultiByteState.func.hpp" +#include "OpenSHC/Text/Enums/HelpTextToken.hpp" + +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WideCharMultiByteState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Text::Enums::HelpTextToken; + + // FUNCTION: STRONGHOLDCRUSADER 0x00461570 + void TextEditor::MenuItemActionHandler_TextEditor_TextInputRelatedUnk() + { + WCHAR WVar1; + uint uVar2; + int iVar3; + WCHAR* pWVar4; + int iVar5; + int iVar6; + WCHAR* pWVar7; + if (DAT_TextEditorState::instance.useAlternateHelpTab == 0) { + uVar2 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::dequeueInputBufferChar, DAT_UserTextHandlerState::ptr)(); + if ((int)uVar2 < 240) { + return; + } + switch (uVar2) { + case 245: + iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight; + iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (iVar3 < ((iVar5 <= 0) - 1 & iVar5) - 18) { + iVar3 += 18; + if (((iVar5 <= 0) - 1 & iVar5) < iVar3) { + iVar3 = (iVar5 <= 0) - 1 & iVar5; + } + } else { + iVar3 = (iVar5 <= 0) - 1 & iVar5; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3; + return; + case 244: + iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (18 <= iVar3) { + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3 - 18; + return; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; + return; + case 246: + DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; + return; + case 247: + iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight; + DAT_TextEditorState::instance.helpContentScrollOffsetY = (iVar5 <= 0) - 1 & iVar5; + return; + case 251: + iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight; + iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (iVar3 < ((iVar5 <= 0) - 1 & iVar5) - DAT_TextEditorState::instance.dialogContentHeight) { + iVar3 += DAT_TextEditorState::instance.dialogContentHeight; + if (((iVar5 <= 0) - 1 & iVar5) < iVar3) { + iVar3 = (iVar5 <= 0) - 1 & iVar5; + } + } else { + iVar3 = (iVar5 <= 0) - 1 & iVar5; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3; + return; + case 250: + iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + iVar6 = DAT_TextEditorState::instance.dialogContentHeight; + if (iVar3 >= iVar6) { + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3 - iVar6; + return; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; + return; + default: + return; + } + } + uVar2 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::dequeueInputBufferChar, DAT_UserTextHandlerState::ptr)(); + iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + if (uVar2 != -1) { + if ((int)uVar2 < 240) { + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar3 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar3; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = (OpenSHC::Text::Enums::HTT_NONE); + } + if ((DAT_TextEditorState::instance.isCustomTextMode != 0) + && (-1 < DAT_TextEditorState::instance.customTextMaxLength)) { + pWVar4 = pWVar7; + do { + WVar1 = *pWVar4; + ++pWVar4; + } while (WVar1 != L'\0'); + if (DAT_TextEditorState::instance.customTextMaxLength <= (int)pWVar4 - (int)(pWVar7 + 1) >> 1) + goto switchD_00461715_caseD_a; + } + LAB_004616f7: + iVar3 = DAT_TextEditorState::instance.customHelpTextLength; + if (DAT_TextEditorState::instance.activeHelpHotspotIndex + <= DAT_TextEditorState::instance.customHelpTextLength) { + do { + pWVar7[iVar3 + 1] = pWVar7[iVar3]; + --iVar3; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + } while (iVar3 >= DAT_TextEditorState::instance.activeHelpHotspotIndex); + } + WVar1 = MACRO_CALL_MEMBER(OpenSHC::Util::WideCharMultiByteState_Func::singleMultiByteToWideChar, + DAT_WideCharMultiByteState::ptr)((char)uVar2); + // put character in memory + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = WVar1; + ++DAT_TextEditorState::instance.customHelpTextLength; + ++DAT_TextEditorState::instance.activeHelpHotspotIndex; + } else { + switch (uVar2) { + case 240: + if (DAT_TextEditorState::instance.isCustomTextMode == 0) { + uVar2 = 9; + goto LAB_004616f7; + } + break; + case 241: + if (DAT_TextEditorState::instance.isCustomTextMode == 0) { + uVar2 = 6; + goto LAB_004616f7; + } + break; + case 242: + iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + if (iVar3 <= 0) + break; + iVar6 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[iVar3 - 1]; + if (32 <= iVar6) { + DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 - 1; + break; + } + iVar5 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)iVar6); + DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 - iVar5; + break; + case 243: + iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + if (iVar3 >= DAT_TextEditorState::instance.customHelpTextLength) + break; + iVar6 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[iVar3]; + if (32 <= iVar6) { + DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 + 1; + break; + } + iVar5 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)iVar6); + DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 + iVar5; + break; + case 244: + DAT_TextEditorState::instance.field_0x2396c = -1; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::setTextRenderingLogic, DAT_TextEditorState::ptr)(); + break; + case 245: + DAT_TextEditorState::instance.field_0x2396c = 1; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::setTextRenderingLogic, DAT_TextEditorState::ptr)(); + break; + case 246: + DAT_TextEditorState::instance.activeHelpHotspotIndex = 0; + break; + case 247: + DAT_TextEditorState::instance.activeHelpHotspotIndex + = DAT_TextEditorState::instance.customHelpTextLength; + break; + case 248: + iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + if (iVar3 <= 0) + break; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + iVar6 = pWVar7[iVar3 - 1]; + iVar5 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)iVar6); + if (DAT_TextEditorState::instance.customHelpTextLength > iVar3 + iVar5) { + iVar6 = (iVar3 - iVar5) * 2; + do { + // delete character in memory + *(WCHAR*)(iVar6 + (int)pWVar7) = pWVar7[iVar3]; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + if (pWVar7[iVar3] == L'\0') + break; + ++iVar3; + iVar6 += 2; + } while (iVar3 < DAT_TextEditorState::instance.customHelpTextLength + iVar5); + } + DAT_TextEditorState::instance.customHelpTextLength -= iVar5; + DAT_TextEditorState::instance.activeHelpHotspotIndex -= iVar5; + break; + case 249: + iVar5 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance + .activeHelpHotspotIndex]); + if (iVar3 < DAT_TextEditorState::instance.customHelpTextLength) { + if (DAT_TextEditorState::instance.customHelpTextLength > iVar3 + iVar5) { + iVar6 = (iVar3 + iVar5) * 2; + do { + pWVar7[iVar3] = *(WCHAR*)(iVar6 + (int)pWVar7); + if (DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[iVar3] == L'\0') + break; + ++iVar3; + iVar6 += 2; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + } while (iVar3 < DAT_TextEditorState::instance.customHelpTextLength + iVar5); + } + DAT_TextEditorState::instance.customHelpTextLength -= iVar5; + } + } + } + switchD_00461715_caseD_a: + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + } + if ((ushort)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] + < 32) { + DAT_TextEditorState::instance.field_0x23970 + = (uint)(ushort)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex]; + return; + } + DAT_TextEditorState::instance.field_0x23970 = 0; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp new file mode 100644 index 0000000000..59b49aa88e --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp @@ -0,0 +1,186 @@ +#include "../VideoOptions.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/UI/MenuItems/BuildingAndStatusMenu.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/ScrollSpeed.hpp" + +#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ScrollingHandler.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Rendering::ScreenResolutionEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00493E20 + void VideoOptions::MenuItemActionHandler_VideoOptions_Main(int param_1, ...) + { + int dialogX; + int dialogY; + switch (param_1) { + case 11: + do { + if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_800x600) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_1024x600; + } else if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_1024x600) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_1024x768; + } else if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_1280x1024) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_1360x768; + } else if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_1360x768) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_1366x768; + } else { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + += OpenSHC::Rendering::SRE_800x600; + if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_1360x768) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_800x600; + } + } + } while (DAT_WindowAndDirectDraw::instance.resolutionSupported_0x68 + .array[DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution] + == 0); + return; + case 12: + DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01 ^= 1; + return; + case 16: + DAT_MenuTextInputState::instance.menuScrollSpeedSetting += OpenSHC::UI::SS_FAST; + if (3 <= (int)DAT_MenuTextInputState::instance.menuScrollSpeedSetting) { + DAT_MenuTextInputState::instance.menuScrollSpeedSetting = 0; + } + break; + case 17: + goto switchD_00493e37_caseD_11; + case 18: + if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + != DAT_WindowAndDirectDraw::instance.currentGameResolution) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::prepareWindowAndDDraw_2Unk, + DAT_WindowAndDirectDraw::ptr)(DAT_WindowAndDirectDraw::instance.runGameAsExclusiveFullscreen, + (ScreenResolutionEnum)(( + int)(DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution))); + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::resetupViewportThunk, + DAT_ViewportRenderState::ptr)(); + MACRO_CALL(OpenSHC::UI::MenuItems::BuildingAndStatusMenu_Func:: + MenuItemActionHandler_BuildingAndStatusMenu_StopBuildingOrPeasantBinkPlayback)(); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + if (DAT_MenuModalComposition3::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR) { + if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_800x600) { + dialogY = 50; + dialogX = 745; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1024x768) { + dialogY = 56; + dialogX = 969; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1024x600) { + dialogY = 56; + dialogX = 969; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1600x1200) { + LAB_00493fda: + dialogY = 56; + dialogX = 1545; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1280x1024) { + dialogY = 56; + dialogX = 1225; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1280x720) { + dialogY = 56; + dialogX = 1225; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1440x900) { + dialogY = 56; + dialogX = 1385; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1920x1080) { + dialogY = 56; + dialogX = 1865; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1920x1200) { + dialogY = 56; + dialogX = 1865; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_2560x1440) { + dialogY = 56; + dialogX = 2505; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_2560x1600) { + dialogY = 56; + dialogX = 2505; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1366x768) { + dialogY = 56; + dialogX = 1311; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1360x768) { + dialogY = 56; + dialogX = 1305; + } else { + if (DAT_WindowAndDirectDraw::instance.currentGameResolution + != OpenSHC::Rendering::SRE_1680x1050) { + if (DAT_WindowAndDirectDraw::instance.currentGameResolution + != OpenSHC::Rendering::SRE_1600x900) + goto LAB_00493ff0; + goto LAB_00493fda; + } + dialogY = 56; + dialogX = 1625; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)( + OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, dialogX, dialogY); + } + } + LAB_00493ff0: + if (DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01 + != DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, + DAT_ViewportRenderState::ptr)(DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01); + DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } + if (DAT_MenuTextInputState::instance.menuCursorType != DAT_MouseState::instance.cursorType) { + DAT_MouseState::instance.cursorType = DAT_MenuTextInputState::instance.menuCursorType; + MACRO_CALL_MEMBER( + OpenSHC::Input::MouseState_Func::makeSelectedCursorTypeCurrent, DAT_MouseState::ptr)(); + } + DAT_ScrollingHandler::instance.scrollSpeedSetting_0x38 + = DAT_MenuTextInputState::instance.menuScrollSpeedSetting; + switchD_00493e37_caseD_11: + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + return; + case -20: + DAT_MenuTextInputState::instance.menuCursorType = 1; + break; + case -10: + DAT_MenuTextInputState::instance.menuCursorType = 2; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6ec8017690..8f763bb448 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6819,7 +6819,7 @@ SHC_3BB0A8C1_0x004276F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00427740 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00427810 | 0.0% | Pending +SHC_3BB0A8C1_0x00427810 | 58.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x00427CB2 | 0.0% | Pending @@ -6889,7 +6889,7 @@ SHC_3BB0A8C1_0x00428A50 | 0.0% | Pending SHC_3BB0A8C1_0x00428A60 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00428AC0 | 0.0% | Pending +SHC_3BB0A8C1_0x00428AC0 | 42.5% | gynt's draft, mechanical pass; register allocation and structure SHC_3BB0A8C1_0x00429630 | 100.0% | Reimplemented @@ -7481,7 +7481,7 @@ SHC_3BB0A8C1_0x0042D138 | 0.0% | Pending SHC_3BB0A8C1_0x0042D13C | 0.0% | Pending -SHC_3BB0A8C1_0x0042D140 | 0.0% | Pending +SHC_3BB0A8C1_0x0042D140 | 46.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0042D554 | 0.0% | Pending @@ -11145,7 +11145,7 @@ SHC_3BB0A8C1_0x00434300 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00434340 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00434350 | 0.0% | Pending +SHC_3BB0A8C1_0x00434350 | 67.1% | compiles again, mechanical pass; structure SHC_3BB0A8C1_0x004347F0 | 100.0% | Reimplemented @@ -12943,7 +12943,7 @@ SHC_3BB0A8C1_0x004387D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00438B60 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00438BE0 | 0.0% | Pending +SHC_3BB0A8C1_0x00438BE0 | 40.9% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0043907C | 0.0% | Pending @@ -13661,7 +13661,7 @@ SHC_3BB0A8C1_0x004409B4 | 0.0% | Pending SHC_3BB0A8C1_0x004409C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00440A50 | 0.0% | Pending +SHC_3BB0A8C1_0x00440A50 | 46.3% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x00440AE0 | 0.0% | Pending @@ -14157,7 +14157,7 @@ SHC_3BB0A8C1_0x0044305C | 0.0% | Pending SHC_3BB0A8C1_0x00443060 | 0.0% | Pending -SHC_3BB0A8C1_0x00443070 | 0.0% | Pending +SHC_3BB0A8C1_0x00443070 | 53.2% | compiles again, mechanical pass; structure SHC_3BB0A8C1_0x00443778 | 0.0% | Pending @@ -14351,7 +14351,7 @@ SHC_3BB0A8C1_0x00443A2D | 0.0% | Pending SHC_3BB0A8C1_0x00443A2E | 0.0% | Pending -SHC_3BB0A8C1_0x00443A30 | 0.0% | Pending +SHC_3BB0A8C1_0x00443A30 | 23.3% | gynt's draft, mechanical pass; register allocation and structure SHC_3BB0A8C1_0x004442A4 | 0.0% | Pending @@ -18835,7 +18835,7 @@ SHC_3BB0A8C1_0x00461520 | 0.0% | Pending SHC_3BB0A8C1_0x00461550 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00461570 | 0.0% | Pending +SHC_3BB0A8C1_0x00461570 | 40.9% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x00461750 | 0.0% | Pending @@ -19763,7 +19763,7 @@ SHC_3BB0A8C1_0x00464300 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00464370 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004643F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004643F0 | 49.0% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0046481C | 0.0% | Pending @@ -19995,7 +19995,7 @@ SHC_3BB0A8C1_0x00466E20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00466F60 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00467040 | 0.0% | Pending +SHC_3BB0A8C1_0x00467040 | 93.3% | register allocation in the shared tail (reset and command parameters) and in the sell branch SHC_3BB0A8C1_0x004672F0 | 0.0% | Pending @@ -23837,7 +23837,7 @@ SHC_3BB0A8C1_0x00493E16 | 0.0% | Pending SHC_3BB0A8C1_0x00493E17 | 0.0% | Pending -SHC_3BB0A8C1_0x00493E20 | 0.0% | Pending +SHC_3BB0A8C1_0x00493E20 | 61.5% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0049404E | 0.0% | Pending @@ -24113,7 +24113,7 @@ SHC_3BB0A8C1_0x004948C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00494920 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00494950 | 0.0% | Pending +SHC_3BB0A8C1_0x00494950 | 64.2% | strcat intrinsic, mechanical pass; structure SHC_3BB0A8C1_0x00494DB0 | 0.0% | Pending @@ -25795,7 +25795,7 @@ SHC_3BB0A8C1_0x004AC650 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AC6E0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004AC7A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004AC7A0 | 52.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004AD110 | 0.0% | Pending @@ -25811,7 +25811,7 @@ SHC_3BB0A8C1_0x004AD780 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AD7C0 | 0.0% | Pending -SHC_3BB0A8C1_0x004AD920 | 0.0% | Pending +SHC_3BB0A8C1_0x004AD920 | 53.3% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004ADD90 | 100.0% | Reimplemented @@ -25879,7 +25879,7 @@ SHC_3BB0A8C1_0x004AE950 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AEA10 | 0.0% | Pending -SHC_3BB0A8C1_0x004AEA50 | 0.0% | Pending +SHC_3BB0A8C1_0x004AEA50 | 71.2% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004AEB20 | 0.0% | Pending @@ -25979,7 +25979,7 @@ SHC_3BB0A8C1_0x004B1410 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B1471 | 0.0% | Pending -SHC_3BB0A8C1_0x004B14C0 | 0.0% | Pending +SHC_3BB0A8C1_0x004B14C0 | 60.5% | compiles again, mechanical pass; structure SHC_3BB0A8C1_0x004B18D0 | 100.0% | Reimplemented @@ -27641,7 +27641,7 @@ SHC_3BB0A8C1_0x004B9530 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B9610 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B9620 | 0.0% | Pending +SHC_3BB0A8C1_0x004B9620 | 64.0% | compiles again, mechanical pass; structure SHC_3BB0A8C1_0x004B9AA8 | 0.0% | Pending @@ -33185,7 +33185,7 @@ SHC_3BB0A8C1_0x004C0CE6 | 0.0% | Pending SHC_3BB0A8C1_0x004C0CE7 | 0.0% | Pending -SHC_3BB0A8C1_0x004C0CF0 | 0.0% | Pending +SHC_3BB0A8C1_0x004C0CF0 | 53.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004C1070 | 100.0% | Reimplemented @@ -35925,7 +35925,7 @@ SHC_3BB0A8C1_0x004D8228 | 0.0% | Pending SHC_3BB0A8C1_0x004D822C | 0.0% | Pending -SHC_3BB0A8C1_0x004D8250 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8250 | 42.4% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004D839E | 0.0% | Pending