First work on dialogic, resized guild, and started implementing portraits.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
[style]
|
||||
type = "Layout Base"
|
||||
name = "Textbubble Base"
|
||||
author = "Dialogic"
|
||||
description = "A base scene for the textbubble style. Expects a textbubble layer."
|
||||
scene = "text_bubble_base.tscn"
|
||||
@@ -0,0 +1,94 @@
|
||||
@tool
|
||||
extends DialogicLayoutBase
|
||||
|
||||
## This layout won't do anything on its own
|
||||
|
||||
var bubbles: Array = []
|
||||
var registered_characters: Dictionary = {}
|
||||
|
||||
@export_group("Main")
|
||||
@export_range(1, 25, 1) var bubble_count: int = 2
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
|
||||
DialogicUtil.autoload().Text.about_to_show_text.connect(_on_dialogic_text_event)
|
||||
$Example/CRT.position = $Example.get_viewport_rect().size/2
|
||||
|
||||
if not has_node('TextBubbleLayer'):
|
||||
return
|
||||
|
||||
if len(bubbles) < bubble_count:
|
||||
add_bubble()
|
||||
|
||||
|
||||
func register_character(character:Variant, node:Node):
|
||||
if typeof(character) == TYPE_STRING:
|
||||
var character_string: String = character
|
||||
if character.begins_with("res://"):
|
||||
character = load(character)
|
||||
else:
|
||||
character = DialogicResourceUtil.get_character_resource(character)
|
||||
if not character:
|
||||
printerr("[Dialogic] Textbubble: Tried registering character from invalid string '", character_string, "'.")
|
||||
|
||||
registered_characters[character] = node
|
||||
if len(registered_characters) > len(bubbles) and len(bubbles) < bubble_count:
|
||||
add_bubble()
|
||||
|
||||
|
||||
func _get_persistent_info() -> Dictionary:
|
||||
return {"textbubble_registers": registered_characters}
|
||||
|
||||
|
||||
func _load_persistent_info(info: Dictionary) -> void:
|
||||
var register_info: Dictionary = info.get("textbubble_registers", {})
|
||||
for character in register_info:
|
||||
if is_instance_valid(register_info[character]):
|
||||
register_character(character, register_info[character])
|
||||
|
||||
|
||||
func add_bubble() -> void:
|
||||
if not has_node('TextBubbleLayer'):
|
||||
return
|
||||
|
||||
var new_bubble: Control = get_node("TextBubbleLayer").add_bubble()
|
||||
bubbles.append(new_bubble)
|
||||
|
||||
|
||||
func _on_dialogic_text_event(info:Dictionary):
|
||||
var bubble_to_use: Node
|
||||
for bubble in bubbles:
|
||||
if bubble.current_character == info.character:
|
||||
bubble_to_use = bubble
|
||||
|
||||
if bubble_to_use == null:
|
||||
for bubble in bubbles:
|
||||
if bubble.current_character == null:
|
||||
bubble_to_use = bubble
|
||||
|
||||
if bubble_to_use == null:
|
||||
bubble_to_use = bubbles[0]
|
||||
|
||||
var node_to_point_at: Node
|
||||
if info.character in registered_characters:
|
||||
node_to_point_at = registered_characters[info.character]
|
||||
$Example.hide()
|
||||
else:
|
||||
node_to_point_at = $Example/CRT/Marker
|
||||
$Example.show()
|
||||
|
||||
bubble_to_use.current_character = info.character
|
||||
bubble_to_use.node_to_point_at = node_to_point_at
|
||||
bubble_to_use.reset()
|
||||
if has_node('TextBubbleLayer'):
|
||||
get_node("TextBubbleLayer").bubble_apply_overrides(bubble_to_use)
|
||||
bubble_to_use.open()
|
||||
|
||||
## Now close other bubbles
|
||||
for bubble in bubbles:
|
||||
if bubble != bubble_to_use:
|
||||
bubble.close()
|
||||
bubble.current_character = null
|
||||
@@ -0,0 +1 @@
|
||||
uid://b8sku3tbf1hoq
|
||||
@@ -0,0 +1,55 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://syki6k0e6aac"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Modules/DefaultLayoutParts/Base_TextBubble/text_bubble_base.gd" id="1_urqwc"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_70ljh"]
|
||||
content_margin_left = 5.0
|
||||
content_margin_top = 5.0
|
||||
content_margin_right = 5.0
|
||||
content_margin_bottom = 5.0
|
||||
bg_color = Color(0, 0, 0, 0.654902)
|
||||
|
||||
[node name="TextBubbleHolder" type="CanvasLayer"]
|
||||
script = ExtResource("1_urqwc")
|
||||
|
||||
[node name="Example" type="Control" parent="."]
|
||||
visible = false
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Label" type="RichTextLabel" parent="Example"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 12.0
|
||||
offset_top = -235.0
|
||||
offset_right = 835.0
|
||||
offset_bottom = -14.0
|
||||
grow_vertical = 0
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_70ljh")
|
||||
bbcode_enabled = true
|
||||
text = "This is a fallback bubble, that is not actually connected to any character. In game use the following code to add speech bubbles to a character:
|
||||
[color=darkgray]
|
||||
var layout = Dialogic.start(timeline_path)
|
||||
layout.register_character(character_resource, node)
|
||||
[/color]
|
||||
- [color=lightblue]character_resource[/color] should be a loaded DialogicCharacter (a .dch file).
|
||||
- [color=lightblue]node[/color] should be the 2D or 3D node the bubble should point at.
|
||||
-> E.g. [color=darkgray]layout.register_character(load(\"res://path/to/my/character.dch\"), $BubbleMarker)"
|
||||
|
||||
[node name="CRT" type="ColorRect" parent="Example"]
|
||||
layout_mode = 0
|
||||
offset_left = 504.0
|
||||
offset_top = 290.0
|
||||
offset_right = 540.0
|
||||
offset_bottom = 324.0
|
||||
rotation = 0.785397
|
||||
color = Color(1, 0.313726, 1, 1)
|
||||
|
||||
[node name="Marker" type="Marker2D" parent="Example/CRT"]
|
||||
position = Vector2(10.6066, 9.1924)
|
||||
Reference in New Issue
Block a user