1
0

Minor cleanup and improvements

This commit is contained in:
Maksym H 2023-08-16 14:08:39 +03:00 committed by Maksym H.
parent 1a553f9efe
commit 66b1aafb4b
10 changed files with 27 additions and 30 deletions

View File

@ -4354,8 +4354,6 @@ void Game::showPauseMenu()
bool hasRealKeyboard = porting::hasRealKeyboard(); bool hasRealKeyboard = porting::hasRealKeyboard();
if (simple_singleplayer_mode && hasRealKeyboard) if (simple_singleplayer_mode && hasRealKeyboard)
ypos -= 0.6f; ypos -= 0.6f;
#endif
#ifdef __IOS__
ypos += 0.5f; ypos += 0.5f;
#endif #endif
const bool high_dpi = RenderingEngine::isHighDpi(); const bool high_dpi = RenderingEngine::isHighDpi();

View File

@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h" #include "settings.h"
#ifdef __IOS__ #ifdef __IOS__
#include "porting_ios.h" #include "porting.h"
extern "C" void external_pause_game(); extern "C" void external_pause_game();
#endif #endif

View File

@ -193,18 +193,12 @@ Minimap::Minimap(Client *client)
// Initialize minimap modes // Initialize minimap modes
addMode(MINIMAP_TYPE_OFF); addMode(MINIMAP_TYPE_OFF);
#if !defined(__ANDROID__) && !defined(__IOS__)
addMode(MINIMAP_TYPE_SURFACE, 256); addMode(MINIMAP_TYPE_SURFACE, 256);
addMode(MINIMAP_TYPE_SURFACE, 128); addMode(MINIMAP_TYPE_SURFACE, 128);
#endif
addMode(MINIMAP_TYPE_SURFACE, 64); addMode(MINIMAP_TYPE_SURFACE, 64);
#if !defined(__ANDROID__) && !defined(__IOS__)
addMode(MINIMAP_TYPE_RADAR, 512);
addMode(MINIMAP_TYPE_RADAR, 256); addMode(MINIMAP_TYPE_RADAR, 256);
addMode(MINIMAP_TYPE_RADAR, 128); addMode(MINIMAP_TYPE_RADAR, 128);
#else
addMode(MINIMAP_TYPE_RADAR, 64); addMode(MINIMAP_TYPE_RADAR, 64);
#endif
// Initialize minimap data // Initialize minimap data
data = new MinimapData; data = new MinimapData;
@ -362,9 +356,6 @@ void Minimap::addMode(MinimapModeDef mode)
porting::mt_snprintf(label_buf, sizeof(label_buf), porting::mt_snprintf(label_buf, sizeof(label_buf),
mode.label.c_str(), zoom); mode.label.c_str(), zoom);
mode.label = label_buf; mode.label = label_buf;
#if defined(__ANDROID__) || defined(__IOS__)
mode.label = mode.label.substr(0, mode.label.find(", "));
#endif
} }
m_modes.push_back(mode); m_modes.push_back(mode);

View File

@ -53,7 +53,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <winuser.h> #include <winuser.h>
#endif #endif
#ifdef __ANDROID__ #if defined(__ANDROID__) || defined(__IOS__)
#include "defaultsettings.h" #include "defaultsettings.h"
#endif #endif
@ -143,6 +143,10 @@ RenderingEngine::RenderingEngine(IEventReceiver *receiver)
#endif #endif
m_device = createDeviceEx(params); m_device = createDeviceEx(params);
#if defined(__ANDROID__) || defined(__IOS__)
FATAL_ERROR_IF(!m_device, ("Device create failed. Driver Type: \"" +
std::string(RenderingEngine::getVideoDriverName(driverType)) + "\".").c_str());
#endif
driver = m_device->getVideoDriver(); driver = m_device->getVideoDriver();
s_singleton = this; s_singleton = this;
@ -152,10 +156,9 @@ RenderingEngine::RenderingEngine(IEventReceiver *receiver)
m_device->getGUIEnvironment()->setSkin(skin); m_device->getGUIEnvironment()->setSkin(skin);
skin->drop(); skin->drop();
#ifdef __ANDROID__ #if defined(__ANDROID__) || defined(__IOS__)
// Apply settings according to screen size // Apply settings according to screen size
// We can get real screen size only after device initialization finished // We can get real screen size only after device initialization finished
if (m_device)
set_default_settings(); set_default_settings();
#endif #endif
} }

View File

