132646f6c3
ci / verify (push) Successful in 48s
Crusenho's Complete UI Essential Pack is CC BY 4.0 -- redistributable and
commercial-friendly, confirmed from the License.txt the pack itself ships --
so unlike the two bdragon packs a subset is committed: twelve PNGs, 48 KB,
under assets/sprites/ui/. Only what is used, because each committed PNG costs
a Godot .import sidecar and a directory nothing references is one nobody
prunes.
UiTheme builds a Theme in code from it -- button states, panels, line edits --
and every screen roots itself through UiTheme.themed_root(). The HUD's bars are
the pack's frame with a tinted fill, drawn as three horizontal slices because
Godot's nine-patch lives on nodes and the HUD is drawn rather than built from
controls. Inventory slots use the pack's slot art at exactly twice the source
size; a non-integer scale on a 1px border reads as a wobble along every edge.
The credits screen is the other half of the request and it is a licence
obligation, not a nicety: two packs are now CC BY, which asks for attribution
"in any reasonable manner", and a markdown file in a source repo is not
reasonable for someone who downloaded a build. Settings -> Credits shows every
source with its terms and a link to the licence text. test_credits.gd asserts
CREDITS.md and docs/ASSETS.md name every entry, so the three cannot drift.
Two things found by actually looking at the screen, which is the point:
- The FIRST version of this styled nothing. A Control inherits its theme from
Control ANCESTORS only, and the chain breaks at the first plain Node or
CanvasLayer -- which is every screen here. get_window().theme set the
property, changed nothing, and read as correct. check.sh, 458 tests and a
clean smoke run all passed with the entire interface unstyled. The theme
test now instantiates every screen and asks what its buttons resolve.
- The settings screen showed Fire bound to the right mouse button, because
the test suite was writing the player's real user://settings.cfg --
rebinding calls save() and nothing had redirected the path. Settings.path
is now redirectable, the fixture points it at a scratch file, and a test
asserts the default is still the player's own.
tools/screenshot.tscn is what found both. It boots the client windowed and
saves the menus, the HUD, settings and credits. Manual, needs a display, and
the only thing in the project that can tell you the interface rendered.
check.sh clean, 460 tests, SMOKE PASS, all four diagnostics green.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
137 lines
4.1 KiB
GDScript
137 lines
4.1 KiB
GDScript
extends CanvasLayer
|
|
## In-game system menu, opened with Escape.
|
|
##
|
|
## Exists because without it there is no way out of a session short of killing
|
|
## the process -- and "kill the process" is exactly the behaviour the escape
|
|
## channel is designed to discourage, so leaving it as the only exit would work
|
|
## against the rest of the design.
|
|
|
|
signal resumed
|
|
signal return_to_hub_requested
|
|
signal disconnect_requested
|
|
signal characters_requested
|
|
signal settings_requested
|
|
|
|
var _panel: VBoxContainer
|
|
var _hub_button: Button
|
|
var _characters_button: Button
|
|
var _disconnect_button: Button
|
|
var _note: Label
|
|
var _in_dungeon: bool = false
|
|
var _open: bool = false
|
|
|
|
|
|
func _ready() -> void:
|
|
layer = 20
|
|
var root := UiTheme.themed_root()
|
|
add_child(root)
|
|
|
|
# Dim the game behind the menu so it is obvious the world is still running.
|
|
var scrim := ColorRect.new()
|
|
scrim.color = Color(0.0, 0.0, 0.0, 0.55)
|
|
scrim.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
scrim.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
root.add_child(scrim)
|
|
|
|
var center := CenterContainer.new()
|
|
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
root.add_child(center)
|
|
|
|
_panel = VBoxContainer.new()
|
|
_panel.custom_minimum_size = Vector2(320.0, 0.0)
|
|
_panel.add_theme_constant_override("separation", 10)
|
|
center.add_child(_panel)
|
|
|
|
var title := Label.new()
|
|
title.text = "PAUSED"
|
|
title.add_theme_font_size_override("font_size", 26)
|
|
_panel.add_child(title)
|
|
|
|
_note = Label.new()
|
|
_note.add_theme_font_size_override("font_size", 12)
|
|
_note.add_theme_color_override("font_color", Color(1.0, 0.7, 0.5))
|
|
_note.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
_note.custom_minimum_size = Vector2(320.0, 0.0)
|
|
_panel.add_child(_note)
|
|
|
|
_hub_button = _button("Return to hub", func() -> void:
|
|
return_to_hub_requested.emit()
|
|
close())
|
|
_characters_button = _button("Change character", func() -> void:
|
|
characters_requested.emit()
|
|
close())
|
|
_button("Settings", func() -> void:
|
|
settings_requested.emit()
|
|
close())
|
|
_button("Resume", func() -> void: close())
|
|
_disconnect_button = _button("Disconnect to menu", func() -> void:
|
|
disconnect_requested.emit()
|
|
close())
|
|
_button("Quit game", func() -> void: get_tree().quit())
|
|
|
|
visible = false
|
|
|
|
|
|
func _button(text: String, on_press: Callable) -> Button:
|
|
var b := Button.new()
|
|
b.text = text
|
|
b.pressed.connect(on_press)
|
|
_panel.add_child(b)
|
|
return b
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("system_menu"):
|
|
toggle()
|
|
get_viewport().set_input_as_handled()
|
|
|
|
|
|
func toggle() -> void:
|
|
if _open:
|
|
close()
|
|
else:
|
|
open()
|
|
|
|
|
|
func open() -> void:
|
|
_open = true
|
|
visible = true
|
|
# Nothing is paused -- the server does not stop for one client's menu, so
|
|
# neither does the view. Only the mouse is freed.
|
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
|
|
|
|
func close() -> void:
|
|
_open = false
|
|
visible = false
|
|
|
|
|
|
func is_open() -> bool:
|
|
return _open
|
|
|
|
|
|
## The hub button is meaningless when you are already in the hub.
|
|
func set_in_dungeon(in_dungeon: bool) -> void:
|
|
if in_dungeon == _in_dungeon and not _note.text.is_empty():
|
|
return
|
|
_in_dungeon = in_dungeon
|
|
_hub_button.disabled = not in_dungeon
|
|
# Swapping is hub-only, and the server enforces that regardless of what
|
|
# this button does -- but a disabled button explains the rule, where a
|
|
# refusal after the fact just looks broken.
|
|
_characters_button.disabled = in_dungeon
|
|
_characters_button.text = "Change character (hub only)" if in_dungeon \
|
|
else "Change character"
|
|
if in_dungeon:
|
|
# Disconnecting is not an escape: the server keeps the body in the
|
|
# world, channelling out, for the same second the escape button costs.
|
|
# Saying so is the difference between a considered choice and a nasty
|
|
# surprise -- the mechanic only reads as fair if players know about it.
|
|
_note.text = "The world keeps running while this is open. " \
|
|
+ "Disconnecting does not save you: your ship stays in the dungeon " \
|
|
+ "for one second and can still be killed."
|
|
_disconnect_button.text = "Disconnect to menu (ship stays 1s)"
|
|
else:
|
|
_note.text = "The world keeps running while this is open."
|
|
_disconnect_button.text = "Disconnect to menu"
|