diff --git a/src/OpenSHC/UI/Helpers/ClearSiegeInformationArray2.cpp b/src/OpenSHC/UI/Helpers/ClearSiegeInformationArray2.cpp new file mode 100644 index 0000000000..2e9e24bf71 --- /dev/null +++ b/src/OpenSHC/UI/Helpers/ClearSiegeInformationArray2.cpp @@ -0,0 +1,26 @@ +#include "../Helpers.func.hpp" + +#include "OpenSHC/Globals/DAT_SiegeInformationArray_2.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00b960b8.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042C190 + void Helpers::ClearSiegeInformationArray2() + { + INT_ARRAY_00b960b8::instance[0] = 0; + INT_ARRAY_00b960b8::instance[1] = 0; + INT_ARRAY_00b960b8::instance[2] = 0; + INT_ARRAY_00b960b8::instance[3] = 0; + // The original clears only the first 11 of each setup's 21 values. + for (int setup = 0; setup < 4; ++setup) { + int* const values = DAT_SiegeInformationArray_2::instance[setup][0]; + for (int value = 0; value < 11; ++value) { + values[value] = 0; + } + } + } + +} +} diff --git a/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp b/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp new file mode 100644 index 0000000000..b998eaaa2b --- /dev/null +++ b/src/OpenSHC/UI/Helpers/SomeFearFactorComputation.cpp @@ -0,0 +1,36 @@ +#include "../Helpers.func.hpp" + +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x0043E5A0 + undefined4 Helpers::SomeFearFactorComputation() + { + // Picks a message number from the player's fear factor level. + int const fearFactor + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + if (fearFactor <= -5) { + return 14; + } + if (fearFactor <= -3) { + return 15; + } + if (fearFactor <= -1) { + return 16; + } + if (fearFactor >= 5) { + return 19; + } + int message = 18; + if (fearFactor < 3) { + message = 17; + } + return message; + } + +} +} diff --git a/src/OpenSHC/UI/Helpers/SomeSiegeUnitsComputation.cpp b/src/OpenSHC/UI/Helpers/SomeSiegeUnitsComputation.cpp new file mode 100644 index 0000000000..3773175e27 --- /dev/null +++ b/src/OpenSHC/UI/Helpers/SomeSiegeUnitsComputation.cpp @@ -0,0 +1,79 @@ +#include "../Helpers.func.hpp" + +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_SiegeInformationArray.hpp" +#include "OpenSHC/Globals/DAT_SiegeInformationArray_2.hpp" +#include "OpenSHC/Globals/DAT_SiegeRemainingPoints.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00b960b8.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042C1E0 + void Helpers::SomeSiegeUnitsComputation(int slot) + { + // The value table starts at ARCHER (7 entries of 3), the slot percentages at field_0x548dc. + int* const unitValues = &DAT_RenderingDefinedData::instance.ARCHER; + int* const slotPercentages = &DAT_RenderingDefinedData::instance.field_0x548dc; + int total = INT_ARRAY_00b960b8::instance[1]; + for (int unit = 0; unit < 7; ++unit) { + for (int value = 0; value < 3; ++value) { + total += DAT_SiegeInformationArray_2::instance[1][unit][value] * unitValues[unit * 3 + value]; + } + } + int budgets[4]; + for (int budget = 0; budget < 4; ++budget) { + budgets[budget] = slotPercentages[budget] * total / 100; + } + INT_ARRAY_00b960b8::instance[0] = DAT_SiegeRemainingPoints::instance; + INT_ARRAY_00b960b8::instance[1] = DAT_SiegeRemainingPoints::instance; + INT_ARRAY_00b960b8::instance[2] = DAT_SiegeRemainingPoints::instance; + INT_ARRAY_00b960b8::instance[3] = DAT_SiegeRemainingPoints::instance; + for (int setup = 0; setup < 4; ++setup) { + // The 7 units by 3 values are copied as one run of 21. + for (int value = 0; value < 21; ++value) { + DAT_SiegeInformationArray_2::instance[setup][value / 3][value % 3] + = DAT_SiegeInformationArray::instance[value / 3][value % 3]; + } + } + if (slot != 1) { + int const percentage = slotPercentages[slot]; + int cost = 0; + for (int unit = 0; unit < 7; ++unit) { + DAT_SiegeInformationArray_2::instance[1][unit][0] + = DAT_SiegeInformationArray_2::instance[slot][unit][0] * 100 / percentage; + DAT_SiegeInformationArray_2::instance[1][unit][1] + = DAT_SiegeInformationArray_2::instance[slot][unit][1] * 100 / percentage; + DAT_SiegeInformationArray_2::instance[1][unit][2] + = DAT_SiegeInformationArray_2::instance[slot][unit][2] * 100 / percentage; + cost += DAT_SiegeInformationArray_2::instance[1][unit][0] * unitValues[unit * 3] + + DAT_SiegeInformationArray_2::instance[1][unit][1] * unitValues[unit * 3 + 1] + + DAT_SiegeInformationArray_2::instance[1][unit][2] * unitValues[unit * 3 + 2]; + } + INT_ARRAY_00b960b8::instance[1] = total - cost; + if (INT_ARRAY_00b960b8::instance[1] < 0) { + INT_ARRAY_00b960b8::instance[1] = 0; + } + } + for (int other = 0; other < 4; ++other) { + if (other == slot || other == 1) { + continue; + } + int const percentage = slotPercentages[other]; + int cost = 0; + for (int unit = 0; unit < 7; ++unit) { + for (int value = 0; value < 3; ++value) { + DAT_SiegeInformationArray_2::instance[other][unit][value] + = DAT_SiegeInformationArray_2::instance[1][unit][value] * percentage / 100; + cost += DAT_SiegeInformationArray_2::instance[other][unit][value] * unitValues[unit * 3 + value]; + } + } + INT_ARRAY_00b960b8::instance[other] = budgets[other] - cost; + if (INT_ARRAY_00b960b8::instance[other] < 0) { + INT_ARRAY_00b960b8::instance[other] = 0; + } + } + } + +} +} diff --git a/src/OpenSHC/UI/MenuItems/ProgressBarBox/MenuItemActionHandler_ProgressBarBox_LoadAndSaveGameButtonLogic.cpp b/src/OpenSHC/UI/MenuItems/ProgressBarBox/MenuItemActionHandler_ProgressBarBox_LoadAndSaveGameButtonLogic.cpp new file mode 100644 index 0000000000..7c15baa7f9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ProgressBarBox/MenuItemActionHandler_ProgressBarBox_LoadAndSaveGameButtonLogic.cpp @@ -0,0 +1,315 @@ +// disable deprecation warnings for strcpy and strcat +#pragma warning(disable : 4996) + +#include "../ProgressBarBox.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/IO/FilePackager.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Rendering/Bink/AIMessageQueue.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" +#include "OpenSHC/Audio/SFX/SpeechEffectID.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-macros.hpp" + +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" +#include "OpenSHC/Globals/DAT_WallAndPitchState.hpp" +#include "OpenSHC/Globals/FilePackagerObj.hpp" +#include "OpenSHC/Globals/INT_00b95b64.hpp" +#include "OpenSHC/Globals/INT_00b960e4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004950B0 + void ProgressBarBox::MenuItemActionHandler_ProgressBarBox_LoadAndSaveGameButtonLogic(int param_1, ...) + { + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY + && DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + && DAT_GameSynchronyState::instance.saveRelated) { + return; + } + // The original copies the name and appends the extension inline, so the macros are used here. + char fileName[1008]; // the size of the original's buffer + switch (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter) { + case 32: + case 46: + // save + DAT_UserTextHandlerState::instance.allowUserTextInput = 0; + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + OpenSHC::Text::TAIT_TWO__FILTER_A); + DAT_UserTextHandlerState::instance.allowUserTextInput = 1; + if (DAT_MenuTextInputState::instance.DAT_ArrayOfMapU3EndInt2) { + strcpy(fileName, + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getCurrentText, DAT_UserTextHandlerState::ptr)()); + // ".tmp" + strcat(fileName, S__TMP_005A75A8); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_MAPS, fileName); + } else if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES + || DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_UNUSED_CREATE_SIEGE) { + strcpy(fileName, + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getCurrentText, DAT_UserTextHandlerState::ptr)()); + // ".map" + strcat(fileName, S__MAP_005A2294); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_MAPS, fileName); + } else if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY + || DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + strcpy(fileName, + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getCurrentText, DAT_UserTextHandlerState::ptr)()); + // ".sav" + strcat(fileName, S__SAV_005A75A0); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_UNKNOWN, fileName); + } else if (DAT_GameSynchronyState::instance.isHost) { + strcpy(fileName, DAT_GameSynchronyState::instance.shortMapName); + // ".msv" + strcat(fileName, S__MSV_005A7498); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_UNKNOWN, fileName); + } else { + strcpy(fileName, DAT_GameSynchronyState::instance.shortMapName); + // ".msv" + strcat(fileName, S__MSV_005A7498); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_UNKNOWN, fileName); + } + DAT_UserTextHandlerState::instance.allowUserTextInput = 0; + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)( + OpenSHC::Text::TAIT_NINE__FILTER_B); + DAT_UserTextHandlerState::instance.allowUserTextInput = 1; + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playSpeechSFX, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_GENERAL_SAVING); + FilePackagerObj::instance.loadAndSaveBarFunc + = MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderLoadAndSaveBar); + MACRO_CALL_MEMBER(OpenSHC::IO::FilePackager_Func::writeMapOrSaveFile, FilePackagerObj::ptr)( + DAT_MapDefinedData::instance.MapSectionAddressArray); + INT_00b95b64::instance = 1; + DAT_WallAndPitchState::instance.countdown = 0; + DAT_MenuTextInputState::instance.field_0xa4 = 1; + if ((DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) + || (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER)) { + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + } + if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES) { + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::loadMapHeaders, DAT_ResourceManager::ptr)( + FALSE); + } + break; + case 31: { + // load + int const index = DAT_MenuTextInputState::instance.menuLoadGameRelativeSelectionIndex + + DAT_MenuTextInputState::instance.menuLoadGameRelativeSelectionOffset; + DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_UNUSED_CREATE_SIEGE) { + strcpy(fileName, + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[index])); + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::setTextEntryAndUpdateCursor, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_TWO__FILTER_A, fileName); + // ".tmp" + strcat(fileName, S__TMP_005A75A8); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_MAPS, fileName); + } else if (DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS) { + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY + && DAT_GameSynchronyState::instance.currentGameMode + != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + if (DAT_GameSynchronyState::instance.isHost) { + strcpy(fileName, DAT_GameSynchronyState::instance.shortMapName); + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::setTextEntryAndUpdateCursor, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_TWO__FILTER_A, fileName); + // ".msv" + strcat(fileName, S__MSV_005A7498); + MACRO_CALL_MEMBER( + OpenSHC::Map::TileMapState_Func::setupAllMapSections, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_UNKNOWN, fileName); + } else { + strcpy(fileName, DAT_GameSynchronyState::instance.shortMapName); + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::setTextEntryAndUpdateCursor, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_TWO__FILTER_A, fileName); + // ".msv" + strcat(fileName, S__MSV_005A7498); + MACRO_CALL_MEMBER( + OpenSHC::Map::TileMapState_Func::setupAllMapSections, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_UNKNOWN, fileName); + } + } else { + strcpy(fileName, + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)( + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[index])); + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::setTextEntryAndUpdateCursor, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_TWO__FILTER_A, fileName); + // ".sav" + strcat(fileName, S__SAV_005A75A0); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_UNKNOWN, fileName); + } + } else { + strcpy(fileName, + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[index])); + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::setTextEntryAndUpdateCursor, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_TWO__FILTER_A, fileName); + // ".map" + strcat(fileName, S__MAP_005A2294); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_MAPS, fileName); + } + DAT_SoundSystemState::instance.streamFlagsUnkAndLoopCount_0x34[4] = 0; + DAT_SoundSystemState::instance.streamFlagsUnkAndLoopCount_0x34[3] = 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::Audio::SFX::SFXState_Func::playSpeechSFX, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_GENERAL_LOADING); + FilePackagerObj::instance.loadAndSaveBarFunc + = MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderLoadAndSaveBar); + MACRO_CALL_MEMBER(OpenSHC::IO::FilePackager_Func::readMapOrSavFile, FilePackagerObj::ptr)( + DAT_MapDefinedData::instance.MapSectionAddressArray); + INT_00b95b64::instance = 1; + DAT_GameCore::instance.isBinkVideoPlaying = 0; + DAT_BuildingsState::instance.DAT_IsBuildingOrPeasantBinkPlaying = FALSE; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::BinkControlClass_Func::stopAllBinkPlayback, DAT_BinkControlState::ptr)(); + DAT_SoundSystemState::instance.currentSoundID_0x3278 = -1; + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::setSomeSoundTime, DAT_SoundSystemState::ptr)(); + if (DAT_SoundSystemState::instance.sec_Section1055_0x3274 < 0) { + DAT_SoundSystemState::instance.sec_Section1055_0x3274 = 0; + } + MACRO_CALL_MEMBER( + OpenSHC::Audio::MSS::SoundSystem_Func::setupVolumeAndSoundID, DAT_SoundSystemState::ptr)( + (OpenSHC::DE::SHCDE::eMusicIDs)(DAT_SoundSystemState::instance.sec_Section1055_0x3274)); + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::prepareMap, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::AIMessageQueue_Func::playNextStoredBinkVideo, DAT_VideoBikQueue::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + DAT_MenuTextInputState::instance.dialogResult = 1; + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_MISSION_WIN_DEFEAT_BANNER, 0); + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_PLAYER_INFO_ON_HOVER, 0); + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_WIN_DEFEAT_WINDOW, 0); + if (DAT_MenuModalComposition2::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_DISPLAY_AI_LORD_MESSAGE) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + } + DAT_UnitsState::instance.lastSelectedUnitID = 0; + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); + if (DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_UNUSED_CREATE_SIEGE) { + if (DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS) { + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY + && DAT_GameSynchronyState::instance.currentGameMode + != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_UNKNOWN_33, 0); + } else { + int const soundID = DAT_SoundSystemState::instance.currentSoundID_0x3278; + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + = OpenSHC::UI::Enums::BASMTT_HUNTERSHUT; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + if (soundID > 0) { + DAT_SoundSystemState::instance.currentSoundID_0x3278 = soundID; + } + for (int i = 0; i < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++i) { + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[i] = -1; + } + if (!DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + } + DAT_GameSynchronyState::instance + .currentPlayerFullIDArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] = 1; + if (DAT_GameSynchronyState::instance.currentGameMode + == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + DAT_GameCore::instance.lordIcons[1] = DAT_GameCore::instance.lordIconUnk; + if (DAT_GameCore::instance.lordIconUnk >= 2) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SHARE_AIV_HASH); + } + } + } + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); + for (int i = 0; i < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); ++i) { + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[i] = -1; + } + if (!DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + } + DAT_GameSynchronyState::instance + .currentPlayerFullIDArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] = 1; + INT_00b960e4::instance = 1; + DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_EDITOR; + for (int i = 1; i < countof(DAT_GameState::instance.playerDataArray); ++i) { + DAT_GameState::instance.playerDataArray[i].playerDeathRelated = 0; + } + } + } + break; + } + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Buttons.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Buttons.cpp new file mode 100644 index 0000000000..526f980c4f --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Buttons.cpp @@ -0,0 +1,621 @@ +// disable deprecation warnings for strcpy and strcat +#pragma warning(disable : 4996) + +#include "../TextEditor.func.hpp" + +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/Text/Enums/HelpTextToken.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" +#include "OpenSHC/Globals/DAT_UserHelpDefinedData.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Text::Enums::HelpTextToken; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00462340 + void TextEditor::MenuItemActionHandler_TextEditor_Buttons(int param_1, ...) + { + WCHAR* pWVar2; + int iVar4; + int iVar5; + int iVar6; + BOOLEnum BVar7; + int iVar9; + switch (param_1) { + case -1: + iVar4 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (iVar4 >= 18) { + iVar4 -= 18; + } else { + iVar4 = 0; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar4; + return; + case -2: + iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight; + iVar4 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (iVar4 < ((iVar5 <= 0) - 1 & iVar5) - 18) { + iVar4 += 18; + if (iVar4 <= ((iVar5 <= 0) - 1 & iVar5)) { + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar4; + return; + } + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = (iVar5 <= 0) - 1 & iVar5; + return; + case -3: + if (DAT_TextEditorState::instance.useAlternateHelpTab != 0) { + if (0 <= DAT_TextEditorState::instance.field_0x23964) { + DAT_TextEditorState::instance.activeHelpHotspotIndex + = DAT_TextEditorState::instance.field_0x23964; + } + } else if (0 <= DAT_TextEditorState::instance.currentLinkId) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::openUnusedHelpTextEditorDialog, + DAT_TextEditorState::ptr)(DAT_TextEditorState::instance.currentLinkId); + } + break; + case -4: + if (DAT_TextEditorState::instance.helpSectionHistoryStack[0] != -1) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::popHelpDialogStack, DAT_TextEditorState::ptr)(); + } + break; + case -5: + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::openUnusedHelpTextEditorDialog, DAT_TextEditorState::ptr)(-1); + return; + case 1: + DAT_TextEditorState::instance.helpDialogSubMode + = (uint)(DAT_TextEditorState::instance.helpDialogSubMode == 0); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 2: + DAT_TextEditorState::instance.customHelpTextLength = 0; + DAT_TextEditorState::instance.graphicFileCount = 0; + DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; + DAT_TextEditorState::instance.topVisibleLineIndex = -1; + *DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory = L'\0'; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 3: + DAT_ResourceManager::instance.strFileTitle[0] = '\0'; + DAT_ResourceManager::instance.strFile[0] = '\0'; + BVar7 = MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::showOpenHelpFileDialog, + // "Select help file to load" + DAT_ResourceManager::ptr)(s_Select_help_file_to_load_005a5894); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::openUnusedHelpTextEditorDialog, + DAT_TextEditorState::ptr)(iVar6); + } + } + break; + case 4: + if (DAT_TextEditorState::instance.customHelpTextLength != 0) { + strcpy(DAT_ResourceManager::instance.strFileTitle, + DAT_UserHelpDefinedData::instance + .HelpSections[DAT_TextEditorState::instance.currentHelpSectionID]); + strcpy(DAT_ResourceManager::instance.strFile, + DAT_UserHelpDefinedData::instance + .HelpSections[DAT_TextEditorState::instance.currentHelpSectionID]); + BVar7 = MACRO_CALL_MEMBER( + OpenSHC::IO::ResourceManager_Func::showSaveHelpFileDialog, DAT_ResourceManager::ptr)(); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + DAT_TextEditorState::instance.currentHelpSectionID + = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::saveHelpFileToResource, + DAT_TextEditorState::ptr)(); + } + } + } + break; + case 5: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + DAT_ResourceManager::instance.strFileTitle[0] = '\0'; + DAT_ResourceManager::instance.strFile[0] = '\0'; + BVar7 = MACRO_CALL_MEMBER( + OpenSHC::IO::ResourceManager_Func::showOpenGfxFileDialog, DAT_ResourceManager::ptr)(); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpGraphicName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::loadHelpSectionGraphics, DAT_TextEditorState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_PIC); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] + = L'\x01'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1] + = (WCHAR)iVar6; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = L'\0'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 3] + = L'\x01'; + iVar6 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_PIC); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, + DAT_TextEditorState::ptr)(); + return; + } + } + break; + case 6: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + DAT_ResourceManager::instance.strFileTitle[0] = '\0'; + DAT_ResourceManager::instance.strFile[0] = '\0'; + BVar7 = MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::showOpenHelpFileDialog, + // "Select help file to link to" + DAT_ResourceManager::ptr)(s_Select_help_file_to_link_to_005a5878); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_LINK); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] + = L'\x04'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1] + = (WCHAR)iVar6; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = L'\x04'; + iVar6 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_LINK); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, + DAT_TextEditorState::ptr)(); + return; + } + } + break; + case 7: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_ENDLINK); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = L'\x05'; + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_ENDLINK); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 8: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_FONT); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = L'\x02'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1] + = L'\x11'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = L'\x02'; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = 2; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 9: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_CENTRE); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = L'\a'; + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_CENTRE); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 10: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_ENDCENTRE); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = L'\b'; + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_ENDCENTRE); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 11: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_COLOUR); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = L'\x03'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1] + = L'\x01'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = (WCHAR)OpenSHC::Text::Enums::HTT_COLOUR; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_COLOUR; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 12: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_SOUND); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = L'\n'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1] = L'\v'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = (WCHAR)OpenSHC::Text::Enums::HTT_LINKCOLOUR; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_LINKCOLOUR; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 13: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + DAT_ResourceManager::instance.strFileTitle[0] = '\0'; + DAT_ResourceManager::instance.strFile[0] = '\0'; + BVar7 = MACRO_CALL_MEMBER( + OpenSHC::IO::ResourceManager_Func::showOpenSoundFileDialog, DAT_ResourceManager::ptr)(); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddSoundName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_STRING); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] + = L'\v'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1] + = (WCHAR)iVar6; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = L'\v'; + iVar6 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_STRING); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, + DAT_TextEditorState::ptr)(); + return; + } + } + break; + case 14: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_STRING); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = L'\f'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1] = L'\0'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = (WCHAR)OpenSHC::Text::Enums::HTT_STRING; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_STRING; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 15: + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; + } + DAT_ResourceManager::instance.strFileTitle[0] = '\0'; + DAT_ResourceManager::instance.strFile[0] = '\0'; + BVar7 = MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::showOpenHelpFileDialog, + // "Select help file to include" + DAT_ResourceManager::ptr)(s_Select_help_file_to_include_005a585c); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::helpToken_insertSpaceForHelpTextToken, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_INCLUDE); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] + = L'\x0e'; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1] + = (WCHAR)iVar6; + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = L'\x0e'; + iVar6 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)(OpenSHC::Text::Enums::HTT_INCLUDE); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, + DAT_TextEditorState::ptr)(); + return; + } + } + break; + case 20: + DAT_TextEditorState::instance.useWideHelpLayout ^= 1; + if (DAT_TextEditorState::instance.useWideHelpLayout == 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::setHelpWindowBounds, + DAT_TextEditorState::ptr)(DAT_TextEditorState::instance.dialogX + 10, + (undefined4)((int)(DAT_TextEditorState::instance.dialogY + 10)), + (undefined4)((int)(DAT_TextEditorState::instance.dialogWidth - 40)), + (undefined4)((int)(DAT_TextEditorState::instance.dialogHeight - 45))); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + } + DAT_TextEditorState::instance.dialogContentX = DAT_TextEditorState::instance.dialogX + 10; + DAT_TextEditorState::instance.dialogContentY = DAT_TextEditorState::instance.dialogY + 10; + DAT_TextEditorState::instance.dialogContentWidth = 664; + DAT_TextEditorState::instance.dialogContentHeight = 291; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 32: + switch (DAT_TextEditorState::instance.field_0x23970) { + case 4: + DAT_ResourceManager::instance.strFileTitle[0] = '\0'; + DAT_ResourceManager::instance.strFile[0] = '\0'; + BVar7 = MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::showOpenHelpFileDialog, + // "Select help file to link to" + DAT_ResourceManager::ptr)(s_Select_help_file_to_link_to_005a5878); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + + 1] = (WCHAR)iVar6; + } + } + break; + case 14: + DAT_ResourceManager::instance.strFileTitle[0] = '\0'; + DAT_ResourceManager::instance.strFile[0] = '\0'; + BVar7 = MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::showOpenHelpFileDialog, + // "Select help file to include" + DAT_ResourceManager::ptr)(s_Select_help_file_to_include_005a585c); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + + 1] = (WCHAR)iVar6; + } + } + case 1: + DAT_ResourceManager::instance.strFileTitle[0] = '\0'; + DAT_ResourceManager::instance.strFile[0] = '\0'; + BVar7 = MACRO_CALL_MEMBER( + OpenSHC::IO::ResourceManager_Func::showOpenGfxFileDialog, DAT_ResourceManager::ptr)(); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpGraphicName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + + 1] = (WCHAR)iVar6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::loadHelpSectionGraphics, + DAT_TextEditorState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, + DAT_TextEditorState::ptr)(); + } + } + break; + case 11: + DAT_ResourceManager::instance.strFileTitle[0] = '\0'; + DAT_ResourceManager::instance.strFile[0] = '\0'; + BVar7 = MACRO_CALL_MEMBER( + OpenSHC::IO::ResourceManager_Func::showOpenSoundFileDialog, DAT_ResourceManager::ptr)(); + if (BVar7) { + if (strlen(DAT_ResourceManager::instance.strFileTitle) != 0) { + iVar6 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddSoundName, + DAT_TextEditorState::ptr)(DAT_ResourceManager::instance.strFileTitle); + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + + 1] = (WCHAR)iVar6; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, + DAT_TextEditorState::ptr)(); + } + } + break; + } + break; + case 33: + switch (DAT_TextEditorState::instance.field_0x23970) { + case 1: + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = L'\0'; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 2: + pWVar2 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + iVar6 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + iVar9 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::getPrevHelpSectionID, + DAT_TextEditorState::ptr)((uint)(ushort)pWVar2[iVar6 + 1]); + pWVar2[iVar6 + 1] = (WCHAR)iVar9; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 3: + case 10: + iVar6 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + pWVar2 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + iVar9 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::getPrevHelpColorEntryIndex, + DAT_TextEditorState::ptr)((uint)(ushort)pWVar2[iVar6 + 1]); + pWVar2[iVar6 + 1] = (WCHAR)iVar9; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 12: + pWVar2 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + iVar6 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + pWVar2[iVar6 + 1] = (WCHAR)((int)((ushort)pWVar2[iVar6 + 1] + 19) % 20); + } + break; + case 0: + case 16: + case 17: + case 18: + case 19: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + case 31: + break; + case 34: + switch (DAT_TextEditorState::instance.field_0x23970) { + case 1: + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = L'\x01'; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 2: + pWVar2 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + iVar6 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + iVar9 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::getNextHelpSectionID, + DAT_TextEditorState::ptr)((uint)(ushort)pWVar2[iVar6 + 1]); + pWVar2[iVar6 + 1] = (WCHAR)iVar9; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 3: + case 10: + pWVar2 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + iVar6 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + iVar9 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::getNextHelpColorEntryIndex, + DAT_TextEditorState::ptr)((uint)(ushort)pWVar2[iVar6 + 1]); + pWVar2[iVar6 + 1] = (WCHAR)iVar9; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + return; + case 12: + pWVar2 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + iVar6 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + pWVar2[iVar6 + 1] = (WCHAR)((int)((ushort)pWVar2[iVar6 + 1] + 1) % 20); + } + break; + case 35: + if (DAT_TextEditorState::instance.field_0x23970 == 1) { + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = L'\x02'; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + } + break; + case 36: + if (DAT_TextEditorState::instance.field_0x23970 == 1) { + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + = L'\x03'; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + } + break; + default: + break; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6e036f9340..ecde19732b 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -7457,9 +7457,9 @@ SHC_3BB0A8C1_0x0042C060 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042C090 | 0.0% | Pending -SHC_3BB0A8C1_0x0042C190 | 0.0% | Pending +SHC_3BB0A8C1_0x0042C190 | 83.7% | the original zeroes its register again at the top of each setup; the loop's end address -SHC_3BB0A8C1_0x0042C1E0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042C1E0 | 89.6% | order of the three products in the unit loops; where the remaining points are loaded SHC_3BB0A8C1_0x0042C2F0 | 0.0% | Pending @@ -13589,7 +13589,7 @@ SHC_3BB0A8C1_0x0043E4E0 | 0.0% | Pending SHC_3BB0A8C1_0x0043E540 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0043E5A0 | 0.0% | Pending +SHC_3BB0A8C1_0x0043E5A0 | 75.0% | the original keeps the fear level and the result in the same register (eax) SHC_3BB0A8C1_0x0043E5F0 | 100.0% | Reimplemented @@ -18897,7 +18897,7 @@ SHC_3BB0A8C1_0x00462150 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00462190 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00462340 | 0.0% | Pending +SHC_3BB0A8C1_0x00462340 | 80.4% | no gotos; register allocation SHC_3BB0A8C1_0x00462550 | 0.0% | Pending @@ -24203,7 +24203,7 @@ SHC_3BB0A8C1_0x004950A8 | 0.0% | Pending SHC_3BB0A8C1_0x004950A9 | 0.0% | Pending -SHC_3BB0A8C1_0x004950B0 | 0.0% | Pending +SHC_3BB0A8C1_0x004950B0 | 92.0% | if-chains in the original's != order; register allocation SHC_3BB0A8C1_0x004951A0 | 0.0% | Pending