diff --git a/core/globals/gamestate.gd b/core/globals/gamestate.gd index ef2dbc1..d4a261c 100644 --- a/core/globals/gamestate.gd +++ b/core/globals/gamestate.gd @@ -75,6 +75,9 @@ func reset_slot(idx: int): if FileAccess.file_exists(slot_path): DirAccess.remove_absolute(slot_path) +func is_slot_used(idx: int): + return FileAccess.file_exists("user://slot%s.save" % idx) + # func quit(code: int): diff --git a/menu/slot/slot.gd b/menu/slot/slot.gd index dc5cc4c..b15cbae 100644 --- a/menu/slot/slot.gd +++ b/menu/slot/slot.gd @@ -1,11 +1,20 @@ extends Node2D +const COLOR_NORMAL = Color.DARK_SLATE_GRAY +const COLOR_USED = Color.WHITE + @export var slot_idx: int @export var slot_label: String = "" +func update_color(): + if Gamestate.is_slot_used(slot_idx): + $StaticBody2D/platform.color = COLOR_USED + else: + $StaticBody2D/platform.color = COLOR_NORMAL func _ready() -> void: $Label.text = str(slot_label) + update_color() func _on_area_2d_load_body_entered(body: Node2D) -> void: # load slot & start game @@ -18,4 +27,5 @@ func _on_area_2d_delete_body_entered(body: Node2D) -> void: # reset slot on disk if body == NodeRegistry.player: Gamestate.reset_slot(slot_idx) - NodeRegistry.player.position = Levels.mainmenu_player_pos + update_color() + NodeRegistry.player.position = self.global_position - Vector2(0, 32)