diff --git a/MainWindow.gd b/MainWindow.gd index 37ab2a9..1d98926 100644 --- a/MainWindow.gd +++ b/MainWindow.gd @@ -25,6 +25,9 @@ var qr_window: Control = %QRWindow @onready var about_window: Control = %AboutWindow +@onready +var log_window: Control = %Log + @onready var statistic_popup: PopupPanel = $StatisticsPopupPanel @@ -49,6 +52,7 @@ func _ready() -> void: sync_window.connect("sync_started", _on_sync_started) sync_window.connect("sync_finished", _on_sync_finished) quiz.server_changed.connect(search_view.get_list_of_soundtracks) + quiz.event_logged.connect(log_window.add_log_row) search_view.get_list_of_soundtracks() @@ -64,10 +68,12 @@ func _input(event: InputEvent) -> void: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) if event.alt_pressed && event.keycode == KEY_K: shortcuts_window.toggle() + if event.alt_pressed && event.keycode == KEY_L: + log_window.toggle() func _popups() -> Array[PopupWindow]: - return [search_view, sync_window, qr_window, shortcuts_window, about_window] + return [search_view, sync_window, qr_window, shortcuts_window, about_window, log_window] func show_search() -> void: diff --git a/MainWindow.tscn b/MainWindow.tscn index f8a444c..7da3a87 100644 --- a/MainWindow.tscn +++ b/MainWindow.tscn @@ -9,6 +9,7 @@ [ext_resource type="PackedScene" uid="uid://btupbowehiyyu" path="res://QRWindow.tscn" id="15_qr_window"] [ext_resource type="PackedScene" uid="uid://cp54idaudb8dp" path="res://AboutWindow.tscn" id="16_about_window"] [ext_resource type="Theme" path="res://popup_theme.tres" id="popup_theme"] +[ext_resource type="PackedScene" uid="uid://bijh5h5yrivm3" path="res://Log.tscn" id="14_26rwn"] [node name="Control" type="Control" unique_id=407149696] layout_mode = 3 @@ -90,3 +91,11 @@ offset_top = 153.0 offset_right = 720.0 offset_bottom = 153.0 +[node name="Log" parent="." unique_id=1289881388 instance=ExtResource("14_26rwn")] +unique_name_in_owner = true +visible = false +layout_mode = 1 +offset_left = 562.0 +offset_top = 132.0 +offset_right = 1262.0 +offset_bottom = 832.0 diff --git a/Quiz.tscn b/Quiz.tscn index b579cef..ef9d3a3 100644 --- a/Quiz.tscn +++ b/Quiz.tscn @@ -4,7 +4,6 @@ [ext_resource type="PackedScene" uid="uid://ds15cgsf8vpvc" path="res://MusicPlayer.tscn" id="5_emn36"] [ext_resource type="PackedScene" uid="uid://cdy4kvemwaiom" path="res://new_character_select.tscn" id="6_dhrvg"] [ext_resource type="PackedScene" uid="uid://dldpeo5y3l5hq" path="res://SettingsWindow.tscn" id="11_k62u5"] -[ext_resource type="PackedScene" uid="uid://bijh5h5yrivm3" path="res://Log.tscn" id="14_26rwn"] [ext_resource type="PackedScene" uid="uid://cxlsmxnrp0agh" path="res://WinnerWindow.tscn" id="17_winner_window"] [ext_resource type="PackedScene" path="res://MusicListPanel.tscn" id="scene_MusicListPanel"] [ext_resource type="PackedScene" path="res://PlayersPanel.tscn" id="scene_PlayersPanel"] @@ -130,15 +129,6 @@ horizontal_alignment = 1 vertical_alignment = 1 autowrap_mode = 2 -[node name="Log" parent="." unique_id=1289881388 instance=ExtResource("14_26rwn")] -unique_name_in_owner = true -visible = false -layout_mode = 1 -offset_left = 562.0 -offset_top = 132.0 -offset_right = 1262.0 -offset_bottom = 832.0 - [node name="SongLoader" type="Node" parent="." unique_id=1520867349] script = ExtResource("song_loader_script") diff --git a/quiz.gd b/quiz.gd index e0588d9..770625c 100644 --- a/quiz.gd +++ b/quiz.gd @@ -11,6 +11,9 @@ extends Control ## reloaded from it. signal server_changed +## Emitted with a line for the game log, e.g. when a player gets a point. +signal event_logged(text: String) + @onready var open_button: Button = $Open @@ -50,9 +53,6 @@ var new_character_select: Control = %NewCharacterSelect @onready var music_player_container: MusicPlayer = $MusicPlayer -@onready -var log_window: Control = %Log - @onready var debug_label: Label = $DebugLabel @@ -117,8 +117,6 @@ func _input(event: InputEvent) -> void: if event.alt_pressed && event.keycode == KEY_RIGHT: print("Alt + RIGHT pressed") music_player_container.seek(5) - if event.alt_pressed && event.keycode == KEY_L: - log_window.toggle() ## Disables the buttons that use the song list while the server syncs it. @@ -168,7 +166,7 @@ func play_next_song() -> void: func _popups() -> Array[PopupWindow]: - return [settings_window, new_character_select, winner_window, log_window] + return [settings_window, new_character_select, winner_window] # The cache size can be changed in the settings. Waiting until the settings are closed @@ -245,7 +243,7 @@ func _on_player_added(new_player_object: PlayerObject) -> void: func _on_point_given(player_object: PlayerObject) -> void: print("_on_point_given") - log_window.add_log_row(player_object.player_name + " got a point") + event_logged.emit(player_object.player_name + " got a point") if Playlist.currently_playing_song >= 0: Playlist.add_point(player_object.id) update_song_list() @@ -257,7 +255,7 @@ func _on_make_point_given_sound() -> void: func _on_point_taken(player_object: PlayerObject) -> void: print("_on_point_taken") - log_window.add_log_row(player_object.player_name + " lost a point") + event_logged.emit(player_object.player_name + " lost a point") music_player_container.play_sound_effect(preload("res://sounds/itemequip.wav")) if Playlist.currently_playing_song >= 0: Playlist.remove_point(player_object.id) diff --git a/tests/integration/test_layout_unchanged.gd b/tests/integration/test_layout_unchanged.gd index 1b8411c..d32b580 100644 --- a/tests/integration/test_layout_unchanged.gd +++ b/tests/integration/test_layout_unchanged.gd @@ -13,7 +13,7 @@ const BASELINE_PATH: String = "res://tests/data/layout_baseline.json" ## Nodes that moved from the main window into the Quiz scene, by their old name. const QUIZ_NODES: Array[String] = [ "Open", "FileDialog", "MusicListPanel", "DebugLabel", "SettingsWindow", - "NewCharacterSelect", "WinnerWindow", "Log", + "NewCharacterSelect", "WinnerWindow", ] ## Nodes that moved into the Quiz scene under another path: old name to new path in diff --git a/tests/integration/test_main_window.gd b/tests/integration/test_main_window.gd index 82d23ab..a11a4ab 100644 --- a/tests/integration/test_main_window.gd +++ b/tests/integration/test_main_window.gd @@ -229,7 +229,7 @@ func test_show_answer_before_first_song_does_not_reveal_next_song() -> void: func test_log_adds_one_row_per_point_with_padded_time() -> void: - var log_box: VBoxContainer = _quiz.get_node("%Log").get_node("%LogVBoxContainer") + var log_box: VBoxContainer = _window.get_node("%Log").get_node("%LogVBoxContainer") var crono: PlayerObject = _add_player("Crono") await _play_first_song() diff --git a/tests/integration/test_popups.gd b/tests/integration/test_popups.gd index ad0ae80..eee13fc 100644 --- a/tests/integration/test_popups.gd +++ b/tests/integration/test_popups.gd @@ -3,14 +3,14 @@ extends MainWindowTestSuite ## dims the window behind them, and the closing click does not reach the main window. ## The main window and the quiz each have their own popups and their own backdrop. -## Popups opened from the top bar, in the main window. +## Popups in the main window: the ones opened from the top bar, and the log. const MAIN_POPUPS: Array[String] = [ - "Search", "SyncWindow", "QRWindow", "ShortcutsWindow", "AboutWindow", + "Search", "SyncWindow", "QRWindow", "ShortcutsWindow", "AboutWindow", "Log", ] ## Popups opened from the quiz, in the Quiz scene. const QUIZ_POPUPS: Array[String] = [ - "SettingsWindow", "NewCharacterSelect", "WinnerWindow", "Log", + "SettingsWindow", "NewCharacterSelect", "WinnerWindow", ] diff --git a/tests/integration/test_scene_split.gd b/tests/integration/test_scene_split.gd index 6e61f5b..4af5b24 100644 --- a/tests/integration/test_scene_split.gd +++ b/tests/integration/test_scene_split.gd @@ -6,7 +6,7 @@ extends MainWindowTestSuite const MAIN_WINDOW_CHILDREN: Array[String] = [ "TopBar", "Quiz", "PopupBackdrop", "Search", "SyncWindow", "QRWindow", - "ShortcutsWindow", "StatisticsPopupPanel", "AboutWindow", + "ShortcutsWindow", "StatisticsPopupPanel", "AboutWindow", "Log", ] const TOP_BAR_CHILDREN: Array[String] = [ @@ -130,7 +130,7 @@ func test_points_from_the_player_list_reach_the_song_and_log() -> void: (_player_row(crono).get_node("HBoxContainer/AddPoint") as BaseButton).pressed.emit() assert_array(Playlist.song_object_array[0].players_given_point).contains_exactly([crono.id]) - assert_int((_quiz.get_node("%Log").get_node("%LogVBoxContainer") as Node).get_child_count()) \ + assert_int((_window.get_node("%Log").get_node("%LogVBoxContainer") as Node).get_child_count()) \ .is_equal(1) @@ -242,7 +242,7 @@ func test_alt_k_opens_shortcuts_and_alt_l_opens_log() -> void: assert_bool((_window.get_node("ShortcutsWindow") as Control).visible).is_true() await _press_keys([KEY_ALT, KEY_L]) - assert_bool((_quiz.get_node("Log") as Control).visible).is_true() + assert_bool((_window.get_node("Log") as Control).visible).is_true() func test_alt_down_lowers_the_volume() -> void: