45 lines
1003 B
GDScript
45 lines
1003 B
GDScript
class_name Memory extends CanvasLayer
|
|
|
|
|
|
func _ready() -> void:
|
|
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
|
|
SceneManager.toggle_pause_counter(true)
|
|
update_display()
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
# memory 界面阻塞所有输入事件,除了 escape
|
|
get_viewport().set_input_as_handled()
|
|
if (
|
|
event.is_action_pressed("escape")
|
|
or event.is_action_pressed("cancel")
|
|
or event.is_action_pressed("memory")
|
|
):
|
|
quit()
|
|
|
|
|
|
func quit() -> void:
|
|
SceneManager.toggle_pause_counter(false)
|
|
queue_free()
|
|
|
|
|
|
# 1-8 in P1, 9-16 in P2
|
|
# path example: Mem/P1/1
|
|
func update_display():
|
|
if ArchiveManager.archive:
|
|
# node name -> display bool
|
|
var display_dict := ArchiveManager.archive.mem_display_dict
|
|
for k in display_dict:
|
|
var node_path = "Mem/"
|
|
if k < 0:
|
|
continue
|
|
elif k < 9:
|
|
node_path += "P1/" + str(k)
|
|
elif k < 17:
|
|
node_path += "P2/" + str(k)
|
|
else:
|
|
continue
|
|
var node = get_node_or_null(node_path)
|
|
if node:
|
|
node.visible = display_dict[k]
|