Toast notifications for game events (#57) #130
No reviewers
Labels
No labels
assets
bug
duplicate
enhancement
help wanted
invalid
question
testing
ui
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
liamjd/UntitledColonyBuilder!130
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "57-toast-notifications"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds toast notifications in the bottom-right corner, raised from anywhere through
GameState.toast_requested. Clicking a toast that refers to a building, pawn or map cell centres the camera on it.Closes #57
What's in it
ToastMessage: text, plus an optional title and icon, a timeout (5s by default,<= 0keeps it until closed), and at most one target, either anEntityor a cell.focus_point(map)works out the target's world position from the record itself, so the click still works after the building or pawn has left its registry.Toast: one message on screen. It counts down in real time, so pausing the game doesn't freeze it. Dismissing fades and slides the panel off to the right, shrinks its slot so the toasts above slide down, then frees the node. Clicking the body sendscamera_focus_requested; the X only closes it.ToastStack: the column. It listens totoast_requested, puts new toasts on top so the oldest is at the bottom, and passescamera_focus_requestedup togame.gd. Its empty space lets clicks through to the map.ToastNotifier: turns gameplay signals into toasts: construction complete (PLANNED or UNDER_CONSTRUCTION → BUILT), demolition complete (removed whilemarked_for_demolition), and task blocked.CameraRig.focus_on(world): snaps the camera to a point, height included, kept inside the map, and ignores a point that isn't finite.game.gd/game.tscn: the notifier is a child ofGame, and the stack sits underUIHUDLayer.game.gdconnects the stack's signal tocamera_rig.focus_on(message.focus_point(map)).The decisions (click anywhere on the toast, one target per toast, snap rather than pan, real-time countdown, which three events) are in the spec comment on #57.
Verification
test_toast_message.gd,test_toast.gd,test_toast_stack.gd,test_toast_notifier.gd,test_camera_focus.gd. They were written before the implementation.tools/screenshot_toast_exit.gdcaptures a dismissal in four frames. It shows the column in the right order, the fade and slide, the slot shrinking with the toast above sliding down, and the node freed at the end.Not in this PR
task_blockedcould fill the column if many tasks block at once.🤖 Generated with Claude Code