]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/guiEngine.cpp
Decoration API: Fix missing low density decorations
[dragonfireclient.git] / src / guiEngine.cpp
index dbb6fdf92396bdb0c5ba2927d5acc205012ba94a..84bc8488ea83f5cb0c2b34d32b4f8c7c59483265 100644 (file)
@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "guiEngine.h"
 
+#include <fstream>
 #include <IGUIStaticText.h>
 #include <ICameraSceneNode.h>
 #include "scripting_mainmenu.h"
@@ -27,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "version.h"
 #include "porting.h"
 #include "filesys.h"
-#include "main.h"
 #include "settings.h"
 #include "guiMainMenu.h"
 #include "sound.h"
@@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "httpfetch.h"
 #include "log.h"
 #include "fontengine.h"
+#include "guiscalingfilter.h"
 
 #ifdef __ANDROID__
 #include "client/tile.h"
@@ -52,7 +53,7 @@ TextDestGuiEngine::TextDestGuiEngine(GUIEngine* engine)
 }
 
 /******************************************************************************/
-void TextDestGuiEngine::gotText(std::map<std::string, std::string> fields)
+void TextDestGuiEngine::gotText(const StringMap &fields)
 {
        m_engine->getScriptIface()->handleMainMenuButtons(fields);
 }
@@ -60,7 +61,7 @@ void TextDestGuiEngine::gotText(std::map<std::string, std::string> fields)
 /******************************************************************************/
 void TextDestGuiEngine::gotText(std::wstring text)
 {
-       m_engine->getScriptIface()->handleMainMenuEvent(wide_to_narrow(text));
+       m_engine->getScriptIface()->handleMainMenuEvent(wide_to_utf8(text));
 }
 
 /******************************************************************************/
@@ -171,8 +172,8 @@ GUIEngine::GUIEngine(       irr::IrrlichtDevice* dev,
                m_sound_manager = &dummySoundManager;
 
        //create topleft header
-       std::wstring t = narrow_to_wide(std::string("Minetest ") +
-                       minetest_version_hash);
+       std::wstring t = utf8_to_wide(std::string(PROJECT_NAME_C " ") +
+                       g_version_hash);
 
        core::rect<s32> rect(0, 0, g_fontengine->getTextWidth(t), g_fontengine->getTextHeight());
        rect += v2s32(4, 0);
@@ -194,7 +195,8 @@ GUIEngine::GUIEngine(       irr::IrrlichtDevice* dev,
                        m_texture_source,
                        m_formspecgui,
                        m_buttonhandler,
-                       NULL);
+                       NULL,
+                       false);
 
        m_menu->allowClose(false);
        m_menu->lockSize(true,v2u32(800,600));
@@ -206,10 +208,8 @@ GUIEngine::GUIEngine(      irr::IrrlichtDevice* dev,
        m_script = new MainMenuScripting(this);
 
        try {
-               if (m_data->errormessage != "") {
-                       m_script->setMainMenuErrorMessage(m_data->errormessage);
-                       m_data->errormessage = "";
-               }
+               m_script->setMainMenuData(&m_data->script_data);
+               m_data->script_data.errormessage = "";
 
                if (!loadMainMenuScript()) {
                        errorstream << "No future without mainmenu" << std::endl;
@@ -217,10 +217,9 @@ GUIEngine::GUIEngine(      irr::IrrlichtDevice* dev,
                }
 
                run();
-       }
-       catch(LuaError &e) {
+       } catch (LuaError &e) {
                errorstream << "MAINMENU ERROR: " << e.what() << std::endl;
-               m_data->errormessage = e.what();
+               m_data->script_data.errormessage = e.what();
        }
 
        m_menu->quitMenu();
@@ -239,13 +238,13 @@ bool GUIEngine::loadMainMenuScript()
        }
 
        std::string script = porting::path_share + DIR_DELIM "builtin" + DIR_DELIM "init.lua";
-       if (m_script->loadScript(script)) {
+       try {
+               m_script->loadScript(script);
                // Menu script loaded
                return true;
-       } else {
-               infostream
-                       << "GUIEngine: execution of menu script in: \""
-                       << m_scriptdir << "\" failed!" << std::endl;
+       } catch (const ModError &e) {
+               errorstream << "GUIEngine: execution of menu script failed: "
+                       << e.what() << std::endl;
        }
 
        return false;
@@ -408,7 +407,7 @@ void GUIEngine::drawBackground(video::IVideoDriver* driver)
                {
                        for (unsigned int y = 0; y < screensize.Y; y += tilesize.Y )
                        {
-                               driver->draw2DImage(texture,
+                               draw2DImageFilterScaled(driver, texture,
                                        core::rect<s32>(x, y, x+tilesize.X, y+tilesize.Y),
                                        core::rect<s32>(0, 0, sourcesize.X, sourcesize.Y),
                                        NULL, NULL, true);
@@ -418,7 +417,7 @@ void GUIEngine::drawBackground(video::IVideoDriver* driver)
        }
 
        /* Draw background texture */
-       driver->draw2DImage(texture,
+       draw2DImageFilterScaled(driver, texture,
                core::rect<s32>(0, 0, screensize.X, screensize.Y),
                core::rect<s32>(0, 0, sourcesize.X, sourcesize.Y),
                NULL, NULL, true);
@@ -437,7 +436,7 @@ void GUIEngine::drawOverlay(video::IVideoDriver* driver)
 
        /* Draw background texture */
        v2u32 sourcesize = texture->getOriginalSize();
-       driver->draw2DImage(texture,
+       draw2DImageFilterScaled(driver, texture,
                core::rect<s32>(0, 0, screensize.X, screensize.Y),
                core::rect<s32>(0, 0, sourcesize.X, sourcesize.Y),
                NULL, NULL, true);
@@ -470,7 +469,7 @@ void GUIEngine::drawHeader(video::IVideoDriver* driver)
 
        video::SColor bgcolor(255,50,50,50);
 
-       driver->draw2DImage(texture, splashrect,
+       draw2DImageFilterScaled(driver, texture, splashrect,
                core::rect<s32>(core::position2d<s32>(0,0),
                core::dimension2di(texture->getOriginalSize())),
                NULL, NULL, true);
@@ -502,7 +501,7 @@ void GUIEngine::drawFooter(video::IVideoDriver* driver)
                rect += v2s32(screensize.Width/2,screensize.Height-footersize.Y);
                rect -= v2s32(footersize.X/2, 0);
 
-               driver->draw2DImage(texture, rect,
+               draw2DImageFilterScaled(driver, texture, rect,
                        core::rect<s32>(core::position2d<s32>(0,0),
                        core::dimension2di(texture->getOriginalSize())),
                        NULL, NULL, true);
@@ -570,13 +569,13 @@ bool GUIEngine::downloadFile(std::string url, std::string target)
 /******************************************************************************/
 void GUIEngine::setTopleftText(std::string append)
 {
-       std::wstring toset = narrow_to_wide( std::string("Minetest ") +
-                       minetest_version_hash);
+       std::wstring toset = utf8_to_wide(std::string(PROJECT_NAME_C " ") +
+               g_version_hash);
 
        if (append != "")
        {
                toset += L" / ";
-               toset += narrow_to_wide(append);
+               toset += utf8_to_wide(append);
        }
 
        m_irr_toplefttext->setText(toset.c_str());