aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2018-01-05 19:39:06 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-01-05 20:59:30 +0100
commit9146c6a50fdf81196bab3d517b8313fb4fa3bc71 (patch)
treedad709901c6840812401dc6f0db1d356a4ef4866 /src/client
parentf40f4143dfbbaadaabcdbd5243412d389a9d29fb (diff)
downloadminetest-9146c6a50fdf81196bab3d517b8313fb4fa3bc71.tar.gz
minetest-9146c6a50fdf81196bab3d517b8313fb4fa3bc71.tar.bz2
minetest-9146c6a50fdf81196bab3d517b8313fb4fa3bc71.zip
Don't recalculate statustext initial color everytime & review fixes
Diffstat (limited to 'src/client')
-rw-r--r--src/client/gameui.cpp22
-rw-r--r--src/client/gameui.h7
2 files changed, 16 insertions, 13 deletions
diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp
index 6f6d2c2a8..84b6ef2d3 100644
--- a/src/client/gameui.cpp
+++ b/src/client/gameui.cpp
@@ -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;
diff --git a/src/client/gameui.h b/src/client/gameui.h
index ebb7842c4..04946084e 100644
--- a/src/client/gameui.h
+++ b/src/client/gameui.h
@@ -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;
};