Don't recalculate statustext initial color everytime & review fixes

This commit is contained in:
Loic Blot 2018-01-05 19:39:06 +01:00 committed by Loïc Blot
parent f40f4143df
commit 9146c6a50f
6 changed files with 24 additions and 21 deletions

@ -41,6 +41,14 @@ inline static const char *yawToDirectionString(int yaw)
return direction[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() void GameUI::init()
{ {
// First line of debug text // 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)); status_y - status_height, status_x + status_width, status_y));
// Fade out // Fade out
video::SColor initial_color(255, 0, 0, 0); video::SColor final_color = m_statustext_initial_color;
if (guienv->getSkin())
initial_color = guienv->getSkin()->getColor(gui::EGDC_BUTTON_TEXT);
video::SColor final_color = initial_color;
final_color.setAlpha(0); final_color.setAlpha(0);
video::SColor fade_color = initial_color.getInterpolated_quadratic( video::SColor fade_color = m_statustext_initial_color.getInterpolated_quadratic(
initial_color, final_color, m_statustext_initial_color, final_color, m_statustext_time / statustext_time_max);
pow(m_statustext_time / statustext_time_max, 2.0f));
m_guitext_status->setOverrideColor(fade_color); m_guitext_status->setOverrideColor(fade_color);
m_guitext_status->enableOverrideColor(true); m_guitext_status->enableOverrideColor(true);
} }
@ -244,7 +246,7 @@ void GameUI::updateProfiler()
if (w < 400) if (w < 400)
w = 400; w = 400;
unsigned text_height = g_fontengine->getTextHeight(); u32 text_height = g_fontengine->getTextHeight();
core::position2di upper_left, lower_right; core::position2di upper_left, lower_right;

@ -46,7 +46,7 @@ class GameUI
friend class TestGameUI; friend class TestGameUI;
public: public:
GameUI() = default; GameUI();
~GameUI() = default; ~GameUI() = default;
// Flags that can, or may, change during main game loop // Flags that can, or may, change during main game loop
@ -100,10 +100,11 @@ private:
gui::IGUIStaticText *m_guitext_status = nullptr; gui::IGUIStaticText *m_guitext_status = nullptr;
std::wstring m_statustext; std::wstring m_statustext;
float m_statustext_time = 0.0f; 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; u8 m_profiler_current_page = 0;
const u8 m_profiler_max_page = 3; const u8 m_profiler_max_page = 3;
}; };

@ -1277,7 +1277,7 @@ private:
void updateChat(f32 dtime, const v2u32 &screensize); void updateChat(f32 dtime, const v2u32 &screensize);
static const ClientEventHandler clientEventHandler[CLIENTEVENT_MAX]; static const ClientEventHandler clientEventHandler[CLIENTEVENT_MAX];
InputHandler *input; InputHandler *input = nullptr;
Client *client = nullptr; Client *client = nullptr;
Server *server = nullptr; Server *server = nullptr;
@ -2912,9 +2912,8 @@ inline void Game::step(f32 *dtime)
if (can_be_and_is_paused) { // This is for a singleplayer server if (can_be_and_is_paused) { // This is for a singleplayer server
*dtime = 0; // No time passes *dtime = 0; // No time passes
} else { } else {
if (server) { if (server)
server->step(*dtime); server->step(*dtime);
}
client->step(*dtime); client->step(*dtime);
} }

@ -92,7 +92,8 @@ namespace gui
s32 id = -1, s32 id = -1,
bool fillBackground = false) 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 //! draws the element and its children

@ -57,7 +57,7 @@ xgettext --package-name=minetest \
--keyword=fgettext_ne \ --keyword=fgettext_ne \
--keyword=strgettext \ --keyword=strgettext \
--keyword=wstrgettext \ --keyword=wstrgettext \
--keyword=showStatusTextSimple \ --keyword=showTranslatedStatusText \
--output $potfile \ --output $potfile \
--from-code=utf-8 \ --from-code=utf-8 \
`find src/ -name '*.cpp' -o -name '*.h'` \ `find src/ -name '*.cpp' -o -name '*.h'` \