diff --git a/src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp b/src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp new file mode 100644 index 0000000000..1b4a186f50 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp @@ -0,0 +1,191 @@ +#include "../CrusadeMap.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MissionDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DWORD_00ed27a8.hpp" +#include "OpenSHC/Globals/DWORD_00ed311c.hpp" +#include "OpenSHC/Globals/INT_00eb9b48.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8EC0 + void CrusadeMap::MenuItemActionHandler_CrusadeMap_Main(int button, ...) + { + // Skip Current Mission: the trail's next mission is marked skipped with the chicken (-1200 months) + if (button == 1000) { + if (DAT_SkirmishTrailRelated1::instance <= 0) { + return; + } + // the trails have 50, 30 and 20 missions + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_FIRST_EDITION) { + int const mission = DAT_GameCore::instance.furthestSkirmishTrailMission; + if (mission >= countof(DAT_MissionDefinedData::instance.SkirmishTrailMissionPositions) - 1) { + return; + } + DAT_GameCore::instance.skirmishTrailProgress = mission; + if (DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken[mission] != -1) { + return; + } + DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken[mission] = -1200; + if (DAT_GameCore::instance.skirmishTrailProgress + == countof(DAT_MissionDefinedData::instance.SkirmishTrailMissionPositions) - 1) { + return; + } + ++DAT_GameCore::instance.skirmishTrailProgress; + ++DAT_GameCore::instance.furthestSkirmishTrailMission; + // this call and the code after it are repeated in each trail's branch, for the match + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)(1); + --DAT_SkirmishTrailRelated1::instance; + DWORD_00ed311c::instance = timeGetTime(); + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setSoundWithVariation, DAT_SFXState::ptr)( + 258, 100); + return; + } + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + int const mission = DAT_GameCore::instance.furthestWarchestTrailMission; + if (mission >= countof(DAT_MissionDefinedData::instance.WarchestTrailMissionPositions) - 1) { + return; + } + DAT_GameCore::instance.warchestTrailProgress = mission; + if (DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken[mission] != -1) { + return; + } + DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken[mission] = -1200; + if (DAT_GameCore::instance.warchestTrailProgress + == countof(DAT_MissionDefinedData::instance.WarchestTrailMissionPositions) - 1) { + return; + } + ++DAT_GameCore::instance.warchestTrailProgress; + ++DAT_GameCore::instance.furthestWarchestTrailMission; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)(2); + --DAT_SkirmishTrailRelated1::instance; + DWORD_00ed311c::instance = timeGetTime(); + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setSoundWithVariation, DAT_SFXState::ptr)( + 258, 100); + return; + } + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + int const mission = DAT_GameCore::instance.furthestExtremeTrailMission; + if (mission >= 19) { + return; + } + DAT_GameCore::instance.extremeTrailProgress = mission; + if (DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[mission] != -1) { + return; + } + DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[mission] = -1200; + if (DAT_GameCore::instance.extremeTrailProgress == 19) { + return; + } + ++DAT_GameCore::instance.extremeTrailProgress; + ++DAT_GameCore::instance.furthestExtremeTrailMission; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)(3); + --DAT_SkirmishTrailRelated1::instance; + DWORD_00ed311c::instance = timeGetTime(); + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setSoundWithVariation, DAT_SFXState::ptr)( + 258, 100); + } + return; + } + // the lord picked: his face goes into the player's face slot, then the mission briefing + if (button == 10) { + MACRO_CALL(OpenSHC::OS_Func::_memcpy)(DAT_TextureRenderCoreObject::instance.bitmapsFaces_0x94 + + (DAT_GameSynchronyState::instance.currentPlayerSlotID + 19) * 66 * 64, + DAT_TextureRenderCoreObject::instance.bitmapsFaces_0x94 + + (DAT_GameCore::instance.lordIconUnk - 2) * 66 * 64, + 66 * 64 * sizeof(ushort)); + DAT_TextureRenderCoreObject::instance + .bitmapFaceSizes[DAT_GameSynchronyState::instance.currentPlayerSlotID + 19] + = 66 * 64 * sizeof(ushort); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_MISSION_INTRO, 0); + return; + } + // back to the choice of crusade + if (button == 11) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SELECT_CRUSADE, 0); + return; + } + // a click on the map picks the mission under the mouse, up to the furthest one reached + if (button == 1) { + int const clickX = DAT_MouseState::instance.screenSpaceX - DAT_ButtonX::instance; + int const clickY = DAT_MouseState::instance.screenSpaceY - DAT_ButtonY::instance; + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_FIRST_EDITION) { + for (int mission = 0; + mission < countof(DAT_MissionDefinedData::instance.SkirmishTrailMissionPositions); ++mission) { + if (mission > DAT_GameCore::instance.furthestSkirmishTrailMission) { + return; + } + int const left + = DAT_MissionDefinedData::instance.SkirmishTrailMissionPositions[mission][0] - 10; + int const top = DAT_MissionDefinedData::instance.SkirmishTrailMissionPositions[mission][1] - 10; + if (clickX >= left && clickX <= left + 20 && clickY >= top && clickY <= top + 20) { + DAT_GameCore::instance.skirmishTrailProgress = mission; + INT_00eb9b48::instance = 1; + DWORD_00ed27a8::instance = timeGetTime(); + return; + } + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + for (int mission = 0; + mission < countof(DAT_MissionDefinedData::instance.WarchestTrailMissionPositions); ++mission) { + if (mission > DAT_GameCore::instance.furthestWarchestTrailMission) { + return; + } + int const left + = DAT_MissionDefinedData::instance.WarchestTrailMissionPositions[mission][0] - 10; + int const top = DAT_MissionDefinedData::instance.WarchestTrailMissionPositions[mission][1] - 10; + if (clickX >= left && clickX <= left + 20 && clickY >= top && clickY <= top + 20) { + DAT_GameCore::instance.warchestTrailProgress = mission; + INT_00eb9b48::instance = 1; + DWORD_00ed27a8::instance = timeGetTime(); + return; + } + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + // only the first 20 of the 30 positions are missions + for (int mission = 0; mission < 20; ++mission) { + if (mission > DAT_GameCore::instance.furthestExtremeTrailMission) { + return; + } + int const left = DAT_MissionDefinedData::instance.ExtremeTrailMissionPositions[mission][0] - 10; + int const top = DAT_MissionDefinedData::instance.ExtremeTrailMissionPositions[mission][1] - 10; + if (clickX >= left && clickX <= left + 20 && clickY >= top && clickY <= top + 20) { + DAT_GameCore::instance.extremeTrailProgress = mission; + INT_00eb9b48::instance = 1; + DWORD_00ed27a8::instance = timeGetTime(); + return; + } + } + } + return; + } + // the rankings + if (button == 99) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_RANKING_GAMES, 0); + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFD); + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_ToolbarButtonPressed.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_ToolbarButtonPressed.cpp new file mode 100644 index 0000000000..72aec10bf8 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_ToolbarButtonPressed.cpp @@ -0,0 +1,427 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Audio/MissingResourceState.func.hpp" +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Map/Units/TribesState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/Audio/SFX/ResourceLackSFX.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.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/Game/Resources/ResourceType.hpp" +#include "OpenSHC/Map/Buildings/BuildingType.hpp" +#include "OpenSHC/Map/Units/UnitType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_00b96110.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_MissingResourceState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_TribesState.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/SEC_RNG.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Commands::MappersEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00444410 + void General::MenuItemActionHandler_General_ToolbarButtonPressed(MappersEnum buttonID) + { + if (DAT_GameSynchronyState::instance.syncStatus != 0) { + return; + } + if (DAT_GameSynchronyState::instance.saveRelated != 0) { + return; + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerDeathRelated + != 0) { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { + return; + } + if (DAT_GameState::instance.mapAndTime.gameOver + != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + return; + } + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .lordKilledByPlayerID + != 0) { + return; + } + if (DAT_GameCore::instance.gamePausedLogical != 0) { + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + if (!MACRO_CALL(OpenSHC::Game_Func::Tutorial_IsActionAllowed)(1, + MACRO_CALL_MEMBER( + OpenSHC::Map::Buildings::BuildingsState_Func::convertCommandBuildingTypeToBuildingType, + DAT_BuildingsState::ptr)(buttonID))) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTutorialHintActiveWithTimestamp)(); + return; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTutorialBuildingActionState)(6, + MACRO_CALL_MEMBER( + OpenSHC::Map::Buildings::BuildingsState_Func::convertCommandBuildingTypeToBuildingType, + DAT_BuildingsState::ptr)(buttonID)); + } + DAT_00b96110::instance = 0; + // cases in the original's block order, for the match + switch (buttonID) { + case OpenSHC::Commands::M_MAPPER_WALL: + case OpenSHC::Commands::M_MAPPER_CRENAL: + case OpenSHC::Commands::M_MAPPER_STAIR: + case OpenSHC::Commands::M_MAPPER_WOODWALL: + if (MACRO_CALL_MEMBER( + OpenSHC::Game::GameStateStructures_Func::getWallTilesThatCanBeBuilt, DAT_GameState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID, OpenSHC::Game::Resources::RT_STONE) + == 0) { + MACRO_CALL_MEMBER(OpenSHC::Audio::MissingResourceState_Func::playResourceLackSFX, + DAT_MissingResourceState::ptr)(1, OpenSHC::Audio::SFX::RLSFX_STONE); + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + return; + } + break; + case OpenSHC::Commands::M_MAPPER_DELETE: + DAT_TileMapState::instance.placementOnWall = 0; + break; + case OpenSHC::Commands::M_MAPPER_MOAT: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { + buttonID = OpenSHC::Commands::M_MAPPER_DUGMOAT; + } + break; + case OpenSHC::Commands::M_MAPPER_ANTIMOAT: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { + buttonID = OpenSHC::Commands::M_MAPPER_UNDUGMOAT; + } + break; + case OpenSHC::Commands::M_MAPPER_TOTEST: + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAP_EDITOR_LANDSCAPING, 0); + return; + case OpenSHC::Commands::M_MAPPER_PATROL: + if (MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)() + == OpenSHC::Map::Units::UT_INVALID) { + return; + } + if (DAT_TribesState::instance.patrolButtonPressed) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTribesPatrolButtonPressed)(FALSE); + DAT_TribesState::instance.rallyCount = 1; + return; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTribesPatrolButtonPressed)(TRUE); + DAT_TribesState::instance.rallyCount = 1; + return; + // each building case has its own copy; MSVC merges them into the first, as the original has it + case OpenSHC::Commands::M_MAPPER_GRANARY: { + MACRO_CALL_MEMBER( + OpenSHC::Game::GameStateStructures_Func::validateBuildingCategoryReference, DAT_GameState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID, OpenSHC::Game::Player::Enums::BEIE_GRANARY); + int const buildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_GRANARY] + .id; + if (buildingID != 0 + && DAT_BuildingsState::instance.buildings[buildingID].surfaceAreaUnk + != DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight + * DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[buildingID].x + 1, + DAT_BuildingsState::instance.buildings[buildingID].y + 1); + } + break; + } + case OpenSHC::Commands::M_MAPPER_STORES: { + MACRO_CALL_MEMBER( + OpenSHC::Game::GameStateStructures_Func::validateBuildingCategoryReference, DAT_GameState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID, OpenSHC::Game::Player::Enums::BEIE_STOCKPILE); + int const buildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] + .id; + if (buildingID != 0 + && DAT_BuildingsState::instance.buildings[buildingID].surfaceAreaUnk + != DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight + * DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[buildingID].x + 1, + DAT_BuildingsState::instance.buildings[buildingID].y + 1); + } + break; + } + case OpenSHC::Commands::M_MAPPER_ARMOURY: { + MACRO_CALL_MEMBER( + OpenSHC::Game::GameStateStructures_Func::validateBuildingCategoryReference, DAT_GameState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID, OpenSHC::Game::Player::Enums::BEIE_ARMORY); + int const buildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_ARMORY] + .id; + if (buildingID != 0 + && DAT_BuildingsState::instance.buildings[buildingID].surfaceAreaUnk + != DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight + * DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[buildingID].x + 1, + DAT_BuildingsState::instance.buildings[buildingID].y + 1); + } + break; + } + case OpenSHC::Commands::M_MAPPER_BARRACKS_EURO: { + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::validateBuildingCategoryReference, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + OpenSHC::Game::Player::Enums::BEIE_MERCENARYPOST); + int const buildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_MERCENARYPOST] + .id; + if (buildingID != 0 + && DAT_BuildingsState::instance.buildings[buildingID].surfaceAreaUnk + != DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight + * DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[buildingID].x + 1, + DAT_BuildingsState::instance.buildings[buildingID].y + 1); + } + break; + } + case OpenSHC::Commands::M_MAPPER_BARRACKS_ARAB: { + MACRO_CALL_MEMBER( + OpenSHC::Game::GameStateStructures_Func::validateBuildingCategoryReference, DAT_GameState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID, OpenSHC::Game::Player::Enums::BEIE_BARRACKS); + int const buildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_BARRACKS] + .id; + if (buildingID != 0 + && DAT_BuildingsState::instance.buildings[buildingID].surfaceAreaUnk + != DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight + * DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[buildingID].x + 1, + DAT_BuildingsState::instance.buildings[buildingID].y + 1); + } + break; + } + case OpenSHC::Commands::M_MAPPER_ENGINEERS_GUILD: { + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::validateBuildingCategoryReference, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + OpenSHC::Game::Player::Enums::BEIE_ENGINEERSGUILD); + int const buildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_ENGINEERSGUILD] + .id; + if (buildingID != 0 + && DAT_BuildingsState::instance.buildings[buildingID].surfaceAreaUnk + != DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight + * DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[buildingID].x + 1, + DAT_BuildingsState::instance.buildings[buildingID].y + 1); + } + break; + } + case OpenSHC::Commands::M_MAPPER_TUNNELERS_GUILD: { + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::validateBuildingCategoryReference, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + OpenSHC::Game::Player::Enums::BEIE_TUNNELERSGUILD); + int const buildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_TUNNELERSGUILD] + .id; + if (buildingID != 0 + && DAT_BuildingsState::instance.buildings[buildingID].surfaceAreaUnk + != DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight + * DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[buildingID].x + 1, + DAT_BuildingsState::instance.buildings[buildingID].y + 1); + } + break; + } + case OpenSHC::Commands::M_MAPPER_TRADEPOST: { + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::validateBuildingCategoryReference, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + OpenSHC::Game::Player::Enums::BEIE_MARKETPLACE); + int const buildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_MARKETPLACE] + .id; + if (buildingID != 0 + && DAT_BuildingsState::instance.buildings[buildingID].surfaceAreaUnk + != DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight + * DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[buildingID].x + 1, + DAT_BuildingsState::instance.buildings[buildingID].y + 1); + } + break; + } + case OpenSHC::Commands::M_MAPPER_HEADS: + DAT_TileMapState::instance.decorationVariantIndex = SEC_RNG::instance.currentNumber1 % 7; + MACRO_CALL_MEMBER(OpenSHC::Random::RNG_Func::nextRandomNumber1, SEC_RNG::ptr)(); + break; + case OpenSHC::Commands::M_MAPPER_TUNNEL_CONSTRUCTION: + if (!MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getTunnelerIDOnlyIfFirstSelected, + DAT_UnitsState::ptr)()) { + DAT_StopHandlingMenuItems::instance = 0; + return; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTribesPatrolButtonPressed)(FALSE); + break; + case OpenSHC::Commands::M_MAPPER_GATE_WOOD1A: + case OpenSHC::Commands::M_MAPPER_GATE_WOOD1B: + case OpenSHC::Commands::M_MAPPER_GATE_WOOD1C: + case OpenSHC::Commands::M_MAPPER_GATE_WOOD1D: + buttonID = (MappersEnum)((DAT_TileMapState::instance.mapOrientation / 2 + - OpenSHC::Commands::M_MAPPER_GATE_WOOD1A + buttonID) + % 4 + + OpenSHC::Commands::M_MAPPER_GATE_WOOD1A); + break; + case OpenSHC::Commands::M_MAPPER_GATE_STONE1A: + case OpenSHC::Commands::M_MAPPER_GATE_STONE1B: + buttonID = (MappersEnum)(((DAT_TileMapState::instance.mapOrientation / 2 + buttonID) & 1) + + OpenSHC::Commands::M_MAPPER_GATE_STONE1A); + break; + case OpenSHC::Commands::M_MAPPER_GATE_STONE2A: + case OpenSHC::Commands::M_MAPPER_GATE_STONE2B: + buttonID = (MappersEnum)(((DAT_TileMapState::instance.mapOrientation / 2 + buttonID) & 1) + + OpenSHC::Commands::M_MAPPER_GATE_STONE2A); + break; + case OpenSHC::Commands::M_MAPPER_STANCE_STAND: + MACRO_CALL_MEMBER(OpenSHC::Map::Units::TribesState_Func::queueUnitStance, DAT_TribesState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID, 0); + return; + case OpenSHC::Commands::M_MAPPER_STANCE_DEFENSIVE: + MACRO_CALL_MEMBER(OpenSHC::Map::Units::TribesState_Func::queueUnitStance, DAT_TribesState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID, 1); + return; + case OpenSHC::Commands::M_MAPPER_STANCE_AGGRESSIVE: + MACRO_CALL_MEMBER(OpenSHC::Map::Units::TribesState_Func::queueUnitStance, DAT_TribesState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID, 2); + return; + case OpenSHC::Commands::M_MAPPER_CATAPULT: + case OpenSHC::Commands::M_MAPPER_TREBUCHET: + case OpenSHC::Commands::M_MAPPER_SIEGE_TOWER: + case OpenSHC::Commands::M_MAPPER_BATTERING_RAM: + case OpenSHC::Commands::M_MAPPER_PORTABLE_SHIELD: + case OpenSHC::Commands::M_MAPPER_ARAB_BALLISTA: + if (MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)()) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTribesPatrolButtonPressed)(FALSE); + break; + } + DAT_StopHandlingMenuItems::instance = 0; + return; + case OpenSHC::Commands::M_MAPPER_ENGINEER_BUILD: + if (!MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)()) { + int const siegeEngines + = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::countSelectedCatapultsAndTrebuchets, + DAT_UnitsState::ptr)(); + if (siegeEngines == 0) { + DAT_StopHandlingMenuItems::instance = 0; + return; + } + if (siegeEngines == 1) { + // one catapult or trebuchet: the command needs 10 stone + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[OpenSHC::Game::Resources::RT_STONE] + < 10) { + MACRO_CALL_MEMBER(OpenSHC::Audio::MissingResourceState_Func::playResourceLackSFX, + DAT_MissingResourceState::ptr)(1, OpenSHC::Audio::SFX::RLSFX_STONE); + return; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 + = DAT_UnitsState::instance.unitIDSelectedCatapultOrTrebuchet; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_86); + return; + } + if (siegeEngines == 2) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 + = DAT_TribesState::instance.DAT_CurrentTribeID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = 1; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_86); + return; + } + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTribesPatrolButtonPressed)(FALSE); + DAT_UnitsState::instance.hasEngineerSelected = TRUE; + return; + case OpenSHC::Commands::M_MAPPER_BUILD_BACK: + DAT_UnitsState::instance.hasEngineerSelected = FALSE; + return; + } + if (MACRO_CALL_MEMBER( + OpenSHC::Map::Buildings::BuildingsState_Func::convertCommandBuildingTypeToBuildingType, + DAT_BuildingsState::ptr)(buttonID) + != OpenSHC::Map::Buildings::BT_NONE) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::checkRequiredResourcesForBuildingOrPlanToBuy, + DAT_GameState::ptr)(buttonID, DAT_GameSynchronyState::instance.currentPlayerSlotID, TRUE); + } + DAT_TileMapState::instance.currentMapperCommand = buttonID; + DAT_TileMapState::instance.unitPlacementCount = 1; + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x87); + if (buttonID != OpenSHC::Commands::M_MAPPER_CATAPULT + && buttonID != OpenSHC::Commands::M_MAPPER_ARAB_BALLISTA + && buttonID != OpenSHC::Commands::M_MAPPER_TREBUCHET + && buttonID != OpenSHC::Commands::M_MAPPER_SIEGE_TOWER + && buttonID != OpenSHC::Commands::M_MAPPER_BATTERING_RAM + && buttonID != OpenSHC::Commands::M_MAPPER_PORTABLE_SHIELD + && buttonID != OpenSHC::Commands::M_MAPPER_TUNNEL_CONSTRUCTION + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINT1 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINT2 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINT3 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINT4 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINT5 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINT6 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINT7 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTM1 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTM2 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTM3 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTM4 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTM5 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTM6 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTM7 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTE1 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTE2 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTT1 + && DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_PLACE_ASSEMBLY_POINTK1 + && DAT_GameCore::instance.activeMenuTab.tabType != DAT_GameCore::instance.field_0x30) { + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType = DAT_GameCore::instance.field_0x30; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp b/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp new file mode 100644 index 0000000000..74fbbbafad --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp @@ -0,0 +1,98 @@ +#include "../HistoricCampaignSelect.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.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/Globals/DAT_ButtonCurrentlyInteracting.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_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnknownGFXIndex.hpp" +#include "OpenSHC/Globals/INT_00b95abc.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004255D0 + void HistoricCampaignSelect::MenuItemRenderFunction_HistoricCampaignSelect_Main(int button, ...) + { + if (DAT_UnknownGFXIndex::instance == 1) { + return; + } + if (button != 5 && !DAT_ButtonCurrentlyInteracting::instance) { + if (button == INT_00b95abc::instance) { + INT_00b95abc::instance = -1; + } + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag && button < 5) { + DAT_CurrentButtonGmDataIndex::instance = 353; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } else { + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag && button < 5) { + DAT_CurrentButtonGmDataIndex::instance = 353; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4; + if (button >= 5) { + return; + } + if (INT_00b95abc::instance != button) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x92); + } + INT_00b95abc::instance = button; + } + if (button >= 5) { + return; + } + // the campaign's name, "Heads on Spikes" to "Crusader States" + // one call per hover state, the two the same, for the match + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, button + 309), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } else { + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, button + 309), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, 1, + DAT_ButtonX::instance - 85, DAT_ButtonY::instance - 28, OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, 2, + 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemActionHandler_OverlaySlider_Slider.cpp b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemActionHandler_OverlaySlider_Slider.cpp new file mode 100644 index 0000000000..b86e22dfd2 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemActionHandler_OverlaySlider_Slider.cpp @@ -0,0 +1,98 @@ +#include "../OverlaySlider.func.hpp" + +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004AA600 + void OverlaySlider::MenuItemActionHandler_OverlaySlider_Slider( + int unused, int scrollbarEvent, int* minValue, int* maxValue, int* currentValue) + { + // a range over 200 gets a slider 1.6 times as long: its first half moves a value in steps of 1/4, the + // second half in steps of 1 + switch (scrollbarEvent) { + case 1: { + int const range = DAT_MenuModalComposition2::instance.sliderMaximum + - DAT_MenuModalComposition2::instance.sliderMinimum; + // stored first and overwritten below, as the original does + *maxValue = range; + if (range > 200) { + *maxValue = range * 3 / 5 + range; + *minValue = 0; + } else { + *minValue = DAT_MenuModalComposition2::instance.sliderMinimum; + *maxValue = DAT_MenuModalComposition2::instance.sliderMaximum; + } + *currentValue = DAT_MenuModalComposition2::instance.sliderValue; + return; + } + case 2: + case 3: + // the slider moved: write the value it stands for + if (DAT_MenuModalComposition2::instance.sliderMaximum + - DAT_MenuModalComposition2::instance.sliderMinimum + > 200) { + DAT_MenuModalComposition2::instance.sliderValue = *currentValue; + if (*currentValue > *maxValue / 2) { + if (DAT_MenuModalComposition2::instance.destination != NULL) { + *DAT_MenuModalComposition2::instance.destination = *currentValue + - DAT_MenuModalComposition2::instance.sliderMaximum * 3 / 5 + + DAT_MenuModalComposition2::instance.sliderMinimum; + if (*currentValue == *maxValue) { + *DAT_MenuModalComposition2::instance.destination + = DAT_MenuModalComposition2::instance.sliderMaximum; + } + return; + } + // short operands, for the original's 16-bit subtract and add + *DAT_MenuModalComposition2::instance.destination2 = (short)*currentValue + - (short)(DAT_MenuModalComposition2::instance.sliderMaximum * 3 / 5) + + (short)DAT_MenuModalComposition2::instance.sliderMinimum; + if (*currentValue == *maxValue) { + *DAT_MenuModalComposition2::instance.destination2 + = DAT_MenuModalComposition2::instance.sliderMaximum; + } + return; + } + if (DAT_MenuModalComposition2::instance.destination != NULL) { + *DAT_MenuModalComposition2::instance.destination + = *currentValue / 4 + DAT_MenuModalComposition2::instance.sliderMinimum; + return; + } + *DAT_MenuModalComposition2::instance.destination2 + = *currentValue / 4 + DAT_MenuModalComposition2::instance.sliderMinimum; + return; + } + DAT_MenuModalComposition2::instance.sliderValue = *currentValue; + if (DAT_MenuModalComposition2::instance.destination != NULL) { + *DAT_MenuModalComposition2::instance.destination = *currentValue; + return; + } + *DAT_MenuModalComposition2::instance.destination2 = *currentValue; + return; + case 4: + case 5: + case 6: + return; + case 7: + // a click on the track: the step it moves the slider by + if (DAT_MenuModalComposition2::instance.sliderMaximum + - DAT_MenuModalComposition2::instance.sliderMinimum + > 200) { + if (*currentValue > *maxValue / 2) { + *currentValue = 1; + } else { + *currentValue = 4; + } + return; + } + *currentValue = 1; + return; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemRenderFunction_SaveLoadMap_TableHeader.cpp b/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemRenderFunction_SaveLoadMap_TableHeader.cpp new file mode 100644 index 0000000000..1b43279631 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemRenderFunction_SaveLoadMap_TableHeader.cpp @@ -0,0 +1,56 @@ +#include "../SaveLoadMap.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00492FD0 + void SaveLoadMap::MenuItemRenderFunction_SaveLoadMap_TableHeader(int column, ...) + { + int textNumInGroup = -1; + switch (column) { + case 2: + textNumInGroup = 29; // "Mission" + break; + case 1: + textNumInGroup = 28; // "Date" + break; + case 0: + textNumInGroup = 27; // "Name" + break; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(FALSE, 1, 0); + // one call per hover state, the two the same: the form that compiles to the original's code + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 3; + int const textX = DAT_ButtonX::instance + 8; + 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_GAME_OPTIONS, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } else { + int const textY = DAT_ButtonY::instance + 3; + int const textX = DAT_ButtonX::instance + 8; + 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_GAME_OPTIONS, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6ec8017690..0b1083bef5 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6711,7 +6711,7 @@ SHC_3BB0A8C1_0x00425500 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00425580 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004255D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004255D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00425720 | 100.0% | Reimplemented @@ -14869,7 +14869,7 @@ SHC_3BB0A8C1_0x0044440A | 0.0% | Pending SHC_3BB0A8C1_0x0044440B | 0.0% | Pending -SHC_3BB0A8C1_0x00444410 | 0.0% | Pending +SHC_3BB0A8C1_0x00444410 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00444A14 | 0.0% | Pending @@ -23545,7 +23545,7 @@ SHC_3BB0A8C1_0x00492FC0 | 0.0% | Pending SHC_3BB0A8C1_0x00492FC4 | 0.0% | Pending -SHC_3BB0A8C1_0x00492FD0 | 0.0% | Pending +SHC_3BB0A8C1_0x00492FD0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00493050 | 100.0% | Reimplemented, Security Cookie mismatches @@ -25497,7 +25497,7 @@ SHC_3BB0A8C1_0x004AA480 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AA540 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004AA600 | 0.0% | Pending +SHC_3BB0A8C1_0x004AA600 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AA7D8 | 0.0% | Pending @@ -36013,7 +36013,7 @@ SHC_3BB0A8C1_0x004D8DC0 | 0.0% | Pending SHC_3BB0A8C1_0x004D8DF0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D8EC0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8EC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D91D0 | 100.0% | Reimplemented