#include "guiEngine.h"
+#include <IGUIStaticText.h>
+#include <ICameraSceneNode.h>
#include "scripting_mainmenu.h"
+#include "util/numeric.h"
#include "config.h"
#include "version.h"
#include "porting.h"
#include "sound_openal.h"
#include "clouds.h"
#include "httpfetch.h"
-#include "util/numeric.h"
+#include "log.h"
+#include "fontengine.h"
+
+#ifdef __ANDROID__
+#include "tile.h"
+#include <GLES/gl.h>
+#endif
-#include <IGUIStaticText.h>
-#include <ICameraSceneNode.h>
/******************************************************************************/
/** TextDestGuiEngine */
if(name.empty())
return NULL;
m_to_delete.insert(name);
+
+#ifdef __ANDROID__
+ video::IImage *image = m_driver->createImageFromFile(name.c_str());
+ if (image) {
+ image = Align2Npot2(image, m_driver);
+ video::ITexture* retval = m_driver->addTexture(name.c_str(), image);
+ image->drop();
+ return retval;
+ }
+#endif
return m_driver->getTexture(name.c_str());
}
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, g_fontengine->getTextWidth(t), g_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
}
m_menu->quitMenu();
- m_menu->remove();
- delete m_menu;
+ m_menu->drop();
m_menu = NULL;
}
cloudInit();
- while(m_device->run() && (!m_startgame) && (!m_kill)) {
+ unsigned int text_height = g_fontengine->getTextHeight();
+
+ while(m_device->run() && (!m_startgame) && (!m_kill))
+ {
+ //check if we need to update the "upper left corner"-text
+ if (text_height != g_fontengine->getTextHeight()) {
+ updateTopLeftTextSize();
+ text_height = g_fontengine->getTextHeight();
+ }
+
driver->beginScene(true, true, video::SColor(255,140,186,250));
if (m_clouds_enabled)
sleep_ms(25);
m_script->step();
+
+#ifdef __ANDROID__
+ m_menu->getAndroidUIInput();
+#endif
}
}
{
float fps_max = g_settings->getFloat("fps_max");
// Time of frame without fps limit
- float busytime;
u32 busytime_u32;
+
// not using getRealTime is necessary for wine
u32 time = m_device->getTimer()->getTime();
if(time > m_cloud.lasttime)
busytime_u32 = time - m_cloud.lasttime;
else
busytime_u32 = 0;
- busytime = busytime_u32 / 1000.0;
// FPS limiter
u32 frametime_min = 1000./fps_max;
}
/******************************************************************************/
-bool GUIEngine::downloadFile(std::string url,std::string target)
+bool GUIEngine::downloadFile(std::string url, std::string target)
{
#if USE_CURL
- std::ofstream targetfile(target.c_str(), std::ios::out | std::ios::binary);
+ std::ofstream target_file(target.c_str(), std::ios::out | std::ios::binary);
- if (!targetfile.good()) {
+ if (!target_file.good()) {
return false;
}
- HTTPFetchRequest fetchrequest;
- HTTPFetchResult fetchresult;
- fetchrequest.url = url;
- fetchrequest.caller = HTTPFETCH_SYNC;
- fetchrequest.timeout = g_settings->getS32("curl_file_download_timeout");
- httpfetch_sync(fetchrequest, fetchresult);
+ HTTPFetchRequest fetch_request;
+ HTTPFetchResult fetch_result;
+ fetch_request.url = url;
+ fetch_request.caller = HTTPFETCH_SYNC;
+ fetch_request.timeout = g_settings->getS32("curl_file_download_timeout");
+ httpfetch_sync(fetch_request, fetch_result);
- if (fetchresult.succeeded) {
- targetfile << fetchresult.data;
- } else {
+ if (!fetch_result.succeeded) {
return false;
}
+ target_file << fetch_result.data;
return true;
#else
/******************************************************************************/
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, g_fontengine->getTextWidth(text), g_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);
}
/******************************************************************************/