diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CrusadeMapAndEndscreen.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CrusadeMapAndEndscreen.cpp index e255516201..a298a7327b 100644 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CrusadeMapAndEndscreen.cpp +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CrusadeMapAndEndscreen.cpp @@ -40,7 +40,7 @@ namespace UI { int const textY = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 583; int const textX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 400; // one call per caption, merged but for the index (an index local: quick_diff 0.9464 -> 0.8468) - if ((int)DAT_SkirmishTrailRelated1::instance > 0) { + if (DAT_SkirmishTrailRelated1::instance > 0) { // "Skip Current Mission" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_TextInputDisplay.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_TextInputDisplay.cpp new file mode 100644 index 0000000000..2b762e5409 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_TextInputDisplay.cpp @@ -0,0 +1,126 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0047CCA0 + void General::MenuItemRenderFunction_General_TextInputDisplay(int field, ...) + { + // == TRUE: the original compares with 1 (a truthiness test: quick_diff 0.9664 -> 0.9365); field 3, the + // title box, is hidden while a title is set + if (field == 3 && DAT_GameCore::instance.isNameEntryActive == TRUE) { + return; + } + int const cursorX = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextWidthUntilCurrentCursor, DAT_UserTextHandlerState::ptr)(); + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(-1, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // the cursor at the typing position, then the text 6 pixels in from the corner + // the text in each case, merged but for the index (one call after the switch: quick_diff 0.9664 -> 0.9365) + switch (field) { + case 0: { + // fields 0 and 1 show the cursor only while their text is the one being typed + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_FIVE__NUMERIC_DOT) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_FIVE__NUMERIC_DOT); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + break; + } + case 1: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_SIX__NUMERIC_ONLY) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_SIX__NUMERIC_ONLY); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + break; + } + case 2: { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_SEVEN__NUMERIC_ONLY); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + break; + } + case 3: { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_ZERO); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + break; + } + case 4: { + // outside the main menu this field is drawn on the map's surface + if (DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_MAIN_MENU) { + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_ZERO); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + break; + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp new file mode 100644 index 0000000000..dbb8aa10ef --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp @@ -0,0 +1,85 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/ScrollingHandler.func.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" + +#include "OpenSHC/Globals/DAT_CurrentFramerate.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ScrollingHandler.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00434120 + void InGameMenu::MenuItemActionHandler_InGameMenu_Scrolling() + { + if (!MACRO_CALL(OpenSHC::UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + OpenSHC::UI::Enums::DEID_DEBUG_NUMBERS)) { + // element state -1000 updates the frame rate below without drawing the debug numbers + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::RenderDebugNumbersDisplayElement)(0, 0, -1000); + } + if (DAT_MouseState::instance.selectionBoxMode != 0) { + return; + } + if (DAT_MouseState::instance.rightClickState) { + return; + } + int scrollDistance = MACRO_CALL_MEMBER( + OpenSHC::UI::ScrollingHandler_Func::getScrollDistanceBaseUnk, DAT_ScrollingHandler::ptr)(); + if (scrollDistance == 0) { + return; + } + // below the game speed's frame rate the step grows by speed / ((speed + frame rate) / 2), making up for + // part of the slowdown + if (DAT_CurrentFramerate::instance < DAT_GameCore::instance.gameSpeedLevel + && DAT_CurrentFramerate::instance != 0) { + scrollDistance = DAT_GameCore::instance.gameSpeedLevel * scrollDistance + / ((DAT_GameCore::instance.gameSpeedLevel - DAT_CurrentFramerate::instance) / 2 + + DAT_CurrentFramerate::instance); + } + switch (DAT_ScrollingHandler::instance.scrollDirection_0x4) { + case OpenSHC::UI::SD_UP: + DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; + break; + case OpenSHC::UI::SD_UP_RIGHT: + DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; + // falls through to the step right + case OpenSHC::UI::SD_RIGHT: + DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance; + break; + case OpenSHC::UI::SD_DOWN_RIGHT: + DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; + DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance; + break; + case OpenSHC::UI::SD_DOWN: + DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; + break; + case OpenSHC::UI::SD_DOWN_LEFT: + DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; + DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance; + break; + case OpenSHC::UI::SD_UP_LEFT: + DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; + // falls through to the step left + case OpenSHC::UI::SD_LEFT: + DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance; + break; + } + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::setViewportBasedOnMapSize, + DAT_ViewportRenderState::ptr)(); + // tutorial action 1: the player scrolled the view + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(1); + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance.cpp new file mode 100644 index 0000000000..52ae78e4df --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance.cpp @@ -0,0 +1,57 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" + +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042A840 + void LobbyMenu::MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance(int button, ...) + { + if (DAT_00b960dc::instance != 0) { + return; + } + // only the host changes the game type and the balance + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + // button 4 draws the balance bar and button 20 the game type panel: clicking them changes nothing + if (button == 4 || button == 20) { + return; + } + // buttons 1 to 3 pick the game type + if (button >= 1 && button <= 3) { + DAT_GameSynchronyState::instance.skirmishGameIntensityType = button; + } + // the balance buttons start at 10 and set balance 1 from there, 3 (button 12) being even + if (button >= 10) { + DAT_GameSynchronyState::instance.skirmishCurrentAdvantageBalance = button - 9; + // 256 at either end, 255 one step from even, 254 at even + if (button == 10 || button == 14) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x100); + } + if (button == 11 || button == 13) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFF); + } + if (button == 12) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFE); + } + } + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + OpenSHC::Commands::GCT_CHANGE_GAME_INTENSITY_OR_BALANCE); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/RankingGames/MenuItemRenderFunction_RankingGames_Main.cpp b/src/OpenSHC/UI/MenuItems/RankingGames/MenuItemRenderFunction_RankingGames_Main.cpp new file mode 100644 index 0000000000..37699c3188 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/RankingGames/MenuItemRenderFunction_RankingGames_Main.cpp @@ -0,0 +1,88 @@ +#include "../RankingGames.func.hpp" + +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_00ed27a0.hpp" +#include "OpenSHC/Globals/DAT_00ed3124.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_MissionDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D99F0 + void RankingGames::MenuItemRenderFunction_RankingGames_Main(int button, ...) + { + // buttons -10 and -11 scroll the list up and down: pictures 85 and 81, the next one when hovered + if (button == -10 || button == -11) { + int picture = 81; + if (button == -10) { + picture = 85; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + ++picture; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, picture, DAT_ButtonX::instance, DAT_ButtonY::instance); + // a frame from one pixel above and left of the arrow to 20 pixels below and right of it + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance - 1, DAT_ButtonY::instance - 1, + DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 20, COL_VERY_SOFT_YELLOW::instance.shortValue); + return; + } + // buttons 0 to 7 are the rows, which draw nothing here + if (button < 8) { + return; + } + // the column headers are 20 to 31; any other button draws its own picture + if (button >= 20 && button <= 31) { + // button 20 clears the hovered header, and the hovered one stores itself + if (button == 20) { + DAT_00ed27a0::instance = 0; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_00ed27a0::instance = button; + } + // headers 20 to 29 sort by columns 1 to 10; 30 and 31 toggle DAT_00ed3124 to 1 and 2 and back to 0: the + // header in use draws the picture two after its own + if ((button < 30 && button - 19 == DAT_MissionDefinedData::instance.sortColumn) + || (button == 30 && DAT_00ed3124::instance == 1) || (button == 31 && DAT_00ed3124::instance == 2)) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + int const picture + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4 + + 2; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0, + picture, DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_CurrentButtonPictureInGm::instance = picture; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp new file mode 100644 index 0000000000..2c6229ca5f --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp @@ -0,0 +1,144 @@ +// disable deprecation warnings for strcpy and strcat +#pragma warning(disable : 4996) + +#include "../SinglePlayerMapChoice.func.hpp" + +#include "OpenSHC/IO/FilePackager.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/Text/FontSizeClass.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-macros.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_MapDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp" +#include "OpenSHC/Globals/DAT_SiegeInformationArray.hpp" +#include "OpenSHC/Globals/DAT_SiegeRemainingPoints.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/FilePackagerObj.hpp" +#include "OpenSHC/Globals/INT_00b95b74.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00442C30 + void SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_MapTable(int row, ...) + { + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row + >= DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber) { + return; + } + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = row; + DWORD const currentTime = timeGetTime(); + // a second click on the same map within 500 ms starts the game (button 65 of the map choice menu) + if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + == DAT_MenuTextInputState::instance.lastClickedListIndex + && (int)(currentTime - DAT_MenuTextInputState::instance.lastListClickTime) < 500) { + DAT_MouseState::instance.waitCursorToggle = 1; + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetCursorDependingOnProgramState)(); + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands)(65); + } + if (DAT_MouseState::instance.leftClickStart) { + DAT_MenuTextInputState::instance.lastClickedListIndex + = DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + DAT_MenuTextInputState::instance.lastListClickTime = currentTime; + } + char fileName[1008]; + strcpy(fileName, + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset])); + // ".map" + strcat(fileName, S__MAP_005A2294); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + OpenSHC::IO::FRT_MAPS, fileName); + MACRO_CALL_MEMBER(OpenSHC::IO::FilePackager_Func::readMapHeader, FilePackagerObj::ptr)(TRUE); + // the description's height and scroll position: mode 1 measures the text 413 pixels wide without drawing + INT_00b95b74::instance = 0; + DAT_00b960f4::instance = 0; + if (DAT_GameCore::instance.mapDescUseStringTable == 0) { + INT_00b95b74::instance = MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[19])( + DAT_GameCore::instance.mapDescription, 0, 0, 413, 0, 0, 1); + } else if (DAT_GameCore::instance.mapDescUseStringTableIndex != 0) { + INT_00b95b74::instance = MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[19])( + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, DAT_GameCore::instance.mapDescUseStringTableIndex), + 0, 0, 413, 0, 0, 1); + } + // map type 2 is siege (button 68) + if (DAT_MapMissionType::instance != 2) { + return; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::ClearSiegeInformationArray2)(); + // section 1059 holds the map's siege army + MACRO_CALL_MEMBER(OpenSHC::IO::FilePackager_Func::readMapHeaderSectionByID, FilePackagerObj::ptr)( + DAT_MapDefinedData::instance.MapSectionAddressArray, 1059); + // the siege army's 21 unit counts as one array (nested [7][3] searches: quick_diff 0.9807 -> 0.8696) + int* const siegeUnits = &DAT_SiegeInformationArray::instance[0][0]; + if (DAT_GameCore::instance.mapU4Int1_2 != 0) { + // an army with no units yet starts empty, with 2000 points + BOOLEnum hasUnits = FALSE; + for (int unit = 0; unit < 21; ++unit) { + if (siegeUnits[unit] > 0) { + hasUnits = TRUE; + break; + } + } + if (!hasUnits) { + for (int unit = 0; unit < 21; ++unit) { + siegeUnits[unit] = 0; + } + DAT_SiegeRemainingPoints::instance = 2000; + } + // advanced mode, player slot 2, difficulty 1 + DAT_SH1_SiegeAdvancedMode::instance = 1; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 2; + DAT_GameState::instance.mapAndTime.difficulty = 1; + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeUnitsComputation)(1); + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeRelatedCopying)(1); + return; + } + // an army with no units yet gets 70% of the map's own, with no points left + for (int unit = 0; unit < 21; ++unit) { + if (siegeUnits[unit] > 0) { + return; + } + } + // SEC_SiegeInformation (SiegeUnitCounts) is read as 20 ints + int const* const mapUnits = (int const*)&DAT_MapPropertiesState::instance.SEC_SiegeInformation; + for (int unit = 0; unit < 20; ++unit) { + siegeUnits[unit] = mapUnits[unit] * 7 / 10; + } + // slot 10 takes 70% of the tunnelers, over the loop's value + siegeUnits[10] = DAT_MapPropertiesState::instance.SEC_Section1067.tunnelersCount * 7 / 10; + DAT_SiegeRemainingPoints::instance = 0; + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeUnitsComputation)(1); + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeRelatedCopying)( + DAT_GameState::instance.mapAndTime.difficulty); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_Scrollbar.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_Scrollbar.cpp new file mode 100644 index 0000000000..db2d21ed8c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_Scrollbar.cpp @@ -0,0 +1,67 @@ +#include "../SinglePlayerMapChoice.func.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00442F40 + void SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_Scrollbar( + int unused, int scrollbarEvent, int* minValue, int* maxValue, int* currentValue) + { + switch (scrollbarEvent) { + case 1: + // the list shows 13 rows + *minValue = 0; + *maxValue = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 13; + *currentValue = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + return; + case 2: + case 3: + // unlike 5 and 6, the selected row is chosen again before the offset changes + if (*currentValue != DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset) { + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + } + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = *currentValue; + return; + case 4: + if (*currentValue != DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset) { + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + } + *currentValue = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + *maxValue = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 13; + return; + case 7: + // a click on the track pages by 12 of the 13 rows + *currentValue = 12; + return; + case 5: + 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); + } + *currentValue = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + return; + case 6: + 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); + } + *currentValue = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + return; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp b/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp new file mode 100644 index 0000000000..4e75fe37b9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp @@ -0,0 +1,134 @@ +#include "../TriggerInvasion.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BBF40 + void TriggerInvasion::MenuItemRenderFunction_TriggerInvasion_Main(int unitType, ...) + { + // the unit's picture in army_units.gm1, counted from 1 + int imageID = 0; + switch (unitType) { + case 0: + imageID = 1; + break; + case 1: + imageID = 2; + break; + case 2: + imageID = 3; + break; + case 3: + imageID = 4; + break; + case 4: + imageID = 5; + break; + case 5: + imageID = 6; + break; + case 6: + imageID = 7; + break; + case 7: + imageID = 8; + break; + case 8: + imageID = 9; + break; + case 9: + imageID = 12; + break; + case 10: + imageID = 13; + break; + case 11: + imageID = 15; + break; + case 12: + imageID = 14; + break; + case 13: + imageID = 16; + break; + case 14: + imageID = 11; + break; + case 15: + imageID = 10; + break; + case 16: + imageID = 17; + break; + case 17: + imageID = 18; + break; + case 18: + imageID = 19; + break; + case 19: + imageID = 20; + break; + case 20: + imageID = 21; + break; + case 21: + imageID = 22; + break; + case 22: + imageID = 23; + break; + case 23: + imageID = 24; + break; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const unitCount = DAT_MapPropertiesState::instance.invasionEventContent.unitCountsPerUnitType[unitType]; + if (unitCount != 0) { + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(unitCount, + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(unitCount, + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + } + // the unit's picture, its middle at y + 15 + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_ARMY_UNITS, imageID, DAT_ButtonX::instance, + DAT_ButtonY::instance + - DAT_GMImageHeaders::instance + .imh[GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_ARMY_UNITS] + imageID - 1] + .height + / 2 + + 15); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/WaitingForHost/MenuItemRenderFunction_WaitingForHost_Button.cpp b/src/OpenSHC/UI/MenuItems/WaitingForHost/MenuItemRenderFunction_WaitingForHost_Button.cpp new file mode 100644 index 0000000000..10d1fe75fc --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/WaitingForHost/MenuItemRenderFunction_WaitingForHost_Button.cpp @@ -0,0 +1,45 @@ +#include "../WaitingForHost.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0047E420 + void WaitingForHost::MenuItemRenderFunction_WaitingForHost_Button(int button, ...) + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // the label, centred 6 pixels below the button's top + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + // the same colour hovered or not, in two calls (one call: quick_diff 0.9375 -> 0.8136) + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, FALSE, 0); + return; + } + 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_MULTIPLAYER_CONNECTION, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6e036f9340..727cd9718e 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6937,7 +6937,7 @@ SHC_3BB0A8C1_0x0042A474 | 0.0% | Pending SHC_3BB0A8C1_0x0042A480 | 0.0% | Pending -SHC_3BB0A8C1_0x0042A840 | 0.0% | Pending +SHC_3BB0A8C1_0x0042A840 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042A8E0 | 0.0% | Pending @@ -11115,7 +11115,7 @@ SHC_3BB0A8C1_0x00433D00 | 0.0% | Pending SHC_3BB0A8C1_0x00433DA0 | 0.0% | Pending -SHC_3BB0A8C1_0x00434120 | 0.0% | Pending +SHC_3BB0A8C1_0x00434120 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004341E1 | 0.0% | Pending @@ -14135,13 +14135,13 @@ SHC_3BB0A8C1_0x00442C2C | 0.0% | Pending SHC_3BB0A8C1_0x00442C2D | 0.0% | Pending -SHC_3BB0A8C1_0x00442C30 | 0.0% | Pending +SHC_3BB0A8C1_0x00442C30 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00442E90 | 0.0% | Pending SHC_3BB0A8C1_0x00442EB0 | 0.0% | Pending -SHC_3BB0A8C1_0x00442F40 | 0.0% | Pending +SHC_3BB0A8C1_0x00442F40 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00443048 | 0.0% | Pending @@ -22281,7 +22281,7 @@ SHC_3BB0A8C1_0x0047CC8C | 0.0% | Pending SHC_3BB0A8C1_0x0047CC90 | 0.0% | Pending -SHC_3BB0A8C1_0x0047CCA0 | 0.0% | Pending +SHC_3BB0A8C1_0x0047CCA0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047CEC4 | 0.0% | Pending @@ -22365,7 +22365,7 @@ SHC_3BB0A8C1_0x0047E3A0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047E3E0 | 0.0% | Pending -SHC_3BB0A8C1_0x0047E420 | 0.0% | Pending +SHC_3BB0A8C1_0x0047E420 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047E490 | 100.0% | Reimplemented @@ -29831,7 +29831,7 @@ SHC_3BB0A8C1_0x004BBF30 | 0.0% | Pending SHC_3BB0A8C1_0x004BBF34 | 0.0% | Pending -SHC_3BB0A8C1_0x004BBF40 | 0.0% | Pending +SHC_3BB0A8C1_0x004BBF40 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BC0A8 | 0.0% | Pending @@ -36031,7 +36031,7 @@ SHC_3BB0A8C1_0x004D9700 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D9730 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D99F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D99F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D9B30 | 100.0% | Reimplemented