Skip to content

Commit

Permalink
Remove touch target setting
Browse files Browse the repository at this point in the history
Crosshair is for all touch screen GUI (not necessarily Android).
Rename variable: m_android_use_crosshair -> m_touch_use_crosshair
  • Loading branch information
srifqi committed Aug 3, 2022
1 parent 572b9c4 commit 638c35f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
4 changes: 0 additions & 4 deletions builtin/mainmenu/tab_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,6 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
core.show_keys_menu()
return true
end
if fields["cb_touchscreen_target"] then
core.settings:set("touchtarget", fields["cb_touchscreen_target"])
return true
end

--Note dropdowns have to be handled LAST!
local ddhandled = false
Expand Down
2 changes: 1 addition & 1 deletion builtin/settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ mouse_sensitivity (Mouse sensitivity) float 0.2 0.001 10.0
# The length in pixels it takes for touch screen interaction to start.
touchscreen_threshold (Touch screen threshold) int 20 0 100

# (Android) Use crosshair to select object instead of whole screen.
# Use crosshair to select object instead of whole screen.
# If enabled, a crosshair will be shown and will be used for selecting object.
touch_use_crosshair (Use crosshair for touch screen) bool false

Expand Down
12 changes: 5 additions & 7 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,7 @@ class Game {

#ifdef HAVE_TOUCHSCREENGUI
bool m_cache_hold_aux1;
bool m_android_touchtarget;
bool m_android_use_crosshair;
bool m_touch_use_crosshair;
#endif
#ifdef __ANDROID__
bool m_android_chat_open;
Expand Down Expand Up @@ -1050,8 +1049,7 @@ bool Game::startup(bool *kill,
m_first_loop_after_window_activation = true;

#ifdef HAVE_TOUCHSCREENGUI
m_android_touchtarget = g_settings->getBool("touchtarget");
m_android_use_crosshair = g_settings->getBool("touch_use_crosshair");
m_touch_use_crosshair = g_settings->getBool("touch_use_crosshair");
#endif

g_client_translations->clear();
Expand Down Expand Up @@ -2982,7 +2980,7 @@ void Game::updateCamera(f32 dtime)

#ifdef HAVE_TOUCHSCREENGUI
if (g_touchscreengui)
g_touchscreengui->setUseCrosshair(m_android_use_crosshair ||
g_touchscreengui->setUseCrosshair(m_touch_use_crosshair ||
camera->getCameraMode() == CAMERA_MODE_THIRD);
#endif

Expand Down Expand Up @@ -3095,7 +3093,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
shootline.end = shootline.start + camera_direction * BS * d;

#ifdef HAVE_TOUCHSCREENGUI
if (m_android_touchtarget && g_touchscreengui && !m_android_use_crosshair &&
if (g_touchscreengui && !m_touch_use_crosshair &&
camera->getCameraMode() == CAMERA_MODE_FIRST) {
shootline = g_touchscreengui->getShootline();
// Scale shootline to the acual distance the player can reach
Expand Down Expand Up @@ -3982,7 +3980,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
(player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) &&
(camera->getCameraMode() != CAMERA_MODE_THIRD_FRONT));
#ifdef HAVE_TOUCHSCREENGUI
if (!m_android_use_crosshair && camera->getCameraMode() == CAMERA_MODE_FIRST)
if (!m_touch_use_crosshair && camera->getCameraMode() == CAMERA_MODE_FIRST)
draw_crosshair = false;
#endif
m_rendering_engine->draw_scene(skycolor, m_game_ui->m_flags.show_hud,
Expand Down
1 change: 0 additions & 1 deletion src/defaultsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ void set_default_settings()
#endif

#ifdef HAVE_TOUCHSCREENGUI
settings->setDefault("touchtarget", "true");
settings->setDefault("touchscreen_threshold","20");
settings->setDefault("touch_use_crosshair", "false");
settings->setDefault("fixed_virtual_joystick", "false");
Expand Down
1 change: 0 additions & 1 deletion src/gui/touchscreengui.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "client/tile.h"
#include "client/game.h"
#include "client/camera.h"

using namespace irr;
using namespace irr::core;
Expand Down

0 comments on commit 638c35f

Please sign in to comment.