mirror of
https://github.com/minetest/minetest.git
synced 2025-01-10 23:37:29 +01: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
|
||||
void showOverlayMessage(const char *msg, float dtime, int percent,
|
||||
bool draw_clouds = true);
|
||||
float *indef_pos = nullptr);
|
||||
|
||||
inline bool fogEnabled()
|
||||
{
|
||||
@ -966,6 +966,8 @@ private:
|
||||
#ifdef __ANDROID__
|
||||
bool m_android_chat_open;
|
||||
#endif
|
||||
|
||||
float m_shutdown_progress = 0.0f;
|
||||
};
|
||||
|
||||
Game::Game() :
|
||||
@ -1245,7 +1247,9 @@ void Game::shutdown()
|
||||
if (g_touchscreengui)
|
||||
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)
|
||||
clouds->drop();
|
||||
@ -1297,7 +1301,7 @@ void Game::shutdown()
|
||||
m_rendering_engine->run();
|
||||
f32 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();
|
||||
@ -1429,7 +1433,7 @@ bool Game::createSingleplayerServer(const std::string &map_dir,
|
||||
if (success)
|
||||
showOverlayMessage(N_("Creating server..."), dtime, 5);
|
||||
else
|
||||
showOverlayMessage(N_("Shutting down..."), dtime, 0, false);
|
||||
showOverlayMessage(N_("Shutting down..."), dtime, 0, &m_shutdown_progress);
|
||||
}
|
||||
|
||||
start_thread->rethrow();
|
||||
@ -4366,10 +4370,10 @@ void Game::drawScene(ProfilerGraph *graph, RunStats *stats)
|
||||
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,
|
||||
dtime, percent, draw_sky);
|
||||
dtime, percent, indef_pos);
|
||||
}
|
||||
|
||||
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,
|
||||
gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime,
|
||||
int percent, bool sky)
|
||||
int percent, float *indef_pos)
|
||||
{
|
||||
v2u32 screensize = getWindowSize();
|
||||
|
||||
@ -322,18 +322,22 @@ void RenderingEngine::draw_load_screen(const std::wstring &text,
|
||||
|
||||
auto *driver = get_video_driver();
|
||||
|
||||
if (sky) {
|
||||
driver->beginScene(true, true, RenderingEngine::MENU_SKY_COLOR);
|
||||
if (g_settings->getBool("menu_clouds")) {
|
||||
g_menuclouds->step(dtime * 3);
|
||||
g_menucloudsmgr->drawAll();
|
||||
}
|
||||
} else {
|
||||
driver->beginScene(true, true, video::SColor(255, 0, 0, 0));
|
||||
driver->setFog(RenderingEngine::MENU_SKY_COLOR);
|
||||
driver->beginScene(true, true, RenderingEngine::MENU_SKY_COLOR);
|
||||
if (g_settings->getBool("menu_clouds")) {
|
||||
g_menuclouds->step(dtime * 3);
|
||||
g_menucloudsmgr->drawAll();
|
||||
}
|
||||
|
||||
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
|
||||
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_bg =
|
||||
tsrc->getTexture("progress_bar_bg.png");
|
||||
@ -364,11 +368,11 @@ void RenderingEngine::draw_load_screen(const std::wstring &text,
|
||||
0, 0, true);
|
||||
|
||||
draw2DImageFilterScaled(get_video_driver(), progress_img,
|
||||
core::rect<s32>(img_pos.X, img_pos.Y,
|
||||
img_pos.X + (percent * imgW) / 100,
|
||||
core::rect<s32>(img_pos.X + (percent_min * imgW) / 100, img_pos.Y,
|
||||
img_pos.X + (percent_max * imgW) / 100,
|
||||
img_pos.Y + imgH),
|
||||
core::rect<s32>(0, 0,
|
||||
(percent * img_size.Width) / 100,
|
||||
core::rect<s32>(percent_min * img_size.Width / 100, 0,
|
||||
percent_max * img_size.Width / 100,
|
||||
img_size.Height),
|
||||
0, 0, true);
|
||||
}
|
||||
|
@ -137,9 +137,11 @@ public:
|
||||
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,
|
||||
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,
|
||||
bool draw_wield_tool, bool draw_crosshair);
|
||||
|
Loading…
Reference in New Issue
Block a user