First work on dialogic, resized guild, and started implementing portraits.

This commit is contained in:
2025-08-14 10:26:24 -04:00
parent 95a7db036b
commit 3aeb3d44e6
959 changed files with 47688 additions and 46 deletions

View File

@@ -0,0 +1,105 @@
@tool
## Event that can change the currently playing background music.
## This event won't play new music if it's already playing.
class_name DialogicMusicEvent
extends DialogicEvent
### Settings
## The file to play. If empty, the previous music will be faded out.
var file_path := "":
set(value):
if file_path != value:
file_path = value
ui_update_needed.emit()
## The channel to use.
var channel_id: int = 0
## The length of the fade. If 0 (by default) it's an instant change.
var fade_length: float = 0
## The volume the music will be played at.
var volume: float = 0
## The audio bus the music will be played at.
var audio_bus := ""
## If true, the audio will loop, otherwise only play once.
var loop := true
################################################################################
## EXECUTE
################################################################################
func _execute() -> void:
if not dialogic.Audio.is_music_playing_resource(file_path, channel_id):
dialogic.Audio.update_music(file_path, volume, audio_bus, fade_length, loop, channel_id)
finish()
################################################################################
## INITIALIZE
################################################################################
func _init() -> void:
event_name = "Music"
set_default_color('Color7')
event_category = "Audio"
event_sorting_index = 2
func _get_icon() -> Resource:
return load(self.get_script().get_path().get_base_dir().path_join('icon_music.png'))
################################################################################
## SAVING/LOADING
################################################################################
func get_shortcode() -> String:
return "music"
func get_shortcode_parameters() -> Dictionary:
return {
#param_name : property_info
"path" : {"property": "file_path", "default": ""},
"channel" : {"property": "channel_id", "default": 0},
"fade" : {"property": "fade_length", "default": 0},
"volume" : {"property": "volume", "default": 0},
"bus" : {"property": "audio_bus", "default": "",
"suggestions": get_bus_suggestions},
"loop" : {"property": "loop", "default": true},
}
################################################################################
## EDITOR REPRESENTATION
################################################################################
func build_event_editor() -> void:
add_header_edit('file_path', ValueType.FILE, {
'left_text' : 'Play',
'file_filter' : "*.mp3, *.ogg, *.wav; Supported Audio Files",
'placeholder' : "No music",
'editor_icon' : ["AudioStreamPlayer", "EditorIcons"]})
add_header_edit('channel_id', ValueType.FIXED_OPTIONS, {'left_text':'on:', 'options': get_channel_list()})
add_header_edit('file_path', ValueType.AUDIO_PREVIEW)
add_body_edit('fade_length', ValueType.NUMBER, {'left_text':'Fade Time:'})
add_body_edit('volume', ValueType.NUMBER, {'left_text':'Volume:', 'mode':2}, '!file_path.is_empty()')
add_body_edit('audio_bus', ValueType.SINGLELINE_TEXT, {'left_text':'Audio Bus:'}, '!file_path.is_empty()')
add_body_edit('loop', ValueType.BOOL, {'left_text':'Loop:'}, '!file_path.is_empty() and not file_path.to_lower().ends_with(".wav")')
func get_bus_suggestions() -> Dictionary:
var bus_name_list := {}
for i in range(AudioServer.bus_count):
bus_name_list[AudioServer.get_bus_name(i)] = {'value':AudioServer.get_bus_name(i)}
return bus_name_list
func get_channel_list() -> Array:
var channel_name_list := []
for i in ProjectSettings.get_setting('dialogic/audio/max_channels', 4):
channel_name_list.append({
'label': 'Channel %s' % (i + 1),
'value': i,
})
return channel_name_list

View File

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

View File

