summaryrefslogtreecommitdiff
path: root/client/global.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/global.gd')
-rw-r--r--client/global.gd24
1 files changed, 23 insertions, 1 deletions
diff --git a/client/global.gd b/client/global.gd
index b25317e3..124bebf4 100644
--- a/client/global.gd
+++ b/client/global.gd
@@ -20,6 +20,7 @@ extends Node
signal settings_changed()
signal using_joypad_change(using: bool)
+signal using_touch_change(using: bool)
var default_profile := {
"username": "Giovanni",
@@ -38,6 +39,7 @@ var default_profile := {
}
var languages := language_array()
var using_joypad := false
+var using_touch := false
var default_settings := {
"language": DropdownSetting.new(tr("Language"), 0, languages),
@@ -45,7 +47,7 @@ var default_settings := {
"music_volume": RangeSetting.new(tr("Music Volume"), 0, -30, 0),
"sfx_volume": RangeSetting.new(tr("SFX Volume"), 0, -30, 0),
"fullscreen": DropdownSetting.new(tr("Fullscreen"), 0, [tr("Keep"), tr("Always"), tr("Never")]),
- "touch_controls": ToggleSetting.new(tr("Enable touch screen controls"), DisplayServer.is_touchscreen_available()),
+ "touch_controls": DropdownSetting.new(tr("Enable touch screen controls"), 0, [tr("Automatic"), tr("Enabled"), tr("Disabled")]),
"interpolate_camera_rotation": ToggleSetting.new(tr("Interpolate the camera rotation"), true),
"invert_camera": ToggleSetting.new(tr("Invert camera movement"), false),
"usernames": ToggleSetting.new(tr("Show username tags"), true),
@@ -111,6 +113,17 @@ func _input(event):
if not using_joypad:
using_joypad = true
using_joypad_change.emit(using_joypad)
+
+ # Update using_touch variable
+ if get_setting("touch_controls") == 0: # Only if set to automatic
+ if event is InputEventScreenTouch or event is InputEventScreenDrag:
+ if not using_touch:
+ using_touch = true
+ using_touch_change.emit(using_touch)
+ if event is InputEventMouseButton or event is InputEventKey or event is InputEventJoypadButton or event is InputEventJoypadMotion:
+ if using_touch:
+ using_touch = false
+ using_touch_change.emit(using_touch)
func apply_settings():
update_fullscreen()
@@ -154,6 +167,15 @@ func apply_settings():
Sound.set_volume(0, get_setting("master_volume"))
Sound.set_volume(1, get_setting("music_volume"))
Sound.set_volume(2, get_setting("sfx_volume"))
+
+ # Touch controls
+ match get_setting("touch_controls"):
+ # 0: Automatically adjusted
+ 1: # Enabled
+ using_touch = true
+ 2: # Disabled
+ using_touch = false
+ using_touch_change.emit()
emit_signal("settings_changed")