Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

game-ui-patterns

БесплатноБез исполняемых скриптовНе проверен

Game UI code patterns: a HUD health bar, a menu state stack, an inventory grid with drag and drop, a typewriter dialogue box, a screen-edge-aware tooltip, and…

HermeticOrmusот HermeticOrmus★ 83 звезды на GitHub

Об этом скилле

Game UI Patterns

HUD Health Bar

# Health bar with smooth tween animation and damage flash
class_name HealthBar extends Control
@onready var fill_bar: ProgressBar = $FillBar
@onready var ghost_bar: ProgressBar = $GhostBar  # Lags behind for damage visualization
@onready var flash_overlay: ColorRect = $FlashOverlay

@export var ghost_tween_duration: float = 0.4
@export var flash_duration: float = 0.1

var _ghost_tween: Tween

func _ready() -> void:
    flash_overlay.modulate.a = 0.0

func set_health(current: float, maximum: float) -> void:
    var ratio := current / maximum
    fill_bar.value = ratio * 100.0

    # Flash red overlay
    var flash_tween := create_tween()
    flash_overlay.modulate.a = 0.5
    flash_tween.tween_property(flash_overlay, "modulate:a", 0.0, flash_duration)

    # Ghost bar lags behind with tween
    if _ghost_tween:
        _ghost_tween.kill()
    _ghost_tween = create_tween()
    _ghost_tween.tween_property(ghost_bar, "value", ratio * 100.0, ghost_tween_duration)\
        .set_delay(0.2)\
        .set_ease(Tween.EASE_IN)\
        .set_trans(Tween.TRANS_QUAD)

Menu State Stack

# Push-down automaton for menu navigation
class_name MenuManager extends CanvasLayer
var _stack: Array[Control] = []

func push_menu(menu: Control) -> void:
    if not _stack.is_empty():
        _stack.back().visible = false
    _stack.append(menu)
    add_child(menu)
    menu.visible = true
    # Give focus to first focusable element
    var first_button := menu.find_child("*Button*", true, false) as Button
    if first_button:
        first_button.grab_focus()

func pop_menu() -> void:
    if _stack.is_empty():
        return
    var top := _stack.pop_back()
    top.queue_free()
    if not _stack.is_empty():
        _stack.back().visible = true
        var first_button := _stack.back().find_child("*Button*", true, false) as Button
        if first_button:
            first_button.grab_focus()

func clear_stack() -> void:
    for menu in _stack:
        menu.queue_free()
    _stack.clear()

Inventory Grid with Drag-and-Drop

# Grid inventory slot - handles drag source and drop target
class_name InventorySlot extends Control
signal item_moved(from_slot: int, to_slot: int)

@export var slot_index: int = 0
@onready var item_icon: TextureRect = $ItemIcon
@onready var count_label: Label = $CountLabel

var _item_data: Dictionary = {}

func set_item(data: Dictionary) -> void:
    _item_data = data
    if data.is_empty():
        item_icon.texture = null
        count_label.visible = false
    else:
        item_icon.texture = data.get("icon") as Texture2D
        var count: int = data.get("count", 1)
        count_label.text = str(count)
        count_label.visible = count > 1

# Drag-and-drop API
func _get_drag_data(_at_position: Vector2) -> Variant:
    if _item_data.is_empty():
        return null
    var preview := TextureRect.new()
    preview.texture = item_icon.texture
    preview.size = Vector2(48, 48)
    set_drag_preview(preview)
    return {"slot_index": slot_index, "item": _item_data}

func _can_drop_data(_at_position: Vector2, data: Variant) -> bool:
    return data is Dictionary and "slot_index" in data

func _drop_data(_at_position: Vector2, data: Variant) -> void:
    var from_index: int = data["slot_index"]
    item_moved.emit(from_index, slot_index)

Typewriter Dialogue Box

# Dialogue display with typewriter effect and skip support
class_name DialogueBox extends Control
@onready var text_label: RichTextLabel = $TextLabel
@onready var speaker_label: Label = $SpeakerLabel
@onready var continue_indicator: Control = $ContinueIndicator

@export var chars_per_second: float = 40.0

signal dialogue_advanced
signal dialogue_finished

var _full_text: String = ""
var _tween: Tween
var _is_typing: bool = false

func show_line(speaker: String, text: String) -> void:
    speaker_label.text = speaker
    text_label.text = ""
    _full_text = text
    continue_indicator.visible = false

    if _tween:
        _tween.kill()

    _is_typing = true
    var duration := float(text.length()) / chars_per_second
    _tween = create_tween()
    _tween.tween_method(_set_visible_characters, 0, text.length(), duration)
    _tween.tween_callback(func():
        _is_typing = false
        continue_indicator.visible = true
    )

func _set_visible_characters(count: int) -> void:
    text_label.text = _full_text.substr(0, count)

func advance() -> void:
    if _is_typing:
        # Skip typewriter - show full text immediately
        if _tween:
            _tween.kill()
        text_label.text = _full_text
        _is_typing = false
        continue_indicator.visible = true
    else:
        dialogue_advanced.emit()

func _unhandled_input(event: InputEvent) -> void:
    if visible and event.is_action_pressed(&"ui_accept"):
        advance()

Screen-Edge-Aware Tooltip

# Tooltip that repositions to stay within screen bounds
class_name
Полный SKILL.md на GitHub

Установить game-ui-patterns в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл game-ui-patterns?

Game UI code patterns: a HUD health bar, a menu state stack, an inventory grid with drag and drop, a typewriter dialogue box, a screen-edge-aware tooltip, and a settings menu with live preview. Use when implementing game interface screens in Godot.

Как установить скилл game-ui-patterns?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл game-ui-patterns запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить game-ui-patterns с