@@ -0,0 +1,86 @@
@tool
class_name DialogicSoundEvent
extends DialogicEvent
## Event that allows to play a sound effect. Requires the Audio subsystem!
### Settings
## The path to the file to play.
var file_path := "":
set(value):
if file_path != value:
file_path = value
ui_update_needed.emit()
## The volume to play the sound at.
var volume: float = 0
## The bus to play the sound on.
var audio_bus := ""
## If true, the sound will loop infinitely. Not recommended (as there is no way to stop it).
var loop := false
################################################################################
## EXECUTE
################################################################################
func _execute() -> void:
dialogic.Audio.play_sound(file_path, volume, audio_bus, loop)
finish()
################################################################################
## INITIALIZE
################################################################################
func _init() -> void:
event_name = "Sound"
set_default_color('Color7')
event_category = "Audio"
event_sorting_index = 3
help_page_path = "https://dialogic.coppolaemilio.com"
func _get_icon() -> Resource:
return load(self.get_script().get_path().get_base_dir().path_join('icon_sound.png'))
################################################################################
## SAVING/LOADING
################################################################################
func get_shortcode() -> String:
return "sound"
func get_shortcode_parameters() -> Dictionary:
return {
#param_name : property_name
"path" : {"property": "file_path", "default": "",},
"volume" : {"property": "volume", "default": 0},
"bus" : {"property": "audio_bus", "default": "",
"suggestions": get_bus_suggestions},
"loop" : {"property": "loop", "default": false},
}
################################################################################
## EDITOR REPRESENTATION
################################################################################
func build_event_editor() -> void:
add_header_edit('file_path', ValueType.FILE,
{'left_text' : 'Play',
'file_filter' : '*.mp3, *.ogg, *.wav; Supported Audio Files',
'placeholder' : "Select file",
'editor_icon' : ["AudioStreamPlayer", "EditorIcons"]})
add_header_edit('file_path', ValueType.AUDIO_PREVIEW)
add_body_edit('volume', ValueType.NUMBER, {'left_text':'Volume:', 'mode':2}, '!file_path.is_empty()')
add_body_edit('audio_bus', ValueType.SINGLELINE_TEXT, {'left_text':'Audio Bus:'}, '!file_path.is_empty()')
func get_bus_suggestions() -> Dictionary:
var bus_name_list := {}
for i in range(AudioServer.bus_count):
bus_name_list[AudioServer.get_bus_name(i)] = {'value':AudioServer.get_bus_name(i)}
return bus_name_list

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://buvpjsvdt4evk"
path="res://.godot/imported/icon_music.png-ffc971ba1265164a55f745186974be5f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/dialogic/Modules/Audio/icon_music.png"
dest_files=["res://.godot/imported/icon_music.png-ffc971ba1265164a55f745186974be5f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d3ookrkto0yh6"
path="res://.godot/imported/icon_sound.png-7a1a8a5533773d97969b6311b6a9133f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/dialogic/Modules/Audio/icon_sound.png"
dest_files=["res://.godot/imported/icon_sound.png-7a1a8a5533773d97969b6311b6a9133f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

View File

@@ -0,0 +1,14 @@
@tool
extends DialogicIndexer
func _get_events() -> Array:
return [this_folder.path_join('event_music.gd'), this_folder.path_join('event_sound.gd')]
func _get_subsystems() -> Array:
return [{'name':'Audio', 'script':this_folder.path_join('subsystem_audio.gd')}]
func _get_settings_pages() -> Array:
return [this_folder.path_join('settings_audio.tscn')]

View File

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

View File

@@ -0,0 +1,32 @@
@tool
extends DialogicSettingsPage
## Settings page that contains settings for the audio subsystem
const MUSIC_MAX_CHANNELS := "dialogic/audio/max_channels"
const TYPE_SOUND_AUDIO_BUS := "dialogic/audio/type_sound_bus"
func _ready() -> void:
%MusicChannelCount.value_changed.connect(_on_music_channel_count_value_changed)
%TypeSoundBus.item_selected.connect(_on_type_sound_bus_item_selected)
func _refresh() -> void:
%MusicChannelCount.value = ProjectSettings.get_setting(MUSIC_MAX_CHANNELS, 4)
%TypeSoundBus.clear()
var idx := 0
for i in range(AudioServer.bus_count):
%TypeSoundBus.add_item(AudioServer.get_bus_name(i))
if AudioServer.get_bus_name(i) == ProjectSettings.get_setting(TYPE_SOUND_AUDIO_BUS, ""):
idx = i
%TypeSoundBus.select(idx)
func _on_music_channel_count_value_changed(value:float) -> void:
ProjectSettings.set_setting(MUSIC_MAX_CHANNELS, value)
ProjectSettings.save()
func _on_type_sound_bus_item_selected(index:int) -> void:
ProjectSettings.set_setting(TYPE_SOUND_AUDIO_BUS, %TypeSoundBus.get_item_text(index))
ProjectSettings.save()

View File

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

View File

@@ -0,0 +1,54 @@
[gd_scene load_steps=3 format=3 uid="uid://c2qgetjc3mfo3"]
[ext_resource type="Script" path="res://addons/dialogic/Modules/Audio/settings_audio.gd" id="1_2iyyr"]
[ext_resource type="PackedScene" uid="uid://dbpkta2tjsqim" path="res://addons/dialogic/Editor/Common/hint_tooltip_icon.tscn" id="2_o1ban"]
[node name="Audio" type="VBoxContainer"]
offset_right = 121.0
offset_bottom = 58.0
script = ExtResource("1_2iyyr")
[node name="Label" type="Label" parent="."]
layout_mode = 2
theme_type_variation = &"DialogicSettingsSection"
text = "Music Channels"
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="Label" type="Label" parent="HBoxContainer"]
layout_mode = 2
text = "Max music channels"
[node name="HintTooltip" parent="HBoxContainer" instance=ExtResource("2_o1ban")]
layout_mode = 2
texture = null
hint_text = "Lowering this value may invalidate existing music events!"
[node name="MusicChannelCount" type="SpinBox" parent="HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
min_value = 1.0
value = 1.0
[node name="TypingSoundsTitle" type="Label" parent="."]
layout_mode = 2
theme_type_variation = &"DialogicSettingsSection"
text = "Typing Sounds"
[node name="HBoxContainer2" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="Label" type="Label" parent="HBoxContainer2"]
layout_mode = 2
text = "Audio Bus"
[node name="HintTooltip" parent="HBoxContainer2" instance=ExtResource("2_o1ban")]
layout_mode = 2
tooltip_text = "Lowering this value may invalidate existing music events!"
texture = null
hint_text = "The default audio bus used by TypeSound nodes."
[node name="TypeSoundBus" type="OptionButton" parent="HBoxContainer2"]
unique_name_in_owner = true
layout_mode = 2

View File

@@ -0,0 +1,219 @@
extends DialogicSubsystem
## Subsystem for managing background music and one-shot sound effects.
##
## This subsystem has many different helper methods for managing audio
## in your timeline.
## For instance, you can listen to music changes via [signal music_started].
## Whenever a new background music is started, this signal is emitted and
## contains a dictionary with the following keys: [br]
## [br]
## Key | Value Type | Value [br]
## ----------- | ------------- | ----- [br]
## `path` | [type String] | The path to the audio resource file. [br]
## `volume` | [type float] | The volume of the audio resource that will be set to the [member base_music_player]. [br]
## `audio_bus` | [type String] | The audio bus name that the [member base_music_player] will use. [br]
## `loop` | [type bool] | Whether the audio resource will loop or not once it finishes playing. [br]
## `channel` | [type int] | The channel ID to play the audio on. [br]
signal music_started(info: Dictionary)
## Whenever a new sound effect is set, this signal is emitted and contains a
## dictionary with the following keys: [br]
## [br]
## Key | Value Type | Value [br]
## ----------- | ------------- | ----- [br]
## `path` | [type String] | The path to the audio resource file. [br]
## `volume` | [type float] | The volume of the audio resource that will be set to [member base_sound_player]. [br]
## `audio_bus` | [type String] | The audio bus name that the [member base_sound_player] will use. [br]
## `loop` | [type bool] | Whether the audio resource will loop or not once it finishes playing. [br]
signal sound_started(info: Dictionary)
var max_channels: int:
set(value):
if max_channels != value:
max_channels = value
ProjectSettings.set_setting('dialogic/audio/max_channels', value)
ProjectSettings.save()
current_music_player.resize(value)
get:
return ProjectSettings.get_setting('dialogic/audio/max_channels', 4)
## Audio player base duplicated to play background music.
##
## Background music is long audio.
var base_music_player := AudioStreamPlayer.new()
## Reference to the last used music player.
var current_music_player: Array[AudioStreamPlayer] = []
## Audio player base, that will be duplicated to play sound effects.
##
## Sound effects are short audio.
var base_sound_player := AudioStreamPlayer.new()
#region STATE
####################################################################################################
## Clears the state on this subsystem and stops all audio.
##
## If you want to stop sounds only, use [method stop_all_sounds].
func clear_game_state(_clear_flag := DialogicGameHandler.ClearFlags.FULL_CLEAR) -> void:
for idx in max_channels:
update_music('', 0.0, '', 0.0, true, idx)
stop_all_sounds()
## Loads the state on this subsystem from the current state info.
func load_game_state(load_flag:=LoadFlags.FULL_LOAD) -> void:
if load_flag == LoadFlags.ONLY_DNODES:
return
var info: Dictionary = dialogic.current_state_info.get("music", {})
if not info.is_empty() and info.has('path'):
update_music(info.path, info.volume, info.audio_bus, 0, info.loop, 0)
else:
for channel_id in info.keys():
if info[channel_id].is_empty() or info[channel_id].path.is_empty():
update_music('', 0.0, '', 0.0, true, channel_id)
else:
update_music(info[channel_id].path, info[channel_id].volume, info[channel_id].audio_bus, 0, info[channel_id].loop, channel_id)
## Pauses playing audio.
func pause() -> void:
for child in get_children():
child.stream_paused = true
## Resumes playing audio.
func resume() -> void:
for child in get_children():
child.stream_paused = false
func _on_dialogic_timeline_ended() -> void:
if not dialogic.Styles.get_layout_node():
clear_game_state()
pass
#endregion
#region MAIN METHODS
####################################################################################################
func _ready() -> void:
dialogic.timeline_ended.connect(_on_dialogic_timeline_ended)
base_music_player.name = "Music"
add_child(base_music_player)
base_sound_player.name = "Sound"
add_child(base_sound_player)
current_music_player.resize(max_channels)
## Updates the background music. Will fade out previous music.
func update_music(path := "", volume := 0.0, audio_bus := "", fade_time := 0.0, loop := true, channel_id := 0) -> void:
if channel_id > max_channels:
printerr("\tChannel ID (%s) higher than Max Music Channels (%s)" % [channel_id, max_channels])
dialogic.print_debug_moment()
return
if not dialogic.current_state_info.has('music'):
dialogic.current_state_info['music'] = {}
dialogic.current_state_info['music'][channel_id] = {'path':path, 'volume':volume, 'audio_bus':audio_bus, 'loop':loop, 'channel':channel_id}
music_started.emit(dialogic.current_state_info['music'][channel_id])
var fader: Tween = null
if is_instance_valid(current_music_player[channel_id]) and current_music_player[channel_id].playing or !path.is_empty():
fader = create_tween()
var prev_node: Node = null
if is_instance_valid(current_music_player[channel_id]) and current_music_player[channel_id].playing:
prev_node = current_music_player[channel_id]
fader.tween_method(interpolate_volume_linearly.bind(prev_node), db_to_linear(prev_node.volume_db),0.0,fade_time)
if path:
current_music_player[channel_id] = base_music_player.duplicate()
add_child(current_music_player[channel_id])
current_music_player[channel_id].stream = load(path)
current_music_player[channel_id].volume_db = volume
if audio_bus:
current_music_player[channel_id].bus = audio_bus
if not current_music_player[channel_id].stream is AudioStreamWAV:
if "loop" in current_music_player[channel_id].stream:
current_music_player[channel_id].stream.loop = loop
elif "loop_mode" in current_music_player[channel_id].stream:
if loop:
current_music_player[channel_id].stream.loop_mode = AudioStreamWAV.LOOP_FORWARD
else:
current_music_player[channel_id].stream.loop_mode = AudioStreamWAV.LOOP_DISABLED
current_music_player[channel_id].play(0)
fader.parallel().tween_method(interpolate_volume_linearly.bind(current_music_player[channel_id]), 0.0, db_to_linear(volume),fade_time)
if prev_node:
fader.tween_callback(prev_node.queue_free)
## Whether music is playing.
func has_music(channel_id := 0) -> bool:
return !dialogic.current_state_info.get('music', {}).get(channel_id, {}).get('path', '').is_empty()
## Plays a given sound file.
func play_sound(path: String, volume := 0.0, audio_bus := "", loop := false) -> void:
if base_sound_player != null and !path.is_empty():
sound_started.emit({'path':path, 'volume':volume, 'audio_bus':audio_bus, 'loop':loop})
var new_sound_node := base_sound_player.duplicate()
new_sound_node.name += "Sound"
new_sound_node.stream = load(path)
if "loop" in new_sound_node.stream:
new_sound_node.stream.loop = loop
elif "loop_mode" in new_sound_node.stream:
if loop:
new_sound_node.stream.loop_mode = AudioStreamWAV.LOOP_FORWARD
else:
new_sound_node.stream.loop_mode = AudioStreamWAV.LOOP_DISABLED
new_sound_node.volume_db = volume
if audio_bus:
new_sound_node.bus = audio_bus
add_child(new_sound_node)
new_sound_node.play()
new_sound_node.finished.connect(new_sound_node.queue_free)
## Stops all audio.
func stop_all_sounds() -> void:
for node in get_children():
if node == base_sound_player:
continue
if "Sound" in node.name:
node.queue_free()
## Converts a linear loudness value to decibel and sets that volume to
## the given [param node].
func interpolate_volume_linearly(value: float, node: Node) -> void:
node.volume_db = linear_to_db(value)
## Returns whether the currently playing audio resource is the same as this
## event's [param resource_path], for [param channel_id].
func is_music_playing_resource(resource_path: String, channel_id := 0) -> bool:
var is_playing_resource: bool = (current_music_player.size() > channel_id
and is_instance_valid(current_music_player[channel_id])
and current_music_player[channel_id].is_playing()
and current_music_player[channel_id].stream.resource_path == resource_path)
return is_playing_resource
#endregion

View File

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

View File

@@ -0,0 +1,27 @@
extends DialogicBackground
## The default background scene.
## Extend the DialogicBackground class to create your own background scene.
@onready var image_node: TextureRect = $Image
@onready var color_node: ColorRect = $ColorRect
func _ready() -> void:
image_node.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
image_node.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_COVERED
image_node.anchor_right = 1
image_node.anchor_bottom = 1
func _update_background(argument:String, _time:float) -> void:
if argument.begins_with('res://'):
image_node.texture = load(argument)
color_node.color = Color.TRANSPARENT
elif argument.is_valid_html_color():
image_node.texture = null
color_node.color = Color(argument, 1)
else:
image_node.texture = null
color_node.color = Color.from_string(argument, Color.TRANSPARENT)

View File

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

View File

@@ -0,0 +1,29 @@
[gd_scene load_steps=2 format=3 uid="uid://cl6g6ymkhjven"]
[ext_resource type="Script" path="res://addons/dialogic/Modules/Background/DefaultBackgroundScene/default_background.gd" id="1_nkdrp"]
[node name="DefaultBackground" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_nkdrp")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Image" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 0

View File

@@ -0,0 +1,7 @@
extends "res://addons/dialogic/Modules/Background/Transitions/simple_push_transitions.gd"
func _fade() -> void:
var shader := setup_push_shader()
shader.set_shader_parameter('final_offset', Vector2.DOWN)
tween_shader_progress().set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)

View File

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

View File

@@ -0,0 +1,7 @@
extends "res://addons/dialogic/Modules/Background/Transitions/simple_push_transitions.gd"
func _fade() -> void:
var shader := setup_push_shader()
shader.set_shader_parameter('final_offset', Vector2.LEFT)
tween_shader_progress().set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)

View File

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

View File

@@ -0,0 +1,7 @@
extends "res://addons/dialogic/Modules/Background/Transitions/simple_push_transitions.gd"
func _fade() -> void:
var shader := setup_push_shader()
shader.set_shader_parameter('final_offset', Vector2.RIGHT)
tween_shader_progress().set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)

