mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Wrap debug text on screen (#12978)
This commit is contained in:
parent
d0a118f5b1
commit
38169db765
1 changed files with 13 additions and 11 deletions
|
@ -55,11 +55,11 @@ void GameUI::init()
|
||||||
{
|
{
|
||||||
// First line of debug text
|
// First line of debug text
|
||||||
m_guitext = gui::StaticText::add(guienv, utf8_to_wide(PROJECT_NAME_C).c_str(),
|
m_guitext = gui::StaticText::add(guienv, utf8_to_wide(PROJECT_NAME_C).c_str(),
|
||||||
core::rect<s32>(0, 0, 0, 0), false, false, guiroot);
|
core::rect<s32>(0, 0, 0, 0), false, true, guiroot);
|
||||||
|
|
||||||
// Second line of debug text
|
// Second line of debug text
|
||||||
m_guitext2 = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 0, 0), false,
|
m_guitext2 = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 0, 0), false,
|
||||||
false, guiroot);
|
true, guiroot);
|
||||||
|
|
||||||
// Chat text
|
// Chat text
|
||||||
m_guitext_chat = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 0, 0),
|
m_guitext_chat = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 0, 0),
|
||||||
|
@ -102,6 +102,8 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
|
||||||
{
|
{
|
||||||
v2u32 screensize = RenderingEngine::getWindowSize();
|
v2u32 screensize = RenderingEngine::getWindowSize();
|
||||||
|
|
||||||
|
s32 minimal_debug_height = 0;
|
||||||
|
|
||||||
// Minimal debug text must only contain info that can't give a gameplay advantage
|
// Minimal debug text must only contain info that can't give a gameplay advantage
|
||||||
if (m_flags.show_minimal_debug) {
|
if (m_flags.show_minimal_debug) {
|
||||||
const u16 fps = 1.0 / stats.dtime_jitter.avg;
|
const u16 fps = 1.0 / stats.dtime_jitter.avg;
|
||||||
|
@ -122,10 +124,12 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
|
||||||
<< (draw_control->range_all ? "All" : itos(draw_control->wanted_range))
|
<< (draw_control->range_all ? "All" : itos(draw_control->wanted_range))
|
||||||
<< std::setprecision(2)
|
<< std::setprecision(2)
|
||||||
<< " | RTT: " << (client->getRTT() * 1000.0f) << "ms";
|
<< " | RTT: " << (client->getRTT() * 1000.0f) << "ms";
|
||||||
|
|
||||||
|
m_guitext->setRelativePosition(core::rect<s32>(5, 5, screensize.X, screensize.Y));
|
||||||
|
|
||||||
setStaticText(m_guitext, utf8_to_wide(os.str()).c_str());
|
setStaticText(m_guitext, utf8_to_wide(os.str()).c_str());
|
||||||
|
|
||||||
m_guitext->setRelativePosition(core::rect<s32>(5, 5, screensize.X,
|
minimal_debug_height = m_guitext->getTextHeight();
|
||||||
5 + g_fontengine->getTextHeight()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally set the guitext visible depending on the flag
|
// Finally set the guitext visible depending on the flag
|
||||||
|
@ -161,12 +165,10 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setStaticText(m_guitext2, utf8_to_wide(os.str()).c_str());
|
m_guitext2->setRelativePosition(core::rect<s32>(5, 5 + minimal_debug_height,
|
||||||
|
screensize.X, screensize.Y));
|
||||||
|
|
||||||
m_guitext2->setRelativePosition(core::rect<s32>(5,
|
setStaticText(m_guitext2, utf8_to_wide(os.str()).c_str());
|
||||||
5 + g_fontengine->getTextHeight(), screensize.X,
|
|
||||||
5 + g_fontengine->getTextHeight() * 2
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_guitext2->setVisible(m_flags.show_basic_debug);
|
m_guitext2->setVisible(m_flags.show_basic_debug);
|
||||||
|
@ -241,9 +243,9 @@ void GameUI::updateChatSize()
|
||||||
s32 chat_y = 5;
|
s32 chat_y = 5;
|
||||||
|
|
||||||
if (m_flags.show_minimal_debug)
|
if (m_flags.show_minimal_debug)
|
||||||
chat_y += g_fontengine->getLineHeight();
|
chat_y += m_guitext->getTextHeight();
|
||||||
if (m_flags.show_basic_debug)
|
if (m_flags.show_basic_debug)
|
||||||
chat_y += g_fontengine->getLineHeight();
|
chat_y += m_guitext2->getTextHeight();
|
||||||
|
|
||||||
const v2u32 &window_size = RenderingEngine::getWindowSize();
|
const v2u32 &window_size = RenderingEngine::getWindowSize();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue