forked from Mirrorlandia_minetest/minetest
GUI: Allow texture packs to customize the progress bar (#5368)
This commit is contained in:
parent
7a4878cd0b
commit
c9492b4d37
@ -76,6 +76,9 @@ by texture packs. All existing fallback textures can be found in the directory
|
|||||||
* `player.png`: front texture of the 2D upright sprite player
|
* `player.png`: front texture of the 2D upright sprite player
|
||||||
* `player_back.png`: back texture of the 2D upright sprite player
|
* `player_back.png`: back texture of the 2D upright sprite player
|
||||||
|
|
||||||
|
* `progress_bar.png`: foreground texture of the loading screen's progress bar
|
||||||
|
* `progress_bar_bg.png`: background texture of the loading screen's progress bar
|
||||||
|
|
||||||
* `moon.png`: texture of the moon. Default texture is generated by Minetest
|
* `moon.png`: texture of the moon. Default texture is generated by Minetest
|
||||||
* `moon_tonemap.png`: tonemap to be used when `moon.png` was found
|
* `moon_tonemap.png`: tonemap to be used when `moon.png` was found
|
||||||
* `sun.png`: texture of the sun. Default texture is generated by Minetest
|
* `sun.png`: texture of the sun. Default texture is generated by Minetest
|
||||||
|
@ -592,30 +592,51 @@ void draw_load_screen(const std::wstring &text, IrrlichtDevice* device,
|
|||||||
|
|
||||||
// draw progress bar
|
// draw progress bar
|
||||||
if ((percent >= 0) && (percent <= 100)) {
|
if ((percent >= 0) && (percent <= 100)) {
|
||||||
std::string gamepath = fs::RemoveRelativePathComponents(
|
const std::string &texture_path = g_settings->get("texture_path");
|
||||||
porting::path_share + DIR_DELIM + "textures");
|
std::string tp_progress_bar = texture_path + "/progress_bar.png";
|
||||||
video::ITexture *progress_img = driver->getTexture(
|
std::string tp_progress_bar_bg = texture_path + "/progress_bar_bg.png";
|
||||||
(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<u32> &img_size = progress_img_bg->getSize();
|
if (!(fs::PathExists(tp_progress_bar) &&
|
||||||
u32 imgW = MYMAX(208, img_size.Width);
|
fs::PathExists(tp_progress_bar_bg))) {
|
||||||
u32 imgH = MYMAX(24, img_size.Height);
|
std::string gamepath = fs::RemoveRelativePathComponents(
|
||||||
v2s32 img_pos((screensize.X - imgW) / 2, (screensize.Y - imgH) / 2);
|
porting::path_share + DIR_DELIM + "textures");
|
||||||
|
tp_progress_bar = gamepath + "/base/pack/progress_bar.png";
|
||||||
|
tp_progress_bar_bg = gamepath + "/base/pack/progress_bar_bg.png";
|
||||||
|
}
|
||||||
|
|
||||||
draw2DImageFilterScaled(
|
video::ITexture *progress_img =
|
||||||
driver, progress_img_bg,
|
driver->getTexture(tp_progress_bar.c_str());
|
||||||
core::rect<s32>(img_pos.X, img_pos.Y, img_pos.X + imgW, img_pos.Y + imgH),
|
video::ITexture *progress_img_bg =
|
||||||
core::rect<s32>(0, 0, img_size.Width, img_size.Height),
|
driver->getTexture(tp_progress_bar_bg.c_str());
|
||||||
0, 0, true);
|
|
||||||
|
|
||||||
draw2DImageFilterScaled(
|
if (progress_img && progress_img_bg) {
|
||||||
driver, progress_img,
|
const core::dimension2d<u32> &img_size = progress_img_bg->getSize();
|
||||||
core::rect<s32>(img_pos.X, img_pos.Y,
|
u32 imgW = rangelim(img_size.Width, 200, 600);
|
||||||
img_pos.X + (percent * imgW) / 100, img_pos.Y + imgH),
|
u32 imgH = rangelim(img_size.Height, 24, 72);
|
||||||
core::rect<s32>(0, 0, ((percent * img_size.Width) / 100), img_size.Height),
|
v2s32 img_pos((screensize.X - imgW) / 2, (screensize.Y - imgH) / 2);
|
||||||
0, 0, true);
|
|
||||||
|
draw2DImageFilterScaled(
|
||||||
|
driver, progress_img_bg,
|
||||||
|
core::rect<s32>(img_pos.X,
|
||||||
|
img_pos.Y,
|
||||||
|
img_pos.X + imgW,
|
||||||
|
img_pos.Y + imgH),
|
||||||
|
core::rect<s32>(0, 0,
|
||||||
|
img_size.Width,
|
||||||
|
img_size.Height),
|
||||||
|
0, 0, true);
|
||||||
|
|
||||||
|
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();
|
||||||
|
Loading…
Reference in New Issue
Block a user