Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include "../BuildingAndStatusMenu.func.hpp"

#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/UI/MenuItems/General.func.hpp"
#include "OpenSHC/DE/SHCDE/eTextSections.hpp"
#include "OpenSHC/Map/Buildings/BuildingType.hpp"
#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp"
#include "OpenSHC/Text/TextAlignment.hpp"

#include "OpenSHC/Globals/DAT_BuildingsState.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 {
namespace BuildingAndStatusMenu {

// FUNCTION: STRONGHOLDCRUSADER 0x00466620
void MenuItemRenderFunction_BuildingAndStatusMenu_OutpostUnitSelection(int bitIndex, ...)
{
int const unitBit = 1 << bitIndex;
// Each outpost's title comes before its unit names; the Arabian outpost's follow the European ones.
int textOffset = 0;
if (DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.buildingType
== Map::Buildings::BT_OUTPOST_ARABIAN) {
textOffset = 9;
}
// The button shows pressed while the outpost has this unit selected.
// The test and the draw in each branch (once, before the hover test: quick_diff 0.9206 -> 0.5854)
if (!DAT_ButtonCurrentlyInteracting::instance) {
if (DAT_BuildingsState::instance.menuSelectedBuildingID != 0
&& (unitBit
& DAT_BuildingsState::instance
.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.outpostRelatedUnk1)
!= 0) {
DAT_ButtonCurrentlyInteracting::instance = TRUE;
} else {
DAT_ButtonCurrentlyInteracting::instance = FALSE;
}
MACRO_CALL(General_Func::
MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)();
// One call per colour pair (one call with colour locals: quick_diff 0.9206 -> 0.4615)
// The position in each branch (in the calls: quick_diff 0.9206 -> 0.8730)
int const textY = DAT_ButtonY::instance + 7;
int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance;
MACRO_CALL_MEMBER(Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)(
MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset,
DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_IN_OUTPOST, textOffset + 1 + bitIndex),
textX, textY, Text::TTA_CENTER, Rendering::Colors::COL_C2F0EB, Rendering::Colors::COL_003E66,
18, FALSE, 0);
return;
}
if (DAT_BuildingsState::instance.menuSelectedBuildingID != 0
&& (unitBit
& DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID]
.outpostRelatedUnk1)
!= 0) {
DAT_ButtonCurrentlyInteracting::instance = TRUE;
} else {
DAT_ButtonCurrentlyInteracting::instance = FALSE;
}
MACRO_CALL(General_Func::
MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)();
int const textY = DAT_ButtonY::instance + 7;
int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance;
MACRO_CALL_MEMBER(Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)(
MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(
DE::SHCDE::TEXT_IN_OUTPOST, textOffset + 1 + bitIndex),
textX, textY, Text::TTA_CENTER, Rendering::Colors::COL_CCFAFF, Rendering::Colors::COL_000000, 18,
FALSE, 0);
}

}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include "../BuildingAvailability.func.hpp"

#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp"
#include "OpenSHC/DE/SHCDE/eTextSections.hpp"
#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp"
#include "OpenSHC/Rendering/Enums/RenderTarget.hpp"
#include "OpenSHC/Text/TextAlignment.hpp"

#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp"
#include "OpenSHC/Globals/DAT_ButtonX.hpp"
#include "OpenSHC/Globals/DAT_ButtonY.hpp"
#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp"
#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp"
#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {
namespace BuildingAvailability {

// FUNCTION: STRONGHOLDCRUSADER 0x004BB3E0
void MenuItemRenderFunction_BuildingAvailability_TableRows(int row, ...)
{
int const buildingIndex
= DAT_MissionAestheticsDefinedData::instance.BuildingAvailabilityStructIndexForNameArray
[DAT_MapPropertiesState::instance.DAT_BuildingAvailabilityScrollbarOffset + row];
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU;
MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawTableCellBackground,
DAT_PencilRenderCore::ptr)(FALSE, row, 0);
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME;
// The building's name: highlighted while hovered, grey when the building is not available.
// One call per colour (one call with a colour local: quick_diff 0.9048 -> 0.5882)
if (DAT_ButtonCurrentlyInteracting::instance) {
// y then x in each branch (once, before the test: quick_diff 0.9048 -> 0.7857; x first: 0.8095)
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonX::instance + 20;
// The name last (before the test: quick_diff 0.9048 -> 0.7381; first: 0.7045; in the call: 0.5208)
int const nameNumber
= DAT_MissionAestheticsDefinedData::instance.BuildingNameRelatedStructArray[buildingIndex]
.nameNumberInTextGroup;
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, nameNumber),
textX, textY, Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0);
} else if (!DAT_MapPropertiesState::instance.buildingAvailability[buildingIndex]) {
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonX::instance + 20;
int const nameNumber
= DAT_MissionAestheticsDefinedData::instance.BuildingNameRelatedStructArray[buildingIndex]
.nameNumberInTextGroup;
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, nameNumber),
textX, textY, Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_7F7F7F, 19, FALSE, 0);
} else {
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonX::instance + 20;
int const nameNumber
= DAT_MissionAestheticsDefinedData::instance.BuildingNameRelatedStructArray[buildingIndex]
.nameNumberInTextGroup;
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, nameNumber),
textX, textY, Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0);
}
}

}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#include "../DisableWeapon.func.hpp"

