Compare commits
2 Commits
563b291a6f
...
abd913e4df
Author | SHA1 | Date |
---|---|---|
Martin Felis | abd913e4df | |
Martin Felis | 7bcf34e7ca |
19
root_ui.gd
19
root_ui.gd
|
@ -1,9 +1,11 @@
|
|||
class_name RootUI
|
||||
extends CanvasLayer
|
||||
|
||||
const GAME_PROFILE_FOLDER:String = "game_profiles"
|
||||
|
||||
@export var startup_scene:PackedScene
|
||||
@export var game_scene:PackedScene
|
||||
@export var autostart_game_scene:bool = true
|
||||
@export var autostart_game_profile:String = ""
|
||||
|
||||
@onready var scene = %Scene
|
||||
@onready var ui_panels:Array = [ %MainMenuUI, %StartGameMenuUI, %CreateGameUI, %GameUI ]
|
||||
|
@ -19,10 +21,11 @@ var current_game_profile_directory:String = ""
|
|||
var _game_build_system:BuildSystem = null
|
||||
|
||||
func _ready():
|
||||
if autostart_game_scene:
|
||||
load_scene(game_scene)
|
||||
set_root_ui_state(ROOT_UI_STATE.GAME)
|
||||
else:
|
||||
var autostart_load_success = false
|
||||
if not autostart_game_profile.is_empty():
|
||||
autostart_load_success = _on_start_game_profile("user://" + GAME_PROFILE_FOLDER + "/" + autostart_game_profile + "/game.tres")
|
||||
|
||||
if not autostart_load_success:
|
||||
set_root_ui_state(ROOT_UI_STATE.MENU)
|
||||
|
||||
%CreateGameUI.start_game.connect(_on_start_game_profile)
|
||||
|
@ -157,7 +160,7 @@ func set_root_ui_state(state:ROOT_UI_STATE):
|
|||
|
||||
_root_ui_state = state
|
||||
|
||||
func _on_start_game_profile(profile_path:String) -> void:
|
||||
func _on_start_game_profile(profile_path:String) -> bool:
|
||||
current_game_profile = null
|
||||
current_game_profile_directory = ""
|
||||
|
||||
|
@ -165,7 +168,7 @@ func _on_start_game_profile(profile_path:String) -> void:
|
|||
current_game_profile = ResourceLoader.load(profile_path)
|
||||
if current_game_profile == null:
|
||||
push_error("Error loading game profile " + profile_path)
|
||||
return
|
||||
return false
|
||||
|
||||
# Update last_played timestamp
|
||||
current_game_profile.last_played = Time.get_datetime_string_from_system()
|
||||
|
@ -182,6 +185,8 @@ func _on_start_game_profile(profile_path:String) -> void:
|
|||
|
||||
activate_ui_panel(%GameUI)
|
||||
|
||||
return true
|
||||
|
||||
func _is_savegame_available() -> bool:
|
||||
if current_game_profile_directory == "":
|
||||
return false
|
||||
|
|
|
@ -212,7 +212,7 @@ unique_name_in_owner = true
|
|||
script = ExtResource("1_7fnkg")
|
||||
startup_scene = ExtResource("2_1untt")
|
||||
game_scene = ExtResource("3_w1gpn")
|
||||
autostart_game_scene = false
|
||||
autostart_game_profile = "Development"
|
||||
|
||||
[node name="MainMenuUI" type="Panel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
|
|
@ -7,13 +7,13 @@ func _ready():
|
|||
if not DialogueManager.is_connected("dialogue_ended", InteractionSystem.stop_conversation):
|
||||
DialogueManager.connect("dialogue_ended", InteractionSystem.stop_conversation)
|
||||
|
||||
func start_conversation(resource: DialogueResource) -> void:
|
||||
func start_conversation(_resource: DialogueResource) -> void:
|
||||
is_conversation_active = true
|
||||
|
||||
if player:
|
||||
player.is_input_blocked = true
|
||||
|
||||
func stop_conversation(resource: DialogueResource) -> void:
|
||||
func stop_conversation(_resource: DialogueResource) -> void:
|
||||
is_conversation_active = false
|
||||
|
||||
if player:
|
||||
|
|
Loading…
Reference in New Issue