]> git.lizzy.rs Git - minetest.git/blobdiff - src/guiChatConsole.cpp
Make ClientInterface::statenames consistent with the state enum again
[minetest.git] / src / guiChatConsole.cpp
index 918f9528bab083ae05b9ae40ebc1c4271dd3d5a8..3937e405cc8dcb81c415c39d4abae47daa0e5dee 100644 (file)
@@ -24,13 +24,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "gettime.h"
 #include "keycode.h"
 #include "settings.h"
-#include "main.h"  // for g_settings
 #include "porting.h"
-#include "tile.h"
+#include "client/tile.h"
 #include "fontengine.h"
-#include <string>
-
+#include "log.h"
 #include "gettext.h"
+#include <string>
 
 #if USE_FREETYPE
 #include "xCGUITTFont.h"
@@ -72,25 +71,22 @@ GUIChatConsole::GUIChatConsole(
        m_animate_time_old = getTimeMs();
 
        // load background settings
-       bool console_color_set = !g_settings->get("console_color").empty();
        s32 console_alpha = g_settings->getS32("console_alpha");
+       m_background_color.setAlpha(clamp_u8(console_alpha));
 
        // load the background texture depending on settings
-       m_background_color.setAlpha(clamp_u8(console_alpha));
-       if (console_color_set)
-       {
+       ITextureSource *tsrc = client->getTextureSource();
+       if (tsrc->isKnownSourceImage("background_chat.jpg")) {
+               m_background = tsrc->getTexture("background_chat.jpg");
+               m_background_color.setRed(255);
+               m_background_color.setGreen(255);
+               m_background_color.setBlue(255);
+       } else {
                v3f console_color = g_settings->getV3F("console_color");
                m_background_color.setRed(clamp_u8(myround(console_color.X)));
                m_background_color.setGreen(clamp_u8(myround(console_color.Y)));
                m_background_color.setBlue(clamp_u8(myround(console_color.Z)));
        }
-       else
-       {
-               m_background = env->getVideoDriver()->getTexture(getTexturePath("background_chat.jpg").c_str());
-               m_background_color.setRed(255);
-               m_background_color.setGreen(255);
-               m_background_color.setBlue(255);
-       }
 
        m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono);
 
@@ -102,7 +98,7 @@ GUIChatConsole::GUIChatConsole(
        {
                core::dimension2d<u32> dim = m_font->getDimension(L"M");
                m_fontsize = v2u32(dim.Width, dim.Height);
-               dstream << "Font size: " << m_fontsize.X << " " << m_fontsize.Y << std::endl;
+               m_font->grab();
        }
        m_fontsize.X = MYMAX(m_fontsize.X, 1);
        m_fontsize.Y = MYMAX(m_fontsize.Y, 1);
@@ -112,7 +108,10 @@ GUIChatConsole::GUIChatConsole(
 }
 
 GUIChatConsole::~GUIChatConsole()
-{}
+{
+       if (m_font)
+               m_font->drop();
+}
 
 void GUIChatConsole::openConsole(f32 height)
 {