mirror of
https://git.kittycat.homes/zoe/pegchamp.git
synced 2024-08-15 03:15:39 +00:00
save system
This commit is contained in:
parent
ad8de1dbb7
commit
ffcccb8c2e
29 changed files with 286 additions and 77 deletions
|
@ -13,3 +13,4 @@ bus = "SFX"
|
|||
|
||||
[node name="Select" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 2 )
|
||||
bus = "SFX"
|
||||
|
|
|
@ -6,6 +6,7 @@ export var unlock_points_required = 0
|
|||
func _ready():
|
||||
if unlock_points_required > GameStats.unlock_points:
|
||||
disabled = true
|
||||
text = String(unlock_points_required - GameStats.unlock_points) + " more points"
|
||||
|
||||
func _on_SceneSelectButton_pressed():
|
||||
GameStats.set_current_scene(scene)
|
||||
|
|
|
@ -7,8 +7,16 @@
|
|||
[ext_resource path="res://Menu/Buttons/ButtonSFX.tscn" type="PackedScene" id=5]
|
||||
|
||||
[node name="PlayButton" type="TextureButton"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -384.0
|
||||
margin_top = -216.0
|
||||
margin_right = -352.0
|
||||
margin_bottom = -184.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
texture_normal = ExtResource( 3 )
|
||||
texture_pressed = ExtResource( 1 )
|
||||
texture_hover = ExtResource( 2 )
|
||||
|
@ -21,5 +29,5 @@ __meta__ = {
|
|||
|
||||
[connection signal="focus_entered" from="." to="ButtonSFX" method="on_hover"]
|
||||
[connection signal="mouse_entered" from="." to="ButtonSFX" method="on_hover"]
|
||||
[connection signal="pressed" from="." to="." method="_on_PlayButton_pressed"]
|
||||
[connection signal="pressed" from="." to="ButtonSFX" method="on_select"]
|
||||
[connection signal="pressed" from="." to="." method="_on_PlayButton_pressed"]
|
||||
|
|
|
@ -21,5 +21,5 @@ __meta__ = {
|
|||
|
||||
[connection signal="focus_entered" from="." to="ButtonSFX" method="on_hover"]
|
||||
[connection signal="mouse_entered" from="." to="ButtonSFX" method="on_hover"]
|
||||
[connection signal="pressed" from="." to="ButtonSFX" method="on_select"]
|
||||
[connection signal="pressed" from="." to="." method="_on_RestartButton_pressed"]
|
||||
[connection signal="pressed" from="." to="ButtonSFX" method="on_select"]
|
||||
|
|
|
@ -1,12 +1,26 @@
|
|||
extends VBoxContainer
|
||||
extends PanelContainer
|
||||
|
||||
onready var stage_label = $CenterContainer/HBoxContainer/VBoxContainer/StageName
|
||||
onready var score = $CenterContainer/HBoxContainer/VBoxContainer/ScoreLabel
|
||||
onready var play = $CenterContainer/HBoxContainer/PlayButton
|
||||
|
||||
func _ready():
|
||||
var _game_stats = GameStats.connect("current_stage_changed", self, "update_info")
|
||||
|
||||
func update_info(stage):
|
||||
$HBoxContainer/PlayButton.disabled = false
|
||||
play.disabled = false
|
||||
var Stage = load(stage)
|
||||
stage = Stage.instance()
|
||||
|
||||
$ScoreLabel.text = stage.stage_name
|
||||
$HBoxContainer/PlayButton.visible = true
|
||||
score.text = String(stage.high_score)
|
||||
play.visible = true
|
||||
|
||||
var filename = "user://" + stage.stage_name + ".dat"
|
||||
var file = File.new()
|
||||
if file.file_exists(filename):
|
||||
var err = file.open(filename, File.READ)
|
||||
if err == OK:
|
||||
var data = file.get_var()
|
||||
file.close()
|
||||
score.text = String(data.high_score)
|
||||
stage_label.text = String(stage.stage_name)
|
||||
|
|
|
@ -1,50 +1,65 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Menu/LevelInfo.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Menu/Theme.tres" type="Theme" id=2]
|
||||
[ext_resource path="res://Menu/Buttons/PlayButton.tscn" type="PackedScene" id=6]
|
||||
|
||||
[node name="LevelInfo" type="VBoxContainer"]
|
||||
margin_left = 3.0
|
||||
margin_right = 150.0
|
||||
margin_bottom = 165.0
|
||||
alignment = 2
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.847059, 0.74902, 0.847059, 1 )
|
||||
|
||||
[node name="LevelInfo" type="PanelContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 2 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="."]
|
||||
margin_top = 115.0
|
||||
margin_right = 147.0
|
||||
margin_bottom = 129.0
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
margin_right = 384.0
|
||||
margin_bottom = 216.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer"]
|
||||
margin_left = 133.0
|
||||
margin_top = 88.0
|
||||
margin_right = 250.0
|
||||
margin_bottom = 128.0
|
||||
alignment = 1
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/HBoxContainer"]
|
||||
margin_right = 117.0
|
||||
margin_bottom = 40.0
|
||||
alignment = 1
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="CenterContainer/HBoxContainer/VBoxContainer"]
|
||||
margin_right = 117.0
|
||||
margin_bottom = 18.0
|
||||
theme = ExtResource( 2 )
|
||||
text = "high score"
|
||||
align = 2
|
||||
valign = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="StageName" type="Label" parent="CenterContainer/HBoxContainer/VBoxContainer"]
|
||||
margin_top = 22.0
|
||||
margin_right = 117.0
|
||||
margin_bottom = 40.0
|
||||
theme = ExtResource( 2 )
|
||||
text = "select stage"
|
||||
align = 2
|
||||
valign = 3
|
||||
|
||||
[node name="StageName" type="Label" parent="."]
|
||||
margin_top = 133.0
|
||||
margin_right = 147.0
|
||||
margin_bottom = 147.0
|
||||
text = "..."
|
||||
align = 2
|
||||
valign = 3
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
margin_top = 151.0
|
||||
margin_right = 147.0
|
||||
margin_bottom = 165.0
|
||||
alignment = 2
|
||||
|
||||
[node name="GoodLuck!!!" type="Label" parent="HBoxContainer"]
|
||||
margin_left = 135.0
|
||||
margin_right = 147.0
|
||||
margin_bottom = 14.0
|
||||
text = "..."
|
||||
align = 2
|
||||
valign = 3
|
||||
|
||||
[node name="PlayButton" parent="HBoxContainer" instance=ExtResource( 6 )]
|
||||
[node name="PlayButton" parent="CenterContainer/HBoxContainer" instance=ExtResource( 6 )]
|
||||
visible = false
|
||||
margin_left = 94.0
|
||||
margin_right = 126.0
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 121.0
|
||||
margin_top = 0.0
|
||||
margin_right = 153.0
|
||||
margin_bottom = 32.0
|
||||
disabled = true
|
||||
|
|
|
@ -105,7 +105,6 @@ __meta__ = {
|
|||
[node name="LevelInfo" parent="Control/TabContainer/Levels/HBoxContainer" instance=ExtResource( 7 )]
|
||||
margin_left = 157.0
|
||||
margin_right = 172.0
|
||||
alignment = 1
|
||||
|
||||
[node name="LevelList" type="ScrollContainer" parent="Control/TabContainer/Levels/HBoxContainer"]
|
||||
margin_left = 176.0
|
||||
|
|
|
@ -54,19 +54,19 @@ anchor_bottom = 0.0
|
|||
margin_right = 32.0
|
||||
margin_bottom = 32.0
|
||||
|
||||
[node name="LevelSelectIconButton" parent="Pause/PanelContainer/HBoxContainer/VBoxContainer" instance=ExtResource( 6 )]
|
||||
[node name="RestartButton" parent="Pause/PanelContainer/HBoxContainer/VBoxContainer" instance=ExtResource( 1 )]
|
||||
margin_left = 36.0
|
||||
margin_right = 68.0
|
||||
margin_bottom = 32.0
|
||||
|
||||
[node name="LevelSelectIconButton" parent="Pause/PanelContainer/HBoxContainer/VBoxContainer" instance=ExtResource( 6 )]
|
||||
margin_left = 72.0
|
||||
margin_right = 104.0
|
||||
margin_bottom = 32.0
|
||||
texture_normal = ExtResource( 3 )
|
||||
texture_pressed = ExtResource( 5 )
|
||||
texture_hover = ExtResource( 4 )
|
||||
|
||||
[node name="RestartButton" parent="Pause/PanelContainer/HBoxContainer/VBoxContainer" instance=ExtResource( 1 )]
|
||||
margin_left = 72.0
|
||||
margin_right = 104.0
|
||||
margin_bottom = 32.0
|
||||
|
||||
[node name="Resume" type="TextureButton" parent="Pause/PanelContainer/HBoxContainer/VBoxContainer"]
|
||||
margin_left = 108.0
|
||||
margin_right = 140.0
|
||||
|
@ -93,8 +93,8 @@ custom_icons/grabber_highlight = ExtResource( 14 )
|
|||
custom_icons/grabber = ExtResource( 13 )
|
||||
bus_channel = "Music"
|
||||
|
||||
[connection signal="pressed" from="Pause/PanelContainer/HBoxContainer/VBoxContainer/LevelSelectIconButton" to="Pause" method="_on_pause_button_pressed"]
|
||||
[connection signal="pressed" from="Pause/PanelContainer/HBoxContainer/VBoxContainer/RestartButton" to="Pause" method="_on_pause_button_pressed"]
|
||||
[connection signal="pressed" from="Pause/PanelContainer/HBoxContainer/VBoxContainer/LevelSelectIconButton" to="Pause" method="_on_pause_button_pressed"]
|
||||
[connection signal="focus_entered" from="Pause/PanelContainer/HBoxContainer/VBoxContainer/Resume" to="Pause/PanelContainer/HBoxContainer/VBoxContainer/Resume/ButtonSFX" method="on_hover"]
|
||||
[connection signal="mouse_entered" from="Pause/PanelContainer/HBoxContainer/VBoxContainer/Resume" to="Pause/PanelContainer/HBoxContainer/VBoxContainer/Resume/ButtonSFX" method="on_hover"]
|
||||
[connection signal="pressed" from="Pause/PanelContainer/HBoxContainer/VBoxContainer/Resume" to="Pause" method="_on_pause_button_pressed"]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=10 format=2]
|
||||
[gd_scene load_steps=11 format=2]
|
||||
|
||||
[ext_resource path="res://Menu/MenuPage.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Menu/Buttons/RestartButton.tscn" type="PackedScene" id=2]
|
||||
|
@ -8,6 +8,7 @@
|
|||
[ext_resource path="res://Menu/Icons/Home/homeIcon1.png" type="Texture" id=6]
|
||||
[ext_resource path="res://Menu/Icons/Home/homeIcon2.png" type="Texture" id=7]
|
||||
[ext_resource path="res://Menu/Icons/Home/homeIcon3.png" type="Texture" id=8]
|
||||
[ext_resource path="res://Menu/WinScreenScoreLabel.gd" type="Script" id=9]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "win"
|
||||
|
@ -40,8 +41,8 @@ script = ExtResource( 4 )
|
|||
visible = false
|
||||
|
||||
[node name="GridContainer" parent="Control/Panel/CenterContainer" index="0"]
|
||||
margin_top = 55.0
|
||||
margin_bottom = 109.0
|
||||
margin_top = 44.0
|
||||
margin_bottom = 120.0
|
||||
|
||||
[node name="ButtonRow" parent="Control/Panel/CenterContainer/GridContainer" index="1"]
|
||||
margin_bottom = 54.0
|
||||
|
@ -59,6 +60,14 @@ texture_normal = ExtResource( 6 )
|
|||
texture_pressed = ExtResource( 8 )
|
||||
texture_hover = ExtResource( 7 )
|
||||
|
||||
[node name="WinScreenScoreLabel" type="Label" parent="Control/Panel/CenterContainer/GridContainer" index="2"]
|
||||
margin_top = 58.0
|
||||
margin_right = 86.0
|
||||
margin_bottom = 76.0
|
||||
text = "700"
|
||||
align = 1
|
||||
script = ExtResource( 9 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="1"]
|
||||
anims/win = SubResource( 1 )
|
||||
|
||||
|
|
8
Menu/WinScreenScoreLabel.gd
Normal file
8
Menu/WinScreenScoreLabel.gd
Normal file
|
@ -0,0 +1,8 @@
|
|||
extends Label
|
||||
|
||||
func _ready():
|
||||
GameStats.connect("score_changed", self, "update_score_text")
|
||||
text = String(GameStats.score)
|
||||
|
||||
func update_score_text(value):
|
||||
text = String(value)
|
Loading…
Add table
Add a link
Reference in a new issue