diff options
author | stujones11 <stujones111@gmail.com> | 2018-11-18 10:31:19 +0000 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-11-18 11:31:19 +0100 |
commit | 3b112889892f6652d4e80d97e45131f179b1fbe4 (patch) | |
tree | 98033eb2cab0639aefc00244411dad94cb9d4c10 /src/client | |
parent | e5a37543cc7932f6252a086b4b8619b5dde9ae5a (diff) | |
download | minetest-3b112889892f6652d4e80d97e45131f179b1fbe4.tar.gz minetest-3b112889892f6652d4e80d97e45131f179b1fbe4.tar.bz2 minetest-3b112889892f6652d4e80d97e45131f179b1fbe4.zip |
Android: Improve UI scaling on smaller high-density displays (#7834)
* Android: Improve UI scaling on smaller high-density displays
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/clientlauncher.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index 85063ff86..0820177b4 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -38,6 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #if USE_SOUND #include "sound_openal.h" #endif +#ifdef __ANDROID__ + #include "porting.h" +#endif /* mainmenumanager.h */ @@ -127,7 +130,30 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args) skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0)); skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 120, 50)); skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255, 255, 255, 255)); - +#ifdef __ANDROID__ + float density = porting::getDisplayDensity(); + skin->setSize(gui::EGDS_CHECK_BOX_WIDTH, (s32)(17.0f * density)); + skin->setSize(gui::EGDS_SCROLLBAR_SIZE, (s32)(14.0f * density)); + skin->setSize(gui::EGDS_WINDOW_BUTTON_WIDTH, (s32)(15.0f * density)); + if (density > 1.5f) { + std::string sprite_path = porting::path_user + "/textures/base/pack/"; + if (density > 3.5f) + sprite_path.append("checkbox_64.png"); + else if (density > 2.0f) + sprite_path.append("checkbox_32.png"); + else + sprite_path.append("checkbox_16.png"); + // Texture dimensions should be a power of 2 + gui::IGUISpriteBank *sprites = skin->getSpriteBank(); + video::IVideoDriver *driver = RenderingEngine::get_video_driver(); + video::ITexture *sprite_texture = driver->getTexture(sprite_path.c_str()); + if (sprite_texture) { + s32 sprite_id = sprites->addTextureAsSprite(sprite_texture); + if (sprite_id != -1) + skin->setIcon(gui::EGDI_CHECK_BOX_CHECKED, sprite_id); + } + } +#endif g_fontengine = new FontEngine(g_settings, guienv); FATAL_ERROR_IF(g_fontengine == NULL, "Font engine creation failed."); |