From 995f2ab8b06295047dae2d46fd1f397ae02bd0bd Mon Sep 17 00:00:00 2001 From: Hamcha Date: Tue, 21 Jul 2020 10:51:15 +0200 Subject: [PATCH] Small refactor --- Actors/Objects/Door/Door.gd | 9 ++-- Scenes/UI.tscn | 5 +- Scenes/UI/Panels/Logs.gd | 16 ++++++ Scenes/UI/Panels/Logs.tscn | 75 ++++++++++++++++++++++++++ Scenes/UI/{ => Panels}/ServerInfo.gd | 0 Scenes/UI/{ => Panels}/ServerInfo.tscn | 3 +- Scenes/UI/Widgets/ResizablePanel.gd | 10 ---- Scenes/UI/Widgets/ResizablePanel.tscn | 61 +-------------------- Sounds/SFX/sources/door-sound.aup | 10 ++-- 9 files changed, 108 insertions(+), 81 deletions(-) create mode 100644 Scenes/UI/Panels/Logs.gd create mode 100644 Scenes/UI/Panels/Logs.tscn rename Scenes/UI/{ => Panels}/ServerInfo.gd (100%) rename Scenes/UI/{ => Panels}/ServerInfo.tscn (84%) diff --git a/Actors/Objects/Door/Door.gd b/Actors/Objects/Door/Door.gd index 4abce11..4a7fb94 100644 --- a/Actors/Objects/Door/Door.gd +++ b/Actors/Objects/Door/Door.gd @@ -35,12 +35,15 @@ master func set_open(open: bool): remotesync func anim_open(open: bool): if open: + if $Sprite.animation != "open": + $AudioStreamPlayer2D.stream = open_sound + $AudioStreamPlayer2D.play() $Sprite.play("open") - $AudioStreamPlayer2D.stream = open_sound else: + if $Sprite.animation != "close": + $AudioStreamPlayer2D.stream = close_sound + $AudioStreamPlayer2D.play() $Sprite.play("close") - $AudioStreamPlayer2D.stream = close_sound - $AudioStreamPlayer2D.play() func _animation_finished(): if is_network_master(): diff --git a/Scenes/UI.tscn b/Scenes/UI.tscn index 328f009..68fdf5b 100644 --- a/Scenes/UI.tscn +++ b/Scenes/UI.tscn @@ -2,8 +2,8 @@ [ext_resource path="res://Scenes/UI/SpaceMap.tscn" type="PackedScene" id=1] [ext_resource path="res://Scenes/UI.gd" type="Script" id=2] -[ext_resource path="res://Scenes/UI/Widgets/ResizablePanel.tscn" type="PackedScene" id=3] -[ext_resource path="res://Scenes/UI/ServerInfo.tscn" type="PackedScene" id=4] +[ext_resource path="res://Scenes/UI/Panels/Logs.tscn" type="PackedScene" id=3] +[ext_resource path="res://Scenes/UI/Panels/ServerInfo.tscn" type="PackedScene" id=4] [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.133333, 0.12549, 0.203922, 0.705882 ) @@ -36,7 +36,6 @@ margin_left = 10.0 margin_top = 10.0 margin_right = -857.0 margin_bottom = -566.0 -title = "Log" [node name="Menu" type="PanelContainer" parent="."] anchor_left = 1.0 diff --git a/Scenes/UI/Panels/Logs.gd b/Scenes/UI/Panels/Logs.gd new file mode 100644 index 0000000..bf5ecb7 --- /dev/null +++ b/Scenes/UI/Panels/Logs.gd @@ -0,0 +1,16 @@ +extends Control + +onready var chat_bar = $ResizablePanel/LineEdit + +func _input(event): + if event is InputEventMouseButton: + if not chat_bar_focus: + chat_bar.release_focus() + +var chat_bar_focus = false + +func _chat_bar_status(editing): + $"/root/scene".writing = editing + +func _chat_bar_focus(entered): + chat_bar_focus = entered diff --git a/Scenes/UI/Panels/Logs.tscn b/Scenes/UI/Panels/Logs.tscn new file mode 100644 index 0000000..ab0f88b --- /dev/null +++ b/Scenes/UI/Panels/Logs.tscn @@ -0,0 +1,75 @@ +[gd_scene load_steps=11 format=2] + +[ext_resource path="res://Graphics/UI/iosevka-aile-regular.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://Graphics/UI/iosevka-aile-italic.ttf" type="DynamicFontData" id=2] +[ext_resource path="res://Graphics/UI/iosevka-aile-bold.ttf" type="DynamicFontData" id=3] +[ext_resource path="res://Graphics/UI/iosevka-aile-bolditalic.ttf" type="DynamicFontData" id=4] +[ext_resource path="res://Scenes/UI/Panels/Logs.gd" type="Script" id=5] +[ext_resource path="res://Scenes/UI/Widgets/ResizablePanel.tscn" type="PackedScene" id=6] + +[sub_resource type="DynamicFont" id=1] +size = 14 +use_mipmaps = true +font_data = ExtResource( 4 ) + +[sub_resource type="DynamicFont" id=2] +size = 14 +use_mipmaps = true +font_data = ExtResource( 2 ) + +[sub_resource type="DynamicFont" id=3] +size = 14 +use_mipmaps = true +font_data = ExtResource( 3 ) + +[sub_resource type="DynamicFont" id=4] +size = 14 +use_mipmaps = true +font_data = ExtResource( 1 ) + +[node name="Logs" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 5 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ResizablePanel" parent="." instance=ExtResource( 6 )] + +[node name="RichTextLabel" type="RichTextLabel" parent="ResizablePanel"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 10.0 +margin_top = 40.0 +margin_right = -10.0 +margin_bottom = -40.0 +focus_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +custom_fonts/bold_italics_font = SubResource( 1 ) +custom_fonts/italics_font = SubResource( 2 ) +custom_fonts/bold_font = SubResource( 3 ) +custom_fonts/normal_font = SubResource( 4 ) +selection_enabled = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="LineEdit" type="LineEdit" parent="ResizablePanel"] +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 10.0 +margin_top = -30.0 +margin_right = -10.0 +focus_mode = 1 +caret_blink = true +caret_blink_speed = 0.5 +__meta__ = { +"_edit_use_anchors_": false +} +[connection signal="focus_entered" from="ResizablePanel/LineEdit" to="." method="_chat_bar_status" binds= [ true ]] +[connection signal="focus_exited" from="ResizablePanel/LineEdit" to="." method="_chat_bar_status" binds= [ false ]] +[connection signal="mouse_entered" from="ResizablePanel/LineEdit" to="." method="_chat_bar_focus" binds= [ true ]] +[connection signal="mouse_exited" from="ResizablePanel/LineEdit" to="." method="_chat_bar_focus" binds= [ false ]] diff --git a/Scenes/UI/ServerInfo.gd b/Scenes/UI/Panels/ServerInfo.gd similarity index 100% rename from Scenes/UI/ServerInfo.gd rename to Scenes/UI/Panels/ServerInfo.gd diff --git a/Scenes/UI/ServerInfo.tscn b/Scenes/UI/Panels/ServerInfo.tscn similarity index 84% rename from Scenes/UI/ServerInfo.tscn rename to Scenes/UI/Panels/ServerInfo.tscn index 60457bf..eb46ae1 100644 --- a/Scenes/UI/ServerInfo.tscn +++ b/Scenes/UI/Panels/ServerInfo.tscn @@ -1,6 +1,7 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://Scenes/UI/ServerInfo.gd" type="Script" id=1] +[ext_resource path="res://Scenes/UI/Panels/ServerInfo.gd" type="Script" id=1] + [node name="ServerInfoPopup" type="WindowDialog"] visible = true diff --git a/Scenes/UI/Widgets/ResizablePanel.gd b/Scenes/UI/Widgets/ResizablePanel.gd index 3113d6c..bd2415b 100644 --- a/Scenes/UI/Widgets/ResizablePanel.gd +++ b/Scenes/UI/Widgets/ResizablePanel.gd @@ -31,17 +31,7 @@ func _input(event): dragging = false if resizing and not event.pressed: resizing = false - if not chat_bar_focus: - $LineEdit.release_focus() func set_title(val): title = val $DragHandle/Label.text = title - -var chat_bar_focus = false - -func _chat_bar_status(editing): - $"/root/scene".writing = editing - -func _chat_bar_focus(entered): - chat_bar_focus = entered diff --git a/Scenes/UI/Widgets/ResizablePanel.tscn b/Scenes/UI/Widgets/ResizablePanel.tscn index 5b5bb78..91ccf12 100644 --- a/Scenes/UI/Widgets/ResizablePanel.tscn +++ b/Scenes/UI/Widgets/ResizablePanel.tscn @@ -1,10 +1,6 @@ -[gd_scene load_steps=11 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://Scenes/UI/Widgets/ResizablePanel.gd" type="Script" id=1] -[ext_resource path="res://Graphics/UI/iosevka-aile-regular.ttf" type="DynamicFontData" id=2] -[ext_resource path="res://Graphics/UI/iosevka-aile-bold.ttf" type="DynamicFontData" id=3] -[ext_resource path="res://Graphics/UI/iosevka-aile-italic.ttf" type="DynamicFontData" id=4] -[ext_resource path="res://Graphics/UI/iosevka-aile-bolditalic.ttf" type="DynamicFontData" id=5] [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.133333, 0.12549, 0.203922, 0.705882 ) @@ -19,26 +15,6 @@ corner_radius_top_right = 4 corner_radius_bottom_right = 4 corner_radius_bottom_left = 4 -[sub_resource type="DynamicFont" id=2] -size = 14 -use_mipmaps = true -font_data = ExtResource( 5 ) - -[sub_resource type="DynamicFont" id=3] -size = 14 -use_mipmaps = true -font_data = ExtResource( 4 ) - -[sub_resource type="DynamicFont" id=4] -size = 14 -use_mipmaps = true -font_data = ExtResource( 3 ) - -[sub_resource type="DynamicFont" id=5] -size = 14 -use_mipmaps = true -font_data = ExtResource( 2 ) - [node name="ResizablePanel" type="Panel"] anchor_right = 1.0 anchor_bottom = 1.0 @@ -87,40 +63,5 @@ size_flags_vertical = 0 __meta__ = { "_edit_use_anchors_": false } - -[node name="RichTextLabel" type="RichTextLabel" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = 10.0 -margin_top = 40.0 -margin_right = -10.0 -margin_bottom = -40.0 -focus_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 3 -custom_fonts/bold_italics_font = SubResource( 2 ) -custom_fonts/italics_font = SubResource( 3 ) -custom_fonts/bold_font = SubResource( 4 ) -custom_fonts/normal_font = SubResource( 5 ) -selection_enabled = true -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="LineEdit" type="LineEdit" parent="."] -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = 10.0 -margin_top = -30.0 -margin_right = -10.0 -focus_mode = 1 -__meta__ = { -"_edit_use_anchors_": false -} [connection signal="gui_input" from="DragHandle" to="." method="_handle_drag"] [connection signal="gui_input" from="ResizeHandle" to="." method="_handle_resize"] -[connection signal="focus_entered" from="LineEdit" to="." method="_chat_bar_status" binds= [ true ]] -[connection signal="focus_exited" from="LineEdit" to="." method="_chat_bar_status" binds= [ false ]] -[connection signal="mouse_entered" from="LineEdit" to="." method="_chat_bar_focus" binds= [ true ]] -[connection signal="mouse_exited" from="LineEdit" to="." method="_chat_bar_focus" binds= [ false ]] diff --git a/Sounds/SFX/sources/door-sound.aup b/Sounds/SFX/sources/door-sound.aup index e49824f..1bdd279 100644 --- a/Sounds/SFX/sources/door-sound.aup +++ b/Sounds/SFX/sources/door-sound.aup @@ -2,23 +2,25 @@ - + - + - + + + - +