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
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::singleWideCharToMultiByte, 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
Loading