Add achievement item UI and logic for displaying achievements

This commit is contained in:
Kirill
2026-10-18 20:03:27 +03:00
parent fe68e788b3
commit e41d652631
4 changed files with 132 additions and 4 deletions
+28
View File
@@ -0,0 +1,28 @@
extends Control
@onready var icons = {
"1c": $Row/Icon1c,
"1g": $Row/Icon1g,
"3c": $Row/Icon3c,
"3g": $Row/Icon3g,
"6c": $Row/Icon6c,
"6g": $Row/Icon6g,
"10c": $Row/Icon10c,
"10g": $Row/Icon10g,
}
@onready var event_label: RichTextLabel = $Row/Label
## Shows this achievement event with the matching points/state icon.
## event_type is "c" for completed or "g" for revealed but not completed.
func open(level: int, event_type: String, event_text: String) -> void:
var icon_key := str(level) + event_type.to_lower()
if not icons.has(icon_key):
push_warning("Unknown achievement icon: %s" % icon_key)
return
for key: String in icons:
icons[key].visible = key == icon_key
event_label.text = event_text
visible = true
+1
View File
@@ -0,0 +1 @@
uid://b6sqyd1tpljr3
+74
View File
@@ -0,0 +1,74 @@
[gd_scene format=3 uid="uid://cs8a5u3ecf51t"]
[ext_resource type="Script" uid="uid://b6sqyd1tpljr3" path="res://ui/achievements/achievement_item.gd" id="1_w8f20"]
[ext_resource type="Texture2D" uid="uid://cfohmmlwh84gk" path="res://ui/achievements/icons/1c.png" id="2_7ntr3"]
[ext_resource type="Texture2D" uid="uid://k6dqaewr30qe" path="res://ui/achievements/icons/1g.png" id="3_1b655"]
[ext_resource type="Texture2D" uid="uid://bccs26gkwsio3" path="res://ui/achievements/icons/3c.png" id="4_xgo6w"]
[ext_resource type="Texture2D" uid="uid://c7regmaoq0dr5" path="res://ui/achievements/icons/3g.png" id="5_7pkbt"]
[ext_resource type="Texture2D" uid="uid://bl7dr5fapao0x" path="res://ui/achievements/icons/6c.png" id="6_aart1"]
[ext_resource type="Texture2D" uid="uid://bk5morikm4k5o" path="res://ui/achievements/icons/6g.png" id="7_ndc4d"]
[ext_resource type="Texture2D" uid="uid://bs54rppydwlvy" path="res://ui/achievements/icons/10c.png" id="8_20e5y"]
[ext_resource type="Texture2D" uid="uid://bmp7e6lmtaex0" path="res://ui/achievements/icons/10g.png" id="9_3xyrb"]
[node name="AchievementItem" type="Control" unique_id=1273881744]
custom_minimum_size = Vector2(1080, 128)
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_w8f20")
[node name="Row" type="HBoxContainer" parent="." unique_id=2025386077]
layout_mode = 0
offset_right = 1080.0
offset_bottom = 128.0
[node name="Icon1c" type="TextureRect" parent="Row" unique_id=2146478339]
visible = false
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
texture = ExtResource("2_7ntr3")
[node name="Icon1g" type="TextureRect" parent="Row" unique_id=2089044466]
visible = false
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
texture = ExtResource("3_1b655")
[node name="Icon3c" type="TextureRect" parent="Row" unique_id=501141005]
visible = false
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
texture = ExtResource("4_xgo6w")
[node name="Icon3g" type="TextureRect" parent="Row" unique_id=844167957]
visible = false
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
texture = ExtResource("5_7pkbt")
[node name="Icon6c" type="TextureRect" parent="Row" unique_id=2137074157]
visible = false
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
texture = ExtResource("6_aart1")
[node name="Icon6g" type="TextureRect" parent="Row" unique_id=616115687]
visible = false
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
texture = ExtResource("7_ndc4d")
[node name="Icon10c" type="TextureRect" parent="Row" unique_id=418038490]
visible = false
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
texture = ExtResource("8_20e5y")
[node name="Icon10g" type="TextureRect" parent="Row" unique_id=1352890506]
visible = false
custom_minimum_size = Vector2(128, 128)
layout_mode = 2
texture = ExtResource("9_3xyrb")
[node name="Label" type="RichTextLabel" parent="Row" unique_id=230945261]
layout_mode = 2
size_flags_horizontal = 3
+29 -4
View File
@@ -64,6 +64,7 @@
[ext_resource type="Texture2D" uid="uid://bce2bpw5642er" path="res://ui/achievements/achievements.en.png" id="61_d36xh"] [ext_resource type="Texture2D" uid="uid://bce2bpw5642er" path="res://ui/achievements/achievements.en.png" id="61_d36xh"]
[ext_resource type="Script" uid="uid://vy0dj2cqfmk0" path="res://ui/credits/credits.gd" id="62_o2i0n"] [ext_resource type="Script" uid="uid://vy0dj2cqfmk0" path="res://ui/credits/credits.gd" id="62_o2i0n"]
[ext_resource type="Texture2D" uid="uid://c46h78ewwlafk" path="res://ui/credits/credits.en.png" id="62_vu83j"] [ext_resource type="Texture2D" uid="uid://c46h78ewwlafk" path="res://ui/credits/credits.en.png" id="62_vu83j"]
[ext_resource type="PackedScene" uid="uid://cs8a5u3ecf51t" path="res://ui/achievements/achievement_item.tscn" id="64_0drd1"]
[ext_resource type="Texture2D" uid="uid://drvvkd724g8hy" path="res://ui/credits/kid_gp_light.png" id="64_rur7c"] [ext_resource type="Texture2D" uid="uid://drvvkd724g8hy" path="res://ui/credits/kid_gp_light.png" id="64_rur7c"]
[ext_resource type="Texture2D" uid="uid://b33ji4mpyw4ks" path="res://ui/credits/kid_gp.png" id="65_y1rwn"] [ext_resource type="Texture2D" uid="uid://b33ji4mpyw4ks" path="res://ui/credits/kid_gp.png" id="65_y1rwn"]
[ext_resource type="Texture2D" uid="uid://dgt52qiyuirso" path="res://ui/indicators/density/warning_border.png" id="66_rur7c"] [ext_resource type="Texture2D" uid="uid://dgt52qiyuirso" path="res://ui/indicators/density/warning_border.png" id="66_rur7c"]
@@ -234,26 +235,30 @@ theme_override_constants/separation = 0
layout_mode = 2 layout_mode = 2
theme_override_constants/separation = 0 theme_override_constants/separation = 0
[node name="PageHeader" type="HBoxContainer" parent="Stage/World/PageScroller/HBoxContainer/ForcePage" unique_id=2102307933] [node name="ForceHeader" type="HBoxContainer" parent="Stage/World/PageScroller/HBoxContainer/ForcePage" unique_id=2102307933]
custom_minimum_size = Vector2(0, 128) custom_minimum_size = Vector2(0, 128)
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 6 size_flags_horizontal = 6
size_flags_vertical = 4 size_flags_vertical = 4
theme_override_constants/separation = 0 theme_override_constants/separation = 0
[node name="LeftIndicator" type="TextureButton" parent="Stage/World/PageScroller/HBoxContainer/ForcePage/PageHeader" unique_id=663302862] [node name="LeftIndicator" type="TextureButton" parent="Stage/World/PageScroller/HBoxContainer/ForcePage/ForceHeader" unique_id=663302862]
custom_minimum_size = Vector2(316, 64) custom_minimum_size = Vector2(316, 64)
layout_mode = 2 layout_mode = 2
[node name="Header" type="TextureRect" parent="Stage/World/PageScroller/HBoxContainer/ForcePage/PageHeader" unique_id=1295272502] [node name="Header" type="TextureRect" parent="Stage/World/PageScroller/HBoxContainer/ForcePage/ForceHeader" unique_id=1295272502]
custom_minimum_size = Vector2(440, 64) custom_minimum_size = Vector2(440, 64)
layout_mode = 2 layout_mode = 2
texture = ExtResource("13_dp8ul") texture = ExtResource("13_dp8ul")
[node name="RighIndicator" type="TextureButton" parent="Stage/World/PageScroller/HBoxContainer/ForcePage/PageHeader" unique_id=504419468] [node name="RighIndicator" type="TextureButton" parent="Stage/World/PageScroller/HBoxContainer/ForcePage/ForceHeader" unique_id=504419468]
custom_minimum_size = Vector2(316, 64) custom_minimum_size = Vector2(316, 64)
layout_mode = 2 layout_mode = 2
[node name="ForceAchievementItem" parent="Stage/World/PageScroller/HBoxContainer/ForcePage" unique_id=1273881744 instance=ExtResource("64_0drd1")]
visible = false
layout_mode = 2
[node name="PageHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/ForcePage" unique_id=1411786120 instance=ExtResource("12_58wjt")] [node name="PageHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/ForcePage" unique_id=1411786120 instance=ExtResource("12_58wjt")]
layout_mode = 2 layout_mode = 2
@@ -397,6 +402,10 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
texture = ExtResource("23_bcq5b") texture = ExtResource("23_bcq5b")
[node name="ResourceAchievementItem" parent="Stage/World/PageScroller/HBoxContainer/ResourcePage" unique_id=746617076 instance=ExtResource("64_0drd1")]
visible = false
layout_mode = 2
[node name="ResourceHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/ResourcePage" unique_id=2672876 instance=ExtResource("12_58wjt")] [node name="ResourceHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/ResourcePage" unique_id=2672876 instance=ExtResource("12_58wjt")]
layout_mode = 2 layout_mode = 2
@@ -525,6 +534,10 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
texture = ExtResource("28_upe80") texture = ExtResource("28_upe80")
[node name="StarAchievementItem" parent="Stage/World/PageScroller/HBoxContainer/StarPage" unique_id=1287836220 instance=ExtResource("64_0drd1")]
visible = false
layout_mode = 2
[node name="StarHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/StarPage" unique_id=2057421818 instance=ExtResource("12_58wjt")] [node name="StarHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/StarPage" unique_id=2057421818 instance=ExtResource("12_58wjt")]
layout_mode = 2 layout_mode = 2
@@ -666,6 +679,10 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
texture = ExtResource("23_bcq5b") texture = ExtResource("23_bcq5b")
[node name="StructureAchievementItem" parent="Stage/World/PageScroller/HBoxContainer/StructurePage" unique_id=1834701519 instance=ExtResource("64_0drd1")]
visible = false
layout_mode = 2
[node name="StructureHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/StructurePage" unique_id=522613609 instance=ExtResource("12_58wjt")] [node name="StructureHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/StructurePage" unique_id=522613609 instance=ExtResource("12_58wjt")]
layout_mode = 2 layout_mode = 2
@@ -814,6 +831,10 @@ texture = ExtResource("40_50rdj")
layout_mode = 2 layout_mode = 2
texture = ExtResource("41_mi6gc") texture = ExtResource("41_mi6gc")
[node name="LifeAchievementItem" parent="Stage/World/PageScroller/HBoxContainer/LifePage" unique_id=1647265705 instance=ExtResource("64_0drd1")]
visible = false
layout_mode = 2
[node name="LifeHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/LifePage" unique_id=100084430 instance=ExtResource("12_58wjt")] [node name="LifeHeaderBorder" parent="Stage/World/PageScroller/HBoxContainer/LifePage" unique_id=100084430 instance=ExtResource("12_58wjt")]
layout_mode = 2 layout_mode = 2
@@ -1078,6 +1099,10 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="AchievementItem" parent="Stage/Achievements/AchievementList/AchievementItems" unique_id=1952626354 instance=ExtResource("64_0drd1")]
visible = false
layout_mode = 2
[node name="Credits" type="VBoxContainer" parent="Stage" unique_id=785042592] [node name="Credits" type="VBoxContainer" parent="Stage" unique_id=785042592]
visible = false visible = false
layout_mode = 0 layout_mode = 0