From e80a044818714da480fe6f108f0439f67380fca6 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Sat, 17 Jan 2015 20:05:45 +0100 Subject: Fix use of uninit data in Sky and (potentially) GUIChatConsole constructors Clean up nearby code a bit As a small side effect, it is now possible to add a background texture to the chat console by simply providing background_chat.jpg, it is no longer necessary to also add "console_color =" to minetest.conf. --- src/guiChatConsole.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/guiChatConsole.cpp') diff --git a/src/guiChatConsole.cpp b/src/guiChatConsole.cpp index 918f9528b..19d9e3007 100644 --- a/src/guiChatConsole.cpp +++ b/src/guiChatConsole.cpp @@ -72,25 +72,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); -- cgit v1.2.3