View File

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

View File

@@ -0,0 +1,7 @@
extends "res://addons/dialogic/Modules/Background/Transitions/simple_push_transitions.gd"
func _fade() -> void:
var shader := setup_push_shader()
shader.set_shader_parameter('final_offset', Vector2.UP)
tween_shader_progress().set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)

View File

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

View File

@@ -0,0 +1,13 @@
extends DialogicBackgroundTransition
func _fade() -> void:
var shader := set_shader()
shader.set_shader_parameter("wipe_texture", load(this_folder.path_join("simple_fade.tres")))
shader.set_shader_parameter("feather", 1)
shader.set_shader_parameter("previous_background", prev_texture)
shader.set_shader_parameter("next_background", next_texture)
tween_shader_progress()

View File

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

View File

@@ -0,0 +1,8 @@
[gd_resource type="GradientTexture2D" load_steps=2 format=3 uid="uid://qak7mr560k0i"]
[sub_resource type="Gradient" id="Gradient_skd6w"]
offsets = PackedFloat32Array(1)
colors = PackedColorArray(0.423651, 0.423651, 0.423651, 1)
[resource]
gradient = SubResource("Gradient_skd6w")

View File

@@ -0,0 +1,8 @@
extends "res://addons/dialogic/Modules/Background/Transitions/simple_swipe_transitions.gd"
func _fade() -> void:
var shader := setup_swipe_shader()
var texture: GradientTexture2D = shader.get_shader_parameter('wipe_texture')
texture.fill_from = Vector2.DOWN
texture.fill_to = Vector2.RIGHT
tween_shader_progress()

View File

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

View File

@@ -0,0 +1,10 @@
extends "res://addons/dialogic/Modules/Background/Transitions/simple_swipe_transitions.gd"
func _fade() -> void:
var shader := setup_swipe_shader()
var texture: GradientTexture2D = shader.get_shader_parameter('wipe_texture')
texture.fill_from = Vector2.ZERO
texture.fill_to = Vector2.RIGHT
tween_shader_progress()

View File

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

View File

@@ -0,0 +1,8 @@
extends "res://addons/dialogic/Modules/Background/Transitions/simple_swipe_transitions.gd"
func _fade() -> void:
var shader := setup_swipe_shader()
var texture: GradientTexture2D = shader.get_shader_parameter('wipe_texture')
texture.fill_from = Vector2.RIGHT
texture.fill_to = Vector2.ZERO
tween_shader_progress()

View File

@@ -0,0 +1 @@
uid://7e4qyyr6wnuo

View File

@@ -0,0 +1,56 @@
class_name DialogicBackgroundTransition
extends Node
## Helper
var this_folder: String = get_script().resource_path.get_base_dir()
## Set before _fade() is called, will be the root node of the previous bg scene.
var prev_scene: Node
## Set before _fade() is called, will be the viewport texture of the previous bg scene.
var prev_texture: ViewportTexture
## Set before _fade() is called, will be the root node of the upcoming bg scene.
var next_scene: Node
## Set before _fade() is called, will be the viewport texture of the upcoming bg scene.
var next_texture: ViewportTexture
## Set before _fade() is called, will be the requested time for the fade
var time: float
## Set before _fade() is called, will be the background holder (TextureRect)
var bg_holder: DialogicNode_BackgroundHolder
signal transition_finished
## To be overridden by transitions
func _fade() -> void:
pass
func set_shader(path_to_shader:String=DialogicUtil.get_module_path('Background').path_join("Transitions/default_transition_shader.gdshader")) -> ShaderMaterial:
if bg_holder:
if path_to_shader.is_empty():
bg_holder.material = null
bg_holder.color = Color.TRANSPARENT
return null
bg_holder.material = ShaderMaterial.new()
bg_holder.material.shader = load(path_to_shader)
return bg_holder.material
return null
func tween_shader_progress(_progress_parameter:="progress") -> PropertyTweener:
if !bg_holder:
return
if !bg_holder.material is ShaderMaterial:
return
bg_holder.material.set_shader_parameter("progress", 0.0)
var tween := create_tween()
var tweener := tween.tween_property(bg_holder, "material:shader_parameter/progress", 1.0, time).from(0.0)
tween.tween_callback(emit_signal.bind('transition_finished'))
return tweener

View File

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

View File

@@ -0,0 +1,36 @@
shader_type canvas_item;
// Indicates how far the transition is (0 start, 1 end).
uniform float progress : hint_range(0.0, 1.0);
// The previous background, transparent if there was none.
uniform sampler2D previous_background : source_color, hint_default_transparent;
// The next background, transparent if there is none.
uniform sampler2D next_background : source_color, hint_default_transparent;
// The texture used to determine how far along the progress has to be for bending in the new background.
uniform sampler2D wipe_texture : source_color;
// The size of the trailing smear of the transition.
uniform float feather : hint_range(0.0, 1.0, 0.0001) = 0.1;
// Determines if the wipe texture should keep it's aspect ratio when scaled to the screen's size.
uniform bool keep_aspect_ratio = false;
void fragment() {
vec2 frag_coord = UV;
if(keep_aspect_ratio) {
vec2 ratio = (SCREEN_PIXEL_SIZE.x > SCREEN_PIXEL_SIZE.y) // determine how to scale
? vec2(SCREEN_PIXEL_SIZE.y / SCREEN_PIXEL_SIZE.x, 1) // fit to width
: vec2(1, SCREEN_PIXEL_SIZE.x / SCREEN_PIXEL_SIZE.y); // fit to height
frag_coord *= ratio;
frag_coord += ((vec2(1,1) - ratio) / 2.0);
}
// get the blend factor between the previous and next background.
float alpha = (texture(wipe_texture, frag_coord).r) - progress;
float blend_factor = 1. - smoothstep(0., feather, alpha + (feather * (1. -progress)));
vec4 old_frag = texture(previous_background, UV);
vec4 new_frag = texture(next_background, UV);
COLOR = mix(old_frag, new_frag, blend_factor);
}

