Add basic top ui functionality
This commit is contained in:
parent
df83dce3a6
commit
e116ac4769
6 changed files with 161 additions and 1 deletions
|
@ -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"]
|
[ext_resource type="Theme" uid="uid://d035h7upxrw3h" path="res://theme.tres" id="1_xbn5h"]
|
||||||
|
|
||||||
[node name="Main" type="Node2D"]
|
[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="."]
|
[node name="Control" type="Control" parent="."]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 0
|
anchors_preset = 0
|
||||||
|
|
|
@ -2,6 +2,7 @@ extends Node
|
||||||
|
|
||||||
@onready var globals = Data.data.globals
|
@onready var globals = Data.data.globals
|
||||||
|
|
||||||
|
|
||||||
var game_time = 0
|
var game_time = 0
|
||||||
var last_flood_time = 0
|
var last_flood_time = 0
|
||||||
var current_flood_state = 0
|
var current_flood_state = 0
|
||||||
|
|
105
ui/UI.tscn
Normal file
105
ui/UI.tscn
Normal file
|
@ -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
|
13
ui/number.gd
Normal file
13
ui/number.gd
Normal file
|
@ -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))
|
BIN
ui/ui-elements.png
Normal file
BIN
ui/ui-elements.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
34
ui/ui-elements.png.import
Normal file
34
ui/ui-elements.png.import
Normal file
|
@ -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
|
Loading…
Reference in a new issue