From eb122a4e80fb60e39bda3b2f58b0278ad0cbdc08 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Thu, 26 Jan 2023 10:32:32 +0200 Subject: [PATCH] Minor engine changes and fixes --- src/client/game.cpp | 44 ++++++++----------------------- src/client/minimap.cpp | 2 +- src/content/subgames.cpp | 8 ------ src/defaultsettings.cpp | 5 ++-- src/gui/guiFormSpecMenu.cpp | 2 +- src/script/lua_api/l_mainmenu.cpp | 2 +- 6 files changed, 17 insertions(+), 46 deletions(-) diff --git a/src/client/game.cpp b/src/client/game.cpp index 4c43c6052..553e7186a 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -655,7 +655,7 @@ struct GameRunData { float jump_timer; float damage_flash; float update_draw_list_timer; -#if defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__) +#if defined(__MACH__) && defined(__APPLE__) float item_select_timer; #endif @@ -701,9 +701,6 @@ public: #if defined(__ANDROID__) || defined(__IOS__) void pauseGame(); #endif -#ifdef __IOS__ - void customStatustext(const std::wstring &text); -#endif protected: @@ -1141,14 +1138,14 @@ void Game::run() // + Sleep time until the wanted FPS are reached limitFps(&draw_times, &dtime); -#if defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__) +#if defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__) && !defined(__aarch64__) if (!device->isWindowFocused()) { if (m_does_lost_focus_pause_game && !isMenuActive()) showPauseMenu(); sleep_ms(50); continue; } -#elif defined(__ANDROID__) || defined(__IOS__) +#else if (device->isWindowMinimized()) { sleep_ms(50); continue; @@ -2052,7 +2049,7 @@ void Game::processKeyInput() void Game::processItemSelection(f32 dtime, GameRunData *run_data) { -#if defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__) +#if defined(__MACH__) && defined(__APPLE__) if (run_data->item_select_timer) run_data->item_select_timer = MYMAX(0.0f, run_data->item_select_timer - dtime); #endif @@ -2075,7 +2072,7 @@ void Game::processItemSelection(f32 dtime, GameRunData *run_data) if (wasKeyDown(KeyType::HOTBAR_PREV)) dir = 1; -#if defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__) +#if defined(__MACH__) && defined(__APPLE__) if (dir && !run_data->item_select_timer) { run_data->item_select_timer = 0.05f; #else @@ -2410,16 +2407,13 @@ void Game::toggleFullViewRange() #if !defined(__ANDROID__) && !defined(__IOS__) draw_control->range_all = !draw_control->range_all; if (draw_control->range_all) - m_game_ui->showTranslatedStatusText("Enabled unlimited viewing range"); - else - m_game_ui->showTranslatedStatusText("Disabled unlimited viewing range"); #else draw_control->extended_range = !draw_control->extended_range; if (draw_control->extended_range) - m_game_ui->showTranslatedStatusText("Enabled far viewing range"); - else - m_game_ui->showTranslatedStatusText("Disabled far viewing range"); #endif + m_game_ui->showTranslatedStatusText("Enabled unlimited viewing range"); + else + m_game_ui->showTranslatedStatusText("Disabled unlimited viewing range"); } @@ -4231,13 +4225,6 @@ void Game::pauseGame() } #endif -#ifdef __IOS__ -void Game::customStatustext(const std::wstring &text) -{ - m_game_ui->showStatusText(text); -} -#endif - /****************************************************************************/ /**************************************************************************** Shutdown / cleanup @@ -4290,7 +4277,7 @@ void Game::showDeathFormspec() #define GET_KEY_NAME(KEY) gettext(getKeySetting(#KEY).name()) void Game::showPauseMenu() { -#ifdef HAVE_TOUCHSCREENGUI +/*#ifdef HAVE_TOUCHSCREENGUI static const std::string control_text = strgettext("Default Controls:\n" "No menu visible:\n" "- single tap: button activate\n" @@ -4339,7 +4326,7 @@ void Game::showPauseMenu() std::string control_text = std::string(control_text_buf); str_formspec_escape(control_text); -#endif +#endif*/ float ypos = simple_singleplayer_mode ? 0.7f : 0.1f; #if defined(__ANDROID__) || defined(__IOS__) @@ -4384,7 +4371,7 @@ void Game::showPauseMenu() << strgettext("Change Keys") << ";;false]"; os << "image_button_exit[3.5," << (ypos++) << ";4,0.9;;btn_exit_menu;" << strgettext("Exit to Menu") << ";;false]"; -#ifndef __IOS__ +#if !defined(__ANDROID__) && !defined(__IOS__) os << "image_button_exit[3.5," << (ypos++) << ";4,0.9;;btn_exit_os;" << strgettext("Exit to OS") << ";;false]"; #endif @@ -4545,12 +4532,3 @@ extern "C" void external_pause_game() g_game->pauseGame(); } #endif - -#ifdef __IOS__ -extern "C" void external_statustext(const char *text) -{ - if (!g_game) - return; - g_game->customStatustext(utf8_to_wide_c(text)); -} -#endif diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index 4c7db524e..5e028c97c 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -362,7 +362,7 @@ void Minimap::addMode(MinimapModeDef mode) porting::mt_snprintf(label_buf, sizeof(label_buf), mode.label.c_str(), zoom); mode.label = label_buf; -#if !defined(__ANDROID__) && !defined(__IOS__) +#if defined(__ANDROID__) || defined(__IOS__) mode.label = mode.label.substr(0, mode.label.find(", ")); #endif } diff --git a/src/content/subgames.cpp b/src/content/subgames.cpp index 764277614..840ed4796 100644 --- a/src/content/subgames.cpp +++ b/src/content/subgames.cpp @@ -66,11 +66,7 @@ SubgameSpec findSubgame(const std::string &id) { if (id.empty()) return SubgameSpec(); -#ifndef __IOS__ std::string share = porting::path_share; -#else - std::string share = porting::path_games; -#endif std::string user = porting::path_user; // Get games install locations @@ -179,11 +175,7 @@ std::set getAvailableGameIds() { std::set gameids; std::set gamespaths; -#ifndef __IOS__ gamespaths.insert(porting::path_share + DIR_DELIM + "games"); -#else - gamespaths.insert(porting::path_games + DIR_DELIM + "games"); -#endif gamespaths.insert(porting::path_user + DIR_DELIM + "games"); Strfnd search_paths(getSubgamePathEnv()); diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 600dc7173..90fc2aa9e 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -77,7 +77,7 @@ void set_default_settings() settings->setDefault("enable_client_modding", "true"); settings->setDefault("max_out_chat_queue_size", "20"); settings->setDefault("pause_on_lost_focus", "true"); - settings->setDefault("enable_register_confirmation", "false"); + settings->setDefault("enable_register_confirmation", "true"); // Keymap settings->setDefault("remote_port", "30000"); @@ -512,11 +512,12 @@ void set_default_settings() settings->setDefault("keymap_camera_mode", "KEY_KEY_C"); settings->setDefault("vsync", "true"); - float ScaleFactor = [NSScreen mainScreen].backingScaleFactor; + int ScaleFactor = (int) [NSScreen mainScreen].backingScaleFactor; settings->setDefault("screen_dpi", std::to_string(ScaleFactor * 72)); if (ScaleFactor >= 2) { settings->setDefault("hud_scaling", "1.5"); } else { + settings->setDefault("font_size", std::to_string(TTF_DEFAULT_FONT_SIZE - 2)); settings->setDefault("hud_scaling", "1.25"); settings->setDefault("gui_scaling", "1.5"); } diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index b83936cec..0a6204be3 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -1613,7 +1613,7 @@ void GUIFormSpecMenu::createTextField(parserData *data, FieldSpec &spec, #else if (is_multiline) { e = new GUIEditBoxWithScrollBar(spec.fdefault.c_str(), true, Environment, - data->current_parent, spec.fid, rect, is_editable, true); + data->current_parent, spec.fid, rect, is_editable, !is_editable); } else if (is_editable) { e = Environment->addEditBox(spec.fdefault.c_str(), rect, true, data->current_parent, spec.fid); diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 3afe05df8..2c2fbc6d2 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -145,7 +145,7 @@ int ModApiMainMenu::l_start(lua_State *L) data->serverdescription = getTextData(L,"serverdescription"); data->servername = getTextData(L,"servername"); -#ifdef __IOS__ +#if defined(__ANDROID__) || defined(__IOS__) if (!g_settings_path.empty()) g_settings->updateConfigFile(g_settings_path.c_str()); #endif