diff --git a/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp b/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp new file mode 100644 index 0000000000..1ea1130174 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp @@ -0,0 +1,171 @@ +// disable deprecation warnings for strcpy +#pragma warning(disable : 4996) + +#include "../ChooseNetworkServiceProvider.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/UI/ChooseNetworkServiceProvider/ChooseNetworkServiceProviderButtonActions.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/Menu_LobbyMenu.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004909E0 + void ChooseNetworkServiceProvider::MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons( + ChooseNetworkServiceProviderButtonActions action, ...) + { + // the cases in the original's block order + switch (action) { + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_NEXT_IP_ADDRESSUnk: + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::setTextEntryAndUpdateCursor, DAT_UserTextHandlerState::ptr)( + 5, DAT_GameSynchronyState::instance.ipRelatedArray[DAT_GameSynchronyState::instance.ipArrayIndex]); + ++DAT_GameSynchronyState::instance.ipArrayIndex; + if (DAT_GameSynchronyState::instance.ipArrayIndex + >= countof(DAT_GameSynchronyState::instance.ipRelatedArray)) { + DAT_GameSynchronyState::instance.ipArrayIndex = 0; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_GAMESPY_ARCADEUnk: + if (DAT_GameSynchronyState::instance.gameSpyArcadeAvailable != 0) { + DAT_WindowAndDirectDraw::instance.postWindowCloseMessage = 1; + DAT_GameSynchronyState::instance.openOnClose = TRUE; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_SCROLL_DOWNUnk: + if (DAT_GameSynchronyState::instance.scrollBarItemOffset + < DAT_GameSynchronyState::instance.scrollBarItemCount - 4) { + ++DAT_GameSynchronyState::instance.scrollBarItemOffset; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_SCROLL_UPUnk: + if (DAT_GameSynchronyState::instance.scrollBarItemOffset > 0) { + --DAT_GameSynchronyState::instance.scrollBarItemOffset; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_JOIN_GAME: + DAT_GameSynchronyState::instance.isHost = FALSE; + DAT_GameSynchronyState::instance.kickedAtTime = 0; + // remember a new address: in the first empty slot, or at the end after dropping the oldest + if (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_GRANARY_OR_MPMENU_TCPIP + && strlen(MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(5)) + != 0) { + OpenSHC::WindowsHelper::Enums::BOOLEnum known = FALSE; + for (int entry = 0; entry < countof(DAT_GameSynchronyState::instance.ipRelatedArray); ++entry) { + if (MACRO_CALL(OpenSHC::OS_Func::__stricmp)( + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(5), + DAT_GameSynchronyState::instance.ipRelatedArray[entry]) + == 0) { + known = TRUE; + break; + } + } + if (!known) { + OpenSHC::WindowsHelper::Enums::BOOLEnum stored = FALSE; + for (int slot = 0; slot < countof(DAT_GameSynchronyState::instance.ipRelatedArray); ++slot) { + if (strlen(DAT_GameSynchronyState::instance.ipRelatedArray[slot]) == 0) { + strcpy(DAT_GameSynchronyState::instance.ipRelatedArray[slot], + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(5)); + stored = TRUE; + break; + } + } + if (!stored) { + // memcpy and memset compile to the original's dword moves + for (int row = 0; row < countof(DAT_GameSynchronyState::instance.ipRelatedArray) - 1; + ++row) { + memcpy(DAT_GameSynchronyState::instance.ipRelatedArray[row], + DAT_GameSynchronyState::instance.ipRelatedArray[row + 1], + sizeof(DAT_GameSynchronyState::instance.ipRelatedArray[row])); + } + memset(DAT_GameSynchronyState::instance + .ipRelatedArray[countof(DAT_GameSynchronyState::instance.ipRelatedArray) - 1], + 0, + sizeof(DAT_GameSynchronyState::instance + .ipRelatedArray[countof(DAT_GameSynchronyState::instance.ipRelatedArray) - 1])); + strcpy(DAT_GameSynchronyState::instance + .ipRelatedArray[countof(DAT_GameSynchronyState::instance.ipRelatedArray) - 1], + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(5)); + } + } + } + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::initializeDirectPlayAndCreateOrJoinSession, + DAT_GameSynchronyState::ptr)(FALSE) + >= 0) { + DAT_GameSynchronyState::instance.unkEnumerationRelatedBool = false; + DAT_GameSynchronyState::instance.scrollBarIndex = -1; + DAT_GameSynchronyState::instance.scrollBarItemOffset = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::restartDPlaySessionEnumeration, + DAT_GameSynchronyState::ptr)(FALSE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_FINDING_NETWORK_SESSIONS, FALSE); + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_HOST_GAME: + DAT_GameSynchronyState::instance.isHost = TRUE; + DAT_GameSynchronyState::instance.kickedAtTime = 0; + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::initializeDirectPlayAndCreateOrJoinSession, + DAT_GameSynchronyState::ptr)(FALSE) + >= 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + DAT_GameSynchronyState::instance.field_0x106ee4 = 1; + DAT_GameCore::instance.menuTabToSwitchTo.tabType = OpenSHC::UI::Enums::BASMTT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_LOBBY_MENU, 0); + MACRO_CALL(OpenSHC::Synchrony_Func::InitSkirmishLobbyData)(); + Menu_LobbyMenu::instance.thousand = 0; + MACRO_CALL(OpenSHC::OS_Func::_memset)(DAT_GameSynchronyState::instance.DAT_PlayerNames, 0, + sizeof(DAT_GameSynchronyState::instance.DAT_PlayerNames)); + strcpy(DAT_GameSynchronyState::instance.DAT_PlayerNames[1], + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(0)); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::waitForMultiplayerHost, + DAT_GameSynchronyState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_EXIT: + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_EXIT_ALTUnk: + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); + DAT_GameSynchronyState::instance.kickedAtTime = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectHeader.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectHeader.cpp new file mode 100644 index 0000000000..0c95af1046 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectHeader.cpp @@ -0,0 +1,78 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00427740 + void LobbyMenu::MenuItemRenderFunction_LobbyMenu_MapSelectHeader(int column, ...) + { + // both set before the dialog tests, for the match: set after them, the two swap registers + int textNumInGroup = -1; + int xOffset = 0; + if (MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE) { + return; + } + // the cases in the original's block order + switch (column) { + case 2: + // "Bl" + textNumInGroup = 410; + xOffset = 2; + break; + case 1: + // "No" + textNumInGroup = 61; + xOffset = 2; + break; + case 0: + // "Name" + textNumInGroup = 62; + xOffset = 8; + break; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(FALSE, 1, DAT_ButtonBackgroundBlendStrength::instance); + // the fade written the long way round, for the match; it comes back to the blend strength itself + int const blendStrength = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32; + int const textY = DAT_ButtonY::instance + 5; + // x read in each branch: one read before the branch swaps two registers + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textX = DAT_ButtonX::instance + xOffset; + 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_XPLAY_WAITING_ROOM, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, + blendStrength); + } else { + int const textX = DAT_ButtonX::instance + xOffset; + 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_XPLAY_WAITING_ROOM, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, + blendStrength); + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemRenderFunction_MainMenu_Main.cpp b/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemRenderFunction_MainMenu_Main.cpp new file mode 100644 index 0000000000..ebd1a1c4ce --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemRenderFunction_MainMenu_Main.cpp @@ -0,0 +1,144 @@ +#include "../MainMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/DirectDrawStatus.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/BOOL_WasInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnknownGFXIndex.hpp" +#include "OpenSHC/Globals/INT_00b95abc.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00424F50 + void MainMenu::MenuItemRenderFunction_MainMenu_Main(int button, ...) + { + if (DAT_UnknownGFXIndex::instance == 1) { + return; + } + if (button != 5 && !DAT_ButtonCurrentlyInteracting::instance && button != 6 && button != 7 && button != 8 + && button != 9) { + // a button that is no longer hovered stops being the last one hovered + if (button == INT_00b95abc::instance) { + INT_00b95abc::instance = -1; + } + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag + && (button == 1 || button == 2 || button == 3)) { + DAT_CurrentButtonGmDataIndex::instance = 353; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } else { + if (button == 5) { + if (DAT_ButtonCurrentlyInteracting::instance && !BOOL_WasInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFB); + } + BOOL_WasInteracting::instance = DAT_ButtonCurrentlyInteracting::instance; + } + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag + && (button == 1 || button == 2 || button == 3 || button == 9)) { + DAT_CurrentButtonGmDataIndex::instance = 353; + } + if (button < 10) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } else { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonOnScreenMenu)(); + } + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4; + // the hover sound plays once, when the pointer moves onto another button + if ((button < 5 || button == 9) && DAT_ButtonCurrentlyInteracting::instance) { + if (INT_00b95abc::instance != button) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x92); + } + INT_00b95abc::instance = button; + } + } + if (button < 5) { + if (button == 4 && DAT_GameCore::instance.directDrawStatus < OpenSHC::Rendering::Enums::DD7_LOADED) { + // "Multiplayer", greyed out + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 29, DAT_ButtonX::instance + 30, + DAT_ButtonY::instance + 15, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_7F7F7F, 0, + 16, FALSE); + } else if (!DAT_ButtonCurrentlyInteracting::instance) { + // one call per hover state, the two the same, each reading y before x, for the match + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + 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_MAINOPTIONS, button + 25), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } else { + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + 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_MAINOPTIONS, button + 25), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } + } + if (button == 9) { + // two calls that are the same, one per hover state: the split is only for the match + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + // "Custom Scenarios" + 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_MAINOPTIONS, 30), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } else { + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + // "Custom Scenarios" + 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_MAINOPTIONS, 30), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } + } else if (button >= 5) { + return; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, 1, + DAT_ButtonX::instance - 85, DAT_ButtonY::instance - 28, OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, + 2, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main.cpp b/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main.cpp new file mode 100644 index 0000000000..4662a2b4a2 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main.cpp @@ -0,0 +1,89 @@ +#include "../OnlineVoteQuitAndQuitGame.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00495860 + void OnlineVoteQuitAndQuitGame::MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main(int button, ...) + { + // the cases in the original's block order + switch (button) { + case 1: + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_MULTIPLAYER_END_OF_GAME; + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 7; + MACRO_CALL( + OpenSHC::UI::MenuItems::General_Func::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk)( + 22); + break; + case 2: { + // a vote needs someone else to answer it + int playerCount = 0; + for (int slot = 1; slot < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); ++slot) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] != -1) { + playerCount++; + } + } + if (playerCount > 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_91); + DAT_GameSynchronyState::instance.quitGameVoteRelated = 2; + // the empty slots count as yes votes, and so does the player asking + for (int slot = 1; slot < countof(DAT_GameSynchronyState::instance.quitGameVoteArray); ++slot) { + DAT_GameSynchronyState::instance.quitGameVoteArray[slot] + = DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] == -1; + } + DAT_GameSynchronyState::instance + .quitGameVoteArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] = 1; + DAT_GameSynchronyState::instance.quitGameVoteRequestTime = timeGetTime(); + break; + } + // alone in the game, the player quits at once, as with button 1: the code is repeated here rather + // than falling into case 1, for the match + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_MULTIPLAYER_END_OF_GAME; + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 7; + MACRO_CALL( + OpenSHC::UI::MenuItems::General_Func::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk)( + 22); + break; + } + case 4: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_QUIT_GAME_VOTE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + break; + case 5: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 1; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_QUIT_GAME_VOTE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + break; + case 3: + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + break; + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp new file mode 100644 index 0000000000..85d7902a24 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp @@ -0,0 +1,167 @@ +#include "../SinglePlayerMapChoice.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_00b960f4.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_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DWORD_00b95b1c.hpp" +#include "OpenSHC/Globals/INT_00b95b74.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042D640 + void SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands(int button, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + return; + } + DAT_StopHandlingMenuItems::instance = 0; + // the cases in the original's block order + switch (button) { + case -1000: + case 2: + // back + if (DAT_MapMissionType::instance == 0) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 10000); + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS, 10000); + } + DWORD_00b95b1c::instance = timeGetTime(); + DAT_00b960dc::instance = 1; + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case -101: { + // map description scroll down + int const limit = INT_00b95b74::instance - 204; + if (DAT_00b960f4::instance >= limit) { + return; + } + DAT_00b960f4::instance += 14; + if (DAT_00b960f4::instance > limit) { + DAT_00b960f4::instance = limit; + } + return; + } + case -1100: + case 65: + // start the game + // the offset through ptr: that way the relative selection is read first, for the match + if (DAT_GameSynchronyState::ptr->DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + < 0) { + return; + } + if (DAT_MapMissionType::instance == 0 || DAT_MapMissionType::instance == 3) { + DAT_GameState::instance.mapAndTime.difficulty = 1; + } + MACRO_CALL(OpenSHC::UI::Actions_Func::LaunchSinglePlayerGameUnk)(0); + return; + case 66: + // castle builder and landscape mode + if (DAT_MapMissionType::instance != 0) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_MapMissionType::instance = 0; + } + return; + case 67: + // mission type 1 + if (DAT_MapMissionType::instance != 1) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_MapMissionType::instance = 1; + } + return; + case 68: + // siege mode + if (DAT_MapMissionType::instance != 2) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_MapMissionType::instance = 2; + } + return; + case 76: + // mission type 3 + if (DAT_MapMissionType::instance != 3) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_MapMissionType::instance = 3; + } + return; + case 69: + // difficulty + if (DAT_GameCore::instance.mapU4Int1_2 == 0 && DAT_MapMissionType::instance != 0) { + ++DAT_GameState::instance.mapAndTime.difficulty; + if (DAT_GameState::instance.mapAndTime.difficulty >= 4) { + DAT_GameState::instance.mapAndTime.difficulty = 0; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeRelatedCopying)( + DAT_GameState::instance.mapAndTime.difficulty); + } + return; + case 74: + // advanced siege, for the defender + if (DAT_GameCore::instance.mapU4Int1_2 == 0 && DAT_MapMissionType::instance == 2 + && DAT_GameSynchronyState::instance.currentPlayerSlotID == 2) { + DAT_SH1_SiegeAdvancedMode::instance ^= 1; + } + return; + case 77: + // "Attacking" or "Defending" + if (DAT_MapMissionType::instance == 2 && DAT_GameCore::instance.mapU4Int1_2 == 0) { + if (DAT_GameSynchronyState::instance.currentPlayerSlotID == 1) { + DAT_GameSynchronyState::instance.currentPlayerSlotID = 2; + return; + } + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_SH1_SiegeAdvancedMode::instance = 0; + } + return; + case -10: + // map list scroll up + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset > 0) { + --DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + } + return; + case -11: + // map list scroll down + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 13) { + ++DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + } + return; + case -100: + // map description scroll up + DAT_00b960f4::instance -= 14; + if (DAT_00b960f4::instance < 0) { + DAT_00b960f4::instance = 0; + } + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 826f7fa80e..3a97b43162 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6685,7 +6685,7 @@ SHC_3BB0A8C1_0x00424CD0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00424DA0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00424F50 | 0.0% | Pending +SHC_3BB0A8C1_0x00424F50 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004251A0 | 100.0% | Reimplemented @@ -6817,7 +6817,7 @@ SHC_3BB0A8C1_0x004274F0 | 0.0% | Pending SHC_3BB0A8C1_0x004276F0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00427740 | 0.0% | Pending +SHC_3BB0A8C1_0x00427740 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00427810 | 0.0% | Pending @@ -7865,7 +7865,7 @@ SHC_3BB0A8C1_0x0042D632 | 0.0% | Pending SHC_3BB0A8C1_0x0042D633 | 0.0% | Pending -SHC_3BB0A8C1_0x0042D640 | 0.0% | Pending +SHC_3BB0A8C1_0x0042D640 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042D8B0 | 0.0% | Pending @@ -23383,7 +23383,7 @@ SHC_3BB0A8C1_0x00490690 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00490920 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004909E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004909E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00490C20 | 0.0% | Pending @@ -24217,7 +24217,7 @@ SHC_3BB0A8C1_0x00495800 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00495840 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00495860 | 0.0% | Pending +SHC_3BB0A8C1_0x00495860 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00495A14 | 0.0% | Pending