mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Implement proper font handling
This commit is contained in:
parent
25945dc539
commit
dceb9f7d60
91 changed files with 902 additions and 194 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue