gd: added menu template

This commit is contained in:
2025-06-10 18:46:20 +02:00
parent f9a6c42b14
commit c554e24b01
421 changed files with 12371 additions and 2 deletions

View File

@ -0,0 +1,60 @@
class_name GameState
extends Resource
const STATE_NAME : String = "GameState"
const FILE_PATH = "res://menus/scripts/game_state.gd"
@export var level_states : Dictionary = {}
@export var max_level_reached : int
@export var current_level : int
@export var times_played : int
static func get_level_state(level_state_key : String) -> LevelState:
var game_state := get_game_state()
if level_state_key.is_empty() : return
if level_state_key in game_state.level_states:
return game_state.level_states[level_state_key]
else:
var new_level_state := LevelState.new()
game_state.level_states[level_state_key] = new_level_state
return new_level_state
static func has_game_state() -> bool:
return GlobalState.has_state(STATE_NAME)
static func get_game_state() -> GameState:
return GlobalState.get_state(STATE_NAME, FILE_PATH)
static func get_current_level() -> int:
var game_state := get_game_state()
if not game_state:
return 0
return game_state.current_level
static func get_max_level_reached() -> int:
var game_state := get_game_state()
if not game_state:
return 0
return game_state.max_level_reached
static func level_reached(level_number : int) -> void:
var game_state := get_game_state()
if not game_state:
return
game_state.max_level_reached = max(level_number, game_state.max_level_reached)
game_state.current_level = level_number
GlobalState.save()
static func set_current_level(level_number : int) -> void:
var game_state := get_game_state()
if not game_state:
return
game_state.current_level = level_number
GlobalState.save()
static func start_game() -> void:
var game_state := get_game_state()
if not game_state:
return
game_state.times_played += 1
GlobalState.save()

View File

@ -0,0 +1 @@
uid://yelhbgm3q31p

View File

@ -0,0 +1,14 @@
extends LevelListManager
func set_current_level_id(value : int) -> void:
super.set_current_level_id(value)
GameState.level_reached(value)
func get_current_level_id() -> int:
current_level_id = GameState.get_current_level() if force_level == -1 else force_level
return current_level_id
func _advance_level() -> bool:
var _advanced := super._advance_level()
GameState.set_current_level(current_level_id)
return _advanced

View File

@ -0,0 +1 @@
uid://3yfyhcjuxm0t

View File

@ -0,0 +1,5 @@
class_name LevelState
extends Resource
@export var color : Color
@export var tutorial_read : bool = false

View File

@ -0,0 +1 @@
uid://d1dccbxlxbleg