Files
aetherbound-guild/runtime/foundation/screen_context.gd
T

49 lines
1.5 KiB
GDScript

class_name ABGScreenContext
extends RefCounted
## A small, UI-independent description of where a screen was opened from and
## where it should return. Page controllers may carry this across a route or
## overlay, but the context never owns gameplay state or persistence.
var screen_id := ""
var caller_id := ""
var return_screen_id := ""
var return_focus_path := ""
var presentation_mode := "page"
var metadata: Dictionary = {}
func _init(values: Dictionary = {}) -> void:
screen_id = String(values.get("screen_id", ""))
caller_id = String(values.get("caller_id", ""))
return_screen_id = String(values.get("return_screen_id", ""))
return_focus_path = String(values.get("return_focus_path", ""))
presentation_mode = String(values.get("presentation_mode", "page"))
metadata = values.get("metadata", {}).duplicate(true) if values.get("metadata", {}) is Dictionary else {}
func is_overlay() -> bool:
return presentation_mode == "overlay"
func duplicate_context():
var copy = get_script().new()
copy.screen_id = screen_id
copy.caller_id = caller_id
copy.return_screen_id = return_screen_id
copy.return_focus_path = return_focus_path
copy.presentation_mode = presentation_mode
copy.metadata = metadata.duplicate(true)
return copy
func to_dictionary() -> Dictionary:
return {
"screen_id": screen_id,
"caller_id": caller_id,
"return_screen_id": return_screen_id,
"return_focus_path": return_focus_path,
"presentation_mode": presentation_mode,
"metadata": metadata.duplicate(true),
}