Mobile: use SDL_IsTablet()
to determine the device type
* cherry picked from commit
1c1acc3cfb
* this commit define automatically the client mode, if tabled or not!
is goot to be backported to final minetest
* this depends of the previous commit, so now phone devices and tables
are buil using SDL, check commit bd244fb402ee965862f42455d18857d7453f2cac
in this repository
This commit is contained in:
parent
bd244fb402
commit
7083b0fb09
@ -2146,7 +2146,7 @@ void Game::openConsole(float scale, const wchar_t *line)
|
||||
gui_chat_console->setAndroidChatOpen(true);
|
||||
}
|
||||
|
||||
if (!g_settings->getBool("device_is_tablet"))
|
||||
if (!RenderingEngine::isTablet())
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
@ -791,13 +791,23 @@ v2u32 RenderingEngine::getDisplaySize()
|
||||
}
|
||||
#endif // __ANDROID__/__IOS__
|
||||
|
||||
bool RenderingEngine::isTablet()
|
||||
{
|
||||
#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
|
||||
static const bool isTablet = SDL_IsTablet();
|
||||
return isTablet;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RenderingEngine::isHighDpi()
|
||||
{
|
||||
#if defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__)
|
||||
return g_settings->getFloat("screen_dpi") / 72.0f >= 2;
|
||||
#elif defined(__IOS__)
|
||||
float density = RenderingEngine::getDisplayDensity();
|
||||
return g_settings->getBool("device_is_tablet") ? (density >= 2) : (density >= 3);
|
||||
return isTablet() ? (density >= 2) : (density >= 3);
|
||||
#else
|
||||
return RenderingEngine::getDisplayDensity() >= 3;
|
||||
#endif
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
static const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type);
|
||||
static float getDisplayDensity();
|
||||
static v2u32 getDisplaySize();
|
||||
static bool isTablet();
|
||||
static bool isHighDpi();
|
||||
|
||||
bool setupTopLevelWindow(const std::string &name);
|
||||
|
@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "mapgen/mapgen.h" // Mapgen::setDefaultSettings
|
||||
#include "util/string.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#ifndef SERVER
|
||||
#include "client/renderingengine.h"
|
||||
#endif
|
||||
|
||||
@ -496,7 +496,9 @@ void set_default_settings()
|
||||
settings->setDefault("screen_dpi", "72");
|
||||
settings->setDefault("display_density_factor", "1");
|
||||
|
||||
settings->setDefault("device_is_tablet", "false");
|
||||
#ifndef SERVER
|
||||
settings->setDefault("device_is_tablet", std::to_string(RenderingEngine::isTablet()));
|
||||
#endif
|
||||
|
||||
// Altered settings for macOS
|
||||
#if defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__)
|
||||
@ -540,6 +542,11 @@ void set_default_settings()
|
||||
settings->setDefault("autosave_screensize", "false");
|
||||
settings->setDefault("recent_chat_messages", "6");
|
||||
|
||||
if (RenderingEngine::isTablet()) {
|
||||
settings->setDefault("recent_chat_messages", "8");
|
||||
settings->setDefault("console_message_height", "0.4");
|
||||
}
|
||||
|
||||
// Set the optimal settings depending on the memory size [Android] | model [iOS]
|
||||
#ifdef __ANDROID__
|
||||
float memoryMax = porting::getTotalSystemMemory();
|
||||
@ -644,10 +651,6 @@ void set_default_settings()
|
||||
// 7" tablets
|
||||
g_settings->setDefault("hud_scaling", "0.9");
|
||||
g_settings->setDefault("selectionbox_width", "6");
|
||||
} else if (x_inches >= 7.0) {
|
||||
settings->setDefault("device_is_tablet", "true");
|
||||
settings->setDefault("recent_chat_messages", "8");
|
||||
settings->setDefault("console_message_height", "0.4");
|
||||
}
|
||||
|
||||
if (x_inches <= 4.5) {
|
||||
@ -676,12 +679,6 @@ void set_default_settings()
|
||||
|
||||
settings->setDefault("debug_log_level", "none");
|
||||
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
settings->setDefault("device_is_tablet", "true");
|
||||
settings->setDefault("recent_chat_messages", "8");
|
||||
settings->setDefault("console_message_height", "0.4");
|
||||
}
|
||||
|
||||
// Set the size of the elements depending on the screen size
|
||||
if SDVersion4Inch {
|
||||
// 4" iPhone and iPod Touch
|
||||
|
@ -101,7 +101,7 @@ void GUIConfirmRegistration::regenerateGui(v2u32 screensize)
|
||||
*/
|
||||
float s = MYMIN(screensize.X / 600.f, screensize.Y / 360.f);
|
||||
#if HAVE_TOUCHSCREENGUI
|
||||
s *= g_settings->getBool("device_is_tablet") ? 0.7f : 0.8f;
|
||||
s *= RenderingEngine::isTablet() ? 0.7f : 0.8f;
|
||||
#else
|
||||
s *= 0.5f;
|
||||
#endif
|
||||
|
@ -530,7 +530,7 @@ void GUIEngine::drawHeader(video::IVideoDriver *driver)
|
||||
core::rect<s32> splashrect(0, 0, splashsize.X, splashsize.Y);
|
||||
splashrect += v2s32((screensize.Width/2)-(splashsize.X/2), 0);
|
||||
|
||||
if (g_settings->getBool("device_is_tablet"))
|
||||
if (RenderingEngine::isTablet())
|
||||
splashrect += v2s32(0, splashsize.Y/4);
|
||||
#endif
|
||||
|
||||
|
@ -3394,7 +3394,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
||||
double prefer_imgsize = padded_screensize.Y / 10 * gui_scaling;
|
||||
|
||||
// Try to fit 13 coordinates on large tablets.
|
||||
if (g_settings->getBool("device_is_tablet"))
|
||||
if (RenderingEngine::isTablet())
|
||||
prefer_imgsize = padded_screensize.Y / 13 * gui_scaling;
|
||||
#else
|
||||
// Desktop computers have more space, so try to fit 15 coordinates.
|
||||
|
@ -137,7 +137,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
|
||||
|
||||
float s = MYMIN(screensize.X / 835.f, screensize.Y / 430.f);
|
||||
#if HAVE_TOUCHSCREENGUI
|
||||
s *= g_settings->getBool("device_is_tablet") ? 0.8f : 0.9f;
|
||||
s *= RenderingEngine::isTablet() ? 0.8f : 0.9f;
|
||||
#else
|
||||
s *= 0.75f;
|
||||
#endif
|
||||
|
@ -90,7 +90,7 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize)
|
||||
*/
|
||||
float s = MYMIN(screensize.X / 380.f, screensize.Y / 180.f);
|
||||
#if HAVE_TOUCHSCREENGUI
|
||||
s *= g_settings->getBool("device_is_tablet") ? 0.4f : 0.5f;
|
||||
s *= RenderingEngine::isTablet() ? 0.4f : 0.5f;
|
||||
#else
|
||||
s *= 0.35f;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user