Skip to content

Commit 2baa191

Browse files
kilbithnerzhul
authored andcommittedMar 10, 2017
GUI: Convert loading screen's progress bar to image (#5362)
1 parent 9878ce0 commit 2baa191

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed
 

Diff for: ‎src/drawscene.cpp

+27-21
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2424
#include "util/timetaker.h"
2525
#include "fontengine.h"
2626
#include "guiscalingfilter.h"
27+
#include "filesys.h"
2728

2829
typedef enum {
2930
LEFT = -1,
@@ -590,30 +591,35 @@ void draw_load_screen(const std::wstring &text, IrrlichtDevice* device,
590591
driver->beginScene(true, true, video::SColor(255, 0, 0, 0));
591592

592593
// draw progress bar
593-
if ((percent >= 0) && (percent <= 100))
594-
{
595-
v2s32 barsize(
596-
// 342 is (approximately) 256/0.75 to keep bar on same size as
597-
// before with default settings
598-
342 * porting::getDisplayDensity() *
599-
g_settings->getFloat("gui_scaling"),
600-
g_fontengine->getTextHeight() * 2);
601-
602-
core::rect<s32> barrect(center - barsize / 2, center + barsize / 2);
603-
driver->draw2DRectangle(video::SColor(255, 255, 255, 255),barrect, NULL); // border
604-
driver->draw2DRectangle(video::SColor(255, 64, 64, 64), core::rect<s32> (
605-
barrect.UpperLeftCorner + 1,
606-
barrect.LowerRightCorner-1), NULL); // black inside the bar
607-
driver->draw2DRectangle(video::SColor(255, 128, 128, 128), core::rect<s32> (
608-
barrect.UpperLeftCorner + 1,
609-
core::vector2d<s32>(
610-
barrect.LowerRightCorner.X -
611-
(barsize.X - 1) + percent * (barsize.X - 2) / 100,
612-
barrect.LowerRightCorner.Y - 1)), NULL); // the actual progress
594+
if ((percent >= 0) && (percent <= 100)) {
595+
std::string gamepath = fs::RemoveRelativePathComponents(
596+
porting::path_share + DIR_DELIM + "textures");
597+
video::ITexture *progress_img = driver->getTexture(
598+
(gamepath + "/base/pack/progress_bar.png").c_str());
599+
video::ITexture *progress_img_bg = driver->getTexture(
600+
(gamepath + "/base/pack/progress_bar_bg.png").c_str());
601+
602+
const core::dimension2d<u32> &img_size = progress_img_bg->getSize();
603+
u32 imgW = MYMAX(208, img_size.Width);
604+
u32 imgH = MYMAX(24, img_size.Height);
605+
v2s32 img_pos((screensize.X - imgW) / 2, (screensize.Y - imgH) / 2);
606+
607+
draw2DImageFilterScaled(
608+
driver, progress_img_bg,
609+
core::rect<s32>(img_pos.X, img_pos.Y, img_pos.X + imgW, img_pos.Y + imgH),
610+
core::rect<s32>(0, 0, img_size.Width, img_size.Height),
611+
0, 0, true);
612+
613+
draw2DImageFilterScaled(
614+
driver, progress_img,
615+
core::rect<s32>(img_pos.X, img_pos.Y,
616+
img_pos.X + (percent * imgW) / 100, img_pos.Y + imgH),
617+
core::rect<s32>(0, 0, ((percent * img_size.Width) / 100), img_size.Height),
618+
0, 0, true);
613619
}
620+
614621
guienv->drawAll();
615622
driver->endScene();
616-
617623
guitext->remove();
618624

619625
//return guitext;

Diff for: ‎textures/base/pack/progress_bar.png

413 Bytes
Loading

Diff for: ‎textures/base/pack/progress_bar_bg.png

354 Bytes
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.