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
1 change: 1 addition & 0 deletions cmake/compiler-flags-gl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,4 @@ src/OpenSHC/UI/Rendering/RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurre
src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_DrawbridgeOpenClose.cpp
src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_GatehouseOpenClose.cpp
src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_WorkshopWeaponSelection.cpp
src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "../General.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_ButtonCurrentlyInteracting.hpp"
#include "OpenSHC/Globals/DAT_ButtonX.hpp"
#include "OpenSHC/Globals/DAT_ButtonY.hpp"
#include "OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp"
#include "OpenSHC/Globals/INT_00ed2bdc.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

// FUNCTION: STRONGHOLDCRUSADER 0x004D8DF0
void General::MenuItemRenderFunction_General_CrusadeMapAndEndscreen(int button, ...)
{
if (button == 1000) {
// the skip-mission button, with the number of skips (chickens) left
// cleared, then set when hovered (a copy of the hover flag: quick_diff 0.9464 -> 0.8000)
INT_00ed2bdc::instance = FALSE;
if (DAT_ButtonCurrentlyInteracting::instance) {
INT_00ed2bdc::instance = TRUE;
}
MACRO_CALL(OpenSHC::UI::MenuItems::General_Func::
MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)();
MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(
DAT_SkirmishTrailRelated1::instance, DAT_ButtonX::instance + 53, DAT_ButtonY::instance + 98,
OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 15, FALSE, 0);
if (!INT_00ed2bdc::instance) {
return;
}
// hovered: a caption 400 and 583 pixels in from the menu's corner; the count is compared signed
// y then x, before the test (x first: quick_diff 0.9464 -> 0.8750)
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) {
// "Skip Current Mission"
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_CHEATS, 0),
textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0);
return;
}
// "No Chickens Left"
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_CHEATS, 1),
textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0);
return;
}
if (button == 10 || button == 11 || button == 99) {
MACRO_CALL(OpenSHC::UI::MenuItems::General_Func::
MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)();
}
}

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

#include "OpenSHC/UI/Rendering/ButtonGmData.func.hpp"
#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp"
#include "OpenSHC/DE/SHCDE/eGM.hpp"
#include "OpenSHC/IO/Graphics/GmID.hpp"
#include "OpenSHC/Rendering/Enums/RenderTarget.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_CurrentButtonGmDataIndex.hpp"
#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"
#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

// FUNCTION: STRONGHOLDCRUSADER 0x00463FF0
void General::MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface()
{
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU;
if (DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance]
.alphaGmIdUnk_0xc
!= 0) {
// a button with an alpha GM is drawn blended, and not at all at blend strength 32
if (DAT_ButtonBlendStrength::instance != 32) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending,
DAT_TextureRenderCoreObject::ptr)((OpenSHC::IO::Graphics::GmID)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])(
DAT_ButtonCurrentlyInteracting::instance),
DAT_ButtonX::instance, DAT_ButtonY::instance, DAT_ButtonBlendStrength::instance);
}
DAT_CurrentButtonPictureInGm::instance
= DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance]
.pictureInGm_0x4;
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])(
DAT_ButtonCurrentlyInteracting::instance),
DAT_ButtonX::instance, DAT_ButtonY::instance);
DAT_CurrentButtonPictureInGm::instance
= DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance]
.pictureInGm_0x4;
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME;
}

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

#include "OpenSHC/UI/Rendering.func.hpp"
#include "OpenSHC/UI/Rendering/ButtonGmData.func.hpp"
#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp"
#include "OpenSHC/DE/SHCDE/eGM.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_GreatestLordDefinedData.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"
#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

// FUNCTION: STRONGHOLDCRUSADER 0x004AE720
void GreatestLord::MenuItemRenderFunction_GreatestLord_Main(int button, ...)
{
// the header of the column the table is sorted by (11 for 1, 12 for 0, 10 for -1) gets its own picture
if ((button == 11 && DAT_GreatestLordDefinedData::instance.tableSortBy == 1)
|| (button == 12 && DAT_GreatestLordDefinedData::instance.tableSortBy == 0)
|| (button == 10 && DAT_GreatestLordDefinedData::instance.tableSortBy == -1)) {
// 14 pictures on from the hovered one, 1 for header 12
int pictureOffset = 14;
if (button == 12) {
pictureOffset = 1;
}
DAT_ButtonCurrentlyInteracting::instance = TRUE;
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)
+ pictureOffset,
DAT_ButtonX::instance, DAT_ButtonY::instance);
return;
}
MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderButtonImageWithBlending)();
}

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

#include "OpenSHC/Game/GameStateStructures.func.hpp"
#include "OpenSHC/Map/TileMapState.func.hpp"
#include "OpenSHC/Rendering/ViewportRenderState.func.hpp"
#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp"
#include "OpenSHC/UI/BottomLeftTextDisplayState.func.hpp"
#include "OpenSHC/Commands/GameCommandType.hpp"
#include "OpenSHC/Commands/MappersEnum.hpp"
#include "OpenSHC/DE/SHCDE/eTextSections.hpp"
#include "OpenSHC/Game/Resources/ResourceType.hpp"
#include "OpenSHC/Map/Buildings/BuildingFailReasonEnum.hpp"

