Skip to content

Commit

Permalink
Added bbcode ghost effect from Godot docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nagidev committed Oct 2, 2023
1 parent 32e0b66 commit 925577a
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 39 deletions.
19 changes: 12 additions & 7 deletions addons/dialogue_nodes/NodeEditor.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=3 uid="uid://bqscglixmr4bd"]
[gd_scene load_steps=22 format=3 uid="uid://bqscglixmr4bd"]

[ext_resource type="Script" path="res://addons/dialogue_nodes/editor/editor.gd" id="1"]
[ext_resource type="Script" path="res://addons/dialogue_nodes/editor/graph.gd" id="2"]
Expand All @@ -18,10 +18,14 @@
[ext_resource type="Texture2D" uid="uid://cf5ef41yo6jl6" path="res://addons/dialogue_nodes/icons/Reload.svg" id="11_ku5xd"]
[ext_resource type="Texture2D" uid="uid://buayifvickq2l" path="res://addons/dialogue_nodes/icons/Folder.svg" id="12_tk1td"]
[ext_resource type="Script" path="res://addons/dialogue_nodes/objects/bbcodeWait.gd" id="15_kpna5"]
[ext_resource type="Script" path="res://addons/dialogue_nodes/objects/bbcodeGhost.gd" id="19_7vkda"]

[sub_resource type="RichTextEffect" id="RichTextEffect_3vpbk"]
[sub_resource type="RichTextEffect" id="RichTextEffect_orqxx"]
script = ExtResource("15_kpna5")

[sub_resource type="RichTextEffect" id="RichTextEffect_ynero"]
script = ExtResource("19_7vkda")

[node name="NodeEditor" type="Control"]
custom_minimum_size = Vector2(0, 300)
layout_mode = 3
Expand Down Expand Up @@ -272,14 +276,14 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -343.5
offset_top = -127.0
offset_right = 343.5
offset_bottom = 127.0
offset_left = -320.0
offset_top = -128.0
offset_right = 320.0
offset_bottom = 128.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("5")
custom_effects = Array[RichTextEffect]([SubResource("RichTextEffect_3vpbk")])
custom_effects = Array[RichTextEffect]([SubResource("RichTextEffect_orqxx"), SubResource("RichTextEffect_ynero")])

[connection signal="about_to_popup" from="Main/ToolBar/RunMenu" to="." method="_update_run_menu"]
[connection signal="node_added" from="Main/Workspace" to="." method="_on_node_added"]
Expand Down Expand Up @@ -308,6 +312,7 @@ custom_effects = Array[RichTextEffect]([SubResource("RichTextEffect_3vpbk")])
[connection signal="disconnection_request" from="Main/Workspace/Graph" to="Main/Workspace/Graph" method="_on_modified"]
[connection signal="duplicate_nodes_request" from="Main/Workspace/Graph" to="Main/Workspace" method="_on_nodes_duplicated"]
[connection signal="duplicate_nodes_request" from="Main/Workspace/Graph" to="Main/Workspace/Graph" method="_on_modified"]
[connection signal="end_node_move" from="Main/Workspace/Graph" to="Main/Workspace/Graph" method="_on_modified"]
[connection signal="modified" from="Main/Workspace/Graph" to="Main/Workspace" method="_on_file_modified"]
[connection signal="popup_request" from="Main/Workspace/Graph" to="Main/Workspace" method="show_menu"]
[connection signal="visibility_changed" from="Main/Workspace/Graph" to="." method="_on_graph_visibility_changed"]
Expand Down
13 changes: 13 additions & 0 deletions addons/dialogue_nodes/objects/bbcodeGhost.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@tool
extends RichTextEffect
class_name RichTextGhost

var bbcode = "ghost"

func _process_custom_fx(char_fx):
var speed = char_fx.env.get("freq", 5.0)
var span = char_fx.env.get("span", 10.0)

var alpha = sin(char_fx.elapsed_time * speed + (char_fx.range.x / span)) * 0.5 + 0.5
char_fx.color.a = alpha
return true
5 changes: 4 additions & 1 deletion addons/dialogue_nodes/objects/dialogueBox.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ signal variable_changed(var_name, value)
@export_enum('Begin', 'Center', 'End') var options_alignment = 2: set = _set_options_alignment
@export var skip_input_action := 'ui_cancel'
@export var next_icon := preload("res://addons/dialogue_nodes/icons/Play.svg")
@export var custom_effects : Array[RichTextEffect] = [RichTextWait.new()]
@export var custom_effects : Array[RichTextEffect] = [
RichTextWait.new(),
RichTextGhost.new()
]

