diff --git a/src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemActionHandler_AlliesOrder_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemActionHandler_AlliesOrder_Main.cpp new file mode 100644 index 0000000000..00c73d2d84 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemActionHandler_AlliesOrder_Main.cpp @@ -0,0 +1,60 @@ +#include "../AlliesOrder.func.hpp" + +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_EnemyArrayIndex.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_LastTeamMemberIndex.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_RequestedGoodsByWhoArray.hpp" +#include "OpenSHC/Globals/DAT_SomeTeamMemberPlayerIDArray.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B1410 + void AlliesOrder::MenuItemActionHandler_AlliesOrder_Main(int button, ...) + { + // -2 shows the allies dialog again + if (button == -2) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + return; + } + // buttons 1 to 6 name an enemy from the list BuildEnemyPlayerList made + if (button <= 6 && button - 1 >= DAT_EnemyArrayIndex::instance) { + return; + } + int const allyPlayerID = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[allyPlayerID] == -1 + && DAT_GameSynchronyState::instance.currentAIArray[allyPlayerID] == 0) { + return; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + if (button <= 6) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = DAT_RequestedGoodsByWhoArray::instance[button]; + } else { + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = 0; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = allyPlayerID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = button; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); + // 10 shows the allies dialog again after its order, the others close it + if (button == 10) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + } else { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp new file mode 100644 index 0000000000..301caac4df --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_EventSlider.cpp @@ -0,0 +1,98 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventType.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/COL_GREYISH_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BA3C0 + void General::MenuItemRenderFunction_General_EventSlider( + int slider, int thumbYPos, int value, int thumbHeight, BOOL isDragged) + { + switch (slider) { + case -2: + case -1: + // these two sliders belong to the events that have a duration + switch (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType) { + case OpenSHC::Game::ScenarioEvents::Enums::SET_TRAVELING_FAIR: + case OpenSHC::Game::ScenarioEvents::Enums::SET_PLAGUE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_WHEAT_DISEASE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_HOPS_WEEVIL: + case OpenSHC::Game::ScenarioEvents::Enums::SET_APPLE_BLIGHT: + case OpenSHC::Game::ScenarioEvents::Enums::SET_TREE_FUNGUS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_RABBIT_EXPLOSION: + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_ATTACK: + case OpenSHC::Game::ScenarioEvents::Enums::SET_BANDITS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_MAD_COWS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_ARCHERS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_THEFT_FROM_GRANARY: + case OpenSHC::Game::ScenarioEvents::Enums::SET_FIRE: + break; + default: + return; + } + break; + case 5: + case 12: + case 18: + case 19: + case 21: + // the other sliders belong to the event one below their number + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + != slider - 1) { + return; + } + break; + } + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(-1, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!isDragged) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + thumbYPos + 1, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + thumbYPos + thumbHeight - 2, + DAT_ButtonY::instance + DAT_ButtonH::instance - 4, COL_GREYISH_YELLOW::instance.shortValue); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + thumbYPos + 1, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + thumbYPos + thumbHeight - 2, + DAT_ButtonY::instance + DAT_ButtonH::instance - 4, COL_DARK_LIME::instance.shortValue); + } + if (slider == -2 && value == 10) { + // "-" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + DAT_TextManagerObject::ptr)(s___005a2280, DAT_ButtonX::instance + DAT_ButtonW::instance + 12, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, + FALSE, 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(value, + DAT_ButtonX::instance + DAT_ButtonW::instance + 12, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE, 0); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp new file mode 100644 index 0000000000..589b9cb1df --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets.cpp @@ -0,0 +1,47 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00438B60 + void InGameMenu::MenuItemActionHandler_InGameMenu_RightClickMenuAndMaybeResets(int unused, ...) + { + DAT_MouseState::instance.mouseBasedEvent = 0; + if (!DAT_ViewportRenderState::instance.viewportState.field_0x0) { + return; + } + if (!DAT_MouseState::instance.rightClickStart + || (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU + && (DAT_GameCore::instance.activeMenuTab.tabType + == OpenSHC::UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM + || DAT_GameCore::instance.activeMenuTab.tabType + == OpenSHC::UI::Enums::BASMTT_SIEGETENT_SHIELD))) { + if (DAT_MouseState::instance.rightClickState && DAT_MouseState::instance.previewEnabled) { + MACRO_CALL_MEMBER( + OpenSHC::Input::MouseState_Func::updateRightDragCameraControl, DAT_MouseState::ptr)(); + return; + } + } else if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_NULL) { + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); + DAT_MouseState::instance.previewEnabled = 1; + DAT_GameSynchronyState::instance.editorPlacementPlayerID = 1; + return; + } + DAT_MouseState::instance.previewEnabled = 0; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp b/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp new file mode 100644 index 0000000000..ff8a3e5882 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemRenderFunction_MissionEndscreen_Main.cpp @@ -0,0 +1,112 @@ +#include "../MissionEndscreen.func.hpp" + +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/ButtonGmData.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" + +#include "OpenSHC/Globals/CHAR_00eb0e44.hpp" +#include "OpenSHC/Globals/DAT_00eb9af8.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_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_FinalResultsOrderByColumn.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/INT_00ec082c.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D6D20 + void MissionEndscreen::MenuItemRenderFunction_MissionEndscreen_Main(int buttonID, ...) + { + DAT_ButtonUnknownZero::instance = TRUE; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) { + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + if (CHAR_00eb0e44::instance != 0 && (buttonID == -100 || buttonID == -101)) { + return; + } + if (buttonID == -2) { + return; + } + // tabs -100 and -101: the selected one (0 or 2 for -100, 1 or 3 for -101) is drawn pressed + if ((buttonID == -100 && (INT_00ec082c::instance == 0 || INT_00ec082c::instance == 2)) + || (buttonID == -101 && (INT_00ec082c::instance == 1 || INT_00ec082c::instance == 3))) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + 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::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0, + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, + &DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance])( + FALSE) + + 2, + DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (buttonID >= 0 && buttonID <= 15) { + // the results table's column headers: the one the table is sorted by is drawn pressed + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_00eb9af8::instance = buttonID; + } + if (buttonID == DAT_FinalResultsOrderByColumn::instance) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_FinalResultsOrderByColumn::instance < 13) { + 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, + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, + &DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance])(TRUE) + + 14, + DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + 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, + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, + &DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance])(TRUE) + + 1, + DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + } + if (DAT_ButtonCurrentlyInteracting::instance) { + switch (buttonID) { + case -10: + DAT_00eb9af8::instance = 17; + break; + case -1: + DAT_00eb9af8::instance = 16; + break; + } + } + MACRO_CALL(General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp new file mode 100644 index 0000000000..378da24b63 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/OverlaySlider/MenuItemRenderFunction_OverlaySlider_Slider.cpp @@ -0,0 +1,69 @@ +#include "../OverlaySlider.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/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/COL_GREYISH_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004AA800 + void OverlaySlider::MenuItemRenderFunction_OverlaySlider_Slider( + int slider, int thumbYPos, int value, int thumbHeight, BOOL isDragged) + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonX::instance + DAT_ButtonW::instance, DAT_ButtonY::instance + DAT_ButtonH::instance, 12); + // the slider's title, drawn under the thumb + if (DAT_MenuModalComposition2::instance.textGroup >= 0) { + // the title's position in locals, y first, as the original reads it + int const textY = DAT_ButtonY::instance + 4; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::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::eTextSections)DAT_MenuModalComposition2::instance.textGroup, + DAT_MenuModalComposition2::instance.textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); + } + if (!isDragged) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + thumbYPos, DAT_ButtonY::instance, + DAT_ButtonX::instance + thumbYPos + thumbHeight, DAT_ButtonY::instance + DAT_ButtonH::instance, + COL_GREYISH_YELLOW::instance.shortValue); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + thumbYPos, DAT_ButtonY::instance, + DAT_ButtonX::instance + thumbYPos + thumbHeight, DAT_ButtonY::instance + DAT_ButtonH::instance, + COL_DARK_LIME::instance.shortValue); + } + // a thumb as wide as the slider covers the title, so it is drawn again over it + if (thumbHeight == DAT_ButtonW::instance && DAT_MenuModalComposition2::instance.textGroup >= 0) { + // the title's position in locals, y first, as the original reads it + int const textY = DAT_ButtonY::instance + 4; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::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::eTextSections)DAT_MenuModalComposition2::instance.textGroup, + DAT_MenuModalComposition2::instance.textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp b/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp new file mode 100644 index 0000000000..31f9083cec --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TacticalPowerBar/MenuItemRenderFunction_TacticalPowerBar_Main.cpp @@ -0,0 +1,97 @@ +#include "../TacticalPowerBar.func.hpp" + +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_ButtonBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TacticalPowersHelpTextDisplayBool.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D9EC0 + void TacticalPowerBar::MenuItemRenderFunction_TacticalPowerBar_Main(int slot, ...) + { + // y, then x, into locals; the icon calls re-read the globals, as the original does + int const buttonY = DAT_ButtonY::instance; + int const buttonX = DAT_ButtonX::instance; + int const level + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .tacticalPowersBarLevel; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + buttonX + 20, buttonY + 10, buttonX + 30, buttonY + 10, COL_VERY_SOFT_YELLOW::instance.shortValue); + // the bar's ten slots show the powers' icons in this order + int icon = slot; + switch (slot) { + case 0: + icon = 5; + break; + case 1: + icon = 6; + break; + case 2: + icon = 1; + break; + case 3: + icon = 3; + break; + case 5: + icon = 7; + break; + case 6: + icon = 2; + break; + case 7: + icon = 4; + break; + case 4: + case 8: + case 9: + icon = 0; + break; + } + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY + || DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + || DAT_GameState::instance.mapAndTime.skirmishNoRushTicks == 0) { + // each slot fills over 636 points of the bar + if (level >= (slot + 1) * 636) { + if (!DAT_GameCore::instance.tacticalPowersDisplayFlag) { + DAT_TacticalPowersHelpTextDisplayBool::instance = true; + DAT_GameCore::instance.tacticalPowersDisplayFlag = 1; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, icon + 289, + DAT_ButtonX::instance, DAT_ButtonY::instance, DAT_ButtonBlendStrength::instance); + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 297, + DAT_ButtonX::instance, DAT_ButtonY::instance, DAT_ButtonBlendStrength::instance); + } + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, icon + 298, + DAT_ButtonX::instance, DAT_ButtonY::instance, DAT_ButtonBlendStrength::instance); + } else { + // during the no-rush time of a multiplayer game the icons are dimmed further + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, icon + 298, + DAT_ButtonX::instance, DAT_ButtonY::instance, 32 - (32 - DAT_ButtonBlendStrength::instance) / 2); + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp new file mode 100644 index 0000000000..15c5151399 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_Scrollbar.cpp @@ -0,0 +1,85 @@ +#include "../TextEditor.func.hpp" + +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0045EDF0 + void TextEditor::MenuItemActionHandler_TextEditor_Scrollbar( + int unused, int scrollbarEvent, int* minValue, int* maxValue, int* currentValue) + { + // the arrows scroll a twentieth of the text, at least one line + int const step = max(max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0) + / 20, + 1); + switch (scrollbarEvent) { + case 1: + *minValue = 0; + *maxValue = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); + // clamped again after max, as the original does + if (*maxValue < 0) { + *maxValue = 0; + } + *currentValue = DAT_TextEditorState::instance.helpContentScrollOffsetY; + return; + case 2: + case 3: + DAT_TextEditorState::instance.helpContentScrollOffsetY = *currentValue; + return; + case 4: + *currentValue = DAT_TextEditorState::instance.helpContentScrollOffsetY; + *maxValue = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); + return; + case 7: + *currentValue = DAT_TextEditorState::instance.dialogContentHeight - 20; + return; + case 5: { + // one step up + int offset = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (offset >= step) { + offset -= step; + } else { + offset = 0; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = offset; + *currentValue = offset; + return; + } + case 6: { + // one step down + int offset = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (offset < max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0) + - step) { + offset += step; + if (offset > max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0)) { + offset = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); + } + } else { + offset = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = offset; + *currentValue = offset; + return; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 507eed8917..e9a3bc67b4 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -12941,7 +12941,7 @@ SHC_3BB0A8C1_0x004387CF | 0.0% | Pending SHC_3BB0A8C1_0x004387D0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00438B60 | 0.0% | Pending +SHC_3BB0A8C1_0x00438B60 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00438BE0 | 0.0% | Pending @@ -18691,7 +18691,7 @@ SHC_3BB0A8C1_0x0045EDEA | 0.0% | Pending SHC_3BB0A8C1_0x0045EDEB | 0.0% | Pending -SHC_3BB0A8C1_0x0045EDF0 | 0.0% | Pending +SHC_3BB0A8C1_0x0045EDF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0045EF6C | 0.0% | Pending @@ -25513,7 +25513,7 @@ SHC_3BB0A8C1_0x004AA7EC | 0.0% | Pending SHC_3BB0A8C1_0x004AA7F0 | 0.0% | Pending -SHC_3BB0A8C1_0x004AA800 | 0.0% | Pending +SHC_3BB0A8C1_0x004AA800 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AA930 | 0.0% | Pending @@ -25975,7 +25975,7 @@ SHC_3BB0A8C1_0x004B11A0 | 0.0% | Pending SHC_3BB0A8C1_0x004B12D0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B1410 | 0.0% | Pending +SHC_3BB0A8C1_0x004B1410 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B1471 | 0.0% | Pending @@ -28967,7 +28967,7 @@ SHC_3BB0A8C1_0x004BA3B0 | 0.0% | Pending SHC_3BB0A8C1_0x004BA3B4 | 0.0% | Pending -SHC_3BB0A8C1_0x004BA3C0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BA3C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BA514 | 0.0% | Pending @@ -35831,7 +35831,7 @@ SHC_3BB0A8C1_0x004D6D13 | 0.0% | Pending SHC_3BB0A8C1_0x004D6D14 | 0.0% | Pending -SHC_3BB0A8C1_0x004D6D20 | 0.0% | Pending +SHC_3BB0A8C1_0x004D6D20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D6EF0 | 100.0% | Reimplemented @@ -36059,7 +36059,7 @@ SHC_3BB0A8C1_0x004D9D90 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D9DB0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D9EC0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D9EC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004DA024 | 0.0% | Pending