mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-14 03:05:54 +00:00
Updated dialogic
This commit is contained in:
parent
1d11462073
commit
cbb82512ee
483 changed files with 5743 additions and 2177 deletions
|
|
@ -1 +1 @@
|
|||
uid://0uxoslmpurip
|
||||
uid://cs2o12y1i6cti
|
||||
|
|
|
|||
|
|
@ -9,7 +9,12 @@ extends Control
|
|||
@onready var name_label_box: PanelContainer = (%NameLabelPanel as PanelContainer)
|
||||
@onready var name_label_holder: HBoxContainer = $DialogText/NameLabelPositioner
|
||||
|
||||
var node_to_point_at: Node = null
|
||||
var node_to_point_at: Node = null:
|
||||
set(val):
|
||||
node_to_point_at = val
|
||||
base_position = get_speaker_canvas_position() + base_direction * safe_zone
|
||||
position = base_position
|
||||
|
||||
var current_character: DialogicCharacter = null
|
||||
|
||||
var max_width := 300
|
||||
|
|
@ -36,13 +41,14 @@ func _ready() -> void:
|
|||
|
||||
|
||||
func reset() -> void:
|
||||
set_process(false)
|
||||
scale = Vector2.ZERO
|
||||
modulate.a = 0.0
|
||||
|
||||
tail.points = []
|
||||
bubble_rect = Rect2(0,0,2,2)
|
||||
|
||||
base_position = get_speaker_canvas_position()
|
||||
base_position = get_speaker_canvas_position() + base_direction * safe_zone
|
||||
position = base_position
|
||||
|
||||
|
||||
|
|
@ -106,7 +112,7 @@ func close() -> void:
|
|||
|
||||
|
||||
func _on_dialog_text_started_revealing_text() -> void:
|
||||
_resize_bubble(get_base_content_size(), true)
|
||||
_resize_bubble(await get_base_content_size(), true)
|
||||
|
||||
|
||||
func _resize_bubble(content_size:Vector2, popup:=false) -> void:
|
||||
|
|
@ -137,25 +143,43 @@ func _on_question_shown(info:Dictionary) -> void:
|
|||
if !is_visible_in_tree():
|
||||
return
|
||||
|
||||
await get_tree().process_frame
|
||||
# Avoid choice_container's flickering(because some ticks will happen in
|
||||
# `await get_base_content_size()` which will make choice_container exist
|
||||
# at its old position for several tens of milliseconds).
|
||||
choice_container.modulate.a = 0
|
||||
|
||||
var content_size := get_base_content_size()
|
||||
var content_size := await get_base_content_size()
|
||||
content_size.y += choice_container.size.y
|
||||
content_size.x = max(content_size.x, choice_container.size.x)
|
||||
_resize_bubble(content_size)
|
||||
|
||||
# Now, choice_container has changed to its new position, so we can make it
|
||||
# actually show up.
|
||||
choice_container.modulate.a = 1
|
||||
|
||||
|
||||
func get_base_content_size() -> Vector2:
|
||||
var font: Font = text.get_theme_font(&"normal_font")
|
||||
return font.get_multiline_string_size(
|
||||
var text_width = font.get_multiline_string_size(
|
||||
text.get_parsed_text(),
|
||||
HORIZONTAL_ALIGNMENT_LEFT,
|
||||
max_width,
|
||||
text.get_theme_font_size(&"normal_font_size")
|
||||
)
|
||||
).x
|
||||
|
||||
# Let text use content's width, and let text auto shrink height to its content.
|
||||
text.size = Vector2(text_width, 0)
|
||||
await get_tree().process_frame
|
||||
|
||||
# Don't know why text.size.y != content's height,
|
||||
# so we re-set text.size.y to 0 to let text shrink to its content again.
|
||||
# Finally works this time.
|
||||
text.size.y = 0
|
||||
await get_tree().process_frame
|
||||
return text.size
|
||||
|
||||
|
||||
func add_choice_container(node:Container, alignment:=FlowContainer.ALIGNMENT_BEGIN) -> void:
|
||||
func add_choice_container(node:Container, alignment:=FlowContainer.ALIGNMENT_BEGIN, choices_button_path:="", maximum_choices:=5) -> void:
|
||||
if choice_container:
|
||||
choice_container.get_parent().remove_child(choice_container)
|
||||
choice_container.queue_free()
|
||||
|
|
@ -168,9 +192,21 @@ func add_choice_container(node:Container, alignment:=FlowContainer.ALIGNMENT_BEG
|
|||
|
||||
if node is HFlowContainer:
|
||||
(node as HFlowContainer).alignment = alignment
|
||||
|
||||
var choices_button: PackedScene = null
|
||||
if not choices_button_path.is_empty():
|
||||
if ResourceLoader.exists(choices_button_path):
|
||||
choices_button = (load(choices_button_path) as PackedScene)
|
||||
else:
|
||||
printerr("[Dialogic] Unable to load custom choice button from ", choices_button_path)
|
||||
|
||||
for i:int in range(5):
|
||||
choice_container.add_child(DialogicNode_ChoiceButton.new())
|
||||
for i:int in range(maximum_choices):
|
||||
var new_button : DialogicNode_ChoiceButton
|
||||
if choices_button == null:
|
||||
new_button = DialogicNode_ChoiceButton.new()
|
||||
else:
|
||||
new_button = (choices_button.instantiate() as DialogicNode_ChoiceButton)
|
||||
choice_container.add_child(new_button)
|
||||
if node is HFlowContainer:
|
||||
continue
|
||||
match alignment:
|
||||
|
|
@ -200,3 +236,11 @@ func get_speaker_canvas_position() -> Vector2:
|
|||
if node_to_point_at is CanvasItem:
|
||||
base_position = (node_to_point_at as CanvasItem).get_global_transform_with_canvas().origin
|
||||
return base_position
|
||||
|
||||
|
||||
## Changes the property of mouse filter of the bubble and its children (text and label).
|
||||
func change_mouse_filter(mouse_filter: Control.MouseFilter) -> void:
|
||||
mouse_filter = mouse_filter
|
||||
text.mouse_filter = mouse_filter
|
||||
name_label_box.mouse_filter = mouse_filter
|
||||
name_label_holder.mouse_filter = mouse_filter
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://cgs1ywlncs4t8
|
||||
uid://bminl7x3r40vc
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://cdw3feu6lc4yp
|
||||
uid://byskpb7ypvuab
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
[gd_scene load_steps=11 format=3 uid="uid://dlx7jcvm52tyw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cgs1ywlncs4t8" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd" id="1_jdhpk"]
|
||||
[ext_resource type="Shader" uid="uid://cdw3feu6lc4yp" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gdshader" id="2_1mhvf"]
|
||||
[ext_resource type="Script" uid="uid://ddkvkdb6nxtyi" path="res://addons/dialogic/Modules/Text/node_dialog_text.gd" id="3_syv35"]
|
||||
[ext_resource type="Script" uid="uid://bkfrnlul8c6cv" path="res://addons/dialogic/Modules/Text/node_type_sound.gd" id="4_7bm4b"]
|
||||
[ext_resource type="Script" uid="uid://be3h8wr0w68dx" path="res://addons/dialogic/Modules/Text/node_name_label.gd" id="6_5gd03"]
|
||||
[ext_resource type="Script" uid="uid://bminl7x3r40vc" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd" id="1_jdhpk"]
|
||||
[ext_resource type="Shader" uid="uid://byskpb7ypvuab" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gdshader" id="2_1mhvf"]
|
||||
[ext_resource type="Script" uid="uid://drhfq6rmdeuri" path="res://addons/dialogic/Modules/Text/node_dialog_text.gd" id="3_syv35"]
|
||||
[ext_resource type="Script" uid="uid://dpv2dfiv5dhmr" path="res://addons/dialogic/Modules/Text/node_type_sound.gd" id="4_7bm4b"]
|
||||
[ext_resource type="Script" uid="uid://bak74s0kcr0ao" path="res://addons/dialogic/Modules/Text/node_name_label.gd" id="6_5gd03"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_0j8nu"]
|
||||
_data = [Vector2(0, 1), 0.0, -1.0, 0, 1, Vector2(1, 0), -1.0, 0.0, 1, 0]
|
||||
|
|
@ -79,6 +79,7 @@ offset_bottom = 12.0
|
|||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_colors/default_color = Color(0, 0, 0, 1)
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
visible_characters_behavior = 1
|
||||
script = ExtResource("3_syv35")
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ extends DialogicLayoutLayer
|
|||
@export_subgroup('Behaviour')
|
||||
@export var behaviour_distance: int = 50
|
||||
@export var behaviour_direction: Vector2 = Vector2(1, -1)
|
||||
@export var behaviour_mouse_filter: Control.MouseFilter
|
||||
|
||||
@export_group('Name Label')
|
||||
@export_subgroup("Name Label")
|
||||
|
|
@ -55,6 +56,10 @@ extends DialogicLayoutLayer
|
|||
@export var choices_layout_force_lines: bool = false
|
||||
@export_file('*.tres', "*.res") var choices_base_theme: String = ""
|
||||
|
||||
@export_subgroup('Behavior')
|
||||
@export var maximum_choices: int = 5
|
||||
@export_file('*.tscn') var choices_custom_button: String = ""
|
||||
|
||||
const TextBubble := preload("res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd")
|
||||
|
||||
var bubbles: Array[TextBubble] = []
|
||||
|
|
@ -93,7 +98,7 @@ func bubble_apply_overrides(bubble:TextBubble) -> void:
|
|||
if !bold_font.is_empty():
|
||||
rtl.add_theme_font_override(&"bold_font", load(bold_font) as Font)
|
||||
if !italic_font.is_empty():
|
||||
rtl.add_theme_font_override(&"italitc_font", load(italic_font) as Font)
|
||||
rtl.add_theme_font_override(&"italics_font", load(italic_font) as Font)
|
||||
if !bold_italic_font.is_empty():
|
||||
rtl.add_theme_font_override(&"bold_italics_font", load(bold_italic_font) as Font)
|
||||
bubble.set(&'max_width', text_max_width)
|
||||
|
|
@ -118,6 +123,7 @@ func bubble_apply_overrides(bubble:TextBubble) -> void:
|
|||
## BEHAVIOUR
|
||||
bubble.safe_zone = behaviour_distance
|
||||
bubble.base_direction = behaviour_direction
|
||||
bubble.change_mouse_filter(behaviour_mouse_filter)
|
||||
|
||||
|
||||
## NAME LABEL SETTINGS
|
||||
|
|
@ -148,9 +154,9 @@ func bubble_apply_overrides(bubble:TextBubble) -> void:
|
|||
|
||||
## CHOICE SETTINGS
|
||||
if choices_layout_force_lines:
|
||||
bubble.add_choice_container(VBoxContainer.new(), choices_layout_alignment)
|
||||
bubble.add_choice_container(VBoxContainer.new(), choices_layout_alignment, choices_custom_button, maximum_choices)
|
||||
else:
|
||||
bubble.add_choice_container(HFlowContainer.new(), choices_layout_alignment)
|
||||
bubble.add_choice_container(HFlowContainer.new(), choices_layout_alignment, choices_custom_button, maximum_choices)
|
||||
|
||||
var choice_theme: Theme = null
|
||||
if choices_base_theme.is_empty() or not ResourceLoader.exists(choices_base_theme):
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
uid://b0npb8ibpyhbx
|
||||
uid://dcae6nsh8fgtp
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://d2it0xiap3gnt"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b0npb8ibpyhbx" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd" id="1_b37je"]
|
||||
[ext_resource type="Script" uid="uid://dcae6nsh8fgtp" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd" id="1_b37je"]
|
||||
|
||||
[node name="TextBubbleLayer" type="Control"]
|
||||
layout_mode = 3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue