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
51 changes: 28 additions & 23 deletions src/OpenSHC/UI/DisplayElements/RenderNoRushDisplayElementUnk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "OpenSHC/Audio/SFX/SFXState.func.hpp"
#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/UI/Helpers.func.hpp"
#include "OpenSHC/UI/Rendering.func.hpp"
#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp"
#include "OpenSHC/DE/SHCDE/eTextSections.hpp"
#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp"
Expand All @@ -26,13 +24,6 @@ namespace OpenSHC {
namespace UI {
namespace DisplayElements {

using OpenSHC::DE::SHCDE::eTextSections;
using OpenSHC::Rendering::ScreenResolutionEnum;
using OpenSHC::Rendering::Enums::RenderTarget;
using OpenSHC::Text::TextAlignment;
using OpenSHC::UI::Enums::DisplayElementID;
using OpenSHC::WindowsHelper::Enums::BOOLEnum;

// FUNCTION: STRONGHOLDCRUSADER 0x004B20B0
void RenderNoRushDisplayElementUnk(int posX, int posY, DWORD elementState)
{
Expand All @@ -52,36 +43,50 @@ namespace UI {
+ 50;
int x = posX + 800;
DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME;
// Separate ifs, not an else-if chain (an else-if chain: quick_diff 0.9797 -> 0.9054)
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x768) {
x += 112;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x1024) {
x -= 240;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x1200) {
x -= 400;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1280x720) {
x -= 240;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1440x900) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1440x900) {
x -= 320;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1080) {
x -= 560;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1920x1200) {
x -= 560;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1440) {
x -= 880;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_2560x1600) {
x -= 880;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1366x768) {
x -= 283;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1680x1050) {
x -= 440;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x900) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1600x900) {
x -= 400;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x600) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1024x600) {
x -= 112;
} else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768) {
}
if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_1360x768) {
x -= 280;
}
x += -18 - (barWidth / 2);
x -= 18 + barWidth / 2;
int const left = x - (barWidth / 2);
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox,
DAT_PencilRenderCore::ptr)(left - 7, posY - 5, (barWidth / 2) + 5 + x, posY + 30, 16);
Expand Down
74 changes: 74 additions & 0 deletions src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderBanner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include "../PencilRenderCore.func.hpp"

#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp"
#include "OpenSHC/IO/Graphics/GmID.hpp"

#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"
#include "OpenSHC/Globals/GMFirstPictureIndex.hpp"

namespace OpenSHC {
namespace UI {
namespace Rendering {

// The banner is 8 rows of 8 by 8 pixel tiles. Each y has a left, a middle and a right picture in
// GID_INTERFACE_ICONS_3, followed by their three alpha masks; these are the rows' first pictures.
enum {
BANNER_TILE_SIZE = 8,
BANNER_HEIGHT = 64,
BANNER_TOP_PICTURES = 48,
BANNER_MIDDLE_PICTURES = 54,
BANNER_BOTTOM_PICTURES = 60,
BANNER_CAP_PICTURE = 91,
BANNER_CAP_MASK = 92
};

// FUNCTION: STRONGHOLDCRUSADER 0x00468FE0
void PencilRenderCore::drawHeaderBanner(int xPos, int yPos, int width, int unusedUnk)
{
// The banner is one tile inside the box at the top and on both sides; width becomes the banner's own.
yPos += BANNER_TILE_SIZE;
int const left = xPos + BANNER_TILE_SIZE;
width -= 2 * BANNER_TILE_SIZE;
for (int y = 0; y < BANNER_HEIGHT; y += BANNER_TILE_SIZE) {
int rowPictures;
if (y == 0) {
rowPictures = BANNER_TOP_PICTURES;
} else if (y == BANNER_HEIGHT - BANNER_TILE_SIZE) {
rowPictures = BANNER_BOTTOM_PICTURES;
} else {
rowPictures = BANNER_MIDDLE_PICTURES;
}
for (int x = 0; x < width; x += BANNER_TILE_SIZE) {
// Nested, not a flat else-if chain (a flat chain: quick_diff 1.0000 -> 0.9827)
int picture = rowPictures;
if (x != 0) {
if (x == width - BANNER_TILE_SIZE) {
picture = rowPictures + 2;
} else {
picture = rowPictures + 1;
}
}
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture,
x + left, y + yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture + 3, 0);
}
}
// An end cap 3 pixels in from each end of the banner
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_PICTURE,
left + 3, yPos + 9, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_MASK, 0);
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_PICTURE,
left
- DAT_GMImageHeaders::instance
.imh[GMFirstPictureIndex::instance[OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3]
+ BANNER_CAP_PICTURE - 1]
.width
+ width - 3,
yPos + 9, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_MASK, 0);
}

}
}
}
86 changes: 86 additions & 0 deletions src/OpenSHC/UI/Rendering/PencilRenderCore/drawHeaderTextBanner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include "../PencilRenderCore.func.hpp"

