Indent every script with tabs, like the Godot editor does

This commit is contained in:
Sansan committed 2026-10-06 10:28:12 +02:00
1 parent 8c1987807c
commit bad4b3ad8b
35 files changed
+1653 -1653

No files matched your search

+13 -13
View File
@@ -8,20 +8,20 @@ var _values: Dictionary = {}
## Records the current values of every script variable on [param autoloads].
static func take(autoloads: Array[Node]) -> AutoloadSnapshot:
var snapshot: AutoloadSnapshot = AutoloadSnapshot.new()
for autoload: Node in autoloads:
var values: Dictionary = {}
for property: Dictionary in autoload.get_property_list():
if property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE:
var value: Variant = autoload.get(property.name)
values[property.name] = value.duplicate() if value is Array else value
snapshot._values[autoload] = values
return snapshot
var snapshot: AutoloadSnapshot = AutoloadSnapshot.new()
for autoload: Node in autoloads:
var values: Dictionary = {}
for property: Dictionary in autoload.get_property_list():
if property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE:
var value: Variant = autoload.get(property.name)
values[property.name] = value.duplicate() if value is Array else value
snapshot._values[autoload] = values
return snapshot
## Puts back the values recorded by [method take].
func restore() -> void:
for autoload: Node in _values:
var values: Dictionary = _values[autoload]
for property_name: String in values:
autoload.set(property_name, values[property_name])
for autoload: Node in _values:
var values: Dictionary = _values[autoload]
for property_name: String in values:
autoload.set(property_name, values[property_name])
+31 -31
View File
@@ -18,74 +18,74 @@ var _previous_transport: HttpTransport
func _init() -> void:
super(null)
super(null)
## Replaces the MusicServerClient transport with this fake.
func install() -> FakeHttpTransport:
_previous_transport = MusicServerClient.transport
MusicServerClient.transport = self
return self
_previous_transport = MusicServerClient.transport
MusicServerClient.transport = self
return self
## Restores the transport that was active before [method install].
func uninstall() -> void:
MusicServerClient.transport = _previous_transport
MusicServerClient.transport = _previous_transport
## Answers requests to [param path] with [param data] encoded as JSON.
func respond_json(path: String, data: Variant, response_code: int = 200) -> void:
respond_bytes(path, JSON.stringify(data).to_utf8_buffer(), response_code)
respond_bytes(path, JSON.stringify(data).to_utf8_buffer(), response_code)
## Answers requests to [param path] with [param body] as-is.
func respond_bytes(path: String, body: PackedByteArray, response_code: int = 200) -> void:
_responses[path] = {"code": response_code, "body": body}
_successes_left.erase(path)
_responses[path] = {"code": response_code, "body": body}
_successes_left.erase(path)
## Lets [param successes] more requests to [param path] succeed, then answers 503 until
## a new response is registered for the path.
func fail_after(path: String, successes: int) -> void:
_successes_left[path] = successes
_successes_left[path] = successes
## Holds back responses to [param path] until [method release] is called, like a slow
## server.
func hold(path: String) -> void:
_held_paths[path] = []
_held_paths[path] = []
## Delivers the responses held back for [param path] and stops holding it.
func release(path: String) -> void:
var waiting: Array = _held_paths.get(path, [])
_held_paths.erase(path)
for pending: Callable in waiting:
pending.call()
var waiting: Array = _held_paths.get(path, [])
_held_paths.erase(path)
for pending: Callable in waiting:
pending.call()
## Returns how many times [param path] has been requested.
func count(path: String) -> int:
return requested_paths.count(path)
return requested_paths.count(path)
func request(url: String, method: int, on_complete: Callable) -> void:
var path: String = url.trim_prefix(Settings.default_path)
requested_paths.append(path)
requested_methods.append(method)
if _held_paths.has(path):
_held_paths[path].append(_answer.bind(path, on_complete))
return
_answer(path, on_complete)
var path: String = url.trim_prefix(Settings.default_path)
requested_paths.append(path)
requested_methods.append(method)
if _held_paths.has(path):
_held_paths[path].append(_answer.bind(path, on_complete))
return
_answer(path, on_complete)
func _answer(path: String, on_complete: Callable) -> void:
if _successes_left.has(path):
if _successes_left[path] == 0:
on_complete.call(503, PackedByteArray())
return
_successes_left[path] -= 1
if _responses.has(path):
on_complete.call(_responses[path].code, _responses[path].body)
else:
on_complete.call(404, PackedByteArray())
if _successes_left.has(path):
if _successes_left[path] == 0:
on_complete.call(503, PackedByteArray())
return
_successes_left[path] -= 1
if _responses.has(path):
on_complete.call(_responses[path].code, _responses[path].body)
else:
on_complete.call(404, PackedByteArray())
+66 -66
View File
@@ -3,8 +3,8 @@ extends GdUnitTestSuite
## Base for tests that run the real main window against a fake MusicServer.
const SONG_INFO: Array[Dictionary] = [
{"SongNo": 0, "Soundtrack": "Chrono Trigger", "Song": "Corridors of Time"},
{"SongNo": 1, "Soundtrack": "Final Fantasy VI", "Song": "Dancing Mad"},
{"SongNo": 0, "Soundtrack": "Chrono Trigger", "Song": "Corridors of Time"},
{"SongNo": 1, "Soundtrack": "Final Fantasy VI", "Song": "Dancing Mad"},
]
var _server: FakeHttpTransport
@@ -15,120 +15,120 @@ var _quiz: Quiz
func before_test() -> void:
_snapshot = AutoloadSnapshot.take([Settings, Playlist])
Playlist.reset_playlist()
Playlist.first_song_played = false
Playlist.is_song_downloading = false
Settings.player_array.clear()
Settings.add_to_stats = true
Settings.hide_next_track = true
Settings.use_low_played_mode = false
Settings.winning_score = 20
_snapshot = AutoloadSnapshot.take([Settings, Playlist])
Playlist.reset_playlist()
Playlist.first_song_played = false
Playlist.is_song_downloading = false
Settings.player_array.clear()
Settings.add_to_stats = true
Settings.hide_next_track = true
Settings.use_low_played_mode = false
Settings.winning_score = 20
_server = FakeHttpTransport.new().install()
var mp3: PackedByteArray = FileAccess.get_file_as_bytes("res://tests/data/short.mp3")
_server.respond_json("/music/all", ["Chrono Trigger", "Final Fantasy VI"])
_server.respond_json("/music/all/order", ["Chrono Trigger", "Final Fantasy VI"])
_server.respond_json("/music/list", [])
_server.respond_json("/characters", [])
_server.respond_bytes("/music/rand", mp3)
_server.respond_bytes("/music/addQue", PackedByteArray())
_server.respond_json("/music/info", SONG_INFO[0])
_server.respond_bytes("/music/reset", PackedByteArray())
_server.respond_bytes("/music/played?song=0", PackedByteArray())
_server = FakeHttpTransport.new().install()
var mp3: PackedByteArray = FileAccess.get_file_as_bytes("res://tests/data/short.mp3")
_server.respond_json("/music/all", ["Chrono Trigger", "Final Fantasy VI"])
_server.respond_json("/music/all/order", ["Chrono Trigger", "Final Fantasy VI"])
_server.respond_json("/music/list", [])
_server.respond_json("/characters", [])
_server.respond_bytes("/music/rand", mp3)
_server.respond_bytes("/music/addQue", PackedByteArray())
_server.respond_json("/music/info", SONG_INFO[0])
_server.respond_bytes("/music/reset", PackedByteArray())
_server.respond_bytes("/music/played?song=0", PackedByteArray())
_before_window_starts()
_runner = scene_runner("res://MainWindow.tscn")
_window = _runner.scene()
_quiz = _window.get_node("Quiz")
# The debug build lowers the winning score on startup; keep it out of reach
Settings.winning_score = 20
_before_window_starts()
_runner = scene_runner("res://MainWindow.tscn")
_window = _runner.scene()
_quiz = _window.get_node("Quiz")
# The debug build lowers the winning score on startup; keep it out of reach
Settings.winning_score = 20
## Override to change the fake server before the window starts and sends its first
## requests.
func _before_window_starts() -> void:
pass
pass
func after_test() -> void:
# Let nodes queued for deletion by the window be freed before orphans are counted
await await_idle_frame()
_server.uninstall()
_snapshot.restore()
# Let nodes queued for deletion by the window be freed before orphans are counted
await await_idle_frame()
_server.uninstall()
_snapshot.restore()
## Makes the next song the server hands out the one described by [param info].
func _next_song_is(info: Dictionary) -> void:
_server.respond_json("/music/info", info)
_server.respond_json("/music/info", info)
## Presses a button in the quiz.
func _press(button_path: String) -> void:
(_quiz.get_node(button_path) as Button).pressed.emit()
(_quiz.get_node(button_path) as Button).pressed.emit()
## Presses Next and waits until the first song is playing.
func _play_first_song() -> void:
_press("NextButton")
await _runner.simulate_frames(2)
_press("NextButton")
await _runner.simulate_frames(2)
## Adds a player through the name field, the same way the user does.
func _add_player(player_name: String) -> PlayerObject:
var name_field: TextEdit = _quiz.get_node(
"PlayersPanel/VBoxContainer/AddPlayerContainer/PlayerNameField")
name_field.text = player_name
_quiz.players_panel.add_player()
return Settings.player_array.back() if !Settings.player_array.is_empty() else null
var name_field: TextEdit = _quiz.get_node(
"PlayersPanel/VBoxContainer/AddPlayerContainer/PlayerNameField")
name_field.text = player_name
_quiz.players_panel.add_player()
return Settings.player_array.back() if !Settings.player_array.is_empty() else null
## Returns the row in the player list that shows [param player_object].
func _player_row(player_object: PlayerObject) -> Player:
var rows: Node = _quiz.get_node(
"PlayersPanel/VBoxContainer/ScrollContainer/PlayersListVBoxContainer")
for row: Player in rows.get_children():
if row.player_object == player_object:
return row
return null
var rows: Node = _quiz.get_node(
"PlayersPanel/VBoxContainer/ScrollContainer/PlayersListVBoxContainer")
for row: Player in rows.get_children():
if row.player_object == player_object:
return row
return null
## Removes a player with the remove button in its row.
func _remove_player(player_object: PlayerObject) -> void:
(_player_row(player_object).get_node("HBoxContainer/RemovePlayer") as BaseButton) \
.pressed.emit()
await _runner.simulate_frames(1)
(_player_row(player_object).get_node("HBoxContainer/RemovePlayer") as BaseButton) \
.pressed.emit()
await _runner.simulate_frames(1)
## Clicks at [param position], given in the window's 1920x1080 layout coordinates.
func _click_at(position: Vector2) -> void:
# The runner takes window pixels; the headless test window is much smaller than the
# layout, so convert like a real mouse position would be
_runner.set_mouse_position(_window.get_viewport().get_final_transform() * position)
await _runner.simulate_mouse_button_pressed(MOUSE_BUTTON_LEFT)
await _runner.await_input_processed()
# The runner takes window pixels; the headless test window is much smaller than the
# layout, so convert like a real mouse position would be
_runner.set_mouse_position(_window.get_viewport().get_final_transform() * position)
await _runner.simulate_mouse_button_pressed(MOUSE_BUTTON_LEFT)
await _runner.await_input_processed()
## Presses [param keys] together, e.g. [code][KEY_ALT, KEY_1][/code], then releases them.
func _press_keys(keys: Array[Key]) -> void:
for key: Key in keys:
_runner.simulate_key_press(key)
await _runner.await_input_processed()
keys.reverse()
for key: Key in keys:
_runner.simulate_key_release(key)
await _runner.await_input_processed()
for key: Key in keys:
_runner.simulate_key_press(key)
await _runner.await_input_processed()
keys.reverse()
for key: Key in keys:
_runner.simulate_key_release(key)
await _runner.await_input_processed()
## Gives a point with Alt+<number>.
func _give_point_with_keybind(number: int) -> void:
await _press_keys([KEY_ALT, (KEY_0 + number) as Key])
await _press_keys([KEY_ALT, (KEY_0 + number) as Key])
## Takes a point with Ctrl+Alt+<number>.
func _take_point_with_keybind(number: int) -> void:
await _press_keys([KEY_CTRL, KEY_ALT, (KEY_0 + number) as Key])
await _press_keys([KEY_CTRL, KEY_ALT, (KEY_0 + number) as Key])
func _scores() -> Array:
return Settings.player_array.map(func(p: PlayerObject) -> int: return p.player_score)
return Settings.player_array.map(func(p: PlayerObject) -> int: return p.player_score)
+153 -153
View File
@@ -9,131 +9,131 @@ extends RefCounted
## them a node lives in.
const SOUNDTRACKS: Array[String] = [
"Chrono Trigger", "Final Fantasy VI", "Secret of Mana", "Terranigma",
"Earthbound", "Super Metroid", "The Legend of Zelda: A Link to the Past",
"Donkey Kong Country 2", "Lufia II", "Illusion of Gaia",
"Chrono Trigger", "Final Fantasy VI", "Secret of Mana", "Terranigma",
"Earthbound", "Super Metroid", "The Legend of Zelda: A Link to the Past",
"Donkey Kong Country 2", "Lufia II", "Illusion of Gaia",
]
const SONG_INFO: Dictionary = {
"SongNo": 0, "Soundtrack": "Chrono Trigger", "Song": "Corridors of Time",
"SongNo": 0, "Soundtrack": "Chrono Trigger", "Song": "Corridors of Time",
}
const SYNC_PROGRESS: Dictionary = {"progress": 40, "time_spent": "00:00:02"}
const SYNC_RESULT: Dictionary = {
"soundtracks_added": ["Terranigma", "Lufia II"],
"soundtracks_re_added": [],
"soundtracks_changed_title": {"FF6": "Final Fantasy VI"},
"soundtracks_changed_content": ["Chrono Trigger"],
"soundtracks_removed": ["Old Soundtrack"],
"catched_errors": [],
"total_time": "00:00:03",
"soundtracks_added": ["Terranigma", "Lufia II"],
"soundtracks_re_added": [],
"soundtracks_changed_title": {"FF6": "Final Fantasy VI"},
"soundtracks_changed_content": ["Chrono Trigger"],
"soundtracks_removed": ["Old Soundtrack"],
"catched_errors": [],
"total_time": "00:00:03",
}
## Popups in the order the tour opens them.
const POPUPS: Array[String] = [
"Search", "SyncWindow", "SettingsWindow", "QRWindow", "NewCharacterSelect",
"ShortcutsWindow", "AboutWindow", "WinnerWindow", "Log", "StatisticsPopupPanel",
"Search", "SyncWindow", "SettingsWindow", "QRWindow", "NewCharacterSelect",
"ShortcutsWindow", "AboutWindow", "WinnerWindow", "Log", "StatisticsPopupPanel",
]
var _main: Control
func _init(main: Control) -> void:
_main = main
_main = main
## Returns a fake server that answers every request the main window makes on the tour.
## Call [method FakeHttpTransport.install] before the main window is created.
static func make_server() -> FakeHttpTransport:
var server: FakeHttpTransport = FakeHttpTransport.new()
var mp3: PackedByteArray = FileAccess.get_file_as_bytes("res://tests/data/short.mp3")
server.respond_json("/music/all", SOUNDTRACKS)
server.respond_json("/music/all/order", SOUNDTRACKS)
server.respond_json("/music/list", [])
server.respond_json("/characters", [])
server.respond_bytes("/music/rand", mp3)
server.respond_bytes("/music/addQue", PackedByteArray())
server.respond_json("/music/info", SONG_INFO)
server.respond_bytes("/music/reset", PackedByteArray())
server.respond_bytes("/music/played?song=0", PackedByteArray())
server.respond_bytes("/sync", PackedByteArray())
server.respond_json("/sync/progress", SYNC_PROGRESS)
return server
var server: FakeHttpTransport = FakeHttpTransport.new()
var mp3: PackedByteArray = FileAccess.get_file_as_bytes("res://tests/data/short.mp3")
server.respond_json("/music/all", SOUNDTRACKS)
server.respond_json("/music/all/order", SOUNDTRACKS)
server.respond_json("/music/list", [])
server.respond_json("/characters", [])
server.respond_bytes("/music/rand", mp3)
server.respond_bytes("/music/addQue", PackedByteArray())
server.respond_json("/music/info", SONG_INFO)
server.respond_bytes("/music/reset", PackedByteArray())
server.respond_bytes("/music/played?song=0", PackedByteArray())
server.respond_bytes("/sync", PackedByteArray())
server.respond_json("/sync/progress", SYNC_PROGRESS)
return server
## Puts Settings and Playlist in the state the tour expects. Call it before the main
## window is created.
static func prepare_autoloads() -> void:
Playlist.reset_playlist()
Playlist.first_song_played = false
Playlist.is_song_downloading = false
Settings.player_array.clear()
Settings.edit_players = false
Settings.currently_syncing = false
Settings.character_select_open = false
Settings.add_to_stats = true
Settings.hide_next_track = true
Settings.use_low_played_mode = false
Settings.winning_score = 20
# The inspiration list scrolls by itself, which would make every picture different
Settings.inspiration_list_speed = 0
Playlist.reset_playlist()
Playlist.first_song_played = false
Playlist.is_song_downloading = false
Settings.player_array.clear()
Settings.edit_players = false
Settings.currently_syncing = false
Settings.character_select_open = false
Settings.add_to_stats = true
Settings.hide_next_track = true
Settings.use_low_played_mode = false
Settings.winning_score = 20
# The inspiration list scrolls by itself, which would make every picture different
Settings.inspiration_list_speed = 0
## Runs the tour. [param on_state] is called (and awaited) with the name of each state
## and the popup that is open in it, or [code]null[/code] when no popup is open.
func run(on_state: Callable) -> void:
# The debug build lowers the winning score on startup; keep it out of reach
Settings.winning_score = 20
await _settle()
await on_state.call("startup", null)
# The debug build lowers the winning score on startup; keep it out of reach
Settings.winning_score = 20
await _settle()
await on_state.call("startup", null)
_call("add_players")
await _settle()
await on_state.call("add_player_row", null)
_call("add_players")
await _settle()
await on_state.call("add_player_row", null)
_add_player("Crono")
_add_player("Marle")
_call("add_players")
await _settle()
await on_state.call("players_added", null)
_add_player("Crono")
_add_player("Marle")
_call("add_players")
await _settle()
await on_state.call("players_added", null)
_call("play_next_song")
await _settle()
_freeze_music_player()
_player_row(0).add_point()
_player_row(0).add_point()
_player_row(1).add_point()
_call("show_answer_pressed")
await _settle()
_freeze_music_player()
_fix_log_times()
await _settle()
await on_state.call("playing", null)
_call("play_next_song")
await _settle()
_freeze_music_player()
_player_row(0).add_point()
_player_row(0).add_point()
_player_row(1).add_point()
_call("show_answer_pressed")
await _settle()
_freeze_music_player()
_fix_log_times()
await _settle()
await on_state.call("playing", null)
for popup_name: String in POPUPS:
var popup: Node = await _open_popup(popup_name)
await _settle()
await on_state.call("popup_" + popup_name, popup)
_close_popup(popup)
await _settle()
for popup_name: String in POPUPS:
var popup: Node = await _open_popup(popup_name)
await _settle()
await on_state.call("popup_" + popup_name, popup)
_close_popup(popup)
await _settle()
var sync_window: PopupWindow = _node("SyncWindow")
Settings.currently_syncing = false
sync_window.has_synced = false
sync_window.start_sync()
sync_window.sync_timer.stop()
sync_window._on_sync_timeout()
await _settle()
await on_state.call("sync_in_progress", sync_window)
sync_window.close()
await _settle()
await on_state.call("sync_buttons_locked", null)
var sync_window: PopupWindow = _node("SyncWindow")
Settings.currently_syncing = false
sync_window.has_synced = false
sync_window.start_sync()
sync_window.sync_timer.stop()
sync_window._on_sync_timeout()
await _settle()
await on_state.call("sync_in_progress", sync_window)
sync_window.close()
await _settle()
await on_state.call("sync_buttons_locked", null)
_server().respond_json("/sync/progress", SYNC_RESULT)
sync_window._on_sync_timeout()
sync_window.open()
await _settle()
await on_state.call("sync_result", sync_window)
sync_window.close()
await _settle()
_server().respond_json("/sync/progress", SYNC_RESULT)
sync_window._on_sync_timeout()
sync_window.open()
await _settle()
await on_state.call("sync_result", sync_window)
sync_window.close()
await _settle()
## Returns where every Control and Window in [param subtree] is on screen, keyed by its
@@ -141,109 +141,109 @@ func run(on_state: Callable) -> void:
## Nodes added at runtime without a name are keyed by their index, e.g. [code]#2[/code],
## so the keys are the same on every run.
static func dump_layout(main: Node, subtree: Node) -> Dictionary:
var layout: Dictionary = {}
var path: String = String(main.get_path_to(subtree))
_dump_node(subtree, path, layout)
return layout
var layout: Dictionary = {}
var path: String = String(main.get_path_to(subtree))
_dump_node(subtree, path, layout)
return layout
static func _dump_node(node: Node, path: String, layout: Dictionary) -> void:
if node is Control:
var rect: Rect2 = (node as Control).get_global_rect()
layout[path] = {"rect": _round_rect(rect), "visible": node.is_visible_in_tree()}
elif node is Window:
var window: Window = node
layout[path] = {
"rect": _round_rect(Rect2(window.position, window.size)),
"visible": window.visible,
}
for child: Node in node.get_children():
var key: String = "#%d" % child.get_index() if "@" in child.name \
else String(child.name)
_dump_node(child, key if path == "." else path + "/" + key, layout)
if node is Control:
var rect: Rect2 = (node as Control).get_global_rect()
layout[path] = {"rect": _round_rect(rect), "visible": node.is_visible_in_tree()}
elif node is Window:
var window: Window = node
layout[path] = {
"rect": _round_rect(Rect2(window.position, window.size)),
"visible": window.visible,
}
for child: Node in node.get_children():
var key: String = "#%d" % child.get_index() if "@" in child.name \
else String(child.name)
_dump_node(child, key if path == "." else path + "/" + key, layout)
static func _round_rect(rect: Rect2) -> Array[float]:
return [snappedf(rect.position.x, 0.01), snappedf(rect.position.y, 0.01),
snappedf(rect.size.x, 0.01), snappedf(rect.size.y, 0.01)]
return [snappedf(rect.position.x, 0.01), snappedf(rect.position.y, 0.01),
snappedf(rect.size.x, 0.01), snappedf(rect.size.y, 0.01)]
## Finds a node of the main window by [param node_name], whether it is a direct child
## of the main window or of its Quiz or TopBar scene.
func _node(node_name: String) -> Node:
for parent: Node in [_main, _main.get_node_or_null("Quiz"),
_main.get_node_or_null("TopBar")]:
if parent != null && parent.has_node(node_name):
return parent.get_node(node_name)
push_error("UiTour: no node named " + node_name)
return null
for parent: Node in [_main, _main.get_node_or_null("Quiz"),
_main.get_node_or_null("TopBar")]:
if parent != null && parent.has_node(node_name):
return parent.get_node(node_name)
push_error("UiTour: no node named " + node_name)
return null
## Calls [param method] on the players panel, the quiz or the main window, whichever
## has it first.
func _call(method: String, args: Array = []) -> Variant:
for path: String in ["Quiz/PlayersPanel", "Quiz"]:
var target: Node = _main.get_node_or_null(path)
if target != null && target.has_method(method):
return target.callv(method, args)
return _main.callv(method, args)
for path: String in ["Quiz/PlayersPanel", "Quiz"]:
var target: Node = _main.get_node_or_null(path)
if target != null && target.has_method(method):
return target.callv(method, args)
return _main.callv(method, args)
func _server() -> FakeHttpTransport:
return MusicServerClient.transport
return MusicServerClient.transport
func _settle() -> void:
for i: int in 4:
await _main.get_tree().process_frame
for i: int in 4:
await _main.get_tree().process_frame
func _add_player(player_name: String) -> void:
(_node("PlayersPanel").get_node("VBoxContainer/AddPlayerContainer/PlayerNameField") \
as TextEdit).text = player_name
_call("add_player")
(_node("PlayersPanel").get_node("VBoxContainer/AddPlayerContainer/PlayerNameField") \
as TextEdit).text = player_name
_call("add_player")
func _player_row(index: int) -> Player:
return _node("PlayersPanel").get_node(
"VBoxContainer/ScrollContainer/PlayersListVBoxContainer").get_child(index)
return _node("PlayersPanel").get_node(
"VBoxContainer/ScrollContainer/PlayersListVBoxContainer").get_child(index)
## Stops the song so the time and progress bar look the same on every run.
func _freeze_music_player() -> void:
var music_player: MusicPlayer = _node("MusicPlayer")
music_player.audio_player.stop()
music_player.sound_player.stop()
music_player.progress_slider.value = 0
music_player.music_time_label.text = "00:00 / 00:01"
var music_player: MusicPlayer = _node("MusicPlayer")
music_player.audio_player.stop()
music_player.sound_player.stop()
music_player.progress_slider.value = 0
music_player.music_time_label.text = "00:00 / 00:01"
## The log starts each row with the time of day; use a fixed time instead.
func _fix_log_times() -> void:
var log_window: PopupWindow = _node("Log")
for row: Label in log_window.log_box.get_children():
row.text = "12:00:00 " + row.text.substr(9)
var log_window: PopupWindow = _node("Log")
for row: Label in log_window.log_box.get_children():
row.text = "12:00:00 " + row.text.substr(9)
func _open_popup(popup_name: String) -> Node:
var popup: Node = _node(popup_name)
match popup_name:
"SyncWindow":
# Opening the window starts a sync; show the empty window instead
popup.open()
"NewCharacterSelect":
popup.show_grid("Crono")
"WinnerWindow":
popup.show_winner(Settings.player_array[0])
"StatisticsPopupPanel":
_call("get_statistics")
_:
popup.open()
return popup
var popup: Node = _node(popup_name)
match popup_name:
"SyncWindow":
# Opening the window starts a sync; show the empty window instead
popup.open()
"NewCharacterSelect":
popup.show_grid("Crono")
"WinnerWindow":
popup.show_winner(Settings.player_array[0])
"StatisticsPopupPanel":
_call("get_statistics")
_:
popup.open()
return popup
func _close_popup(popup: Node) -> void:
if popup is PopupWindow:
popup.close()
else:
popup.visible = false
if popup is PopupWindow:
popup.close()
else:
popup.visible = false