From 1b44ccd206630e7d98fc78038fddb7fa5305ab82 Mon Sep 17 00:00:00 2001 From: AleaJactaEst Date: Sat, 12 Feb 2022 23:15:01 +0100 Subject: [PATCH] configure control, but not activate --- locales/en.po | 6 + locales/fr.po | 6 + locales/messages.pot | 9 + scenes/controls/add.png | Bin 0 -> 208 bytes scenes/controls/add.png.import | 34 ++++ scenes/controls/add.svg | 46 +++++ scenes/controls/add.svg.import | 35 ++++ scenes/controls/control_function.gd | 25 +++ scenes/controls/control_function.tscn | 32 +++ scenes/controls/control_input.gd | 23 +++ scenes/controls/control_input.tscn | 44 +++++ scenes/controls/controls.gd | 272 ++++++++++++++++++++++++++ scenes/controls/controls.tscn | 106 ++++++++++ scenes/controls/trash.png | Bin 0 -> 666 bytes scenes/controls/trash.png.import | 34 ++++ scenes/controls/trash.svg | 97 +++++++++ scenes/controls/trash.svg.import | 35 ++++ scenes/hud/hud.gd | 12 +- scenes/hud/hud.tscn | 10 +- scenes/languages/languages.gd | 2 +- scenes/languages/languages.tscn | 1 + 21 files changed, 821 insertions(+), 8 deletions(-) create mode 100644 scenes/controls/add.png create mode 100644 scenes/controls/add.png.import create mode 100644 scenes/controls/add.svg create mode 100644 scenes/controls/add.svg.import create mode 100644 scenes/controls/control_function.gd create mode 100644 scenes/controls/control_function.tscn create mode 100644 scenes/controls/control_input.gd create mode 100644 scenes/controls/control_input.tscn create mode 100644 scenes/controls/controls.gd create mode 100644 scenes/controls/controls.tscn create mode 100644 scenes/controls/trash.png create mode 100644 scenes/controls/trash.png.import create mode 100644 scenes/controls/trash.svg create mode 100644 scenes/controls/trash.svg.import diff --git a/locales/en.po b/locales/en.po index 5885d1f..936465b 100644 --- a/locales/en.po +++ b/locales/en.po @@ -29,3 +29,9 @@ msgstr "Select your language" msgid "Quit" msgstr "Exit" +msgid "Sort by input" +msgstr "Sort by input" + +msgid "Reload system config" +msgstr "Reload system config" + diff --git a/locales/fr.po b/locales/fr.po index de844ca..168e8d7 100644 --- a/locales/fr.po +++ b/locales/fr.po @@ -29,3 +29,9 @@ msgstr "Sélectionner votre langue" msgid "Quit" msgstr "Sortir" +msgid "Sort by input" +msgstr "Trié par contrôle" + +msgid "Reload system config" +msgstr "Recharger la configuration de base" + diff --git a/locales/messages.pot b/locales/messages.pot index 900dec7..267ead0 100644 --- a/locales/messages.pot +++ b/locales/messages.pot @@ -19,3 +19,12 @@ msgstr "" msgid "Quit" msgstr "" + +msgid "Edit control" +msgstr "" + +msgid "Sort by input" +msgstr "" + +msgid "Reload system config" +msgstr "" diff --git a/scenes/controls/add.png b/scenes/controls/add.png new file mode 100644 index 0000000000000000000000000000000000000000..663605f51a053037da7d084b4ce3c23c30b3652a GIT binary patch literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^;y|p(!3HFaI1L1V6lZ})WHFE~0Aa>+6-kqU49ODL zh?3y^w370~qEv?R@^Zb*yzJuS#DY}4{G#;P?`))iief!o978-h-(FhC+YrFxdXc%N zGf|T5zy>MhO{{F*39Zvu94{@;_tWyK(f;PL{``@fqHz@uTkAKrY2N6Q5ZcT4y?gPY xiZ7E`rJrfsD`2@T9KPuP$L%5@HUIhQ8Rq_GFJh}&wF_twgQu&X%Q~loCIF>4M*08% literal 0 HcmV?d00001 diff --git a/scenes/controls/add.png.import b/scenes/controls/add.png.import new file mode 100644 index 0000000..11c6a04 --- /dev/null +++ b/scenes/controls/add.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture2D" +uid="uid://dhme55udo3chx" +path="res://.godot/imported/add.png-857c1c6e0729b01483785eee8bf67941.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/controls/add.png" +dest_files=["res://.godot/imported/add.png-857c1c6e0729b01483785eee8bf67941.stex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +compress/streamed=false +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/HDR_as_SRGB=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/controls/add.svg b/scenes/controls/add.svg new file mode 100644 index 0000000..ac59e02 --- /dev/null +++ b/scenes/controls/add.svg @@ -0,0 +1,46 @@ + + + + + + + + + + diff --git a/scenes/controls/add.svg.import b/scenes/controls/add.svg.import new file mode 100644 index 0000000..35605cf --- /dev/null +++ b/scenes/controls/add.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture2D" +uid="uid://24bvysta5tma" +path="res://.godot/imported/add.svg-26b0305e6798499dcda78ea163b6ef1d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/controls/add.svg" +dest_files=["res://.godot/imported/add.svg-26b0305e6798499dcda78ea163b6ef1d.stex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +compress/streamed=false +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/HDR_as_SRGB=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 diff --git a/scenes/controls/control_function.gd b/scenes/controls/control_function.gd new file mode 100644 index 0000000..275116d --- /dev/null +++ b/scenes/controls/control_function.gd @@ -0,0 +1,25 @@ +extends HBoxContainer + + +signal add_pressed( command ) + +var action = null + +func set_label( command ): + $Label.text = command + +func set_action( _action ): + action = _action + +func set_param(_action, _command, position): + set_label(_command) + set_action(_action) + if position: + $Add_front.visible = true + $Add.visible = false + else: + $Add_front.visible = false + $Add.visible = true + +func _on_add_pressed(): + emit_signal( "add_pressed", action, $Label.text ) diff --git a/scenes/controls/control_function.tscn b/scenes/controls/control_function.tscn new file mode 100644 index 0000000..1ff21fa --- /dev/null +++ b/scenes/controls/control_function.tscn @@ -0,0 +1,32 @@ +[gd_scene load_steps=3 format=3 uid="uid://d2nu5ak74y4xk"] + +[ext_resource type="Script" path="res://scenes/controls/control_function.gd" id="1_2cvgr"] +[ext_resource type="Texture2D" uid="uid://dhme55udo3chx" path="res://scenes/controls/add.png" id="2_f4wes"] + +[node name="Control" type="HBoxContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( "1_2cvgr" ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Add_front" type="TextureButton" parent="."] +offset_right = 23.0 +offset_bottom = 600.0 +texture_normal = ExtResource( "2_f4wes" ) +stretch_mode = 3 + +[node name="Label" type="Label" parent="."] +offset_left = 27.0 +offset_top = 288.0 +offset_right = 997.0 +offset_bottom = 311.0 +size_flags_horizontal = 3 + +[node name="Add" type="TextureButton" parent="."] +offset_left = 1001.0 +offset_right = 1024.0 +offset_bottom = 600.0 +texture_normal = ExtResource( "2_f4wes" ) +stretch_mode = 3 diff --git a/scenes/controls/control_input.gd b/scenes/controls/control_input.gd new file mode 100644 index 0000000..29a4d7d --- /dev/null +++ b/scenes/controls/control_input.gd @@ -0,0 +1,23 @@ +extends HBoxContainer + + +signal del_pressed( command, control, eventInput ) + +var command:String +var eventInput + +func set_param( command:String, control:String, param_comment:String, eventInput ): + self.command = command + $Label.text = control + self.eventInput = eventInput + if param_comment.length() > 0: + $Comment.text = param_comment + $Empty.visible = false + $Comment.visible = true + else: + $Comment.text = "" + $Empty.visible = true + $Comment.visible = false + +func _on_del_pressed(): + emit_signal( "del_pressed", self.command, $Label.text, self.eventInput ) diff --git a/scenes/controls/control_input.tscn b/scenes/controls/control_input.tscn new file mode 100644 index 0000000..a12cd0e --- /dev/null +++ b/scenes/controls/control_input.tscn @@ -0,0 +1,44 @@ +[gd_scene load_steps=3 format=3 uid="uid://mtftrelrm0uy"] + +[ext_resource type="Script" path="res://scenes/controls/control_input.gd" id="1_dp231"] +[ext_resource type="Texture2D" uid="uid://js4s65teoql3" path="res://scenes/controls/trash.png" id="2_r7srr"] + +[node name="Control" type="HBoxContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = ExtResource( "1_dp231" ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Empty" type="Label" parent="."] +offset_right = 329.0 +offset_bottom = 600.0 +size_flags_horizontal = 3 +size_flags_vertical = 5 + +[node name="Comment" type="Label" parent="."] +offset_left = 333.0 +offset_right = 662.0 +offset_bottom = 600.0 +size_flags_horizontal = 3 +size_flags_vertical = 5 + +[node name="Del" type="TextureButton" parent="."] +offset_left = 666.0 +offset_right = 690.0 +offset_bottom = 600.0 +hint_tooltip = "Delete" +size_flags_horizontal = 5 +size_flags_vertical = 5 +texture_normal = ExtResource( "2_r7srr" ) +stretch_mode = 0 + +[node name="Label" type="Label" parent="."] +offset_left = 694.0 +offset_right = 1024.0 +offset_bottom = 600.0 +size_flags_horizontal = 3 +size_flags_vertical = 5 diff --git a/scenes/controls/controls.gd b/scenes/controls/controls.gd new file mode 100644 index 0000000..f5977b6 --- /dev/null +++ b/scenes/controls/controls.gd @@ -0,0 +1,272 @@ +extends Control + + +var control_system_conf = {} + + +func _init(): + load_control_system() + + +func _ready(): + pass + + +func reload_control_system(): + # Adding new Action + for key in control_system_conf: + if not InputMap.has_action(key): + InputMap.add_action(key) + # Adding new event + for newevent in control_system_conf[key]: + var ele = generate_inputevent(newevent) + if not InputMap.action_has_event(key, ele): + InputMap.action_add_event(key, ele) + # Remove action/event not used + for keyInput in InputMap.get_actions(): + var foundAction:bool = false + for key in control_system_conf: + if key == keyInput: + foundAction = true + break + if not foundAction: + InputMap.erase_action(keyInput) + continue + var listInput = InputMap.get_action_list(keyInput) + for eventInput in listInput: + var foundEvent:bool = false + var vis = get_dict_inputevent(eventInput) + for v in control_system_conf[keyInput]: + if compare_dict_inputevent(v, vis): + foundEvent = true + break + if not foundEvent: + InputMap.action_erase_event(keyInput, eventInput) + + +func compare_dict_inputevent(ref, cmp): + if ref.size() != cmp.size(): + return false + for key in ref: + if ref[key] != cmp[key]: + return false + return true + + +func get_dict_inputevent(event): + if event is InputEventKey: + return { + 'type' : 'InputEventKey', + 'keycode' : event.get_keycode(), + 'physical_keycode' : event.get_physical_keycode(), + 'unicode' :event.get_unicode(), + 'echo' : event.is_echo(), + 'alt' : event.is_alt_pressed(), + 'command' : event.is_command_pressed(), + 'control' : event.is_ctrl_pressed(), + 'meta' : event.is_meta_pressed(), + 'shift' : event.is_shift_pressed(), + 'storing_command': event.is_storing_command() + } + elif event is InputEventMouseButton: + return { 'type' : 'InputEventMouseButton', 'value' : event.get_button_index() } + elif event is InputEventJoypadButton: + return { 'type' : 'InputEventJoypadButton', 'value' : event.get_button_index() } + return { 'type' : 'Unknown'} + + + +func generate_inputevent(param): + if param['type'] == 'InputEventKey': + var ele:InputEventKey = InputEventKey.new() + ele.set_physical_scancode(param['physical_scancode']) + ele.set_scancode(param['scancode']) + ele.set_echo(param['echo']) + if OS.get_ime_selection(): + ele.set_unicode(param['unicode']) + ele.set_alt(param['alt']) + ele.set_command(param['command']) + ele.set_control(param['control']) + ele.set_metakey(param['meta']) + ele.set_shift(param['shift']) + return ele + elif param['type'] == 'InputEventMouseButton': + var ele:InputEventMouseButton = InputEventMouseButton.new() + ele.set_button_index(param['value']) + return ele + elif param['type'] == 'InputEventJoypadButton': + var ele:InputEventJoypadButton = InputEventJoypadButton.new() + ele.set_button_index(param['value']) + return ele + return null + + +func get_hash_inputevent(event): + var head:String + if event is InputEventKey: + head = 'a' + elif event is InputEventMouseButton: + head = 'm' + elif event is InputEventJoypadButton: + head = 'j' + else: + head ='z' + return head + str(get_string_input(event)) + + +func get_string_input_mousse_button(event:InputEventMouseButton): + match event.get_button_index(): + 1: + return "BUTTON_LEFT" + 3: + return "BUTTON_MIDDLE" + 2: + return "BUTTON_RIGHT" + 4: + return "BUTTON_WHEEL_UP" + 5: + return "BUTTON_WHEEL_DOWN" + 6: + return "BUTTON_WHEEL_LEFT" + 7: + return "BUTTON_WHEEL_RIGHT" + 8: + return "BUTTON_XBUTTON1" + 9: + return "BUTTON_XBUTTON2" + _: + return "MOUSSE BUTTON: " + str(event.get_button_index()) + + +func get_string_input_joypad_button(event:InputEventJoypadButton): + match event.get_button_index(): + 0: + return "JOY_BUTTON_A" + 1: + return "JOY_BUTTON_B" + 2: + return "JOY_BUTTON_X" + 3: + return "JOY_BUTTON_Y" + 4: + return "JOY_BUTTON_BACK" + 5: + return "JOY_BUTTON_GUIDE" + 6: + return "JOY_BUTTON_START" + 7: + return "JOY_BUTTON_LEFT_STICK" + 8: + return "JOY_BUTTON_RIGHT_STICK" + 9: + return "JOY_BUTTON_LEFT_SHOULDER" + 10: + return "JOY_BUTTON_RIGHT_SHOULDER" + 11: + return "JOY_BUTTON_DPAD_UP" + 12: + return "JOY_BUTTON_DPAD_DOWN" + 13: + return "JOY_BUTTON_DPAD_LEFT" + 14: + return "JOY_BUTTON_DPAD_RIGHT" + _: + return "JOYPAD BUTTON: " + str(event.get_button_index()) + + +func get_string_input_keyboard(event:InputEventKey): + return OS.get_keycode_string(event.keycode) + + +func get_string_input(event): + if event is InputEventKey: + return get_string_input_keyboard(event) # OS.get_scancode_string(event.get_scancode_with_modifiers()) + elif event is InputEventMouseButton: + return get_string_input_mousse_button(event) + elif event is InputEventJoypadButton: + return get_string_input_joypad_button(event) + else: + return str(event) + + +func load_current_control(): + var conf = {} + for key in InputMap.get_actions(): + var a = InputMap.action_get_events(key) + var beta = [] + for z in a: + beta.append( get_dict_inputevent(z) ) + conf[key] = beta + return conf + + +func configure_control(): + if $Window/VBox/Menu/SortByInput.is_pressed(): + configure_control_sort_by_input() + else: + configure_control_sort_by_categories() + + +func configure_control_sort_by_input(): + #$Window/VBox/Input/Control + var def = {} + for action in InputMap.get_actions(): + for z in InputMap.action_get_events(action): + var id = str(get_hash_inputevent(z)) + "_" + str(action) + def[id] = { 'event': z, 'action': action } + var defsorted = def.keys() + defsorted.sort() + var lastevent = null + for id in defsorted: + var z = def[id]['event'] + var action = def[id]['action'] + var zhash = get_dict_inputevent(z).hash() + if zhash != lastevent: + var separator = HSeparator.new() + $Window/VBox/Input/Control.add_child( separator ) + lastevent = zhash + if z is InputEventKey: + var item = preload( "res://scenes/controls/control_input.tscn" ).instantiate(1) #.instance() + item.set_param(action, get_string_input_keyboard(z), action, z) + #item.connect( "del_pressed", self, "_on_input_box_del_pressed" ) + #print(action,':', z, z.get_scancode_with_modifiers(),' - ', z.get_scancode(), ' - ', z.unicode , ' - ', OS.get_scancode_string(z.get_scancode_with_modifiers())) + $Window/VBox/Input/Control.add_child( item ) + #$Window/VBox/Test.add_child( item ) + elif z is InputEventMouseButton: + var item = preload( "res://scenes/controls/control_input.tscn" ).instantiate() + #item.set_label(action, "Mouse Button: " + str(z.get_button_index())) + item.set_param(action, "Mouse Button: " + get_string_input_mousse_button(z), action, z) + #item.connect( "del_pressed", self, "_on_input_box_del_pressed" ) + $Window/VBox/Input/Control.add_child( item ) + #print(action,':', z, z.get_button_mask(), ' - ', z.get_factor(), ' - ' , z.get_button_index() ) + elif z is InputEventJoypadButton: + #print(action,':', z, z.get_button_index() ) + var item = preload( "res://scenes/controls/control_input.tscn" ).instantiate() + #item.set_label(action, "Joypad Button: " + str(z.get_button_index())) + item.set_param(action, "Joypad Button: " + get_string_input_joypad_button(z), action, z) + #item.connect( "del_pressed", self, "_on_input_box_del_pressed" ) + $Window/VBox/Input/Control.add_child( item ) + for action in InputMap.get_actions(): + var separator = HSeparator.new() + $Window/VBox/Input/Control.add_child( separator ) + var control_box = preload( "res://scenes/controls/control_function.tscn" ).instantiate() + #control_box.set_label(key) + control_box.set_param(action, action, true) + #control_box.connect( "add_pressed", self, "_on_control_box_add_pressed" ) + $Window/VBox/Input/Control.add_child( control_box ) + + +func configure_control_sort_by_categories(): + print("configure_control_sort_by_categories") + + +func load_control_system(): + control_system_conf = load_current_control() + + +func _on_quit_pressed(): + $Window.visible = false + + +func _on_sort_by_input_pressed(): + configure_control() diff --git a/scenes/controls/controls.tscn b/scenes/controls/controls.tscn new file mode 100644 index 0000000..800a758 --- /dev/null +++ b/scenes/controls/controls.tscn @@ -0,0 +1,106 @@ +[gd_scene load_steps=2 format=3 uid="uid://cl8xk8w3jmta0"] + +[ext_resource type="Script" path="res://scenes/controls/controls.gd" id="1_2c8s6"] + +[node name="Control" type="Control"] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( "1_2c8s6" ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Window" type="Window" parent="."] +title = "Edit control" +size = Vector2i(400, 500) +visible = false +content_scale_mode = 1 +content_scale_aspect = 4 + +[node name="VBox" type="VBoxContainer" parent="Window"] +offset_right = 40.0 +offset_bottom = 40.0 +size_flags_horizontal = 6 +size_flags_vertical = 6 + +[node name="Menu" type="HBoxContainer" parent="Window/VBox"] +offset_right = 301.0 +offset_bottom = 31.0 +size_flags_horizontal = 3 + +[node name="SortByInput" type="CheckBox" parent="Window/VBox/Menu"] +offset_right = 127.0 +offset_bottom = 31.0 +size_flags_horizontal = 7 +text = "Sort by input" + +[node name="Reload" type="Button" parent="Window/VBox/Menu"] +offset_left = 131.0 +offset_right = 301.0 +offset_bottom = 31.0 +size_flags_horizontal = 7 +text = "Reload system config" + +[node name="Input" type="ScrollContainer" parent="Window/VBox"] +offset_top = 35.0 +offset_right = 301.0 +offset_bottom = 35.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="Control" type="VBoxContainer" parent="Window/VBox/Input"] +offset_right = 301.0 +offset_bottom = 56.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="Label" type="Label" parent="Window/VBox/Input/Control"] +offset_right = 293.0 +offset_bottom = 26.0 +size_flags_horizontal = 3 +size_flags_vertical = 7 +text = "Test" + +[node name="Label2" type="Label" parent="Window/VBox/Input/Control"] +offset_top = 30.0 +offset_right = 293.0 +offset_bottom = 56.0 +size_flags_horizontal = 3 +size_flags_vertical = 7 +text = "Test" + +[node name="Test" type="VBoxContainer" parent="Window/VBox"] +offset_top = 39.0 +offset_right = 301.0 +offset_bottom = 95.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="Label3" type="Label" parent="Window/VBox/Test"] +offset_right = 301.0 +offset_bottom = 26.0 +size_flags_horizontal = 3 +size_flags_vertical = 7 +text = "Test" + +[node name="Label4" type="Label" parent="Window/VBox/Test"] +offset_top = 30.0 +offset_right = 301.0 +offset_bottom = 56.0 +size_flags_horizontal = 3 +size_flags_vertical = 7 +text = "Test" + +[node name="Quit" type="Button" parent="Window/VBox"] +offset_top = 99.0 +offset_right = 301.0 +offset_bottom = 130.0 +size_flags_horizontal = 6 +size_flags_vertical = 10 +text = "Quit" + +[connection signal="close_requested" from="Window" to="." method="_on_quit_pressed"] +[connection signal="pressed" from="Window/VBox/Menu/SortByInput" to="." method="_on_sort_by_input_pressed"] +[connection signal="pressed" from="Window/VBox/Menu/Reload" to="." method="reload_system_config"] +[connection signal="pressed" from="Window/VBox/Quit" to="." method="_on_quit_pressed"] diff --git a/scenes/controls/trash.png b/scenes/controls/trash.png new file mode 100644 index 0000000000000000000000000000000000000000..7b43c84066a789f01f21c5bb82d8a6d724c8b4c1 GIT binary patch literal 666 zcmV;L0%iS)P)3nRD*U+^u2Xf4pYmzJq7@gll+&)7ZsR zT*n4}qJ}qyuvJA;s$QxJ>KDJOzb0WVJ-SM@E9FD z#Am!kvyLrv(Lfs~uz)|9tKh<1#GZ_??ZE2dTRk;GNjnBDPe8C7@9n_aLbo2BtxN$d zh1{wHofwk{8i6ShY?cU)tDq5>as|`2Xh1;|J5wOo39LQ^!z>y%2O}+N;CB{0iGohF zFDO~mQf#g>A#o`JXDblQM(k3|{%rIONa*LXQwVe~} zXFrUfrB|8e73aw)f^N)QjBVusWr9td%7RDLgmOJTT}8o4Mlh-_m+SFL6$MwK{UDw< z6{U0)7vo-yzBNU1Q|x6$9uK|N6&vk1_j(Ta4}w9*VzFr+T>t<807*qoM6N<$f)c_V A + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scenes/controls/trash.svg.import b/scenes/controls/trash.svg.import new file mode 100644 index 0000000..883c4ef --- /dev/null +++ b/scenes/controls/trash.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture2D" +uid="uid://c7xor1oxx72h4" +path="res://.godot/imported/trash.svg-f0ab7922f4cdf12c78a96422c95706d8.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scenes/controls/trash.svg" +dest_files=["res://.godot/imported/trash.svg-f0ab7922f4cdf12c78a96422c95706d8.stex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +compress/streamed=false +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/HDR_as_SRGB=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 diff --git a/scenes/hud/hud.gd b/scenes/hud/hud.gd index 57f61e2..dc00d2f 100644 --- a/scenes/hud/hud.gd +++ b/scenes/hud/hud.gd @@ -1,18 +1,16 @@ extends Control -func _input(event): - if Input.is_action_pressed("ui_menu"): +func _input(_event): + if Input.is_action_just_pressed("ui_menu"): $Menu.visible = ! $Menu.visible func _on_timer_timeout(): - print("fin") $Message/Label.visible = false func _on_quit_pressed(): - #get_tree().quit() $ConfirmQuit.popup_centered() $ConfirmQuit.visible = true pass @@ -25,3 +23,9 @@ func _on_confirmation_dialog_confirmed(): func _on_languages_pressed(): $MenuOption/Window.popup_centered() $MenuOption/Window.visible = true + + +func _on_keys_pressed(): + #$MenuControl/Window.popup_centered() + #$MenuControl/Window.visible = true + pass diff --git a/scenes/hud/hud.tscn b/scenes/hud/hud.tscn index be587e2..5f6a801 100644 --- a/scenes/hud/hud.tscn +++ b/scenes/hud/hud.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=3 uid="uid://cdyi1a858p7em"] +[gd_scene load_steps=4 format=3 uid="uid://cdyi1a858p7em"] [ext_resource type="Script" path="res://scenes/hud/hud.gd" id="1_s6f6d"] [ext_resource type="PackedScene" uid="uid://dpvequp5fv27k" path="res://scenes/languages/languages.tscn" id="2_um8fw"] +[ext_resource type="PackedScene" uid="uid://cl8xk8w3jmta0" path="res://scenes/controls/controls.tscn" id="3_08xl7"] [node name="Control" type="Control"] anchor_right = 1.0 @@ -41,8 +42,8 @@ __meta__ = { } [node name="Keys" type="Button" parent="Menu"] -offset_left = 444.0 -offset_right = 488.0 +offset_left = 510.0 +offset_right = 554.0 offset_bottom = 40.0 text = "Keys" @@ -69,6 +70,9 @@ dialog_text = "Do you want quit?" [node name="MenuOption" parent="." instance=ExtResource( "2_um8fw" )] visible = false +[node name="MenuControl" parent="." instance=ExtResource( "3_08xl7" )] + +[connection signal="pressed" from="Menu/Keys" to="." method="_on_keys_pressed"] [connection signal="pressed" from="Menu/Languages" to="." method="_on_languages_pressed"] [connection signal="pressed" from="Menu/Quit" to="." method="_on_quit_pressed"] [connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/scenes/languages/languages.gd b/scenes/languages/languages.gd index 6eff9ee..a63210a 100644 --- a/scenes/languages/languages.gd +++ b/scenes/languages/languages.gd @@ -31,7 +31,7 @@ func _ready(): $Window/VBoxContainer/Select.select(selected) -func _on_select_item_selected(index): +func _on_select_item_selected(_index): var pos = 0 for key in TranslationServer.get_loaded_locales(): if pos == $Window/VBoxContainer/Select.get_selected(): diff --git a/scenes/languages/languages.tscn b/scenes/languages/languages.tscn index 9b143b3..dfb1c4a 100644 --- a/scenes/languages/languages.tscn +++ b/scenes/languages/languages.tscn @@ -33,5 +33,6 @@ offset_right = 43.0 offset_bottom = 66.0 text = "Quit" +[connection signal="close_requested" from="Window" to="." method="_on_quit_pressed"] [connection signal="item_selected" from="Window/VBoxContainer/Select" to="." method="_on_select_item_selected"] [connection signal="pressed" from="Window/VBoxContainer/Quit" to="." method="_on_quit_pressed"]