@@ -54,10 +54,16 @@ void GameUI::init()
54
54
m_guitext_info = gui::StaticText::add (guienv, L" " ,
55
55
core::rect<s32>(0 , 0 , 400 , g_fontengine->getTextHeight () * 5 + 5 )
56
56
+ v2s32 (100 , 200 ), false , true , guiroot);
57
+
58
+ // Status text (displays info when showing and hiding GUI stuff, etc.)
59
+ m_guitext_status = gui::StaticText::add (guienv, L" <Status>" ,
60
+ core::rect<s32>(0 , 0 , 0 , 0 ), false , false , guiroot);
61
+
62
+ m_guitext_status->setVisible (false );
57
63
}
58
64
59
65
void GameUI::update (const RunStats &stats, Client *client, MapDrawControl *draw_control,
60
- const CameraOrientation &cam, const PointedThing &pointed_old)
66
+ const CameraOrientation &cam, const PointedThing &pointed_old, float dtime )
61
67
{
62
68
v2u32 screensize = RenderingEngine::get_instance ()->getWindowSize ();
63
69
@@ -125,6 +131,44 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
125
131
126
132
setStaticText (m_guitext_info, translate_string (m_infotext).c_str ());
127
133
m_guitext_info->setVisible (m_flags.show_hud && g_menumgr.menuCount () == 0 );
134
+
135
+ static const float statustext_time_max = 1 .5f ;
136
+
137
+ if (!m_statustext.empty ()) {
138
+ m_statustext_time += dtime;
139
+
140
+ if (m_statustext_time >= statustext_time_max) {
141
+ clearStatusText ();
142
+ m_statustext_time = 0 .0f ;
143
+ }
144
+ }
145
+
146
+ setStaticText (m_guitext_status, translate_string (m_statustext).c_str ());
147
+ m_guitext_status->setVisible (!m_statustext.empty ());
148
+
149
+ if (!m_statustext.empty ()) {
150
+ s32 status_width = m_guitext_status->getTextWidth ();
151
+ s32 status_height = m_guitext_status->getTextHeight ();
152
+ s32 status_y = screensize.Y - 150 ;
153
+ s32 status_x = (screensize.X - status_width) / 2 ;
154
+
155
+ m_guitext_status->setRelativePosition (core::rect<s32>(status_x ,
156
+ status_y - status_height, status_x + status_width, status_y));
157
+
158
+ // Fade out
159
+ video::SColor initial_color (255 , 0 , 0 , 0 );
160
+
161
+ if (guienv->getSkin ())
162
+ initial_color = guienv->getSkin ()->getColor (gui::EGDC_BUTTON_TEXT);
163
+
164
+ video::SColor final_color = initial_color;
165
+ final_color.setAlpha (0 );
166
+ video::SColor fade_color = initial_color.getInterpolated_quadratic (
167
+ initial_color, final_color,
168
+ pow (m_statustext_time / statustext_time_max, 2 .0f ));
169
+ m_guitext_status->setOverrideColor (fade_color);
170
+ m_guitext_status->enableOverrideColor (true );
171
+ }
128
172
}
129
173
130
174
void GameUI::initFlags ()
0 commit comments