Skip to content

Commit

Permalink
Fix mail subject fix if it's empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Enorovan committed Oct 15, 2024
1 parent 6b123f9 commit 2dcc765
Showing 1 changed file with 80 additions and 99 deletions.
179 changes: 80 additions & 99 deletions LanguageBarrier/GameText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ typedef int(__cdecl* DrawGlyphProc)(int textureId, float glyphInTextureStartX,
static DrawGlyphProc gameExeDrawGlyph = NULL; // = (DrawGlyphProc)0x42F950;
static DrawGlyphProc gameExeDrawGlyphReal = NULL;



typedef int(__cdecl* DrawLbpGlyphMaskProc)(
int textureId, int a2, float glyphInTextureStartX,
float glyphInTextureStartY, float glyphInTextureWidth,
Expand All @@ -201,10 +199,6 @@ static DrawLbpGlyphMaskProc gameExeDrawLbpGlyphMask =
NULL; // = (DrawGlyphProc)0x42F950;
static DrawLbpGlyphMaskProc gameExeDrawLbpGlyphMaskReal = NULL;





typedef unsigned int(__cdecl* Sg0DrawGlyph3Proc)(
int textureId, int maskTextureId, float textureStartX, float textureStartY,
float textureSizeX, float textureSizeY, float startPosX, float startPosY,
Expand Down Expand Up @@ -428,13 +422,8 @@ __declspec(naked) void tipsListWidthLookupHook() {
}
}





__declspec(naked) void gameExePhoneMouseFixHook() {

_asm {
_asm {
push ebx
mov ebx, [edx+6A88h]
mov ecx, [edx+6A8Ch]
Expand All @@ -452,11 +441,8 @@ __declspec(naked) void gameExePhoneMouseFixHook() {
jmp gameExePhoneMouseFixHookJmp2

}

}



__declspec(naked) void gameExePhoneMouseFix2Hook() {
_asm {
push ebx
Expand All @@ -472,13 +458,10 @@ __declspec(naked) void gameExePhoneMouseFix2Hook() {
skip:
pop ebx
jmp gameExePhoneMouseFixHookJmp3


}
}



__declspec(naked) void ccBacklogNamePosAdjustHook() {
__asm {
// copied code
Expand Down Expand Up @@ -795,7 +778,6 @@ void gameTextInit() {
(LPVOID)sg0DrawGlyphHook,
(LPVOID*)&gameExeDrawGlyphReal);


if (config["gamedef"]["drawGlyphVersion"].get<std::string>() == "sglbp") {
currentGame = SGLBP;
gameExeDrawLbpGlyphMask =
Expand Down Expand Up @@ -1200,14 +1182,13 @@ void gameTextInit() {
(uintptr_t)((uint8_t*)gameExePhoneMouseFix + jmp2);
}

if (signatures.count("phoneMouseFix2") == 1) {
if (signatures.count("phoneMouseFix2") == 1) {
int jmp1 = signatures["phoneMouseFix2"].value<int>("jmpOffset1", 0);

scanCreateEnableHook("game", "phoneMouseFix2", &gameExePhoneMouseFix,
gameExePhoneMouseFix2Hook, NULL);
gameExePhoneMouseFixHookJmp3 =
(uintptr_t)((uint8_t*)gameExePhoneMouseFix + jmp1);

}

if (signatures.count("getRineInputRectangle") == 1) {
Expand Down Expand Up @@ -1371,8 +1352,9 @@ int __cdecl dialogueLayoutRelatedHook(int unk0, int* unk1, int* unk2, int unk3,
uint32_t currentChar = \
page->glyphCol[i - 1] + \
page->glyphRow[i - 1] * TextRendering::Get().GLYPHS_PER_ROW; \
auto glyphInfo = TextRendering::Get().getFont(fontSize, false) \
-> getGlyphInfo(currentChar, Regular); \
auto glyphInfo = TextRendering::Get() \
.getFont(fontSize, false) \
->getGlyphInfo(currentChar, Regular); \
displayStartX += glyphInfo->advance; \
} else { \
displayStartX = \
Expand All @@ -1387,9 +1369,10 @@ int __cdecl dialogueLayoutRelatedHook(int unk0, int* unk1, int* unk2, int unk3,
page->glyphCol[i] + \
page->glyphRow[i] * TextRendering::Get().GLYPHS_PER_ROW; \
wchar_t cChar = TextRendering::Get().fullCharMap[currentChar]; \
const auto glyphInfo = TextRendering::Get().getFont( \
page->glyphDisplayHeight[i] * 1.5f, \
false) -> getGlyphInfo(currentChar, FontType::Outline); \
const auto glyphInfo = \
TextRendering::Get() \
.getFont(page->glyphDisplayHeight[i] * 1.5f, false) \
->getGlyphInfo(currentChar, FontType::Outline); \
displayStartY = (page->charDisplayY[i] + yOffset) * 1.5f; \
\
__int16 fontSize = page->glyphDisplayHeight[i] * 1.5f; \
Expand All @@ -1411,9 +1394,10 @@ int __cdecl dialogueLayoutRelatedHook(int unk0, int* unk1, int* unk2, int unk3,
uint32_t currentChar = \
page->glyphCol[i] + \
page->glyphRow[i] * TextRendering::Get().GLYPHS_PER_ROW; \
auto glyphInfo = TextRendering::Get().getFont( \
page->glyphDisplayHeight[i] * 1.5f, \
false) -> getGlyphInfo(currentChar, FontType::Regular); \
auto glyphInfo = \
TextRendering::Get() \
.getFont(page->glyphDisplayHeight[i] * 1.5f, false) \
->getGlyphInfo(currentChar, FontType::Regular); \
\
displayStartY = (page->charDisplayY[i] + yOffset) * 1.5f; \
float xRatio = ((float)page->glyphDisplayWidth[i] / \
Expand Down Expand Up @@ -2732,7 +2716,7 @@ int __cdecl sghdGetLinksFromSc3StringHook(int xOffset, int yOffset,
str.curLinkNumber, str.curColor, baseGlyphSize, NULL);

int j = 0;
;
;
for (int i = 0; i < str.length; i++) {
if (str.linkNumber[i] != NOT_A_LINK) {
result[j].linkNumber = str.linkNumber[i];
Expand All @@ -2756,7 +2740,6 @@ int __cdecl sghdDrawInteractiveMailHook(
int selectedLinkColor, int selectedLink) {
ProcessedSc3String_t str;


if (!lineLength) lineLength = DEFAULT_LINE_LENGTH;

std::list<StringWord_t> words;
Expand Down Expand Up @@ -2834,9 +2817,9 @@ int __cdecl getSc3StringLineCountHook(int lineLength, char* sc3string,
processSc3TokenList(0, 0, lineLength, words, LINECOUNT_DISABLE_OR_ERROR, 0,
baseGlyphSize, &str, true, 1.0f, -1, NOT_A_LINK, 0,
baseGlyphSize, NULL);
if (currentGame == SGLBP && lineLength == 254) return str.lines;


if (currentGame == SGLBP && lineLength == 254 && str.lines > 0)
return str.lines;
return str.lines + 1;
}
int __cdecl getRineInputRectangleHook(int* lineLength, char* text,
Expand Down Expand Up @@ -3072,11 +3055,8 @@ unsigned int sg0DrawGlyph3Hook(int textureId, int maskTextureId,
}

int setTipContentHook(char* sc3string) {



if (TextRendering::Get().enabled && currentGame!=SGLBP)
return gameExeSetTipContentReal(sc3string);
if (TextRendering::Get().enabled && currentGame != SGLBP)
return gameExeSetTipContentReal(sc3string);
tipContent = sc3string;
ProcessedSc3String_t str;

Expand All @@ -3096,12 +3076,10 @@ int setTipContentHook(char* sc3string) {
TIP_REIMPL_GLYPH_SIZE, &str, false, COORDS_MULTIPLIER, -1,
NOT_A_LINK, 0, TIP_REIMPL_GLYPH_SIZE * 1.5f, &mData);

auto scrollHeight = str.displayEndY[str.length - 1];

auto scrollHeight = str.displayEndY[str.length - 1];

if (currentGame == SGLBP)
return scrollHeight / 1.5f;
return scrollHeight;
if (currentGame == SGLBP) return scrollHeight / 1.5f;
return scrollHeight;
}

void drawReportContentHook(int textureId, int maskId, int a3, int a4,
Expand Down Expand Up @@ -3261,7 +3239,7 @@ void drawTipContentHook(int textureId, int maskId, int startX, int startY,
}
*/

if (!TextRendering::Get().enabled && currentGame !=SGLBP) {
if (!TextRendering::Get().enabled && currentGame != SGLBP) {
gameExeDrawTipContentReal(textureId, maskId, startX, startY, maskStartY,
maskHeight, a7, color, shadowColor, opacity);
return;
Expand All @@ -3282,64 +3260,67 @@ void drawTipContentHook(int textureId, int maskId, int startX, int startY,
TIP_REIMPL_GLYPH_SIZE, &str, false, COORDS_MULTIPLIER, -1,
NOT_A_LINK, color, TIP_REIMPL_GLYPH_SIZE * 1.5f, &mData);

if (TextRendering::Get().enabled) {


TextRendering::Get().replaceFontSurface(TIP_REIMPL_GLYPH_SIZE);
auto fontData = TextRendering::Get().getFont(TIP_REIMPL_GLYPH_SIZE, false);
maskHeight *= 1.5f;
for (int i = 0; i < str.length; i++) {
if (str.displayStartY[i] / COORDS_MULTIPLIER > maskStartY &&
str.displayEndY[i] / COORDS_MULTIPLIER <
(maskStartY + maskHeight) * 1.0f) {
auto glyphInfo = fontData->getGlyphInfo(str.glyph[i], FontType::Regular);

gameExeSg0DrawGlyph2(
TextRendering::Get().FONT_TEXTURE_ID, maskId, str.textureStartX[i],
str.textureStartY[i], str.textureWidth[i], str.textureHeight[i],
((float)str.displayStartX[i] + (1.0f * COORDS_MULTIPLIER)),
((float)str.displayStartY[i] + TIP_REIMPL_GLYPH_SIZE -
glyphInfo->top + (1.0f * COORDS_MULTIPLIER)),
((float)str.displayStartX[i] + (1.0f * COORDS_MULTIPLIER)),
((float)str.displayStartY[i] + TIP_REIMPL_GLYPH_SIZE -
glyphInfo->top + ((1.0f + (float)a7) * COORDS_MULTIPLIER)),
((float)str.displayEndX[i] + (1.0f * COORDS_MULTIPLIER)),
((float)str.displayEndY[i] + TIP_REIMPL_GLYPH_SIZE - glyphInfo->top +
((1.0f + (float)a7) * COORDS_MULTIPLIER)),
shadowColor, opacity, &dummy1, &dummy2);

gameExeSg0DrawGlyph2(
TextRendering::Get().FONT_TEXTURE_ID, maskId, str.textureStartX[i],
str.textureStartY[i], str.textureWidth[i], str.textureHeight[i],
str.displayStartX[i],
str.displayStartY[i] + TIP_REIMPL_GLYPH_SIZE - glyphInfo->top,
str.displayStartX[i],
((float)str.displayStartY[i] + TIP_REIMPL_GLYPH_SIZE -
glyphInfo->top + ((float)a7 * COORDS_MULTIPLIER)),
str.displayEndX[i],
((float)str.displayEndY[i] + TIP_REIMPL_GLYPH_SIZE - glyphInfo->top +
((float)a7 * COORDS_MULTIPLIER)),
str.color[i], opacity, &dummy1, &dummy2);
}
}
}
if (TextRendering::Get().enabled) {
if (TextRendering::Get().enabled) {
if (TextRendering::Get().enabled) {
TextRendering::Get().replaceFontSurface(TIP_REIMPL_GLYPH_SIZE);
auto fontData =
TextRendering::Get().getFont(TIP_REIMPL_GLYPH_SIZE, false);
maskHeight *= 1.5f;
for (int i = 0; i < str.length; i++) {
if (str.displayStartY[i] / COORDS_MULTIPLIER > maskStartY &&
str.displayEndY[i] / COORDS_MULTIPLIER <
(maskStartY + maskHeight) * 1.0f) {
auto glyphInfo =
fontData->getGlyphInfo(str.glyph[i], FontType::Regular);

gameExeSg0DrawGlyph2(
TextRendering::Get().FONT_TEXTURE_ID, maskId,
str.textureStartX[i], str.textureStartY[i], str.textureWidth[i],
str.textureHeight[i],
((float)str.displayStartX[i] + (1.0f * COORDS_MULTIPLIER)),
((float)str.displayStartY[i] + TIP_REIMPL_GLYPH_SIZE -
glyphInfo->top + (1.0f * COORDS_MULTIPLIER)),
((float)str.displayStartX[i] + (1.0f * COORDS_MULTIPLIER)),
((float)str.displayStartY[i] + TIP_REIMPL_GLYPH_SIZE -
glyphInfo->top + ((1.0f + (float)a7) * COORDS_MULTIPLIER)),
((float)str.displayEndX[i] + (1.0f * COORDS_MULTIPLIER)),
((float)str.displayEndY[i] + TIP_REIMPL_GLYPH_SIZE -
glyphInfo->top + ((1.0f + (float)a7) * COORDS_MULTIPLIER)),
shadowColor, opacity, &dummy1, &dummy2);

gameExeSg0DrawGlyph2(
TextRendering::Get().FONT_TEXTURE_ID, maskId,
str.textureStartX[i], str.textureStartY[i], str.textureWidth[i],
str.textureHeight[i], str.displayStartX[i],
str.displayStartY[i] + TIP_REIMPL_GLYPH_SIZE - glyphInfo->top,
str.displayStartX[i],
((float)str.displayStartY[i] + TIP_REIMPL_GLYPH_SIZE -
glyphInfo->top + ((float)a7 * COORDS_MULTIPLIER)),
str.displayEndX[i],
((float)str.displayEndY[i] + TIP_REIMPL_GLYPH_SIZE -
glyphInfo->top + ((float)a7 * COORDS_MULTIPLIER)),
str.color[i], opacity, &dummy1, &dummy2);
}
}
}

else {
maskHeight *= 1.5f;
for (int i = 0; i < str.length; i++) {
if (str.displayStartY[i] / COORDS_MULTIPLIER > maskStartY &&
str.displayEndY[i] / COORDS_MULTIPLIER <
(maskStartY + maskHeight) * 1.0f) {
sg0DrawGlyph3Hook(0x4F, maskId, str.textureStartX[i], str.textureStartY[i],
str.textureWidth[i], str.textureHeight[i],
str.displayStartX[i], str.displayStartY[i],
str.displayEndX[i], str.displayEndY[i], 0xFFFFFFFF,
opacity);
else {
maskHeight *= 1.5f;
for (int i = 0; i < str.length; i++) {
if (str.displayStartY[i] / COORDS_MULTIPLIER > maskStartY &&
str.displayEndY[i] / COORDS_MULTIPLIER <
(maskStartY + maskHeight) * 1.0f) {
sg0DrawGlyph3Hook(0x4F, maskId, str.textureStartX[i],
str.textureStartY[i], str.textureWidth[i],
str.textureHeight[i], str.displayStartX[i],
str.displayStartY[i], str.displayEndX[i],
str.displayEndY[i], 0xFFFFFFFF, opacity);
}
}
}
}

}

}
}
int drawSpriteHook(int textureId, float spriteX, float spriteY,
float spriteWidth, float spriteHeight, float displayX,
Expand Down

0 comments on commit 2dcc765

Please sign in to comment.