GUI: Convert loading screen's progress bar to image (#5362)
parent
9878ce05e7
commit
2baa191a64
|
@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "util/timetaker.h"
|
#include "util/timetaker.h"
|
||||||
#include "fontengine.h"
|
#include "fontengine.h"
|
||||||
#include "guiscalingfilter.h"
|
#include "guiscalingfilter.h"
|
||||||
|
#include "filesys.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LEFT = -1,
|
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));
|
driver->beginScene(true, true, video::SColor(255, 0, 0, 0));
|
||||||
|
|
||||||
// draw progress bar
|
// draw progress bar
|
||||||
if ((percent >= 0) && (percent <= 100))
|
if ((percent >= 0) && (percent <= 100)) {
|
||||||
{
|
std::string gamepath = fs::RemoveRelativePathComponents(
|
||||||
v2s32 barsize(
|
porting::path_share + DIR_DELIM + "textures");
|
||||||
// 342 is (approximately) 256/0.75 to keep bar on same size as
|
video::ITexture *progress_img = driver->getTexture(
|
||||||
// before with default settings
|
(gamepath + "/base/pack/progress_bar.png").c_str());
|
||||||
342 * porting::getDisplayDensity() *
|
video::ITexture *progress_img_bg = driver->getTexture(
|
||||||
g_settings->getFloat("gui_scaling"),
|
(gamepath + "/base/pack/progress_bar_bg.png").c_str());
|
||||||
g_fontengine->getTextHeight() * 2);
|
|
||||||
|
|
||||||
core::rect<s32> barrect(center - barsize / 2, center + barsize / 2);
|
const core::dimension2d<u32> &img_size = progress_img_bg->getSize();
|
||||||
driver->draw2DRectangle(video::SColor(255, 255, 255, 255),barrect, NULL); // border
|
u32 imgW = MYMAX(208, img_size.Width);
|
||||||
driver->draw2DRectangle(video::SColor(255, 64, 64, 64), core::rect<s32> (
|
u32 imgH = MYMAX(24, img_size.Height);
|
||||||
barrect.UpperLeftCorner + 1,
|
v2s32 img_pos((screensize.X - imgW) / 2, (screensize.Y - imgH) / 2);
|
||||||
barrect.LowerRightCorner-1), NULL); // black inside the bar
|
|
||||||
driver->draw2DRectangle(video::SColor(255, 128, 128, 128), core::rect<s32> (
|
draw2DImageFilterScaled(
|
||||||
barrect.UpperLeftCorner + 1,
|
driver, progress_img_bg,
|
||||||
core::vector2d<s32>(
|
core::rect<s32>(img_pos.X, img_pos.Y, img_pos.X + imgW, img_pos.Y + imgH),
|
||||||
barrect.LowerRightCorner.X -
|
core::rect<s32>(0, 0, img_size.Width, img_size.Height),
|
||||||
(barsize.X - 1) + percent * (barsize.X - 2) / 100,
|
0, 0, true);
|
||||||
barrect.LowerRightCorner.Y - 1)), NULL); // the actual progress
|
|
||||||
|
draw2DImageFilterScaled(
|
||||||
|
driver, progress_img,
|
||||||
|
core::rect<s32>(img_pos.X, img_pos.Y,
|
||||||
|
img_pos.X + (percent * imgW) / 100, img_pos.Y + imgH),
|
||||||
|
core::rect<s32>(0, 0, ((percent * img_size.Width) / 100), img_size.Height),
|
||||||
|
0, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
guienv->drawAll();
|
guienv->drawAll();
|
||||||
driver->endScene();
|
driver->endScene();
|
||||||
|
|
||||||
guitext->remove();
|
guitext->remove();
|
||||||
|
|
||||||
//return guitext;
|
//return guitext;
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 413 B |
Binary file not shown.
After Width: | Height: | Size: 354 B |
Loading…
Reference in New Issue