* Fix errors caused by #30

This commit is contained in:
iProgramInCpp
2023-08-06 12:59:46 +03:00
parent 9e9d2110e3
commit 2b105fe1eb
14 changed files with 137 additions and 90 deletions

View File

@@ -259,38 +259,10 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
#endif
// render messages
int topEdge = height - 49;
for (auto& msg : m_guiMessages)
if (m_bRenderMessages)
{
if (msg.field_18 > 199)
continue;
int bkgdColor = 0x7F000000, textColor = 0xFFFFFFFF;
float fade = 10.0f * (1.0f - (float(msg.field_18) / 200.0f));
if (fade <= 0.0f)
continue;
if (fade < 1.0f)
{
int x = int(fade * fade * 255.0f);
if (x == 0)
continue;
bkgdColor = (x / 2) << 24;
textColor = (x << 24) + 0xFFFFFF;
}
fill(2, topEdge, 322, topEdge + 9, bkgdColor);
glEnable(GL_BLEND);
m->m_pFont->drawShadow(msg.msg, 2, topEdge + 1, textColor);
topEdge -= 9;
renderMessages(false);
}
glDisable(GL_BLEND);
}
void Gui::tick()
@@ -414,3 +386,41 @@ void Gui::handleKeyPressed(int keyCode)
}
}
}
void Gui::renderMessages(bool bShowAll)
{
int width = Minecraft::width * InvGuiScale,
height = Minecraft::height * InvGuiScale;
int topEdge = height - 49;
for (auto& msg : m_guiMessages)
{
if (!bShowAll && msg.field_18 > 199)
continue;
int bkgdColor = 0x7F000000, textColor = 0xFFFFFFFF;
float fade = 10.0f * (1.0f - (float(msg.field_18) / 200.0f));
if (fade <= 0.0f)
continue;
if (fade < 1.0f)
{
int x = int(fade * fade * 255.0f);
if (x == 0)
continue;
bkgdColor = (x / 2) << 24;
textColor = (x << 24) + 0xFFFFFF;
}
fill(2, topEdge, 322, topEdge + 9, bkgdColor);
glEnable(GL_BLEND);
m_pMinecraft->m_pFont->drawShadow(msg.msg, 2, topEdge + 1, textColor);
topEdge -= 9;
}
glDisable(GL_BLEND);
}