themes/main_theme.tres is the project theme. It holds Godot's default look for every control type the game uses, plus named styles for the game's own look (popups, the background, spacers, list rows, title and text sizes, highlights) and a palette for the popup dimming. Scenes and scripts name these styles instead of setting colours, sizes or style boxes, and the five old theme files are gone. themes/README.md explains the styles and how to make a new theme. The screenshot tour now uses the real character pictures, so the layout baseline is taken again. Screenshots are pixel-identical to before, and test_theme.gd checks that the look stays in the theme.
32 lines
1.1 KiB
GDScript
32 lines
1.1 KiB
GDScript
class_name PopupBackdrop
|
|
extends ColorRect
|
|
## Dims everything behind an open popup and keeps clicks from reaching the buttons
|
|
## under it.
|
|
##
|
|
## The backdrop sits above the rest of its parent and below the popups it belongs to.
|
|
## Popups close themselves when clicked outside, and the backdrop keeps that click from
|
|
## reaching the buttons behind them.
|
|
|
|
var _popups: Array[BasePopup] = []
|
|
|
|
|
|
## Adds a backdrop to [param parent] and moves [param popups] above it. The backdrop
|
|
## shows while any of them is open.
|
|
static func add_to(parent: Control, popups: Array[BasePopup]) -> PopupBackdrop:
|
|
var backdrop: PopupBackdrop = PopupBackdrop.new()
|
|
backdrop.name = "PopupBackdrop"
|
|
backdrop.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
backdrop._popups = popups
|
|
parent.add_child(backdrop)
|
|
backdrop.color = backdrop.get_theme_color(&"backdrop", &"Palette")
|
|
backdrop.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
for popup: BasePopup in popups:
|
|
parent.move_child(popup, -1)
|
|
popup.visibility_changed.connect(backdrop._update)
|
|
backdrop._update()
|
|
return backdrop
|
|
|
|
|
|
func _update() -> void:
|
|
visible = _popups.any(func(popup: BasePopup) -> bool: return popup.visible)
|