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

44 lines
1.3 KiB
GDScript

class_name ABGPageContext
extends RefCounted
## Explicit route metadata passed to a PageView.
##
## PageContext carries navigation identity only. It never owns Company, Battle,
## Save or service state, so a View can be mounted and tested in isolation.
var page_id := ""
var caller_id := ""
var return_page_id := ""
var return_focus_path := ""
var presentation_mode := "page"
var metadata: Dictionary = {}
func _init(values: Dictionary = {}) -> void:
page_id = String(values.get("page_id", values.get("screen_id", "")))
caller_id = String(values.get("caller_id", ""))
return_page_id = String(values.get("return_page_id", values.get("return_screen_id", "")))
return_focus_path = String(values.get("return_focus_path", ""))
presentation_mode = String(values.get("presentation_mode", "page"))
var raw_metadata = values.get("metadata", {})
metadata = raw_metadata.duplicate(true) if raw_metadata is Dictionary else {}
func is_overlay() -> bool:
return presentation_mode == "overlay"
func duplicate_context() -> ABGPageContext:
return ABGPageContext.new(to_dictionary())
func to_dictionary() -> Dictionary:
return {
"page_id": page_id,
"caller_id": caller_id,
"return_page_id": return_page_id,
"return_focus_path": return_focus_path,
"presentation_mode": presentation_mode,
"metadata": metadata.duplicate(true),
}