Skip to content

Commit e36e2b6

Browse files
committedSep 25, 2024
Add seen/all counter to catalog
1 parent b1b4da6 commit e36e2b6

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed
 

‎addons/YouCanDoIt/Scenes/CatalogDock.tscn

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
[gd_scene load_steps=2 format=3 uid="uid://b1m1fmbl0giqi"]
1+
[gd_scene load_steps=3 format=3 uid="uid://b1m1fmbl0giqi"]
22

33
[sub_resource type="LabelSettings" id="LabelSettings_xdbgf"]
44
font_size = 24
55

6+
[sub_resource type="LabelSettings" id="LabelSettings_lpkqd"]
7+
font_size = 20
8+
69
[node name="CatalogDock" type="Control"]
710
custom_minimum_size = Vector2(0, 200)
811
layout_mode = 3
@@ -26,11 +29,25 @@ anchors_preset = 10
2629
anchor_right = 1.0
2730
offset_bottom = 50.0
2831
grow_horizontal = 2
29-
text = "Catalog"
32+
text = "Girl Catalog"
3033
label_settings = SubResource("LabelSettings_xdbgf")
3134
horizontal_alignment = 1
3235
vertical_alignment = 1
3336

37+
[node name="Counter" type="Label" parent="Background"]
38+
layout_mode = 1
39+
anchors_preset = 1
40+
anchor_left = 1.0
41+
anchor_right = 1.0
42+
offset_left = -150.0
43+
offset_right = -15.0
44+
offset_bottom = 50.0
45+
grow_horizontal = 0
46+
text = "Seen: 0/0"
47+
label_settings = SubResource("LabelSettings_lpkqd")
48+
horizontal_alignment = 2
49+
vertical_alignment = 1
50+
3451
[node name="Scroll" type="ScrollContainer" parent="Background"]
3552
layout_mode = 1
3653
anchors_preset = 15

‎addons/YouCanDoIt/Scripts/main.gd

+16-6
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,22 @@ func transition_overlay(to_visible:bool)->void:
115115
func fill_catalog():
116116
# Get girl paths
117117
var all_paths:Dictionary = all_girl_paths()
118-
var seen_paths:Dictionary = seen_girl_paths()
118+
var seen_pathnames:Dictionary = seen_girl_pathnames()
119119

120-
# Get catalog container
120+
# Get catalog nodes
121121
var flow:FlowContainer = catalog_dock.get_node("Background/Scroll/Flow")
122122
var portrait_template:TextureRect = flow.get_node("Portrait")
123+
var counter_label:Label = catalog_dock.get_node("Background/Counter")
123124

124125
# Clear existing girls
125126
for portrait:Node in flow.get_children():
126127
if portrait != portrait_template:
127128
portrait.queue_free()
128129

130+
# Count girls
131+
var unseen_count:int = 0
132+
var seen_count:int = 0
133+
129134
# Add each girl to catalog
130135
for type:String in all_paths:
131136
for girl_path:String in all_paths[type]:
@@ -137,12 +142,14 @@ func fill_catalog():
137142
portrait.texture = load(addon_path.path_join("Images/Girls").path_join(type).path_join(girl_path))
138143

139144
# Show girl if seen
140-
if seen_paths.has(girl_pathname):
145+
if seen_pathnames.has(girl_pathname):
146+
seen_count += 1
141147
portrait.tooltip_text = girl_pathname \
142-
+ "\nType: " + type \
143-
+ "\nSeen: " + str(seen_paths[girl_pathname]) + " times"
148+
+ "\nType: {0}".format([type]) \
149+
+ "\nSeen: {0} times".format([seen_pathnames[girl_pathname]])
144150
# Lock girl if not seen
145151
else:
152+
unseen_count += 1
146153
portrait.self_modulate = Color.BLACK
147154
portrait.tooltip_text = "Locked"
148155

@@ -152,6 +159,9 @@ func fill_catalog():
152159

153160
# Wait to prevent freezing
154161
await get_tree().process_frame
162+
163+
# Render counter
164+
counter_label.text = "Seen: {0}/{1}".format([seen_count, seen_count + unseen_count])
155165

156166
func save_progress(progress:Dictionary)->void:
157167
var save_file:FileAccess = FileAccess.open(save_path, FileAccess.WRITE)
@@ -171,7 +181,7 @@ func save_seen_girl(girl_pathname:String)->void:
171181
save_progress(progress)
172182
fill_catalog()
173183

174-
func seen_girl_paths()->Dictionary:
184+
func seen_girl_pathnames()->Dictionary:
175185
var progress:Dictionary = load_progress()
176186
return progress.get_or_add("seen", {})
177187

0 commit comments

Comments
 (0)
Please sign in to comment.