mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-23 08:08:47 -05:00
Make debug text adjust it's border to the screensize and fix a border update bug
This commit is contained in:
parent
65016c880c
commit
088b18da3d
29
src/game.cpp
29
src/game.cpp
@ -1099,8 +1099,6 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
|
|||||||
// Calculate text height using the font
|
// Calculate text height using the font
|
||||||
u32 text_height = font->getDimension(L"Random test string").Height;
|
u32 text_height = font->getDimension(L"Random test string").Height;
|
||||||
|
|
||||||
v2u32 screensize = driver->getScreenSize();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Draw "Loading" screen
|
Draw "Loading" screen
|
||||||
*/
|
*/
|
||||||
@ -1536,12 +1534,12 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
|
|||||||
// First line of debug text
|
// First line of debug text
|
||||||
gui::IGUIStaticText *guitext = guienv->addStaticText(
|
gui::IGUIStaticText *guitext = guienv->addStaticText(
|
||||||
L"Minetest",
|
L"Minetest",
|
||||||
core::rect<s32>(5, 5, 795, 5+text_height),
|
core::rect<s32>(0, 0, 0, 0),
|
||||||
false, false);
|
false, false);
|
||||||
// Second line of debug text
|
// Second line of debug text
|
||||||
gui::IGUIStaticText *guitext2 = guienv->addStaticText(
|
gui::IGUIStaticText *guitext2 = guienv->addStaticText(
|
||||||
L"",
|
L"",
|
||||||
core::rect<s32>(5, 5+(text_height+5)*1, 795, (5+text_height)*2),
|
core::rect<s32>(0, 0, 0, 0),
|
||||||
false, false);
|
false, false);
|
||||||
// At the middle of the screen
|
// At the middle of the screen
|
||||||
// Object infos are shown in this
|
// Object infos are shown in this
|
||||||
@ -1677,6 +1675,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
|
|||||||
if(device->run() == false || kill == true)
|
if(device->run() == false || kill == true)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
v2u32 screensize = driver->getScreenSize();
|
||||||
|
|
||||||
// Time of frame without fps limit
|
// Time of frame without fps limit
|
||||||
float busytime;
|
float busytime;
|
||||||
u32 busytime_u32;
|
u32 busytime_u32;
|
||||||
@ -3220,7 +3220,18 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
|
|||||||
{
|
{
|
||||||
guitext->setVisible(false);
|
guitext->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (guitext->isVisible())
|
||||||
|
{
|
||||||
|
core::rect<s32> rect(
|
||||||
|
5,
|
||||||
|
5,
|
||||||
|
screensize.X,
|
||||||
|
5 + text_height
|
||||||
|
);
|
||||||
|
guitext->setRelativePosition(rect);
|
||||||
|
}
|
||||||
|
|
||||||
if(show_debug)
|
if(show_debug)
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios_base::binary);
|
std::ostringstream os(std::ios_base::binary);
|
||||||
@ -3233,6 +3244,14 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
|
|||||||
<<")";
|
<<")";
|
||||||
guitext2->setText(narrow_to_wide(os.str()).c_str());
|
guitext2->setText(narrow_to_wide(os.str()).c_str());
|
||||||
guitext2->setVisible(true);
|
guitext2->setVisible(true);
|
||||||
|
|
||||||
|
core::rect<s32> rect(
|
||||||
|
5,
|
||||||
|
5 + text_height,
|
||||||
|
screensize.X,
|
||||||
|
5 + (text_height * 2)
|
||||||
|
);
|
||||||
|
guitext2->setRelativePosition(rect);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user