From ecc678a1e2c6e1f36acd256f39bc2197de0172a2 Mon Sep 17 00:00:00 2001 From: osquallo Date: Mon, 30 Jul 2018 14:56:17 +0200 Subject: [PATCH] fix l'appuis sur echap ne liberait plus la souris --- scenes/GUI/GUI.gd | 2 +- scenes/GUI/GUI.tscn | 2 +- scenes/GUI/HUD/HUD.gd | 13 +------------ scenes/GUI/HUD/HUD.tscn | 6 +----- scenes/GUI/HUD/WindowControl.gd | 10 ++++++++-- scenes/GUI/Settings/Settings.tscn | 2 +- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/scenes/GUI/GUI.gd b/scenes/GUI/GUI.gd index 220b5d9..9a5df4f 100644 --- a/scenes/GUI/GUI.gd +++ b/scenes/GUI/GUI.gd @@ -41,7 +41,7 @@ func _input(event): play() # ---------------------------------- # Capturing/Freeing the cursor - if Input.is_action_just_pressed("ui_free_cursor") and event is InputEventKey: + if Input.is_action_just_pressed("ui_free_cursor"): if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE: Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) else: diff --git a/scenes/GUI/GUI.tscn b/scenes/GUI/GUI.tscn index a4c6885..ef7b0b3 100644 --- a/scenes/GUI/GUI.tscn +++ b/scenes/GUI/GUI.tscn @@ -19,7 +19,7 @@ _sections_unfolded = [ "Font", "Settings" ] default_font = SubResource( 1 ) -[node name="GUI" type="MarginContainer"] +[node name="GUI" type="MarginContainer" index="0"] anchor_left = 0.0 anchor_top = 0.0 diff --git a/scenes/GUI/HUD/HUD.gd b/scenes/GUI/HUD/HUD.gd index e8541b5..c863e5a 100644 --- a/scenes/GUI/HUD/HUD.gd +++ b/scenes/GUI/HUD/HUD.gd @@ -26,15 +26,4 @@ func _on_SaveHUD_pressed(): for child in get_node("Windows" ).get_children(): child.save_to_file( config_file ) - config_file.save( HUD_config_file ) - -func _on_Windows_gui_input( event ): - if event is InputEventMouseButton \ - and Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE \ - and event.is_action_pressed( "ui_free_cursor" ): - Input.set_mouse_mode( Input.MOUSE_MODE_CAPTURED ) - - elif event is InputEventMouseButton \ - and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED \ - and event.is_action_pressed( "ui_free_cursor" ): - Input.set_mouse_mode( Input.MOUSE_MODE_VISIBLE ) \ No newline at end of file + config_file.save( HUD_config_file ) \ No newline at end of file diff --git a/scenes/GUI/HUD/HUD.tscn b/scenes/GUI/HUD/HUD.tscn index 8d1d313..05a8d18 100644 --- a/scenes/GUI/HUD/HUD.tscn +++ b/scenes/GUI/HUD/HUD.tscn @@ -12,7 +12,7 @@ [ext_resource path="res://scenes/GUI/HUD/trauma.gd" type="Script" id=10] [ext_resource path="res://scenes/GUI/HUD/douleur.gd" type="Script" id=11] -[node name="HUD" type="MarginContainer"] +[node name="HUD" type="MarginContainer" index="0"] anchor_left = 0.0 anchor_top = 0.0 @@ -33,7 +33,6 @@ _sections_unfolded = [ "Margin", "Mouse", "Rect", "Size Flags", "Theme", "Visibi [node name="overlay_oubli" type="Panel" parent="." index="0"] -visible = false modulate = Color( 0, 0, 0, 0 ) anchor_left = 0.0 anchor_top = 0.0 @@ -51,7 +50,6 @@ _sections_unfolded = [ "Mouse", "Visibility" ] [node name="overlay_douleur" type="Panel" parent="." index="1"] -visible = false modulate = Color( 1, 0, 0, 0 ) anchor_left = 0.0 anchor_top = 0.0 @@ -1338,8 +1336,6 @@ flat = false align = 1 _sections_unfolded = [ "Size Flags" ] -[connection signal="gui_input" from="Windows" to="." method="_on_Windows_gui_input"] - [connection signal="gui_input" from="Windows/Test/VBoxContainer/Header" to="Windows/Test" method="_on_Header_gui_input"] [connection signal="pressed" from="Windows/Test/VBoxContainer/Header/HBoxContainer/Quit" to="Windows/Test" method="_on_Quit_pressed"] diff --git a/scenes/GUI/HUD/WindowControl.gd b/scenes/GUI/HUD/WindowControl.gd index 8d186a5..cefeec7 100644 --- a/scenes/GUI/HUD/WindowControl.gd +++ b/scenes/GUI/HUD/WindowControl.gd @@ -6,7 +6,7 @@ export(bool) var is_borderless = false var current_rect_size = Vector2( 0, 0 ) -var current_rect_position = Vector2( 0, 0 ) +var current_rect_position = Vector2( -1, -1 ) var is_resizing = false var is_moving = false @@ -118,10 +118,16 @@ func load_from_file( config_file ): func save_to_file( config_file ): config_file.set_value(self.name, "position", self.rect_position) - config_file.set_value(self.name, "size", current_rect_size) + + if not current_rect_size == Vector2( -1, -1 ): + config_file.set_value(self.name, "size", current_rect_size) + else: + config_file.set_value(self.name, "size", self.rect_size) + if $VBoxContainer/Content.visible: config_file.set_value(self.name, "opened", true) else: config_file.set_value(self.name, "opened", false) + config_file.set_value(self.name, "borderless", is_borderless) \ No newline at end of file diff --git a/scenes/GUI/Settings/Settings.tscn b/scenes/GUI/Settings/Settings.tscn index c1b165e..a031f84 100644 --- a/scenes/GUI/Settings/Settings.tscn +++ b/scenes/GUI/Settings/Settings.tscn @@ -148,7 +148,7 @@ use_filter = false font_data = ExtResource( 2 ) _sections_unfolded = [ "Font", "Settings" ] -[node name="Settings" type="MarginContainer" index="0"] +[node name="Settings" type="MarginContainer"] anchor_left = 0.0 anchor_top = 0.0