View File

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

View File

@@ -0,0 +1,17 @@
shader_type canvas_item;
uniform vec2 final_offset = vec2(0,-1);
uniform float progress: hint_range(0.0, 1.0);
uniform sampler2D previous_background: source_color, hint_default_transparent;
uniform sampler2D next_background: source_color, hint_default_transparent;
void fragment() {
vec2 uv = UV + final_offset * progress*vec2(-1, -1);
if (uv.x < 1.0 && uv.x > 0.0 && uv.y < 1.0 && uv.y > 0.0){
COLOR = texture(previous_background, uv, 1);
} else {
COLOR = texture(next_background, uv-final_offset*vec2(-1,-1));
}
}

View File

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

View File

@@ -0,0 +1,9 @@
extends DialogicBackgroundTransition
func setup_push_shader() -> ShaderMaterial:
var shader := set_shader(DialogicUtil.get_module_path('Background').path_join("Transitions/push_transition_shader.gdshader"))
shader.set_shader_parameter("previous_background", prev_texture)
shader.set_shader_parameter("next_background", next_texture)
return shader

View File

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

View File

@@ -0,0 +1,7 @@
[gd_resource type="GradientTexture2D" load_steps=2 format=3 uid="uid://cweb3y3xc4uw0"]
[sub_resource type="Gradient" id="Gradient_skd6w"]
colors = PackedColorArray(0, 0, 0, 1, 0.991164, 0.991164, 0.991164, 1)
[resource]
gradient = SubResource("Gradient_skd6w")

View File

@@ -0,0 +1,14 @@
extends DialogicBackgroundTransition
func setup_swipe_shader() -> ShaderMaterial:
var shader := set_shader()
shader.set_shader_parameter("wipe_texture", load(
DialogicUtil.get_module_path('Background').path_join("Transitions/simple_swipe_gradient.tres")
))
shader.set_shader_parameter("feather", 0.3)
shader.set_shader_parameter("previous_background", prev_texture)
shader.set_shader_parameter("next_background", next_texture)
return shader

View File

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

View File

@@ -0,0 +1,38 @@
extends Node
class_name DialogicBackground
## This is the base class for dialogic backgrounds.
## Extend it and override it's methods when you create a custom background.
## You can take a look at the default background to get an idea of how it's working.
## The subviewport container that holds this background. Set when instanced.
var viewport_container: SubViewportContainer
## The viewport that holds this background. Set when instanced.
var viewport: SubViewport
## Load the new background in here.
## The time argument is given for when [_should_do_background_update] returns true
## (then you have to do a transition in here)
func _update_background(_argument:String, _time:float) -> void:
pass
## If a background event with this scene is encountered while this background is used,
## this decides whether to create a new instance and call fade_out or just call [_update_background] # on this scene. Default is false
func _should_do_background_update(_argument:String) -> bool:
return false
## Called by dialogic when first created.
## If you return false (by default) it will attempt to animate the "modulate" property.
func _custom_fade_in(_time:float) -> bool:
return false
## Called by dialogic before removing (done by dialogic).
## If you return false (by default) it will attempt to animate the "modulate" property.
func _custom_fade_out(_time:float) -> bool:
return false

View File

@@ -0,0 +1 @@
uid://300wwwje0bj

View File