#include "OpenSHC/Text/TextManager.func.hpp"
#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp"
#include "OpenSHC/IO/Graphics/GmID.hpp"
#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp"
#include "OpenSHC/Text/TextAlignment.hpp"

#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"
#include "OpenSHC/Globals/GMFirstPictureIndex.hpp"

namespace OpenSHC {
namespace UI {
namespace Rendering {

// The banner is 8 rows of 8 by 8 pixel tiles. Each y has a left, a middle and a right picture in
// GID_INTERFACE_ICONS_3, followed by their three alpha masks; these are the rows' first pictures.
enum {
BANNER_TILE_SIZE = 8,
BANNER_HEIGHT = 64,
BANNER_TOP_PICTURES = 48,
BANNER_MIDDLE_PICTURES = 54,
BANNER_BOTTOM_PICTURES = 60,
BANNER_CAP_PICTURE = 91,
BANNER_CAP_MASK = 92,
BANNER_TEXT_FONT_SIZE = 15
};

// FUNCTION: STRONGHOLDCRUSADER 0x00475CC0
void PencilRenderCore::drawHeaderTextBanner(
int textGroupIndex, int textNumInGroup, int xPos, int yPos, int width, int height)
{
// drawHeaderBanner's banner, with a text centred on it
// The banner is one tile inside the box at the top and on both sides; width becomes the banner's own.
yPos += BANNER_TILE_SIZE;
int const left = xPos + BANNER_TILE_SIZE;
width -= 2 * BANNER_TILE_SIZE;
for (int y = 0; y < BANNER_HEIGHT; y += BANNER_TILE_SIZE) {
int rowPictures;
if (y == 0) {
rowPictures = BANNER_TOP_PICTURES;
} else if (y == BANNER_HEIGHT - BANNER_TILE_SIZE) {
rowPictures = BANNER_BOTTOM_PICTURES;
} else {
rowPictures = BANNER_MIDDLE_PICTURES;
}
for (int x = 0; x < width; x += BANNER_TILE_SIZE) {
// Nested, not a flat else-if chain (a flat chain: quick_diff 0.9909 -> 0.9774)
int picture = rowPictures;
if (x != 0) {
if (x == width - BANNER_TILE_SIZE) {
picture = rowPictures + 2;
} else {
picture = rowPictures + 1;
}
}
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture,
x + left, y + yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture + 3, 0);
}
}
// An end cap 3 pixels in from each end of the banner
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_PICTURE,
left + 3, yPos + 9, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_MASK, 0);
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_PICTURE,
left
- DAT_GMImageHeaders::instance
.imh[GMFirstPictureIndex::instance[OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3]
+ BANNER_CAP_PICTURE - 1]
.width
+ width - 3,
yPos + 9, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, BANNER_CAP_MASK, 0);
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)textGroupIndex, textNumInGroup),
width / 2 + left, yPos + 14, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB,
BANNER_TEXT_FONT_SIZE, FALSE, 0);
}

}
}
}
100 changes: 100 additions & 0 deletions src/OpenSHC/UI/Rendering/PencilRenderCore/drawScrollbar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include "../PencilRenderCore.func.hpp"

#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp"
#include "OpenSHC/DE/SHCDE/eGM.hpp"
#include "OpenSHC/IO/Graphics/GmID.hpp"

