diff --git a/src/OpenSHC/Game/ScenarioEvents/IngameInvasionEventItemContent.hpp b/src/OpenSHC/Game/ScenarioEvents/IngameInvasionEventItemContent.hpp index 5ba6015795..55aa7eef88 100644 --- a/src/OpenSHC/Game/ScenarioEvents/IngameInvasionEventItemContent.hpp +++ b/src/OpenSHC/Game/ScenarioEvents/IngameInvasionEventItemContent.hpp @@ -26,7 +26,7 @@ namespace Game { int markerIDUnk; // 0x00000078 length: 4 undefined1 padding_0x7c[36]; // 0x0000007C length: 36 int field_0xa0; // 0x000000A0 length: 4 - undefined1 padding_0xa4[4]; // 0x000000A4 length: 4 + int field_0xa4; // 0x000000A4 length: 4 int field_0xa8; // 0x000000A8 length: 4 undefined1 padding_0xac[4]; // 0x000000AC length: 4 diff --git a/src/OpenSHC/Globals/DAT_SentOrRequestedGoodsAmount.hpp b/src/OpenSHC/Globals/DAT_SentOrRequestedGoodsAmount.hpp index 709387f73e..bb93de17c4 100644 --- a/src/OpenSHC/Globals/DAT_SentOrRequestedGoodsAmount.hpp +++ b/src/OpenSHC/Globals/DAT_SentOrRequestedGoodsAmount.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00DF428C -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00DF428C) DAT_SentOrRequestedGoodsAmount; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00DF428C) DAT_SentOrRequestedGoodsAmount; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00DF428C); 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..b1b03ea811 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp @@ -0,0 +1,260 @@ +#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/ResourceTypeMin1.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.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 { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B14C0 + void AlliesSendAndRequestGoods::MenuItemActionHandler_AlliesSendAndRequestGoods_Main(int button, ...) + { + int const playerID = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; + if (button == 40) { + return; + } + if (button <= 20) { + // a good's button: the list skips RTM_PARTIALSTONE and RTM_PITCH, and has iron armour in gold's place + DAT_RequestedGoodsByWhoArray::instance[0] = button; + if (button >= 4) { + DAT_RequestedGoodsByWhoArray::instance[0] = button + 1; + } + if (button >= 5) { + DAT_RequestedGoodsByWhoArray::instance[0]++; + } + if (DAT_RequestedGoodsByWhoArray::instance[0] == OpenSHC::Game::Resources::RTM_GOLD) { + DAT_RequestedGoodsByWhoArray::instance[0] = OpenSHC::Game::Resources::RTM_IRONARMOR; + } + return; + } + // gold + if (button == 21) { + DAT_RequestedGoodsByWhoArray::instance[0] = OpenSHC::Game::Resources::RTM_GOLD; + return; + } + // the amount's buttons + if (button == 50) { + DAT_SentOrRequestedGoodsAmount::instance += 10; + return; + } + if (button == 51) { + DAT_SentOrRequestedGoodsAmount::instance += 25; + return; + } + if (button == 52) { + DAT_SentOrRequestedGoodsAmount::instance += 100; + return; + } + if (button == 53) { + DAT_SentOrRequestedGoodsAmount::instance += 5; + return; + } + if (button == 54) { + DAT_SentOrRequestedGoodsAmount::instance += 500; + return; + } + // cancel: the choice is cleared, and an ally whose request this dialog answers gets command 3 + if (button == 102) { + DAT_RequestedGoodsByWhoArray::instance[0] = -1; + DAT_SentOrRequestedGoodsAmount::instance = 0; + if (DAT_MenuModalComposition1::instance.activeModalDialogID + != OpenSHC::UI::Enums::MMT_ALLIES_SEND_GOODS) { + return; + } + if (!DAT_00df4284::instance) { + return; + } + 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; + } + // confirm, once a good and an amount are chosen + if (button == 100) { + if (DAT_RequestedGoodsByWhoArray::instance[0] <= -1) { + return; + } + if (DAT_SentOrRequestedGoodsAmount::instance <= 0) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_ALLIES_REQUEST_GOODS) { + if (DAT_RequestedGoodsByWhoArray::instance[0] + 1 == OpenSHC::Game::Resources::RT_GOLD) { + if (!MACRO_CALL_MEMBER( + OpenSHC::AI::AICState_Func::isResourceLargerOrEqualThanMinimumGoodsRequiredAfterTrade, + DAT_AICState::ptr)(playerID, + (OpenSHC::Game::Resources::ResourceType)(DAT_RequestedGoodsByWhoArray::instance[0] + 1), + DAT_SentOrRequestedGoodsAmount::instance)) { + MACRO_CALL_MEMBER( + OpenSHC::AI::AICState_Func::playGoodsNotSentBikFromPlayer, DAT_AICState::ptr)(playerID); + } else { + 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); + } + } else { + int const space = 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 (space == -1) { + // no building to put it in: the fail state says which one is missing + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)( + 3, (OpenSHC::Game::Resources::ResourceType)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, 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, DAT_SFXState::ptr)( + s_space_warning1_wav_005a593c); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 7) { + // "No armory built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning3_wav_005a5928); + } + } else if (space < DAT_SentOrRequestedGoodsAmount::instance) { + // not enough room in it + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)( + 4, (OpenSHC::Game::Resources::ResourceType)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, 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, DAT_SFXState::ptr)( + s_space_warning4_wav_005a5914); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 10) { + // "No space in the armory" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning6_wav_005a5900); + } + } else if ( + !MACRO_CALL_MEMBER( + OpenSHC::AI::AICState_Func::isResourceLargerOrEqualThanMinimumGoodsRequiredAfterTrade, + DAT_AICState::ptr)(playerID, + (OpenSHC::Game::Resources::ResourceType)(DAT_RequestedGoodsByWhoArray::instance[0] + 1), + DAT_SentOrRequestedGoodsAmount::instance)) { + MACRO_CALL_MEMBER( + OpenSHC::AI::AICState_Func::playGoodsNotSentBikFromPlayer, DAT_AICState::ptr)(playerID); + } else { + 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; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + // sending: the ally needs room for it and the player has to have it; gold needs no room + int const resource = DAT_RequestedGoodsByWhoArray::instance[0] + 1; + int storedAs = resource; + if (resource == OpenSHC::Game::Resources::RT_PARTIALPITCH) { + storedAs = resource - 1; + } + int amount = DAT_SentOrRequestedGoodsAmount::instance; + if (resource == OpenSHC::Game::Resources::RT_GOLD) { + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[OpenSHC::Game::Resources::RT_GOLD] + < amount) { + return; + } + } else { + int const space = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::getResourceSpace, + DAT_BuildingsState::ptr)(playerID, (OpenSHC::Game::Resources::ResourceType)storedAs); + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[storedAs] + < amount) { + return; + } + if (space < 0) { + return; + } + if (space < amount) { + amount = space; + } + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 2; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = resource; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = amount; + 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; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp new file mode 100644 index 0000000000..7fd366ca3b --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp @@ -0,0 +1,263 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventType.hpp" + +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B9E50 + void General::MenuItemActionHandler_General_EventSlider( + int slider, int scrollbarEvent, int* minValue, int* maxValue, int* currentValue) + { + // the highest amount: by event type for the amount sliders, whose number is the type plus one + int limit = 0; + switch (slider) { + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_AWAKES + 1: + limit = 10; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SET_PLAGUE + 1: + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_ATTACK + 1: + limit = 5; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SET_BANDITS + 1: + case OpenSHC::Game::ScenarioEvents::Enums::SET_ARCHERS + 1: + limit = 20; + break; + case -10: + limit = DAT_MapPropertiesState::instance.invasionEventContent.field_0xa4; + break; + } + // scrollbarEvent 1 sets a slider up, 2 and 3 store its value, 4 brings the stored value into range, + // 5 and 6 step it, and 7 sets the two repeat sliders to 1 + switch (slider) { + case -1: + // how often the event repeats, 0 to 60, for the events that can repeat + switch (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType) { + case OpenSHC::Game::ScenarioEvents::Enums::SET_TRAVELING_FAIR: + case OpenSHC::Game::ScenarioEvents::Enums::SET_PLAGUE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_WHEAT_DISEASE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_HOPS_WEEVIL: + case OpenSHC::Game::ScenarioEvents::Enums::SET_APPLE_BLIGHT: + case OpenSHC::Game::ScenarioEvents::Enums::SET_TREE_FUNGUS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_RABBIT_EXPLOSION: + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_ATTACK: + case OpenSHC::Game::ScenarioEvents::Enums::SET_BANDITS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_MAD_COWS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_ARCHERS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_THEFT_FROM_GRANARY: + case OpenSHC::Game::ScenarioEvents::Enums::SET_FIRE: + switch (scrollbarEvent) { + case 1: + *minValue = 0; + *maxValue = 60; + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat; + return; + case 2: + case 3: + *minValue = 0; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat = *currentValue; + return; + case 7: + *currentValue = 1; + break; + case 4: + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat; + *minValue = 0; + *maxValue = 60; + if (*currentValue > 60) { + *currentValue = 60; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat = *maxValue; + } + if (*currentValue < *minValue) { + *currentValue = *minValue; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat = *minValue; + } + break; + } + } + break; + case -2: + // the months between two repeats, 1 to 10 + switch (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType) { + case OpenSHC::Game::ScenarioEvents::Enums::SET_TRAVELING_FAIR: + case OpenSHC::Game::ScenarioEvents::Enums::SET_PLAGUE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_WHEAT_DISEASE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_HOPS_WEEVIL: + case OpenSHC::Game::ScenarioEvents::Enums::SET_APPLE_BLIGHT: + case OpenSHC::Game::ScenarioEvents::Enums::SET_TREE_FUNGUS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_RABBIT_EXPLOSION: + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_ATTACK: + case OpenSHC::Game::ScenarioEvents::Enums::SET_BANDITS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_MAD_COWS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_ARCHERS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_THEFT_FROM_GRANARY: + case OpenSHC::Game::ScenarioEvents::Enums::SET_FIRE: + switch (scrollbarEvent) { + case 1: + *minValue = 1; + *maxValue = 10; + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths; + return; + case 2: + case 3: + *minValue = 1; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths = *currentValue; + return; + case 7: + *currentValue = 1; + break; + case 4: + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths; + *minValue = 1; + *maxValue = 10; + if (*currentValue > 10) { + *currentValue = 10; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths = *maxValue; + } + if (*currentValue < *minValue) { + *currentValue = *minValue; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths = *minValue; + } + break; + } + } + break; + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_AWAKES + 1: + case OpenSHC::Game::ScenarioEvents::Enums::SET_PLAGUE + 1: + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_ATTACK + 1: + case OpenSHC::Game::ScenarioEvents::Enums::SET_BANDITS + 1: + case OpenSHC::Game::ScenarioEvents::Enums::SET_ARCHERS + 1: + // the amount of the event that this slider belongs to + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + == slider - 1) { + switch (scrollbarEvent) { + case 1: + *minValue = 1; + *maxValue = limit; + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + return; + case 2: + case 3: + *minValue = 1; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = *currentValue; + return; + case 4: + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + *minValue = 1; + *maxValue = limit; + if (*currentValue > limit) { + *currentValue = limit; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = *maxValue; + } + if (*currentValue < *minValue) { + *currentValue = *minValue; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = *minValue; + } + break; + case 5: + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData + < *maxValue) { + ++DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + } + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + return; + case 6: + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData + > 0) { + --DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + } + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + break; + } + } + break; + case -10: + // the invasion's amount + switch (scrollbarEvent) { + case 1: + *minValue = 1; + *maxValue = limit; + *currentValue = DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + return; + case 2: + case 3: + *minValue = 1; + DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 = *currentValue; + return; + case 4: + *currentValue = DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + *minValue = 1; + *maxValue = limit; + if (*currentValue > limit) { + *currentValue = limit; + DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 = *maxValue; + } + if (*currentValue < *minValue) { + *currentValue = *minValue; + DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 = *minValue; + } + break; + case 5: + if (DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 < *maxValue) { + ++DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + } + *currentValue = DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + return; + case 6: + if (DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 > 0) { + --DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + } + *currentValue = DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + } + break; + } + } + + } +} +} 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..dd8449a16f --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp @@ -0,0 +1,179 @@ +#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_GMImageHeaders.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" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004C0CF0 + void SiegeAttackingForceAndStartGoods::MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main( + int button, ...) + { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (button < 0) { + // the negative buttons are the rows of the two lists + int const index = -1 - button; + if (index < 20) { + // a starting good: its amount and icon, on any map but a siege + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { + return; + } + 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[index]], + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, 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[index]], + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + int icon = DAT_MissionAestheticsDefinedData::instance.field_0x345c[index] * 2 + 141; + if (icon == 157) { + icon = 155; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, icon, + DAT_ButtonX::instance + 10, + DAT_ButtonY::instance + - DAT_GMImageHeaders::instance + .imh[GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2] + icon + - 1] + .height + / 2 + + 15); + } else if (index < 30) { + // a unit of the attacking force, on a siege map + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + return; + } + 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_SiegeInformation[index - 20], + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, 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_SiegeInformation[index - 20], + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + int imageID = index - 19; + if (index == 29) { + imageID = index - 18; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_ARMY_UNITS, imageID, + DAT_ButtonX::instance, + DAT_ButtonY::instance + - DAT_GMImageHeaders::instance + .imh[GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_ARMY_UNITS] + imageID - 1] + .height + / 2 + + 15); + } else if (index == 30) { + // "Popularity" + 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_SCENARIO, 79, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } + } else if (index >= 40 && index < 50) { + // a siege engine of the attacking force; row 46 reads tunnelersCount, which follows the engines + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + return; + } + 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_Section1067.siegeEngineCounts[index - 40], + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, 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)( + DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[index - 40], + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 8, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + int imageID = index - 28; + if (index == 45) { + imageID = 10; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_ARMY_UNITS, imageID, + DAT_ButtonX::instance, + DAT_ButtonY::instance + - DAT_GMImageHeaders::instance + .imh[GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_ARMY_UNITS] + imageID - 1] + .height + / 2 + + 15); + } + } else if (button < 1000) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button); + } else if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonX::instance + DAT_ButtonW::instance, DAT_ButtonY::instance + DAT_ButtonH::instance, + OpenSHC::UI::Enums::RBERL_SLIGHT); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonX::instance + DAT_ButtonW::instance, DAT_ButtonY::instance + DAT_ButtonH::instance, + COL_BLUE::instance.shortValue, 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..f762db2d98 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp @@ -0,0 +1,176 @@ +#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 button, ...) + { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + switch (button) { + // the scroll arrows of the two lists + case -10: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(0, DAT_ButtonBackgroundBlendStrength::instance); + break; + case -11: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(1, DAT_ButtonBackgroundBlendStrength::instance); + break; + case -100: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(0, DAT_ButtonBackgroundBlendStrength::instance); + break; + case -101: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(1, DAT_ButtonBackgroundBlendStrength::instance); + break; + case 2: + // the blend strength goes through * 32 / 32, as the original computes it (shl 5, then a signed divide) + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + break; + case 69: + // "Difficulty" and its setting, where the mission has one + if (DAT_MapMissionType::instance != 0 && DAT_GameCore::instance.mapU4Int1_2 == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + 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, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + 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, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + 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, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } + break; + case 74: + // "Advanced", for the second player of a siege; shown as pressed while the advanced mode is on + if (DAT_MapMissionType::instance == 2 && DAT_GameSynchronyState::instance.currentPlayerSlotID == 2 + && DAT_GameCore::instance.mapU4Int1_2 == 0) { + 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); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, button, + DAT_ButtonX::instance + DAT_ButtonW::instance / 2, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } else if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, button, + DAT_ButtonX::instance + DAT_ButtonW::instance / 2, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, button, + DAT_ButtonX::instance + DAT_ButtonW::instance / 2, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } + } + break; + case 77: + // the side the player is on: text 77, or 78 for the first player + if (DAT_MapMissionType::instance == 2) { + if (DAT_GameSynchronyState::instance.currentPlayerSlotID == 1) { + button = 78; + } + if (DAT_GameCore::instance.mapU4Int1_2 == 0) { + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(DAT_ButtonBackgroundBlendStrength::instance, + OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, button, + DAT_ButtonX::instance + DAT_ButtonW::instance / 2, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(DAT_ButtonBackgroundBlendStrength::instance, + OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, button, + DAT_ButtonX::instance + DAT_ButtonW::instance / 2, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } + } + } + break; + case 65: { + // at half strength, and never as pressed, while no map is selected + DAT_ButtonUnknownZero::instance = FALSE; + int factor = 32; + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + < 0) { + factor = 16; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + 32 - (32 - DAT_ButtonBackgroundBlendStrength::instance) * factor / 32); + break; + } + case 78: + // nothing to draw; written out, since the original's switch has this case of its own + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + + } +} +} 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..459bd47ec6 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp @@ -0,0 +1,157 @@ +#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/CursorType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/ScrollSpeed.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.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 { + + // FUNCTION: STRONGHOLDCRUSADER 0x00493E20 + void VideoOptions::MenuItemActionHandler_VideoOptions_Main(int button, ...) + { + switch (button) { + case 11: { // resolution: the next one that the screen supports, in the menu's order + int resolution = DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution; + for (OpenSHC::WindowsHelper::Enums::BOOLEnum supported = FALSE; !supported; + supported = DAT_WindowAndDirectDraw::instance.resolutionSupported_0x68.array[resolution]) { + if (resolution == OpenSHC::Rendering::SRE_800x600) { + resolution = OpenSHC::Rendering::SRE_1024x600; + } else if (resolution == OpenSHC::Rendering::SRE_1024x600) { + resolution = OpenSHC::Rendering::SRE_1024x768; + } else if (resolution == OpenSHC::Rendering::SRE_1280x1024) { + resolution = OpenSHC::Rendering::SRE_1360x768; + } else if (resolution == OpenSHC::Rendering::SRE_1360x768) { + resolution = OpenSHC::Rendering::SRE_1366x768; + } else { + resolution++; + if (resolution == OpenSHC::Rendering::SRE_1360x768) { + resolution = OpenSHC::Rendering::SRE_800x600; + } + } + } + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution = resolution; + return; + } + case 12: // zoomed out, on or off + DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01 ^= 1; + return; + case 16: // scroll speed + DAT_MenuTextInputState::instance.menuScrollSpeedSetting++; + // after the third speed comes the first again + if (DAT_MenuTextInputState::instance.menuScrollSpeedSetting >= 3) { + DAT_MenuTextInputState::instance.menuScrollSpeedSetting = OpenSHC::UI::SS_NORMAL; + } + return; + case 18: // apply the settings, then close + 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, + (OpenSHC::Rendering::ScreenResolutionEnum) + 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) { + // the tactical power bar sits 55 pixels from the right edge of the new resolution + int const resolution = DAT_WindowAndDirectDraw::instance.currentGameResolution; + if (resolution == OpenSHC::Rendering::SRE_800x600) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 745, 50); + } else if (resolution == OpenSHC::Rendering::SRE_1024x768) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 969, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1024x600) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 969, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1600x1200) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1545, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1280x1024) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1225, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1280x720) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1225, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1440x900) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1385, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1920x1080) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1865, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1920x1200) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1865, 56); + } else if (resolution == OpenSHC::Rendering::SRE_2560x1440) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 2505, 56); + } else if (resolution == OpenSHC::Rendering::SRE_2560x1600) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 2505, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1366x768) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1311, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1360x768) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1305, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1680x1050) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1625, 56); + } else if (resolution == OpenSHC::Rendering::SRE_1600x900) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, 1545, 56); + } + } + } + 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; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + return; + case 17: // close without applying + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + return; + case -10: // cursor type + DAT_MenuTextInputState::instance.menuCursorType = OpenSHC::UI::Enums::CT_WINDOWS_LIKE_CURSOR; + return; + case -20: + DAT_MenuTextInputState::instance.menuCursorType = OpenSHC::UI::Enums::CT_ANI_CURSOR; + return; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp new file mode 100644 index 0000000000..b7e5164266 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/reinitWindow.cpp @@ -0,0 +1,34 @@ +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x004708F0 + void WindowAndDirectDraw::reinitWindow() + { + HWND const window = this->windowHandle; + if (GetForegroundWindow() != window) { + return; + } + this->isNotProcessingInputEvents = FALSE; + // the fullscreen flag is read through the global instance, as in the original + if (DAT_WindowAndDirectDraw::instance.runGameAsExclusiveFullscreen) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::prepareWindowAndDDrawUnk, this)(); + SetRect( + &this->clientOnScreenCoords, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); + SetFocus(this->windowHandle); + return; + } + GetClientRect(window, &this->clientOnScreenCoords); + ClientToScreen(this->windowHandle, (LPPOINT) & this->clientOnScreenCoords.left); + ClientToScreen(this->windowHandle, (LPPOINT) & this->clientOnScreenCoords.right); + UpdateWindow(this->windowHandle); + SetFocus(this->windowHandle); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..0fd6a59ec7 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -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 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042D554 | 0.0% | Pending @@ -21255,7 +21255,7 @@ SHC_3BB0A8C1_0x004706E0 | 0.0% | Pending SHC_3BB0A8C1_0x004707F0 | 0.0% | Pending -SHC_3BB0A8C1_0x004708F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004708F0 | 100.0% | Reimplemented, register allocation only (#414) SHC_3BB0A8C1_0x004709B0 | 100.0% | Reimplemented @@ -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 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0049404E | 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 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B18D0 | 100.0% | Reimplemented @@ -28653,7 +28653,7 @@ SHC_3BB0A8C1_0x004B9E4E | 0.0% | Pending SHC_3BB0A8C1_0x004B9E4F | 0.0% | Pending -SHC_3BB0A8C1_0x004B9E50 | 0.0% | Pending +SHC_3BB0A8C1_0x004B9E50 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BA2A0 | 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 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004C1070 | 100.0% | Reimplemented