Name popups *Popup and give scripts, scenes and classes matching names
Every popup is now called *Popup instead of *Window in its file, root node, node name, class and variable, and PopupWindow becomes BasePopup. Player is PlayerRow, SongListObject is SongRow and Character is CharacterCard. Script files are snake_case and scene files PascalCase, each matching its class or root node, and LightGrayTheme.tres is light_gray_theme.tres.
This commit is contained in:
1 parent
b7d67b573e
commit
390da577d7
78 files changed
+281
-258
No files matched your search
+121
@@ -0,0 +1,121 @@
|
||||
class_name MainWindow
|
||||
extends Control
|
||||
## The main window: the top bar, the popups opened from it and the quiz below it.
|
||||
##
|
||||
## Everything that is not part of a quiz lives here, so other views can be added next
|
||||
## to the quiz later.
|
||||
|
||||
@onready
|
||||
var top_bar: TopBar = $TopBar
|
||||
|
||||
@onready
|
||||
var quiz: Quiz = $Quiz
|
||||
|
||||
@onready
|
||||
var search_popup: SearchPopup = $SearchPopup
|
||||
|
||||
@onready
|
||||
var sync_popup: SyncPopup = %SyncPopup
|
||||
|
||||
@onready
|
||||
var shortcuts_popup: ShortcutsPopup = %ShortcutsPopup
|
||||
|
||||
@onready
|
||||
var qr_popup: QRPopup = %QRPopup
|
||||
|
||||
@onready
|
||||
var about_popup: AboutPopup = %AboutPopup
|
||||
|
||||
@onready
|
||||
var log_popup: LogPopup = %LogPopup
|
||||
|
||||
@onready
|
||||
var statistic_popup: PopupPanel = $StatisticsPopupPanel
|
||||
|
||||
@onready
|
||||
var statistic_label: Label = $StatisticsPopupPanel/StatisticsLabel
|
||||
|
||||
## Dims the window behind an open popup and keeps clicks from reaching the buttons under it.
|
||||
var popup_backdrop: PopupBackdrop
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
popup_backdrop = PopupBackdrop.add_to(self, _popups())
|
||||
if OS.has_feature("macos"):
|
||||
GameLog.debug("is_mac")
|
||||
top_bar.search_pressed.connect(show_search)
|
||||
top_bar.sync_pressed.connect(sync_soundtracks)
|
||||
top_bar.statistics_pressed.connect(get_statistics)
|
||||
top_bar.shortcuts_pressed.connect(show_shortcuts)
|
||||
top_bar.about_pressed.connect(show_about)
|
||||
top_bar.qr_pressed.connect(show_qr)
|
||||
|
||||
sync_popup.connect("sync_started", _on_sync_started)
|
||||
sync_popup.connect("sync_finished", _on_sync_finished)
|
||||
quiz.server_changed.connect(search_popup.get_list_of_soundtracks)
|
||||
quiz.event_logged.connect(log_popup.add_log_row)
|
||||
|
||||
search_popup.get_list_of_soundtracks()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.alt_pressed && event.keycode == KEY_ENTER:
|
||||
GameLog.debug("Alt + Enter pressed")
|
||||
Settings.fullscreen = !Settings.fullscreen
|
||||
if Settings.fullscreen == true:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
if Settings.fullscreen == false:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
||||
if event.alt_pressed && event.keycode == KEY_K:
|
||||
shortcuts_popup.toggle()
|
||||
if event.alt_pressed && event.keycode == KEY_L:
|
||||
log_popup.toggle()
|
||||
|
||||
|
||||
func _popups() -> Array[BasePopup]:
|
||||
return [search_popup, sync_popup, qr_popup, shortcuts_popup, about_popup, log_popup]
|
||||
|
||||
|
||||
func show_search() -> void:
|
||||
GameLog.debug("show_search")
|
||||
search_popup.toggle()
|
||||
|
||||
|
||||
func show_about() -> void:
|
||||
GameLog.debug("show_about")
|
||||
about_popup.open()
|
||||
|
||||
|
||||
func show_shortcuts() -> void:
|
||||
GameLog.debug("show_shortcuts")
|
||||
shortcuts_popup.open()
|
||||
|
||||
|
||||
func show_qr() -> void:
|
||||
GameLog.debug("show_qr")
|
||||
qr_popup.open()
|
||||
|
||||
|
||||
func get_statistics() -> void:
|
||||
GameLog.debug("get_statistics")
|
||||
statistic_popup.visible = true
|
||||
statistic_label.text = "Total amount of soundtracks in the playlist: " \
|
||||
+ str(search_popup.soundtracks.size())
|
||||
|
||||
|
||||
func sync_soundtracks() -> void:
|
||||
GameLog.debug("sync_soundtracks")
|
||||
sync_popup.start_sync()
|
||||
|
||||
|
||||
func _on_sync_started() -> void:
|
||||
GameLog.debug("_on_sync_started")
|
||||
top_bar.sync_button.disabled = false
|
||||
quiz.lock_for_sync()
|
||||
|
||||
|
||||
func _on_sync_finished() -> void:
|
||||
GameLog.debug("_on_sync_finished")
|
||||
search_popup.get_list_of_soundtracks()
|
||||
quiz.on_sync_finished()
|
||||
Reference in new issue
Block a user