add a new main scene (#89)

Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/89
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
Lera Elvoé 2024-02-29 18:41:53 +00:00 committed by yagich
parent 7eaac0dee5
commit d98d6f52bd
4 changed files with 53 additions and 15 deletions

View file

@ -67,9 +67,10 @@ var _deck_to_save: WeakRef
@onready var twitch_setup_dialog := $Twitch_Setup_Dialog as TwitchSetupDialog @onready var twitch_setup_dialog := $Twitch_Setup_Dialog as TwitchSetupDialog
@onready var bottom_dock: BottomDock = %BottomDock @onready var bottom_dock: BottomDock = %BottomDock
signal quit_completed
func _ready() -> void: func _ready() -> void:
get_tree().auto_accept_quit = false
tab_container.add_button_pressed.connect(add_empty_deck) tab_container.add_button_pressed.connect(add_empty_deck)
tab_container.tab_changed.connect(_on_tab_container_tab_changed) tab_container.tab_changed.connect(_on_tab_container_tab_changed)
tab_container.tab_about_to_change.connect(_on_tab_container_tab_about_to_change) tab_container.tab_about_to_change.connect(_on_tab_container_tab_about_to_change)
@ -465,19 +466,17 @@ func add_recents_to_menu() -> void:
RendererPersistence.set_value(PERSISTENCE_NAMESPACE, "config", "recent_files", recent_files) RendererPersistence.set_value(PERSISTENCE_NAMESPACE, "config", "recent_files", recent_files)
func _notification(what: int) -> void: func request_quit() -> void:
if what == NOTIFICATION_WM_CLOSE_REQUEST:
RendererPersistence.commit(PERSISTENCE_NAMESPACE) RendererPersistence.commit(PERSISTENCE_NAMESPACE)
if range(tab_container.get_tab_count()).any(func(x: int): return tab_container.get_content(x).dirty): if range(tab_container.get_tab_count()).any(func(x: int): return tab_container.get_content(x).dirty):
unsaved_changes_dialog.show() unsaved_changes_dialog.show()
else: else:
#for i in tab_container.get_tab_count():
#close_tab(i)
for i in range(tab_container.get_tab_count() - 1, -1, -1): for i in range(tab_container.get_tab_count() - 1, -1, -1):
await close_tab(i) await close_tab(i)
get_tree().quit() #get_tree().quit()
quit_completed.emit()
func _on_unsaved_changes_dialog_single_deck_confirmed() -> void: func _on_unsaved_changes_dialog_single_deck_confirmed() -> void:
@ -494,7 +493,8 @@ func _on_unsaved_changes_dialog_single_deck_custom_action(action: StringName) ->
func _on_unsaved_changes_dialog_confirmed() -> void: func _on_unsaved_changes_dialog_confirmed() -> void:
for i in range(tab_container.get_tab_count() - 1, -1, -1): for i in range(tab_container.get_tab_count() - 1, -1, -1):
await close_tab(i) await close_tab(i)
get_tree().quit() #get_tree().quit()
quit_completed.emit()
func _unhandled_input(event: InputEvent) -> void: func _unhandled_input(event: InputEvent) -> void:

32
main.gd Normal file
View file

@ -0,0 +1,32 @@
# (c) 2023-present Eroax
# (c) 2023-present Yagich
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
extends Node
const DEFAULT_RENDERER := preload("res://graph_node_renderer/deck_holder_renderer.tscn")
var deck_holder_renderer: DeckHolderRenderer = null
var deck_holder_renderer_finished := false
func _ready() -> void:
get_tree().auto_accept_quit = false
if DisplayServer.get_name() != "headless":
# not headless, start default renderer
deck_holder_renderer = DEFAULT_RENDERER.instantiate()
add_child(deck_holder_renderer)
deck_holder_renderer.quit_completed.connect(_on_deck_holder_renderer_quit_completed)
func _on_deck_holder_renderer_quit_completed() -> void:
# will be used later to make sure both default and rpc are finished processing
deck_holder_renderer_finished = true
get_tree().quit()
func _notification(what: int) -> void:
if what == NOTIFICATION_WM_CLOSE_REQUEST:
if deck_holder_renderer:
deck_holder_renderer.request_quit()

6
main.tscn Normal file
View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://clxtes7sdpe65"]
[ext_resource type="Script" path="res://main.gd" id="1_rxyjw"]
[node name="Main" type="Node"]
script = ExtResource("1_rxyjw")

View file

@ -12,7 +12,7 @@ config_version=5
config/name="StreamGraph" config/name="StreamGraph"
config/version="0.0.5" config/version="0.0.5"
run/main_scene="res://graph_node_renderer/deck_holder_renderer.tscn" run/main_scene="res://main.tscn"
config/use_custom_user_dir=true config/use_custom_user_dir=true
config/custom_user_dir_name="streamgraph" config/custom_user_dir_name="streamgraph"
config/auto_accept_quit=false config/auto_accept_quit=false