reset button in stats menu and fix of achievement sound
parent
b71ea39155
commit
1883760b6e
Binary file not shown.
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
importer="wav"
|
importer="wav"
|
||||||
type="AudioStreamWAV"
|
type="AudioStreamWAV"
|
||||||
uid="uid://c7x1rtkae66k4"
|
uid="uid://c2xs6x6q70sr1"
|
||||||
path="res://.godot/imported/achievement_unlock.wav-9a9f9e013cd33e691b8d6734dd2cf61a.sample"
|
path="res://.godot/imported/achievement_unlock.wav-9a9f9e013cd33e691b8d6734dd2cf61a.sample"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,38 @@ content_margin_top = 4.0
|
||||||
content_margin_right = 10.0
|
content_margin_right = 10.0
|
||||||
content_margin_bottom = 4.0
|
content_margin_bottom = 4.0
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_reset_hover"]
|
||||||
|
bg_color = Color(0.5, 0.04, 0.04, 0.4)
|
||||||
|
border_width_left = 2
|
||||||
|
border_width_top = 2
|
||||||
|
border_width_right = 2
|
||||||
|
border_width_bottom = 2
|
||||||
|
border_color = Color(1.0, 0.3, 0.3, 0.75)
|
||||||
|
corner_radius_top_left = 3
|
||||||
|
corner_radius_top_right = 3
|
||||||
|
corner_radius_bottom_right = 3
|
||||||
|
corner_radius_bottom_left = 3
|
||||||
|
content_margin_left = 10.0
|
||||||
|
content_margin_top = 4.0
|
||||||
|
content_margin_right = 10.0
|
||||||
|
content_margin_bottom = 4.0
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_reset_pressed"]
|
||||||
|
bg_color = Color(0.35, 0.02, 0.02, 0.6)
|
||||||
|
border_width_left = 2
|
||||||
|
border_width_top = 2
|
||||||
|
border_width_right = 2
|
||||||
|
border_width_bottom = 2
|
||||||
|
border_color = Color(1.0, 0.5, 0.5, 1.0)
|
||||||
|
corner_radius_top_left = 3
|
||||||
|
corner_radius_top_right = 3
|
||||||
|
corner_radius_bottom_right = 3
|
||||||
|
corner_radius_bottom_left = 3
|
||||||
|
content_margin_left = 10.0
|
||||||
|
content_margin_top = 4.0
|
||||||
|
content_margin_right = 10.0
|
||||||
|
content_margin_bottom = 4.0
|
||||||
|
|
||||||
[node name="StatsScreen" type="CanvasLayer"]
|
[node name="StatsScreen" type="CanvasLayer"]
|
||||||
script = ExtResource("1_stats")
|
script = ExtResource("1_stats")
|
||||||
|
|
||||||
|
|
@ -108,6 +140,23 @@ size_flags_horizontal = 3
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
custom_minimum_size = Vector2(0, 12)
|
custom_minimum_size = Vector2(0, 12)
|
||||||
|
|
||||||
|
[node name="ResetButton" type="Button" parent="VBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(250, 50)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0.85, 0.5, 0.5, 1)
|
||||||
|
theme_override_colors/font_hover_color = Color(1, 0.35, 0.35, 1)
|
||||||
|
theme_override_colors/font_pressed_color = Color(1, 0.55, 0.55, 1)
|
||||||
|
theme_override_colors/font_focus_color = Color(0.85, 0.5, 0.5, 1)
|
||||||
|
theme_override_fonts/font = ExtResource("3_stats")
|
||||||
|
theme_override_font_sizes/font_size = 24
|
||||||
|
theme_override_styles/normal = SubResource("StyleBoxEmpty_normal")
|
||||||
|
theme_override_styles/hover = SubResource("StyleBoxFlat_reset_hover")
|
||||||
|
theme_override_styles/pressed = SubResource("StyleBoxFlat_reset_pressed")
|
||||||
|
theme_override_styles/focus = SubResource("StyleBoxEmpty_focus")
|
||||||
|
theme_override_styles/disabled = SubResource("StyleBoxEmpty_normal")
|
||||||
|
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_reset_pressed")
|
||||||
|
text = "Reset Stats & Achievements"
|
||||||
|
|
||||||
[node name="BackButton" type="Button" parent="VBoxContainer"]
|
[node name="BackButton" type="Button" parent="VBoxContainer"]
|
||||||
custom_minimum_size = Vector2(250, 50)
|
custom_minimum_size = Vector2(250, 50)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
@ -125,4 +174,5 @@ theme_override_styles/disabled = SubResource("StyleBoxEmpty_normal")
|
||||||
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_pressed")
|
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_pressed")
|
||||||
text = "Back"
|
text = "Back"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="VBoxContainer/ResetButton" to="." method="_on_reset_button_pressed"]
|
||||||
[connection signal="pressed" from="VBoxContainer/BackButton" to="." method="_on_back_button_pressed"]
|
[connection signal="pressed" from="VBoxContainer/BackButton" to="." method="_on_back_button_pressed"]
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,11 @@ func _meets(ach: Dictionary) -> bool:
|
||||||
return d["runs_played"] >= t
|
return d["runs_played"] >= t
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
func reset() -> void:
|
||||||
|
for ach in achievements:
|
||||||
|
ach.unlocked = false
|
||||||
|
_save()
|
||||||
|
|
||||||
func get_unlocked_count() -> int:
|
func get_unlocked_count() -> int:
|
||||||
var n = 0
|
var n = 0
|
||||||
for ach in achievements:
|
for ach in achievements:
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,17 @@ func on_spell_cast(spell_type: String) -> void:
|
||||||
data["spells_cast"][spell_type] += 1
|
data["spells_cast"][spell_type] += 1
|
||||||
AchievementManager.call_deferred("check_all")
|
AchievementManager.call_deferred("check_all")
|
||||||
|
|
||||||
|
func reset() -> void:
|
||||||
|
data["runs_played"] = 0
|
||||||
|
data["total_deaths"] = 0
|
||||||
|
data["longest_run_seconds"] = 0.0
|
||||||
|
data["total_survive_seconds"] = 0.0
|
||||||
|
for key in data["kills"]:
|
||||||
|
data["kills"][key] = 0
|
||||||
|
for key in data["spells_cast"]:
|
||||||
|
data["spells_cast"][key] = 0
|
||||||
|
_save()
|
||||||
|
|
||||||
func _save() -> void:
|
func _save() -> void:
|
||||||
var file = FileAccess.open(SAVE_PATH, FileAccess.WRITE)
|
var file = FileAccess.open(SAVE_PATH, FileAccess.WRITE)
|
||||||
if file == null:
|
if file == null:
|
||||||
|
|
|
||||||
|
|
@ -89,5 +89,10 @@ func _fmt_time(seconds: float) -> String:
|
||||||
return "%dh %02dm %02ds" % [h, m, sec]
|
return "%dh %02dm %02ds" % [h, m, sec]
|
||||||
return "%dm %02ds" % [m, sec]
|
return "%dm %02ds" % [m, sec]
|
||||||
|
|
||||||
|
func _on_reset_button_pressed() -> void:
|
||||||
|
StatsManager.reset()
|
||||||
|
AchievementManager.reset()
|
||||||
|
get_tree().change_scene_to_file("res://scenes/stats_screen.tscn")
|
||||||
|
|
||||||
func _on_back_button_pressed() -> void:
|
func _on_back_button_pressed() -> void:
|
||||||
get_tree().change_scene_to_file("res://scenes/mainmenu.tscn")
|
get_tree().change_scene_to_file("res://scenes/mainmenu.tscn")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue