diff --git a/Main.tscn b/Main.tscn index 336395e..15e1edb 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,9 +1,16 @@ -[gd_scene load_steps=2 format=3 uid="uid://5ske2hm55rce"] +[gd_scene load_steps=4 format=3 uid="uid://5ske2hm55rce"] +[ext_resource type="PackedScene" uid="uid://n2lpy72tkyc8" path="res://storm/StormManager.tscn" id="1_gcxt1"] +[ext_resource type="PackedScene" uid="uid://bxctpr0tfqidf" path="res://ui/UI.tscn" id="1_ve2mn"] [ext_resource type="Theme" uid="uid://d035h7upxrw3h" path="res://theme.tres" id="1_xbn5h"] [node name="Main" type="Node2D"] +[node name="StormManager" parent="." instance=ExtResource("1_gcxt1")] + +[node name="UI" parent="." instance=ExtResource("1_ve2mn")] +offset_right = 640.0 + [node name="Control" type="Control" parent="."] layout_mode = 3 anchors_preset = 0 diff --git a/storm/storm_manager.gd b/storm/storm_manager.gd index e959e95..2a7d43f 100644 --- a/storm/storm_manager.gd +++ b/storm/storm_manager.gd @@ -2,6 +2,7 @@ extends Node @onready var globals = Data.data.globals + var game_time = 0 var last_flood_time = 0 var current_flood_state = 0 diff --git a/ui/UI.tscn b/ui/UI.tscn new file mode 100644 index 0000000..e0ee260 --- /dev/null +++ b/ui/UI.tscn @@ -0,0 +1,105 @@ +[gd_scene load_steps=3 format=3 uid="uid://bxctpr0tfqidf"] + +[ext_resource type="Texture2D" uid="uid://dsy18stvo2pu5" path="res://ui/ui-elements.png" id="1_cx752"] +[ext_resource type="Script" path="res://ui/number.gd" id="2_ei01o"] + +[node name="UI" type="MarginContainer"] +anchors_preset = 10 +anchor_right = 1.0 +offset_bottom = 44.0 +grow_horizontal = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="LeftCounters" type="HBoxContainer" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="FloodLevel" type="MarginContainer" parent="HBoxContainer/LeftCounters"] +layout_mode = 2 + +[node name="Background" type="NinePatchRect" parent="HBoxContainer/LeftCounters/FloodLevel"] +custom_minimum_size = Vector2(160, 40) +layout_mode = 2 +texture = ExtResource("1_cx752") +region_rect = Rect2(779.878, 10.1175, 231.253, 25.8529) + +[node name="Title" type="Label" parent="HBoxContainer/LeftCounters/FloodLevel/Background"] +layout_mode = 2 +offset_top = 9.0 +offset_right = 112.0 +offset_bottom = 32.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "Flood Level:" +horizontal_alignment = 1 + +[node name="Number" type="Label" parent="HBoxContainer/LeftCounters/FloodLevel/Background"] +layout_mode = 2 +offset_left = 112.0 +offset_top = 9.0 +offset_right = 148.0 +offset_bottom = 32.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +horizontal_alignment = 2 +script = ExtResource("2_ei01o") + +[node name="RightCounters" type="VBoxContainer" parent="HBoxContainer"] +layout_direction = 2 +layout_mode = 2 + +[node name="Population" type="MarginContainer" parent="HBoxContainer/RightCounters"] +layout_mode = 2 + +[node name="Background" type="NinePatchRect" parent="HBoxContainer/RightCounters/Population"] +custom_minimum_size = Vector2(160, 20) +layout_mode = 2 +texture = ExtResource("1_cx752") +region_rect = Rect2(779.878, 10.1175, 231.253, 25.8529) + +[node name="Title" type="Label" parent="HBoxContainer/RightCounters/Population/Background"] +layout_mode = 2 +offset_top = -2.0 +offset_right = 112.0 +offset_bottom = 21.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "Population:" +horizontal_alignment = 1 + +[node name="Number" type="Label" parent="HBoxContainer/RightCounters/Population/Background"] +layout_mode = 2 +offset_left = 112.0 +offset_top = -1.0 +offset_right = 148.0 +offset_bottom = 22.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "10" +horizontal_alignment = 2 + +[node name="Resources" type="MarginContainer" parent="HBoxContainer/RightCounters"] +layout_mode = 2 + +[node name="Background" type="NinePatchRect" parent="HBoxContainer/RightCounters/Resources"] +custom_minimum_size = Vector2(160, 20) +layout_mode = 2 +texture = ExtResource("1_cx752") +region_rect = Rect2(779.878, 10.1175, 231.253, 25.8529) + +[node name="Title" type="Label" parent="HBoxContainer/RightCounters/Resources/Background"] +layout_mode = 2 +offset_top = -2.0 +offset_right = 112.0 +offset_bottom = 21.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "Resources:" +horizontal_alignment = 1 + +[node name="Number" type="Label" parent="HBoxContainer/RightCounters/Resources/Background"] +layout_mode = 2 +offset_left = 112.0 +offset_top = -1.0 +offset_right = 148.0 +offset_bottom = 22.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "10" +horizontal_alignment = 2 diff --git a/ui/number.gd b/ui/number.gd new file mode 100644 index 0000000..c1adeb2 --- /dev/null +++ b/ui/number.gd @@ -0,0 +1,13 @@ +extends Label + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + var floodlevel = Persister.get_value("flood_level") + if floodlevel: + set_text(str(floodlevel)) + else: + set_text(str(0)) diff --git a/ui/ui-elements.png b/ui/ui-elements.png new file mode 100644 index 0000000..81312ec Binary files /dev/null and b/ui/ui-elements.png differ diff --git a/ui/ui-elements.png.import b/ui/ui-elements.png.import new file mode 100644 index 0000000..aa737a0 --- /dev/null +++ b/ui/ui-elements.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dsy18stvo2pu5" +path="res://.godot/imported/ui-elements.png-9343eafe24264ca7277498c1badb542f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ui/ui-elements.png" +dest_files=["res://.godot/imported/ui-elements.png-9343eafe24264ca7277498c1badb542f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +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/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1