summaryrefslogtreecommitdiff
path: root/src/guiEngine.cpp
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-11-23 13:40:43 +0100
committersapier <Sapier at GMX dot net>2014-11-30 17:50:09 +0100
commitdceb9f7d6058785cf60d9dbcc8eecdcee1053412 (patch)
tree0cbaa6969210d3e104f195ac5d3c2cabad8d6338 /src/guiEngine.cpp
parent25945dc5395a03cab069ff0e6470ba8d59b03978 (diff)
downloadminetest-dceb9f7d6058785cf60d9dbcc8eecdcee1053412.tar.gz
minetest-dceb9f7d6058785cf60d9dbcc8eecdcee1053412.tar.bz2
minetest-dceb9f7d6058785cf60d9dbcc8eecdcee1053412.zip
Implement proper font handling
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);
}
/******************************************************************************/