aboutsummaryrefslogtreecommitdiff
path: root/client/menu
diff options
context:
space:
mode:
Diffstat (limited to 'client/menu')
-rw-r--r--client/menu/entry.gd2
-rw-r--r--client/menu/menu.gd2
-rw-r--r--client/menu/popup_message.gd74
-rw-r--r--client/menu/settings/input/input_manager.gd36
-rw-r--r--client/menu/settings/input/input_value_node.gd15
-rw-r--r--client/menu/setup.gd2
6 files changed, 92 insertions, 39 deletions
diff --git a/client/menu/entry.gd b/client/menu/entry.gd
index 456709ed..00420ac6 100644
--- a/client/menu/entry.gd
+++ b/client/menu/entry.gd
@@ -18,7 +18,7 @@ extends Menu
func _ready():
super()
- if not Global.get_setting("gameplay.setup_complete"):
+ if not Global.get_setting("gameplay.setup_completed"):
await submenu("res://menu/setup.tscn")
else:
await submenu("res://menu/main.tscn")
diff --git a/client/menu/menu.gd b/client/menu/menu.gd
index 30a9ca7d..52a9bd7d 100644
--- a/client/menu/menu.gd
+++ b/client/menu/menu.gd
@@ -125,6 +125,6 @@ func update_parent_menu(node: Node):
func _input(_event):
if popup != null: return
if Time.get_ticks_msec() - open_since < 100: return
- if Input.is_action_just_pressed("ui_cancel"):
+ if Input.is_action_just_pressed("menu"):
Sound.play_click()
exit()
diff --git a/client/menu/popup_message.gd b/client/menu/popup_message.gd
index 1464e20c..d3e7905d 100644
--- a/client/menu/popup_message.gd
+++ b/client/menu/popup_message.gd
@@ -109,32 +109,55 @@ func _input(_event):
Global.set_hint("has_reset", true)
func _on_boost_timeout():
- if not Global.get_hint("has_boosted") and not Global.get_setting("ui.touch_controls"):
- display_hint_msg(tr("Press %s to boost") % display_keybind(tr("SHIFT"), "B"))
+ if not Global.get_hint("has_boosted") and not Global.using_touch:
+ display_hint_msg(tr("c.hint.boost") % display_keybind("boost"))
func _on_move_timeout():
- if not Global.get_hint("has_moved") and not Global.get_setting("ui.touch_controls"):
- display_hint_msg(tr("Use %s to move") % display_keybind("WASD", tr("left stick")))
+ if not Global.get_hint("has_moved") and not Global.using_touch:
+ display_hint_msg(tr("c.hint.movement") % ", ".join(
+ [
+ display_keybind("forwards"),
+ display_keybind("left"),
+ display_keybind("backwards"),
+ display_keybind("right")
+ ]
+ ))
func _on_interact_timeout():
- if not Global.get_hint("has_interacted") and not Global.get_setting("ui.touch_controls"):
- var keybind = display_keybind(tr("SPACE"), "A")
- display_hint_msg(tr("Press %s to pick up items and hold %s to interact with tools") % [keybind, keybind])
+ if not Global.get_hint("has_interacted") and not Global.using_touch:
+ display_hint_msg(tr("c.hint.interact") % display_keybind("interact"))
func _on_reset_timeout():
- if not Global.get_hint("has_reset") and not Global.get_setting("ui.touch_controls"):
- display_hint_msg(tr("Press %s to reset the camera view") % display_keybind("R", "Y"))
+ if not Global.get_hint("has_reset") and not Global.using_touch:
+ display_hint_msg(tr("c.hint.reset_camera") % display_keybind("reset"))
func _on_zoom_timeout():
- if not Global.get_hint("has_zoomed") and not Global.get_setting("ui.touch_controls"):
- display_hint_msg(tr("Use %s to zoom in/out") % display_keybind(tr("PageUp/PageDown"), "LT/RT"))
+ if not Global.get_hint("has_zoomed") and not Global.using_touch:
+ display_hint_msg(tr("c.hint.zoom_camera") % ", ".join(
+ [
+ display_keybind("zoom_in"),
+ display_keybind("zoom_out")
+ ]
+ ))
-func display_keybind(keyboard: String, joypad: String, touch = null) -> String:
- if Global.using_joypad:
- return joypad + " (Joypad)"
- if touch != null:
- return touch
- return keyboard
+func display_keybind(action_name: String) -> String:
+ var events := InputManager.get_events(action_name)
+
+ if events.size() == 0:
+ # There are no events which match the action
+ return tr("c.settings.input.unknown_event")
+
+ for event: InputEvent in events:
+ # Try to find event which matches input method
+ var type := InputManager.get_event_type(event)
+ if Global.using_joypad and type != InputManager.EventType.JOYPAD:
+ continue
+ if Global.using_touch and type != InputManager.EventType.TOUCH:
+ continue
+ return InputManager.display_input_event(event)
+
+ # No matching event found. Just show any event.
+ return InputManager.display_input_event(events[0])
func any_action_just_pressed(actions: Array) -> bool:
for a: String in actions:
@@ -143,20 +166,27 @@ func any_action_just_pressed(actions: Array) -> bool:
return false
func _on_rotate_camera_timeout():
- if not Global.get_hint("has_rotated") and not Global.get_setting("ui.touch_controls"):
- display_hint_msg(tr("Use %s to rotate the camera view") % display_keybind(tr("arrow keys"), tr("right stick")))
+ if not Global.get_hint("has_rotated") and not Global.using_touch:
+ display_hint_msg(tr("c.hint.rotate") % ", ".join(
+ [
+ display_keybind("rotate_up"),
+ display_keybind("rotate_left"),
+ display_keybind("rotate_down"),
+ display_keybind("rotate_right")
+ ]
+ ))
func _on_nametags_timeout():
if not Global.get_hint("has_seen_nametags") and not Global.get_setting("graphics.usernames"):
Global.set_hint("has_seen_nametags", true)
- display_hint_msg(tr("Username tags can be enabled/disabled in the settings"))
+ display_hint_msg(tr("c.hint.username_tags"))
func _on_join_while_running_timeout():
if not game.is_joined and not Global.get_hint("has_seen_join_while_running"):
Global.set_hint("has_seen_join_while_running", true)
- display_hint_msg(tr("Press %s and click \"Join\" to join the game while it is running") % display_keybind(tr("ESCAPE"), tr("Menu button")))
+ display_hint_msg(tr("c.hint.join_while_running") % display_keybind("menu"))
func _on_performance_timeout() -> void:
if not Global.get_hint("has_seen_performance") and Engine.get_frames_per_second() < DisplayServer.screen_get_refresh_rate() * 0.75:
Global.set_hint("has_seen_performance", true)
- display_hint_msg(tr("Your framerate seems to be low. You can lower your graphics settings in the settings menu."))
+ display_hint_msg(tr("c.hint.framerate_low"))
diff --git a/client/menu/settings/input/input_manager.gd b/client/menu/settings/input/input_manager.gd
index d216884b..640410d0 100644
--- a/client/menu/settings/input/input_manager.gd
+++ b/client/menu/settings/input/input_manager.gd
@@ -16,8 +16,15 @@
#
extends Node
+enum EventType {
+ KEYBOARD,
+ JOYPAD,
+ TOUCH,
+ OTHER
+}
+
var default_input_map = {}
-var input_map
+var input_map: Dictionary
func _init():
default_input_map = get_input_map()
@@ -31,6 +38,12 @@ func get_input_map() -> Dictionary:
kb[a] = input_events
return kb
+func get_events(action_name: String) -> Array:
+ if not input_map.has(action_name):
+ push_error("Tried to get action %s in input map which does not exist" % action_name)
+ return []
+ return input_map[action_name]
+
func input_map_to_settings(map: Dictionary) -> Array:
var entries := []
for k in map.keys():
@@ -68,3 +81,24 @@ func apply_input_map(new_input_map: Dictionary):
func reset_input_map():
Global.set_setting("input_map", default_input_map.duplicate())
apply_input_map(Global.get_setting("input_map"))
+
+func get_event_type(input_event: InputEvent) -> EventType:
+ if input_event is InputEventKey or input_event is InputEventMouseButton:
+ return EventType.KEYBOARD
+ elif input_event is InputEventJoypadButton or input_event is InputEventJoypadMotion:
+ return EventType.JOYPAD
+ elif input_event is InputEventScreenTouch or input_event is InputEventScreenDrag:
+ return EventType.TOUCH
+ return EventType.OTHER
+
+func display_input_event(input_event: InputEvent) -> String:
+ if input_event is InputEventKey:
+ return tr("c.settings.input.keyboard") % OS.get_keycode_string(input_event.physical_keycode)
+ elif input_event is InputEventMouseButton:
+ return tr("c.settings.input.mouse_button") % input_event.button_index
+ elif input_event is InputEventJoypadButton:
+ return tr("c.settings.input.joypad") % input_event.button_index
+ elif input_event is InputEventJoypadMotion:
+ return tr("c.settings.input.joypad_axis") % [input_event.axis]
+ else:
+ return tr("c.settings.input.other_event")
diff --git a/client/menu/settings/input/input_value_node.gd b/client/menu/settings/input/input_value_node.gd
index 9f89416b..ef00c09b 100644
--- a/client/menu/settings/input/input_value_node.gd
+++ b/client/menu/settings/input/input_value_node.gd
@@ -34,20 +34,9 @@ func update(fix_focus: bool = false):
c.queue_free()
for e: InputEvent in value:
- var description: String
-
- if e is InputEventKey:
- description = tr("%s (Keyboard)") % OS.get_keycode_string(e.physical_keycode)
- elif e is InputEventMouseButton:
- description = tr("Mouse button %s") % e.button_index
- elif e is InputEventJoypadButton:
- description = tr("%s (Joypad)") % e.button_index
- elif e is InputEventJoypadMotion:
- description = tr("Joypad axis %s") % [e.axis]
- else:
- description = tr("Other event")
-
+ var description: String = InputManager.display_input_event(e)
var button := Button.new()
+
button.text = description
button.pressed.connect(erase_event.bind(e))
actions_container.add_child(button)
diff --git a/client/menu/setup.gd b/client/menu/setup.gd
index 16944c7c..c87e0112 100644
--- a/client/menu/setup.gd
+++ b/client/menu/setup.gd
@@ -73,5 +73,5 @@ func _on_sign_pressed():
Global.set_profile("username", username.text)
Global.set_profile("character", character)
- Global.set_setting("gameplay.setup_complete", true)
+ Global.set_setting("gameplay.setup_completed", true)
replace_menu("res://menu/main.tscn")