Added level selection screen
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
class_name CSaveManager
|
||||
extends Node
|
||||
|
||||
|
||||
@export var save_file_path := "user://save.bin"
|
||||
@export var save_file_pass := "save_file_data"
|
||||
|
||||
|
||||
const CATEGORY_GAME = "game"
|
||||
const GAME_COMPLETED_LEVELS = "completed_levels"
|
||||
|
||||
|
||||
var completed_levels := 0
|
||||
|
||||
var _save_file: ConfigFile
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_save_file = ConfigFile.new()
|
||||
_load()
|
||||
|
||||
|
||||
func save() -> void:
|
||||
_save_file.set_value(CATEGORY_GAME, GAME_COMPLETED_LEVELS, completed_levels)
|
||||
_save_file.save_encrypted_pass(save_file_path, save_file_pass)
|
||||
|
||||
|
||||
|
||||
|
||||
func _load() -> void:
|
||||
if _save_file.load_encrypted_pass(save_file_path, save_file_pass) == OK:
|
||||
_process_save_file()
|
||||
|
||||
save()
|
||||
|
||||
|
||||
func _process_save_file() -> void:
|
||||
completed_levels = _save_file.get_value(
|
||||
CATEGORY_GAME, GAME_COMPLETED_LEVELS, completed_levels
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
uid://d2vtovrykiwd
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cuqxyst3qlvmw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d2vtovrykiwd" path="res://game/managers/save_manager.gd" id="1_c6jim"]
|
||||
|
||||
[node name="SaveManager" type="Node"]
|
||||
script = ExtResource("1_c6jim")
|
||||
Reference in New Issue
Block a user