added public wrap for drawliteral for changing text shadow size, added yadjust for positioing the typechatbar

This commit is contained in:
KKNecmi 2026-03-07 08:24:00 +03:00
parent a03bfc8789
commit 4322cc49c7
4 changed files with 80 additions and 9 deletions

View file

@ -140,19 +140,80 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey)
void ChatScreen::render(int xm, int ym, float a)
{
fill(2, height - 14, width - 2, height - 2, 0x80000000);
int iPad = minecraft->player->GetXboxPad();
int uiSetting = app.GetGameSettings(iPad, eGameSetting_UISize);
float textScale = 0.6f;
int barTopOffset = 14;
int barBottomOffset = 2;
int textYOffset = 12;
int yAdjust = 0;
if (uiSetting == 0)
{
textScale = textScale * 1.5f;
barTopOffset = 10;
barBottomOffset = 0;
textYOffset = 8;
yAdjust = 50;
}
else if (uiSetting == 1)
{
textScale = textScale * 1.0f;
barTopOffset = 14;
barBottomOffset = 2;
textYOffset = 12;
yAdjust = 0;
}
else if (uiSetting == 2)
{
textScale = textScale * 0.75f;
barTopOffset = 18;
barBottomOffset = 4;
textYOffset = 16;
yAdjust = -50;
}
int barY = height - barTopOffset + yAdjust;
int barBottom = height - barBottomOffset + yAdjust;
int textY = height - textYOffset + yAdjust;
fill(2, barY, width - 2, barBottom, 0x80000000);
const wstring prefix = L"> ";
int x = 4;
drawString(font, prefix, x, height - 12, 0xe0e0e0);
drawString(font, prefix, x, textY, 0xe0e0e0);
x += font->width(prefix);
wstring beforeCursor = message.substr(0, cursorIndex);
wstring afterCursor = message.substr(cursorIndex);
drawStringLiteral(font, beforeCursor, x, height - 12, 0xe0e0e0);
x += font->widthLiteral(beforeCursor);
glPushMatrix();
glTranslatef((float)x, (float)textY, 0);
glScalef(textScale, textScale, 1.0f);
font->drawShadowLiteralCustom(beforeCursor, 0, 0, 0xe0e0e0, 0x000000);
glPopMatrix();
x += (int)(font->widthLiteral(beforeCursor) * textScale);
if (frame / 6 % 2 == 0)
drawString(font, L"_", x, height - 12, 0xe0e0e0);
x += font->width(L"_");
drawStringLiteral(font, afterCursor, x, height - 12, 0xe0e0e0);
{
glPushMatrix();
glTranslatef((float)x, (float)textY, 0);
glScalef(textScale, textScale, 1.0f);
font->drawShadowLiteralCustom(L"_", 0, 0, 0xe0e0e0, 0x000000);
glPopMatrix();
}
x += (int)(font->width(L"_") * textScale);
glPushMatrix();
glTranslatef((float)x, (float)textY, 0);
glScalef(textScale, textScale, 1.0f);
font->drawShadowLiteralCustom(afterCursor, 0, 0, 0xe0e0e0, 0x000000);
glPopMatrix();
Screen::render(xm, ym, a);
}

View file

@ -281,6 +281,11 @@ void Font::draw(const wstring& str, int x, int y, int color)
draw(str, x, y, color, false);
}
void Font::drawLiteralPublic(const wstring& str, int x, int y, int color)
{
drawLiteral(str, x, y, color);
}
wstring Font::reorderBidi(const wstring &str)
{
// 4J Not implemented

View file

@ -56,6 +56,7 @@ public:
void drawShadowLiteralCustom(const wstring& str, int x, int y, int color, int shadowColor); // custom shadow color
void drawShadowWordWrap(const wstring &str, int x, int y, int w, int color, int h); // 4J Added h param
void draw(const wstring &str, int x, int y, int color);
void drawLiteralPublic(const wstring& str, int x, int y, int color);
/**
* Reorders the string according to bidirectional levels. A bit expensive at
* the moment.

View file

@ -975,7 +975,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
int uiSetting = app.GetGameSettings(iPad, eGameSetting_UISize);
float scaleFactor = 1.0f;
float textScale = 0.6f;
float textScale = 0.65f;
int backgroundtop = 13;
if (uiSetting == 0)
@ -1030,7 +1030,11 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
glPushMatrix();
glTranslatef((float)(iSafezoneXHalf+4), (float)(y), 0);
glScalef(textScale, textScale, scaleFactor);
font->drawShadowLiteralCustom(msg, 0, 0, 0xffffff + (alpha << 24), 0x000000 + (alpha << 24));
glPushMatrix();
glScalef(1.0f, 1.0f, 1.0f);
font->drawLiteralPublic(msg, 2, 2, 0x000000 + (alpha / 2 << 24));
glPopMatrix();
font->drawLiteralPublic(msg, 0, 0, 0xffffff + (alpha << 24));
glPopMatrix();
}
}