diff --git a/src/OpenSHC/UI/HoveredState/calculateHoveredTile.cpp b/src/OpenSHC/UI/HoveredState/calculateHoveredTile.cpp new file mode 100644 index 0000000000..d2f2251753 --- /dev/null +++ b/src/OpenSHC/UI/HoveredState/calculateHoveredTile.cpp @@ -0,0 +1,150 @@ +#include "../HoveredState.func.hpp" + +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x005119D0 + void HoveredState::calculateHoveredTile() + { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { + return; + } + // kept across the loop, as in the original (declared at first use: quick_diff 0.9690 -> 0.6590) + int imageID = 0; + int flagX = 0; + int flagY = 0; + int const rotation = DAT_TileMapState::instance.uiBuildingRotation; + for (int i = 0; i < countof(this->elements); ++i) { + if (this->elements[i].type == Commands::M_MAPPER_NULL) { + continue; + } + switch (this->elements[i].type) { + case Commands::M_MAPPER_MANGONEL: + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::createFloatingLayerElement, + DAT_ViewportRenderState::ptr)(IO::Graphics::GID_BODY_MANGONEL, 1, 0, 0, + DAT_ViewportRenderState::instance.translationMatrix[this->elements[i].y].addXgetTile + + this->elements[i].x, + 5); + break; + case Commands::M_MAPPER_BALLISTA: + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::createFloatingLayerElement, + DAT_ViewportRenderState::ptr)(IO::Graphics::GID_BODY_BALLISTA, 1, 0, 0, + DAT_ViewportRenderState::instance.translationMatrix[this->elements[i].y].addXgetTile + + this->elements[i].x, + 5); + break; + case Commands::M_MAPPER_BRAZIER: + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::createFloatingLayerElement, + DAT_ViewportRenderState::ptr)(IO::Graphics::GID_BODY_BRAZIER, 1, 15, 7, + DAT_ViewportRenderState::instance.translationMatrix[this->elements[i].y].addXgetTile + + this->elements[i].x, + 29); + break; + case Commands::M_MAPPER_FLAG_TYPE0: + case Commands::M_MAPPER_FLAG_TYPE1: + case Commands::M_MAPPER_FLAG_TYPE2: + case Commands::M_MAPPER_FLAG_TYPE3: { + int const tile = DAT_ViewportRenderState::instance.translationMatrix[this->elements[i].y].addXgetTile + + this->elements[i].x; + switch (this->elements[i].type) { + case Commands::M_MAPPER_FLAG_TYPE0: + imageID = 9; + flagX = 15; + flagY = 7; + break; + case Commands::M_MAPPER_FLAG_TYPE1: + imageID = 41; + flagX = 15; + flagY = -2; + break; + case Commands::M_MAPPER_FLAG_TYPE2: + imageID = 73; + flagX = 6; + flagY = 6; + break; + case Commands::M_MAPPER_FLAG_TYPE3: + imageID = 105; + flagX = 6; + flagY = 7; + break; + } + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::createFloatingLayerElement, + DAT_ViewportRenderState::ptr)(IO::Graphics::GID_ANIM_FLAGS, imageID, flagX, flagY, tile, 13); + break; + } + case Commands::M_MAPPER_HEADS: + imageID = this->elements[i].size + 1; + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::createFloatingLayerElement, + DAT_ViewportRenderState::ptr)(IO::Graphics::GID_ANIM_HEADS, imageID, 15, 7, + DAT_ViewportRenderState::instance.translationMatrix[this->elements[i].y].addXgetTile + + this->elements[i].x, + 29); + break; + case Commands::M_MAPPER_CATAPULT: + case Commands::M_MAPPER_TREBUCHET: + case Commands::M_MAPPER_SIEGE_TOWER: + case Commands::M_MAPPER_BATTERING_RAM: + case Commands::M_MAPPER_PORTABLE_SHIELD: + case Commands::M_MAPPER_ARAB_BALLISTA: { + // siege equipment shows its tent on the tile in front, by the map's orientation + int x = this->elements[i].x; + int y = this->elements[i].y; + int imageX = 0; + int imageY = 0; + switch (DAT_TileMapState::instance.mapOrientation) { + case 0: + ++x; + imageX = 13; + ++y; + imageY = 2; + break; + case 4: + --x; + imageX = 13; + imageY = -30; + --y; + break; + case 2: + --x; + imageX = 45; + ++y; + imageY = -14; + break; + case 6: + ++x; + imageX = -19; + imageY = -12; + --y; + break; + } + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::createFloatingLayerElement, + DAT_ViewportRenderState::ptr)(IO::Graphics::GID_BODY_TENT, 1, imageX, imageY, + DAT_ViewportRenderState::instance.translationMatrix[y].addXgetTile + x, 5); + break; + } + default: + // any other mapper is a building placement preview, in the element's rotation + DAT_TileMapState::instance.skipPlacementFailChecks = 1; + DAT_TileMapState::instance.uiBuildingRotation = this->elements[i].rotationOrExtraInfo; + // the type goes as a word (movzx), though the header's parameter is a MappersEnum + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setConstructionGFXLayerBasedOnPlacementChecks, + DAT_TileMapState::ptr)(this->elements[i].x, this->elements[i].y, + (Commands::MappersEnum)(ushort)this->elements[i].type, this->elements[i].size); + break; + } + } + DAT_TileMapState::instance.uiBuildingRotation = rotation; + } + +} +} diff --git a/src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemRenderFunction_AlliesOrder_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemRenderFunction_AlliesOrder_Main.cpp new file mode 100644 index 0000000000..72ba4ee430 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/AlliesOrder/MenuItemRenderFunction_AlliesOrder_Main.cpp @@ -0,0 +1,154 @@ +#include "../AlliesOrder.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_00df51f8.hpp" +#include "OpenSHC/Globals/DAT_00df51fc.hpp" +#include "OpenSHC/Globals/DAT_00df5200.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_EnemyArrayIndex.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_RequestedGoodsByWhoArray.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004AD480 + void AlliesOrder::MenuItemRenderFunction_AlliesOrder_Main(int button, ...) + { + if (button == -2) { + MACRO_CALL( + OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); + return; + } + if (button >= 10) { + // the dialog's other buttons; hovered, 10 and 11 set the tooltip + if (button == 10) { + DAT_00df5200::instance = 0; + } + MACRO_CALL( + OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); + if (DAT_ButtonCurrentlyInteracting::instance) { + if (button == 10) { + // "Clear Orders" + DAT_00df5200::instance = OpenSHC::DE::SHCDE::TEXT_ALLIES; + DAT_00df51fc::instance = 8; + return; + } + if (button == 11) { + // "Defend Me" + DAT_00df5200::instance = OpenSHC::DE::SHCDE::TEXT_ALLIES; + DAT_00df51fc::instance = 9; + return; + } + } + } + // buttons 1 to 6 are the enemies' portraits; button turns into the row, then the player (one register) + if (button <= 6 && button != -1) { + --button; + if (button >= DAT_EnemyArrayIndex::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonX::instance + 71, DAT_ButtonY::instance + 71, COL_BLACK::instance.shortValue); + } else { + button = DAT_RequestedGoodsByWhoArray::instance[button + 1]; + int ai = 0; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[button] == -1) { + ai = DAT_GameSynchronyState::instance.currentAIArray[button]; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, button + 546, + DAT_ButtonX::instance, DAT_ButtonY::instance); + if (ai == 0) { + // a human: the lord's icon, or the own face + if (DAT_GameCore::instance.lordIcons[button] == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 539, + DAT_ButtonX::instance, DAT_ButtonY::instance); + } else if (DAT_GameCore::instance.lordIcons[button] == 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 540, + DAT_ButtonX::instance, DAT_ButtonY::instance); + } else if (DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[button + 19] > 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 541, + DAT_ButtonX::instance, DAT_ButtonY::instance); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFace, + DAT_TextureRenderCoreObject::ptr)( + button + 19, DAT_ButtonX::instance + 4, DAT_ButtonY::instance + 4); + } + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, ai + 522, + DAT_ButtonX::instance, DAT_ButtonY::instance); + } + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 514, + DAT_ButtonX::instance - 6, DAT_ButtonY::instance - 6, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 513, 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 574, + DAT_ButtonX::instance - 10, DAT_ButtonY::instance - 8, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 575, 0); + // "Attack" + DAT_00df5200::instance = OpenSHC::DE::SHCDE::TEXT_ALLIES; + DAT_00df51fc::instance = 10; + DAT_00df51f8::instance = button; + } + } + } + if (button != -1) { + return; + } + // -1 draws the tooltip set by the hovered button, for a portrait with the player's name + if (DAT_00df5200::instance == 0) { + return; + } + int const x = DAT_ButtonX::instance; + int const y = DAT_ButtonY::instance; + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + (OpenSHC::DE::SHCDE::eTextSections)DAT_00df5200::instance, DAT_00df51fc::instance), + x, y, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + if (DAT_00df51fc::instance == 10) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[DAT_00df51f8::instance] != -1) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.DAT_PlayerNames[DAT_00df51f8::instance], x + 5, y, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, TRUE, 0); + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + return; + } + // the AI's name + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + DAT_GameSynchronyState::instance.currentAIArray[DAT_00df51f8::instance] * 8 + + DAT_GameSynchronyState::instance.aiVariationArray[DAT_00df51f8::instance] + 103, + x + 5, y, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, TRUE); + } + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroops.cpp b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroops.cpp new file mode 100644 index 0000000000..817c768cf0 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroops.cpp @@ -0,0 +1,122 @@ +#include "../BuildMenu.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/Map/Units/Selection/UnitSelectionEnum.hpp" +#include "OpenSHC/Map/Units/Selection/UnitSelectionEnumInt.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace BuildMenu { + + // FUNCTION: STRONGHOLDCRUSADER 0x00439160 + void MenuItemRenderFunction_BuildMenu_CurrentlySelectedTroops(int slotID, ...) + { + if (DAT_UnitsState::instance.nHasOwnedUnitInSelection == 0) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + Map::Units::Selection::UnitSelectionEnumInt const troopType + = DAT_UnitsState::instance.selectionSlots[slotID]; + DAT_ButtonUnknownZero::instance = FALSE; + if (troopType == -1) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + return; + } + // The count goes under the button where it was before the portrait is moved into place. + int const buttonY = DAT_ButtonY::instance; + int const buttonX = DAT_ButtonX::instance; + // Each troop its own case (shared labels and fall-throughs: quick_diff 0.9457 -> 0.7640) + switch (troopType) { + case Map::Units::Selection::USE_E_ARCHERS: + DAT_ButtonY::instance -= 14; + break; + case Map::Units::Selection::USE_E_SPEARMEN: + DAT_ButtonX::instance -= 3; + break; + case Map::Units::Selection::USE_E_MACEMEN: + DAT_ButtonX::instance += 1; + break; + case Map::Units::Selection::USE_E_PIKEMEN: + DAT_ButtonX::instance += 2; + DAT_ButtonY::instance -= 20; + break; + case Map::Units::Selection::USE_E_SWORDSMEN: + DAT_ButtonX::instance += 1; + DAT_ButtonY::instance -= 8; + break; + case Map::Units::Selection::USE_E_KNIGHTS: + DAT_ButtonY::instance -= 20; + DAT_ButtonX::instance -= 7; + break; + case Map::Units::Selection::USE_E_ENGINEERS: + DAT_ButtonX::instance += 1; + break; + case Map::Units::Selection::USE_E_LADDERMEN: + DAT_ButtonY::instance -= 8; + break; + case Map::Units::Selection::USE_E_TUNNELERS: + DAT_ButtonY::instance -= 19; + break; + case Map::Units::Selection::USE_E_BALLISTAS: + DAT_ButtonY::instance -= 4; + break; + case Map::Units::Selection::USE_A_ARAB_ARCHERS: + DAT_ButtonY::instance -= 8; + DAT_ButtonX::instance += 2; + break; + case Map::Units::Selection::USE_A_SLAVES: + DAT_ButtonY::instance -= 9; + DAT_ButtonX::instance += 1; + break; + case Map::Units::Selection::USE_A_SLINGERS: + DAT_ButtonY::instance -= 7; + break; + case Map::Units::Selection::USE_A_ASSASSINS: + DAT_ButtonY::instance -= 1; + break; + case Map::Units::Selection::USE_A_HORSE_ARCHERS: + DAT_ButtonY::instance -= 13; + DAT_ButtonX::instance -= 6; + break; + case Map::Units::Selection::USE_A_SWORDSMEN: + DAT_ButtonY::instance -= 9; + DAT_ButtonX::instance += 1; + break; + case Map::Units::Selection::USE_A_FIRETHROWERS: + DAT_ButtonX::instance += 1; + break; + case Map::Units::Selection::USE_A_FIRE_BALLISTAS: + DAT_ButtonX::instance -= 6; + break; + } + // The Arabian troops' portraits are a second set further along the button table. + if (troopType >= Map::Units::Selection::USE_A_ARAB_ARCHERS) { + DAT_CurrentButtonGmDataIndex::instance = troopType + 521; + } else { + DAT_CurrentButtonGmDataIndex::instance = troopType + 380; + } + MACRO_CALL(General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_UnitsState::instance.selectionUnitType[troopType], DAT_ButtonW::instance / 2 + buttonX, + buttonY + 83, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_FFFFFF, 0, 17, FALSE, 0); + } + + } + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_RepairBuildingButton.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_RepairBuildingButton.cpp new file mode 100644 index 0000000000..f67d4a2533 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_RepairBuildingButton.cpp @@ -0,0 +1,97 @@ +#include "../BuildingAndStatusMenu.func.hpp" + +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Map/Navigation/PathFindingState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace BuildingAndStatusMenu { + + using WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00466320 + void MenuItemRenderFunction_BuildingAndStatusMenu_RepairBuildingButton(int unused, ...) + { + int const buildingID = DAT_BuildingsState::instance.menuSelectedBuildingID; + BOOLEnum notDamaged = FALSE; + DAT_ButtonUnknownZero::instance = FALSE; + if (DAT_BuildingsState::instance.buildings[buildingID].owner + != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonUnknownZero::instance = TRUE; + } + if (!MACRO_CALL_MEMBER(Map::Buildings::BuildingsState_Func::updateRepairCostAndReturnIfDamaged, + DAT_BuildingsState::ptr)(buildingID)) { + notDamaged = TRUE; + } + // The button is live when there is damage to repair and no enemy is within 30 (15 in a multiplayer + // game). + int requiredDistance; + if (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY) { + requiredDistance = 15; + } else { + requiredDistance = 30; + } + // The flag is tested twice (one if/else holding the texts: quick_diff 0.9481 -> 0.6994) + BOOLEnum const disabled + = MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func::isEnemyTooCloseUnk, + DAT_PathFindingState::ptr)(DAT_BuildingsState::instance.buildings[buildingID].owner, + DAT_BuildingsState::instance.buildings[buildingID].x, + DAT_BuildingsState::instance.buildings[buildingID].y, requiredDistance) + || notDamaged; + if (disabled) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(8, OpenSHC::Rendering::Enums::RT_SCREEN_MENU); + } else { + MACRO_CALL_MEMBER(Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_SCREEN_MENU); + } + // "Repair"; the position in each arm (once before them: quick_diff 0.9481 -> 0.6623) + if (disabled) { + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 7; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, 257), + textX, textY, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_7CAAAF, 18, FALSE, 0); + } else if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 7; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, 257), + textX, textY, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 7; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, 257), + textX, textY, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + } + + } + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_StartDate.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_StartDate.cpp new file mode 100644 index 0000000000..523061f37a --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_StartDate.cpp @@ -0,0 +1,63 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.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 { + namespace EditScenario { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BAC90 + void MenuItemRenderFunction_EditScenario_StartDate(int button, ...) + { + switch (button) { + case -5: { + // "Start Date"; y read before x as in the original (x first: quick_diff 0.9306 -> 0.8750) + int const labelY = DAT_ButtonY::instance + 6; + int const labelX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_SCENARIO, 39), + labelX, labelY, Text::TTA_CENTER, Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + break; + } + case -1: { + // "Name" + int const labelY = DAT_ButtonY::instance + 6; + int const labelX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_SCENARIO, 32), + labelX, labelY, Text::TTA_CENTER, Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + break; + } + case 0: + break; + default: + // any other button shows its own scenario text, centred unless the button has no width + if (DAT_ButtonW::instance == 0) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + DE::SHCDE::TEXT_SCENARIO, button, DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + Text::TTA_LEFT, Rendering::Colors::COL_CCFAFF, 18, FALSE); + } else { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + DE::SHCDE::TEXT_SCENARIO, button, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, Text::TTA_CENTER, Rendering::Colors::COL_CCFAFF, 18, FALSE); + } + // the two calls share their tail only with this break (without it: quick_diff 0.9306 -> 0.8784) + break; + } + } + + } + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ViewToKeeps.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ViewToKeeps.cpp new file mode 100644 index 0000000000..d5c3499467 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ViewToKeeps.cpp @@ -0,0 +1,97 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/Game/Player/Enums/BuildingEntryInfoEnum.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.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_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DWORD_00b98410.hpp" +#include "OpenSHC/Globals/INT_00b9840c.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004335A0 + void InGameMenu::MenuItemActionHandler_InGameMenu_ViewToKeeps(int unused, ...) + { + if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { + return; + } + // two wheel steps within a second count as one move: down views the next keep, up the own keep + DWORD const now = timeGetTime(); + if (now - DWORD_00b98410::instance > 1000) { + DWORD_00b98410::instance = now; + INT_00b9840c::instance = 0; + } + if (DAT_MouseState::instance.scrollEventData == 7) { + if (INT_00b9840c::instance < 0) { + INT_00b9840c::instance = 0; + } + ++INT_00b9840c::instance; + if (INT_00b9840c::instance == 2) { + DWORD_00b98410::instance = now; + INT_00b9840c::instance = 0; + // the keep after the one viewed last, counting the map's keeps from 1 + int keepNumber = 1; + int tileIndex = -1; + for (int i = 0; i < countof(DAT_GameState::instance.mapAndTime.playerKeepTile); ++i) { + if (DAT_GameState::instance.mapAndTime.playerKeepTile[i] > -1) { + if (keepNumber == DAT_GameCore::instance.viewedKeepIndex) { + tileIndex = i; + } + ++keepNumber; + } + } + if (tileIndex == -1) { + int const keep = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .id; + if (keep != 0) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[keep].x + 2, + DAT_BuildingsState::instance.buildings[keep].y + 2); + } + } else { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnTile, + DAT_ViewportRenderState::ptr)(DAT_GameState::instance.mapAndTime.playerKeepTile[tileIndex]); + } + ++DAT_GameCore::instance.viewedKeepIndex; + if (DAT_GameCore::instance.viewedKeepIndex >= keepNumber) { + DAT_GameCore::instance.viewedKeepIndex = 0; + } + } + } + if (DAT_MouseState::instance.scrollEventData != 8) { + return; + } + if (INT_00b9840c::instance > 0) { + INT_00b9840c::instance = 0; + } + --INT_00b9840c::instance; + if (INT_00b9840c::instance != -2) { + return; + } + DWORD_00b98410::instance = now; + int const keep + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .id; + INT_00b9840c::instance = 0; + if (keep != 0) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::focusOnCoordinate, + DAT_ViewportRenderState::ptr)(DAT_BuildingsState::instance.buildings[keep].x + 2, + DAT_BuildingsState::instance.buildings[keep].y + 2); + } + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemActionHandler_NewMapMapsize_Buttons.cpp b/src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemActionHandler_NewMapMapsize_Buttons.cpp new file mode 100644 index 0000000000..9db6c1176f --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemActionHandler_NewMapMapsize_Buttons.cpp @@ -0,0 +1,102 @@ +#include "../NewMapMapsize.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Map/Navigation/PathFindingState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Map/WildlifeState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/UI/MinimapViewState.func.hpp" +#include "OpenSHC/Map/MapConstants.hpp" +#include "OpenSHC/Map/MapLockState.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WildlifeState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042F940 + void NewMapMapsize::MenuItemActionHandler_NewMapMapsize_Buttons(int button, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { + return; + } + // buttons 1 to 4 make a map of that size (set after the returns: quick_diff 0.9704 -> 0.9586) + int mapSize = OpenSHC::Map::MC_MAP_SIZE_400; + if (button <= 0) { + return; + } + if (button > 4) { + if (button == 7) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS, 0); + } + return; + } + if (button == 1) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_160; + } else if (button == 2) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_200; + } else if (button == 3) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_300; + } + DAT_TileMapState::instance.mapSize = mapSize; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::resetHeightAndMapBorders, DAT_TileMapState::ptr)( + mapSize); + DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; + MACRO_CALL_MEMBER( + OpenSHC::Map::Navigation::PathFindingState_Func::updatePathLinkageLayerForEachBuildingAtEachTile, + DAT_PathFindingState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::Navigation::PathFindingState_Func::updateSeparateAreaTileMap, + DAT_PathFindingState::ptr)(1); + MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::updatePathLinkageLayerForAllBuildings, + DAT_BuildingsState::ptr)(); + DAT_TileMapState::instance.forceUpdateMacroLayerFlag = 1; + DAT_TileMapState::instance.field_0x55487c = 200; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::forceFullTileMapRedraw, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::processGameTick, DAT_GameState::ptr)(); + for (int row = 0; row < 40; ++row) { + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateWildlifeGrid, DAT_WildlifeState::ptr)(row); + } + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateWildlife, DAT_WildlifeState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateSection1034Info, DAT_WildlifeState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateNofFpoints, DAT_WildlifeState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::UI::MinimapViewState_Func::setTileColorsDependingOnMapSize, DAT_MinimapViewState::ptr)(0, 100); + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::setMapPropertyDependingOnMapSize, + DAT_MinimapViewState::ptr)(0, 100); + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::setViewportBasedOnMapSize, + DAT_ViewportRenderState::ptr)(); + DAT_GameCore::instance.descriptionUseStringTable = FALSE; + DAT_GameCore::instance.U3_mapLockedState = OpenSHC::Map::MLS_EDITABLE; + DAT_GameCore::instance.temporaryTextBufferOfSize1000[0] = '\0'; + // both arms the same; the original still compares (one call: quick_diff 0.9704 -> 0.7636) + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 1) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); + } + DAT_GameCore::instance.mapLoadedForEditor = TRUE; + } + + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/SoundOptions/MenuItemActionHandler_SoundOptions_VolumeSlider.cpp b/src/OpenSHC/UI/MenuItems/SoundOptions/MenuItemActionHandler_SoundOptions_VolumeSlider.cpp new file mode 100644 index 0000000000..4a28b3de00 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SoundOptions/MenuItemActionHandler_SoundOptions_VolumeSlider.cpp @@ -0,0 +1,86 @@ +#include "../SoundOptions.func.hpp" + +#include "OpenSHC/Audio/mss/SoundSystem.func.hpp" + +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + namespace SoundOptions { + + // FUNCTION: STRONGHOLDCRUSADER 0x00492890 + void MenuItemActionHandler_SoundOptions_VolumeSlider( + int slider, int scrollbarEvent, int* minValue, int* maxValue, int* currentValue) + { + switch (scrollbarEvent) { + case 1: + // the slider's range, then its stored volume + *minValue = 0; + *maxValue = 100; + switch (slider) { + case 0: + *currentValue = DAT_MenuTextInputState::instance.pendingStreamVolume0; + break; + case 1: + *currentValue = DAT_MenuTextInputState::instance.pendingStreamVolume1; + break; + case 2: + *currentValue = DAT_MenuTextInputState::instance.pendingStreamVolume3; + break; + } + return; + case 2: + case 3: + // A new volume goes to the slider's sound channels when it differs from the stored one. + switch (slider) { + case 0: + if (DAT_MenuTextInputState::instance.pendingStreamVolume0 != *currentValue) { + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::setVolumeUnk, DAT_SoundSystemState::ptr)( + 0, *currentValue); + } + DAT_MenuTextInputState::instance.pendingStreamVolume0 = *currentValue; + return; + case 1: + if (DAT_MenuTextInputState::instance.pendingStreamVolume1 != *currentValue) { + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::setVolumeUnk, DAT_SoundSystemState::ptr)( + 1, *currentValue); + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::setVolumeUnk, DAT_SoundSystemState::ptr)( + 2, *currentValue); + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::setVolumeUnk, DAT_SoundSystemState::ptr)( + -1, *currentValue); + } + DAT_MenuTextInputState::instance.pendingStreamVolume1 = *currentValue; + return; + case 2: + if (DAT_MenuTextInputState::instance.pendingStreamVolume3 != *currentValue) { + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::setVolumeUnk, DAT_SoundSystemState::ptr)( + 3, *currentValue); + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::setVolumeUnk, DAT_SoundSystemState::ptr)( + 4, *currentValue); + } + DAT_MenuTextInputState::instance.pendingStreamVolume3 = *currentValue; + return; + } + return; + case 4: + // read back again here (one read-back after the switch: quick_diff 0.9222 -> 0.7797) + switch (slider) { + case 0: + *currentValue = DAT_MenuTextInputState::instance.pendingStreamVolume0; + break; + case 1: + *currentValue = DAT_MenuTextInputState::instance.pendingStreamVolume1; + break; + case 2: + *currentValue = DAT_MenuTextInputState::instance.pendingStreamVolume3; + break; + } + } + } + + } + } +} +} diff --git a/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedCreateMessageEvent_Buttons.cpp b/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedCreateMessageEvent_Buttons.cpp new file mode 100644 index 0000000000..ca235c04b9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedCreateMessageEvent_Buttons.cpp @@ -0,0 +1,128 @@ +#include "../Unused.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/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_ButtonUnknownZero.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_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BA980 + void Unused::MenuItemRenderFunction_UnusedCreateMessageEvent_Buttons(int button, ...) + { + DAT_ButtonUnknownZero::instance = FALSE; + // The message library: buttons 4 to 8 open its pages, "Tutor" to "Characters". + // On "Characters" the faces 1009 to 1012 stand in for buttons 9 to 12; on the other pages they are off. + if (DAT_MapPropertiesState::instance.field_0x13590 == 4) { + if (button == 9 || button == 10 || button == 11 || button == 12) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + } else if (button == 1009 || button == 1010 || button == 1011 || button == 1012) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + // the open page's button and the entries chosen on pages 3 and 4 are drawn highlighted + if ((button <= 8 && button - 4 == DAT_MapPropertiesState::instance.field_0x13590) + || (DAT_MapPropertiesState::instance.field_0x13590 == 4 + && (((button <= 12 || button > 1000) + && button - 1009 == DAT_MapPropertiesState::instance.field_0x13594) + || button - 13 == DAT_MapPropertiesState::instance.field_0x13598)) + || (DAT_MapPropertiesState::instance.field_0x13590 == 3 && button <= 12 + && button - 8 == DAT_MapPropertiesState::instance.field_0x13594)) { + // on "Adviser Prompts" buttons 9 and 10 are "Civil" and "Military", 11 and 12 are off + if (DAT_MapPropertiesState::instance.field_0x13590 == 3 && button >= 9) { + if (button == 9) { + button = 24; + } else if (button == 10) { + button = 25; + } else { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + } + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (DAT_MapPropertiesState::instance.field_0x13590 == 4 + && (button == 1009 || button == 1010 || button == 1011 || button == 1012)) { + // a character's face above its name + button -= 1000; + 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_ENEMY_FACES, button - 8, + DAT_ButtonW::instance / 2 - 32 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7); + DAT_ButtonY::instance += 72; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, button, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, + FALSE); + return; + } + // pages 0 to 2 have no buttons past 8, page 3 none past 12 + if (DAT_MapPropertiesState::instance.field_0x13590 < 3 && button >= 9) { + return; + } + if (DAT_MapPropertiesState::instance.field_0x13590 < 4 && button >= 13) { + return; + } + // the remap again, as the original does it once for the hover test and once for the drawing + if (DAT_MapPropertiesState::instance.field_0x13590 == 3 && button >= 9) { + if (button == 9) { + button = 24; + } else if (button == 10) { + button = 25; + } else { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (DAT_MapPropertiesState::instance.field_0x13590 == 4 + && (button == 1009 || button == 1010 || button == 1011 || button == 1012)) { + button -= 1000; + 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_ENEMY_FACES, button - 8, + DAT_ButtonW::instance / 2 - 32 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7); + DAT_ButtonY::instance += 72; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + // An if/else, not an early return (early return: quick_diff 0.9718 -> 0.8870) + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, button, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, + FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, button, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, + FALSE); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ed989c9a21..b884b6ce19 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -9159,7 +9159,7 @@ SHC_3BB0A8C1_0x0042F7E4 | 0.0% | Pending SHC_3BB0A8C1_0x0042F7F0 | 100.0% | Reimplemented, Security Cookie mismatches -SHC_3BB0A8C1_0x0042F940 | 0.0% | Pending +SHC_3BB0A8C1_0x0042F940 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042FA10 | 0.0% | Pending @@ -11101,7 +11101,7 @@ SHC_3BB0A8C1_0x0043355C | 0.0% | Pending SHC_3BB0A8C1_0x00433560 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004335A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004335A0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00433630 | 0.0% | Pending @@ -13301,7 +13301,7 @@ SHC_3BB0A8C1_0x00439150 | 0.0% | Pending SHC_3BB0A8C1_0x00439151 | 0.0% | Pending -SHC_3BB0A8C1_0x00439160 | 0.0% | Pending +SHC_3BB0A8C1_0x00439160 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00439318 | 0.0% | Pending @@ -19937,7 +19937,7 @@ SHC_3BB0A8C1_0x00466160 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00466260 | 0.0% | Pending -SHC_3BB0A8C1_0x00466320 | 0.0% | Pending +SHC_3BB0A8C1_0x00466320 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00466430 | 0.0% | Pending @@ -23489,7 +23489,7 @@ SHC_3BB0A8C1_0x00492660 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492690 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00492890 | 0.0% | Pending +SHC_3BB0A8C1_0x00492890 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004929B0 | 0.0% | Pending @@ -25805,7 +25805,7 @@ SHC_3BB0A8C1_0x004AD2B0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AD2F0 | 0.0% | Pending -SHC_3BB0A8C1_0x004AD480 | 0.0% | Pending +SHC_3BB0A8C1_0x004AD480 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AD780 | 100.0% | Reimplemented @@ -29091,11 +29091,11 @@ SHC_3BB0A8C1_0x004BA8B0 | 0.0% | Pending SHC_3BB0A8C1_0x004BA910 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BA980 | 0.0% | Pending +SHC_3BB0A8C1_0x004BA980 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BAC20 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BAC90 | 0.0% | Pending +SHC_3BB0A8C1_0x004BAC90 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BAD70 | 0.0% | Pending @@ -44205,7 +44205,7 @@ SHC_3BB0A8C1_0x005119B4 | 0.0% | Pending SHC_3BB0A8C1_0x005119C0 | 0.0% | Pending -SHC_3BB0A8C1_0x005119D0 | 0.0% | Pending +SHC_3BB0A8C1_0x005119D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00511A10 | 0.0% | Pending