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,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