diff options
| author | metamuffin <metamuffin@disroot.org> | 2025-09-04 23:47:24 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2025-09-05 23:07:07 +0200 | 
| commit | 81deaf81c800900e30046cb927be1c9d91ae61b8 (patch) | |
| tree | 20ce9898465e8d4c49eeff12a9ea55572517ea7b /client/menu/settings/input/input_manager.gd | |
| parent | fd80142282fcef628466a18e3ea62f0d1372d807 (diff) | |
| download | hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar.bz2 hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar.zst | |
reorganize client gui files
Diffstat (limited to 'client/menu/settings/input/input_manager.gd')
| -rw-r--r-- | client/menu/settings/input/input_manager.gd | 101 | 
1 files changed, 0 insertions, 101 deletions
| diff --git a/client/menu/settings/input/input_manager.gd b/client/menu/settings/input/input_manager.gd deleted file mode 100644 index e3158a03..00000000 --- a/client/menu/settings/input/input_manager.gd +++ /dev/null @@ -1,101 +0,0 @@ -# Hurry Curry! - a game about cooking -# Copyright (C) 2025 Hurry Curry! contributors -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License only. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program.  If not, see <https://www.gnu.org/licenses/>. -# -extends Node - -enum EventType { -	KEYBOARD, -	JOYPAD, -	TOUCH, -	OTHER -} - -var default_input_map = {} -var input_map: Dictionary - -func _init(): -	default_input_map = get_input_map() -	input_map = default_input_map.duplicate(true) - -func get_input_map() -> Dictionary: -	var actions = InputMap.get_actions().filter(func isBuiltIn(k: String): return !k.begins_with("ui_")) -	var kb = {} -	for a in actions: -		var input_events: Array[InputEvent] = InputMap.action_get_events(a).duplicate(true) -		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 settings() -> Array: -	var entries := [] -	for k in input_map.keys(): entries.append(InputSetting.new(k)) -	return entries - -func change_input_map_action(action_name: String, events: Array, save: bool = true): -	if !InputMap.has_action(action_name): -		push_error("Action %s does not exist" % action_name, false) -		return -	# Erase previous keybindings -	InputMap.action_erase_events(action_name) -	# Add new keybindings -	for e in events: -		InputMap.action_add_event(action_name, e) -	 -	if save: -		# Update input map dictionary -		input_map = get_input_map() -		# Save settings -		Global.set_setting("input_map", input_map.duplicate(true)) - -func apply_input_map(new_input_map: Dictionary): -	# Load into input map dictionary -	for k in new_input_map.keys(): -		input_map[k] = [] -		for a in new_input_map[k]: -			input_map[k].append(a) -	 -	# Apply keybindings -	for k in input_map.keys(): -		change_input_map_action(k, input_map[k], false) - -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").format([OS.get_keycode_string(input_event.physical_keycode)]) -	elif input_event is InputEventMouseButton: -		return tr("c.settings.input.mouse_button").format([input_event.button_index]) -	elif input_event is InputEventJoypadButton: -		return tr("c.settings.input.joypad").format([input_event.button_index]) -	elif input_event is InputEventJoypadMotion: -		return tr("c.settings.input.joypad_axis").format([input_event.axis]) -	else: -		return tr("c.settings.input.other_event") | 
