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..1e7196b11d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp @@ -0,0 +1,300 @@ +#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/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 { + + // FUNCTION: STRONGHOLDCRUSADER 0x00434350 + void InGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection(int unused, ...) + { + if (DAT_GameSynchronyState::instance.syncStatus != 0) { + return; + } + if (DAT_GameSynchronyState::instance.saveRelated != 0) { + return; + } + // in a multiplayer game, command 117 goes out every 1.5 seconds with a counter, until that reaches 66 + 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) { + INT_00b960f0::instance = timeGetTime() + 20000; + } else { + DWORD const now = timeGetTime(); + if ((int)(now - INT_00b960f0::instance) > 1500) { + INT_00b960f0::instance = now; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = DAT_00b960f8::instance; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + 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 + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk + || DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) + && DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) { + if (MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getArmySize, DAT_UnitsState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID) + == 0) { + if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_CASTLE_KEEPS) { + if (DAT_GameCore::instance.menuSwitchDelay == -1) { + if (MACRO_CALL_MEMBER( + OpenSHC::Game::GameStateStructures_Func::singlePlayerHasKeepAndGranaryCheck, + DAT_GameState::ptr)() + != 1) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func:: + CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 1); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } else { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func:: + CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab + = OpenSHC::UI::Enums::BMTT_CASTLE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + } + } else { + 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.buildMenuTab + == OpenSHC::UI::Enums::BMTT_UNKNOWN_49) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 2); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } else { + 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.buildMenuTab == OpenSHC::UI::Enums::BMTT_UNKNOWN_49) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 2); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + // a call in each arm with its own constant: the original pushes the constant inside the arm + if (DAT_UnitsState::instance.unitCount >= 2300) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, 1); + } else { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, 0); + } + } + // the mouse's view events; each is recorded for the tutorial + 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) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(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) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(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) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(2); + } + } else if (DAT_MouseState::instance.mouseBasedEvent == 4) { + DAT_MouseState::instance.field_0x198 = 2; + // a call in each arm here too, each pushing its own argument as the original does + if (DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk) { + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)(0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)(1); + } + 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) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(3); + } + } else if (DAT_MouseState::instance.mouseBasedEvent == 5) { + 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) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(17); + } + } + // the mouse is not over the map + if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { + if (DAT_MouseState::instance.rightClickStart) { + 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)(); + return; + } + if (DAT_MouseState::instance.rightClickStart) { + 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; + return; + } + if (DAT_MouseState::instance.rightClickStop + && 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) { + // no mapper command: the click is handled below. This arm stays empty on purpose: written as + // `else if (command != M_MAPPER_NULL) { ... }` without it, the match is lost + } else { + if (!DAT_MouseState::instance.leftClickStart + && 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)(); + return; + } + if (DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + > 0) { + return; + } + if (DAT_UnitsState::instance.totalUnitsInSelection > 0) { + return; + } + // nothing selected: a click selects the unit or opens the building under the mouse, or the stockpile + // menu when the tile has the stockpile flag and belongs to the player + DWORD const clickTime = timeGetTime(); + if (!DAT_MouseState::instance.draggingStopped) { + return; + } + if (DAT_MouseState::instance.selectionBoxState != 0) { + return; + } + if (DAT_MouseState::instance.savedSelectionBoxState != 0) { + return; + } + if (MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::selectUnitAndOpenStatusMenu, + AlphaAndButtonSurfaceObj::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseRayUnitID)) { + return; + } + // within 200 ms, the unit that was under the mouse before counts too (the result in a local: tested + // on the call, the match is lost) + BOOLEnum selectedLast = FALSE; + if ((int)(clickTime - DAT_ViewportRenderState::instance.viewportState.field_0x34) < 200) { + selectedLast = MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::selectUnitAndOpenStatusMenu, + AlphaAndButtonSurfaceObj::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseRayLastUnitID); + } + if (selectedLast) { + return; + } + if (MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::openBuildingStatusMenuForBuildingID, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID)) { + return; + } + if ((DAT_TileMapState::instance + .LogicLayer[DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] + & 2) + == 0) { + return; + } + if ((DAT_TileMapState::instance + .WallOwnerLayer[DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] + & 7) + + 1 + != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + return; + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] + .id + == 0) { + return; + } + DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = OpenSHC::UI::Enums::BASMTT_STOCKPILE; + 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/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp new file mode 100644 index 0000000000..3932a8d95a --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp @@ -0,0 +1,184 @@ +#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 button, ...) + { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_StopHandlingMenuItems::instance = 0; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk && button != 10 && button != 12 + && button != 13 && button != -3 && button != -4 && button != -1) { + return; + } + if (INT_00ed27bc::instance == 1 && button != 12) { + return; + } + // -1: the difficulty and its setting, in a campaign mission after the third or an economic one + if (button == -1) { + if (DAT_00ed2798::instance != 0 && DAT_00ed2798::instance != 1) { + return; + } + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.missionNumber1to20 <= 3) + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + return; + } + if (DAT_GameCore::instance.mapU4Int1) { + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + 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); + // a call for each colour: the original pushes the colour inside each arm + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, DAT_ButtonX::instance + 10, DAT_ButtonY::instance + 8, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, DAT_ButtonX::instance + 10, DAT_ButtonY::instance + 8, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, DAT_GameState::instance.mapAndTime.difficulty + 19, + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 8, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_00FF00, 18, FALSE); + return; + } + // -2 to -4: three text buttons + if (button == -2) { + if (DAT_00ed2798::instance) { + return; + } + if (DAT_ARRAY_00ed26d0::instance[0].y == 0) { + return; + } + if (INT_00ed27bc::instance) { + 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) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, + 18, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE); + } + return; + } + if (button == -3) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + return; + } + if (DAT_GameCore::instance.gameSuspended != 1) { + 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) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 11, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, + 18, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 11, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE); + } + return; + } + if (button == -4) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + return; + } + if (INT_00ed27c4::instance <= 1) { + 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) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, + 18, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE); + } + return; + } + // the other buttons are drawn as they are, but for the ones the game mode hides + 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 (button == 11) { + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk + && DAT_GameCore::instance.gameSuspended == 1) { + if (button == 12) { + return; + } + } else if (button == 13) { + return; + } + } else if (button == 12 || button == 13) { + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 + && (button == 12 || button == 13)) { + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuViews/GameStartEnterName/MenuView_GameStartEnterName_Prepare.cpp b/src/OpenSHC/UI/MenuViews/GameStartEnterName/MenuView_GameStartEnterName_Prepare.cpp new file mode 100644 index 0000000000..823ce98253 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/GameStartEnterName/MenuView_GameStartEnterName_Prepare.cpp @@ -0,0 +1,104 @@ +// disable deprecation warnings for strcpy +#pragma warning(disable : 4996) + +#include "../GameStartEnterName.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/IO/LowLevelMemory.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuViews/MainMenu.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Audio/SFX/SpeechEffectID.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuView_TriggerPrepare.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_SpeechDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00440560 + void GameStartEnterName::MenuView_GameStartEnterName_Prepare() + { + // the original reads the local time and drops it + __time64_t now; + MACRO_CALL(OpenSHC::OS_Func::__time64)(&now); + MACRO_CALL(OpenSHC::OS_Func::_localtime)(&now); + // the lord's name, spoken when the game has a recording of it, otherwise the start-game line + char lordName[250]; + strcpy(lordName, + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0)); + BOOLEnum named = FALSE; + for (int lord = 0; lord < countof(DAT_SpeechDefinedData::instance.LordNameToCall); ++lord) { + if (MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::isLordNameCallable, DAT_LowLevelMemory::ptr)( + lordName, DAT_SpeechDefinedData::instance.LordNameToCall[lord].name)) { + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::playSoundOnStream3Unk, + DAT_SoundSystemState::ptr)(DAT_SpeechDefinedData::instance.LordNameToCall[lord].source, 1); + named = TRUE; + break; + } + } + if (!named) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playSpeechSFX, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_GENERAL_STARTGAME); + } + // a name already entered: straight on to the main menu + if (strlen(MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0)) + != 0) { + DAT_GameCore::instance.isNameEntryActive = TRUE; + DAT_GameCore::instance.nameEntryStartTime = timeGetTime(); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::processMenuViewSwitch, DAT_GameCore::ptr)(); + MACRO_CALL(OpenSHC::UI::MenuViews::MainMenu_Func::MenuView_MainMenu_Prepare)(); + MACRO_CALL(OpenSHC::UI::MenuViews::MainMenu_Func::MenuView_MainMenu_DoInitial)(); + MACRO_CALL(OpenSHC::UI::MenuViews::MainMenu_Func::MenuView_MainMenu_DoEveryFrame)(); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = FALSE; + DAT_MenuView_TriggerPrepare::instance = FALSE; + return; + } + // otherwise the name entry dialog, filled in with "Lord Crusader" + DAT_TextureRenderCoreObject::instance.totalLoadedGfx = 0; + // "frontend_combat3.tgx" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::loadGfxFile, + DAT_TextureRenderCoreObject::ptr)(s_frontend_combat3_tgx_005a2134); + MACRO_CALL(OpenSHC::UI::Helpers_Func::LoadTGX_shc_back)(); + DAT_GameCore::instance.isNameEntryActive = FALSE; + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + OpenSHC::Text::TAIT_ZERO); + // "Lord Crusader" + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, 48)); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ENTER_TITLE_ON_GAME_START, FALSE); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..2e8d773ee2 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -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 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004347F0 | 100.0% | Reimplemented @@ -13641,7 +13641,7 @@ SHC_3BB0A8C1_0x00440420 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00440430 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00440560 | 0.0% | Pending +SHC_3BB0A8C1_0x00440560 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00440600 | 0.0% | Pending @@ -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 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D839E | 0.0% | Pending