#include "OpenSHC/Globals/DAT_BottomLeftTextDisplayState.hpp"
#include "OpenSHC/Globals/DAT_GameState.hpp"
#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp"
#include "OpenSHC/Globals/DAT_MouseState.hpp"
#include "OpenSHC/Globals/DAT_ScrollingHandler.hpp"
#include "OpenSHC/Globals/DAT_TileMapState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"

namespace OpenSHC {
namespace UI {
namespace MenuItems {

// FUNCTION: STRONGHOLDCRUSADER 0x00437ED0
void InGameMenu::MenuItemActionHandler_InGameMenu_TriggerPlaceWallCommand()
{
if (DAT_GameSynchronyState::instance.syncStatus != 0) {
return;
}
if (DAT_GameSynchronyState::instance.saveRelated != 0) {
return;
}
// only for the wall, wooden wall, stairs and crenel tools
if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_WALL
&& DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_WOODWALL
&& DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_STAIR
&& DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_CRENAL) {
return;
}
if (!DAT_ViewportRenderState::instance.viewportState.field_0x0) {
return;
}
DAT_MouseState::instance.field_0x1dc = 1000;
// the tile under the mouse
if (DAT_TileMapState::instance.flatViewToggleValue1) {
MACRO_CALL_MEMBER(
OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY2, DAT_ViewportRenderState::ptr)();
} else {
MACRO_CALL_MEMBER(
OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)();
}
// a click starts the drag, a held button or a finished drag moves its end, no button puts both ends here
if (DAT_MouseState::instance.leftClickStart) {
DAT_TileMapState::instance.dragStartX = DAT_ViewportRenderState::instance.viewportState.mouseTileX;
DAT_TileMapState::instance.dragStartY = DAT_ViewportRenderState::instance.viewportState.mouseTileY;
} else if (DAT_MouseState::instance.draggingStopped || DAT_MouseState::instance.leftClickState) {
DAT_TileMapState::instance.dragEndX = DAT_ViewportRenderState::instance.viewportState.mouseTileX;
DAT_TileMapState::instance.dragEndY = DAT_ViewportRenderState::instance.viewportState.mouseTileY;
} else {
if (DAT_ScrollingHandler::instance.isScrolling_0x0) {
return;
}
DAT_TileMapState::instance.dragStartX = DAT_ViewportRenderState::instance.viewportState.mouseTileX;
DAT_TileMapState::instance.dragStartY = DAT_ViewportRenderState::instance.viewportState.mouseTileY;
DAT_TileMapState::instance.dragEndX = DAT_ViewportRenderState::instance.viewportState.mouseTileX;
DAT_TileMapState::instance.dragEndY = DAT_ViewportRenderState::instance.viewportState.mouseTileY;
}
DAT_TileMapState::instance.buildingPlacementFailReason
= OpenSHC::Map::Buildings::BFRE_DEFAULT_CANT_PLACE_THAT_THERE;
DAT_TileMapState::instance.wallPlacementCost = 0;
DAT_TileMapState::instance.constructionTileCount = MACRO_CALL_MEMBER(
OpenSHC::Game::GameStateStructures_Func::getWallTilesThatCanBeBuilt, DAT_GameState::ptr)(
DAT_GameSynchronyState::instance.currentPlayerSlotID, OpenSHC::Game::Resources::RT_STONE);
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::validateWallBuildPath, DAT_TileMapState::ptr)(
DAT_GameSynchronyState::instance.currentPlayerSlotID, DAT_TileMapState::instance.dragStartX,
DAT_TileMapState::instance.dragStartY, DAT_TileMapState::instance.dragEndX,
DAT_TileMapState::instance.dragEndY, (ushort)DAT_TileMapState::instance.currentMapperCommand);
// until the drag stops, only the preview is drawn
if (!DAT_MouseState::instance.draggingStopped) {
DAT_TileMapState::instance.wallDragButtonUp = !DAT_MouseState::instance.leftClickState;
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::renderWallDragPreview, DAT_TileMapState::ptr)(
DAT_GameSynchronyState::instance.currentPlayerSlotID, DAT_TileMapState::instance.dragStartX,
DAT_TileMapState::instance.dragStartY, DAT_TileMapState::instance.dragEndX,
DAT_TileMapState::instance.dragEndY, (ushort)DAT_TileMapState::instance.currentMapperCommand);
return;
}
if (DAT_TileMapState::instance.illegalBuild) {
// the panel feedback text with the fail reason's number
if (DAT_TileMapState::instance.buildingPlacementFailReason
!= OpenSHC::Map::Buildings::BFRE_DEFAULT_CANT_PLACE_THAT_THERE) {
MACRO_CALL_MEMBER(OpenSHC::UI::BottomLeftTextDisplayState_Func::setBottomLeftTextDisplayText,
DAT_BottomLeftTextDisplayState::ptr)(1, OpenSHC::DE::SHCDE::TEXT_PANEL_FEEDBACK,
DAT_TileMapState::instance.buildingPlacementFailReason, 0, 100, 6000);
}
return;
}
DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = DAT_TileMapState::instance.dragStartX;
DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = DAT_TileMapState::instance.dragStartY;
DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.dragEndX;
DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = DAT_TileMapState::instance.dragEndY;
DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = DAT_TileMapState::instance.currentMapperCommand;
DAT_GameSynchronyState::instance.DAT_GameCommandParam5 = DAT_TileMapState::instance.constructionTileCount;
MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)(
OpenSHC::Commands::GCT_PLACE_WALL);
}

}
}
}
Loading
Loading