Don't recalculate statustext initial color everytime & review fixes
authorLoic Blot <loic.blot@unix-experience.fr>
Fri, 5 Jan 2018 18:39:06 +0000 (19:39 +0100)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Fri, 5 Jan 2018 19:59:30 +0000 (20:59 +0100)
src/client/gameui.cpp
src/client/gameui.h
src/game.cpp
src/gui/guiFormSpecMenu.cpp
src/irrlicht_changes/static_text.h
util/updatepo.sh

index 6f6d2c2a88dbae01ff4bd5b780f8e428aa67c1bd..84b6ef2d3872a37e558664e253d7a8f2f3bab3aa 100644 (file)
@@ -41,6 +41,14 @@ inline static const char *yawToDirectionString(int yaw)
        return direction[yaw];
 }
 
+GameUI::GameUI()
+{
+       if (guienv && guienv->getSkin())
+               m_statustext_initial_color = guienv->getSkin()->getColor(gui::EGDC_BUTTON_TEXT);
+       else
+               m_statustext_initial_color = video::SColor(255, 0, 0, 0);
+
+}
 void GameUI::init()
 {
        // First line of debug text
@@ -169,16 +177,10 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
                        status_y - status_height, status_x + status_width, status_y));
 
                // Fade out
-               video::SColor initial_color(255, 0, 0, 0);
-
-               if (guienv->getSkin())
-                       initial_color = guienv->getSkin()->getColor(gui::EGDC_BUTTON_TEXT);
-
-               video::SColor final_color = initial_color;
+               video::SColor final_color = m_statustext_initial_color;
                final_color.setAlpha(0);
-               video::SColor fade_color = initial_color.getInterpolated_quadratic(
-                       initial_color, final_color,
-                       pow(m_statustext_time / statustext_time_max, 2.0f));
+               video::SColor fade_color = m_statustext_initial_color.getInterpolated_quadratic(
+                       m_statustext_initial_color, final_color, m_statustext_time / statustext_time_max);
                m_guitext_status->setOverrideColor(fade_color);
                m_guitext_status->enableOverrideColor(true);
        }
@@ -244,7 +246,7 @@ void GameUI::updateProfiler()
                if (w < 400)
                        w = 400;
 
-               unsigned text_height = g_fontengine->getTextHeight();
+               u32 text_height = g_fontengine->getTextHeight();
 
                core::position2di upper_left, lower_right;
 
index ebb7842c4d18c950b6fd0ae534ef22ef16a3b53c..04946084e8e52bacdaf4c51f4db59cbf8b3e0bfe 100644 (file)
@@ -46,7 +46,7 @@ class GameUI
        friend class TestGameUI;
 
 public:
-       GameUI() = default;
+       GameUI();
        ~GameUI() = default;
 
        // Flags that can, or may, change during main game loop
@@ -100,10 +100,11 @@ private:
        gui::IGUIStaticText *m_guitext_status = nullptr;
        std::wstring m_statustext;
        float m_statustext_time = 0.0f;
+       video::SColor m_statustext_initial_color;
 
-       gui::IGUIStaticText *m_guitext_chat; // Chat text
+       gui::IGUIStaticText *m_guitext_chat = nullptr; // Chat text
 
-       gui::IGUIStaticText *m_guitext_profiler; // Profiler text
+       gui::IGUIStaticText *m_guitext_profiler = nullptr; // Profiler text
        u8 m_profiler_current_page = 0;
        const u8 m_profiler_max_page = 3;
 };
index 924ca8c47066ee799edead7897ce1286bd876654..1ab360d3cd711f29ba14f2abaeaae18ef704ecd0 100644 (file)
@@ -1277,7 +1277,7 @@ private:
        void updateChat(f32 dtime, const v2u32 &screensize);
        static const ClientEventHandler clientEventHandler[CLIENTEVENT_MAX];
 
-       InputHandler *input;
+       InputHandler *input = nullptr;
 
        Client *client = nullptr;
        Server *server = nullptr;
@@ -2669,9 +2669,9 @@ void Game::toggleFog()
 {
        m_flags.force_fog_off = !m_flags.force_fog_off;
        if (m_flags.force_fog_off)
-                       m_game_ui->showTranslatedStatusText("Fog disabled");
+               m_game_ui->showTranslatedStatusText("Fog disabled");
        else
-                       m_game_ui->showTranslatedStatusText("Fog enabled");
+               m_game_ui->showTranslatedStatusText("Fog enabled");
 }
 
 
@@ -2912,9 +2912,8 @@ inline void Game::step(f32 *dtime)
        if (can_be_and_is_paused) {     // This is for a singleplayer server
                *dtime = 0;             // No time passes
        } else {
-               if (server) {
+               if (server)
                        server->step(*dtime);
-               }
 
                client->step(*dtime);
        }
index 5926cca3a3364eae22fdcff4be2b16cb247af5ae..6ca4a2e16b0cef662dcd0f405270a499bfa18369 100644 (file)
@@ -2026,7 +2026,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
                assert(!m_tooltip_element);
                // Note: parent != this so that the tooltip isn't clipped by the menu rectangle
                m_tooltip_element = gui::StaticText::add(Environment, L"",
-                       core::rect<s32>(0,0,110,18));
+                       core::rect<s32>(0, 0, 110, 18));
                m_tooltip_element->enableOverrideColor(true);
                m_tooltip_element->setBackgroundColor(m_default_tooltip_bgcolor);
                m_tooltip_element->setDrawBackground(true);
index 6bb85bd6b1507e343424e18c04e1c7f14b7014a2..c95d5b95f8927b07ab6fd7ce497908d23d37fdf4 100644 (file)
@@ -92,7 +92,8 @@ namespace gui
                        s32 id = -1,
                        bool fillBackground = false)
                {
-                       return add(guienv, EnrichedString(text), rectangle, border, wordWrap, parent, id, fillBackground);
+                       return add(guienv, EnrichedString(text), rectangle, border, wordWrap, parent,
+                               id, fillBackground);
                }
 
                //! draws the element and its children
index 99cb38a0aaada542607f610e1d737cb5098048a3..84dfd3ddb0c5708869b420ade068ad3adfe5508e 100755 (executable)
@@ -57,7 +57,7 @@ xgettext --package-name=minetest \
        --keyword=fgettext_ne \
        --keyword=strgettext \
        --keyword=wstrgettext \
-       --keyword=showStatusTextSimple \
+       --keyword=showTranslatedStatusText \
        --output $potfile \
        --from-code=utf-8 \
        `find src/ -name '*.cpp' -o -name '*.h'` \