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.
38 lines
1.0 KiB
GDScript
38 lines
1.0 KiB
GDScript
class_name PopupWindow
|
|
extends Control
|
|
## A window shown on top of the main window, such as Settings or About.
|
|
##
|
|
## Clicking outside [member panel] closes it. Popups that need to prepare or clean up
|
|
## override [method open] or [method close] and call [code]super()[/code].
|
|
|
|
## The visible part of the popup. Clicks outside it close the popup.
|
|
@export var panel: Control
|
|
|
|
|
|
## Shows the popup.
|
|
func open() -> void:
|
|
visible = true
|
|
|
|
|
|
## Hides the popup.
|
|
func close() -> void:
|
|
visible = false
|
|
|
|
|
|
## Opens the popup if it is closed and closes it if it is open.
|
|
func toggle() -> void:
|
|
if visible:
|
|
close()
|
|
else:
|
|
open()
|
|
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
if !visible || !(event is InputEventMouseButton) || !event.pressed:
|
|
return
|
|
var click: InputEventMouseButton = panel.make_input_local(event)
|
|
if !Rect2(Vector2.ZERO, panel.size).has_point(click.position):
|
|
close()
|
|
# The click only closes the popup; it must not also press what is behind it
|
|
get_viewport().set_input_as_handled()
|