aboutsummaryrefslogtreecommitdiff
path: root/src/guiEngine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/guiEngine.cpp')
-rw-r--r--src/guiEngine.cpp49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp
index e53b52b01..e941003fa 100644
--- a/src/guiEngine.cpp
+++ b/src/guiEngine.cpp
@@ -35,6 +35,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "clouds.h"
#include "httpfetch.h"
#include "log.h"
+#include "fontengine.h"
+
#ifdef __ANDROID__
#include "tile.h"
#include <GLES/gl.h>
@@ -169,12 +171,14 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
m_sound_manager = &dummySoundManager;
//create topleft header
- core::rect<s32> rect(0, 0, 500, 20);
+ std::wstring t = narrow_to_wide(std::string("Minetest ") +
+ minetest_version_hash);
+
+ core::rect<s32> rect(0, 0, glb_fontengine->getTextWidth(t), glb_fontengine->getTextHeight());
rect += v2s32(4, 0);
- std::string t = std::string("Minetest ") + minetest_version_hash;
m_irr_toplefttext =
- m_device->getGUIEnvironment()->addStaticText(narrow_to_wide(t).c_str(),
+ m_device->getGUIEnvironment()->addStaticText(t.c_str(),
rect,false,true,0,-1);
//create formspecsource
@@ -256,7 +260,16 @@ void GUIEngine::run()
cloudInit();
- while(m_device->run() && (!m_startgame) && (!m_kill)) {
+ unsigned int text_height = glb_fontengine->getTextHeight();
+
+ while(m_device->run() && (!m_startgame) && (!m_kill))
+ {
+ //check if we need to update the "upper left corner"-text
+ if (text_height != glb_fontengine->getTextHeight()) {
+ updateTopLeftTextSize();
+ text_height = glb_fontengine->getTextHeight();
+ }
+
driver->beginScene(true, true, video::SColor(255,140,186,250));
if (m_clouds_enabled)
@@ -558,14 +571,32 @@ bool GUIEngine::downloadFile(std::string url, std::string target)
/******************************************************************************/
void GUIEngine::setTopleftText(std::string append)
{
- std::string toset = std::string("Minetest ") + minetest_version_hash;
+ std::wstring toset = narrow_to_wide( std::string("Minetest ") +
+ minetest_version_hash);
- if (append != "") {
- toset += " / ";
- toset += append;
+ if (append != "")
+ {
+ toset += L" / ";
+ toset += narrow_to_wide(append);
}
- m_irr_toplefttext->setText(narrow_to_wide(toset).c_str());
+ m_irr_toplefttext->setText(toset.c_str());
+
+ updateTopLeftTextSize();
+}
+
+/******************************************************************************/
+void GUIEngine::updateTopLeftTextSize()
+{
+ std::wstring text = m_irr_toplefttext->getText();
+
+ core::rect<s32> rect(0, 0, glb_fontengine->getTextWidth(text), glb_fontengine->getTextHeight());
+ rect += v2s32(4, 0);
+
+ m_irr_toplefttext->remove();
+ m_irr_toplefttext =
+ m_device->getGUIEnvironment()->addStaticText(text.c_str(),
+ rect,false,true,0,-1);
}
/******************************************************************************/