diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp new file mode 100644 index 0000000000..a15c753874 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp @@ -0,0 +1,307 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/ScenarioEvents/InGameEventUnionVersion.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventConditionIndex.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CopyOfScenarioGold.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +#include + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B8220 + void EditScenario::MenuItemActionHandler_EditScenario_BaseMenuButtons(int button, ...) + { + if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { + return; + } + switch (button) { + case 3: + // back to the map's properties with the typed start year + DAT_MapPropertiesState::instance.SEC_StartingYear + = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_10)); + if (DAT_MapPropertiesState::instance.year_copy != DAT_MapPropertiesState::instance.SEC_StartingYear) { + DAT_GameState::instance.mapAndTime.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; + DAT_GameState::instance.mapAndTime.year = DAT_MapPropertiesState::instance.SEC_StartingYear; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); + return; + case 38: + // the trader settings; not on a siege map + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { + DAT_StopHandlingMenuItems::instance = 0; + return; + } + DAT_MapPropertiesState::instance.indexStored = 0; + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + OpenSHC::Text::TAIT_NINE__FILTER_B); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_TRADER_SETTINGS, FALSE); + return; + case 41: { + char text[12]; + // the attacking force on a siege map, the starting goods otherwise + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { + // The attacking force's rows start at 20 + DAT_MapPropertiesState::instance.indexStored = 20; + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12); + // "%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(text, s__d_005aa7f0, + DAT_MapPropertiesState::instance + .SEC_SiegeInformation[DAT_MapPropertiesState::instance.indexStored - 20]); + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)(text); + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_NINE__FILTER_B); + DAT_MapPropertiesState::instance.DAT_MapEditorUnitPointsSum = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_UNUSED_SIEGE_ATTACKING_FORCEUnk, FALSE); + return; + } + DAT_MapPropertiesState::instance.indexStored = 0; + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + OpenSHC::Text::TAIT_UNKNOWN_12); + // "%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(text, s__d_005aa7f0, + DAT_MapPropertiesState::instance.SEC_StartingResources[DAT_MissionAestheticsDefinedData::instance + .field_0x345c[DAT_MapPropertiesState::instance.indexStored]]); + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)(text); + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + OpenSHC::Text::TAIT_NINE__FILTER_B); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_START_GOODS, FALSE); + return; + } + case 79: + // the starting popularity slider; not on a siege map + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { + DAT_StopHandlingMenuItems::instance = 0; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setSliderParameters, + DAT_MenuModalComposition2::ptr)(0, 100, DAT_MapPropertiesState::instance.SEC_StartingPopularity, + (undefined*)&DAT_MapPropertiesState::instance.SEC_StartingPopularity, + MACRO_CALL(OpenSHC::UI::Helpers_Func::SumUnitPoints)); + DAT_MenuModalComposition2::instance.textGroup = OpenSHC::DE::SHCDE::TEXT_SCENARIO; + // "Popularity" + DAT_MenuModalComposition2::instance.textIndex = 79; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, DAT_MenuModalComposition2::ptr)( + OpenSHC::UI::Enums::MMT_OVERLAY_SLIDER, DAT_ButtonX::instance - 2, DAT_ButtonY::instance + 25); + return; + case -1: + // the start month, from December round to January + ++DAT_MapPropertiesState::instance.SEC_StartingMonth; + if (DAT_MapPropertiesState::instance.SEC_StartingMonth >= 12) { + DAT_MapPropertiesState::instance.SEC_StartingMonth = 0; + } + DAT_GameState::instance.mapAndTime.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; + DAT_GameState::instance.mapAndTime.year = DAT_MapPropertiesState::instance.SEC_StartingYear; + return; + case 42: { + char text[12]; + // a new invasion, on an invasion map + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_INVASION) { + return; + } + DAT_MapPropertiesState::instance.currentEventID = DAT_MapPropertiesState::instance.eventsCount; + ++DAT_MapPropertiesState::instance.eventsCount; + DAT_MapPropertiesState::instance.editedEventType = 1; + MACRO_CALL_MEMBER(OpenSHC::Game::ScenarioEvents::InGameEventUnionVersion_Func::resetEvent, + &DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID])(); + DAT_MapPropertiesState::instance.SEC_StartingYear + = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_10)); + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.year = DAT_MapPropertiesState::instance.SEC_StartingYear; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + OpenSHC::Text::TAIT_UNKNOWN_14); + // "" + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)(s__005a5339); + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + OpenSHC::Text::TAIT_UNKNOWN_11); + // "%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(text, s__d_005aa7f0, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.year); + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)(text); + DAT_MapPropertiesState::instance.field_0x1356c = 0; + DAT_MapPropertiesState::instance.offset = 0; + DAT_MapPropertiesState::instance.indexStored = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NEW_INVASION, FALSE); + return; + } + case 43: { + char text[12]; + // a new event; not on a just-build map + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_JUST_BUILD) { + return; + } + DAT_MapPropertiesState::instance.currentEventID = DAT_MapPropertiesState::instance.eventsCount; + ++DAT_MapPropertiesState::instance.eventsCount; + DAT_MapPropertiesState::instance.editedEventType = 3; + MACRO_CALL_MEMBER(OpenSHC::Game::ScenarioEvents::InGameEventUnionVersion_Func::initializeScenarioEvent, + &DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID])(); + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_AUTO_STOP] + .enabled = 1; + // Written out (a for loop over 5 to 7: quick_diff 0.9573 -> 0.9001) + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_FOOD_ACQUIRED] + .subType = 10; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED] + .subType = 10; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_GOODS_ACQUIRED] + .subType = 10; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED_17] + .subType = 10; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY] + .value = 5; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS] + .value = 5; + DAT_MapPropertiesState::instance.SEC_StartingYear + = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_10)); + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.year = DAT_MapPropertiesState::instance.SEC_StartingYear; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; + DAT_MapPropertiesState::instance.invasionTroopIndex = 0; + DAT_MapPropertiesState::instance.flag = TRUE; + // fixme: the formatted year is not used (the original does the same, 0x004B86E5) + // "%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(text, s__d_005aa7f0, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.year); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NEW_EVENT, FALSE); + return; + } + case 168: + // the attacking force's gold slider, on a siege map + // textGroup first (168, 169, 61): a shared tail (textIndex first: quick_diff 0.9573 -> 0.9197) + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + return; + } + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(0, + 10000, DAT_MapPropertiesState::instance.SEC_StartingResources[OpenSHC::Game::Resources::RT_GOLD], + (undefined*)&DAT_MapPropertiesState::instance + .SEC_StartingResources[OpenSHC::Game::Resources::RT_GOLD], + MACRO_CALL(OpenSHC::UI::Helpers_Func::SumUnitPoints)); + DAT_MenuModalComposition2::instance.textGroup = OpenSHC::DE::SHCDE::TEXT_SCENARIO; + // "Starting Gold" + DAT_MenuModalComposition2::instance.textIndex = 168; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, DAT_MenuModalComposition2::ptr)( + OpenSHC::UI::Enums::MMT_OVERLAY_SLIDER, DAT_ButtonX::instance - 2, DAT_ButtonY::instance + 25); + return; + case 169: + // the attacking force's partial pitch slider, on a siege map + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + return; + } + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(0, 100, + DAT_MapPropertiesState::instance.SEC_StartingResources[OpenSHC::Game::Resources::RT_PARTIALPITCH], + (undefined*)&DAT_MapPropertiesState::instance + .SEC_StartingResources[OpenSHC::Game::Resources::RT_PARTIALPITCH], + MACRO_CALL(OpenSHC::UI::Helpers_Func::SumUnitPoints)); + DAT_MenuModalComposition2::instance.textGroup = OpenSHC::DE::SHCDE::TEXT_SCENARIO; + // "Starting Pitch" + DAT_MenuModalComposition2::instance.textIndex = 169; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, DAT_MenuModalComposition2::ptr)( + OpenSHC::UI::Enums::MMT_OVERLAY_SLIDER, DAT_ButtonX::instance - 2, DAT_ButtonY::instance + 25); + return; + case 171: + // the building availability + DAT_MapPropertiesState::instance.DAT_BuildingAvailabilityScrollbarOffset = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_BUILDING_AVAILABILITY, FALSE); + return; + case 61: + // the scenario's gold slider, with the extra options on + if (!DAT_GameState::instance.mapAndTime.editScenarioExtraOptions) { + return; + } + DAT_CopyOfScenarioGold::instance = DAT_GameState::instance.mapAndTime.scenarioGold; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(0, + 10000, DAT_CopyOfScenarioGold::instance, (undefined*)DAT_CopyOfScenarioGold::ptr, + MACRO_CALL(OpenSHC::UI::Helpers_Func::RestoreScenarioGold)); + DAT_MenuModalComposition2::instance.textGroup = OpenSHC::DE::SHCDE::TEXT_SCENARIO; + // "Gold" + DAT_MenuModalComposition2::instance.textIndex = 61; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, DAT_MenuModalComposition2::ptr)( + OpenSHC::UI::Enums::MMT_OVERLAY_SLIDER, DAT_ButtonX::instance - 2, DAT_ButtonY::instance + 25); + return; + case 166: + // the rations setting, 0 to 4 and round again, with the extra options on + if (!DAT_GameState::instance.mapAndTime.editScenarioExtraOptions) { + return; + } + ++DAT_GameState::instance.mapAndTime.scenarioRationsSetting; + if (DAT_GameState::instance.mapAndTime.scenarioRationsSetting >= 5) { + DAT_GameState::instance.mapAndTime.scenarioRationsSetting = 0; + } + return; + case 167: + // the tax setting, 0 to 9 and round again, with the extra options on + if (!DAT_GameState::instance.mapAndTime.editScenarioExtraOptions) { + return; + } + ++DAT_GameState::instance.mapAndTime.scenarioTaxesSetting; + if (DAT_GameState::instance.mapAndTime.scenarioTaxesSetting >= 10) { + DAT_GameState::instance.mapAndTime.scenarioTaxesSetting = 0; + } + return; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp new file mode 100644 index 0000000000..0312429075 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp @@ -0,0 +1,222 @@ +#include "../NewEventAction.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventType.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.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_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004C0860 + void NewEventAction::MenuItemRenderFunction_NewEventAction_Main(int button, ...) + { + DAT_ButtonUnknownZero::instance = FALSE; + // The row's text, and the button for the value (selectedButton first: quick_diff 0.9184 -> 0.9143) + int textNumber = button; + int const selectedButton = button; + int iconOffset = -1; + switch (button) { + // 38 to 40 show "Select Message" (text 40), each for one message action + case 37: + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button); + return; + case 38: + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + == OpenSHC::Game::ScenarioEvents::Enums::SET_LOSE_AND_MESSAGE) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button + 2); + return; + } + DAT_ButtonUnknownZero::instance = TRUE; + return; + case 39: + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + == OpenSHC::Game::ScenarioEvents::Enums::SET_WIN_AND_MESSAGE) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button + 1); + return; + } + DAT_ButtonUnknownZero::instance = TRUE; + return; + case 40: + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + == OpenSHC::Game::ScenarioEvents::Enums::SET_MESSAGE) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button); + return; + } + DAT_ButtonUnknownZero::instance = TRUE; + return; + // the action rows: 128 to 155 are event types 0 to 27, 177 to 187 are 28 to 38 + case 177: + case 178: + case 179: + case 180: + case 181: + case 182: + case 183: + case 184: + case 185: + case 186: + case 187: + button -= 21; + case 128: + case 129: + case 130: + case 131: + case 132: + case 133: + case 134: + case 135: + case 136: + case 137: + case 138: + case 139: + case 140: + case 141: + case 142: + case 143: + case 144: + case 145: + case 146: + case 147: + case 148: + case 149: + case 150: + case 151: + case 152: + case 153: + case 154: + case 155: + // "Archers" (148) is drawn as "Bandits" (146) with the other icon + if (textNumber == 148) { + textNumber = 146; + iconOffset = 0; + } else if (textNumber == 146) { + iconOffset = 2; + } + if (button - 128 + == DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumber, DAT_ButtonX::instance + 14, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, + FALSE); + if (iconOffset > -1) { + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s___005a2304, DAT_ButtonX::instance + 20, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, + 18, TRUE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iconOffset + 128, + DAT_TextManagerObject::instance.currentXOffset_0x0 + DAT_ButtonX::instance + 23, + DAT_ButtonY::instance + 3); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + if (DAT_MapPropertiesState::instance.sliderPopupDelay != 0) { + --DAT_MapPropertiesState::instance.sliderPopupDelay; + if (DAT_MapPropertiesState::instance.sliderPopupDelay == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_OVERLAY_SLIDER, + DAT_MapPropertiesState::instance.sliderPopupX, + DAT_MapPropertiesState::instance.sliderPopupY); + } + } + switch (selectedButton) { + case 132: + case 139: + case 145: + case 146: + case 148: + case 179: + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData, + DAT_ButtonW::instance + DAT_ButtonX::instance - 14, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 178: + // "%" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_percentage_005a2770, + DAT_ButtonW::instance + DAT_ButtonX::instance - 14, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData, + DAT_ButtonW::instance + DAT_ButtonX::instance - 28, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + return; + } + // The same draw in both branches (one draw without the test: quick_diff 0.9184 -> 0.7731) + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumber, DAT_ButtonX::instance + 14, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, + FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumber, DAT_ButtonX::instance + 14, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, + FALSE); + } + if (iconOffset > -1) { + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s___005a2304, DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iconOffset + 128, + DAT_TextManagerObject::instance.currentXOffset_0x0 + DAT_ButtonX::instance + 23, + DAT_ButtonY::instance + 3); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + return; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp new file mode 100644 index 0000000000..9c1c9f0a0c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp @@ -0,0 +1,354 @@ +#include "../NewEventCondition.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/Game/ScenarioEvents/Enums/ScenarioEventConditionIndex.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/WindowsHelper/Enums/BOOLEnum.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_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004C01B0 + void NewEventCondition::MenuItemRenderFunction_NewEventCondition_Main(int button, ...) + { + // The condition's text, copied at the start (copied after the check: quick_diff 0.9440 -> 0.8940) + int textNumber = button; + DAT_ButtonUnknownZero::instance = FALSE; + if (button > 5000) { + return; + } + switch (button) { + case -1: + // The event's month: X + W / 2 here (W / 2 + X, as in 2002: reccmp 99.7% -> 99.3%) + // One call per colour (one call with a colour local: quick_diff 0.9440 -> 0.9237) + 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_MONTHS, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.month + + 12, + 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_MONTHS, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.month + + 12, + DAT_ButtonX::instance + DAT_ButtonW::instance / 2, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } + return; + case 126: + if (!DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[DAT_MapPropertiesState::instance.invasionTroopIndex] + .enabled) { + // "Inactive" + button = 127; + } + // as 19 + case 19: + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button); + return; + case 104: + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.allOrAnyCondition) { + // "All of these" + button = 105; + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button); + return; + case 209: { + // "Win Timer" (row 39) only while one of these conditions is on: else DAT_ButtonUnknownZero + BOOLEnum anyEnabled = FALSE; + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION] + .enabled) { + anyEnabled = TRUE; + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_GOLD_ACQUIRED] + .enabled) { + anyEnabled = TRUE; // Written out (a loop over 4 to 7: quick_diff 0.9440 -> 0.8543) + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_FOOD_ACQUIRED] + .enabled) { + anyEnabled = TRUE; + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED] + .enabled) { + anyEnabled = TRUE; + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_GOODS_ACQUIRED] + .enabled) { + anyEnabled = TRUE; + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED_17] + .enabled) { + anyEnabled = TRUE; + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED] + .enabled) { + anyEnabled = TRUE; // Written out (a loop over 20 to 22: quick_diff 0.9440 -> 0.8708) + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_DRINKING_ALE] + .enabled) { + anyEnabled = TRUE; + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY] + .enabled) { + anyEnabled = TRUE; + } + if (!DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS] + .enabled + && !anyEnabled) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + } + // as 190 to 208 + case 190: // conditions 20 to 39 + case 191: + case 192: + case 193: + case 194: + case 195: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 202: + case 203: + case 204: + case 205: + case 206: + case 207: + case 208: + button -= 64; + case 106: // conditions 0 to 19 + case 107: + case 108: + case 109: + case 110: + case 111: + case 112: + case 113: + case 114: + case 115: + case 116: + case 117: + case 118: + case 119: + case 120: + case 121: + case 122: + case 123: + case 124: + case 125: { + int const slot = button - 106; + DAT_ButtonCurrentlyInteracting::instance = DAT_MapPropertiesState::instance.invasionTroopIndex == slot; + uint color = OpenSHC::Rendering::Colors::COL_C2F0EB; + if (DAT_ButtonCurrentlyInteracting::instance) { + color = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // "Food Acquired" (111) and "Weapons Acquired" (112, 123) show "Goods Acquired" (113) + if (textNumber == 111 || textNumber == 112 || textNumber == 113 || textNumber == 123) { + textNumber = 113; + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[slot] + .enabled) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumber, DAT_ButtonX::instance + 5, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_LEFT, color, 18, FALSE); + if (DAT_MissionAestheticsDefinedData::instance.EventConditionMaxValue[slot] == 0) { + return; + } + // ParamKind 1: one of EventConditionOptionTextOffsets (goods); 2: one of field_0x170 (an opponent) + if (DAT_MissionAestheticsDefinedData::instance.EventConditionParamKind[slot] == 1) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, + DAT_MissionAestheticsDefinedData::instance + .EventConditionOptionTextOffsets[DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[slot] + .subType], + DAT_ButtonX::instance + 14, DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_LEFT, color, 18, + TRUE); + } + if (DAT_MissionAestheticsDefinedData::instance.EventConditionParamKind[slot] == 2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, + DAT_MissionAestheticsDefinedData::instance.field_0x170[DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[slot] + .subType], + DAT_ButtonX::instance + 14, DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_LEFT, color, 18, + TRUE); + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[slot] + .value + * DAT_MissionAestheticsDefinedData::instance.EventConditionValueScale[slot], + DAT_ButtonW::instance + DAT_ButtonX::instance - 8, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, color, 18, FALSE); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumber, DAT_ButtonX::instance + 5, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_7F7F7F, 18, FALSE); + return; + } + case 1001: + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::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_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLUE::instance.shortValue, OpenSHC::UI::Enums::RBERL_SLIGHT); + } + return; + // 2000 before 1000, !interacting first (in turn: quick_diff 0.9440 -> 0.9109; interacting first: 0.8223) + case 2000: + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::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_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLUE::instance.shortValue, OpenSHC::UI::Enums::RBERL_SLIGHT); + } + return; + case 1000: + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::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_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLUE::instance.shortValue, OpenSHC::UI::Enums::RBERL_SLIGHT); + } + return; + case 2002: + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, + DAT_MissionAestheticsDefinedData::instance + .EventConditionOptionTextOffsets[DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[DAT_MapPropertiesState::instance.invasionTroopIndex] + .subType], + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 8, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); + } + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + != 2) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, + DAT_MissionAestheticsDefinedData::instance.field_0x170[DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[DAT_MapPropertiesState::instance.invasionTroopIndex] + .subType], + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 8, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); + return; + case 2001: + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::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_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLUE::instance.shortValue, OpenSHC::UI::Enums::RBERL_SLIGHT); + } + return; + default: + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button); + return; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedWinCondition_Options.cpp b/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedWinCondition_Options.cpp index b5431f1b5c..f3bb312349 100644 --- a/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedWinCondition_Options.cpp +++ b/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedWinCondition_Options.cpp @@ -1,7 +1,7 @@ -#include "OpenSHC/UI/MenuItems/Unused.func.hpp" +#include "../Unused.func.hpp" + #include "OpenSHC/UI/MenuModalComposition.func.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" @@ -10,9 +10,6 @@ namespace UI { namespace MenuItems { namespace Unused { - using OpenSHC::UI::Enums::MenuModalType; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x004B1090 void MenuItemActionHandler_UnusedWinCondition_Options(int value, ...) { @@ -24,7 +21,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); if (DAT_MenuModalComposition1::instance.sliderCallbackFunction != NULL) { - ((void (*)())DAT_MenuModalComposition1::instance.sliderCallbackFunction)(); + DAT_MenuModalComposition1::instance.sliderCallbackFunction(); } } diff --git a/src/OpenSHC/UI/MenuModalComposition/setSliderParameters2.cpp b/src/OpenSHC/UI/MenuModalComposition/setSliderParameters2.cpp index a4cda0f72d..e8e72e32e9 100644 --- a/src/OpenSHC/UI/MenuModalComposition/setSliderParameters2.cpp +++ b/src/OpenSHC/UI/MenuModalComposition/setSliderParameters2.cpp @@ -7,7 +7,7 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x004AA540 void MenuModalComposition::setSliderParameters2( - dword minimum, dword maximum, dword value, dword destination, undefined* callbackFunction) + dword minimum, dword maximum, dword value, dword destination, NoArgCallback* callbackFunction) { int const range = maximum - minimum; this->sliderMinimum = minimum; diff --git a/src/OpenSHC/UI/MenuModals/NewEventAction/MenuModalRenderFunction_NewEventAction.cpp b/src/OpenSHC/UI/MenuModals/NewEventAction/MenuModalRenderFunction_NewEventAction.cpp new file mode 100644 index 0000000000..578a728b1d --- /dev/null +++ b/src/OpenSHC/UI/MenuModals/NewEventAction/MenuModalRenderFunction_NewEventAction.cpp @@ -0,0 +1,56 @@ +#include "../NewEventAction.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventType.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuModals { + + // FUNCTION: STRONGHOLDCRUSADER 0x004ABAB0 + void NewEventAction::MenuModalRenderFunction_NewEventAction(int x, int y, int width, int height) + { + // "Event Actions" + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, + DAT_PencilRenderCore::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 103, x, y, width, height); + // the actions that repeat label their two fields + 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: + // "Repeat (months)" + 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_SCENARIO, 175), + x + 390, y + 461, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + // "Repeat Count" + 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_SCENARIO, 176), + x + 390, y + 496, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + break; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuModals/UnusedSetName/MenuModalRenderFunction_UnusedSetName.cpp b/src/OpenSHC/UI/MenuModals/UnusedSetName/MenuModalRenderFunction_UnusedSetName.cpp new file mode 100644 index 0000000000..2604e68591 --- /dev/null +++ b/src/OpenSHC/UI/MenuModals/UnusedSetName/MenuModalRenderFunction_UnusedSetName.cpp @@ -0,0 +1,34 @@ +#include "../UnusedSetName.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/UI/Enums/RoundedBoxEdgeRoundingLevel.hpp" + +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuModals { + + // FUNCTION: STRONGHOLDCRUSADER 0x004266E0 + void UnusedSetName::MenuModalRenderFunction_UnusedSetName(int x, int y, int width, int height) + { + // a 400 pixel wide title box in the middle of the dialog + int const margin = (width - 400) / 2; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, DAT_PencilRenderCore::ptr)( + margin + x, y + 10, x - margin + width, y + 60, OpenSHC::UI::Enums::RBERL_STRONG); + // "Enter Your Title" + 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_MAINOPTIONS, 6), + width / 2 + x, y + 15, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 15, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 4a0c6c0d6a..2c346d0643 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6771,7 +6771,7 @@ SHC_3BB0A8C1_0x00426600 | 0.0% | Pending SHC_3BB0A8C1_0x004266A0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004266E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004266E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00426750 | 100.0% | Reimplemented @@ -25559,7 +25559,7 @@ SHC_3BB0A8C1_0x004AB790 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004ABA20 | 0.0% | Pending -SHC_3BB0A8C1_0x004ABAB0 | 0.0% | Pending +SHC_3BB0A8C1_0x004ABAB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004ABB70 | 0.0% | Pending @@ -27111,7 +27111,7 @@ SHC_3BB0A8C1_0x004B8200 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B8210 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B8220 | 0.0% | Pending +SHC_3BB0A8C1_0x004B8220 | 100.0% | Reimplemented, only the atol call target differs (and the slider callbacks while the SumUnitPoints and RestoreScenarioGold resolvers are off) SHC_3BB0A8C1_0x004B88A4 | 0.0% | Pending @@ -32329,7 +32329,7 @@ SHC_3BB0A8C1_0x004C01A5 | 0.0% | Pending SHC_3BB0A8C1_0x004C01A6 | 0.0% | Pending -SHC_3BB0A8C1_0x004C01B0 | 0.0% | Pending +SHC_3BB0A8C1_0x004C01B0 | 100.0% | Reimplemented, only the RenderScenarioButtonWithText tail call targets differ, while its resolver is off SHC_3BB0A8C1_0x004C0770 | 0.0% | Pending @@ -32765,7 +32765,7 @@ SHC_3BB0A8C1_0x004C085C | 0.0% | Pending SHC_3BB0A8C1_0x004C085D | 0.0% | Pending -SHC_3BB0A8C1_0x004C0860 | 0.0% | Pending +SHC_3BB0A8C1_0x004C0860 | 100.0% | Reimplemented, only the RenderScenarioButtonWithText tail call targets differ, while its resolver is off SHC_3BB0A8C1_0x004C0BF8 | 0.0% | Pending