@@ -0,0 +1,156 @@
@tool
class_name DialogicBackgroundEvent
extends DialogicEvent
## Event to show scenes in the background and switch between them.
### Settings
## The scene to use. If empty, this will default to the DefaultBackground.gd scene.
## This scene supports images and fading.
## If you set it to a scene path, then that scene will be instanced.
## Learn more about custom backgrounds in the Subsystem_Background.gd docs.
var scene := ""
## The argument that is passed to the background scene.
## For the default scene it's the path to the image to show.
var argument := ""
## The time the fade animation will take. Leave at 0 for instant change.
var fade: float = 0.0
## Name of the transition to use.
var transition := ""
## Helpers for visual editor
enum ArgumentTypes {IMAGE, CUSTOM}
var _arg_type := ArgumentTypes.IMAGE :
get:
if argument.begins_with("res://"):
return ArgumentTypes.IMAGE
else:
return _arg_type
set(value):
if value == ArgumentTypes.CUSTOM:
if argument.begins_with("res://"):
argument = " "+argument
_arg_type = value
enum SceneTypes {DEFAULT, CUSTOM}
var _scene_type := SceneTypes.DEFAULT :
get:
if scene.is_empty():
return _scene_type
else:
return SceneTypes.CUSTOM
set(value):
if value == SceneTypes.DEFAULT:
scene = ""
_scene_type = value
#region EXECUTION
################################################################################
func _execute() -> void:
var final_fade_duration := fade
if dialogic.Inputs.auto_skip.enabled:
var time_per_event: float = dialogic.Inputs.auto_skip.time_per_event
final_fade_duration = min(fade, time_per_event)
dialogic.Backgrounds.update_background(scene, argument, final_fade_duration, transition)
finish()
#endregion
#region INITIALIZE
################################################################################
func _init() -> void:
event_name = "Background"
set_default_color('Color8')
event_category = "Visuals"
event_sorting_index = 0
#endregion
#region SAVE & LOAD
################################################################################
func get_shortcode() -> String:
return "background"
func get_shortcode_parameters() -> Dictionary:
return {
#param_name : property_info
"scene" : {"property": "scene", "default": ""},
"arg" : {"property": "argument", "default": ""},
"fade" : {"property": "fade", "default": 0},
"transition" : {"property": "transition", "default": "",
"suggestions": get_transition_suggestions},
}
#endregion
#region EDITOR REPRESENTATION
################################################################################
func build_event_editor() -> void:
add_header_edit('_scene_type', ValueType.FIXED_OPTIONS, {
'left_text' :'Show',
'options': [
{
'label': 'Background',
'value': SceneTypes.DEFAULT,
'icon': ["GuiRadioUnchecked", "EditorIcons"]
},
{
'label': 'Custom Scene',
'value': SceneTypes.CUSTOM,
'icon': ["PackedScene", "EditorIcons"]
}
]})
add_header_label("with image", "_scene_type == SceneTypes.DEFAULT")
add_header_edit("scene", ValueType.FILE,
{'file_filter':'*.tscn, *.scn; Scene Files',
'placeholder': "Custom scene",
'editor_icon': ["PackedScene", "EditorIcons"],
}, '_scene_type == SceneTypes.CUSTOM')
add_header_edit('_arg_type', ValueType.FIXED_OPTIONS, {
'left_text' : 'with',
'options': [
{
'label': 'Image',
'value': ArgumentTypes.IMAGE,
'icon': ["Image", "EditorIcons"]
},
{
'label': 'Custom Argument',
'value': ArgumentTypes.CUSTOM,
'icon': ["String", "EditorIcons"]
}
], "symbol_only": true}, "_scene_type == SceneTypes.CUSTOM")
add_header_edit('argument', ValueType.FILE,
{'file_filter':'*.jpg, *.jpeg, *.png, *.webp, *.tga, *svg, *.bmp, *.dds, *.exr, *.hdr; Supported Image Files',
'placeholder': "No Image",
'editor_icon': ["Image", "EditorIcons"],
},
'_arg_type == ArgumentTypes.IMAGE or _scene_type == SceneTypes.DEFAULT')
add_header_edit('argument', ValueType.SINGLELINE_TEXT, {}, '_arg_type == ArgumentTypes.CUSTOM')
add_body_edit("transition", ValueType.DYNAMIC_OPTIONS,
{'left_text':'Transition:',
'empty_text':'Simple Fade',
'suggestions_func':get_transition_suggestions,
'editor_icon':["PopupMenu", "EditorIcons"]})
add_body_edit("fade", ValueType.NUMBER, {'left_text':'Fade time:'})
func get_transition_suggestions(_filter:String="") -> Dictionary:
var transitions := DialogicResourceUtil.list_special_resources("BackgroundTransition")
var suggestions := {}
for i in transitions:
suggestions[DialogicUtil.pretty_name(i)] = {'value': DialogicUtil.pretty_name(i), 'editor_icon': ["PopupMenu", "EditorIcons"]}
return suggestions
#endregion

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://517mp8gfj811"
path="res://.godot/imported/icon.png-cab4c78f59b171335e340ba590cf5991.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/dialogic/Modules/Background/icon.png"
dest_files=["res://.godot/imported/icon.png-cab4c78f59b171335e340ba590cf5991.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

View File

@@ -0,0 +1,13 @@
@tool
extends DialogicIndexer
func _get_events() -> Array:
return [this_folder.path_join('event_background.gd')]
func _get_subsystems() -> Array:
return [{'name':'Backgrounds', 'script':this_folder.path_join('subsystem_backgrounds.gd')}]
func _get_special_resources() -> Dictionary:
return {&"BackgroundTransition":list_special_resources("Transitions/Defaults", ".gd")}

View File

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

View File

@@ -0,0 +1,6 @@
class_name DialogicNode_BackgroundHolder
extends ColorRect
func _ready() -> void:
add_to_group('dialogic_background_holders')

View File

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

View File

@@ -0,0 +1,186 @@
extends DialogicSubsystem
## Subsystem for managing backgrounds.
##
## This subsystem has many different helper methods for managing backgrounds.
## For instance, you can listen to background changes via
## [signal background_changed].
## Whenever a new background is set, this signal is emitted and contains a
## dictionary with the following keys: [br]
## [br]
## Key | Value Type | Value [br]
## ----------- | ------------- | ----- [br]
## `scene` | [type String] | The scene path of the new background. [br]
## `argument` | [type String] | Information given to the background on its update routine. [br]
## `fade_time` | [type float] | The time the background may take to transition in. [br]
## `same_scene`| [type bool] | If the new background uses the same Godot scene. [br]
signal background_changed(info: Dictionary)
## The default background scene Dialogic will use.
var default_background_scene: PackedScene = load(get_script().resource_path.get_base_dir().path_join('DefaultBackgroundScene/default_background.tscn'))
## The default transition Dialogic will use.
var default_transition: String = get_script().resource_path.get_base_dir().path_join("Transitions/Defaults/simple_fade.gd")
#region STATE
####################################################################################################
## Empties the current background state.
func clear_game_state(_clear_flag := DialogicGameHandler.ClearFlags.FULL_CLEAR) -> void:
update_background()
## Loads the background state from the current state info.
func load_game_state(_load_flag := LoadFlags.FULL_LOAD) -> void:
update_background(dialogic.current_state_info.get('background_scene', ''), dialogic.current_state_info.get('background_argument', ''), 0.0, default_transition, true)
#endregion
#region MAIN METHODS
####################################################################################################
## Method that adds a given scene as child of the DialogicNode_BackgroundHolder.
## It will call [_update_background()] on that scene with the given argument [argument].
## It will call [_fade_in()] on that scene with the given fade time.
## Will call fade_out on previous backgrounds scene.
##
## If the scene is the same as the last background you can bypass another instantiating
## and use the same scene.
## To do so implement [_should_do_background_update()] on the custom background scene.
## Then [_update_background()] will be called directly on that previous scene.
func update_background(scene := "", argument := "", fade_time := 0.0, transition_path:=default_transition, force := false) -> void:
var background_holder: DialogicNode_BackgroundHolder
if dialogic.has_subsystem('Styles'):
background_holder = dialogic.Styles.get_first_node_in_layout('dialogic_background_holders')
else:
background_holder = get_tree().get_first_node_in_group('dialogic_background_holders')
var info := {'scene':scene, 'argument':argument, 'fade_time':fade_time, 'same_scene':false}
if background_holder == null:
background_changed.emit(info)
return
var bg_set := false
# First try just updating the existing scene.
if scene == dialogic.current_state_info.get('background_scene', ''):
if not force and argument == dialogic.current_state_info.get('background_argument', ''):
return
for old_bg in background_holder.get_children():
if !old_bg.has_meta('node') or not old_bg.get_meta('node') is DialogicBackground:
continue
var prev_bg_node: DialogicBackground = old_bg.get_meta('node')
if prev_bg_node._should_do_background_update(argument):
prev_bg_node._update_background(argument, fade_time)
bg_set = true
info['same_scene'] = true
dialogic.current_state_info['background_scene'] = scene
dialogic.current_state_info['background_argument'] = argument
if bg_set:
background_changed.emit(info)
return
var old_viewport: SubViewportContainer = null
if background_holder.has_meta('current_viewport'):
old_viewport = background_holder.get_meta('current_viewport', null)
var new_viewport: SubViewportContainer
if scene.ends_with('.tscn') and ResourceLoader.exists(scene):
new_viewport = add_background_node(load(scene), background_holder)
elif argument:
new_viewport = add_background_node(default_background_scene, background_holder)
else:
new_viewport = null
var trans_script: Script = load(DialogicResourceUtil.guess_special_resource("BackgroundTransition", transition_path, {"path":default_transition}).path)
var trans_node := Node.new()
trans_node.set_script(trans_script)
trans_node = (trans_node as DialogicBackgroundTransition)
trans_node.bg_holder = background_holder
trans_node.time = fade_time
if old_viewport:
trans_node.prev_scene = old_viewport.get_meta('node', null)
trans_node.prev_texture = old_viewport.get_child(0).get_texture()
old_viewport.get_meta('node')._custom_fade_out(fade_time)
old_viewport.hide()
# TODO We have to call this again here because of https://github.com/godotengine/godot/issues/23729
old_viewport.get_child(0).render_target_update_mode = SubViewport.UPDATE_ALWAYS
trans_node.transition_finished.connect(old_viewport.queue_free)
if new_viewport:
trans_node.next_scene = new_viewport.get_meta('node', null)
trans_node.next_texture = new_viewport.get_child(0).get_texture()
new_viewport.get_meta('node')._update_background(argument, fade_time)
new_viewport.get_meta('node')._custom_fade_in(fade_time)
else:
background_holder.remove_meta('current_viewport')
add_child(trans_node)
if fade_time == 0:
trans_node.transition_finished.emit()
_on_transition_finished(background_holder, trans_node)
else:
trans_node.transition_finished.connect(_on_transition_finished.bind(background_holder, trans_node))
# We need to break this connection if the background_holder get's removed during the transition
background_holder.tree_exited.connect(trans_node.disconnect.bind("transition_finished", _on_transition_finished))
trans_node._fade()
background_changed.emit(info)
func _on_transition_finished(background_node:DialogicNode_BackgroundHolder, transition_node:DialogicBackgroundTransition) -> void:
if background_node.has_meta("current_viewport"):
if background_node.get_meta("current_viewport").get_meta("node", null) == transition_node.next_scene:
background_node.get_meta("current_viewport").show()
background_node.material = null
background_node.color = Color.TRANSPARENT
transition_node.queue_free()
## Adds sub-viewport with the given background scene as child to
## Dialogic scene.
func add_background_node(scene:PackedScene, parent:DialogicNode_BackgroundHolder) -> SubViewportContainer:
var v_con := SubViewportContainer.new()
var viewport := SubViewport.new()
var b_scene := scene.instantiate()
if not b_scene is DialogicBackground:
printerr("[Dialogic] Given background scene was not of type DialogicBackground! Make sure the scene has a script that extends DialogicBackground.")
v_con.queue_free()
viewport.queue_free()
b_scene.queue_free()
return null
parent.add_child(v_con)
v_con.hide()
v_con.stretch = true
v_con.size = parent.size
v_con.set_anchors_preset(Control.PRESET_FULL_RECT)
v_con.add_child(viewport)
viewport.transparent_bg = true
viewport.disable_3d = true
viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS
viewport.canvas_item_default_texture_filter = ProjectSettings.get_setting("rendering/textures/canvas_textures/default_texture_filter")
viewport.add_child(b_scene)
b_scene.viewport = viewport
b_scene.viewport_container = v_con
parent.set_meta('current_viewport', v_con)
v_con.set_meta('node', b_scene)
return v_con
## Whether a background is set.
func has_background() -> bool:
return !dialogic.current_state_info.get('background_scene', '').is_empty() or !dialogic.current_state_info.get('background_argument','').is_empty()
#endregion

View File

@@ -0,0 +1 @@
uid://3ulo6wgj1m85

View File

@@ -0,0 +1,263 @@
@tool
class_name DialogicCallEvent
extends DialogicEvent
## Event that allows calling a method in a node or autoload.
### Settings
## The name of the autoload to call the method on.
var autoload_name := ""
## The name of the method to call on the given autoload.
var method := "":
set(value):
method = value
if Engine.is_editor_hint():
update_argument_info()
check_arguments_and_update_warning()
## A list of arguments to give to the call.
var arguments := []:
set(value):
arguments = value
if Engine.is_editor_hint():
check_arguments_and_update_warning()
var _current_method_arg_hints := {'a':null, 'm':null, 'info':{}}
################################################################################
## EXECUTION
################################################################################
func _execute() -> void:
var object: Object = null
var obj_path := autoload_name
var autoload: Node = dialogic.get_node('/root/'+obj_path.get_slice('.', 0))
obj_path = obj_path.trim_prefix(obj_path.get_slice('.', 0)+'.')
object = autoload
if object:
while obj_path:
if obj_path.get_slice(".", 0) in object and object.get(obj_path.get_slice(".", 0)) is Object:
object = object.get(obj_path.get_slice(".", 0))
else:
break
obj_path = obj_path.trim_prefix(obj_path.get_slice('.', 0)+'.')
if object == null:
printerr("[Dialogic] Call event failed: Unable to find autoload '",autoload_name,"'")
finish()
return
if object.has_method(method):
var args := []
for arg in arguments:
if arg is String and arg.begins_with('@'):
args.append(dialogic.Expressions.execute_string(arg.trim_prefix('@')))
else:
args.append(arg)
dialogic.current_state = dialogic.States.WAITING
await object.callv(method, args)
dialogic.current_state = dialogic.States.IDLE
else:
printerr("[Dialogic] Call event failed: Autoload doesn't have the method '", method,"'.")
finish()
################################################################################
## INITIALIZE
################################################################################
func _init() -> void:
event_name = "Call"
set_default_color('Color6')
event_category = "Logic"
event_sorting_index = 10
################################################################################
## SAVING/LOADING
################################################################################
func to_text() -> String:
var result := "do "
if autoload_name:
result += autoload_name
if method:
result += '.'+method
if arguments.is_empty():
result += '()'
else:
result += '('
for i in arguments:
if i is String and i.begins_with('@'):
result += i.trim_prefix('@')
else:
result += var_to_str(i)
result += ', '
result = result.trim_suffix(', ')+')'
return result
func from_text(string:String) -> void:
var result := RegEx.create_from_string(r"do (?<autoload>[^\(]*)\.((?<method>[^.(]*)(\((?<arguments>.*)\))?)?").search(string.strip_edges())
if result:
autoload_name = result.get_string('autoload')
method = result.get_string('method')
if result.get_string('arguments').is_empty():
arguments = []
else:
var arr := []
for i in result.get_string('arguments').split(','):
i = i.strip_edges()
if str_to_var(i) != null:
arr.append(str_to_var(i))
else:
# Mark this as a complex expression
arr.append("@"+i)
arguments = arr
func is_valid_event(string:String) -> bool:
if string.strip_edges().begins_with("do"):
return true
return false
func get_shortcode_parameters() -> Dictionary:
return {
#param_name : property_info
"autoload" : {"property": "autoload_name", "default": ""},
"method" : {"property": "method", "default": ""},
"args" : {"property": "arguments", "default": []},
}
################################################################################
## EDITOR REPRESENTATION
################################################################################
func build_event_editor() -> void:
add_header_edit('autoload_name', ValueType.DYNAMIC_OPTIONS, {'left_text':'On autoload',
'empty_text':'Autoload',
'suggestions_func':get_autoload_suggestions,
'editor_icon':["Node", "EditorIcons"]})
add_header_edit('method', ValueType.DYNAMIC_OPTIONS, {'left_text':'call',
'empty_text':'Method',
'suggestions_func':get_method_suggestions,
'editor_icon':["Callable", "EditorIcons"]}, 'autoload_name')
add_body_edit('arguments', ValueType.ARRAY, {'left_text':'Arguments:'}, 'not autoload_name.is_empty() and not method.is_empty()')
func get_autoload_suggestions(filter:String="") -> Dictionary:
var suggestions := {}
for prop in ProjectSettings.get_property_list():
if prop.name.begins_with('autoload/'):
var autoload: String = prop.name.trim_prefix('autoload/')
suggestions[autoload] = {'value': autoload, 'tooltip':autoload, 'editor_icon': ["Node", "EditorIcons"]}
if filter.begins_with(autoload):
suggestions[filter] = {'value': filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]}
return suggestions
func get_method_suggestions(filter:String="", temp_autoload:String = "") -> Dictionary:
var suggestions := {}
var script: Script
if temp_autoload and ProjectSettings.has_setting('autoload/'+temp_autoload):
script = load(ProjectSettings.get_setting('autoload/'+temp_autoload).trim_prefix('*'))
elif autoload_name and ProjectSettings.has_setting('autoload/'+autoload_name):
var loaded_autoload := load(ProjectSettings.get_setting('autoload/'+autoload_name).trim_prefix('*'))
if loaded_autoload is PackedScene:
var packed_scene: PackedScene = loaded_autoload
script = packed_scene.instantiate().get_script()
else:
script = loaded_autoload
if script:
for script_method in script.get_script_method_list():
if script_method.name.begins_with('@') or script_method.name.begins_with('_'):
continue
suggestions[script_method.name] = {'value': script_method.name, 'tooltip':script_method.name, 'editor_icon': ["Callable", "EditorIcons"]}
if !filter.is_empty():
suggestions[filter] = {'value': filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]}
return suggestions
func update_argument_info() -> void:
if autoload_name and method and not _current_method_arg_hints.is_empty() and (_current_method_arg_hints.a == autoload_name and _current_method_arg_hints.m == method):
if !ResourceLoader.exists(ProjectSettings.get_setting('autoload/'+autoload_name, '').trim_prefix('*')):
_current_method_arg_hints = {}
return
var script: Script = load(ProjectSettings.get_setting('autoload/'+autoload_name, '').trim_prefix('*'))
for m in script.get_script_method_list():
if m.name == method:
_current_method_arg_hints = {'a':autoload_name, 'm':method, 'info':m}
break
func check_arguments_and_update_warning() -> void:
if not _current_method_arg_hints.has("info") or _current_method_arg_hints.info.is_empty():
ui_update_warning.emit()
return
var idx := -1
for arg in arguments:
idx += 1
if len(_current_method_arg_hints.info.args) <= idx:
continue
if _current_method_arg_hints.info.args[idx].type != 0:
if _current_method_arg_hints.info.args[idx].type != typeof(arg):
if arg is String and arg.begins_with('@'):
continue
var expected_type: String = ""
match _current_method_arg_hints.info.args[idx].type:
TYPE_BOOL: expected_type = "bool"
TYPE_STRING: expected_type = "string"
TYPE_FLOAT: expected_type = "float"
TYPE_INT: expected_type = "int"
_: expected_type = "something else"
ui_update_warning.emit('Argument '+ str(idx+1)+ ' ('+_current_method_arg_hints.info.args[idx].name+') has the wrong type (method expects '+expected_type+')!')
return
if len(arguments) < len(_current_method_arg_hints.info.args)-len(_current_method_arg_hints.info.default_args):
ui_update_warning.emit("The method is expecting at least "+str(len(_current_method_arg_hints.info.args)-len(_current_method_arg_hints.info.default_args))+ " arguments, but is given only "+str(len(arguments))+".")
return
elif len(arguments) > len(_current_method_arg_hints.info.args):
ui_update_warning.emit("The method is expecting at most "+str(len(_current_method_arg_hints.info.args))+ " arguments, but is given "+str(len(arguments))+".")
return
ui_update_warning.emit()
####################### CODE COMPLETION ########################################
################################################################################
func _get_code_completion(_CodeCompletionHelper:Node, TextNode:TextEdit, line:String, _word:String, symbol:String) -> void:
if line.count(' ') == 1 and not '.' in line:
for i in get_autoload_suggestions():
TextNode.add_code_completion_option(CodeEdit.KIND_MEMBER, i, i+'.', event_color.lerp(TextNode.syntax_highlighter.normal_color, 0.3), TextNode.get_theme_icon("Node", "EditorIcons"))
elif symbol == '.' and not '(' in line:
for i in get_method_suggestions('', line.get_slice('.', 0).trim_prefix('do ')):
TextNode.add_code_completion_option(CodeEdit.KIND_MEMBER, i, i+'(', event_color.lerp(TextNode.syntax_highlighter.normal_color, 0.3), TextNode.get_theme_icon("Callable", "EditorIcons"))
func _get_start_code_completion(_CodeCompletionHelper:Node, TextNode:TextEdit) -> void:
TextNode.add_code_completion_option(CodeEdit.KIND_PLAIN_TEXT, 'do', 'do ', event_color.lerp(TextNode.syntax_highlighter.normal_color, 0.3), _get_icon())
#################### SYNTAX HIGHLIGHTING #######################################
################################################################################
func _get_syntax_highlighting(Highlighter:SyntaxHighlighter, dict:Dictionary, line:String) -> Dictionary:
dict[line.find('do')] = {"color":event_color.lerp(Highlighter.normal_color, 0.3)}
dict[line.find('do')+2] = {"color":event_color.lerp(Highlighter.normal_color, 0.5)}
Highlighter.color_region(dict, Highlighter.normal_color, line, '(', ')')
Highlighter.color_region(dict, Highlighter.string_color, line, '"', '"')
Highlighter.color_word(dict, Highlighter.boolean_operator_color, line, 'true')
Highlighter.color_word(dict, Highlighter.boolean_operator_color, line, 'false')
return dict

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://duvcdvtgy4h4b"
path="res://.godot/imported/icon.png-12e444f0ed59397c7537943ea85b475c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/dialogic/Modules/Call/icon.png"
dest_files=["res://.godot/imported/icon.png-12e444f0ed59397c7537943ea85b475c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

View File

@@ -0,0 +1,6 @@
@tool
extends DialogicIndexer
func _get_events() -> Array:
return [this_folder.path_join('event_call.gd')]

View File

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

View File

@@ -0,0 +1,16 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
tween.set_ease(Tween.EASE_OUT)
tween.tween_property(node, 'position:y', base_position.y-node.get_viewport().size.y/10, time*0.4).set_trans(Tween.TRANS_EXPO)
tween.parallel().tween_property(node, 'scale:y', base_scale.y*1.05, time*0.4).set_trans(Tween.TRANS_EXPO)
tween.tween_property(node, 'position:y', base_position.y, time*0.6).set_trans(Tween.TRANS_BOUNCE)
tween.parallel().tween_property(node, 'scale:y', base_scale.y, time*0.6).set_trans(Tween.TRANS_BOUNCE)
tween.finished.connect(emit_signal.bind('finished_once'))
func _get_named_variations() -> Dictionary:
return {
"bounce": {"type": AnimationType.ACTION},
}

View File

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

View File

@@ -0,0 +1,39 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
var end_scale: Vector2 = node.scale
var end_modulate_alpha := 1.0
var modulation_property := get_modulation_property()
if is_reversed:
end_scale = Vector2(0, 0)
end_modulate_alpha = 0.0
else:
node.scale = Vector2(0, 0)
var original_modulation: Color = node.get(modulation_property)
original_modulation.a = 0.0
node.set(modulation_property, original_modulation)
tween.set_ease(Tween.EASE_IN_OUT)
tween.set_trans(Tween.TRANS_SINE)
tween.set_parallel()
(tween.tween_property(node, "scale", end_scale, time)
.set_trans(Tween.TRANS_SPRING)
.set_ease(Tween.EASE_OUT))
tween.tween_property(node, modulation_property + ":a", end_modulate_alpha, time)
await tween.finished
finished_once.emit()
func _get_named_variations() -> Dictionary:
return {
"bounce in": {"reversed": false, "type": AnimationType.IN},
"bounce out": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,44 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
var start_height: float = base_position.y - node.get_viewport().size.y / 5
var end_height := base_position.y
var start_modulation := 0.0
var end_modulation := 1.0
if is_reversed:
end_height = start_height
start_height = base_position.y
end_modulation = 0.0
start_modulation = 1.0
node.position.y = start_height
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_SINE)
tween.set_parallel()
var end_postion := Vector2(base_position.x, end_height)
tween.tween_property(node, "position", end_postion, time)
var property := get_modulation_property()
var original_modulation: Color = node.get(property)
original_modulation.a = start_modulation
node.set(property, original_modulation)
var modulation_alpha := property + ":a"
tween.tween_property(node, modulation_alpha, end_modulation, time)
await tween.finished
finished_once.emit()
func _get_named_variations() -> Dictionary:
return {
"fade in down": {"reversed": false, "type": AnimationType.IN},
"fade out up": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,34 @@
extends DialogicAnimation
func animate() -> void:
var modulation_property := get_modulation_property()
var end_modulation_alpha := 1.0
if is_reversed:
end_modulation_alpha = 0.0
else:
var original_modulation: Color = node.get(modulation_property)
original_modulation.a = 0.0
node.set(modulation_property, original_modulation)
var tween := (node.create_tween() as Tween)
if is_reversed:
tween.set_ease(Tween.EASE_IN)
else:
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_SINE)
tween.tween_property(node, modulation_property + ":a", end_modulation_alpha, time)
await tween.finished
finished_once.emit()
func _get_named_variations() -> Dictionary:
return {
"fade in": {"reversed": false, "type": AnimationType.IN},
"fade out": {"reversed": true, "type": AnimationType.OUT},
"fade cross": {"type": AnimationType.CROSSFADE},
}

View File

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

View File

@@ -0,0 +1,44 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
var start_height: float = base_position.y + node.get_viewport().size.y / 5
var end_height := base_position.y
var start_modulation := 0.0
var end_modulation := 1.0
if is_reversed:
end_height = start_height
start_height = base_position.y
end_modulation = 0.0
start_modulation = 1.0
node.position.y = start_height
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_SINE)
tween.set_parallel()
var end_postion := Vector2(base_position.x, end_height)
tween.tween_property(node, "position", end_postion, time)
var property := get_modulation_property()
var original_modulation: Color = node.get(property)
original_modulation.a = start_modulation
node.set(property, original_modulation)
var modulation_alpha := property + ":a"
tween.tween_property(node, modulation_alpha, end_modulation, time)
await tween.finished
finished_once.emit()
func _get_named_variations() -> Dictionary:
return {
"fade in up": {"reversed": false, "type": AnimationType.IN},
"fade out down": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,13 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
tween.tween_property(node, 'scale', Vector2(1,1)*1.2, time*0.5).set_trans(Tween.TRANS_ELASTIC).set_ease(Tween.EASE_OUT)
tween.tween_property(node, 'scale', Vector2(1,1), time*0.5).set_trans(Tween.TRANS_BOUNCE).set_ease(Tween.EASE_OUT)
tween.finished.connect(emit_signal.bind('finished_once'))
func _get_named_variations() -> Dictionary:
return {
"heartbeat": {"type": AnimationType.ACTION},
}

View File

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

View File

@@ -0,0 +1,12 @@
extends DialogicAnimation
func animate() -> void:
await node.get_tree().process_frame
finished.emit()
func _get_named_variations() -> Dictionary:
return {
"instant in": {"reversed": false, "type": AnimationType.IN},
"instant out": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,20 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
tween.set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_SINE)
var strength: float = node.get_viewport().size.x/60
var bound_multitween := DialogicUtil.multitween.bind(node, "position", "animation_shake_x")
tween.tween_method(bound_multitween, Vector2(), Vector2(1, 0)*strength, time*0.2)
tween.tween_method(bound_multitween, Vector2(), Vector2(-1,0)*strength, time*0.1)
tween.tween_method(bound_multitween, Vector2(), Vector2(1, 0)*strength, time*0.1)
tween.tween_method(bound_multitween, Vector2(), Vector2(-1,0)*strength, time*0.1)
tween.tween_method(bound_multitween, Vector2(), Vector2(1, 0)*strength, time*0.1)
tween.tween_method(bound_multitween, Vector2(), Vector2(-1,0)*strength, time*0.1)
tween.tween_method(bound_multitween, Vector2(), Vector2(1, 0)*strength, time*0.2)
tween.finished.connect(emit_signal.bind('finished_once'))
func _get_named_variations() -> Dictionary:
return {
"shake x": {"type": AnimationType.ACTION},
}

View File

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

View File

@@ -0,0 +1,23 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
tween.set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_SINE)
var strength: float = node.get_viewport().size.y/40
tween.tween_property(node, 'position:y', base_position.y + strength, time * 0.2)
tween.tween_property(node, 'position:y', base_position.y - strength, time * 0.1)
tween.tween_property(node, 'position:y', base_position.y + strength, time * 0.1)
tween.tween_property(node, 'position:y', base_position.y - strength, time * 0.1)
tween.tween_property(node, 'position:y', base_position.y + strength, time * 0.1)
tween.tween_property(node, 'position:y', base_position.y - strength, time * 0.1)
tween.tween_property(node, 'position:y', base_position.y + strength, time * 0.1)
tween.tween_property(node, 'position:y', base_position.y, time * 0.2)
tween.finished.connect(emit_signal.bind('finished_once'))
func _get_named_variations() -> Dictionary:
return {
"shake y": {"type": AnimationType.ACTION},
}

