summaryrefslogtreecommitdiff
path: root/src/drawscene.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-04-16 14:44:15 +0200
committerGitHub <noreply@github.com>2017-04-16 14:44:15 +0200
commit73de17afa821ccea84a119096b267e05a77db3ff (patch)
treeccb05343e11982058c8550533f6b54483be09474 /src/drawscene.cpp
parentd17636484dedab91b820667a82ec23cf6168ac7a (diff)
downloadminetest-73de17afa821ccea84a119096b267e05a77db3ff.tar.gz
minetest-73de17afa821ccea84a119096b267e05a77db3ff.tar.bz2
minetest-73de17afa821ccea84a119096b267e05a77db3ff.zip
Android progressbar fix (#5601)
* Fix progressbar for Android Fixes #5599 Fixed #5403 * draw_load_screen: use texturesource this permits to unify texture loading code * scale progress bar * Add gl version check for GL_OES_texture_npot. This fixed the texture on loading screen * Remove two sanity checks pointed by @celeron55 * sfan5 comments + android ratio fixes
Diffstat (limited to 'src/drawscene.cpp')
-rw-r--r--src/drawscene.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/drawscene.cpp b/src/drawscene.cpp
index 421b96f12..7d2d1d12f 100644
--- a/src/drawscene.cpp
+++ b/src/drawscene.cpp
@@ -599,7 +599,8 @@ void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr,
Additionally, a progressbar can be drawn when percent is set between 0 and 100.
*/
void draw_load_screen(const std::wstring &text, IrrlichtDevice* device,
- gui::IGUIEnvironment* guienv, float dtime, int percent, bool clouds )
+ gui::IGUIEnvironment* guienv, ITextureSource *tsrc,
+ float dtime, int percent, bool clouds)
{
video::IVideoDriver* driver = device->getVideoDriver();
v2u32 screensize = porting::getWindowSize();
@@ -625,27 +626,20 @@ void draw_load_screen(const std::wstring &text, IrrlichtDevice* device,
// draw progress bar
if ((percent >= 0) && (percent <= 100)) {
- const std::string &texture_path = g_settings->get("texture_path");
- std::string tp_progress_bar = texture_path + "/progress_bar.png";
- std::string tp_progress_bar_bg = texture_path + "/progress_bar_bg.png";
-
- if (!(fs::PathExists(tp_progress_bar) &&
- fs::PathExists(tp_progress_bar_bg))) {
- std::string gamepath = fs::RemoveRelativePathComponents(
- 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";
- }
-
- video::ITexture *progress_img =
- driver->getTexture(tp_progress_bar.c_str());
- video::ITexture *progress_img_bg =
- driver->getTexture(tp_progress_bar_bg.c_str());
+ video::ITexture *progress_img = tsrc->getTexture("progress_bar.png");
+ video::ITexture *progress_img_bg = tsrc->getTexture("progress_bar_bg.png");
if (progress_img && progress_img_bg) {
+#ifndef __ANDROID__
const core::dimension2d<u32> &img_size = progress_img_bg->getSize();
u32 imgW = rangelim(img_size.Width, 200, 600);
u32 imgH = rangelim(img_size.Height, 24, 72);
+#else
+ const core::dimension2d<u32> img_size(256, 48);
+ float imgRatio = (float) img_size.Height / img_size.Width;
+ u32 imgW = screensize.X / 2.2f;
+ u32 imgH = floor(imgW * imgRatio);
+#endif
v2s32 img_pos((screensize.X - imgW) / 2, (screensize.Y - imgH) / 2);
draw2DImageFilterScaled(