diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp new file mode 100644 index 0000000000..6befcb639d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp @@ -0,0 +1,138 @@ +#include "../General.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/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.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/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BBA60 + void General::MenuItemRenderFunction_General_CreateEventCallbackFunction(int textNumInGroup, ...) + { + int option = -1; + int iconOffset = 2; + switch (textNumInGroup) { + case 91: + case 221: + option = 0; + break; + case 92: + case 222: + option = 1; + break; + case 93: + option = 2; + break; + case 94: + option = 3; + break; + case 95: + option = 4; + break; + case 96: + option = 5; + break; + case 97: + option = 6; + break; + case 98: + option = 7; + break; + case 99: + option = 8; + break; + case 157: + option = 9; + break; + case 158: + option = 10; + break; + case 159: + option = 11; + break; + case 160: + option = 12; + break; + case 161: + option = 13; + break; + case 162: + option = 14; + break; + } + switch (textNumInGroup) { + case 221: + case 222: + if (DAT_MapPropertiesState::instance.invasionEventContent.crusaderArabian == option) { + 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, textNumInGroup, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + return; + } + break; + case 148: + // drawn as the bandits button with the other icon + textNumInGroup = 146; + iconOffset = 0; + // fall through + case 146: { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // "Bandits"; each path reads its own text position, y first, for the original's merged call + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 - 15 + DAT_ButtonX::instance; + 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, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonW::instance / 2 - 15 + DAT_ButtonX::instance; + 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, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + int const nameWidth = DAT_TextManagerObject::instance.currentXOffset_0x0; + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s___005a2304, nameWidth / 2 - 15 + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, + FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iconOffset + 128, + DAT_ButtonW::instance / 2 - 9 + (DAT_TextManagerObject::instance.currentXOffset_0x0 + nameWidth) / 2 + + DAT_ButtonX::instance, + DAT_ButtonY::instance + 3); + return; + } + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(textNumInGroup); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox.cpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox.cpp new file mode 100644 index 0000000000..323559ae82 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox.cpp @@ -0,0 +1,94 @@ +#include "../MapEditorProperties.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_00b960f4.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_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.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 0x0042EBC0 + void MapEditorProperties::MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox(int unused, ...) + { + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0 + || DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU + || DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { + return; + } + int const x = DAT_ButtonX::instance; + // top before right, as the original computes them + int const top = DAT_ButtonY::instance + 4; + int const right = DAT_ButtonW::instance + 24 + x; + int const bottom = DAT_ButtonH::instance - 6 + DAT_ButtonY::instance; + int const divider = right - 20; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + x, top, divider, bottom); + int const sideTop = bottom - 35; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + right - 19, sideTop, right, bottom); + // the lines work from top, as the original does, not from the button's y + int const lineTop = top - 1; + // x - 1 at each use, as the original computes it each time + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x - 1, lineTop, right + 1, lineTop, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x - 1, bottom + 1, right + 1, bottom + 1, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x - 1, top, x - 1, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + right + 1, top, right + 1, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + divider, top, divider, sideTop, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + divider, top + 20, right, top + 20, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + divider, bottom - 55, right, bottom - 55, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + divider, sideTop, right, sideTop, COL_VERY_SOFT_YELLOW::instance.shortValue); + if (!DAT_GameCore::instance.mapLoadedForEditor) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRange, + DAT_TextureRenderCoreObject::ptr)( + DAT_ButtonY::instance + 7, DAT_ButtonH::instance - 42 + DAT_ButtonY::instance); + if (!DAT_GameCore::instance.descriptionUseStringTable) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + DAT_GameCore::instance.temporaryTextBufferOfSize1000, DAT_ButtonX::instance + 5, + DAT_ButtonY::instance - DAT_00b960f4::instance + 11, 360, OpenSHC::Rendering::Colors::COL_C2F0EB, + 19, 0); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRangeToResolution, + DAT_TextureRenderCoreObject::ptr)(); + return; + } + if (DAT_GameCore::instance.descriptionStringTableIndex != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText2Unk, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, DAT_GameCore::instance.descriptionStringTableIndex, + DAT_ButtonX::instance + 5, DAT_ButtonY::instance - DAT_00b960f4::instance + 11, 360, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19); + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRangeToResolution, + DAT_TextureRenderCoreObject::ptr)(); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp new file mode 100644 index 0000000000..ab469c4a9d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp @@ -0,0 +1,235 @@ +#include "../VideoOptions.func.hpp" + +#include "OpenSHC/Text/TextManager.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/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/CursorType.hpp" +#include "OpenSHC/UI/ScrollSpeed.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00492170 + void VideoOptions::MenuItemRenderFunction_VideoOptions_Main(int button, ...) + { + if (button <= -10) { + // 0 or 2 first, then the base added, as the original computes the icon + int icon = 0; + if (button == -10) { + if (DAT_MenuTextInputState::instance.menuCursorType == OpenSHC::UI::Enums::CT_WINDOWS_LIKE_CURSOR) { + icon = 2; + } + icon += 182; + } else { + if (button != -20) { + return; + } + if (DAT_MenuTextInputState::instance.menuCursorType == OpenSHC::UI::Enums::CT_ANI_CURSOR) { + icon = 2; + } + icon += 183; + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, icon, DAT_ButtonX::instance, DAT_ButtonY::instance); + return; + } + if (button >= 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // each path reads its own text position, y first, for the original's merged call + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + return; + } + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + int textID; + // the negated tests keep the -3 and -2 bodies last, as the original lays them out + if (button != -3) { + if (button != -2) { + if (button != -1) { + return; + } + // the cases in the original's block order + switch (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution) { + case OpenSHC::Rendering::SRE_800x600: + // "800x600" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_800x600_005a7598, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1024x600: + // "1024x600" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1024x600_005a758c, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1024x768: + // "1024x768" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1024x768_005a7580, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1280x1024: + // "1280x1024" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1280x1024_005a7574, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1600x1200: + // "1600x1200" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1600x1200_005a7568, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1280x720: + // "1280x720" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1280x720_005a755c, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1440x900: + // "1440x900" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1440x900_005a7550, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1920x1080: + // "1920x1080" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1920x1080_005a7544, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1920x1200: + // "1920x1200" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1920x1200_005a7538, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_2560x1440: + // "2560x1440" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_2560x1440_005a752c, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_2560x1600: + // "2560x1600" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_2560x1600_005a7520, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1366x768: + // "1366x768" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1366x768_005a7514, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1360x768: + // "1360x768" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1360x768_005a7508, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1680x1050: + // "1680x1050" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1680x1050_005a74fc, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case OpenSHC::Rendering::SRE_1600x900: + // "1600x900" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s_1600x900_005a74f0, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + default: + return; + } + } + // the zoom flag's cases, 1 first, as the original tests them + switch (DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01) { + case 1: + // "On" + textID = 13; + break; + case 0: + // "Off" + textID = 14; + break; + default: + return; + } + } else { + // the scroll speed's cases in the reverse of the original's test order + switch (DAT_MenuTextInputState::instance.menuScrollSpeedSetting) { + case OpenSHC::UI::SS_SLOW: + // "Slow" + textID = 19; + break; + case OpenSHC::UI::SS_FAST: + // "Fast" + textID = 21; + break; + case OpenSHC::UI::SS_NORMAL: + // "Normal" + textID = 20; + break; + default: + return; + } + } + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, textID), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_DoEveryFrame.cpp new file mode 100644 index 0000000000..5b95ed19c1 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/MapEditorProperties/MenuView_MapEditorProperties_DoEveryFrame.cpp @@ -0,0 +1,317 @@ +#include "../MapEditorProperties.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/MinimapViewState.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/MapConstants.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MapEditorProperties_ClickedButton.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00b95f68.hpp" +#include "OpenSHC/Globals/INT_00b960e4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042E0D0 + void MapEditorProperties::MenuView_MapEditorProperties_DoEveryFrame() + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawGfxOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)(0, + (DAT_WindowAndDirectDraw::instance.resolutionX + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].width) + / 2, + (DAT_WindowAndDirectDraw::instance.resolutionY + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].height) + / 2); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderBanner, DAT_PencilRenderCore::ptr)( + DAT_MenuHandlerState::instance.x + 48, DAT_MenuHandlerState::instance.y + 6, 704, 50); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameCore::instance.mapLoadedForEditor) { + // the position in locals, y first, as the original reads it + int const textY = DAT_MenuHandlerState::instance.y + 35; + int const textX = DAT_MenuHandlerState::instance.x + 140; + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0) { + // "Single-Player" + 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_MAPEDIT, 12), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, FALSE, 0); + // the separators and map types read the position again, as the original does + switch (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1) { + case OpenSHC::Map::MT_SIEGE: + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s___005a2304, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + // "Siege" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 28, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + break; + case OpenSHC::Map::MT_INVASION: + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s___005a2304, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + if (DAT_GameCore::instance.mapU3EndInt == 0) { + // "Invasion" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 29, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + } else { + // "Economic" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 30, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + } + break; + case OpenSHC::Map::MT_ECONOMIC: + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s___005a2304, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + // "Economic" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 30, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + break; + case OpenSHC::Map::MT_JUST_BUILD: + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + DAT_TextManagerObject::ptr)(s___005a2304, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + // "Landscape" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 33, DAT_MenuHandlerState::instance.x + 140, + DAT_MenuHandlerState::instance.y + 35, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE); + break; + } + } else { + // "Multi-Player" + 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_MAPEDIT, 13), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, FALSE, 0); + } + // " - " + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s___005a2304, DAT_MenuHandlerState::instance.x + 140, DAT_MenuHandlerState::instance.y + 35, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + if (INT_00b960e4::instance == 0) { + // y and x into locals before the call, as the original reads them + int const nameY = DAT_MenuHandlerState::instance.y + 35; + int const nameX = DAT_MenuHandlerState::instance.x + 140; + // "Untitled" + 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_MAPEDIT, 24), + nameX, nameY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, 0); + } else { + // the position before the name lookup, as the original reads it + int const nameY = DAT_MenuHandlerState::instance.y + 35; + int const nameX = DAT_MenuHandlerState::instance.x + 140; + char* const name = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(2); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + name, nameX, nameY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, TRUE, + 0); + } + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE) { + int left = DAT_MenuHandlerState::instance.x; + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0) { + left += 400; + } else { + left += 600; + } + int top = DAT_MenuHandlerState::instance.y + 240; + int mapSize = DAT_TileMapState::instance.mapSize; + if (mapSize == 0) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_400; + } + // the centre is copied once the size is settled, as the original does + int const centerX = left; + int const centerY = top; + DAT_MinimapViewState::instance.needsRedraw = TRUE; + char sizeText[20]; + // "%dx%d" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(sizeText, s__dx_d_005a22fc, mapSize, mapSize); + int width; + switch (mapSize) { + case OpenSHC::Map::MC_MAP_SIZE_100: + left -= 50; + top -= 50; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, mapSize, mapSize); + width = 100; + break; + case OpenSHC::Map::MC_MAP_SIZE_160: + left -= 80; + top -= 80; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, mapSize, mapSize); + width = 160; + break; + case OpenSHC::Map::MC_MAP_SIZE_200: + left -= 100; + top -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, mapSize, mapSize); + width = 200; + break; + case OpenSHC::Map::MC_MAP_SIZE_300: + left -= 75; + top -= 75; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, 150, 150); + width = 150; + break; + default: // 400 (no map size yet) and any other size + left -= 100; + top -= 100; + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapEditor, + DAT_MinimapViewState::ptr)(left, top, 200, 200); + width = 200; + break; + } + switch (mapSize) { + case OpenSHC::Map::MC_MAP_SIZE_300: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 75, centerY - 75, centerX + 73, centerY + 74, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 76, centerY - 76, centerX + 74, centerY + 75, COL_BLACK::instance.shortValue); + break; + case OpenSHC::Map::MC_MAP_SIZE_200: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 98, centerY - 99, centerX + 99, centerY + 99, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 99, centerY - 100, centerX + 100, centerY + 100, COL_BLACK::instance.shortValue); + break; + case OpenSHC::Map::MC_MAP_SIZE_160: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 78, centerY - 79, centerX + 78, centerY + 77, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 79, centerY - 80, centerX + 79, centerY + 78, COL_BLACK::instance.shortValue); + break; + default: + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 100, centerY - 100, centerX + 99, centerY + 100, COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + centerX - 101, centerY - 101, centerX + 100, centerY + 101, COL_BLACK::instance.shortValue); + break; + } + int const right = width + left; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::dimBox, DAT_PencilRenderCore::ptr)( + right + - MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)(sizeText, 19) + - 15, + top - 15, right, top); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + DAT_TextManagerObject::ptr)(sizeText, right - 5, top - 11, OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 19, FALSE, 0); + // each text's position in locals, y first, as the original reads it + if (DAT_MapEditorProperties_ClickedButton::instance == -3) { + int const textY = DAT_MenuHandlerState::instance.y + 560; + int const textX = DAT_MenuHandlerState::instance.x + 300; + // "Flag this map as Balanced" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 45), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 17, FALSE, + 0); + } + if (DAT_MapEditorProperties_ClickedButton::instance == -4) { + int const textY = DAT_MenuHandlerState::instance.y + 560; + int const textX = DAT_MenuHandlerState::instance.x + 300; + // "Flag this map as Un-Balanced" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 46), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 17, FALSE, + 0); + } + if (DAT_MapEditorProperties_ClickedButton::instance == -5) { + int const textY = DAT_MenuHandlerState::instance.y + 560; + int const textX = DAT_MenuHandlerState::instance.x + 300; + // "Invasion" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 29), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 17, FALSE, + 0); + } + if (DAT_MapEditorProperties_ClickedButton::instance == -6) { + int const textY = DAT_MenuHandlerState::instance.y + 560; + int const textX = DAT_MenuHandlerState::instance.x + 300; + // "Economic" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 30), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 17, FALSE, + 0); + } + } + if (DAT_GameCore::instance.isTimeHalted2 != 0) { + // "Game Paused" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + DAT_TextManagerObject::ptr)(s_Game_Paused_005a22f0, 798, 576, OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_00A2FF, OpenSHC::Rendering::Colors::COL_003E66, 17, FALSE, 0); + } + DAT_MapEditorProperties_ClickedButton::instance = 0; + if (DAT_MenuTextInputState::instance.field_0xa4 != 0) { + INT_00b95f68::instance = 0; + DAT_MenuTextInputState::instance.field_0xa4 = 0; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuViews/MissionFinishedTransition/MenuView_MissionFinishedTransition_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/MissionFinishedTransition/MenuView_MissionFinishedTransition_DoEveryFrame.cpp new file mode 100644 index 0000000000..23cf78f4e4 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/MissionFinishedTransition/MenuView_MissionFinishedTransition_DoEveryFrame.cpp @@ -0,0 +1,314 @@ +#include "../MissionFinishedTransition.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/Skirmish.func.hpp" +#include "OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/MenuItems/CustomScenarios.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/MenuItems/MainMenu.func.hpp" +#include "OpenSHC/UI/MenuItems/SelectCrusade.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/BOOLEnum_00ed279c.hpp" +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/DWORD_00ed27b4.hpp" +#include "OpenSHC/Globals/SEC_SkirmishLobbySetupStructure.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004DC500 + void MissionFinishedTransition::MenuView_MissionFinishedTransition_DoEveryFrame() + { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) { + if (DAT_BinkControlState::instance.binkObjPtrArray[0] == NULL) { + DAT_MouseState::instance.draggingStopped = TRUE; + } + } else { + if (DAT_GameSynchronyState::instance.currentGameMode + == OpenSHC::Game::GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawGfxOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)(0, + (DAT_WindowAndDirectDraw::instance.resolutionX + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].width) + / 2, + (DAT_WindowAndDirectDraw::instance.resolutionY + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].height) + / 2); + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderGreatestLordScreen)(); + } + // a flag, not a goto: the timed-out path skips the return below + BOOLEnum waitedLongEnough = FALSE; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + && DAT_GameSynchronyState::instance.currentGameMode + != OpenSHC::Game::GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER + && DAT_BinkControlState::instance.unknown02_zero[0] != 0) { + if (DWORD_00ed27b4::instance == 0) { + DWORD_00ed27b4::instance = timeGetTime(); + } else if (timeGetTime() - DWORD_00ed27b4::instance > 5000) { + waitedLongEnough = TRUE; + } + } + if (!waitedLongEnough + && (!DAT_MouseState::instance.draggingStopped + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) + && !BOOLEnum_00ed279c::instance) { + return; + } + // endSpeechStreamsAndResetLoopFlags, written out inline + DAT_SoundSystemState::instance.streamFlagsUnkAndLoopCount_0x34[OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_2] + = 0; + DAT_SoundSystemState::instance.streamFlagsUnkAndLoopCount_0x34[OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1] + = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( + OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( + OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_2); + MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::BinkControlClass_Func::stopAllBinkPlayback, DAT_BinkControlState::ptr)(); + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + if (!DAT_GameCore::instance.isSkirmishTrail) { + if (!DAT_GameCore::instance.skipStoreSKMasters) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)(0); + } + MACRO_CALL( + OpenSHC::UI::MenuItems::SelectCrusade_Func::MenuItemActionHandler_SelectCrusade_Main)(2); + MACRO_CALL_MEMBER( + OpenSHC::Game::Skirmish::SkirmishLobbySetupStructure_Func::restoreSkirmishLobbySetup, + SEC_SkirmishLobbySetupStructure::ptr)(); + } + // compared with TRUE, as the original does + if (DAT_GameCore::instance.isSkirmishTrail == TRUE) { + if (!DAT_GameCore::instance.skipStoreSKMasters) { + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)( + DAT_GameCore::instance.extremeTrailProgress + 81); + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)( + DAT_GameCore::instance.warchestTrailProgress + 51); + } else { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::StoreGameIntoSKMasters)( + DAT_GameCore::instance.skirmishTrailProgress + 1); + } + } + int progressBefore = DAT_GameCore::instance.skirmishTrailProgress; + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + progressBefore = DAT_GameCore::instance.extremeTrailProgress; + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + progressBefore = DAT_GameCore::instance.warchestTrailProgress; + } + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0) { + int const months = DAT_GameState::instance.mapAndTime.month + + DAT_GameState::instance.mapAndTime.year * 12; + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + if (months - DAT_GameCore::instance.extremeTrailStartDateMonths + < DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[DAT_GameCore::instance + .extremeTrailProgress] + || DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[DAT_GameCore::instance + .extremeTrailProgress] + < 0) { + DAT_GameCore::instance + .extremeTrailMonthsTakenOrChicken[DAT_GameCore::instance.extremeTrailProgress] + = months - DAT_GameCore::instance.extremeTrailStartDateMonths; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)( + 3); + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + if (months - DAT_GameCore::instance.warchestTrailStartDateMonths + < DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken + [DAT_GameCore::instance.warchestTrailProgress] + || DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken[DAT_GameCore::instance + .warchestTrailProgress] + < 0) { + DAT_GameCore::instance + .warchestTrailMonthsTakenOrChicken[DAT_GameCore::instance.warchestTrailProgress] + = months - DAT_GameCore::instance.warchestTrailStartDateMonths; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)( + 2); + } + } else { + if (months - DAT_GameCore::instance.skirmishTrailStartDateMonths + < DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken + [DAT_GameCore::instance.skirmishTrailProgress] + || DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken[DAT_GameCore::instance + .skirmishTrailProgress] + < 0) { + DAT_GameCore::instance + .skirmishTrailMonthsTakenOrChicken[DAT_GameCore::instance.skirmishTrailProgress] + = months - DAT_GameCore::instance.skirmishTrailStartDateMonths; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)( + 1); + } + } + } + // each trail's step nested like this, as the original lays out the three trails + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.extremeTrailProgress + >= DAT_GameCore::instance.furthestExtremeTrailMission) { + DAT_GameCore::instance.furthestExtremeTrailMission + = DAT_GameCore::instance.extremeTrailProgress + 1; + if (DAT_GameCore::instance.extremeTrailProgress < 19) { + ++DAT_GameCore::instance.extremeTrailProgress; + } + } else if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.extremeTrailProgress < 19) { + ++DAT_GameCore::instance.extremeTrailProgress; + } + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.extremeTrailProgress == 19 + && progressBefore == DAT_GameCore::instance.extremeTrailProgress) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_ENDSCREEN, 0); + } else { + MACRO_CALL(OpenSHC::UI::MenuItems::SelectCrusade_Func:: + MenuItemActionHandler_SelectCrusade_Main)(4); + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.warchestTrailProgress + >= DAT_GameCore::instance.furthestWarchestTrailMission) { + DAT_GameCore::instance.furthestWarchestTrailMission + = DAT_GameCore::instance.warchestTrailProgress + 1; + if (DAT_GameCore::instance.warchestTrailProgress < 29) { + ++DAT_GameCore::instance.warchestTrailProgress; + } + } else if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.warchestTrailProgress < 29) { + ++DAT_GameCore::instance.warchestTrailProgress; + } + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.warchestTrailProgress == 29 + && progressBefore == DAT_GameCore::instance.warchestTrailProgress) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_ENDSCREEN, 0); + } else { + MACRO_CALL(OpenSHC::UI::MenuItems::SelectCrusade_Func:: + MenuItemActionHandler_SelectCrusade_Main)(3); + } + } else { + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.skirmishTrailProgress + >= DAT_GameCore::instance.furthestSkirmishTrailMission) { + DAT_GameCore::instance.furthestSkirmishTrailMission + = DAT_GameCore::instance.skirmishTrailProgress + 1; + if (DAT_GameCore::instance.skirmishTrailProgress < 49) { + ++DAT_GameCore::instance.skirmishTrailProgress; + } + } else if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.skirmishTrailProgress < 49) { + ++DAT_GameCore::instance.skirmishTrailProgress; + } + if (DAT_GameState::instance.mapAndTime + .playerIsAlive[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0 + && DAT_GameCore::instance.skirmishTrailProgress == 49 + && progressBefore == DAT_GameCore::instance.skirmishTrailProgress) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_ENDSCREEN, 0); + } else { + MACRO_CALL(OpenSHC::UI::MenuItems::SelectCrusade_Func:: + MenuItemActionHandler_SelectCrusade_Main)(1); + } + } + } + } else if (DAT_GameSynchronyState::instance.currentGameMode + == OpenSHC::Game::GM_SKIRMISH_END_OF_GAME_SINGLE_PLAYER) { + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_RANKING_GAMES, 0); + } else { + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 7; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk)(22); + if (DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL_MEMBER( + OpenSHC::Game::Skirmish::SkirmishLobbySetupStructure_Func::restoreSkirmishLobbySetup, + SEC_SkirmishLobbySetupStructure::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_HOST_SHARE_LOBBY_STATE); + } + } + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + DAT_GameCore::instance.gameSuspended = 0; + if (DAT_GameCore::instance.missionNumber1to20 > DAT_GameCore::instance.historicCampaignNumber * 5) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_HISTORIC_CAMPAIGN_OUTRO, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_HISTORIC_MISSION_PICTURE, 0); + } + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) { + DAT_GameCore::instance.gameSuspended = 0; + if (DAT_GameCore::instance.missionNumber1to20 > 37) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); + } + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + // a switch on the map type, as the original dispatches it + switch (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1) { + case OpenSHC::Map::MT_ECONOMIC: + MACRO_CALL(OpenSHC::UI::MenuItems::MainMenu_Func::MenuItemActionHandler_MainMenu_Main)(3); + break; + default: + MACRO_CALL( + OpenSHC::UI::MenuItems::CustomScenarios_Func::MenuItemActionHandler_CustomScenarios_Main)(4); + break; + } + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + } + DAT_GameCore::instance.skipStoreSKMasters = 0; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 507eed8917..38b5e2f5f4 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -8267,7 +8267,7 @@ SHC_3BB0A8C1_0x0042DF40 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042DFD0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0042E0D0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042E0D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042E808 | 0.0% | Pending @@ -8697,7 +8697,7 @@ SHC_3BB0A8C1_0x0042E96A | 0.0% | Pending SHC_3BB0A8C1_0x0042EA59 | 0.0% | Pending -SHC_3BB0A8C1_0x0042EBC0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042EBC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042EDF0 | 100.0% | Reimplemented @@ -23453,7 +23453,7 @@ SHC_3BB0A8C1_0x00492080 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492120 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00492170 | 0.0% | Pending +SHC_3BB0A8C1_0x00492170 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492620 | 0.0% | Pending @@ -29321,7 +29321,7 @@ SHC_3BB0A8C1_0x004BBA20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BBA30 | 0.0% | Pending -SHC_3BB0A8C1_0x004BBA60 | 0.0% | Pending +SHC_3BB0A8C1_0x004BBA60 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BBC64 | 0.0% | Pending @@ -36253,7 +36253,7 @@ SHC_3BB0A8C1_0x004DC140 | 100.0% | Reimplemented, only the loop's end address re SHC_3BB0A8C1_0x004DC1C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004DC500 | 0.0% | Pending +SHC_3BB0A8C1_0x004DC500 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DC9E0 | 100.0% | Reimplemented