From 2baa191a64c4a0f4475bfd12540672dc99405f4f Mon Sep 17 00:00:00 2001 From: kilbith Date: Fri, 10 Mar 2017 13:26:24 +0100 Subject: [PATCH] GUI: Convert loading screen's progress bar to image (#5362) --- src/drawscene.cpp | 48 ++++++++++++++----------- textures/base/pack/progress_bar.png | Bin 0 -> 413 bytes textures/base/pack/progress_bar_bg.png | Bin 0 -> 354 bytes 3 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 textures/base/pack/progress_bar.png create mode 100644 textures/base/pack/progress_bar_bg.png diff --git a/src/drawscene.cpp b/src/drawscene.cpp index 32a078b8e..c4ef3cc51 100644 --- a/src/drawscene.cpp +++ b/src/drawscene.cpp @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/timetaker.h" #include "fontengine.h" #include "guiscalingfilter.h" +#include "filesys.h" typedef enum { LEFT = -1, @@ -590,30 +591,35 @@ void draw_load_screen(const std::wstring &text, IrrlichtDevice* device, driver->beginScene(true, true, video::SColor(255, 0, 0, 0)); // draw progress bar - if ((percent >= 0) && (percent <= 100)) - { - v2s32 barsize( - // 342 is (approximately) 256/0.75 to keep bar on same size as - // before with default settings - 342 * porting::getDisplayDensity() * - g_settings->getFloat("gui_scaling"), - g_fontengine->getTextHeight() * 2); - - core::rect barrect(center - barsize / 2, center + barsize / 2); - driver->draw2DRectangle(video::SColor(255, 255, 255, 255),barrect, NULL); // border - driver->draw2DRectangle(video::SColor(255, 64, 64, 64), core::rect ( - barrect.UpperLeftCorner + 1, - barrect.LowerRightCorner-1), NULL); // black inside the bar - driver->draw2DRectangle(video::SColor(255, 128, 128, 128), core::rect ( - barrect.UpperLeftCorner + 1, - core::vector2d( - barrect.LowerRightCorner.X - - (barsize.X - 1) + percent * (barsize.X - 2) / 100, - barrect.LowerRightCorner.Y - 1)), NULL); // the actual progress + if ((percent >= 0) && (percent <= 100)) { + std::string gamepath = fs::RemoveRelativePathComponents( + porting::path_share + DIR_DELIM + "textures"); + video::ITexture *progress_img = driver->getTexture( + (gamepath + "/base/pack/progress_bar.png").c_str()); + video::ITexture *progress_img_bg = driver->getTexture( + (gamepath + "/base/pack/progress_bar_bg.png").c_str()); + + const core::dimension2d &img_size = progress_img_bg->getSize(); + u32 imgW = MYMAX(208, img_size.Width); + u32 imgH = MYMAX(24, img_size.Height); + v2s32 img_pos((screensize.X - imgW) / 2, (screensize.Y - imgH) / 2); + + draw2DImageFilterScaled( + driver, progress_img_bg, + core::rect(img_pos.X, img_pos.Y, img_pos.X + imgW, img_pos.Y + imgH), + core::rect(0, 0, img_size.Width, img_size.Height), + 0, 0, true); + + draw2DImageFilterScaled( + driver, progress_img, + core::rect(img_pos.X, img_pos.Y, + img_pos.X + (percent * imgW) / 100, img_pos.Y + imgH), + core::rect(0, 0, ((percent * img_size.Width) / 100), img_size.Height), + 0, 0, true); } + guienv->drawAll(); driver->endScene(); - guitext->remove(); //return guitext; diff --git a/textures/base/pack/progress_bar.png b/textures/base/pack/progress_bar.png new file mode 100644 index 0000000000000000000000000000000000000000..e80367191644d95c36f28921bdd6b82c1f6ec421 GIT binary patch literal 413 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K53^>?;i(P=vF< zBeIx*fj<$18CTdZ&jbpxmw5WRvOi?z6z7s%{Uog#Xq1+xi(^Q|t+#g!vkoOlG(7y{ z`ax)^#)}76TmwEZ>}^jLJO7B)rfosBqbs{QJG*0y6~{WiT{~2oG#pLNe$JWbBmd;- zewO-9O=it#4G;N#EbUjKy+l-Mqya?^qZ(7&saP9SU2c zmX>~QTOap1#b<*5?SD2Fj6kPxFccJil|4{p>=|=?_1grW2O#AN3=Z$+GP2Lp`J^-9 RAt=}xJYD@<);T3K0RW6PjtT$( literal 0 HcmV?d00001 diff --git a/textures/base/pack/progress_bar_bg.png b/textures/base/pack/progress_bar_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..4e30ae889deb94fd1db1b65c03f2bf95ae33b5be GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K53^>?;i(P=vF< zBeIx*fj<$18CTdZ&jbpxmw5WRvOi?z6tgfa?K8Ot6ngLJ;uunK>+Ow=yiE=w4Tj!|prZOJ(kQ|M=W@p)__|>Wkx=%t@l# z;@+KMzog2bz~IpJ>H23o>m76CH(S?V4qL`D@z+Ow{Tm<`GcrsPJ+-Lpd3(t}PKba3 zlK_JQNQ#AlJjM@yjqa*Svs!zT+*B`tl?&y=@9*ISnkB%X5c%`dgDUH@?>O5378