View File

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

View File

@@ -0,0 +1,26 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
tween.set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK)
var target_position := base_position.y
var start_position: float = -node.get_viewport().size.y
if is_reversed:
target_position = -node.get_viewport().size.y
start_position = base_position.y
node.position.y = start_position
tween.tween_property(node, 'position:y', target_position, time)
await tween.finished
finished_once.emit()
func _get_named_variations() -> Dictionary:
return {
"slide in down": {"reversed": false, "type": AnimationType.IN},
"slide out up": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,26 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
tween.set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK)
var end_position_x: float = base_position.x
if is_reversed:
end_position_x = -node.get_viewport().size.x / 2
else:
node.position.x = -node.get_viewport().size.x / 5
tween.tween_property(node, 'position:x', end_position_x, time)
await tween.finished
finished_once.emit()
func _get_named_variations() -> Dictionary:
return {
"slide in left": {"reversed": false, "type": AnimationType.IN},
"slide out right": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,27 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
tween.set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK)
var viewport_x: float = node.get_viewport().size.x
var start_position_x: float = viewport_x + viewport_x / 5
var end_position_x := base_position.x
if is_reversed:
start_position_x = base_position.x
end_position_x = viewport_x + node.get_viewport().size.x / 5
node.position.x = start_position_x
tween.tween_property(node, 'position:x', end_position_x, time)
tween.finished.connect(emit_signal.bind('finished_once'))
func _get_named_variations() -> Dictionary:
return {
"slide in right": {"reversed": false, "type": AnimationType.IN},
"slide out left": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,25 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
tween.set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK)
var start_position_y: float = node.get_viewport().size.y * 2
var end_position_y := base_position.y
if is_reversed:
start_position_y = base_position.y
end_position_y = node.get_viewport().size.y * 2
node.position.y = start_position_y
tween.tween_property(node, 'position:y', end_position_y, time)
await tween.finished
finished_once.emit()
func _get_named_variations() -> Dictionary:
return {
"slide in up": {"reversed": false, "type": AnimationType.IN},
"slide out down": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,25 @@
extends DialogicAnimation
func animate() -> void:
var tween := (node.create_tween() as Tween)
tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
var strength: float = 0.01
tween.set_parallel(true)
tween.tween_property(node, 'scale', Vector2(1,1)*(1+strength), time*0.3)
tween.tween_property(node, 'rotation', -strength, time*0.1).set_delay(time*0.2)
tween.tween_property(node, 'rotation', strength, time*0.1).set_delay(time*0.3)
tween.tween_property(node, 'rotation', -strength, time*0.1).set_delay(time*0.4)
tween.tween_property(node, 'rotation', strength, time*0.1).set_delay(time*0.5)
tween.tween_property(node, 'rotation', -strength, time*0.1).set_delay(time*0.6)
tween.chain().tween_property(node, 'scale', Vector2(1,1), time*0.3)
tween.parallel().tween_property(node, 'rotation', 0.0, time*0.3)
tween.finished.connect(emit_signal.bind('finished_once'))
func _get_named_variations() -> Dictionary:
return {
"tada": {"type": AnimationType.ACTION},
}

View File

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

View File

@@ -0,0 +1,36 @@
extends DialogicAnimation
func animate() -> void:
var modulate_property := get_modulation_property()
var modulate_alpha_property := modulate_property + ":a"
var end_scale: Vector2 = node.scale
var end_modulation_alpha := 1.0
if is_reversed:
end_modulation_alpha = 0.0
else:
node.scale = Vector2(0, 0)
node.position.y = base_position.y - node.get_viewport().size.y * 0.5
var original_modulation: Color = node.get(modulate_property)
original_modulation.a = 0.0
node.set(modulate_property, original_modulation)
var tween := (node.create_tween() as Tween)
tween.set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_EXPO)
tween.set_parallel(true)
tween.tween_property(node, "scale", end_scale, time)
tween.tween_property(node, "position", base_position, time)
tween.tween_property(node, modulate_alpha_property, end_modulation_alpha, time)
await tween.finished
finished_once.emit()
func _get_named_variations() -> Dictionary:
return {
"zoom center in": {"reversed": false, "type": AnimationType.IN},
"zoom center out": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,35 @@
extends DialogicAnimation
func animate() -> void:
var modulate_property := get_modulation_property()
var modulate_alpha_property := modulate_property + ":a"
var end_scale: Vector2 = node.scale
var end_modulation_alpha := 1.0
if is_reversed:
end_scale = Vector2(0, 0)
end_modulation_alpha = 0.0
else:
node.scale = Vector2(0,0)
var original_modulation: Color = node.get(modulate_property)
original_modulation.a = 0.0
node.set(modulate_property, original_modulation)
var tween := (node.create_tween() as Tween)
tween.set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_EXPO)
tween.set_parallel(true)
tween.tween_property(node, "scale", end_scale, time)
tween.tween_property(node, modulate_alpha_property, end_modulation_alpha, time)
await tween.finished
finished_once.emit()
func _get_named_variations() -> Dictionary:
return {
"zoom in": {"reversed": false, "type": AnimationType.IN},
"zoom out": {"reversed": true, "type": AnimationType.OUT},
}