#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"

namespace OpenSHC {
namespace UI {
namespace Rendering {

// Pictures in GID_INTERFACE_ICONS_3. The track's two and the small thumb are each followed by its alpha mask;
// the thumb's top, middle row and bottom are followed by their three masks.
enum {
SCROLLBAR_TRACK_PICTURE = 79,
SCROLLBAR_TRACK_ROW_PICTURE = 95,
SCROLLBAR_SMALL_THUMB_PICTURE = 89,
SCROLLBAR_THUMB_TOP_PICTURE = 100,
SCROLLBAR_THUMB_ROW_PICTURE = 101,
SCROLLBAR_THUMB_BOTTOM_PICTURE = 102,
SCROLLBAR_TRACK_PICTURE_HEIGHT = 20,
SCROLLBAR_SMALL_THUMB_HEIGHT = 20,
SCROLLBAR_THUMB_END_HEIGHT = 10
};

// FUNCTION: STRONGHOLDCRUSADER 0x004690E0
void PencilRenderCore::drawScrollbar(
uint xPos, int yPos, int height, int thumbYPos, BOOLEnum isDragged, int thumbHeight, int blendStrength)
{
int const top = yPos;
int const bottom = yPos + height;
// The track in whole pictures, then single rows down to the bottom
for (; yPos <= bottom - SCROLLBAR_TRACK_PICTURE_HEIGHT; yPos += SCROLLBAR_TRACK_PICTURE_HEIGHT) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_TRACK_PICTURE, xPos, yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_TRACK_PICTURE + 1, blendStrength);
}
for (; yPos < bottom; ++yPos) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_TRACK_ROW_PICTURE, xPos, yPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_TRACK_ROW_PICTURE + 1, blendStrength);
}
// A dragged thumb is drawn without its masks
if (isDragged) {
if (thumbHeight <= SCROLLBAR_SMALL_THUMB_HEIGHT) {
MACRO_CALL_MEMBER(
OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, SCROLLBAR_SMALL_THUMB_PICTURE, xPos, top + thumbYPos);
return;
}
MACRO_CALL_MEMBER(
OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, SCROLLBAR_THUMB_TOP_PICTURE, xPos, top + thumbYPos);
// The top and bottom pieces are 10 pixels high, single middle rows fill the rest
thumbYPos += SCROLLBAR_THUMB_END_HEIGHT;
thumbHeight -= SCROLLBAR_THUMB_END_HEIGHT;
for (int row = SCROLLBAR_THUMB_END_HEIGHT; row < thumbHeight; ++row) {
MACRO_CALL_MEMBER(
OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, SCROLLBAR_THUMB_ROW_PICTURE, xPos, top + thumbYPos);
++thumbYPos;
}
MACRO_CALL_MEMBER(
OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)(
OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, SCROLLBAR_THUMB_BOTTOM_PICTURE, xPos, top + thumbYPos);
return;
}
if (thumbHeight <= SCROLLBAR_SMALL_THUMB_HEIGHT) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_SMALL_THUMB_PICTURE, xPos, top + thumbYPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_SMALL_THUMB_PICTURE + 1, blendStrength);
return;
}
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_THUMB_TOP_PICTURE, xPos, top + thumbYPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_THUMB_TOP_PICTURE + 3, blendStrength);
// The top and bottom pieces are 10 pixels high, single middle rows fill the rest
thumbYPos += SCROLLBAR_THUMB_END_HEIGHT;
thumbHeight -= SCROLLBAR_THUMB_END_HEIGHT;
for (int row = SCROLLBAR_THUMB_END_HEIGHT; row < thumbHeight; ++row) {
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_THUMB_ROW_PICTURE, xPos, top + thumbYPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_THUMB_ROW_PICTURE + 3, blendStrength);
++thumbYPos;
}
MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask,
DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_THUMB_BOTTOM_PICTURE, xPos, top + thumbYPos, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3,
SCROLLBAR_THUMB_BOTTOM_PICTURE + 3, blendStrength);
}

}
}
}
Loading
Loading