Files
stickman/scripts/waypoint_context.gd
T

36 lines
1.3 KiB
GDScript

class_name WaypointContext
extends PopupMenu
## WaypointContext - Right-click context menu for a walk_to waypoint (Phase 3c.3).
##
## Provides Edit/Delete/Insert actions for the waypoint's walk action plus a
## "Edit Trigger Rules" entry (shown only when rules target this waypoint).
const EDIT_WALK := 0
const DELETE_WALK := 1
const INSERT_BEFORE := 2
const INSERT_AFTER := 3
const EDIT_TRIGGER_RULES := 4
const _EDIT_TRIGGER_IDX := 5 # item position of the trigger-rules entry (after a separator at 4)
func _init() -> void:
# _init runs before the node is in the tree; item order is fixed here.
add_item("✎ Edit this Walk", EDIT_WALK)
add_item("✕ Delete this Walk", DELETE_WALK)
add_item("⬆ Insert action before", INSERT_BEFORE)
add_item("⬇ Insert action after", INSERT_AFTER)
add_separator()
add_item("⚡ Edit Trigger Rules", EDIT_TRIGGER_RULES)
## Updates the trigger-rules entry (count / enabled) and pops up at `rect`.
func popup_for(rect: Rect2i, trigger_rule_count: int) -> void:
if trigger_rule_count > 0:
set_item_text(_EDIT_TRIGGER_IDX, "⚡ Edit Trigger Rules (%d rule%s)" % [trigger_rule_count, "" if trigger_rule_count == 1 else "s"])
set_item_disabled(_EDIT_TRIGGER_IDX, false)
else:
set_item_text(_EDIT_TRIGGER_IDX, "⚡ Edit Trigger Rules")
set_item_disabled(_EDIT_TRIGGER_IDX, true)
popup(rect)