diff --git a/src/OpenSHC/UI/MenuItems/CrusadeMissionIntro/MenuItemActionHandler_CrusadeMissionIntro_Main.cpp b/src/OpenSHC/UI/MenuItems/CrusadeMissionIntro/MenuItemActionHandler_CrusadeMissionIntro_Main.cpp new file mode 100644 index 0000000000..2d8501b594 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/CrusadeMissionIntro/MenuItemActionHandler_CrusadeMissionIntro_Main.cpp @@ -0,0 +1,64 @@ +#include "../CrusadeMissionIntro.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/Skirmish.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8C10 + void CrusadeMissionIntro::MenuItemActionHandler_CrusadeMissionIntro_Main(int button, ...) + { + if (button == 10) { + if (DAT_GameCore::instance.gameSuspended == 1) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + // the next mission of the trail, while there is one: 20, 30 and 50 missions long + // one call per trail, which MSVC merges (one call with mission and length locals: 100.0% -> 80.9%) + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + if (DAT_GameCore::instance.extremeTrailProgress < 20) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::SetupSkirmishMode)( + DAT_GameCore::instance.extremeTrailProgress); + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + if (DAT_GameCore::instance.warchestTrailProgress < 30) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::SetupSkirmishMode)( + DAT_GameCore::instance.warchestTrailProgress); + } + } else { + if (DAT_GameCore::instance.skirmishTrailProgress < 50) { + MACRO_CALL(OpenSHC::Game::Skirmish_Func::SetupSkirmishMode)( + DAT_GameCore::instance.skirmishTrailProgress); + } + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + if (button == 11) { + if (DAT_GameCore::instance.gameSuspended == 1) { + // the yes/no dialog asks "Quit Mission" + 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; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_MAP, 0); + } + } + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/CrusadeMissionIntro/MenuItemRenderFunction_CrusadeMissionIntro_Main.cpp b/src/OpenSHC/UI/MenuItems/CrusadeMissionIntro/MenuItemRenderFunction_CrusadeMissionIntro_Main.cpp new file mode 100644 index 0000000000..eaca13b013 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/CrusadeMissionIntro/MenuItemRenderFunction_CrusadeMissionIntro_Main.cpp @@ -0,0 +1,46 @@ +#include "../CrusadeMissionIntro.func.hpp" + +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8BB0 + void CrusadeMissionIntro::MenuItemRenderFunction_CrusadeMissionIntro_Main(int button, ...) + { + // the trail is finished once its progress reaches its length: 20, 30 and 50 missions + BOOLEnum trailComplete = FALSE; + DAT_ButtonUnknownZero::instance = FALSE; + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + if (DAT_GameCore::instance.extremeTrailProgress >= 20) { + trailComplete = TRUE; + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + if (DAT_GameCore::instance.warchestTrailProgress >= 30) { + trailComplete = TRUE; + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_FIRST_EDITION) { + if (DAT_GameCore::instance.skirmishTrailProgress >= 50) { + trailComplete = TRUE; + } + } + if (button == 10 && trailComplete) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/FindingNetworkSessions/MenuItemActionHandler_FindingNetworkSessions_Scrollbar.cpp b/src/OpenSHC/UI/MenuItems/FindingNetworkSessions/MenuItemActionHandler_FindingNetworkSessions_Scrollbar.cpp new file mode 100644 index 0000000000..81188df3f1 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/FindingNetworkSessions/MenuItemActionHandler_FindingNetworkSessions_Scrollbar.cpp @@ -0,0 +1,48 @@ +#include "../FindingNetworkSessions.func.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace FindingNetworkSessions { + + // FUNCTION: STRONGHOLDCRUSADER 0x0047D330 + void MenuItemActionHandler_FindingNetworkSessions_Scrollbar( + int unused, int scrollbarEvent, int* minValue, int* maxValue, int* currentValue) + { + // ten sessions fit in the list + switch (scrollbarEvent) { + case 1: + *minValue = 0; + *maxValue = DAT_GameSynchronyState::instance.DPLAY_SessionsCount - 10; + *currentValue = DAT_GameSynchronyState::instance.scrollBarItemOffset; + return; + case 2: + case 3: + DAT_GameSynchronyState::instance.scrollBarItemOffset = *currentValue; + return; + case 4: + *currentValue = DAT_GameSynchronyState::instance.scrollBarItemOffset; + *maxValue = DAT_GameSynchronyState::instance.DPLAY_SessionsCount - 10; + return; + case 5: + if (DAT_GameSynchronyState::instance.scrollBarItemOffset > 0) { + --DAT_GameSynchronyState::instance.scrollBarItemOffset; + } + *currentValue = DAT_GameSynchronyState::instance.scrollBarItemOffset; + return; + case 6: + if (DAT_GameSynchronyState::instance.scrollBarItemOffset + < DAT_GameSynchronyState::instance.DPLAY_SessionsCount - 10) { + ++DAT_GameSynchronyState::instance.scrollBarItemOffset; + } + *currentValue = DAT_GameSynchronyState::instance.scrollBarItemOffset; + return; + } + } + + } + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_GameOptionsTextButton.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_GameOptionsTextButton.cpp new file mode 100644 index 0000000000..7e4e17fdae --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_GameOptionsTextButton.cpp @@ -0,0 +1,48 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace General { + + // FUNCTION: STRONGHOLDCRUSADER 0x004934F0 + void MenuItemRenderFunction_General_GameOptionsTextButton(int textIndex, ...) + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // one call and position per path, which MSVC merges (colour local: 100.0% -> 62.5%; x, y above: 97.2%) + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 7; + 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, textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + return; + } + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 7; + 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, textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + + } + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/RankingGames/MenuItemActionHandler_RankingGames_Scrollbar.cpp b/src/OpenSHC/UI/MenuItems/RankingGames/MenuItemActionHandler_RankingGames_Scrollbar.cpp new file mode 100644 index 0000000000..375fa6d9a8 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/RankingGames/MenuItemActionHandler_RankingGames_Scrollbar.cpp @@ -0,0 +1,63 @@ +#include "../RankingGames.func.hpp" + +#include "OpenSHC/Globals/INT_00eb9b60.hpp" +#include "OpenSHC/Globals/INT_00ed3120.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D9B30 + void RankingGames::MenuItemActionHandler_RankingGames_Scrollbar( + int unused, int scrollbarEvent, int* minValue, int* maxValue, int* currentValue) + { + // eight games fit in the list + switch (scrollbarEvent) { + case 1: + *minValue = 0; + *maxValue = 1; + *currentValue = 0; + return; + case 2: + case 3: + // stores only on a change, as the original does (plain store: quick_diff 0.8679 -> 0.7308) + if (*currentValue != INT_00ed3120::instance) { + INT_00ed3120::instance = *currentValue; + } + return; + case 4: { + *minValue = 0; + // one read of the count (reading it again for the test: quick_diff 0.8679 -> 0.7593) + int const lastOffset = INT_00eb9b60::instance - 8; + *maxValue = lastOffset; + if (lastOffset < 0) { + *maxValue = 0; + } + // stores only on a change, as the original does (plain store: quick_diff 0.8679 -> 0.6538) + if (*currentValue != INT_00ed3120::instance) { + *currentValue = INT_00ed3120::instance; + } + return; + } + case 7: + // a click on the track pages by 6 of the 8 games + *currentValue = 6; + return; + case 5: + if (INT_00ed3120::instance > 0) { + --INT_00ed3120::instance; + } + *currentValue = INT_00ed3120::instance; + return; + case 6: + if (INT_00ed3120::instance < INT_00eb9b60::instance - 8) { + ++INT_00ed3120::instance; + } + *currentValue = INT_00ed3120::instance; + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index d195ecb365..9bdd23e6e5 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -22313,7 +22313,7 @@ SHC_3BB0A8C1_0x0047D100 | 0.0% | Pending SHC_3BB0A8C1_0x0047D190 | 0.0% | Pending -SHC_3BB0A8C1_0x0047D330 | 0.0% | Pending +SHC_3BB0A8C1_0x0047D330 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047D3CC | 0.0% | Pending @@ -23621,7 +23621,7 @@ SHC_3BB0A8C1_0x004934E4 | 0.0% | Pending SHC_3BB0A8C1_0x004934E5 | 0.0% | Pending -SHC_3BB0A8C1_0x004934F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004934F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00493560 | 0.0% | Pending @@ -36003,9 +36003,9 @@ SHC_3BB0A8C1_0x004D8AB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D8AE0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D8BB0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8BB0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D8C10 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8C10 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D8CB0 | 0.0% | Pending @@ -36033,7 +36033,7 @@ SHC_3BB0A8C1_0x004D9730 | 0.0% | Pending SHC_3BB0A8C1_0x004D99F0 | 0.0% | Pending -SHC_3BB0A8C1_0x004D9B30 | 0.0% | Pending +SHC_3BB0A8C1_0x004D9B30 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D9BF0 | 0.0% | Pending