View File

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

View File

@@ -0,0 +1,47 @@
@tool
class_name DialogicPortraitAnimationUtil
enum AnimationType {ALL=-1, IN=1, OUT=2, ACTION=3, CROSSFADE=4}
static func guess_animation(string:String, type := AnimationType.ALL) -> String:
var default := {}
var filter := {}
var ignores := []
match type:
AnimationType.ALL:
pass
AnimationType.IN:
filter = {"type":AnimationType.IN}
ignores = ["in"]
AnimationType.OUT:
filter = {"type":AnimationType.OUT}
ignores = ["out"]
AnimationType.ACTION:
filter = {"type":AnimationType.ACTION}
AnimationType.CROSSFADE:
filter = {"type":AnimationType.CROSSFADE}
ignores = ["cross"]
return DialogicResourceUtil.guess_special_resource(&"PortraitAnimation", string, default, filter, ignores).get("path", "")
static func get_portrait_animations_filtered(type := AnimationType.ALL) -> Dictionary:
var filter := {"type":type}
if type == AnimationType.ALL:
filter["type"] = [AnimationType.IN, AnimationType.OUT, AnimationType.ACTION]
return DialogicResourceUtil.list_special_resources("PortraitAnimation", filter)
static func get_suggestions(_search_text := "", current_value:= "", empty_text := "Default", action := AnimationType.ALL) -> Dictionary:
var suggestions := {}
if empty_text and current_value:
suggestions[empty_text] = {'value':"", 'editor_icon':["GuiRadioUnchecked", "EditorIcons"]}
for anim_name in get_portrait_animations_filtered(action):
suggestions[DialogicUtil.pretty_name(anim_name)] = {
'value' : DialogicUtil.pretty_name(anim_name),
'editor_icon' : ["Animation", "EditorIcons"]
}
return suggestions

