diff --git a/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp new file mode 100644 index 0000000000..20df47dbd0 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp @@ -0,0 +1,89 @@ +#include "../HistoricMissionSelect.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_00b95b2c.hpp" +#include "OpenSHC/Globals/DAT_00b96100.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.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 0x004269E0 + void HistoricMissionSelect::MenuItemRenderFunction_HistoricMissionSelect_MissionRows(int row, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog == OpenSHC::UI::Enums::MMT_NO_MENU + && DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE) { + // a mission not reached yet is drawn greyed, with no text + if (!DAT_GameCore::instance.unlockAllHistoricalCampaigns + && (int)(DAT_00b96100::instance - row - 1) + > (&DAT_GameCore::instance.scenarioProgress.progressCallToArms)[DAT_00b95b2c::instance]) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(FALSE, row, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, DAT_PencilRenderCore::ptr)( + DAT_00b96100::instance - row - 1 == DAT_GameCore::instance.missionNumber1to20, row, 0); + int const number = -row; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + // written in each arm: MSVC then hoists the calls' common pushes, as the original has them + if (number == DAT_GameCore::instance.missionNumber1to20) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(number, DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); + // read before the nested call, in the order the original loads them + int const nameY = DAT_ButtonY::instance + 5; + int const nameX = DAT_ButtonX::instance + 30; + int const mission = DAT_00b96100::instance - row - 1; + 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_MISSION_NAMES, mission), + nameX, nameY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); + } else if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(number, DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_NAMES, DAT_00b96100::instance - row - 1, + DAT_ButtonX::instance + 30, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(number, DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_NAMES, DAT_00b96100::instance - row - 1, + DAT_ButtonX::instance + 30, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE); + } + DAT_ButtonUnknownZero::instance = FALSE; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp new file mode 100644 index 0000000000..d623e40635 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp @@ -0,0 +1,292 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.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_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00b95960.hpp" +#include "OpenSHC/Globals/INT_00b95b74.hpp" +#include "OpenSHC/Globals/INT_00b95f64.hpp" +#include "OpenSHC/Globals/SEC_RNG.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00442640 + void LobbyMenu::MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick(int action, ...) + { + if (DAT_00b960dc::instance != 0) { + return; + } + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + return; + } + // case 105's index, declared here: declared in its case, the two loads of case 4's sum swap + int mapIndex = 0; + switch (action) { + case -1: + // chat scroll up + if (DAT_GameSynchronyState::instance.chatScrollOffset < 15) { + ++DAT_GameSynchronyState::instance.chatScrollOffset; + } + break; + case -2: + // chat scroll down + if (DAT_GameSynchronyState::instance.chatScrollOffset > 0) { + --DAT_GameSynchronyState::instance.chatScrollOffset; + } + break; + case 1: + // load game: only when every occupied slot is ready + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++player) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 + && DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[player] == 0) { + return; + } + } + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::checkPlayerSetValid, DAT_GameSynchronyState::ptr)() + >= 2) { + DAT_MenuTextInputState::instance.field_0x9c = 1; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::loadOrSaveGame, DAT_MenuTextInputState::ptr)(9); + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + } + break; + case 2: + // leave the lobby + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + } else { + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_MULTIPLAYER_END_OF_GAME; + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 7; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk)(22); + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + } + } + break; + case -20: + case 3: + // ready button + if (DAT_GameSynchronyState::instance.flag_0x7aad8 + && DAT_GameSynchronyState::instance.DAT_TwoIfNotHost == 2) { + DAT_GameSynchronyState::instance + .DAT_PlayerSlotArraySomeValue[DAT_GameSynchronyState::instance.currentPlayerSlotID] ^= 1; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_HOST_ANNOUNCE_TEAMS_AND_POSITIONS); + } + if (DAT_GameSynchronyState::instance.isHost + && DAT_GameSynchronyState::instance + .DAT_PlayerSlotArraySomeValue[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_GAME_INTENSITY_OR_BALANCE); + } + break; + case 4: + // start the game: only when every occupied slot is ready + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++player) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 + && DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[player] == 0) { + return; + } + } + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::checkPlayerSetValid, DAT_GameSynchronyState::ptr)() + >= 2 + && DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + >= 0 + && DAT_GameSynchronyState::instance + .unknownMapRelatedReceivedDataArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected]] + > 0) { + MACRO_CALL_MEMBER(OpenSHC::Random::RNG_Func::setTimeBasedSeed, SEC_RNG::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_TRIGGER_LOBBY_PLAYER_INFORMATION_REFRESH); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_GAME_INTENSITY_OR_BALANCE); + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + DAT_GameCore::instance.isSkirmishTrail = FALSE; + MACRO_CALL(OpenSHC::UI::Actions_Func::LaunchSkirmishGame)(0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_START_MULTIPLAYER_GAME); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + break; + case -10: + // map list scroll up + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset > 0) { + --DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + if (DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_MAP_SELECTION); + } + } + break; + case -11: + // map list scroll down + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 8) { + ++DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + if (DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_MAP_SELECTION); + } + } + break; + case -100: + // map description scroll up + DAT_00b960f4::instance -= 14; + if (DAT_00b960f4::instance < -19) { + DAT_00b960f4::instance = -19; + } + break; + case -101: { + // map description scroll down + int const limit = INT_00b95b74::instance - 114; + if (DAT_00b960f4::instance < limit) { + DAT_00b960f4::instance += 14; + if (DAT_00b960f4::instance > limit) { + DAT_00b960f4::instance = limit; + } + } + break; + } + case -200: + // pick up the keep position under the mouse + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + for (int position = 0; position < countof(DAT_GameCore::instance.keepPositions); ++position) { + if (DAT_GameCore::instance.keepPositions[position].x < 0 + || DAT_MouseState::instance.screenSpaceX < DAT_GameCore::instance.keepPositions[position].x + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 572 + || DAT_MouseState::instance.screenSpaceX > DAT_GameCore::instance.keepPositions[position].x + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 595) { + continue; + } + int const y = DAT_GameCore::instance.keepPositions[position].y + + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + if (DAT_MouseState::instance.screenSpaceY < y + 3 + || DAT_MouseState::instance.screenSpaceY > y + 35) { + continue; + } + INT_00b95960::instance = DAT_GameSynchronyState::instance.playerPositionsArray[position]; + INT_00b95f64::instance = position; + return; + } + break; + case -201: + // drop it on the keep position under the mouse: swap the two players' positions + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + if (INT_00b95960::instance >= 0) { + for (int position = 0; position < countof(DAT_GameCore::instance.keepPositions); ++position) { + if (DAT_GameCore::instance.keepPositions[position].x < 0 + || DAT_MouseState::instance.screenSpaceX < DAT_GameCore::instance.keepPositions[position].x + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 572 + || DAT_MouseState::instance.screenSpaceX > DAT_GameCore::instance.keepPositions[position].x + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 595) { + continue; + } + int const y = DAT_GameCore::instance.keepPositions[position].y + + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + if (DAT_MouseState::instance.screenSpaceY < y + 3 + || DAT_MouseState::instance.screenSpaceY > y + 35) { + continue; + } + int const dragged + = DAT_GameSynchronyState::instance.playerPositionsArray[INT_00b95f64::instance]; + DAT_GameSynchronyState::instance.playerPositionsArray[INT_00b95f64::instance] + = DAT_GameSynchronyState::instance.playerPositionsArray[position]; + DAT_GameSynchronyState::instance.playerPositionsArray[position] = dragged; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_HOST_ANNOUNCE_TEAMS_AND_POSITIONS); + break; + } + } + INT_00b95960::instance = -1; + break; + case 105: + mapIndex = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[mapIndex]; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_103); + break; + case 413: + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFD); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_RANKING_GAMES, 0); + break; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp b/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp new file mode 100644 index 0000000000..230d9826e9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp @@ -0,0 +1,95 @@ +#include "../SaveLoadMap.func.hpp" + +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00492DE0 + void SaveLoadMap::MenuItemActionHandler_SaveLoadMap_TableHeader(int button, ...) + { + // the header's arrows, -1 to -4, choose the column and the order the sort below turns round + if (button < 0) { + button = -1 - button; + switch (button) { + case 0: + DAT_MenuTextInputState::instance.fileListSortOrder = 1; + break; + case 1: + DAT_MenuTextInputState::instance.fileListSortOrder = 0; + button = 0; + break; + case 2: + DAT_MenuTextInputState::instance.fileListSortOrder = 3; + button = 1; + break; + case 3: + DAT_MenuTextInputState::instance.fileListSortOrder = 2; + button = 1; + break; + } + } + switch (button) { + case 1: + // by the file's time: a bubble sort, one way or the other + if (DAT_MenuTextInputState::instance.fileListSortOrder == 2) { + for (int swaps = 1; swaps != 0;) { + swaps = 0; + for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount - 1; ++i) { + if (DAT_ResourceManager::instance + .mapFileTimes[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]] + > DAT_ResourceManager::instance + .mapFileTimes[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]]) { + int const moved = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1] = moved; + ++swaps; + } + } + } + DAT_MenuTextInputState::instance.fileListSortOrder = 3; + } else { + for (int swaps = 1; swaps != 0;) { + swaps = 0; + for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount - 1; ++i) { + if (DAT_ResourceManager::instance + .mapFileTimes[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]] + < DAT_ResourceManager::instance + .mapFileTimes[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]]) { + int const moved = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1] = moved; + ++swaps; + } + } + } + DAT_MenuTextInputState::instance.fileListSortOrder = 2; + } + DAT_MenuTextInputState::instance.previewedListIndex = -1; + return; + case 0: + // by name: the list as it was read, or the other way round + if (DAT_MenuTextInputState::instance.fileListSortOrder == 0) { + for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount; ++i) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] + = DAT_MenuTextInputState::instance.fileListEntryCount - i - 1; + } + DAT_MenuTextInputState::instance.fileListSortOrder = 1; + } else { + for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount; ++i) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] = i; + } + DAT_MenuTextInputState::instance.fileListSortOrder = 0; + } + DAT_MenuTextInputState::instance.previewedListIndex = -1; + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..f343067b9a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6781,7 +6781,7 @@ SHC_3BB0A8C1_0x00426830 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004268C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004269E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004269E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00426B80 | 100.0% | Reimplemented @@ -13693,7 +13693,7 @@ SHC_3BB0A8C1_0x00442230 | 0.0% | Pending SHC_3BB0A8C1_0x00442300 | 0.0% | Pending -SHC_3BB0A8C1_0x00442640 | 0.0% | Pending +SHC_3BB0A8C1_0x00442640 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004429C0 | 0.0% | Pending @@ -23525,7 +23525,7 @@ SHC_3BB0A8C1_0x00492C60 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492C90 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00492DE0 | 0.0% | Pending +SHC_3BB0A8C1_0x00492DE0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492E70 | 0.0% | Pending