@tool class_name CollectableUi extends CenterContainer @export var has_stage: bool = false: set(focused): if has_stage == focused: return if focused: has_stage = true is_collapsed = false if not visible: show() else: has_stage = false get_viewport().gui_release_focus() is_collapsed = true #@export var collapsed = true: # set(collapse): # if is_inside_tree() and not Engine.is_editor_hint(): # if State.reduce_motion: # collapsed = false # return # if collapse and not collapsed: # if is_inside_tree(): # _hide_buttons() # collapsed = collapse # elif not collapse and collapsed: # if is_inside_tree(): # _show_buttons() # collapsed = collapse # # if collapse and has_stage: State.leave_stage(self) @export var scene: Scenes.id = Scenes.id.YOUTH_DRAEVEN: set(id): scene = id if is_inside_tree() and not is_board: match id: Scenes.id.YOUTH_DRAEVEN: # FIXME: this explicit translation should not be nessecary if title_override == "": title_label.text = TranslationServer.translate("Starlight") if subtitle_override == "": cn_label.text = TranslationServer.translate("[b]CN:[/b] Alienation") Scenes.id.YOUTH_CHILDHOOD: if title_override == "": title_label.text = TranslationServer.translate("crafted Mask") if subtitle_override == "": cn_label.text = TranslationServer.translate("[b]CN:[/b] Eating issues, Alienation, Swearing") Scenes.id.YOUTH_VOICE_TRAINING: if title_override == "": title_label.text = TranslationServer.translate("Comic Stash") if subtitle_override == "": cn_label.text = TranslationServer.translate("[b]CN:[/b] Internalised Mysoginy, Nudity, Bullying, Comic Voilence") Scenes.id.YOUTH_JUI_JUTSU: if title_override == "": title_label.text = TranslationServer.translate("Sports Clothes") if subtitle_override == "": cn_label.text = TranslationServer.translate("[b]CN:[/b] Body Issues (Gender-Dysphoria), non-consensual Sex, Dissociation, Self-sabotaging Thoughts, Swearing") Scenes.id.TRANSITION: if title_override == "": title_label.text = "Starlight" if subtitle_override == "": cn_label.text = "" Scenes.id.YOUTH_DRAEVEN: if title_override == "": title_label.text = "Starlight" if subtitle_override == "": cn_label.text = "" Scenes.id.YOUTH_DRAEVEN: if title_override == "": title_label.text = "Starlight" if subtitle_override == "": cn_label.text = "" Scenes.id.YOUTH_DRAEVEN: if title_override == "": title_label.text = "Starlight" if subtitle_override == "": cn_label.text = "" if not Engine.is_editor_hint(): is_collected = Scenes.is_sequence_repeating(scene) @export var is_collected: bool = false: set(value): is_collected = value if is_inside_tree(): collected_box.button_pressed = value if is_collected and not is_board: %CollectLabel.text = "listen again" else: if not is_board: %CollectLabel.text = "collect" else: %CollectLabel.text = "find connections" @onready var collected_box: CheckBox = %CheckBox @export var title_override: String = "": set(value): title_override = value if is_inside_tree() and not is_board: title_label.text = value @onready var title_label: Label = %TitleLabel @export var subtitle_override: String = "": set(value): subtitle_override = value if is_inside_tree() and not is_board: cn_label.text = value @onready var cn_label: RichTextLabel = %ContentNoteLabel @onready var animation_player: AnimationPlayer = %AnimationPlayer @export var is_collapsed: bool = true @export var is_expanded: bool = false: set(expanded): if expanded != is_expanded: is_expanded = expanded if is_inside_tree(): animation_player.play("expand") await animation_player.animation_finished for button:Button in [%ReadStory, %CollectButton, %SummaryButton, %SkipButton]: if button.visible: button.grab_focus() return @export var was_skipped: bool = false @export var is_board:bool = false: set(board): is_board = board if is_inside_tree(): if board: if title_override == "": title_label.text = "Mind Board" collected_box.hide() # Not room agnostic yet! if not Engine.is_editor_hint(): match Scenes.get_completed_total(): 1: if subtitle_override == "": cn_label.text = "Find all three Mementos to collect all thoughts." 2: if subtitle_override == "": cn_label.text = "Find two more Mementos to get all cards." 3: if subtitle_override == "": cn_label.text = "Find the last remaining Memento." 4: if subtitle_override == "": cn_label.text = "Use this to find a Frame of Mind." else: scene = scene collected_box.show() signal open_board #TODO implement proper scene skipping signal scene_skipped(i: int) func _ready() -> void: State.settings_changed.connect(_on_context_updated) %CollectButton.pressed.connect(collect_memento) ##TODO: add functions for remaining buttons update_state() func _on_context_updated(): %SkipButton.visible = State.allow_skipping %SummaryButton.visible = State.provide_summaries %ReadStory.visible = is_collected %OptionPrompt.visible = State.allow_skipping or State.provide_summaries or is_collected and not is_board %OptionsLabel.visible = State.allow_skipping or State.provide_summaries or is_collected and not is_board cn_label.visible = true if State.show_content_notes else false func update_state(): scene = scene is_board = is_board _on_context_updated() func reveal(): if not visible: update_state() visible = true animation_player.play("reveal") #func _process(_delta: float) -> void: # if not visible or Engine.is_editor_hint(): return # if Input.is_action_just_pressed("collect_memento_ui"): # if not is_board: # collect_memento() # else: # open_board.emit() # elif Input.is_action_just_pressed("option_memento_ui"): # is_expanded = true #FIXME something was eating all my inputs, maybe I can use the more pretty pattern when I figure out the culprit func _input(event: InputEvent) -> void: print("handle input") if not visible: return if event.is_action_pressed("collect_memento_ui"): if not is_board: collect_memento() get_viewport().set_input_as_handled() else: open_board.emit() elif event.is_action_pressed("option_memento_ui"): is_expanded = true get_viewport().set_input_as_handled() func vanish(): if not visible: return if is_expanded: animation_player.play("vanish_all") else: animation_player.play("vanish") func collect_memento(): Scenes.start_sequence(scene) State.leave_stage(self) #get_tree().call_group("scene_actors", "play_scene", scene, collected) if was_skipped: scene_skipped.emit(-1) is_collected = true func _on_skip_pressed(): print("Scene skipped!") if scene != null: scene_skipped.emit(1) was_skipped = true $Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "collect (un-skip)" State.leave_stage(self)