Skip to content

Commit

Permalink
add text labels to progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
rosskarchner committed May 14, 2024
1 parent d8ee8ef commit e8d1603
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 1 deletion.
Binary file added assets/Silkscreen-Bold.ttf
Binary file not shown.
34 changes: 34 additions & 0 deletions assets/Silkscreen-Bold.ttf.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="font_data_dynamic"
type="FontFile"
uid="uid://cbnfp7teqsrl4"
path="res://.godot/imported/Silkscreen-Bold.ttf-abebf65a3558a04d16524c868e69a754.fontdata"

[deps]

source_file="res://assets/Silkscreen-Bold.ttf"
dest_files=["res://.godot/imported/Silkscreen-Bold.ttf-abebf65a3558a04d16524c868e69a754.fontdata"]

[params]

Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}
Binary file added assets/Silkscreen-Regular.ttf
Binary file not shown.
34 changes: 34 additions & 0 deletions assets/Silkscreen-Regular.ttf.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="font_data_dynamic"
type="FontFile"
uid="uid://blikjye18e0gw"
path="res://.godot/imported/Silkscreen-Regular.ttf-179ff117523cc7de1f65787ba0b2e83c.fontdata"

[deps]

source_file="res://assets/Silkscreen-Regular.ttf"
dest_files=["res://.godot/imported/Silkscreen-Regular.ttf-179ff117523cc7de1f65787ba0b2e83c.fontdata"]

[params]

Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}
6 changes: 6 additions & 0 deletions scenes/hud.gd
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
extends Control

@onready var bar = %ProgressBar
@onready var progress_labels = %ProgressLabels
@onready var day_label = %DayLabel
@onready var night_label = %NightLabel

func _ready():
CountManager.score_changed.connect(update_scores)

func update_scores(day_score):
bar.value = day_score
day_label.text = str(day_score)
night_label.text = str(556-day_score)
progress_labels.position.x = (day_score/556.0) * 600
39 changes: 38 additions & 1 deletion scenes/hud.tscn
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
[gd_scene load_steps=5 format=3 uid="uid://cekjwqxxs86fi"]
[gd_scene load_steps=8 format=3 uid="uid://cekjwqxxs86fi"]

[ext_resource type="PackedScene" uid="uid://cv17gh2fl3icx" path="res://scenes/board.tscn" id="1_avq32"]
[ext_resource type="Script" path="res://scenes/hud.gd" id="1_gjy51"]
[ext_resource type="FontFile" uid="uid://bi11acdv4cq0g" path="res://silkscreen-bold.tres" id="3_tun3p"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ytb10"]
bg_color = Color(0.0666667, 0.298039, 0.352941, 1)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jf5j2"]
bg_color = Color(0.85098, 0.909804, 0.890196, 1)

[sub_resource type="LabelSettings" id="LabelSettings_b3mox"]
font = ExtResource("3_tun3p")
font_size = 18
font_color = Color(0.0666667, 0.298039, 0.352941, 1)

[sub_resource type="LabelSettings" id="LabelSettings_dxuqy"]
font = ExtResource("3_tun3p")
font_size = 18

[node name="HUD" type="Control"]
layout_mode = 3
anchors_preset = 15
Expand Down Expand Up @@ -52,3 +62,30 @@ theme_override_styles/fill = SubResource("StyleBoxFlat_jf5j2")
max_value = 556.0
value = 278.0
show_percentage = false

[node name="ProgressLabels" type="Node2D" parent="VBoxContainer/HBoxContainer/ProgressBar"]
unique_name_in_owner = true
position = Vector2(300, 10)

[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/HBoxContainer/ProgressBar/ProgressLabels"]
offset_left = -100.0
offset_top = -10.0
offset_right = 100.0
offset_bottom = 15.0
alignment = 1

[node name="DayLabel" type="Label" parent="VBoxContainer/HBoxContainer/ProgressBar/ProgressLabels/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "278"
label_settings = SubResource("LabelSettings_b3mox")

[node name="Placeholder" type="Label" parent="VBoxContainer/HBoxContainer/ProgressBar/ProgressLabels/HBoxContainer"]
layout_mode = 2
text = " "

[node name="NightLabel" type="Label" parent="VBoxContainer/HBoxContainer/ProgressBar/ProgressLabels/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "278"
label_settings = SubResource("LabelSettings_dxuqy")

0 comments on commit e8d1603

Please sign in to comment.