Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
89 lines
1.8 KiB
GDScript
89 lines
1.8 KiB
GDScript
class_name ImplantApp
|
|
extends Control
|
|
## Base class for all implant apps. Absorbs HudGroups boilerplate; subclasses
|
|
## override lifecycle hooks only (#844, D-191).
|
|
##
|
|
## Subclass _ready() pattern:
|
|
## func _ready() -> void:
|
|
## manifest = load("res://ui/implant/apps/my_app/app.tres")
|
|
## super._ready()
|
|
## # additional init here if needed
|
|
|
|
signal app_opened(mode: int)
|
|
signal app_closed
|
|
signal insert_deactivated
|
|
|
|
var manifest: ImplantAppManifest = null
|
|
var nav: ImplantNavStack = null
|
|
|
|
|
|
func _ready() -> void:
|
|
set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
mouse_filter = Control.MOUSE_FILTER_STOP
|
|
visible = false
|
|
|
|
if manifest:
|
|
HudGroups.register(self, manifest.app_path)
|
|
HudGroups.app_changed.connect(_internal_app_changed)
|
|
|
|
nav = ImplantNavStack.new()
|
|
nav.screen_changed.connect(_on_screen_changed)
|
|
add_child(nav)
|
|
|
|
on_install()
|
|
|
|
|
|
func _internal_app_changed(app_path: String, mode: int) -> void:
|
|
if manifest == null:
|
|
return
|
|
if app_path != manifest.app_path:
|
|
if visible:
|
|
visible = false
|
|
on_close()
|
|
app_closed.emit()
|
|
return
|
|
|
|
match mode:
|
|
HudGroups.Mode.FULLSCREEN, HudGroups.Mode.INSERT:
|
|
if not visible:
|
|
visible = true
|
|
if not manifest.preserves_state:
|
|
nav.reset_to_default()
|
|
elif nav.is_empty():
|
|
nav.push_default()
|
|
on_open(mode)
|
|
app_opened.emit(mode)
|
|
HudGroups.Mode.GAMEPLAY:
|
|
if visible:
|
|
visible = false
|
|
on_close()
|
|
app_closed.emit()
|
|
|
|
|
|
# --- Lifecycle hooks — subclasses override ---
|
|
|
|
|
|
func on_install() -> void:
|
|
pass
|
|
|
|
|
|
func on_open(_mode: int) -> void:
|
|
pass
|
|
|
|
|
|
func on_close() -> void:
|
|
pass
|
|
|
|
|
|
func on_insert_deactivated() -> void:
|
|
if manifest and HudGroups.is_app_active(manifest.app_path):
|
|
HudGroups.close_app()
|
|
|
|
|
|
func _on_screen_changed(_screen_id: String) -> void:
|
|
pass
|
|
|
|
|
|
func handle_intent(_action: String, _params: Dictionary) -> void:
|
|
pass
|