Fix and tidy the Character select, Shortcuts, Log and QR popups
Character select
- A card only picks its character when it is clicked. Before, every card
watched every click, so clicking below the panel could pick a card
scrolled out of view there.
- Six columns of fixed-size cards that scroll for any number of
characters, with a gap between the cards and the scrollbar.
- Pictures are read as PNG, JPG or WebP by their first bytes, so JPGs no
longer print an error. Names are split into words ("Paper Mario") and
the card under the mouse is highlighted.
Shortcuts
- Alt+Z restarts the song; it was listed as "Reset".
- Grouped by what the keys do, in sentence case, and the panel fits the
list. A test checks that every button shortcut is listed.
Log
- Scrolls to the newest row, alternates row colours and says "Nothing
has happened yet" when empty.
QR
- A title, and the code is set up in one place.
This commit is contained in:
1 parent
b2d547b650
commit
8d21b0617d
23 files changed
+4694
-5349
No files matched your search
+62
-48
@@ -1,65 +1,79 @@
|
||||
class_name ShortcutsPopup
|
||||
extends BasePopup
|
||||
## Lists the keyboard shortcuts. Opened with Alt+K or the Shortcuts button.
|
||||
## Lists the keyboard shortcuts, grouped by what they do. Opened with Alt+K or the
|
||||
## Shortcuts button.
|
||||
|
||||
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",
|
||||
}
|
||||
## Each group's heading and its shortcuts, as [code][keys, what they do][/code].
|
||||
## [code]tests/integration/test_shortcuts_popup.gd[/code] checks that every button
|
||||
## shortcut in the game is here with the right keys.
|
||||
const SHORTCUTS: Array = [
|
||||
["Players and points", [
|
||||
["Alt + 1–9", "Give a player a point"],
|
||||
["Alt + Ctrl + 1–9", "Take a point from a player"],
|
||||
["Alt + A", "Add players"],
|
||||
]],
|
||||
["Songs", [
|
||||
["Alt + C", "Next song"],
|
||||
["Alt + V", "Show answer"],
|
||||
["Alt + X", "Play or pause"],
|
||||
["Alt + Z", "Restart song"],
|
||||
["Alt + Ctrl + Left", "Restart song"],
|
||||
["Alt + Left", "Jump back 5 seconds"],
|
||||
["Alt + Right", "Jump forward 5 seconds"],
|
||||
["Alt + Up", "Volume up"],
|
||||
["Alt + Down", "Volume down"],
|
||||
]],
|
||||
["Windows", [
|
||||
["Alt + S", "Search"],
|
||||
["Alt + K", "Shortcuts"],
|
||||
["Alt + L", "Log"],
|
||||
["Alt + Enter", "Fullscreen"],
|
||||
]],
|
||||
]
|
||||
|
||||
## Space above each group but the first.
|
||||
const GROUP_GAP: Vector2 = Vector2(0, 8)
|
||||
|
||||
@onready var shortcuts_vbox: VBoxContainer = %shortcutsVBox
|
||||
@onready var shortcuts_panel: Panel = %ShortcutsPanel
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
shortcuts_dic.sort()
|
||||
Settings.delete_children(shortcuts_vbox)
|
||||
for group: Array in SHORTCUTS:
|
||||
if shortcuts_vbox.get_child_count() > 0:
|
||||
var gap: Control = Control.new()
|
||||
gap.custom_minimum_size = GROUP_GAP
|
||||
shortcuts_vbox.add_child(gap)
|
||||
var heading: Label = Label.new()
|
||||
heading.theme_type_variation = &"HighlightLarge"
|
||||
heading.text = group[0]
|
||||
shortcuts_vbox.add_child(heading)
|
||||
var row: int = 0
|
||||
for shortcut: Array in group[1]:
|
||||
shortcuts_vbox.add_child(_make_row(shortcut[0], shortcut[1], row))
|
||||
row += 1
|
||||
|
||||
var title: Label = Label.new()
|
||||
title.theme_type_variation = &"TextLarge"
|
||||
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
|
||||
## Every key combination in the list, e.g. "Alt + C".
|
||||
static func listed_keys() -> Array[String]:
|
||||
var keys: Array[String] = []
|
||||
for group: Array in SHORTCUTS:
|
||||
for shortcut: Array in group[1]:
|
||||
keys.append(shortcut[0])
|
||||
return keys
|
||||
|
||||
|
||||
func _make_row(keys: String, action: String, row: int) -> PanelContainer:
|
||||
var panel: PanelContainer = PanelContainer.new()
|
||||
if row % 2 == 0:
|
||||
panel.theme_type_variation = &"ShortcutRowDark"
|
||||
var hbox: HBoxContainer = HBoxContainer.new()
|
||||
for text: String in [keys, action]:
|
||||
var label: Label = Label.new()
|
||||
label.theme_type_variation = &"TextLarge"
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.text = shortcut
|
||||
label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
label.text = text
|
||||
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
|
||||
var label2: Label = Label.new()
|
||||
label2.theme_type_variation = &"TextLarge"
|
||||
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:
|
||||
panel.theme_type_variation = &"ShortcutRowDark"
|
||||
|
||||
hbox.add_child(label)
|
||||
hbox.add_child(label2)
|
||||
panel.add_child(hbox)
|
||||
shortcuts_vbox.add_child(panel)
|
||||
count += 1
|
||||
panel.add_child(hbox)
|
||||
return panel
|
||||
Reference in new issue
Block a user