Skip to content
Draft
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
6 changes: 3 additions & 3 deletions src/OpenSHC/Text/FontSizeClass.func.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ namespace Text {
Address::SHC_3BB0A8C1_0x004733A0, &FontSizeClass::renderSomeSpecificTextUnk)
renderSomeSpecificTextUnk;

MACRO_FUNCTION_RESOLVER(int (FontSizeClass::*)(char, int, int, int, int), false,
MACRO_FUNCTION_RESOLVER(int (FontSizeClass::*)(byte, int, int, int, int), false,
Address::SHC_3BB0A8C1_0x00473640, &FontSizeClass::renderCharUnk)
renderCharUnk;

MACRO_FUNCTION_RESOLVER(void (FontSizeClass::*)(LPWSTR, int, int, int, BGR24, int), false,
MACRO_FUNCTION_RESOLVER(int (FontSizeClass::*)(LPWSTR, int, int, int, BGR24, int), false,
Address::SHC_3BB0A8C1_0x004737B0, &FontSizeClass::renderWideText)
renderWideText;

MACRO_FUNCTION_RESOLVER(int (FontSizeClass::*)(undefined4, int, int, int, int), false,
MACRO_FUNCTION_RESOLVER(int (FontSizeClass::*)(WCHAR, int, int, int, int), false,
Address::SHC_3BB0A8C1_0x00473830, &FontSizeClass::renderWideChar)
renderWideChar;

Expand Down
8 changes: 4 additions & 4 deletions src/OpenSHC/Text/FontSizeClass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Text {
int fontStartImageId_0x8; // 0x00000008 length: 4
FontRenderTypeInt renderType_0xc; // 0x0000000C length: 4
int baselineOffset_0x10; // 0x00000010 length: 4
dword lineHeight_0x14; // 0x00000014 length: 4
int lineHeight_0x14; // 0x00000014 length: 4
int letterSpacing_0x18; // 0x00000018 length: 4
int whiteSpaceWidth_0x1c; // 0x0000001C length: 4
HGDIOBJ hgdiobj; // 0x00000020 length: 4
Expand Down Expand Up @@ -74,11 +74,11 @@ namespace Text {

void renderSomeSpecificTextUnk(int lengthUnk, int otherBlendValueUnk, int xPos, int yPos, BGR24 color);

int renderCharUnk(char charId, int xPos, int yPosUnk, int bgr24, int blendStrengthUnk);
int renderCharUnk(byte charId, int xPos, int yPosUnk, int bgr24, int blendStrengthUnk);

void renderWideText(LPWSTR wideText, int textLength, int xPos, int yPos, BGR24 color, int blendStrength);
int renderWideText(LPWSTR wideText, int textLength, int xPos, int yPos, BGR24 color, int blendStrength);

int renderWideChar(undefined4 param_1, int param_2, int param_3, int param_4, int param_5);
int renderWideChar(WCHAR wideChar, int xPos, int yPos, int bgr24, int blendStrengthUnk);
};

static_assert_cpp98_obj(sizeof(FontSizeClass) == 36, FontSizeClass);
Expand Down
36 changes: 36 additions & 0 deletions src/OpenSHC/Text/FontSizeClass/getCharWidthUnk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "../FontSizeClass.func.hpp"

#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp"
#include "OpenSHC/Globals/DAT_TextInputDefinedData.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/GMTotalPicturesProcessed.hpp"

namespace OpenSHC {
namespace Text {

// FUNCTION: STRONGHOLDCRUSADER 0x00469E10
int FontSizeClass::getCharWidthUnk(byte charUnk)
{
int _width = 0;
if (this->fontStartImageId_0x8 == -1) {
this->fontStartImageId_0x8
= GMTotalPicturesProcessed::instance[this->fontGmID_0x0] + this->numberOfFontStartInGm_0x4 - 1;
}

int const imageSeqID
= DAT_TextInputDefinedData::instance
.CharToImageSeqIDMapping[DAT_TextManagerObject::instance.alternativeCodePageUsedUnk][charUnk];

if (imageSeqID == -1) {
if (charUnk >= ' ') {
return this->whiteSpaceWidth_0x1c;
}
} else {
_width = DAT_GMImageHeaders::instance.imh[this->fontStartImageId_0x8 + imageSeqID].width
+ this->letterSpacing_0x18;
}
return _width;
}

}
}
18 changes: 18 additions & 0 deletions src/OpenSHC/Text/FontSizeClass/getWideCharWidth.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "../FontSizeClass.func.hpp"

#include "OpenSHC/Util/WideCharMultiByteState.func.hpp"

#include "OpenSHC/Globals/DAT_WideCharMultiByteState.hpp"

namespace OpenSHC {
namespace Text {

// FUNCTION: STRONGHOLDCRUSADER 0x00471670
dword FontSizeClass::getWideCharWidth(WCHAR wChar)
{
return MACRO_CALL_MEMBER(FontSizeClass_Func::getCharWidthUnk, this)(MACRO_CALL_MEMBER(
Util::WideCharMultiByteState_Func::wideCharToByteUnk, DAT_WideCharMultiByteState::ptr)(wChar));
}

}
}
72 changes: 72 additions & 0 deletions src/OpenSHC/Text/FontSizeClass/getWidthOfText.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "../FontSizeClass.func.hpp"

#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp"
#include "OpenSHC/Globals/DAT_TextInputDefinedData.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/GMTotalPicturesProcessed.hpp"

namespace OpenSHC {
namespace Text {

// FUNCTION: STRONGHOLDCRUSADER 0x00469A70
int FontSizeClass::getWidthOfText(char* text, int length)
{
int _currentLineWidthUnk = 0;
int _maxSingleLineWidth = -1;

int local_c = DAT_TextManagerObject::instance.field9_0x24;
if (DAT_TextManagerObject::instance.field9_0x24 <= DAT_TextManagerObject::instance.field10_0x28) {
local_c = DAT_TextManagerObject::instance.field10_0x28;
}

int iVar1 = 0;
if (this->fontStartImageId_0x8 == -1) {
this->fontStartImageId_0x8
= GMTotalPicturesProcessed::instance[this->fontGmID_0x0] + -1 + this->numberOfFontStartInGm_0x4;
}

for (int _textIndex = 0; _textIndex < length; ++_textIndex) {
byte _char = text[_textIndex];

int imageID
= DAT_TextInputDefinedData::instance
.CharToImageSeqIDMapping[DAT_TextManagerObject::instance.alternativeCodePageUsedUnk][_char];
if (imageID == -1) {
if (_char >= ' ') {
_currentLineWidthUnk += this->whiteSpaceWidth_0x1c;
} else if (_char == '\n' && _currentLineWidthUnk > _maxSingleLineWidth) {
_maxSingleLineWidth = _currentLineWidthUnk;
_currentLineWidthUnk = 0;
}
} else {
imageID += this->fontStartImageId_0x8;
if (local_c != 0) {
local_c = 0;

if (this->lineHeight_0x14 == 27) {
iVar1 = 19;
}

if (this->lineHeight_0x14 == 20) {
iVar1 = 20;
}

if (iVar1 != 0) {
_currentLineWidthUnk += 3
+ DAT_GMImageHeaders::instance.imh[GMTotalPicturesProcessed::instance[156] + iVar1 - 1]
.width
- DAT_GMImageHeaders::instance.imh[imageID].width - this->letterSpacing_0x18;
}
}
_currentLineWidthUnk += DAT_GMImageHeaders::instance.imh[imageID].width + this->letterSpacing_0x18;
}
}
if (_currentLineWidthUnk <= _maxSingleLineWidth) {
_currentLineWidthUnk = _maxSingleLineWidth;
}

return _currentLineWidthUnk;
}

}
}
20 changes: 20 additions & 0 deletions src/OpenSHC/Text/FontSizeClass/getWidthOfWideText.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "../FontSizeClass.func.hpp"

#include "OpenSHC/Util/WideCharMultiByteState.func.hpp"

#include "OpenSHC/Globals/DAT_WideCharMultiByteState.hpp"

namespace OpenSHC {
namespace Text {

// FUNCTION: STRONGHOLDCRUSADER 0x00471610
int FontSizeClass::getWidthOfWideText(LPWSTR wideText, int numberOfChars)
{
CHAR _charStringBuffer[3000];
MACRO_CALL_MEMBER(Util::WideCharMultiByteState_Func::wideCharToMultiByteWithSize,
DAT_WideCharMultiByteState::ptr)(_charStringBuffer, wideText, numberOfChars);
return MACRO_CALL_MEMBER(FontSizeClass_Func::getWidthOfText, this)(_charStringBuffer, numberOfChars);
}

}
}
50 changes: 50 additions & 0 deletions src/OpenSHC/Text/FontSizeClass/getWordStartingFromPos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "../FontSizeClass.func.hpp"

#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"

namespace OpenSHC {
namespace Text {

// FUNCTION: STRONGHOLDCRUSADER 0x00469B90
int FontSizeClass::getWordStartingFromPos(
char* text, int startAndRunIndex, char* wordReceiver, int maxWordBufferSize, int* wordStartIndexOutPtr)
{
if (!text || !wordReceiver || text[startAndRunIndex] == '\0') {
return 0;
}

if (DAT_TextManagerObject::instance.field12_0x30) {
*wordReceiver = text[startAndRunIndex];
wordReceiver[1] = '\0';
*wordStartIndexOutPtr = 0;
return 1;
}

int wordStartIndex = -1;
char _charHolder;
do {
_charHolder = text[startAndRunIndex];
++startAndRunIndex;
++wordStartIndex;
if (_charHolder == '\0') {
return 0;
}
} while (_charHolder == ' ');
*wordStartIndexOutPtr = wordStartIndex;
*wordReceiver = _charHolder;

int wordIndexAndLength;
for (wordIndexAndLength = 1; wordIndexAndLength < maxWordBufferSize; ++wordIndexAndLength) {
char currentChar = text[startAndRunIndex];
++startAndRunIndex;
if (currentChar == '\0' || currentChar == ' ') {
break;
}
wordReceiver[wordIndexAndLength] = currentChar;
}
wordReceiver[wordIndexAndLength] = '\0';
return wordIndexAndLength;
}

}
}
74 changes: 74 additions & 0 deletions src/OpenSHC/Text/FontSizeClass/renderCharUnk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include "../FontSizeClass.func.hpp"

#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp"
#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp"

#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp"
#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp"
#include "OpenSHC/Globals/DAT_TextInputDefinedData.hpp"
#include "OpenSHC/Globals/DAT_TextManagerObject.hpp"
#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp"
#include "OpenSHC/Globals/GMTotalPicturesProcessed.hpp"

namespace OpenSHC {
namespace Text {

// FUNCTION: STRONGHOLDCRUSADER 0x00473640
int FontSizeClass::renderCharUnk(byte charId, int xPos, int yPosUnk, int bgr24, int blendStrengthUnk)
{
int _xPos = xPos;
int _yPos = yPosUnk;

Rendering::Enums::RenderTarget renderTargetTemp
= (Rendering::Enums::RenderTarget)DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue;

Rendering::Colors::RGB15 const _fillColorUnk
= MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::transformBGR24ToScreenColor,
DAT_TextureRenderCoreObject::ptr)(bgr24);
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = DAT_TextManagerObject::instance.textSurfaceTarget;

if (this->fontStartImageId_0x8 == -1) {
this->fontStartImageId_0x8
= GMTotalPicturesProcessed::instance[this->fontGmID_0x0] + this->numberOfFontStartInGm_0x4 - 1;
}

int imageSeqID
= DAT_TextInputDefinedData::instance
.CharToImageSeqIDMapping[DAT_TextManagerObject::instance.alternativeCodePageUsedUnk][charId];

if (_xPos + this->whiteSpaceWidth_0x1c * 5 > DAT_TextManagerObject::instance.field2_0x8
&& _xPos < DAT_TextManagerObject::instance.field3_0xc) {

if (imageSeqID == -1) {
if (charId >= ' ') {
if (DAT_TextManagerObject::instance.field6_0x18 != 0) {
MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)(
_xPos, this->baselineOffset_0x10 + 2 + _yPos, this->whiteSpaceWidth_0x1c + _xPos,
this->baselineOffset_0x10 + 2 + _yPos, _fillColorUnk);
}
_xPos += this->whiteSpaceWidth_0x1c;
}
} else {
imageSeqID += this->fontStartImageId_0x8;
MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderTextChar,
DAT_TextureRenderCoreObject::ptr)(_xPos, _yPos + this->baselineOffset_0x10, imageSeqID,
(FontRenderType)this->renderType_0xc, this->lineHeight_0x14, _fillColorUnk, blendStrengthUnk);
_xPos += DAT_GMImageHeaders::instance.imh[imageSeqID].width + this->letterSpacing_0x18
+ DAT_TextureRenderCoreObject::instance.mbr_0x6c;
}
} else {
if (imageSeqID == -1) {
if (charId >= ' ') {
_xPos += this->whiteSpaceWidth_0x1c;
}
} else {
imageSeqID += this->fontStartImageId_0x8;
_xPos += DAT_GMImageHeaders::instance.imh[imageSeqID].width + this->letterSpacing_0x18;
}
}
DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = renderTargetTemp;
return _xPos;
}

}
}
Loading