var speaker : Label
var portrait : TextureRect
Expand Down
2 changes: 1 addition & 1 deletion examples/Demo.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[ext_resource type="Script" path="res://examples/demo.gd" id="2"]
[ext_resource type="Resource" uid="uid://dj818hys8f3u8" path="res://examples/ExampleBasic.tres" id="3_r2hw0"]
[ext_resource type="Theme" uid="uid://dc6c1peo4pfyr" path="res://addons/dialogue_nodes/themes/bubbly.theme" id="4"]
[ext_resource type="Resource" path="res://examples/ExampleBBCodes.tres" id="4_hv77k"]
[ext_resource type="Resource" uid="uid://btriowhsx04c2" path="res://examples/ExampleBBCodes.tres" id="4_hv77k"]
[ext_resource type="Resource" uid="uid://bjme2drtas671" path="res://examples/ExampleBranching.tres" id="5_quhw6"]
[ext_resource type="Resource" uid="uid://c303qivlsn30t" path="res://examples/ExampleCharacters.tres" id="6_ncvoa"]
[ext_resource type="Resource" uid="uid://b4os1qum2hx0x" path="res://examples/ExampleSignals.tres" id="7_sjqsf"]
Expand Down
51 changes: 25 additions & 26 deletions examples/ExampleBBCodes.tres
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
[gd_resource type="Resource" load_steps=2 format=2]
[gd_resource type="Resource" script_class="DialogueData" load_steps=2 format=3 uid="uid://btriowhsx04c2"]

[ext_resource path="res://addons/dialogue_nodes/objects/DialogueData.gd" type="Script" id=1]
[ext_resource type="Script" path="res://addons/dialogue_nodes/objects/DialogueData.gd" id="1"]

[resource]
script = ExtResource( 1 )
script = ExtResource("1")
starts = {
"START": "0_1"
"START": &"0_1"
}
nodes = {
"0_1": {
"link": "1_1",
"offset": Vector2( 0, 0 ),
"link": &"1_1",
"offset": Vector2(0, 0),
"start_id": "START"
},
"1_1": {
"dialogue": "Wanna learn about [u]bbcodes[/u]?",
"offset": Vector2( 220, 0 ),
"offset": Vector2(220, 0),
"options": {
0: {
"link": "1_3",
"link": &"1_3",
"text": "Yeah!"
},
1: {
"link": "1_2",
"link": &"1_2",
"text": "Nah"
}
},
"size": {
"x": 200.0,
"y": 282.0
"y": 289.0
},
"speaker": "Greg"
},
"1_2": {
"dialogue": "[shake]Oh... too bad...[/shake]",
"offset": Vector2( 460, 280 ),
"offset": Vector2(460, 280),
"options": {
"0": {
"link": "END",
Expand All @@ -43,31 +43,31 @@ nodes = {
},
"size": {
"x": 200.0,
"y": 255.0
"y": 261.0
},
"speaker": "Greg"
},
"1_3": {
"dialogue": "You can write special keywords between [ ] for different effects.",
"offset": Vector2( 460, 0 ),
"offset": Vector2(460, 0),
"options": {
0: {
"link": "1_4",
"link": &"1_4",
"text": ""
}
},
"size": {
"x": 200.0,
"y": 255.0
"y": 261.0
},
"speaker": "Greg"
},
"1_4": {
"dialogue": "Like u for [u]underlining[/u] or [fade length=5]fade[/fade] or [color=red]color=red[/color] or [rainbow]rainbow[/rainbow] or [shake]shake[/shake] or [wave]wave[/wave] or [tornado]tornado[/tornado]",
"offset": Vector2( 700, 0 ),
"dialogue": "Like u for [u]underlining[/u] or [fade start=26 length=4]fade[/fade] or [color=red]color=red[/color] or [rainbow]rainbow[/rainbow] or [shake]shake[/shake] or [wave]wave[/wave] or [tornado]tornado[/tornado]",
"offset": Vector2(700, 0),
"options": {
0: {
"link": "1_5",
"link": &"1_5",
"text": ""
}
},
Expand All @@ -80,13 +80,13 @@ nodes = {
"1_5": {
"dialogue": "You can even combine two or more effects to create [rainbow][wave]EVEN MORE AWESOME EFFECTS![/wave][/rainbow]
Usage: [effect1] [effect2] text goes here [/effect2] [/effect1]",
"offset": Vector2( 1200, 0 ),
"offset": Vector2(1200, 0),
"options": {
1: {
"link": "1_3",
0: {
"link": &"1_3",
"text": "One more time?"
},
"0": {
"1": {
"link": "END",
"text": "Got it!"
}
Expand All @@ -98,8 +98,7 @@ Usage: [effect1] [effect2] text goes here [/effect2] [/effect1]",
"speaker": "Greg"
}
}
variables = {
}
comments = [ ]
strays = [ ]
variables = {}
comments = Array[String]([])
strays = Array[String]([])
characters = ""
8 changes: 4 additions & 4 deletions examples/ExampleVariables.tres
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Current value: {{COINS}}
},
"1_7": {
"dialogue": "Like right now you have more than 5 coins!",
"offset": Vector2(1540, 260),
"offset": Vector2(1600, 260),
"options": {
0: {
"link": &"1_9",
Expand All @@ -129,13 +129,13 @@ Current value: {{COINS}}
},
"size": {
"x": 200.0,
"y": 261.0
"y": 250.447
},
"speaker": "Greg"
},
"1_8": {
"dialogue": "I can tell you don't have more than 5 coins...",
"offset": Vector2(1540, 500),
"offset": Vector2(1600, 540),
"options": {
0: {
"link": &"1_9",
Expand All @@ -150,7 +150,7 @@ Current value: {{COINS}}
},
"1_9": {
"dialogue": "Feel free to look at the example files to learn how to do it yourself!",
"offset": Vector2(1800, 320),
"offset": Vector2(1900, 260),
"options": {
0: {
"link": &"1_2",
Expand Down

0 comments on commit 925577a

Please sign in to comment.