View File

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

View File

@@ -0,0 +1,77 @@
class_name DialogicAnimation
extends Node
## Class that can be used to animate portraits. Can be extended to create animations.
enum AnimationType {IN=1, OUT=2, ACTION=3, CROSSFADE=4}
signal finished_once
signal finished
## Set at runtime, will be the node to animate.
var node: Node
## Set at runtime, will be the length of the animation.
var time: float
## Set at runtime, will be the base position of the node.
## Depending on the animation, this might be the start, end or both.
var base_position: Vector2
## Set at runtime, will be the base scale of the node.
var base_scale: Vector2
## Used to repeate the animation for a number of times.
var repeats: int
## If `true`, the animation will be reversed.
## This must be implemented by each animation or it will have no effect.
var is_reversed: bool = false
func _ready() -> void:
finished_once.connect(finished_one_loop)
## To be overridden. Do the actual animating/tweening in here.
## Use the properties [member node], [member time], [member base_position], etc.
func animate() -> void:
pass
## This method controls whether to repeat the animation or not.
## Animations must call this once they finished an animation.
func finished_one_loop() -> void:
repeats -= 1
if repeats > 0:
animate()
else:
finished.emit()
func pause() -> void:
if node:
node.process_mode = Node.PROCESS_MODE_DISABLED
func resume() -> void:
if node:
node.process_mode = Node.PROCESS_MODE_INHERIT
func _get_named_variations() -> Dictionary:
return {}
## If the animation wants to change the modulation, this method
## will return the property to change.
##
## The [class CanvasGroup] can use `self_modulate` instead of `modulate`
## to uniformly change the modulation of all children without additively
## overlaying the modulations.
func get_modulation_property() -> String:
if node is CanvasGroup:
return "self_modulate"
else:
return "modulate"

View File

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

Some files were not shown because too many files have changed in this diff Show More