#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/UI/MenuItems/General.func.hpp"
#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp"
#include "OpenSHC/UI/Rendering/TextureRenderCore.func.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/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_MapPropertiesState.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {
namespace DisableWeapon {

// FUNCTION: STRONGHOLDCRUSADER 0x004BB7B0
void MenuItemRenderFunction_DisableWeapon_Main(int button, ...)
{
// Before the range test: the Exit block reuses its zero (inside the if: quick_diff 0.8889 -> 0.7273)
int iconOffsetY = 0;
// Guarded, not an early return (early return: quick_diff 0.8889 -> 0.8673)
// One unsigned test for 0..7 (button >= 0 && button <= 7: reccmp 100.0% -> 90.0%)
if ((uint)button <= 7) {
// Button 1 moves down a pixel while hovered; its icon stays where it was.
if (button == 1 && DAT_ButtonCurrentlyInteracting::instance) {
++DAT_ButtonY::instance;
iconOffsetY = -1;
}
MACRO_CALL(General_Func::
MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)();
// The weapons 0 to 5 get the disabled icon only while they cannot be made.
// Break to the icon, then return (the return first: quick_diff 0.8889 -> 0.7527)
switch (button) {
case 0:
if (!DAT_MapPropertiesState::instance.SEC_XbowProducible_save) {
break;
}
return;
case 1:
if (!DAT_MapPropertiesState::instance.SEC_PikeProducible_save) {
break;
}
return;
case 2:
if (!DAT_MapPropertiesState::instance.SEC_SwordProducible_save) {
break;
}
return;
case 3:
if (!DAT_MapPropertiesState::instance.SEC_BowProducible_save) {
break;
}
return;
case 4:
if (!DAT_MapPropertiesState::instance.SEC_SpearProducible_save) {
break;
}
return;
case 5:
if (!DAT_MapPropertiesState::instance.SEC_MaceProducible_save) {
break;
}
return;
// An explicit default keeps every return's epilogue (without it: quick_diff 0.8889 -> 0.8673)
default:
break;
}
if (button != 0) {
DAT_ButtonX::instance -= 4;
}
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue
= OpenSHC::Rendering::Enums::RT_SCREEN_MENU;
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 45,
DAT_ButtonX::instance + 6, DAT_ButtonY::instance + iconOffsetY - 5, 12);
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue
= OpenSHC::Rendering::Enums::RT_MAP_GAME;
return;
}
if (button == -3) {
// "Exit"
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton,
AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED);
// One call per colour (one call with a colour local: quick_diff 0.8889 -> 0.7839)
// The position in each branch (once, before the test: quick_diff 0.8889 -> 0.8788)
if (!DAT_ButtonCurrentlyInteracting::instance) {
int const textY = DAT_ButtonY::instance + 6;
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::TEXT_SCENARIO, 3),
textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE,
0);
} else {
int const textY = DAT_ButtonY::instance + 6;
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::TEXT_SCENARIO, 3),
textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE,
0);
}
}
}

}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "../EditScenario.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_MapPropertiesState.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {
namespace EditScenario {

// FUNCTION: STRONGHOLDCRUSADER 0x004BAC20
void MenuItemRenderFunction_EditScenario_StartDateMonth(int param_1, ...)
{
MACRO_CALL_MEMBER(Rendering::AlphaAndButtonSurface_Func::renderBasicButton,
AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED);
// One call per colour (one call with a colour local: quick_diff 0.9062 -> 0.5373)
// y, x, then the month, in each branch (once, before the test: quick_diff 0.9062 -> 0.8438)
if (!DAT_ButtonCurrentlyInteracting::instance) {
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance;
// The month's full name, read last (first: quick_diff 0.9062 -> 0.6970; in the call: 0.6857)
int const monthTextIndex = DAT_MapPropertiesState::instance.SEC_StartingMonth + 12;
MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(
MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset,
DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_MONTHS, monthTextIndex),
textX, textY, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0);
return;
}
int const textY = DAT_ButtonY::instance + 6;
int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance;
int const monthTextIndex = DAT_MapPropertiesState::instance.SEC_StartingMonth + 12;
MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(
MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(
DE::SHCDE::TEXT_MONTHS, monthTextIndex),
textX, textY, Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0);
}

}
}
}
}
Loading
Loading