Index of every page on this site: llms.txt
All skills
jame581 avatar

/hud-system

@426e8ab
by Jan Mesarčjame581/godotprompter979 stars
63
Run it yourself

Use when building in-game HUDs — health bars, score displays, minimap, notifications, and damage numbers

Use this Skill: https://skilld.dev/gh/jame581/godotprompter/hud-system

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesnotifications.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Notification Stack

Reference for skills/hud-system/SKILL.md — VBoxContainer-based notification stack with auto-dismiss, GDScript + C#.

← Back to SKILL.md


5. Notification System

Toast-style notifications appear for a short time then auto-dismiss. A VBoxContainer holds all visible toasts; a max-visible cap holds extra messages in a queue until a visible toast is dismissed.

GDScript

## notification_stack.gd — attach to a VBoxContainer anchored to top-right corner
class_name NotificationStack
extends VBoxContainer

@export var notification_scene: PackedScene
@export var max_visible: int = 5
@export var auto_dismiss_time: float = 3.0

var _queue: Array[String] = []
var _active: Array[Control] = []


func _ready() -> void:
    # Connect to an EventBus signal, or call push() directly from code.
    EventBus.notification_requested.connect(push)


## Enqueue a new notification message.
func push(message: String) -> void:
    _queue.append(message)
    _flush_queue()


func _flush_queue() -> void:
    while _queue.size() > 0 and _active.size() < max_visible:
        _show_next()


func _show_next() -> void:
    var message: String = _queue.pop_front()
    var toast: Control = notification_scene.instantiate()

    # Expect the toast scene's Label at MarginContainer/MessageLabel (see the tree below)
    toast.get_node("MarginContainer/MessageLabel").text = message
    toast.modulate.a = 0.0
    add_child(toast)
    _active.append(toast)

    # Fade in
    var tween: Tween = create_tween()
    tween.tween_property(toast, "modulate:a", 1.0, 0.2)

    # Auto-dismiss timer
    var timer: Timer = Timer.new()
    timer.wait_time = auto_dismiss_time
    timer.one_shot  = true
    toast.add_child(timer)
    timer.timeout.connect(_dismiss.bind(toast))
    timer.start()


func _dismiss(toast: Control) -> void:
    _active.erase(toast)

    var tween: Tween = toast.create_tween()
    tween.tween_property(toast, "modulate:a", 0.0, 0.2)
    tween.finished.connect(func() -> void:
        toast.queue_free()
        _flush_queue()  # Show next queued message if any
    )

C#

// NotificationStack.cs — attach to a VBoxContainer
using Godot;
using System.Collections.Generic;

public partial class NotificationStack : VBoxContainer
{
    [Export] public PackedScene NotificationScene { get; set; }
    [Export] public int MaxVisible { get; set; } = 5;
    [Export] public float AutoDismissTime { get; set; } = 3.0f;

    private readonly Queue<string> _queue  = new();
    private readonly List<Control> _active = new();

    public override void _Ready()
    {
        GetNode<EventBus>("/root/EventBus").NotificationRequested += Push;
    }

    public void Push(string message)
    {
        _queue.Enqueue(message);
        FlushQueue();
    }

    private void FlushQueue()
    {
        while (_queue.Count > 0 && _active.Count < MaxVisible)
            ShowNext();
    }

    private void ShowNext()
    {
        string message = _queue.Dequeue();
        var toast = NotificationScene.Instantiate<Control>();
        toast.GetNode<Label>("MarginContainer/MessageLabel").Text = message;
        toast.Modulate = new Color(1, 1, 1, 0);
        AddChild(toast);
        _active.Add(toast);

        var tween = CreateTween();
        tween.TweenProperty(toast, "modulate:a", 1.0f, 0.2f);

        var timer = new Timer { WaitTime = AutoDismissTime, OneShot = true };
        toast.AddChild(timer);
        timer.Timeout += () => Dismiss(toast);
        timer.Start();
    }

    private void Dismiss(Control toast)
    {
        _active.Remove(toast);

        var tween = toast.CreateTween();
        tween.TweenProperty(toast, "modulate:a", 0.0f, 0.2f);
        tween.Finished += () =>
        {
            toast.QueueFree();
            FlushQueue();
        };
    }
}

Toast scene structure:

ToastNotification (PanelContainer)
└── MarginContainer
    └── MessageLabel (Label)

EventBus signal needed:

# autoloads/event_bus.gd
signal notification_requested(message: String)
// EventBus.cs (partial — notification signal)
[Signal] public delegate void NotificationRequestedEventHandler(string message);

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts8d3 checks · Risk SAFE
  • Gen Agent Trust Hub8d

    The skill provides standard game development patterns for creating Head-Up Displays (HUDs) in the Godot Engine using GDScript and C#. No security risks or malicious patterns were identified.

  • Socket8d

    No alerts

  • Snyk8d

    Risk: LOW · No issues

Signed by skilld at 426e8ab. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 6 days ago.

Activeupdated last month

README badge

README badge for jame581/godotprompter/hud-system