mirror of
https://github.com/minetest/minetest.git
synced 2024-08-19 21:14:15 +02:00
Display background & moving progress bar on shutdown screen (#14597)
Co-authored-by: Gregor Parzefall <gregor.parzefall@posteo.de>
This commit is contained in:
parent
36d236c5e0
commit
ab783b9bb2
@ -790,7 +790,7 @@ protected:
|
|||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
void showOverlayMessage(const char *msg, float dtime, int percent,
|
void showOverlayMessage(const char *msg, float dtime, int percent,
|
||||||
bool draw_clouds = true);
|
float *indef_pos = nullptr);
|
||||||
|
|
||||||
inline bool fogEnabled()
|
inline bool fogEnabled()
|
||||||
{
|
{
|
||||||
@ -966,6 +966,8 @@ private:
|
|||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
bool m_android_chat_open;
|
bool m_android_chat_open;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
float m_shutdown_progress = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
Game::Game() :
|
Game::Game() :
|
||||||
@ -1245,7 +1247,9 @@ void Game::shutdown()
|
|||||||
if (g_touchscreengui)
|
if (g_touchscreengui)
|
||||||
g_touchscreengui->hide();
|
g_touchscreengui->hide();
|
||||||
|
|
||||||
showOverlayMessage(N_("Shutting down..."), 0, 0, false);
|
// only if the shutdown progress bar isn't shown yet
|
||||||
|
if (m_shutdown_progress == 0.0f)
|
||||||
|
showOverlayMessage(N_("Shutting down..."), 0, 0);
|
||||||
|
|
||||||
if (clouds)
|
if (clouds)
|
||||||
clouds->drop();
|
clouds->drop();
|
||||||
@ -1297,7 +1301,7 @@ void Game::shutdown()
|
|||||||
m_rendering_engine->run();
|
m_rendering_engine->run();
|
||||||
f32 dtime;
|
f32 dtime;
|
||||||
fps_control.limit(device, &dtime);
|
fps_control.limit(device, &dtime);
|
||||||
showOverlayMessage(N_("Shutting down..."), dtime, 0, false);
|
showOverlayMessage(N_("Shutting down..."), dtime, 0, &m_shutdown_progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_thread->rethrow();
|
stop_thread->rethrow();
|
||||||
@ -1429,7 +1433,7 @@ bool Game::createSingleplayerServer(const std::string &map_dir,
|
|||||||
if (success)
|
if (success)
|
||||||
showOverlayMessage(N_("Creating server..."), dtime, 5);
|
showOverlayMessage(N_("Creating server..."), dtime, 5);
|
||||||
else
|
else
|
||||||
showOverlayMessage(N_("Shutting down..."), dtime, 0, false);
|
showOverlayMessage(N_("Shutting down..."), dtime, 0, &m_shutdown_progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
start_thread->rethrow();
|
start_thread->rethrow();
|
||||||
@ -4366,10 +4370,10 @@ void Game::drawScene(ProfilerGraph *graph, RunStats *stats)
|
|||||||
Misc
|
Misc
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void Game::showOverlayMessage(const char *msg, float dtime, int percent, bool draw_sky)
|
void Game::showOverlayMessage(const char *msg, float dtime, int percent, float *indef_pos)
|
||||||
{
|
{
|
||||||
m_rendering_engine->draw_load_screen(wstrgettext(msg), guienv, texture_src,
|
m_rendering_engine->draw_load_screen(wstrgettext(msg), guienv, texture_src,
|
||||||
dtime, percent, draw_sky);
|
dtime, percent, indef_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::settingChangedCallback(const std::string &setting_name, void *data)
|
void Game::settingChangedCallback(const std::string &setting_name, void *data)
|
||||||
|
@ -308,7 +308,7 @@ bool RenderingEngine::setWindowIcon()
|
|||||||
*/
|
*/
|
||||||
void RenderingEngine::draw_load_screen(const std::wstring &text,
|
void RenderingEngine::draw_load_screen(const std::wstring &text,
|
||||||
gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime,
|
gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime,
|
||||||
int percent, bool sky)
|
int percent, float *indef_pos)
|
||||||
{
|
{
|
||||||
v2u32 screensize = getWindowSize();
|
v2u32 screensize = getWindowSize();
|
||||||
|
|
||||||
@ -322,18 +322,22 @@ void RenderingEngine::draw_load_screen(const std::wstring &text,
|
|||||||
|
|
||||||
auto *driver = get_video_driver();
|
auto *driver = get_video_driver();
|
||||||
|
|
||||||
if (sky) {
|
driver->setFog(RenderingEngine::MENU_SKY_COLOR);
|
||||||
driver->beginScene(true, true, RenderingEngine::MENU_SKY_COLOR);
|
driver->beginScene(true, true, RenderingEngine::MENU_SKY_COLOR);
|
||||||
if (g_settings->getBool("menu_clouds")) {
|
if (g_settings->getBool("menu_clouds")) {
|
||||||
g_menuclouds->step(dtime * 3);
|
g_menuclouds->step(dtime * 3);
|
||||||
g_menucloudsmgr->drawAll();
|
g_menucloudsmgr->drawAll();
|
||||||
}
|
|
||||||
} else {
|
|
||||||
driver->beginScene(true, true, video::SColor(255, 0, 0, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int percent_min = 0;
|
||||||
|
int percent_max = percent;
|
||||||
|
if (indef_pos) {
|
||||||
|
*indef_pos = fmodf(*indef_pos + (dtime * 50.0f), 140.0f);
|
||||||
|
percent_max = std::min((int) *indef_pos, 100);
|
||||||
|
percent_min = std::max((int) *indef_pos - 40, 0);
|
||||||
|
}
|
||||||
// draw progress bar
|
// draw progress bar
|
||||||
if ((percent >= 0) && (percent <= 100)) {
|
if ((percent_min >= 0) && (percent_max <= 100)) {
|
||||||
video::ITexture *progress_img = tsrc->getTexture("progress_bar.png");
|
video::ITexture *progress_img = tsrc->getTexture("progress_bar.png");
|
||||||
video::ITexture *progress_img_bg =
|
video::ITexture *progress_img_bg =
|
||||||
tsrc->getTexture("progress_bar_bg.png");
|
tsrc->getTexture("progress_bar_bg.png");
|
||||||
@ -364,11 +368,11 @@ void RenderingEngine::draw_load_screen(const std::wstring &text,
|
|||||||
0, 0, true);
|
0, 0, true);
|
||||||
|
|
||||||
draw2DImageFilterScaled(get_video_driver(), progress_img,
|
draw2DImageFilterScaled(get_video_driver(), progress_img,
|
||||||
core::rect<s32>(img_pos.X, img_pos.Y,
|
core::rect<s32>(img_pos.X + (percent_min * imgW) / 100, img_pos.Y,
|
||||||
img_pos.X + (percent * imgW) / 100,
|
img_pos.X + (percent_max * imgW) / 100,
|
||||||
img_pos.Y + imgH),
|
img_pos.Y + imgH),
|
||||||
core::rect<s32>(0, 0,
|
core::rect<s32>(percent_min * img_size.Width / 100, 0,
|
||||||
(percent * img_size.Width) / 100,
|
percent_max * img_size.Width / 100,
|
||||||
img_size.Height),
|
img_size.Height),
|
||||||
0, 0, true);
|
0, 0, true);
|
||||||
}
|
}
|
||||||
|
@ -137,9 +137,11 @@ public:
|
|||||||
return m_device->getGUIEnvironment();
|
return m_device->getGUIEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If "indef_pos" is given, the value of "percent" is ignored and an indefinite
|
||||||
|
// progress bar is drawn.
|
||||||
void draw_load_screen(const std::wstring &text,
|
void draw_load_screen(const std::wstring &text,
|
||||||
gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
|
gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
|
||||||
float dtime = 0, int percent = 0, bool sky = true);
|
float dtime = 0, int percent = 0, float *indef_pos = nullptr);
|
||||||
|
|
||||||
void draw_scene(video::SColor skycolor, bool show_hud,
|
void draw_scene(video::SColor skycolor, bool show_hud,
|
||||||
bool draw_wield_tool, bool draw_crosshair);
|
bool draw_wield_tool, bool draw_crosshair);
|
||||||
|
Loading…
Reference in New Issue
Block a user