Dialogic textbox

This commit is contained in:
MaddoScientisto 2025-03-17 21:52:41 +01:00
commit 4226891235
25 changed files with 497 additions and 55 deletions

View file

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3 uid="uid://ch1q7fv72saii"]
[ext_resource type="Script" uid="uid://bcowue6w1sdxs" path="res://addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd" id="1_ifsho"]
[node name="DefaultLayoutBase" type="CanvasLayer"]
script = ExtResource("1_ifsho")
global_font = "uid://cc3bdt3rt8a1o"
global_font_size = 19

View file

@ -0,0 +1,19 @@
@tool
extends DialogicLayoutBase
## The default layout base scene.
@export var canvas_layer: int = 1
@export var follow_viewport: bool = false
@export_subgroup("Global")
@export var global_bg_color: Color = Color(0, 0, 0, 0.9)
@export var global_font_color: Color = Color("white")
@export_file('*.ttf', '*.tres') var global_font: String = ""
@export var global_font_size: int = 18
func _apply_export_overrides() -> void:
# apply layer
set(&'layer', canvas_layer)
set(&'follow_viewport_enabled', follow_viewport)

View file

@ -0,0 +1 @@
uid://bwvf4nl2tw8tl

View file

@ -0,0 +1,105 @@
[gd_scene load_steps=17 format=3 uid="uid://c88rhk1uktibh"]
[ext_resource type="Script" uid="uid://bcowue6w1sdxs" path="res://addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd" id="1_ifsho"]
[ext_resource type="PackedScene" uid="uid://c1k5m0w3r40xf" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn" id="2_4ap2k"]
[ext_resource type="Script" uid="uid://c7frh5xu7x34r" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd" id="3_t6u6x"]
[ext_resource type="PackedScene" uid="uid://cn674foxwedqu" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Input/full_advance_input_layer.tscn" id="4_dtw0c"]
[ext_resource type="Script" uid="uid://bqc33k65j5ioy" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Input/full_advance_input_layer.gd" id="5_ixcfc"]
[ext_resource type="PackedScene" uid="uid://by6waso0mjpjp" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/textbox_with_speaker_portrait.tscn" id="6_2i86k"]
[ext_resource type="Script" uid="uid://dmxeo7lm8ftsi" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd" id="7_vwcvu"]
[ext_resource type="PackedScene" uid="uid://dsbwnp5hegnu3" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.tscn" id="8_vlnng"]
[ext_resource type="Script" uid="uid://dbbd73i5odrjs" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd" id="9_puffk"]
[ext_resource type="PackedScene" uid="uid://dhk6j6eb6e3q" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.tscn" id="10_15qnt"]
[ext_resource type="Script" uid="uid://c8we4ppbftu0e" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd" id="11_cnlur"]
[ext_resource type="PackedScene" uid="uid://cvgf4c6gg0tsy" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.tscn" id="12_2f1ul"]
[ext_resource type="Script" uid="uid://i5l4pdftho0h" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd" id="13_pitac"]
[ext_resource type="PackedScene" uid="uid://lx24i8fl6uo" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn" id="14_nj00e"]
[ext_resource type="Script" uid="uid://jlhgg7cs1iap" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd" id="15_dj8ph"]
[ext_resource type="PackedScene" uid="uid://cuoywrmvda1yg" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_History/example_history_item.tscn" id="16_8capi"]
[node name="Custom" type="CanvasLayer"]
script = ExtResource("1_ifsho")
global_font = "uid://cc3bdt3rt8a1o"
global_font_size = 19
[node name="BackgroundLayer" type="Control" parent="." instance=ExtResource("2_4ap2k")]
layout_direction = 2
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("3_t6u6x")
apply_overrides_on_ready = true
[node name="FullAdvanceInputLayer" type="Control" parent="." instance=ExtResource("4_dtw0c")]
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("5_ixcfc")
apply_overrides_on_ready = true
[node name="TextboxWithSpeakerPortrait" type="Control" parent="." instance=ExtResource("6_2i86k")]
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("7_vwcvu")
text_custom_size = 6
name_label_custom_size = 10
box_panel = "res://Resources/Styles/PixelStyleBoxRed_SquareBackground.tres"
box_size = Vector2(300, 80)
box_distance = 0
apply_overrides_on_ready = true
[node name="Glossary" type="Control" parent="." instance=ExtResource("8_vlnng")]
layout_mode = 3
anchors_preset = 0
mouse_filter = 2
script = ExtResource("9_puffk")
apply_overrides_on_ready = true
[node name="VN_ChoiceLayer" type="Control" parent="." instance=ExtResource("10_15qnt")]
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("11_cnlur")
apply_overrides_on_ready = true
[node name="TextInputLayer" type="Control" parent="." instance=ExtResource("12_2f1ul")]
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("13_pitac")
apply_overrides_on_ready = true
[node name="ExampleHistoryScene" type="Control" parent="." instance=ExtResource("14_nj00e")]
layout_direction = 1
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
mouse_filter = 2
script = ExtResource("15_dj8ph")
HistoryItem = ExtResource("16_8capi")
apply_overrides_on_ready = true

View file

@ -0,0 +1,10 @@
[gd_resource type="LabelSettings" load_steps=2 format=3 uid="uid://ct4jf3wlfmc4w"]
[ext_resource type="FontFile" uid="uid://cc3bdt3rt8a1o" path="res://fonts/Silver.ttf" id="1_y5rfn"]
[resource]
line_spacing = 1.0
font = ExtResource("1_y5rfn")
font_size = 19
outline_size = 4
outline_color = Color(0, 0, 0, 1)

View file

@ -0,0 +1,131 @@
[gd_scene load_steps=8 format=3 uid="uid://cx6y8bri11i6d"]
[ext_resource type="Script" uid="uid://cfcx0of1aekhk" path="res://addons/dialogic/Modules/Character/node_portrait_container.gd" id="1_4jxq7"]
[ext_resource type="Script" uid="uid://dmxeo7lm8ftsi" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd" id="1_7jt4d"]
[ext_resource type="Script" uid="uid://be3h8wr0w68dx" path="res://addons/dialogic/Modules/Text/node_name_label.gd" id="2_y0h34"]
[ext_resource type="Script" uid="uid://ddkvkdb6nxtyi" path="res://addons/dialogic/Modules/Text/node_dialog_text.gd" id="3_11puy"]
[ext_resource type="FontFile" uid="uid://cc3bdt3rt8a1o" path="res://fonts/Silver.ttf" id="4_5grjp"]
[ext_resource type="Script" uid="uid://bkfrnlul8c6cv" path="res://addons/dialogic/Modules/Text/node_type_sound.gd" id="5_sr2qw"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dmg1w"]
bg_color = Color(0.254902, 0.254902, 0.254902, 1)
skew = Vector2(0.073, 0)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
[node name="TextboxWithSpeakerPortrait" 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_7jt4d")
text_custom_size = 19
box_panel = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/default_stylebox.tres"
[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
mouse_filter = 2
[node name="Panel" type="PanelContainer" parent="Anchor"]
unique_name_in_owner = true
self_modulate = Color(0.533333, 0.376471, 0.176471, 1)
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -250.0
offset_top = -200.0
offset_right = 250.0
offset_bottom = -50.0
grow_horizontal = 2
grow_vertical = 0
mouse_filter = 2
[node name="HBox" type="HBoxContainer" parent="Anchor/Panel"]
layout_mode = 2
mouse_filter = 2
theme_override_constants/separation = 15
[node name="PortraitPanel" type="Panel" parent="Anchor/Panel/HBox"]
unique_name_in_owner = true
clip_children = 1
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.3
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_dmg1w")
[node name="PortraitBackgroundColor" type="ColorRect" parent="Anchor/Panel/HBox/PortraitPanel"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -7.0
offset_top = -3.0
offset_right = 7.0
offset_bottom = 3.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
color = Color(0, 0, 0, 0.231373)
[node name="DialogicNode_PortraitContainer" type="Control" parent="Anchor/Panel/HBox/PortraitPanel/PortraitBackgroundColor"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = 4.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
script = ExtResource("1_4jxq7")
mode = 1
container_ids = PackedStringArray("1")
[node name="VBoxContainer" type="VBoxContainer" parent="Anchor/Panel/HBox"]
layout_mode = 2
size_flags_horizontal = 3
mouse_filter = 2
theme_override_constants/separation = -6
[node name="DialogicNode_NameLabel" type="Label" parent="Anchor/Panel/HBox/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/line_spacing = -8
theme_override_fonts/font = ExtResource("4_5grjp")
theme_override_font_sizes/font_size = 19
text = "Name"
script = ExtResource("2_y0h34")
[node name="DialogicNode_DialogText" type="RichTextLabel" parent="Anchor/Panel/HBox/VBoxContainer" node_paths=PackedStringArray("textbox_root")]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/line_separation = -8
theme_override_fonts/normal_font = ExtResource("4_5grjp")
theme_override_font_sizes/normal_font_size = 19
bbcode_enabled = true
text = "Some text
on two lines"
scroll_following = true
visible_characters_behavior = 1
script = ExtResource("3_11puy")
textbox_root = NodePath("../../..")
[node name="DialogicNode_TypeSounds" type="AudioStreamPlayer" parent="Anchor/Panel/HBox/VBoxContainer/DialogicNode_DialogText"]
script = ExtResource("5_sr2qw")

View file

@ -0,0 +1,129 @@
@tool
extends DialogicLayoutLayer
enum Alignments {LEFT, CENTER, RIGHT}
enum LimitedAlignments {LEFT=0, RIGHT=1}
@export_group('Text')
@export_subgroup("Text")
@export var text_alignment: Alignments = Alignments.LEFT
@export_subgroup('Size')
@export var text_use_global_size: bool = true
@export var text_custom_size: int = 15
@export_subgroup('Color')
@export var text_use_global_color: bool = true
@export var text_custom_color: Color = Color.WHITE
@export_subgroup('Fonts')
@export var use_global_fonts: bool = true
@export_file('*.ttf', '*.tres') var custom_normal_font: String = ""
@export_file('*.ttf', '*.tres') var custom_bold_font: String = ""
@export_file('*.ttf', '*.tres') var custom_italic_font: String = ""
@export_file('*.ttf', '*.tres') var custom_bold_italic_font: String = ""
@export_group('Name Label')
@export_subgroup("Color")
enum NameLabelColorModes {GLOBAL_COLOR, CHARACTER_COLOR, CUSTOM_COLOR}
@export var name_label_color_mode: NameLabelColorModes = NameLabelColorModes.GLOBAL_COLOR
@export var name_label_custom_color: Color = Color.WHITE
@export_subgroup("Behaviour")
@export var name_label_alignment: Alignments = Alignments.LEFT
@export var name_label_hide_when_no_character: bool = false
@export_subgroup("Font & Size")
@export var name_label_use_global_size: bool = true
@export var name_label_custom_size: int = 15
@export var name_label_use_global_font: bool = true
@export_file('*.ttf', '*.tres') var name_label_customfont: String = ""
@export_group('Box')
@export_subgroup("Box")
@export_file('*.tres') var box_panel: String = this_folder.path_join("default_stylebox.tres")
@export var box_modulate_global_color: bool = true
@export var box_modulate_custom_color: Color = Color(0.47247135639191, 0.31728461384773, 0.16592600941658)
@export var box_size: Vector2 = Vector2(600, 160)
@export var box_distance: int = 25
@export_group('Portrait')
@export_subgroup('Portrait')
@export var portrait_stretch_factor: float = 0.3
@export var portrait_position: LimitedAlignments = LimitedAlignments.LEFT
@export var portrait_bg_modulate: Color = Color(0, 0, 0, 0.5137255191803)
## Called by dialogic whenever export overrides might change
func _apply_export_overrides() -> void:
## FONT SETTINGS
var dialog_text: DialogicNode_DialogText = %DialogicNode_DialogText
dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment
var text_size: int = text_custom_size
if text_use_global_size:
text_size = get_global_setting(&'font_size', text_custom_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)
var text_color: Color = text_custom_color
if text_use_global_color:
text_color = get_global_setting(&'font_color', text_custom_color)
dialog_text.add_theme_color_override(&"default_color", text_color)
var normal_font: String = custom_normal_font
if use_global_fonts and ResourceLoader.exists(get_global_setting(&'font', '') as String):
normal_font = get_global_setting(&'font', '')
if !normal_font.is_empty():
dialog_text.add_theme_font_override(&"normal_font", load(normal_font) as Font)
if !custom_bold_font.is_empty():
dialog_text.add_theme_font_override(&"bold_font", load(custom_bold_font) as Font)
if !custom_italic_font.is_empty():
dialog_text.add_theme_font_override(&"italics_font", load(custom_italic_font) as Font)
if !custom_bold_italic_font.is_empty():
dialog_text.add_theme_font_override(&"bold_italics_font", load(custom_bold_italic_font) as Font)
## BOX SETTINGS
var panel: PanelContainer = %Panel
var portrait_panel: Panel = %PortraitPanel
if box_modulate_global_color:
panel.self_modulate = get_global_setting(&'bg_color', box_modulate_custom_color)
else:
panel.self_modulate = box_modulate_custom_color
panel.size = box_size
panel.position = Vector2(-box_size.x/2, -box_size.y-box_distance)
portrait_panel.size_flags_stretch_ratio = portrait_stretch_factor
var stylebox: StyleBox = load(box_panel)
panel.add_theme_stylebox_override(&'panel', stylebox)
## PORTRAIT SETTINGS
var portrait_background_color: ColorRect = %PortraitBackgroundColor
portrait_background_color.color = portrait_bg_modulate
portrait_panel.get_parent().move_child(portrait_panel, portrait_position)
## NAME LABEL SETTINGS
var name_label: DialogicNode_NameLabel = %DialogicNode_NameLabel
if name_label_use_global_size:
name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_size) as int)
else:
name_label.add_theme_font_size_override(&"font_size", name_label_custom_size)
var name_label_font: String = name_label_customfont
if name_label_use_global_font and ResourceLoader.exists(get_global_setting(&'font', '') as String):
name_label_font = get_global_setting(&'font', '')
if !name_label_font.is_empty():
name_label.add_theme_font_override(&'font', load(name_label_font) as Font)
name_label.use_character_color = false
match name_label_color_mode:
NameLabelColorModes.GLOBAL_COLOR:
name_label.add_theme_color_override(&"font_color", get_global_setting(&'font_color', name_label_custom_color) as Color)
NameLabelColorModes.CUSTOM_COLOR:
name_label.add_theme_color_override(&"font_color", name_label_custom_color)
NameLabelColorModes.CHARACTER_COLOR:
name_label.use_character_color = true
name_label.horizontal_alignment = name_label_alignment as HorizontalAlignment
name_label.hide_when_empty = name_label_hide_when_no_character

View file

@ -0,0 +1,12 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://d1vblh0fnhuhf"]
[resource]
content_margin_left = 10.0
content_margin_top = 10.0
content_margin_right = 10.0
content_margin_bottom = 10.0
bg_color = Color(1, 1, 1, 1)
corner_radius_top_left = 10
corner_radius_top_right = 10
corner_radius_bottom_right = 10
corner_radius_bottom_left = 10