open-fpsz/interfaces/hud/hud.tscn
2024-04-27 13:32:08 +00:00

150 lines
4.6 KiB
Text

[gd_scene load_steps=8 format=3 uid="uid://bcv81ku26xo"]
[ext_resource type="StyleBox" uid="uid://dcn1ll2ra4lwn" path="res://interfaces/hud/vitals/background.tres" id="1_gmv44"]
[ext_resource type="StyleBox" uid="uid://bq7rjpm38pao7" path="res://interfaces/hud/vitals/health_foreground.tres" id="2_6ejsl"]
[sub_resource type="GDScript" id="GDScript_2vxif"]
script/source = "class_name HUD extends CanvasLayer
@export_category(\"Vitals\")
@export var _health_bar : ProgressBar
@export var _energy_bar : ProgressBar
func _ready() -> void:
_update_health_bar(100.)
_update_energy_bar(100.)
func _update_energy_bar(energy : float) -> void:
_energy_bar.value = energy
func _on_energy_changed(new_energy : float) -> void:
_update_energy_bar(new_energy)
func _update_health_bar(health : float) -> void:
_health_bar.value = health
func _on_health_changed(new_health : float) -> void:
_update_health_bar(new_health)
"
[sub_resource type="GDScript" id="GDScript_w8l21"]
script/source = "extends Label
@onready var player : Player = get_parent().owner
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
if not OS.is_debug_build():
queue_free()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta : float) -> void:
var velocity_xz : Vector3 = player.linear_velocity
velocity_xz.y = 0
text = \"\"
text += \"fps: %s\\n\" % str(Engine.get_frames_per_second())
text += \"position: %d, %d, %d\\n\" % [player.position.x, player.position.y, player.position.z]
text += \"speed: %d km/h\\n\" % (player.linear_velocity.length() * 3.6)
text += \"speed_xz: %d km/h\\n\" % (velocity_xz.length() * 3.6)
"
[sub_resource type="Shader" id="Shader_gaah5"]
code = "shader_type canvas_item;
uniform vec4 color : source_color;
float circle(vec2 pos, float radius, float feather) {
return smoothstep(radius, radius - feather, length(pos - vec2(.5)));
}
void fragment() {
// draw reticle
float alpha = circle(UV, .5, .04);
COLOR = vec4(texture(TEXTURE, UV).rgb, alpha);
}"
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7blp5"]
shader = SubResource("Shader_gaah5")
shader_parameter/color = Color(1, 1, 1, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_f23s3"]
bg_color = Color(0.0901961, 0.87451, 0.760784, 0.65098)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
anti_aliasing = false
[node name="HUD" type="CanvasLayer" node_paths=PackedStringArray("_health_bar", "_energy_bar")]
script = SubResource("GDScript_2vxif")
_health_bar = NodePath("MarginContainer/HBoxContainer/VBoxContainer/HealthBar")
_energy_bar = NodePath("MarginContainer/HBoxContainer/VBoxContainer/EnergyBar")
[node name="DebugLabel" type="Label" parent="."]
offset_left = 20.0
offset_top = 20.0
offset_right = 21.0
offset_bottom = 43.0
script = SubResource("GDScript_w8l21")
[node name="Reticle" type="ColorRect" parent="."]
material = SubResource("ShaderMaterial_7blp5")
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -1.5
offset_top = -1.5
offset_right = 1.5
offset_bottom = 1.5
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="MarginContainer" type="MarginContainer" parent="."]
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -42.0
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/margin_left = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.2
theme_override_constants/separation = 6
[node name="HealthBar" type="ProgressBar" parent="MarginContainer/HBoxContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 8)
layout_mode = 2
mouse_filter = 2
theme_override_styles/background = ExtResource("1_gmv44")
theme_override_styles/fill = ExtResource("2_6ejsl")
value = 60.0
show_percentage = false
[node name="EnergyBar" type="ProgressBar" parent="MarginContainer/HBoxContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 8)
layout_mode = 2
mouse_filter = 2
theme_override_styles/background = ExtResource("1_gmv44")
theme_override_styles/fill = SubResource("StyleBoxFlat_f23s3")
value = 60.0
show_percentage = false
[node name="Spacer" type="Control" parent="MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.8