From 656e95594fb7fea049e97b320771d1c32587f45b Mon Sep 17 00:00:00 2001 From: MaddoScientisto Date: Mon, 17 Mar 2025 23:16:22 +0100 Subject: [PATCH] VN Sizing --- Dialogue/Styles/VN.tres | 10 +- .../VisualNovelTextbox/animations.gd | 93 +++++ .../VisualNovelTextbox/animations.gd.uid | 1 + .../autoadvance_indicator.gd | 13 + .../autoadvance_indicator.gd.uid | 1 + .../custom_visual_novel_textbox.tscn | 349 ++++++++++++++++++ .../VisualNovelTextbox/next.svg | 12 + .../VisualNovelTextbox/next.svg.import | 37 ++ .../vn_textbox_default_panel.tres | 12 + .../VisualNovelTextbox/vn_textbox_layer.gd | 278 ++++++++++++++ .../vn_textbox_layer.gd.uid | 1 + .../vn_textbox_name_label_panel.tres | 12 + Resources/Styles/vn_textbox_cirno_panel.tres | 12 + 13 files changed, 827 insertions(+), 4 deletions(-) create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/animations.gd create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/animations.gd.uid create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/autoadvance_indicator.gd create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/autoadvance_indicator.gd.uid create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/custom_visual_novel_textbox.tscn create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/next.svg create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/next.svg.import create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_default_panel.tres create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_layer.gd create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_layer.gd.uid create mode 100644 Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_name_label_panel.tres create mode 100644 Resources/Styles/vn_textbox_cirno_panel.tres diff --git a/Dialogue/Styles/VN.tres b/Dialogue/Styles/VN.tres index 7fb737c9..3213b2d7 100644 --- a/Dialogue/Styles/VN.tres +++ b/Dialogue/Styles/VN.tres @@ -4,7 +4,7 @@ [ext_resource type="PackedScene" uid="uid://c1k5m0w3r40xf" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn" id="2_obap8"] [ext_resource type="PackedScene" uid="uid://cy1y14inwkplb" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn" id="3_kxjow"] [ext_resource type="PackedScene" uid="uid://cn674foxwedqu" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Input/full_advance_input_layer.tscn" id="4_d8rd6"] -[ext_resource type="PackedScene" uid="uid://bquja8jyk8kbr" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn" id="5_bks8v"] +[ext_resource type="PackedScene" uid="uid://bkycr7efsukaj" path="res://Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/custom_visual_novel_textbox.tscn" id="5_mp7sv"] [ext_resource type="PackedScene" uid="uid://dsbwnp5hegnu3" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.tscn" id="6_mk3bt"] [ext_resource type="PackedScene" uid="uid://dhk6j6eb6e3q" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.tscn" id="7_8cj1f"] [ext_resource type="PackedScene" uid="uid://cvgf4c6gg0tsy" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.tscn" id="8_aoqfk"] @@ -35,11 +35,13 @@ overrides = {} [sub_resource type="Resource" id="Resource_6e5ca"] script = ExtResource("1_47mos") -scene = ExtResource("5_bks8v") +scene = ExtResource("5_mp7sv") overrides = { "box_margin_bottom": "1.0", +"box_panel": "\"res://Resources/Styles/PixelStyleBoxRed.tres\"", "box_size": "Vector2(300, 50)", -"name_label_box_offset": "Vector2(0, 16)", +"name_label_box_offset": "Vector2(0, 8)", +"name_label_box_panel": "\"res://Resources/Styles/PixelStyleBoxRed.tres\"", "name_label_custom_font_size": "11.0", "next_indicator_size": "Vector2(12, 12)", "text_size": "6.0" @@ -82,4 +84,4 @@ layer_info = { } base_overrides = {} layers = Array[ExtResource("1_47mos")]([]) -metadata/_latest_layer = "" +metadata/_latest_layer = "13" diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/animations.gd b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/animations.gd new file mode 100644 index 00000000..c03b3ee0 --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/animations.gd @@ -0,0 +1,93 @@ +extends AnimationPlayer + +## A custom script/node that adds some animations to the textbox. + +# Careful: Sync these with the ones in the root script! +enum AnimationsIn {NONE, POP_IN, FADE_UP} +enum AnimationsOut {NONE, POP_OUT, FADE_DOWN} +enum AnimationsNewText {NONE, WIGGLE} + +var animation_in: AnimationsIn +var animation_out: AnimationsOut +var animation_new_text: AnimationsNewText + +var full_clear := true + + +func get_text_panel() -> PanelContainer: + return %DialogTextPanel + + +func get_dialog() -> DialogicNode_DialogText: + return %DialogicNode_DialogText + + +func _ready() -> void: + var text_system: Node = DialogicUtil.autoload().get(&'Text') + text_system.connect(&'animation_textbox_hide', _on_textbox_hide) + text_system.connect(&'animation_textbox_show', _on_textbox_show) + text_system.connect(&'animation_textbox_new_text', _on_textbox_new_text) + text_system.connect(&'about_to_show_text', _on_about_to_show_text) + var animation_system: Node = DialogicUtil.autoload().get(&'Animations') + animation_system.connect(&'animation_interrupted', _on_animation_interrupted) + + +func _on_textbox_show() -> void: + if animation_in == AnimationsIn.NONE: + return + play('RESET') + var animation_system: Node = DialogicUtil.autoload().get(&'Animations') + animation_system.call(&'start_animating') + get_text_panel().get_parent().get_parent().set(&'modulate', Color.TRANSPARENT) + get_dialog().text = "" + match animation_in: + AnimationsIn.POP_IN: + play("textbox_pop") + AnimationsIn.FADE_UP: + play("textbox_fade_up") + if not animation_finished.is_connected(Callable(animation_system, &'animation_finished')): + animation_finished.connect(Callable(animation_system, &'animation_finished'), CONNECT_ONE_SHOT) + + +func _on_textbox_hide() -> void: + if animation_out == AnimationsOut.NONE: + return + play('RESET') + var animation_system: Node = DialogicUtil.autoload().get(&'Animations') + animation_system.call(&'start_animating') + match animation_out: + AnimationsOut.POP_OUT: + play_backwards("textbox_pop") + AnimationsOut.FADE_DOWN: + play_backwards("textbox_fade_up") + + if not animation_finished.is_connected(Callable(animation_system, &'animation_finished')): + animation_finished.connect(Callable(animation_system, &'animation_finished'), CONNECT_ONE_SHOT) + + +func _on_about_to_show_text(info:Dictionary) -> void: + full_clear = !info.append + + +func _on_textbox_new_text() -> void: + if DialogicUtil.autoload().Inputs.auto_skip.enabled: + return + + if animation_new_text == AnimationsNewText.NONE: + return + + var animation_system: Node = DialogicUtil.autoload().get(&'Animations') + animation_system.call(&'start_animating') + if full_clear: + get_dialog().text = "" + match animation_new_text: + AnimationsNewText.WIGGLE: + play("new_text") + + if not animation_finished.is_connected(Callable(animation_system, &'animation_finished')): + animation_finished.connect(Callable(animation_system, &'animation_finished'), CONNECT_ONE_SHOT) + + +func _on_animation_interrupted() -> void: + if is_playing(): + stop() diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/animations.gd.uid b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/animations.gd.uid new file mode 100644 index 00000000..1b01eead --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/animations.gd.uid @@ -0,0 +1 @@ +uid://b5q8651der7x0 diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/autoadvance_indicator.gd b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/autoadvance_indicator.gd new file mode 100644 index 00000000..a4384bd6 --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/autoadvance_indicator.gd @@ -0,0 +1,13 @@ +extends Range + +var enabled: bool = true + +func _process(_delta : float) -> void: + if !enabled: + hide() + return + if DialogicUtil.autoload().Inputs.auto_advance.get_progress() < 0: + hide() + else: + show() + value = DialogicUtil.autoload().Inputs.auto_advance.get_progress() diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/autoadvance_indicator.gd.uid b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/autoadvance_indicator.gd.uid new file mode 100644 index 00000000..3fb91151 --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/autoadvance_indicator.gd.uid @@ -0,0 +1 @@ +uid://r2im54tr6xbx diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/custom_visual_novel_textbox.tscn b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/custom_visual_novel_textbox.tscn new file mode 100644 index 00000000..bf45bc5a --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/custom_visual_novel_textbox.tscn @@ -0,0 +1,349 @@ +[gd_scene load_steps=17 format=3 uid="uid://bkycr7efsukaj"] + +[ext_resource type="Script" uid="uid://cyho51h8hmlrh" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd" id="1_bpydr"] +[ext_resource type="Script" uid="uid://b1nyasc86bvlp" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd" id="2_xy7a2"] +[ext_resource type="Script" uid="uid://ddkvkdb6nxtyi" path="res://addons/dialogic/Modules/Text/node_dialog_text.gd" id="3_4634k"] +[ext_resource type="StyleBox" uid="uid://ctw2hju32l3rg" path="res://Resources/Styles/PixelStyleBoxRed.tres" id="3_j47nm"] +[ext_resource type="FontFile" uid="uid://cc3bdt3rt8a1o" path="res://fonts/Silver.ttf" id="4_j47nm"] +[ext_resource type="Script" uid="uid://bkfrnlul8c6cv" path="res://addons/dialogic/Modules/Text/node_type_sound.gd" id="4_ma5mw"] +[ext_resource type="Script" uid="uid://dk0xy5qppo033" path="res://addons/dialogic/Modules/Text/node_next_indicator.gd" id="5_40a50"] +[ext_resource type="Script" uid="uid://cd42pehtw2oq5" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd" id="6_07xym"] +[ext_resource type="Texture2D" uid="uid://b0rpqfg4fhebk" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/next.svg" id="6_uch03"] +[ext_resource type="Script" uid="uid://be3h8wr0w68dx" path="res://addons/dialogic/Modules/Text/node_name_label.gd" id="7_bi7sh"] +[ext_resource type="FontFile" uid="uid://coek1e2q257pq" path="res://fonts/at01.ttf" id="10_j47nm"] + +[sub_resource type="Animation" id="Animation_au0a2"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Anchor/AnimationParent:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Anchor/AnimationParent:rotation") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Anchor/AnimationParent:scale") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(1, 1)] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Anchor/AnimationParent:modulate") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} +tracks/4/type = "bezier" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Anchor/AnimationParent/Sizer/DialogTextPanel:rotation") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="Animation" id="Animation_6kbwc"] +resource_name = "new_text" +length = 0.4 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Anchor/AnimationParent/Sizer/DialogTextPanel:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(3, 3, 3, 3, 3), +"points": PackedFloat32Array(0, -0.025, 0, 0.025, 0, 0.005, -0.025, 0, 0.025, 0, -0.005, -0.025, 0, 0.025, 0, 0.005, -0.025, 0, 0.025, 0, 0, -0.025, 0, 0.025, 0), +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4) +} + +[sub_resource type="Animation" id="Animation_g6k55"] +resource_name = "textbox_fade_up" +length = 0.7 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Anchor/AnimationParent:position") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.3, 0.7), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(0, 50), Vector2(0, 19.6793), Vector2(0, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Anchor/AnimationParent:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0.1, 0.6), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Anchor/AnimationParent:rotation") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Anchor/AnimationParent:scale") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(1, 1)] +} + +[sub_resource type="Animation" id="Animation_htbgc"] +resource_name = "textbox_pop" +length = 0.3 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Anchor/AnimationParent:position") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Anchor/AnimationParent:rotation") +tracks/1/interp = 2 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.2, 0.3), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [-0.0899883, 0.0258223, 0.0] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Anchor/AnimationParent:scale") +tracks/2/interp = 2 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 0.2, 0.3), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(0.793957, 0.778082), Vector2(0.937299, 1.14248), Vector2(1, 1)] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Anchor/AnimationParent:modulate") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_c14kh"] +_data = { +&"RESET": SubResource("Animation_au0a2"), +&"new_text": SubResource("Animation_6kbwc"), +&"textbox_fade_up": SubResource("Animation_g6k55"), +&"textbox_pop": SubResource("Animation_htbgc") +} + +[node name="VN_TextboxLayer" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +script = ExtResource("1_bpydr") +box_panel = "res://Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_default_panel.tres" +box_size = Vector2(550, 150) +name_label_box_panel = "res://Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_name_label_panel.tres" +name_label_box_modulate = Color(0, 0, 0, 1) + +[node name="Animations" type="AnimationPlayer" parent="."] +unique_name_in_owner = true +libraries = { +&"": SubResource("AnimationLibrary_c14kh") +} +autoplay = "RESET" +script = ExtResource("2_xy7a2") + +[node name="Anchor" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 0 + +[node name="AnimationParent" type="Control" parent="Anchor"] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 0 +mouse_filter = 2 + +[node name="Sizer" type="Control" parent="Anchor/AnimationParent"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -150.0 +offset_top = -50.0 +offset_right = 150.0 +grow_horizontal = 2 +grow_vertical = 0 +mouse_filter = 2 + +[node name="DialogTextPanel" type="PanelContainer" parent="Anchor/AnimationParent/Sizer"] +unique_name_in_owner = true +self_modulate = Color(0.00784314, 0.00784314, 0.00784314, 0.843137) +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +theme_override_styles/panel = ExtResource("3_j47nm") +metadata/_edit_layout_mode = 1 + +[node name="DialogicNode_DialogText" type="RichTextLabel" parent="Anchor/AnimationParent/Sizer/DialogTextPanel" node_paths=PackedStringArray("textbox_root")] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 1 +theme_override_colors/default_color = Color(1, 1, 1, 1) +theme_override_constants/line_separation = -8 +theme_override_fonts/normal_font = ExtResource("4_j47nm") +theme_override_font_sizes/bold_italics_font_size = 15 +theme_override_font_sizes/italics_font_size = 15 +theme_override_font_sizes/normal_font_size = 19 +theme_override_font_sizes/bold_font_size = 15 +bbcode_enabled = true +text = "Some default text +on multiple lines +wow so small" +visible_characters_behavior = 1 +script = ExtResource("3_4634k") +textbox_root = NodePath("..") + +[node name="DialogicNode_TypeSounds" type="AudioStreamPlayer" parent="Anchor/AnimationParent/Sizer/DialogTextPanel/DialogicNode_DialogText"] +unique_name_in_owner = true +script = ExtResource("4_ma5mw") +play_every_character = 0 + +[node name="NextIndicator" type="Control" parent="Anchor/AnimationParent/Sizer/DialogTextPanel"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 8 +size_flags_vertical = 8 +mouse_filter = 2 +script = ExtResource("5_40a50") +show_on_questions = true +texture = ExtResource("6_uch03") +metadata/_edit_layout_mode = 1 + +[node name="AutoAdvanceProgressbar" type="ProgressBar" parent="Anchor/AnimationParent/Sizer/DialogTextPanel"] +unique_name_in_owner = true +modulate = Color(1, 1, 1, 0.188235) +custom_minimum_size = Vector2(0, 10) +layout_mode = 2 +size_flags_vertical = 8 +mouse_filter = 2 +max_value = 1.0 +step = 0.001 +value = 0.5 +show_percentage = false +script = ExtResource("6_07xym") + +[node name="NameLabelHolder" type="Control" parent="Anchor/AnimationParent/Sizer/DialogTextPanel"] +layout_mode = 2 +mouse_filter = 2 + +[node name="NameLabelPanel" type="PanelContainer" parent="Anchor/AnimationParent/Sizer/DialogTextPanel/NameLabelHolder"] +unique_name_in_owner = true +self_modulate = Color(0.00784314, 0.00784314, 0.00784314, 0.843137) +layout_mode = 1 +offset_top = -50.0 +offset_right = 49.0 +offset_bottom = -29.0 +mouse_filter = 2 +theme_override_styles/panel = ExtResource("3_j47nm") +metadata/_edit_layout_mode = 1 +metadata/_edit_use_custom_anchors = true +metadata/_edit_group_ = true + +[node name="DialogicNode_NameLabel" type="Label" parent="Anchor/AnimationParent/Sizer/DialogTextPanel/NameLabelHolder/NameLabelPanel" node_paths=PackedStringArray("name_label_root")] +unique_name_in_owner = true +layout_mode = 2 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_constants/line_spacing = -8 +theme_override_fonts/font = ExtResource("10_j47nm") +theme_override_font_sizes/font_size = 16 +text = "Spaghetti" +script = ExtResource("7_bi7sh") +name_label_root = NodePath("..") diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/next.svg b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/next.svg new file mode 100644 index 00000000..ae877a21 --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/next.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/next.svg.import b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/next.svg.import new file mode 100644 index 00000000..30f9ccb1 --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/next.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b03cc8c75mobe" +path="res://.godot/imported/next.svg-a8b4e0073913a2f38d8d8e89ac75e3c0.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/next.svg" +dest_files=["res://.godot/imported/next.svg-a8b4e0073913a2f38d8d8e89ac75e3c0.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_default_panel.tres b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_default_panel.tres new file mode 100644 index 00000000..82974506 --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_default_panel.tres @@ -0,0 +1,12 @@ +[gd_resource type="StyleBoxFlat" format=3 ] + +[resource] +content_margin_left = 15.0 +content_margin_top = 15.0 +content_margin_right = 15.0 +content_margin_bottom = 15.0 +bg_color = Color(1, 1, 1, 1) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_layer.gd b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_layer.gd new file mode 100644 index 00000000..95a4ce3c --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_layer.gd @@ -0,0 +1,278 @@ +@tool +extends DialogicLayoutLayer +## This layer's scene file contains following nodes: +## - a dialog_text node +## - a name_label node +## - a next_indicator node +## - a type_sound node +## +## As well as custom: +## - animations +## - auto-advance progress indicator +## +## If you want to customize this layer, here is a little rundown of this layer: +## The Layer Settings are divided into the `@export_group`s below. +## They get applied in [method _apply_export_overrides]. +## Each `@export_group` has its own method to apply the settings to the scene. +## If you want to change a specific part inside the scene, you can simply +## remove or add # (commenting) to the method line. + + + +enum Alignments {LEFT, CENTER, RIGHT} + +enum AnimationsIn {NONE, POP_IN, FADE_UP} +enum AnimationsOut {NONE, POP_OUT, FADE_DOWN} +enum AnimationsNewText {NONE, WIGGLE} + +@export_group("Text") + +@export_subgroup("Alignment & Size") +@export var text_alignment: Alignments= Alignments.LEFT +@export var text_use_global_size: bool = true +@export var text_size: int = 15 + +@export_subgroup("Color") +@export var text_use_global_color: bool = true +@export var text_custom_color: Color = Color.WHITE + +@export_subgroup('Font') +@export var text_use_global_font: bool = true +@export_file('*.ttf', '*.tres') var normal_font: String = "" +@export_file('*.ttf', '*.tres') var bold_font: String = "" +@export_file('*.ttf', '*.tres') var italics_font: String = "" +@export_file('*.ttf', '*.tres') var bold_italics_font: String = "" + + +@export_group("Box") + +@export_subgroup("Panel") +@export_file("*.tres") var box_panel: String = this_folder.path_join("vn_textbox_default_panel.tres") + +@export_subgroup("Color") +@export var box_color_use_global: bool = true +@export var box_color_custom: Color = Color.BLACK + +@export_subgroup("Size & Position") +@export var box_size: Vector2 = Vector2(550, 110) +@export var box_margin_bottom: int = 15 + +@export_subgroup("Animation") +@export var box_animation_in: AnimationsIn = AnimationsIn.FADE_UP +@export var box_animation_out: AnimationsOut = AnimationsOut.FADE_DOWN +@export var box_animation_new_text: AnimationsNewText = AnimationsNewText.NONE + + +@export_group("Name Label") + +@export_subgroup('Color') +@export var name_label_use_global_color: bool= true +@export var name_label_use_character_color: bool = true +@export var name_label_custom_color: Color = Color.WHITE + +@export_subgroup('Font') +@export var name_label_use_global_font: bool = true +@export_file('*.ttf', '*.tres') var name_label_font: String = "" +@export var name_label_use_global_font_size: bool = true +@export var name_label_custom_font_size: int = 15 + +@export_subgroup('Box') +@export_file("*.tres") var name_label_box_panel: String = this_folder.path_join("vn_textbox_name_label_panel.tres") +@export var name_label_box_use_global_color: bool = true +@export var name_label_box_modulate: Color = box_color_custom + +@export_subgroup('Alignment') +@export var name_label_alignment: Alignments = Alignments.LEFT +@export var name_label_box_offset: Vector2 = Vector2.ZERO + + +@export_group("Indicators") + +@export_subgroup("Next Indicator") +@export var next_indicator_enabled: bool = true +@export var next_indicator_show_on_questions: bool = true +@export var next_indicator_show_on_autoadvance: bool = false +@export_enum('bounce', 'blink', 'none') var next_indicator_animation: int = 0 +@export_file("*.png","*.svg","*.tres") var next_indicator_texture: String = '' +@export var next_indicator_size: Vector2 = Vector2(25,25) + +@export_subgroup("Autoadvance") +@export var autoadvance_progressbar: bool = true + + +@export_group('Sounds') + +@export_subgroup('Typing Sounds') +@export var typing_sounds_enabled: bool = true +@export var typing_sounds_mode: DialogicNode_TypeSounds.Modes = DialogicNode_TypeSounds.Modes.INTERRUPT +@export_dir var typing_sounds_sounds_folder: String = "res://addons/dialogic/Example Assets/sound-effects/" +@export_file("*.wav", "*.ogg", "*.mp3") var typing_sounds_end_sound: String = "" +@export_range(1, 999, 1) var typing_sounds_every_nths_character: int = 1 +@export_range(0.01, 4, 0.01) var typing_sounds_pitch: float = 1.0 +@export_range(0.0, 3.0) var typing_sounds_pitch_variance: float = 0.0 +@export_range(-80, 24, 0.01) var typing_sounds_volume: float = -10 +@export_range(0.0, 10) var typing_sounds_volume_variance: float = 0.0 +@export var typing_sounds_ignore_characters: String = " .,!?" + + +func _apply_export_overrides() -> void: + if !is_inside_tree(): + await ready + + ## FONT SETTINGS + _apply_text_settings() + + + ## BOX SETTINGS + _apply_box_settings() + + ## BOX ANIMATIONS + _apply_box_animations_settings() + + ## NAME LABEL SETTINGS + _apply_name_label_settings() + + ## NEXT INDICATOR SETTINGS + _apply_indicator_settings() + + ## OTHER + var progress_bar: ProgressBar = %AutoAdvanceProgressbar + progress_bar.set(&'enabled', autoadvance_progressbar) + + #### SOUNDS + + ## TYPING SOUNDS + _apply_sounds_settings() + + +## Applies all text box settings to the scene. +## Except the box animations. +func _apply_box_settings() -> void: + var dialog_text_panel: PanelContainer = %DialogTextPanel + if ResourceLoader.exists(box_panel): + dialog_text_panel.add_theme_stylebox_override(&'panel', load(box_panel) as StyleBox) + + if box_color_use_global: + dialog_text_panel.self_modulate = get_global_setting(&'bg_color', box_color_custom) + else: + dialog_text_panel.self_modulate = box_color_custom + + var sizer: Control = %Sizer + sizer.size = box_size + sizer.position = box_size * Vector2(-0.5, -1)+Vector2(0, -box_margin_bottom) + + +## Applies box animations settings to the scene. +func _apply_box_animations_settings() -> void: + var animations: AnimationPlayer = %Animations + animations.set(&'animation_in', box_animation_in) + animations.set(&'animation_out', box_animation_out) + animations.set(&'animation_new_text', box_animation_new_text) + + +## Applies all name label settings to the scene. +func _apply_name_label_settings() -> void: + var name_label: DialogicNode_NameLabel = %DialogicNode_NameLabel + + if name_label_use_global_font_size: + name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_font_size) as int) + else: + name_label.add_theme_font_size_override(&"font_size", name_label_custom_font_size) + + if name_label_use_global_font and get_global_setting(&'font', false): + name_label.add_theme_font_override(&'font', load(get_global_setting(&'font', '') as String) as Font) + elif not name_label_font.is_empty(): + name_label.add_theme_font_override(&'font', load(name_label_font) as Font) + + if name_label_use_global_color: + name_label.add_theme_color_override(&"font_color", get_global_setting(&'font_color', name_label_custom_color) as Color) + else: + name_label.add_theme_color_override(&"font_color", name_label_custom_color) + + name_label.use_character_color = name_label_use_character_color + + var name_label_panel: PanelContainer = %NameLabelPanel + if ResourceLoader.exists(name_label_box_panel): + name_label_panel.add_theme_stylebox_override(&'panel', load(name_label_box_panel) as StyleBox) + else: + name_label_panel.add_theme_stylebox_override(&'panel', load(this_folder.path_join("vn_textbox_name_label_panel.tres")) as StyleBox) + + if name_label_box_use_global_color: + name_label_panel.self_modulate = get_global_setting(&'bg_color', name_label_box_modulate) + else: + name_label_panel.self_modulate = name_label_box_modulate + var dialog_text_panel: PanelContainer = %DialogTextPanel + name_label_panel.position = name_label_box_offset+Vector2(0, -40) + name_label_panel.position -= Vector2( + dialog_text_panel.get_theme_stylebox(&'panel', &'PanelContainer').content_margin_left, + dialog_text_panel.get_theme_stylebox(&'panel', &'PanelContainer').content_margin_top) + name_label_panel.anchor_left = name_label_alignment/2.0 + name_label_panel.anchor_right = name_label_alignment/2.0 + name_label_panel.grow_horizontal = [1, 2, 0][name_label_alignment] + + +## Applies all text settings to the scene. +func _apply_text_settings() -> void: + var dialog_text: DialogicNode_DialogText = %DialogicNode_DialogText + dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment + + if text_use_global_size: + text_size = get_global_setting(&'font_size', text_size) + dialog_text.add_theme_font_size_override(&"normal_font_size", text_size) + dialog_text.add_theme_font_size_override(&"bold_font_size", text_size) + dialog_text.add_theme_font_size_override(&"italics_font_size", text_size) + dialog_text.add_theme_font_size_override(&"bold_italics_font_size", text_size) + + if text_use_global_color: + dialog_text.add_theme_color_override(&"default_color", get_global_setting(&'font_color', text_custom_color) as Color) + else: + dialog_text.add_theme_color_override(&"default_color", text_custom_color) + + if text_use_global_font and get_global_setting(&'font', false): + dialog_text.add_theme_font_override(&"normal_font", load(get_global_setting(&'font', '') as String) as Font) + elif !normal_font.is_empty(): + dialog_text.add_theme_font_override(&"normal_font", load(normal_font) as Font) + if !bold_font.is_empty(): + dialog_text.add_theme_font_override(&"bold_font", load(bold_font) as Font) + if !italics_font.is_empty(): + dialog_text.add_theme_font_override(&"italics_font", load(italics_font) as Font) + if !bold_italics_font.is_empty(): + dialog_text.add_theme_font_override(&"bold_italics_font", load(bold_italics_font) as Font) + + +## Applies all indicator settings to the scene. +func _apply_indicator_settings() -> void: + var next_indicator: DialogicNode_NextIndicator = %NextIndicator + next_indicator.enabled = next_indicator_enabled + + if next_indicator_enabled: + next_indicator.animation = next_indicator_animation as DialogicNode_NextIndicator.Animations + if ResourceLoader.exists(next_indicator_texture): + next_indicator.texture = load(next_indicator_texture) + next_indicator.show_on_questions = next_indicator_show_on_questions + next_indicator.show_on_autoadvance = next_indicator_show_on_autoadvance + next_indicator.texture_size = next_indicator_size + + +## Applies all sound settings to the scene. +func _apply_sounds_settings() -> void: + var type_sounds: DialogicNode_TypeSounds = %DialogicNode_TypeSounds + type_sounds.enabled = typing_sounds_enabled + type_sounds.mode = typing_sounds_mode + + if not typing_sounds_sounds_folder.is_empty(): + type_sounds.sounds = DialogicNode_TypeSounds.load_sounds_from_path(typing_sounds_sounds_folder) + else: + type_sounds.sounds.clear() + + if not typing_sounds_end_sound.is_empty(): + type_sounds.end_sound = load(typing_sounds_end_sound) + else: + type_sounds.end_sound = null + + type_sounds.play_every_character = typing_sounds_every_nths_character + type_sounds.base_pitch = typing_sounds_pitch + type_sounds.base_volume = typing_sounds_volume + type_sounds.pitch_variance = typing_sounds_pitch_variance + type_sounds.volume_variance = typing_sounds_volume_variance + type_sounds.ignore_characters = typing_sounds_ignore_characters diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_layer.gd.uid b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_layer.gd.uid new file mode 100644 index 00000000..ce3f7c49 --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_layer.gd.uid @@ -0,0 +1 @@ +uid://c0ry5ux16ah84 diff --git a/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_name_label_panel.tres b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_name_label_panel.tres new file mode 100644 index 00000000..417ac4b8 --- /dev/null +++ b/Resources/Styles/VN_Dialogue_Box/VisualNovelTextbox/vn_textbox_name_label_panel.tres @@ -0,0 +1,12 @@ +[gd_resource type="StyleBoxFlat" format=3 ] + +[resource] +content_margin_left = 10.0 +content_margin_top = 5.0 +content_margin_right = 10.0 +content_margin_bottom = 5.0 +bg_color = Color(1, 1, 1, 1) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 diff --git a/Resources/Styles/vn_textbox_cirno_panel.tres b/Resources/Styles/vn_textbox_cirno_panel.tres new file mode 100644 index 00000000..9e264f86 --- /dev/null +++ b/Resources/Styles/vn_textbox_cirno_panel.tres @@ -0,0 +1,12 @@ +[gd_resource type="StyleBoxFlat" format=3 uid="uid://cmyqabrx5pm7o"] + +[resource] +content_margin_left = 4.0 +content_margin_top = 4.0 +content_margin_right = 4.0 +content_margin_bottom = 4.0 +bg_color = Color(1, 1, 1, 1) +corner_radius_top_left = 2 +corner_radius_top_right = 2 +corner_radius_bottom_right = 2 +corner_radius_bottom_left = 2