-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvsk_profile_dialog.gd
99 lines (63 loc) · 2.52 KB
/
vsk_profile_dialog.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Copyright (c) 2018-present. This file is part of V-Sekai https://v-sekai.org/.
# SaracenOne & K. S. Ernest (Fire) Lee & Lyuma & MMMaellon & Contributors
# vsk_profile_dialog.gd
# SPDX-License-Identifier: MIT
@tool
extends AcceptDialog
var vsk_editor: Node = null
const WINDOW_SIZE = Vector2(650, 800)
var control: Control = null
var vsk_login_control_script_const = preload("vsk_login_editor_control.gd")
var vsk_profile_control_script_const = preload("vsk_profile_editor_control.gd")
# const vsk_profile_control_const = preload("vsk_profile_editor_control.tscn")
var vsk_profile_control_const = load("res://addons/vsk_editor/vsk_profile_editor_control.tscn")
func _clear_children() -> void:
if control:
control.queue_free()
control.get_parent().remove_child(control)
control = null
func _instance_login_child_control() -> void:
set_title("Sign in")
if control and control.get_script() != vsk_login_control_script_const:
_clear_children()
if !control:
control = vsk_login_control_script_const.new(vsk_editor)
if control.session_request_successful.connect(self._state_changed) != OK:
push_error("Could not connect 'session_request_successful'")
add_child(control, true)
control.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT, Control.PRESET_MODE_MINSIZE)
func _instance_profile_child_control() -> void:
set_title("Profile")
if control and not is_instance_of(control.get_script(), vsk_profile_control_script_const):
_clear_children()
if !control:
control = vsk_profile_control_const.instantiate()
control.set_vsk_editor(vsk_editor)
if control.session_deletion_successful.connect(self._state_changed) != OK:
push_error("Could not connect 'session_deletion_successful'")
add_child(control, true)
control.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT, Control.PRESET_MODE_MINSIZE)
func _instance_child_control() -> void:
if VSKAccountManager.is_signed_in():
_instance_profile_child_control()
else:
_instance_login_child_control()
func _about_to_popup() -> void:
_state_changed()
func _state_changed() -> void:
_instance_child_control()
func _about_to_close() -> void:
self.hide()
func _ready() -> void:
if about_to_popup.connect(self._about_to_popup) != OK:
push_error("Could not connect to about_to_popup")
close_requested.connect(self._about_to_close)
popup_window = false
var ok_button: Button = get_ok_button()
if ok_button:
ok_button.hide()
func _init(p_vsk_editor: Node):
popup_window = false
vsk_editor = p_vsk_editor
set_title("Sign in")
set_size(WINDOW_SIZE)