Files
MusicPlayer/shortcuts_window.gd
T
Sansan c7d49bc5cc Rework popups and fix blurry text and player list layout
Popups:
- All nine popups now extend a shared PopupWindow class with open(),
  close() and toggle(), instead of each copying its own close-on-click
  code. Popups that need cleanup override close().
- A click outside a popup closed it and also pressed whatever was
  underneath, e.g. Reset playlist. The closing click is now consumed.
- Popups used Godot's see-through default panel, so the song list and
  titles showed through. They now use an opaque popup theme, and a
  backdrop dims the window behind them.
- The main window root now fills the screen, so the backdrop covers it.

Text and images:
- Many labels and buttons forced nearest filtering, which made text and
  icons jagged when the window is not 1920x1080. They now use the
  default smooth filtering. Only the pixel-art "no character" picture
  keeps nearest filtering when the winner window enlarges it.

Player list:
- A long player name pushed that row's character and buttons to the
  right. Names now take the free space and shorten with an ellipsis, so
  all rows line up and use the full width of the panel.
2026-10-06 08:32:56 +02:00

74 lines
2.3 KiB
GDScript

extends PopupWindow
@onready
var shortcuts_vbox: VBoxContainer = %shortcutsVBox
@onready
var shortcuts_panel: Panel = %ShortcutsPanel
var shortcuts_dic: Dictionary = {
"Alt + S": "Search",
"Alt + A": "Add Players",
"Alt + Z": "Reset",
"Alt + X": "Play/Pause",
"Alt + C": "Next Song",
"Alt + V": "Show Answer",
"Alt + L": "Show Debug Log",
"Alt + K": "Show shortcuts",
"Alt + Enter": "Fullscreen",
"Alt + UP": "Volume up",
"Alt + DOWN": "Volume down",
"Alt + LEFT": "Jump back in song",
"Alt + Ctrl + LEFT": "Restart song",
"Alt + RIGHT": "Jump forward in song",
"Alt + 1 - 9": "Give player point",
"Alt + Ctrl + 1 - 9": "Take point from player",
}
#Color(0.18, 0.18, 0.18)
#Color(0.302, 0.302, 0.302)
#Color(0.259, 0.259, 0.259)
func _ready() -> void:
shortcuts_dic.sort()
Settings.delete_children(shortcuts_vbox)
var title: Label = Label.new()
title.add_theme_font_size_override("font_size", 20)
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
title.text = "Shortcuts"
shortcuts_vbox.add_child(title)
var count: int = 0
for shortcut: String in shortcuts_dic.keys():
var panel: PanelContainer = PanelContainer.new()
var hbox: HBoxContainer = HBoxContainer.new()
hbox.alignment = BoxContainer.ALIGNMENT_CENTER
var label: Label = Label.new()
label.add_theme_font_size_override("font_size", 20)
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.text = shortcut
label.autowrap_mode = TextServer.AUTOWRAP_WORD
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
var label2: Label = Label.new()
label2.add_theme_font_size_override("font_size", 20)
label2.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label2.text = shortcuts_dic[shortcut]
label2.autowrap_mode = TextServer.AUTOWRAP_WORD
label2.size_flags_horizontal = Control.SIZE_EXPAND_FILL
if count % 2 == 0:
var new_stylebox_normal: Resource = panel.get_theme_stylebox("panel").duplicate()
new_stylebox_normal.bg_color = Color(0.18, 0.18, 0.18)
panel.add_theme_stylebox_override("panel", new_stylebox_normal)
#label.add_theme_stylebox_override("normal", new_stylebox_normal)
#label2.add_theme_stylebox_override("normal", new_stylebox_normal)
hbox.add_child(label)
hbox.add_child(label2)
panel.add_child(hbox)
shortcuts_vbox.add_child(panel)
count += 1