@ -536,7 +536,6 @@ void set_default_settings()
settings->setDefault("emergequeue_limit_diskonly", "16"); settings->setDefault("emergequeue_limit_diskonly", "16");
settings->setDefault("emergequeue_limit_generate", "16"); settings->setDefault("emergequeue_limit_generate", "16");
settings->setDefault("curl_verify_cert", "false"); settings->setDefault("curl_verify_cert", "false");
settings->setDefault("max_objects_per_block", "16");
settings->setDefault("doubletap_jump", "true"); settings->setDefault("doubletap_jump", "true");
settings->setDefault("gui_scaling_filter_txr2img", "false"); settings->setDefault("gui_scaling_filter_txr2img", "false");
settings->setDefault("autosave_screensize", "false"); settings->setDefault("autosave_screensize", "false");
@ -559,13 +558,14 @@ void set_default_settings()
#endif #endif
settings->setDefault("client_unload_unused_data_timeout", "60"); settings->setDefault("client_unload_unused_data_timeout", "60");
settings->setDefault("client_mapblock_limit", "50"); settings->setDefault("client_mapblock_limit", "50");
settings->setDefault("fps_max", "30"); settings->setDefault("fps_max", "35");
settings->setDefault("fps_max_unfocused", "10"); settings->setDefault("fps_max_unfocused", "10");
settings->setDefault("viewing_range", "30"); settings->setDefault("viewing_range", "30");
settings->setDefault("smooth_lighting", "false"); settings->setDefault("smooth_lighting", "false");
settings->setDefault("enable_3d_clouds", "false"); settings->setDefault("enable_3d_clouds", "false");
settings->setDefault("active_object_send_range_blocks", "1"); settings->setDefault("active_object_send_range_blocks", "1");
settings->setDefault("active_block_range", "1"); settings->setDefault("active_block_range", "1");
settings->setDefault("max_objects_per_block", "16");
settings->setDefault("dedicated_server_step", "0.2"); settings->setDefault("dedicated_server_step", "0.2");
settings->setDefault("abm_interval", "3.0"); settings->setDefault("abm_interval", "3.0");
settings->setDefault("chunksize", "3"); settings->setDefault("chunksize", "3");
@ -586,14 +586,15 @@ void set_default_settings()
settings->setDefault("smooth_lighting", "false"); settings->setDefault("smooth_lighting", "false");
settings->setDefault("active_object_send_range_blocks", "1"); settings->setDefault("active_object_send_range_blocks", "1");
settings->setDefault("active_block_range", "2"); settings->setDefault("active_block_range", "2");
settings->setDefault("max_objects_per_block", "16");
settings->setDefault("dedicated_server_step", "0.2"); settings->setDefault("dedicated_server_step", "0.2");
settings->setDefault("abm_interval", "2.0"); settings->setDefault("abm_interval", "2.0");
settings->setDefault("chunksize", "3"); settings->setDefault("chunksize", "3");
settings->setDefault("max_block_generate_distance", "2"); settings->setDefault("max_block_generate_distance", "2");
settings->setDefault("arm_inertia", "false"); settings->setDefault("arm_inertia", "false");
#ifdef __ANDROID__ #ifdef __ANDROID__
} else if (memoryMax >= 4 && memoryMax < 6) { } else if (memoryMax >= 4 && memoryMax <= 5) {
// medium settings for 4.1-6GB RAM // medium settings for 4.1-5GB RAM
#elif __IOS__ #elif __IOS__
} else if (([SDVersion deviceVersion] == iPhone6S) || ([SDVersion deviceVersion] == iPhone6SPlus) || ([SDVersion deviceVersion] == iPhoneSE) || } else if (([SDVersion deviceVersion] == iPhone6S) || ([SDVersion deviceVersion] == iPhone6SPlus) || ([SDVersion deviceVersion] == iPhoneSE) ||
([SDVersion deviceVersion] == iPhone7) || ([SDVersion deviceVersion] == iPhone7Plus) || ([SDVersion deviceVersion] == iPhone7) || ([SDVersion deviceVersion] == iPhone7Plus) ||
@ -607,6 +608,7 @@ void set_default_settings()
settings->setDefault("viewing_range", "60"); settings->setDefault("viewing_range", "60");
settings->setDefault("active_object_send_range_blocks", "2"); settings->setDefault("active_object_send_range_blocks", "2");
settings->setDefault("active_block_range", "2"); settings->setDefault("active_block_range", "2");
settings->setDefault("max_objects_per_block", "32");
settings->setDefault("max_block_generate_distance", "3"); settings->setDefault("max_block_generate_distance", "3");
} else { } else {
// high settings // high settings
@ -624,7 +626,7 @@ void set_default_settings()
// Android Settings // Android Settings
#ifdef __ANDROID__ #ifdef __ANDROID__
// Switch to olges2 with shaders on powerful Android devices // Switch to olges2 with shaders on powerful Android devices
if (memoryMax >= 6) { if (memoryMax > 5) {
settings->setDefault("video_driver", "ogles2"); settings->setDefault("video_driver", "ogles2");
settings->setDefault("enable_shaders", "true"); settings->setDefault("enable_shaders", "true");
} else { } else {
@ -669,7 +671,7 @@ void set_default_settings()
// iOS Settings // iOS Settings
#ifdef __IOS__ #ifdef __IOS__
// Switch to olges2 with shaders in new iOS versions // Switch to olges2 with shaders in new iOS versions
if (IOS_VERSION_AVAILABLE("13.0")) { if (IOS_VERSION_AVAILABLE("14.0")) {
settings->setDefault("video_driver", "ogles2"); settings->setDefault("video_driver", "ogles2");
settings->setDefault("enable_shaders", "true"); settings->setDefault("enable_shaders", "true");
} else { } else {
@ -690,7 +692,7 @@ void set_default_settings()
settings->setDefault("touch_sensitivity", "0.27"); settings->setDefault("touch_sensitivity", "0.27");
} else if SDVersion5and5Inch { } else if SDVersion5and5Inch {
// 5.5" iPhone Plus // 5.5" iPhone Plus
settings->setDefault("hud_scaling", "0.65"); settings->setDefault("hud_scaling", "0.6");
settings->setDefault("touch_sensitivity", "0.3"); settings->setDefault("touch_sensitivity", "0.3");
} else if (SDVersion5and8Inch || SDVersion6and1Inch) { } else if (SDVersion5and8Inch || SDVersion6and1Inch) {
// 5.8" and 6.1" iPhones // 5.8" and 6.1" iPhones
@ -725,7 +727,8 @@ void set_default_settings()
} }
// Settings for the Rounded Screen and Home Bar // Settings for the Rounded Screen and Home Bar
if SDVersionRoundScreen { int RoundScreen = porting::getRoundScreen();
if (RoundScreen > 0) {
int upwards = 25, round = 40; int upwards = 25, round = 40;
if SDVersioniPhone12Series { if SDVersioniPhone12Series {
upwards = 20, round = 90; upwards = 20, round = 90;

View File

@ -640,7 +640,7 @@ void GUIEngine::updateTopLeftTextSize()
{ {
core::rect<s32> rect(0, 0, g_fontengine->getTextWidth(m_toplefttext.c_str()), core::rect<s32> rect(0, 0, g_fontengine->getTextWidth(m_toplefttext.c_str()),
g_fontengine->getTextHeight()); g_fontengine->getTextHeight());
rect += v2s32(5 + g_settings->getU16("round_screen"), 0); rect += v2s32(5 + g_settings->getU16("round_screen") * 1.1, 0);
m_irr_toplefttext->remove(); m_irr_toplefttext->remove();
m_irr_toplefttext = gui::StaticText::add(RenderingEngine::get_gui_env(), m_irr_toplefttext = gui::StaticText::add(RenderingEngine::get_gui_env(),

View File

@ -401,7 +401,7 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
if (!ret && m_hovered && m_hovered != focused) if (!ret && m_hovered && m_hovered != focused)
ret = m_hovered->OnEvent(mouse_event); ret = m_hovered->OnEvent(mouse_event);
if (event.TouchInput.Event == ETIE_LEFT_UP) { if (event.TouchInput.Event == ETIE_LEFT_UP) {
m_pointer = v2s32(0, 0); m_pointer = AbsoluteClippingRect.UpperLeftCorner;
leave(); leave();
} }
return ret; return ret;

View File

@ -52,8 +52,8 @@ public:
void quitMenu(); void quitMenu();
void removeChildren(); void removeChildren();
virtual void regenerateGui(v2u32 screensize) = 0; virtual void regenerateGui(v2u32 screensize) {};
virtual void drawMenu() = 0; virtual void drawMenu() {};
virtual bool preprocessEvent(const SEvent &event); virtual bool preprocessEvent(const SEvent &event);
virtual bool OnEvent(const SEvent &event) { return false; }; virtual bool OnEvent(const SEvent &event) { return false; };
virtual bool pausesGame() { return false; } // Used for pause menu virtual bool pausesGame() { return false; } // Used for pause menu

View File

@ -494,12 +494,12 @@ int ModApiUtil::l_sha1(lua_State *L)
int ModApiUtil::l_upgrade(lua_State *L) int ModApiUtil::l_upgrade(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
#ifdef __ANDROID__ #if defined(__ANDROID__) || defined(__IOS__)
const std::string item_name = luaL_checkstring(L, 1); const std::string item_name = luaL_checkstring(L, 1);
porting::upgrade(item_name); porting::upgrade(item_name);
lua_pushboolean(L, true); lua_pushboolean(L, true);
#else #else
// Not implemented on non-Android platforms // Not implemented on other platforms
lua_pushnil(L); lua_pushnil(L);
#endif #endif

View File

@ -280,10 +280,12 @@ public:
// Envlock and conlock should be locked when using scriptapi // Envlock and conlock should be locked when using scriptapi
ServerScripting *getScriptIface(){ return m_script; } ServerScripting *getScriptIface(){ return m_script; }
#if USE_SQLITE
// actions: time-reversed list // actions: time-reversed list
// Return value: success/failure // Return value: success/failure
bool rollbackRevertActions(const std::list<RollbackAction> &actions, bool rollbackRevertActions(const std::list<RollbackAction> &actions,
std::list<std::string> *log); std::list<std::string> *log);
#endif
// IGameDef interface // IGameDef interface
// Under envlock // Under envlock