From 65f583a232fd9aa0f3e51b1c0f4ae931503a5845 Mon Sep 17 00:00:00 2001 From: Maxim Lobovsky Date: Mon, 4 Apr 2022 19:55:11 +0200 Subject: [PATCH] roba strana fixata + neve --- src/levels/Game.tscn | 63 ++++++++++++++++++++++++++------------ src/ui/HealthBar.tscn | 10 ------ src/ui/TheDarkNightUI.tscn | 21 +++++++++++++ src/ui/TimeSurvived.tscn | 16 ---------- 4 files changed, 64 insertions(+), 46 deletions(-) delete mode 100644 src/ui/HealthBar.tscn create mode 100644 src/ui/TheDarkNightUI.tscn delete mode 100644 src/ui/TimeSurvived.tscn diff --git a/src/levels/Game.tscn b/src/levels/Game.tscn index c2856d7..6f6f556 100644 --- a/src/levels/Game.tscn +++ b/src/levels/Game.tscn @@ -6,10 +6,8 @@ [ext_resource path="res://src/entities/players/PhaseOnePlayer.tscn" type="PackedScene" id=4] [ext_resource path="res://src/mechanics/RNG.tscn" type="PackedScene" id=5] [ext_resource path="res://src/levels/Game.gd" type="Script" id=6] -[ext_resource path="res://src/ui/TimeSurvived.tscn" type="PackedScene" id=7] -[ext_resource path="res://src/ui/fonts/SourceSerifPro-Regular.ttf" type="DynamicFontData" id=8] +[ext_resource path="res://src/ui/TheDarkNightUI.tscn" type="PackedScene" id=8] [ext_resource path="res://src/levels/PhaseOneMusic.gd" type="Script" id=11] -[ext_resource path="res://src/ui/HealthBar.tscn" type="PackedScene" id=14] [ext_resource path="res://src/music/BaseDrum.mp3" type="AudioStream" id=19] [ext_resource path="res://src/music/BaseBell.mp3" type="AudioStream" id=20] [ext_resource path="res://src/music/BaseChoir.mp3" type="AudioStream" id=21] @@ -31,8 +29,20 @@ scale_random = 1.0 size = 22 font_data = ExtResource( 8 ) -[sub_resource type="Theme" id=2] -default_font = SubResource( 1 ) + +func _ready(): + var game = get_tree().root.get_node(\"Game\") + game.connect(\"survival_seconds_updated\", self, \"_on_survival_seconds_updated\") + + +func _on_survival_seconds_updated(value: float): + # warning-ignore:NARROWING_CONVERSION + var minutes: int = floor(value / 60) + var seconds_and_millis: float = value - minutes * 60 + var seconds: int = int(seconds_and_millis) + var millis: int = int((seconds_and_millis - seconds) * 1000) + text = \"%02d:%02d.%03d\" % ([minutes, seconds, millis]) +" [node name="Game" type="Node2D"] script = ExtResource( 6 ) @@ -89,24 +99,37 @@ process_material = SubResource( 5 ) [node name="UserInterface" type="CanvasLayer" parent="."] -[node name="UserIntefaceContainer" type="Panel" parent="UserInterface"] -light_mask = 2 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 +[node name="TheDarkNightUI" parent="UserInterface" instance=ExtResource( 8 )] +anchor_left = 0.0 +anchor_right = 1.0 +margin_left = 0.0 +margin_right = 0.0 + +[node name="Panel" type="Panel" parent="UserInterface/TheDarkNightUI"] +anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = -640.0 -margin_top = -80.0 -margin_right = 640.0 -theme = SubResource( 2 ) -[node name="TimeSurvived" parent="UserInterface/UserIntefaceContainer" instance=ExtResource( 7 )] -margin_left = -45.5 -margin_top = -14.5 -margin_right = 45.5 -margin_bottom = 14.5 +[node name="TimeSurvived" type="Label" parent="UserInterface/TheDarkNightUI/Panel"] +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = 14.0 +margin_right = -14.0 +margin_bottom = -14.0 +grow_horizontal = 0 +grow_vertical = 2 +text = "00:00.000" +align = 2 +valign = 1 +script = SubResource( 1 ) -[node name="HealthBar" parent="UserInterface/UserIntefaceContainer" instance=ExtResource( 14 )] +[node name="HealthBar" type="ProgressBar" parent="UserInterface/TheDarkNightUI/Panel"] +anchor_bottom = 1.0 margin_left = 14.0 +margin_top = 14.0 +margin_right = 320.0 +margin_bottom = -14.0 +grow_vertical = 2 +value = 50.0 [connection signal="intensity_changed" from="PhaseOne/Entities/Fire" to="PhaseOne/Music" method="_on_Fire_intensity_changed"] diff --git a/src/ui/HealthBar.tscn b/src/ui/HealthBar.tscn deleted file mode 100644 index 630e4d9..0000000 --- a/src/ui/HealthBar.tscn +++ /dev/null @@ -1,10 +0,0 @@ -[gd_scene format=2] - -[node name="HealthBar" type="ProgressBar"] -anchor_top = 0.5 -anchor_bottom = 0.5 -margin_top = -14.0 -margin_right = 320.0 -margin_bottom = 14.0 -step = 1.0 -value = 50.0 diff --git a/src/ui/TheDarkNightUI.tscn b/src/ui/TheDarkNightUI.tscn new file mode 100644 index 0000000..eaa41c2 --- /dev/null +++ b/src/ui/TheDarkNightUI.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/ui/fonts/SourceSerifPro-Regular.ttf" type="DynamicFontData" id=4] + +[sub_resource type="DynamicFont" id=1] +size = 22 +font_data = ExtResource( 4 ) + +[sub_resource type="Theme" id=2] +default_font = SubResource( 1 ) + +[node name="TheDarkNightUI" type="Control"] +light_mask = 2 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +margin_left = -640.0 +margin_top = -80.0 +margin_right = 640.0 +theme = SubResource( 2 ) diff --git a/src/ui/TimeSurvived.tscn b/src/ui/TimeSurvived.tscn deleted file mode 100644 index f079388..0000000 --- a/src/ui/TimeSurvived.tscn +++ /dev/null @@ -1,16 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://src/ui/TimeSurvived.gd" type="Script" id=1] - -[node name="TimeSurvived" type="Label"] -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -margin_left = -32.0 -margin_top = -7.0 -margin_right = 32.0 -margin_bottom = 7.0 -text = "00:00.000" -align = 1 -script = ExtResource( 1 )