diff --git a/Scripts/GraphNodes/ChoiceNode.gd b/Scripts/GraphNodes/ChoiceNode.gd index 83d7c7b3..7a5b3a35 100644 --- a/Scripts/GraphNodes/ChoiceNode.gd +++ b/Scripts/GraphNodes/ChoiceNode.gd @@ -92,5 +92,3 @@ func _update(panel: ChoiceNodePanel = null): var next_node = get_graph_node(option.get("NextID")) if not next_node is int: get_parent().connect_node(name, options.find(option), next_node.name, 0) - - size.y = 0 diff --git a/Scripts/MonologueGraphNode.gd b/Scripts/MonologueGraphNode.gd index 7c786c2f..3cddaddf 100644 --- a/Scripts/MonologueGraphNode.gd +++ b/Scripts/MonologueGraphNode.gd @@ -15,5 +15,9 @@ func _to_dict(): func _update(_panel = null): pass +func _common_update(_x = null): + size.y = 0 + func _connect_to_panel(sgnl): sgnl.connect(_update) + sgnl.connect(_common_update) diff --git a/Test/Scripts/Main.gd b/Test/Scripts/Main.gd index 5613464f..5d567515 100644 --- a/Test/Scripts/Main.gd +++ b/Test/Scripts/Main.gd @@ -8,6 +8,8 @@ extends MonologueProcess # SidePanel nodes @onready var sp_text_box_container = $SidePanelContainer/MarginContainer/ScrollContainer/Container/ScrollContainer/TextBoxContainer @onready var sp_choice_container = $SidePanelContainer/MarginContainer/ScrollContainer/Container/ChoiceContainer +@onready var sp_scroll_container: ScrollContainer = $SidePanelContainer/MarginContainer/ScrollContainer/Container/ScrollContainer +@onready var sp_scrollbar: ScrollBar = sp_scroll_container.get_v_scroll_bar() # TextBox nodes @onready var tb_text_label = $TextBoxContainer/Panel/MarginContainer/Container/TextLabel @onready var tb_choice_container = $TextBoxContainer/Panel/MarginContainer/Container/ChoiceContainer @@ -21,6 +23,8 @@ func _ready(): var global_vars = get_node("/root/GlobalVariables") var path = global_vars.test_path + sp_scrollbar.connect("changed", _handle_scrollbar_changed) + if path: load_dialogue(path.get_basename()) next() @@ -29,6 +33,9 @@ func _input(event): if event.is_action_pressed("ui_accept") and is_completed and not sp_choice_container.visible: next() +func _handle_scrollbar_changed(): + sp_scroll_container.scroll_vertical = int(sp_scrollbar.max_value) + func get_character_asset(character: String, _variant = null): if character.begins_with("_"): return @@ -105,14 +112,17 @@ func _on_monologue_sentence(sentence, speaker, speaker_name): get_tree().create_tween().tween_property(tb_text_label, "visible_characters", len(tb_text_label.text), 0.5) +func _instantiate_option(option): + var new_option = option_button.instantiate() + new_option.text = option.get("Sentence") + new_option.connect("pressed", option_selected.bind(option)) + + return new_option + func _on_monologue_new_choice(options): for option in options: - var new_option = option_button.instantiate() - new_option.text = option.get("Sentence") - new_option.connect("pressed", option_selected.bind(option)) - - tb_choice_container.add_child(new_option) - sp_choice_container.add_child(new_option) + tb_choice_container.add_child(_instantiate_option(option)) + sp_choice_container.add_child(_instantiate_option(option)) tb_choice_container.show() sp_choice_container.show() diff --git a/project.godot b/project.godot index cbc93e28..2283c44c 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Monologue" -config/version="2.1.0" +config/version="2.1.1" run/main_scene="res://Scenes/App.tscn" config/features=PackedStringArray("4.2") run/low_processor_mode=true