diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp new file mode 100644 index 0000000000..0564bccab4 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp @@ -0,0 +1,194 @@ +#include "../EditScenario.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/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B8BF0 + void EditScenario::MenuItemRenderFunction_EditScenario_EventAndInvasionList(int row, ...) + { + if (DAT_MapPropertiesState::instance.eventListSelection >= DAT_MapPropertiesState::instance.eventsCount) { + DAT_MapPropertiesState::instance.eventListSelection = DAT_MapPropertiesState::instance.eventsCount - 1; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(row == DAT_MapPropertiesState::instance.eventListSelection, row, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + // the event index is re-read after every call (an eventID local: quick_diff 0.9831 -> 0.6609) + if (DAT_MapPropertiesState::instance.eventListScrollOffset + row + >= DAT_MapPropertiesState::instance.eventsCount) { + return; + } + // set in each branch (a default overridden: reccmp 100.0% -> 99.3%) + uint color; + if (row == DAT_MapPropertiesState::instance.eventListSelection + || DAT_ButtonCurrentlyInteracting::instance) { + color = OpenSHC::Rendering::Colors::COL_CCFAFF; + } else { + color = OpenSHC::Rendering::Colors::COL_C2F0EB; + } + // the month in a local first (in the call: quick_diff 0.9831 -> 0.9155) + int const month = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .header.month; + 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_MONTHS, month), + DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + 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.eventListScrollOffset + row] + .header.year, + DAT_ButtonX::instance + 40, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + // "Month(s)" in each case, merged by MSVC (a flag and one if after the switch: quick_diff 0.9831 -> 0.7973) + switch (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .header.tl_type) { + case 1: { + // an invasion: "Invasion", its unit count and, if it repeats, "(x Month(s))" + // "Invasion" + 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, 46), + DAT_ButtonX::instance + 80, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, FALSE, + 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.invasion.totalUnitCount, + DAT_ButtonX::instance + 250, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, FALSE, + 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.invasion.repeatMonths + == 0) { + return; + } + // "(x" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s__x_005aa7f4, DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + color, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.invasion.repeatMonths, + DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, TRUE, + 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.invasion.repeatMonths + == 1) { + // "Month" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 210, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, TRUE); + } else { + // "Months" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 211, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, TRUE); + } + break; + } + case 3: { + // an event: its name and, if it repeats, "(x Month(s))" + // the event names start at 128 in the scenario texts, with 21 other texts after the 28th + int textIndex = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.ScenarioEventType + + 128; + if (textIndex > 155) { + textIndex += 21; + } + // y then x for the name (in the call: quick_diff 0.9831 -> 0.9696) + int const nameY = DAT_ButtonY::instance + 4; + int const nameX = DAT_ButtonX::instance + 80; + 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, textIndex), + nameX, nameY, OpenSHC::Text::TTA_LEFT, color, 18, FALSE, 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeat + == 0) { + return; + } + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeatMonths + == 1) { + return; + } + // "(" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_close_005a2778, DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, FALSE, 0); + // 10 shows no number + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeatMonths + != 10) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeatMonths, + DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, + TRUE); + } + // "x" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_x_005aa7f8, DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + color, 18, TRUE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeat, + DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, TRUE, + 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeat + == 1) { + // "Month" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 210, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, TRUE); + } else { + // "Months" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 211, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, TRUE); + } + break; + } + default: + return; + } + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_open_005a2774, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + color, 18, TRUE, 0); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp new file mode 100644 index 0000000000..12f4282e54 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp @@ -0,0 +1,216 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.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/Text/TextArrayIndexType.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +#include + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BF1D0 + void EditScenario::MenuItemRenderFunction_EditScenario_TextBoxLike(int box, ...) + { + if (box == 7 + && DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + int const cursorOffset = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextWidthUntilCurrentCursor, DAT_UserTextHandlerState::ptr)(); + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(-1, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // each case renders its own text (one call after the switch: quick_diff 0.9606 -> 0.9356) + switch (box) { + // boxes 0 to 7 show a text slot, with the cursor while it is typed into + case 0: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_15) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 4 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 5 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + // y, x and the text first (in the call: quick_diff 0.9606 -> 0.8724; the text in it: 0.8459) + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_15); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 1: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_10) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 8 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 9 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 10; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_10); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 2: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_11) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 8 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 9 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 10; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_11); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 3: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_12) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 9 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 10 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + // the typed value goes to the starting good, unit or popularity being edited + if (DAT_MapPropertiesState::instance.indexStored < 20) { + DAT_MapPropertiesState::instance + .SEC_StartingResources[DAT_MissionAestheticsDefinedData::instance + .field_0x345c[DAT_MapPropertiesState::instance.indexStored]] + = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12)); + } else if (DAT_MapPropertiesState::instance.indexStored < 30) { + DAT_MapPropertiesState::instance + .SEC_SiegeInformation[DAT_MapPropertiesState::instance.indexStored - 20] + = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12)); + int const unitPoints = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); + // the starting units may cost 500 points at most + if (unitPoints > 500) { + DAT_MapPropertiesState::instance + .SEC_SiegeInformation[DAT_MapPropertiesState::instance.indexStored - 20] + += 500 - unitPoints; + } + } else if (DAT_MapPropertiesState::instance.indexStored == 30) { + DAT_MapPropertiesState::instance.SEC_StartingPopularity + = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12)); + } + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 11; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 6: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_14) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 4 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 5 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_14); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 7: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_12) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 9 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 10 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + // the typed value, in the condition's unit + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[DAT_MapPropertiesState::instance.invasionTroopIndex] + .value = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12)) + / DAT_MissionAestheticsDefinedData::instance + .EventConditionValueScale[DAT_MapPropertiesState::instance.invasionTroopIndex]; + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 11; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + // 100 to 102 show a total under a "Total Troops" label + case 100: { + // "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, DAT_ButtonW::instance / 2 - 20 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, + FALSE); + int const unitPoints = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + unitPoints, DAT_ButtonW::instance / 2 - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + break; + } + case 101: { + // "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); + int const unitCount = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumUnitCounts, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + unitCount, DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 102: { + // "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); + int const invasionUnitCount = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumInvasionEventUnitCount, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + invasionUnitCount, DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp b/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp new file mode 100644 index 0000000000..d11251caa4 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp @@ -0,0 +1,107 @@ +#include "../EditorMapTypeQuickChange.func.hpp" + +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Map/Navigation/PathFindingState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Map/WildlifeState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/UI/MinimapViewState.func.hpp" +#include "OpenSHC/Map/MapConstants.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WildlifeState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004ABEB0 + void EditorMapTypeQuickChange::MenuItemActionHandler_EditorMapTypeQuickChange_Main(int button, ...) + { + switch (button) { + case 0: // 0 to 2: editable, playable, mission + case 1: + case 2: + DAT_GameCore::instance.U3_mapLockedState = button; + return; + case 3: + case 4: + case 5: + case 6: + // 3 to 6: siege, invasion, economic, just build + if (!MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::mapHasCertainEvent, DAT_MapPropertiesState::ptr)()) { + DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = button - 3; + } + return; + case 10: // single or multiplayer + DAT_GameCore::instance.U2_mapType_singleOrMulti = 0; + return; + case 11: + DAT_GameCore::instance.U2_mapType_singleOrMulti = 1; + return; + case 20: + case 21: + case 22: + case 23: { + MACRO_CALL_MEMBER( + OpenSHC::Map::TileMapState_Func::resetAreaBasedOnLogicalLayer, DAT_TileMapState::ptr)(); + // No else: button is 20 to 23 here (an else keeping button: reccmp 100.0% -> 94.5%) + int mapSize; + // the sizes in turn (a switch: reccmp 100.0% -> 85.5%) + if (button == 20) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_160; + } else if (button == 21) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_200; + } else if (button == 22) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_300; + } else if (button == 23) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_400; + } + DAT_TileMapState::instance.mapSize = mapSize; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::resetHeightAndMapBorders, DAT_TileMapState::ptr)( + mapSize); + MACRO_CALL_MEMBER( + OpenSHC::Map::TileMapState_Func::resetAreaBasedOnLogicalLayer, DAT_TileMapState::ptr)(); + DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; + MACRO_CALL_MEMBER( + OpenSHC::Map::Navigation::PathFindingState_Func::updatePathLinkageLayerForEachBuildingAtEachTile, + DAT_PathFindingState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::Navigation::PathFindingState_Func::updateSeparateAreaTileMap, + DAT_PathFindingState::ptr)(1); + MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::updatePathLinkageLayerForAllBuildings, + DAT_BuildingsState::ptr)(); + DAT_TileMapState::instance.forceUpdateMacroLayerFlag = 1; + DAT_TileMapState::instance.field_0x55487c = 200; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::forceFullTileMapRedraw, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::processGameTick, DAT_GameState::ptr)(); + for (int row = 0; row < 40; ++row) { + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateWildlifeGrid, DAT_WildlifeState::ptr)( + row); + } + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateWildlife, DAT_WildlifeState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateSection1034Info, DAT_WildlifeState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateNofFpoints, DAT_WildlifeState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::setTileColorsDependingOnMapSize, + DAT_MinimapViewState::ptr)(0, 100); + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::setMapPropertyDependingOnMapSize, + DAT_MinimapViewState::ptr)(0, 100); + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::setViewportBasedOnMapSize, + DAT_ViewportRenderState::ptr)(); + return; + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp new file mode 100644 index 0000000000..7261d4146d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp @@ -0,0 +1,210 @@ +#include "../ScenarioDescription.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00ed2794.hpp" +#include "OpenSHC/Globals/DAT_00ed2798.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" +#include "OpenSHC/Globals/INT_00eb0b24.hpp" +#include "OpenSHC/Globals/INT_00ed27bc.hpp" +#include "OpenSHC/Globals/INT_00ed27c4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8570 + void ScenarioDescription::MenuItemActionHandler_ScenarioDescription_Main(int button, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + return; + } + switch (button) { + case 10: + // start the mission + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, DAT_TextEditorState::ptr)(); + if (DAT_GameCore::instance.gameSuspended == 1) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + return; + } + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + if (DAT_GameCore::instance.missionNumber1to20 <= 0) { + DAT_GameCore::instance.missionNumber1to20 = 1; + } + DAT_GameCore::instance.section1066 = 1; + DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.buildMenuTab = 231; + MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::loadMissionMapAndSetLord, + DAT_MapPropertiesState::ptr)(DAT_GameCore::instance.missionNumber1to20); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); + MACRO_CALL(OpenSHC::Synchrony_Func::SetAIPlayerNickNames)(); + if (DAT_GameCore::instance.missionNumber1to20 >= 16) { + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::initializeFinalResultsForActivePlayers, + DAT_GameSynchronyState::ptr)(); + } + } + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = OpenSHC::UI::Enums::BMTT_CASTLE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::clearModalDialog2to6, DAT_MenuTextInputState::ptr)(); + DAT_00ed2794::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, + DAT_SoundSystemState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case 12: + case 13: + // in the builder: back to the map choice, or ask first while a game is suspended + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + // the map choice's mission type: 0 just build, 1 economic, 2 siege, 3 invasion + switch (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1) { + case OpenSHC::Map::MT_SIEGE: + DAT_MapMissionType::instance = 2; + break; + case OpenSHC::Map::MT_INVASION: + DAT_MapMissionType::instance = 3; + break; + case OpenSHC::Map::MT_ECONOMIC: + DAT_MapMissionType::instance = 1; + break; + case OpenSHC::Map::MT_JUST_BUILD: + DAT_MapMissionType::instance = 0; + break; + } + if (!DAT_GameCore::instance.gameSuspended) { + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SINGLEPLAYER_MAP_CHOICE, 0); + return; + } + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = -7; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + return; + } + // otherwise as 11 + case 11: + if (INT_00ed27bc::instance == 1) { + INT_00ed27bc::instance = 0; + return; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, DAT_TextEditorState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, + DAT_SoundSystemState::ptr)(); + if (!DAT_GameCore::instance.gameSuspended) { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_HISTORIC_MISSION_SELECT, 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_UNUSED_ECONOMIC_MISSION_SELECTUnk, 0); + return; + } + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 1000; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + return; + case 6: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) { + DAT_00ed2798::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, + DAT_TextEditorState::ptr)(); + } + return; + case 8: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) { + DAT_00ed2798::instance = 2; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, + DAT_TextEditorState::ptr)(); + } + return; + case 9: + // the mission's help page + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) { + DAT_00ed2798::instance = 3; + char helpSectionName[100]; + // "mission%d.hlp" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)( + helpSectionName, s_mission_d_hlp_005aaf7c, DAT_GameCore::instance.missionNumber1to20); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::openScenarioHelpDialog, DAT_TextEditorState::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, + DAT_TextEditorState::ptr)(helpSectionName)); + } + return; + case -1: + // "Difficulty": from 0 to 3 and round again + if (DAT_00ed2798::instance == 0 + && (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) + && !DAT_GameCore::instance.gameSuspended) { + ++DAT_GameState::instance.mapAndTime.difficulty; + if (DAT_GameState::instance.mapAndTime.difficulty > 3) { + DAT_GameState::instance.mapAndTime.difficulty = 0; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + DAT_GameCore::instance.missionDifficulty = DAT_GameState::instance.mapAndTime.difficulty; + MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetEventStatusUnk)(); + return; + } + DAT_GameCore::instance.missionDifficulty2 = DAT_GameState::instance.mapAndTime.difficulty; + MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetEventStatusUnk)(); + } + return; + case -2: // "View Briefing" + INT_00ed27bc::instance = 1; + return; + case -3: // "Restart Mission", asked first + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 44; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + return; + case -4: // "Next": the next description page + ++INT_00eb0b24::instance; + if (INT_00eb0b24::instance >= INT_00ed27c4::instance) { + INT_00eb0b24::instance = 0; + } + return; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp b/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp new file mode 100644 index 0000000000..d86dd5ed42 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp @@ -0,0 +1,121 @@ +#include "../TraderSettings.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/IO/Graphics/GmID.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 0x004C1070 + void TraderSettings::MenuItemRenderFunction_TraderSettings(int button, ...) + { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // below 0 the goods rows, below 1000 the dialog's buttons, 1100 the trader's name, else the goods list + if (button < 0) { + int const row = -1 - button; + DAT_ButtonCurrentlyInteracting::instance + = DAT_MapPropertiesState::instance.SEC_Section1065 + .tradeabilityArray[DAT_MissionAestheticsDefinedData::instance.field_0x345c[row]] + != FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const resource = DAT_MissionAestheticsDefinedData::instance.field_0x345c[row]; + // Two pictures per good from 141; partial pitch (157) shows the pitch picture (155) + int icon = resource * 2 + 141; + if (icon == 157) { + icon = 155; + } + int const imhIndex = icon + GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2] - 1; + // y then x for the On/Off text (in the call: quick_diff 0.9570 -> 0.8865; x first: 0.9140) + if (DAT_MapPropertiesState::instance.SEC_Section1065.tradeabilityArray[resource]) { + 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[imhIndex].height / 2 + 15); + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; + // "On" + 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, 172), + textX, textY, OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, icon, + DAT_ButtonX::instance + 10, + DAT_ButtonY::instance - DAT_GMImageHeaders::instance.imh[imhIndex].height / 2 + 15, 16); + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; + // "Off" + 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, 173), + textX, textY, OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_7CAAAF, 18, FALSE, 0); + } + } else if (button < 1000) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button); + } else if (button == 1100) { + 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); + // "Trader 1" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_TRADER_NAMES, 1, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_00A2FF, + OpenSHC::Rendering::Colors::COL_003E66, 18, FALSE); + } 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); + // "Trader 1" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_TRADER_NAMES, 1, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_FFFFFF, + OpenSHC::Rendering::Colors::COL_000000, 18, FALSE); + } + } else 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); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6e036f9340..cbe4ebdefe 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25631,7 +25631,7 @@ SHC_3BB0A8C1_0x004ABE50 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004ABE80 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004ABEB0 | 0.0% | Pending +SHC_3BB0A8C1_0x004ABEB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AC008 | 0.0% | Pending @@ -27521,7 +27521,7 @@ SHC_3BB0A8C1_0x004B8B0C | 0.0% | Pending SHC_3BB0A8C1_0x004B8B10 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B8BF0 | 0.0% | Pending +SHC_3BB0A8C1_0x004B8BF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B9020 | 100.0% | Reimplemented @@ -30495,7 +30495,7 @@ SHC_3BB0A8C1_0x004BEC10 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BEC40 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BF1D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BF1D0 | 100.0% | Reimplemented, only the atol call target differs SHC_3BB0A8C1_0x004BF684 | 0.0% | Pending @@ -33187,7 +33187,7 @@ SHC_3BB0A8C1_0x004C0CE7 | 0.0% | Pending SHC_3BB0A8C1_0x004C0CF0 | 0.0% | Pending -SHC_3BB0A8C1_0x004C1070 | 0.0% | Pending +SHC_3BB0A8C1_0x004C1070 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004C1320 | 0.0% | Pending @@ -35929,7 +35929,7 @@ SHC_3BB0A8C1_0x004D8250 | 0.0% | Pending SHC_3BB0A8C1_0x004D839E | 0.0% | Pending -SHC_3BB0A8C1_0x004D8570 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8570 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D89CC | 0.0% | Pending