From 65f21cf95727e3cc3c035ea03b64563a82dd622b Mon Sep 17 00:00:00 2001 From: Pheubel Date: Tue, 5 Dec 2023 19:47:34 +0100 Subject: [PATCH 01/13] create first pass transition resource --- .../Modules/Background/dialogic_transition.gd | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 addons/dialogic/Modules/Background/dialogic_transition.gd diff --git a/addons/dialogic/Modules/Background/dialogic_transition.gd b/addons/dialogic/Modules/Background/dialogic_transition.gd new file mode 100644 index 000000000..898cf87d2 --- /dev/null +++ b/addons/dialogic/Modules/Background/dialogic_transition.gd @@ -0,0 +1,75 @@ +extends Resource +class_name DialogicTransition + +const default_shader = preload("res://addons/dialogic/Modules/Background/default_background_transition.gdshader") + +@export var shader: Shader = default_shader + +@export var inherits : DialogicTransition = null + +@export var base_overrides := {} + +@export var name := "Transition": + get: + if name.is_empty(): + return "Unkown Transition" + return name + + +func _init(_name:="") -> void: + if not _name.is_empty(): + name = _name + + +## This always returns the inheritance root's shader. +func get_shader() -> Shader: + var shader := get_inheritance_root().shader + + return shader if shader else default_shader + + +func set_parameter(name: String, value: Variant) -> void: + base_overrides[name] = value + + changed.emit() + + +func remove_paramter(name: String) -> void: + base_overrides.erase(name) + + changed.emit() + + +func inherits_anything() -> bool: + return inherits != null + + +func get_transition_overrides(inherited_only:=false) -> Dictionary: + var transition := self + var overrides := base_overrides.duplicate(true) if inherited_only else {} + + while transition.inherits != null: + transition = transition.inherits + overrides.merge(transition.base_overrides) + + return overrides + + +func get_inheritance_root() -> DialogicTransition: + if inherits == null: + return self + + var transition : DialogicTransition = self + while transition.inherits != null: + transition = transition.inherits + + return transition + + +func clone() -> DialogicTransition: + var transition := DialogicTransition.new() + transition.name = name + transition.inherits = inherits + transition.base_overrides = base_overrides + + return transition From 01891108f678062ff16a8d4ed94a5235eac57e34 Mon Sep 17 00:00:00 2001 From: Pheubel Date: Wed, 6 Dec 2023 22:15:13 +0100 Subject: [PATCH 02/13] added rough editor for transitions --- .../default_background_transition.tres | 9 +- .../Modules/Background/dialogic_transition.gd | 10 +- addons/dialogic/Modules/Background/index.gd | 2 + .../Background/node_background_holder.gd | 2 - .../Modules/Background/transition_editor.gd | 274 +++++++++++++++ .../Modules/Background/transition_editor.tscn | 319 ++++++++++++++++++ .../Background/transition_setting_editor.gd | 264 +++++++++++++++ .../full_background_layer.gd | 12 - .../full_background_layer.tscn | 12 +- 9 files changed, 881 insertions(+), 23 deletions(-) create mode 100644 addons/dialogic/Modules/Background/transition_editor.gd create mode 100644 addons/dialogic/Modules/Background/transition_editor.tscn create mode 100644 addons/dialogic/Modules/Background/transition_setting_editor.gd delete mode 100644 addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd diff --git a/addons/dialogic/Modules/Background/default_background_transition.tres b/addons/dialogic/Modules/Background/default_background_transition.tres index ec0715918..97812b307 100644 --- a/addons/dialogic/Modules/Background/default_background_transition.tres +++ b/addons/dialogic/Modules/Background/default_background_transition.tres @@ -1,9 +1,10 @@ -[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://0wc7bedn7ee8"] +[gd_resource type="Resource" script_class="DialogicTransition" load_steps=3 format=3 uid="uid://3ol086bnxiai"] +[ext_resource type="Script" path="res://addons/dialogic/Modules/Background/dialogic_transition.gd" id="1_douvg"] [ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/default_background_transition.gdshader" id="1_uctph"] [resource] +script = ExtResource("1_douvg") shader = ExtResource("1_uctph") -shader_parameter/progress = 0.035 -shader_parameter/feather = 1.0 -shader_parameter/keep_aspect_ratio = false +base_overrides = {} +name = "Transition" diff --git a/addons/dialogic/Modules/Background/dialogic_transition.gd b/addons/dialogic/Modules/Background/dialogic_transition.gd index 898cf87d2..e19675d03 100644 --- a/addons/dialogic/Modules/Background/dialogic_transition.gd +++ b/addons/dialogic/Modules/Background/dialogic_transition.gd @@ -1,3 +1,4 @@ +@tool extends Resource class_name DialogicTransition @@ -21,6 +22,13 @@ func _init(_name:="") -> void: name = _name +func realize_inheritance() -> void: + base_overrides = get_transition_overrides() + + inherits = null + changed.emit() + + ## This always returns the inheritance root's shader. func get_shader() -> Shader: var shader := get_inheritance_root().shader @@ -46,7 +54,7 @@ func inherits_anything() -> bool: func get_transition_overrides(inherited_only:=false) -> Dictionary: var transition := self - var overrides := base_overrides.duplicate(true) if inherited_only else {} + var overrides := base_overrides.duplicate(true) if !inherited_only else {} while transition.inherits != null: transition = transition.inherits diff --git a/addons/dialogic/Modules/Background/index.gd b/addons/dialogic/Modules/Background/index.gd index 97c05b58f..180a79d6f 100644 --- a/addons/dialogic/Modules/Background/index.gd +++ b/addons/dialogic/Modules/Background/index.gd @@ -5,6 +5,8 @@ extends DialogicIndexer func _get_events() -> Array: return [this_folder.path_join('event_background.gd')] +func _get_editors() -> Array: + return [this_folder.path_join('transition_editor.tscn')] func _get_subsystems() -> Array: return [{'name':'Backgrounds', 'script':this_folder.path_join('subsystem_backgrounds.gd')}] diff --git a/addons/dialogic/Modules/Background/node_background_holder.gd b/addons/dialogic/Modules/Background/node_background_holder.gd index 35f4565ed..6b2c3b520 100644 --- a/addons/dialogic/Modules/Background/node_background_holder.gd +++ b/addons/dialogic/Modules/Background/node_background_holder.gd @@ -4,5 +4,3 @@ extends ColorRect func _ready(): add_to_group('dialogic_background_holders') - if material == null: - material = load("res://addons/dialogic/Modules/Background/default_background_transition.tres") diff --git a/addons/dialogic/Modules/Background/transition_editor.gd b/addons/dialogic/Modules/Background/transition_editor.gd new file mode 100644 index 000000000..0a40d3825 --- /dev/null +++ b/addons/dialogic/Modules/Background/transition_editor.gd @@ -0,0 +1,274 @@ +@tool +extends DialogicEditor + +const default_transition_resource : DialogicTransition = preload("res://addons/dialogic/Modules/Background/default_background_transition.tres") + +var transitions: Array[DialogicTransition] = [] +var current_transition : DialogicTransition = null +var default_transition := "" + + +enum AddTransitionButtonOptions { + NewTransition = 2, + InheritedTransition = 3 +} + + +func _get_title() -> String: + return "Transition" + +func _register() -> void: + editors_manager.register_simple_editor(self) + alternative_text = "Change the look of the background transitions in your game" + +func _open(extra_info: Variant = null) -> void: + load_transition_list() + + +func _close() -> void: + save_transition_list() + save_transition() + +func _ready() -> void: + collect_transitions() + + setup_ui() + +func add_transition(file_path: String, transition: DialogicTransition, inherits: DialogicTransition= null) -> void: + transition.resource_path = file_path + transition.inherits = inherits + + ResourceSaver.save(transition, file_path) + transitions.append(transition) + + save_transition_list() + load_transition_list() + select_transition(transition) + +func delete_transition(transition: DialogicTransition) -> void: + if current_transition == transition: + current_transition = null + + for other_transition in transitions: + if other_transition.inherits == transition: + other_transition.realize_inheritance() + push_warning('[Dialogic] Transition "', other_transition.name,'" had to be realized because it inherited "', transition.name,'" which was deleted!') + + if transition.resource_path == default_transition: + default_transition = "" + + transitions.erase(transition) + save_transition_list() + +func realize_transition() -> void: + current_transition.realize_inheritance() + + select_transition(current_transition) + +func select_transition(transition: DialogicTransition) -> void: + DialogicUtil.set_editor_setting('latest_background_transition', transition.name) + for idx in range(%TransitionList.item_count): + if %TransitionList.get_item_metadata(idx) == transition: + %TransitionList.select(idx) + return + +func setup_ui() -> void: + %AddButton.icon = get_theme_icon("Add", "EditorIcons") + %DuplicateButton.icon = get_theme_icon("Duplicate", "EditorIcons") + %InheritanceButton.icon = get_theme_icon("GuiDropdown", "EditorIcons") + %RemoveButton.icon = get_theme_icon("Remove", "EditorIcons") + + %EditNameButton.icon = get_theme_icon("Edit", "EditorIcons") + %TestTransitionButton.icon = get_theme_icon("PlayCustom", "EditorIcons") + %MakeDefaultButton.icon = get_theme_icon("Favorites", "EditorIcons") + + %TransitionList.item_selected.connect(_on_transitionlist_selected) + %AddButton.get_popup().index_pressed.connect(_on_AddTranstitionMenu_selected) + %AddButton.about_to_popup.connect(_on_AddTransitionMenu_about_to_popup) + %InheritanceButton.get_popup().index_pressed.connect(_on_inheritance_index_pressed) + %TransitionView.hide() + %NoTransitionView.show() + +#region signal hooks +func _on_transitionlist_selected(index: int) -> void: + load_transition(%TransitionList.get_item_metadata(index)) + +func _on_AddTransitionMenu_about_to_popup() -> void: + %AddButton.get_popup().set_item_disabled(3, not %TransitionList.is_anything_selected()) + +func _on_AddTranstitionMenu_selected(index: int) -> void: + #TODO: consider making an option to inherrit from a transition on a public repo? + + match index: + AddTransitionButtonOptions.NewTransition: + var new_transition: DialogicTransition = default_transition_resource.clone() + + find_parent('EditorView').godot_file_dialog( + add_transition_undoable.bind(new_transition), + '*.tres', + EditorFileDialog.FILE_MODE_SAVE_FILE, + "Select folder for new transition") + + AddTransitionButtonOptions.InheritedTransition: + if %StyleList.get_selected_items().is_empty(): + return + + find_parent('EditorView').godot_file_dialog( + add_transition_undoable.bind(DialogicTransition.new(), current_transition), + '*.tres', + EditorFileDialog.FILE_MODE_SAVE_FILE, + "Select folder for new style") + +func add_transition_undoable(file_path: String, transition: DialogicTransition, inherits: DialogicTransition = null) -> void: + transition.name = _get_new_name(file_path.get_file().trim_suffix('.'+file_path.get_extension())) + var undo_redo: EditorUndoRedoManager = DialogicUtil.get_dialogic_plugin().get_undo_redo() + undo_redo.create_action('Add Transition', UndoRedo.MERGE_ALL) + undo_redo.add_do_method(self, "add_transition", file_path, transition, inherits) + undo_redo.add_do_method(self, "load_transition_list") + undo_redo.add_undo_method(self, "delete_transition", transition) + undo_redo.add_undo_method(self, "load_transition_list") + undo_redo.commit_action() + DialogicUtil.set_editor_setting('latest_background_transition', transition.name) + +func _on_inheritance_index_pressed(index:int) -> void: + if index == 0: + realize_transition() + +func _on_duplicate_button_pressed(): + if !%TransitionList.is_anything_selected(): + return + + find_parent('EditorView').godot_file_dialog( + add_transition_undoable.bind(current_transition.clone(), current_transition), + '', + EditorFileDialog.FILE_MODE_SAVE_FILE, + "Select folder for new transition") + +func _on_remove_button_pressed(): + if !%TransitionList.is_anything_selected(): + return + + if current_transition.name == default_transition: + push_warning("[Dialogic] You cannot delete the default transition!") + return + + delete_transition(current_transition) + load_transition_list() + +func _on_make_default_button_pressed(): + default_transition = current_transition.resource_path + save_transition_list() + load_transition_list() + +func _on_create_transition_button_pressed() -> void: + var new_transition: DialogicTransition = default_transition_resource.clone() + + find_parent('EditorView').godot_file_dialog( + add_transition_undoable.bind(new_transition), + '*.tres', + EditorFileDialog.FILE_MODE_SAVE_FILE, + "Select folder for new transition") + +#endregion + +func collect_transitions() -> void: +# for indexer in DialogicUtil.get_indexers(): +# for layout in indexer._get_layout_parts(): +# premade_style_parts[layout['path']] = layout + + var transition_list: Array = ProjectSettings.get_setting('dialogic/transition/transition_list', []) + for transition in transition_list: + if ResourceLoader.exists(transition): + var transition_res := load(transition) + if transition != null: + transitions.append(ResourceLoader.load(transition, "DialogicTransition")) + else: + print("[Dialogic] Failed to open transition '", transition, "'. Some dependency might be broken.") + else: + print("[Dialogic] Failed to open transition '", transition, "'. Might have been moved or deleted.") + + default_transition = ProjectSettings.get_setting('dialogic/transition/default_transition', 'Default') + + +func load_transition_list() -> void: + var latest := DialogicUtil.get_editor_setting('latest_background_transition', 'Default') + + %TransitionList.clear() + var idx := 0 + for transition in transitions: + %TransitionList.add_item(transition.name, get_theme_icon("PopupMenu", "EditorIcons")) + if transition.resource_path == default_transition: + %TransitionList.set_item_icon_modulate(idx, get_theme_color("warning_color", "Editor")) + if transition.name == latest: + %TransitionList.select(idx) + load_transition(transition) + %TransitionList.set_item_tooltip(idx, transition.resource_path) + %TransitionList.set_item_metadata(idx, transition) + idx += 1 + + if len(transitions) == 0: + %TransitionView.hide() + %NoTransitionView.show() + + elif !%TransitionList.is_anything_selected(): + %TransitionList.select(0) + load_transition(%TransitionList.get_item_metadata(0)) + + +func save_transition_list() -> void: + ProjectSettings.set_setting('dialogic/transition/transition_list', transitions.map(func(transition:DialogicTransition): return transition.resource_path)) + ProjectSettings.set_setting('dialogic/transition/default_transition', default_transition) + ProjectSettings.save() + +func save_transition() -> void: + if current_transition == null: + return + + print("[Dialogic] Saved ", current_transition.name) + ResourceSaver.save(current_transition) + + +func load_transition(transition: DialogicTransition) -> void: + if current_transition != null: + current_transition.changed.disconnect(save_transition) + save_transition() + current_transition = transition + if current_transition == null: + return + current_transition.changed.connect(save_transition) + + %BackgroundTransitionName.text = transition.name + if transition.resource_path == default_transition: + %MakeDefaultButton.tooltip_text = "Is Default" + %MakeDefaultButton.disabled = true + else: + %MakeDefaultButton.tooltip_text = "Make Default" + %MakeDefaultButton.disabled = false + + %TransitionEditor.load_transition(transition) + + %InheritanceButton.visible = transition.inherits_anything() + if %InheritanceButton.visible: + %InheritanceButton.text = "Inherits " + transition.inherits.name + + + DialogicUtil.set_editor_setting('latest_background_transition', transition.name) + + %TransitionView.show() + %NoTransitionView.hide() + +func _get_new_name(base_name: String) -> String: + var new_name_idx := 1 + var found_unique_name := false + var new_name := base_name + while not found_unique_name: + found_unique_name = true + for transition in transitions: + if transition.name == new_name: + new_name_idx += 1 + new_name = base_name+" "+str(new_name_idx) + found_unique_name = false + return new_name + + + diff --git a/addons/dialogic/Modules/Background/transition_editor.tscn b/addons/dialogic/Modules/Background/transition_editor.tscn new file mode 100644 index 000000000..51366d6e1 --- /dev/null +++ b/addons/dialogic/Modules/Background/transition_editor.tscn @@ -0,0 +1,319 @@ +[gd_scene load_steps=15 format=3 uid="uid://bnt7spjq5k6kt"] + +[ext_resource type="Script" path="res://addons/dialogic/Modules/Background/transition_editor.gd" id="1_mg8i8"] +[ext_resource type="PackedScene" uid="uid://dbpkta2tjsqim" path="res://addons/dialogic/Editor/Common/hint_tooltip_icon.tscn" id="2_n5tec"] +[ext_resource type="Script" path="res://addons/dialogic/Modules/Background/transition_setting_editor.gd" id="3_5uve6"] + +[sub_resource type="Image" id="Image_ebqxh"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), +"format": "RGBA8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id="ImageTexture_c81y7"] +image = SubResource("Image_ebqxh") + +[sub_resource type="Image" id="Image_kw1o5"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), +"format": "RGBA8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id="ImageTexture_xtj53"] +image = SubResource("Image_kw1o5") + +[sub_resource type="Theme" id="Theme_l6tyr"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tixgs"] + +[sub_resource type="Image" id="Image_svp6i"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), +"format": "RGBA8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id="ImageTexture_isjve"] +image = SubResource("Image_svp6i") + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0nh8y"] +bg_color = Color(1, 1, 1, 1) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_right = 10 +corner_radius_bottom_left = 10 + +[sub_resource type="Image" id="Image_p1pql"] +data = { +"data": PackedByteArray(0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255), +"format": "RGBA8", +"height": 2, +"mipmaps": false, +"width": 2 +} + +[sub_resource type="ImageTexture" id="ImageTexture_yr3tj"] +image = SubResource("Image_p1pql") + +[node name="TransitionEditor" type="HSplitContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -3.0 +offset_bottom = 3.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/separation = 0 +script = ExtResource("1_mg8i8") + +[node name="Panel" type="PanelContainer" parent="."] +custom_minimum_size = Vector2(150, 0) +layout_mode = 2 +size_flags_stretch_ratio = 0.2 +theme_type_variation = &"DialogicPanelA" + +[node name="VBox" type="VBoxContainer" parent="Panel"] +layout_mode = 2 + +[node name="Title" type="HBoxContainer" parent="Panel/VBox"] +layout_mode = 2 + +[node name="TransitionListTitle" type="Label" parent="Panel/VBox/Title"] +layout_mode = 2 +theme_type_variation = &"DialogicSubTitle" +text = "Transitions" + +[node name="HintTooltip" parent="Panel/VBox/Title" instance=ExtResource("2_n5tec")] +layout_mode = 2 +tooltip_text = "TODO" +texture = SubResource("ImageTexture_c81y7") +hint_text = "TODO" + +[node name="TransitionButtons" type="HBoxContainer" parent="Panel/VBox"] +layout_mode = 2 +alignment = 2 + +[node name="AddButton" type="MenuButton" parent="Panel/VBox/TransitionButtons"] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Add background transition" +icon = SubResource("ImageTexture_c81y7") +switch_on_hover = true +item_count = 4 +popup/item_0/text = "ADD STYLE" +popup/item_0/id = 0 +popup/item_0/disabled = true +popup/item_1/text = "" +popup/item_1/id = 0 +popup/item_1/separator = true +popup/item_2/text = "New Transition" +popup/item_2/id = 0 +popup/item_3/text = "Inherited Transition" +popup/item_3/id = 1 + +[node name="DuplicateButton" type="Button" parent="Panel/VBox/TransitionButtons"] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Duplicate transition" +icon = SubResource("ImageTexture_c81y7") +flat = true + +[node name="RemoveButton" type="Button" parent="Panel/VBox/TransitionButtons"] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Remove transition from list" +icon = SubResource("ImageTexture_c81y7") +flat = true + +[node name="MakeDefaultButton" type="Button" parent="Panel/VBox/TransitionButtons"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 4 +tooltip_text = "Make Default" +toggle_mode = true +icon = SubResource("ImageTexture_c81y7") +flat = true + +[node name="TransitionList" type="ItemList" parent="Panel/VBox"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 3 +item_count = 1 +item_0/text = "Transition" +item_0/icon = SubResource("ImageTexture_xtj53") + +[node name="TransitionView" type="VBoxContainer" parent="."] +unique_name_in_owner = true +visible = false +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="HBox" type="HBoxContainer" parent="TransitionView"] +layout_mode = 2 +theme = SubResource("Theme_l6tyr") +theme_override_constants/separation = 0 + +[node name="BackgroundTransitionName" type="LineEdit" parent="TransitionView/HBox"] +unique_name_in_owner = true +layout_mode = 2 +theme_type_variation = &"DialogicTitle" +theme_override_styles/normal = SubResource("StyleBoxEmpty_tixgs") +theme_override_styles/focus = SubResource("StyleBoxEmpty_tixgs") +theme_override_styles/read_only = SubResource("StyleBoxEmpty_tixgs") +text = "Transition" +expand_to_text_length = true + +[node name="EditNameButton" type="Button" parent="TransitionView/HBox"] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Edit Name" +icon = SubResource("ImageTexture_c81y7") +flat = true + +[node name="InheritanceButton" type="MenuButton" parent="TransitionView/HBox"] +unique_name_in_owner = true +visible = false +layout_mode = 2 +text = "Inherits VN Transition" +icon = SubResource("ImageTexture_c81y7") +icon_alignment = 2 +item_count = 1 +popup/item_0/text = "Clear Inheritance" +popup/item_0/id = 0 + +[node name="TestTransitionButton" type="Button" parent="TransitionView/HBox"] +unique_name_in_owner = true +visible = false +layout_mode = 2 +size_flags_horizontal = 10 +tooltip_text = "Play current timeline with this style" +text = "Test Transition" +icon = SubResource("ImageTexture_c81y7") + +[node name="PanelContainer" type="PanelContainer" parent="TransitionView"] +layout_mode = 2 +size_flags_vertical = 3 +theme_type_variation = &"DialogicPanelB" + +[node name="TransitionEditor" type="HSplitContainer" parent="TransitionView/PanelContainer"] +unique_name_in_owner = true +layout_mode = 2 +script = ExtResource("3_5uve6") + +[node name="TransitionSettings" type="VBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TransitionInfoHeader" type="HBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings"] +layout_mode = 2 + +[node name="TransitionName" type="Label" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoHeader"] +unique_name_in_owner = true +layout_mode = 2 +theme_type_variation = &"DialogicTitle" +text = "Default Transition Base" + +[node name="ExpandTransitionInfo" type="Button" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoHeader"] +unique_name_in_owner = true +layout_mode = 2 +icon = SubResource("ImageTexture_isjve") +flat = true + +[node name="TransitionInfoBody" type="VBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings"] +unique_name_in_owner = true +layout_mode = 2 + +[node name="HBox" type="HBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody"] +layout_mode = 2 + +[node name="Panel" type="PanelContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox"] +show_behind_parent = true +clip_children = 2 +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_0nh8y") + +[node name="SmallTransitionPreview" type="TextureRect" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Panel"] +unique_name_in_owner = true +layout_mode = 2 +texture = SubResource("ImageTexture_yr3tj") +expand_mode = 3 +stretch_mode = 6 + +[node name="Info" type="VBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/separation = 0 + +[node name="HBoxContainer" type="HBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info"] +layout_mode = 2 +theme_override_constants/separation = 0 + +[node name="SmallTransitionAuthor" type="Label" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info/HBoxContainer"] +unique_name_in_owner = true +self_modulate = Color(1, 1, 1, 0.603922) +layout_mode = 2 +theme_type_variation = &"DialogicHintText" +text = "Dialogic" + +[node name="Description" type="HBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info"] +layout_mode = 2 +theme_override_constants/separation = 0 + +[node name="Label" type="Label" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info/Description"] +layout_mode = 2 +theme_type_variation = &"DialogicHintText2" +text = "Info:" + +[node name="SmallTransitionDescription" type="Label" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info/Description"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 1 +theme_type_variation = &"DialogicHintText2" +text = "A very simple base for transitions." +autowrap_mode = 3 +text_overrun_behavior = 4 + +[node name="TransitionSettingsTabs" type="TabContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 3 + +[node name="Margin" type="Control" parent="TransitionView"] +custom_minimum_size = Vector2(0, 10) +layout_mode = 2 + +[node name="NoTransitionView" type="VBoxContainer" parent="."] +unique_name_in_owner = true +layout_mode = 2 +alignment = 1 + +[node name="Label" type="Label" parent="NoTransitionView"] +layout_mode = 2 +text = "You have not setup any transitions." +horizontal_alignment = 1 +autowrap_mode = 3 + +[node name="CreateTransitionButton" type="Button" parent="NoTransitionView"] +layout_mode = 2 +size_flags_horizontal = 4 +tooltip_text = "Make a custom style from a variation of the fallback." +text = "Make my own!" + +[connection signal="pressed" from="Panel/VBox/TransitionButtons/DuplicateButton" to="." method="_on_duplicate_button_pressed"] +[connection signal="pressed" from="Panel/VBox/TransitionButtons/RemoveButton" to="." method="_on_remove_button_pressed"] +[connection signal="pressed" from="Panel/VBox/TransitionButtons/MakeDefaultButton" to="." method="_on_make_default_button_pressed"] +[connection signal="focus_exited" from="TransitionView/HBox/BackgroundTransitionName" to="." method="_on_layout_style_name_focus_exited"] +[connection signal="text_submitted" from="TransitionView/HBox/BackgroundTransitionName" to="." method="_on_layout_style_name_text_submitted"] +[connection signal="pressed" from="TransitionView/HBox/EditNameButton" to="." method="_on_edit_name_button_pressed"] +[connection signal="pressed" from="TransitionView/HBox/TestTransitionButton" to="." method="_on_test_style_button_pressed"] +[connection signal="pressed" from="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoHeader/ExpandTransitionInfo" to="TransitionView/PanelContainer/TransitionEditor" method="_on_expand_transition_info_pressed"] +[connection signal="pressed" from="NoTransitionView/CreateTransitionButton" to="." method="_on_create_transition_button_pressed"] diff --git a/addons/dialogic/Modules/Background/transition_setting_editor.gd b/addons/dialogic/Modules/Background/transition_setting_editor.gd new file mode 100644 index 000000000..877e374bd --- /dev/null +++ b/addons/dialogic/Modules/Background/transition_setting_editor.gd @@ -0,0 +1,264 @@ +@tool +extends HSplitContainer + +var current_transition: DialogicTransition = null + +var customization_editor_info := {} + +func load_transition(transition: DialogicTransition) -> void: + current_transition = transition + + load_transition_settings_list() + +func load_transition_settings_list() -> void: + var overrides := current_transition.get_transition_overrides() + var inherrited_overrides := current_transition.get_transition_overrides(true) + + %SmallTransitionPreview.hide() + + load_transition_customization(overrides, inherrited_overrides) + +func load_transition_customization(overrides: Dictionary = {}, inherited_overrides: Dictionary = {}) -> void: + for child in %TransitionSettingsTabs.get_children(): + child.get_parent().remove_child(child) + child.queue_free() + + var shader = current_transition.get_shader() + + var settings := [] + + settings.append({'name':'Resource', 'added':false, 'id':&"GROUP"}) + + var transition_properties = current_transition.get_property_list() + var prop = transition_properties.filter(func (p: Variant) -> bool: return p['name'] == "shader")[0] + prop['id'] = &"SETTING" + settings.append(prop) + + if shader: + settings.append_array(collect_settings(shader.get_shader_uniform_list())) + + if settings.is_empty(): + var note := Label.new() + note.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART + note.text = "This layer has no exposed settings." + note.theme_type_variation = 'DialogicHintText2' + %TransitionSettingsTabs.add_child(note) + note.name = "General" + return + + var current_grid: GridContainer = null + + var label_bg_style = get_theme_stylebox("CanvasItemInfoOverlay", "EditorStyles").duplicate() + label_bg_style.content_margin_left = 5 + label_bg_style.content_margin_right = 5 + label_bg_style.content_margin_top = 5 + + var current_group_name := "" + var current_subgroup_name := "" + customization_editor_info = {} + + for i in settings: + match i['id']: + &"GROUP": + var main_scroll = ScrollContainer.new() + main_scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL + main_scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL + main_scroll.name = i['name'] + %TransitionSettingsTabs.add_child(main_scroll, true) + + current_grid = GridContainer.new() + current_grid.columns = 3 + current_grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL + main_scroll.add_child(current_grid) + current_group_name = i['name'].to_snake_case() + current_subgroup_name = "" + + &"SUBGROUP": + + # add separator + if current_subgroup_name: + current_grid.add_child(HSeparator.new()) + current_grid.get_child(-1).add_theme_constant_override('separation', 20) + current_grid.add_child(current_grid.get_child(-1).duplicate()) + current_grid.add_child(current_grid.get_child(-1).duplicate()) + + var title_label := Label.new() + title_label.text = i['name'] + title_label.theme_type_variation = "DialogicSection" + title_label.size_flags_horizontal = SIZE_EXPAND_FILL + current_grid.add_child(title_label, true) + + # add spaced to the grid + current_grid.add_child(Control.new()) + current_grid.add_child(Control.new()) + + current_subgroup_name = i['name'].to_snake_case() + + &"SETTING": + var label := Label.new() + label.text = str(i['name'].trim_prefix(current_group_name+'_').trim_prefix(current_subgroup_name+'_')).capitalize() + current_grid.add_child(label, true) + + customization_editor_info[i['name']] = {} + var current_value :Variant + var input :Node + + if current_group_name == "resource": + current_value = current_transition.shader + customization_editor_info[i['name']]['orig'] = preload("res://addons/dialogic/Modules/Background/default_background_transition.gdshader") + + else: + if i['name'] in inherited_overrides: + var override = inherited_overrides.get(i['name']) + customization_editor_info[i['name']]['orig'] = str_to_var(override) if override is String else override + else: + customization_editor_info[i['name']]['orig'] = RenderingServer.shader_get_parameter_default(shader.get_rid(), i['name']) + + if i['name'] in overrides: + var override = overrides.get(i['name']) + current_value = str_to_var(override) if override is String else override + else: + current_value = customization_editor_info[i['name']]['orig'] + + input= DialogicUtil.setup_script_property_edit_node(i, current_value, set_export_override) + + # TODO: remove manual overriding once resources are supported in dialogic utils + if i['type'] == TYPE_OBJECT: + input = EditorResourcePicker.new() + input.edited_resource = current_value + input.base_type = i['hint_string'] + + if current_group_name == "resource": + if current_transition.inherits_anything() and 'editable' in input: + input.editable = false + + #TODO: make this less specific so it can be used for more than one parameter + input.resource_changed.connect(func (resource: Resource) -> void: + current_transition.shader = resource as Shader + ) + + else: + input.resource_changed.connect(func (resource: Resource) -> void: + if resource != customization_editor_info[i.name]['orig']: + current_transition.set_parameter(i.name, resource) + customization_editor_info[i.name]['reset'].disabled = false + else: + current_transition.remove_paramter(i.name) + customization_editor_info[i.name]['reset'].disabled = true + ) + + + + input.size_flags_horizontal = SIZE_EXPAND_FILL + customization_editor_info[i['name']]['node'] = input + + var reset := Button.new() + reset.flat = true + reset.icon = get_theme_icon("Reload", "EditorIcons") + reset.tooltip_text = "Remove customization" + customization_editor_info[i['name']]['reset'] = reset + reset.disabled = current_value == customization_editor_info[i['name']]['orig'] + current_grid.add_child(reset) + if current_group_name == "resource": + reset.pressed.connect(func() : + var default_shader = customization_editor_info[i['name']]['orig'] + current_transition.shader = default_shader + customization_editor_info[i['name']]['reset'].disabled = true + set_customization_value(i['name'], default_shader) + ) + else: + reset.pressed.connect(_on_export_override_reset.bind(i['name'])) + current_grid.add_child(input) + + +func collect_settings(properties: Array) -> Array[Dictionary]: + var settings: Array[Dictionary] = [] + + var current_group := {} + var current_subgroup := {} + + for i in properties: + if i['usage'] & PROPERTY_USAGE_CATEGORY: + continue + + if (i['usage'] & PROPERTY_USAGE_GROUP): + current_group = i + current_group['added'] = false + current_group['id'] = &'GROUP' + current_subgroup = {} + + elif i['usage'] & PROPERTY_USAGE_SUBGROUP: + current_subgroup = i + current_subgroup['added'] = false + current_subgroup['id'] = &'SUBGROUP' + + elif i['usage'] & PROPERTY_USAGE_EDITOR: + if _is_reserved_uniform(i): + continue + + if current_group.get('name', '') == 'Private': + continue + + if current_group.is_empty(): + current_group = {'name':'Parameters', 'added':false, 'id':&"GROUP"} + + if current_group.get('added', true) == false: + settings.append(current_group) + current_group['added'] = true + + if current_subgroup.is_empty(): + current_subgroup = {'name':current_group['name'], 'added':false, 'id':&"SUBGROUP"} + + if current_subgroup.get('added', true) == false: + settings.append(current_subgroup) + current_subgroup['added'] = true + + i['id'] = &'SETTING' + settings.append(i) + return settings + + +func set_export_override(property_name: String, value: String = "") -> void: + if str_to_var(value) != customization_editor_info[property_name]['orig']: + current_transition.set_parameter(property_name, value) + customization_editor_info[property_name]['reset'].disabled = false + else: + current_transition.remove_paramter(property_name) + customization_editor_info[property_name]['reset'].disabled = true + + +func _on_export_override_reset(property_name: String) -> void: + current_transition.remove_paramter(property_name) + customization_editor_info[property_name]['reset'].disabled = true + set_customization_value(property_name, customization_editor_info[property_name]['orig']) + + +func set_customization_value(property_name:String, value:Variant) -> void: + var node : Node = customization_editor_info[property_name]['node'] + + if node is CheckBox: + node.button_pressed = true if value else false + elif node is LineEdit: + node.text = value + elif node is EditorResourcePicker: + node.edited_resource = value + elif node.has_method('set_value'): + node.set_value(0 if !value else value) + elif node is ColorPickerButton: + node.color = value + elif node is OptionButton: + node.select(value) + elif node is SpinBox: + node.value = 0 if !value else value + +func _is_reserved_uniform(uniform: Variant) -> bool: + return uniform["name"] == "progress" || uniform["name"] == "previous_background" || uniform["name"] == "next_background" + + +func _on_expand_transition_info_pressed() -> void: + if %TransitionInfoBody.visible: + %TransitionInfoBody.hide() + %ExpandTransitionInfo.icon = get_theme_icon("CodeFoldedRightArrow", "EditorIcons") + else: + %TransitionInfoBody.show() + %ExpandTransitionInfo.icon = get_theme_icon("CodeFoldDownArrow", "EditorIcons") diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd deleted file mode 100644 index 0ab3886fa..000000000 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd +++ /dev/null @@ -1,12 +0,0 @@ -@tool -extends DialogicLayoutLayer - -## A layer that holds full-screen backgrounds. - -@export_group('Transition') -@export_file('*.tres') var transition_shader_material := "" - - -func _apply_export_overrides() -> void: - if ResourceLoader.exists(transition_shader_material): - $DialogicNode_BackgroundHolder.material = load(transition_shader_material) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn index c083d8b0a..ad54443de 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn @@ -1,9 +1,14 @@ [gd_scene load_steps=4 format=3 uid="uid://c1k5m0w3r40xf"] -[ext_resource type="Material" uid="uid://0wc7bedn7ee8" path="res://addons/dialogic/Modules/Background/default_background_transition.tres" id="1_ccins"] -[ext_resource type="Script" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd" id="1_srvyd"] +[ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/default_background_transition.gdshader" id="1_ygjlc"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Background/node_background_holder.gd" id="2_ghan2"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_msuxf"] +shader = ExtResource("1_ygjlc") +shader_parameter/progress = null +shader_parameter/feather = 0.1 +shader_parameter/keep_aspect_ratio = false + [node name="BackgroundLayer" type="Control"] layout_mode = 3 anchors_preset = 15 @@ -11,10 +16,9 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -script = ExtResource("1_srvyd") [node name="DialogicNode_BackgroundHolder" type="ColorRect" parent="."] -material = ExtResource("1_ccins") +material = SubResource("ShaderMaterial_msuxf") layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 From 64b95d6065ea189c6af642d37212a2c3cd41c7ff Mon Sep 17 00:00:00 2001 From: Pheubel Date: Wed, 6 Dec 2023 22:54:51 +0100 Subject: [PATCH 03/13] background event should have access to transitions --- .../Modules/Background/event_background.gd | 36 ++++++++++++++++--- .../Background/subsystem_backgrounds.gd | 27 ++++++++------ 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/addons/dialogic/Modules/Background/event_background.gd b/addons/dialogic/Modules/Background/event_background.gd index 405aa742d..d69a46389 100644 --- a/addons/dialogic/Modules/Background/event_background.gd +++ b/addons/dialogic/Modules/Background/event_background.gd @@ -17,6 +17,8 @@ var argument: String = "" ## The time the fade animation will take. Leave at 0 for instant change. var fade: float = 0.0 +var transition_path : String = "" + ################################################################################ ## EXECUTION @@ -28,8 +30,16 @@ func _execute() -> void: if Dialogic.Input.auto_skip.enabled: var time_per_event: float = Dialogic.Input.auto_skip.time_per_event final_fade_duration = min(fade, time_per_event) - - dialogic.Backgrounds.update_background(scene, argument, final_fade_duration) + + var transition: DialogicTransition + if !transition_path.is_empty(): + transition = load(transition_path) as DialogicTransition + + if transition: + dialogic.Backgrounds.update_background(scene, argument, final_fade_duration, transition) + else: + dialogic.Backgrounds.update_background(scene, argument, final_fade_duration) + finish() @@ -55,9 +65,10 @@ func get_shortcode() -> String: func get_shortcode_parameters() -> Dictionary: return { #param_name : property_info - "scene" : {"property": "scene", "default": ""}, - "arg" : {"property": "argument", "default": ""}, - "fade" : {"property": "fade", "default": 0}, + "scene" : {"property": "scene", "default": ""}, + "arg" : {"property": "argument", "default": ""}, + "fade" : {"property": "fade", "default": 0}, + "transition" : {"property": "transition_path", "default": ""}, } @@ -79,3 +90,18 @@ func build_event_editor(): 'file_filter':'*.tscn, *.scn; Scene Files', 'placeholder': "Default scene", 'editor_icon':["PackedScene", "EditorIcons"]}) + add_body_edit("transition_path", ValueType.COMPLEX_PICKER, + {'left_text':'transition', + 'empty_text':'Default', + 'suggestions_func':get_transition_suggestions, + 'editor_icon':["PopupMenu", "EditorIcons"]}, 'autoload_name') + + +func get_transition_suggestions(filter:String="") -> Dictionary: + var transitions := ProjectSettings.get_setting('dialogic/layout/style_list', []) + var suggestions := {} + suggestions["No Transition"] = {'value': "", 'editor_icon': ["EditorHandleDisabled", "EditorIcons"]} + for i in transitions: + var transition: DialogicTransition = load(i) + suggestions[transition.name] = {'value': transition.name, 'editor_icon': ["PopupMenu", "EditorIcons"]} + return suggestions diff --git a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd index 8e73751e3..1a13aed3d 100644 --- a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd +++ b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd @@ -8,6 +8,7 @@ var _tween: Tween var _tween_callbacks: Array[Callable] var default_background_scene: PackedScene = load(get_script().resource_path.get_base_dir().path_join('default_background.tscn')) +const default_transition: DialogicTransition = preload("res://addons/dialogic/Modules/Background/default_background_transition.tres") #################################################################################################### ## STATE @@ -34,7 +35,7 @@ func load_game_state(load_flag:=LoadFlags.FULL_LOAD): ## 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:String = '', argument:String = '', fade_time:float = 0.0) -> void: +func update_background(scene:String = '', argument:String = '', fade_time:float = 0.0, transition: DialogicTransition = default_transition) -> void: var background_holder: DialogicNode_BackgroundHolder = get_tree().get_first_node_in_group('dialogic_background_holders') if background_holder == null: return @@ -56,22 +57,28 @@ func update_background(scene:String = '', argument:String = '', fade_time:float # If that didn't work, add a new scene, then cross-fade if !bg_set: - var material: Material = background_holder.material + var previous_material = background_holder.material + var material := ShaderMaterial.new() + background_holder.material = material + + material.shader = transition.shader + # make sure material is clean and ready to go material.set_shader_parameter("progress", 0) # swap the next background into previous, as that is now the older frame - material.set_shader_parameter("previous_background", material.get_shader_parameter("next_background")) + material.set_shader_parameter("previous_background", previous_material.get_shader_parameter("next_background") if previous_material else null) material.set_shader_parameter("next_background", null) - + + if _tween: _tween.kill() - + _tween = get_tree().create_tween() - - # could be implemented as passed by the event - #material.set_shader_parameter("whipe_texture", whipe_texture) # the direction the whipe takes from black to white - #material.set_shader_parameter("feather", feather) # the trailing smear left behind when the whipe happens - + + var parameter_overrides := transition.get_transition_overrides() + for parameter_override in parameter_overrides: + material.set_shader_parameter(parameter_override, parameter_overrides[parameter_override]) + _tween.tween_method(func (progress: float): material.set_shader_parameter("progress", progress) , 0.0, 1.0, fade_time) From 4cf8d3bb7849c100cf1022bd386c85610a66ada4 Mon Sep 17 00:00:00 2001 From: Pheubel Date: Wed, 6 Dec 2023 23:36:56 +0100 Subject: [PATCH 04/13] fixed spelling mistake --- .../Background/default_background_transition.gdshader | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/dialogic/Modules/Background/default_background_transition.gdshader b/addons/dialogic/Modules/Background/default_background_transition.gdshader index d631d9ff0..9ae2c306a 100644 --- a/addons/dialogic/Modules/Background/default_background_transition.gdshader +++ b/addons/dialogic/Modules/Background/default_background_transition.gdshader @@ -8,10 +8,10 @@ uniform sampler2D previous_background : source_color, hint_default_transparent; 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 whipe_texture : source_color; +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 whipe texture should keep it's aspect ratio when scaled to the screen's size. +// 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() { @@ -24,7 +24,7 @@ void fragment() { } // get the blend factor between the previous and next background. - float alpha = (texture(whipe_texture, frag_coord).r) - progress; + 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); From 0e57c1a24de48db9a221155224a021f1b3ea9106 Mon Sep 17 00:00:00 2001 From: Pheubel Date: Wed, 6 Dec 2023 23:38:03 +0100 Subject: [PATCH 05/13] fixed layout i broke earlier --- .../Layer_FullBackground/full_background_layer.gd | 2 ++ .../Layer_FullBackground/full_background_layer.tscn | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd new file mode 100644 index 000000000..9162300ec --- /dev/null +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd @@ -0,0 +1,2 @@ +@tool +extends DialogicLayoutLayer diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn index ad54443de..31bbfbeb4 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=4 format=3 uid="uid://c1k5m0w3r40xf"] +[gd_scene load_steps=5 format=3 uid="uid://c1k5m0w3r40xf"] +[ext_resource type="Script" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd" id="1_tu40u"] [ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/default_background_transition.gdshader" id="1_ygjlc"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Background/node_background_holder.gd" id="2_ghan2"] @@ -16,6 +17,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_tu40u") [node name="DialogicNode_BackgroundHolder" type="ColorRect" parent="."] material = SubResource("ShaderMaterial_msuxf") From c1da48faac322fe471ca8ee422d301b1fcbfc003 Mon Sep 17 00:00:00 2001 From: Pheubel Date: Wed, 6 Dec 2023 23:39:54 +0100 Subject: [PATCH 06/13] in functioning state --- .../Background/default_background_transition.tres | 14 ++++++++++++-- .../Modules/Background/event_background.gd | 9 +++++---- .../Modules/Background/transition_editor.gd | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/addons/dialogic/Modules/Background/default_background_transition.tres b/addons/dialogic/Modules/Background/default_background_transition.tres index 97812b307..6ebf42439 100644 --- a/addons/dialogic/Modules/Background/default_background_transition.tres +++ b/addons/dialogic/Modules/Background/default_background_transition.tres @@ -1,10 +1,20 @@ -[gd_resource type="Resource" script_class="DialogicTransition" load_steps=3 format=3 uid="uid://3ol086bnxiai"] +[gd_resource type="Resource" script_class="DialogicTransition" load_steps=5 format=3 uid="uid://3ol086bnxiai"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Background/dialogic_transition.gd" id="1_douvg"] [ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/default_background_transition.gdshader" id="1_uctph"] +[sub_resource type="Gradient" id="Gradient_n6t2j"] +offsets = PackedFloat32Array(1) +colors = PackedColorArray(0.498039, 0.498039, 0.498039, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_fjhwy"] +gradient = SubResource("Gradient_n6t2j") + [resource] script = ExtResource("1_douvg") shader = ExtResource("1_uctph") -base_overrides = {} +base_overrides = { +"feather": 1.0, +"wipe_texture": SubResource("GradientTexture1D_fjhwy") +} name = "Transition" diff --git a/addons/dialogic/Modules/Background/event_background.gd b/addons/dialogic/Modules/Background/event_background.gd index d69a46389..842855ba5 100644 --- a/addons/dialogic/Modules/Background/event_background.gd +++ b/addons/dialogic/Modules/Background/event_background.gd @@ -94,14 +94,15 @@ func build_event_editor(): {'left_text':'transition', 'empty_text':'Default', 'suggestions_func':get_transition_suggestions, - 'editor_icon':["PopupMenu", "EditorIcons"]}, 'autoload_name') + 'editor_icon':["PopupMenu", "EditorIcons"]}) func get_transition_suggestions(filter:String="") -> Dictionary: - var transitions := ProjectSettings.get_setting('dialogic/layout/style_list', []) + var transitions := ProjectSettings.get_setting('dialogic/transition/transition_list', []) + print(transitions) var suggestions := {} - suggestions["No Transition"] = {'value': "", 'editor_icon': ["EditorHandleDisabled", "EditorIcons"]} + suggestions["Default Transition"] = {'value': "", 'editor_icon': ["EditorHandleDisabled", "EditorIcons"]} for i in transitions: var transition: DialogicTransition = load(i) - suggestions[transition.name] = {'value': transition.name, 'editor_icon': ["PopupMenu", "EditorIcons"]} + suggestions[transition.name] = {'value': transition.resource_path, 'editor_icon': ["PopupMenu", "EditorIcons"]} return suggestions diff --git a/addons/dialogic/Modules/Background/transition_editor.gd b/addons/dialogic/Modules/Background/transition_editor.gd index 0a40d3825..eb4ad5c16 100644 --- a/addons/dialogic/Modules/Background/transition_editor.gd +++ b/addons/dialogic/Modules/Background/transition_editor.gd @@ -110,14 +110,14 @@ func _on_AddTranstitionMenu_selected(index: int) -> void: "Select folder for new transition") AddTransitionButtonOptions.InheritedTransition: - if %StyleList.get_selected_items().is_empty(): + if %TransitionList.get_selected_items().is_empty(): return find_parent('EditorView').godot_file_dialog( add_transition_undoable.bind(DialogicTransition.new(), current_transition), '*.tres', EditorFileDialog.FILE_MODE_SAVE_FILE, - "Select folder for new style") + "Select folder for new transition") func add_transition_undoable(file_path: String, transition: DialogicTransition, inherits: DialogicTransition = null) -> void: transition.name = _get_new_name(file_path.get_file().trim_suffix('.'+file_path.get_extension())) From 08bfb60903b20937edc87b7652f65e0d7e3ad679 Mon Sep 17 00:00:00 2001 From: Pheubel Date: Wed, 6 Dec 2023 23:59:32 +0100 Subject: [PATCH 07/13] allow for custom defaults for transitions --- addons/dialogic/Modules/Background/event_background.gd | 3 +++ addons/dialogic/Modules/Background/transition_editor.gd | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/dialogic/Modules/Background/event_background.gd b/addons/dialogic/Modules/Background/event_background.gd index 842855ba5..6c2aaa110 100644 --- a/addons/dialogic/Modules/Background/event_background.gd +++ b/addons/dialogic/Modules/Background/event_background.gd @@ -34,6 +34,9 @@ func _execute() -> void: var transition: DialogicTransition if !transition_path.is_empty(): transition = load(transition_path) as DialogicTransition + else: + var default_transition_path = ProjectSettings.get_setting('dialogic/transition/default_transition','') + transition = load(default_transition_path) as DialogicTransition if !default_transition_path.is_empty() else null if transition: dialogic.Backgrounds.update_background(scene, argument, final_fade_duration, transition) diff --git a/addons/dialogic/Modules/Background/transition_editor.gd b/addons/dialogic/Modules/Background/transition_editor.gd index eb4ad5c16..d2cc3582f 100644 --- a/addons/dialogic/Modules/Background/transition_editor.gd +++ b/addons/dialogic/Modules/Background/transition_editor.gd @@ -187,11 +187,11 @@ func collect_transitions() -> void: else: print("[Dialogic] Failed to open transition '", transition, "'. Might have been moved or deleted.") - default_transition = ProjectSettings.get_setting('dialogic/transition/default_transition', 'Default') + default_transition = ProjectSettings.get_setting('dialogic/transition/default_transition', '') func load_transition_list() -> void: - var latest := DialogicUtil.get_editor_setting('latest_background_transition', 'Default') + var latest := DialogicUtil.get_editor_setting('latest_background_transition', '') %TransitionList.clear() var idx := 0 From 306b6c5516793dbf548cc670ac2a2d7fb55835c0 Mon Sep 17 00:00:00 2001 From: Pheubel Date: Thu, 7 Dec 2023 00:13:33 +0100 Subject: [PATCH 08/13] make sure that texture stays centered when scaled --- .../Background/default_background_transition.gdshader | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/dialogic/Modules/Background/default_background_transition.gdshader b/addons/dialogic/Modules/Background/default_background_transition.gdshader index 9ae2c306a..5c3cf3947 100644 --- a/addons/dialogic/Modules/Background/default_background_transition.gdshader +++ b/addons/dialogic/Modules/Background/default_background_transition.gdshader @@ -17,10 +17,12 @@ 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 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 *= ratio; + frag_coord += ((vec2(1,1) - ratio) / 2.0); } // get the blend factor between the previous and next background. From 7e2aebe6ec539ef1231fc7df0ce0779701852a48 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Wed, 13 Dec 2023 16:19:20 +0100 Subject: [PATCH 09/13] Simplify background transition system --- .../default_background.gd | 4 - .../default_background.tscn | 2 +- .../default_background_transition.gd | 14 + .../default_background_transition.gdshader | 2 +- .../class_dialogic_background_transition.gd | 38 +++ .../default_background_transition.tres | 20 -- .../Modules/Background/dialogic_transition.gd | 83 ----- .../Modules/Background/event_background.gd | 18 +- addons/dialogic/Modules/Background/index.gd | 3 - .../Background/subsystem_backgrounds.gd | 115 ++++--- .../Modules/Background/transition_editor.gd | 274 --------------- .../Modules/Background/transition_editor.tscn | 319 ------------------ .../Background/transition_setting_editor.gd | 264 --------------- .../Character/class_dialogic_animation.gd | 4 +- .../full_background_layer.tscn | 6 +- 15 files changed, 125 insertions(+), 1041 deletions(-) rename addons/dialogic/Modules/Background/{ => DefaultBackgroundScene}/default_background.gd (91%) rename addons/dialogic/Modules/Background/{ => DefaultBackgroundScene}/default_background.tscn (90%) create mode 100644 addons/dialogic/Modules/Background/Transition/default_background_transition.gd rename addons/dialogic/Modules/Background/{ => Transition}/default_background_transition.gdshader (99%) create mode 100644 addons/dialogic/Modules/Background/class_dialogic_background_transition.gd delete mode 100644 addons/dialogic/Modules/Background/default_background_transition.tres delete mode 100644 addons/dialogic/Modules/Background/dialogic_transition.gd delete mode 100644 addons/dialogic/Modules/Background/transition_editor.gd delete mode 100644 addons/dialogic/Modules/Background/transition_editor.tscn delete mode 100644 addons/dialogic/Modules/Background/transition_setting_editor.gd diff --git a/addons/dialogic/Modules/Background/default_background.gd b/addons/dialogic/Modules/Background/DefaultBackgroundScene/default_background.gd similarity index 91% rename from addons/dialogic/Modules/Background/default_background.gd rename to addons/dialogic/Modules/Background/DefaultBackgroundScene/default_background.gd index 675f0f4e6..ce4d217bb 100644 --- a/addons/dialogic/Modules/Background/default_background.gd +++ b/addons/dialogic/Modules/Background/DefaultBackgroundScene/default_background.gd @@ -25,7 +25,3 @@ func _update_background(argument:String, time:float) -> void: else: image_node.texture = null color_node.color = Color.from_string(argument, Color.TRANSPARENT) - - -func _should_do_background_update(argument:String) -> bool: - return false diff --git a/addons/dialogic/Modules/Background/default_background.tscn b/addons/dialogic/Modules/Background/DefaultBackgroundScene/default_background.tscn similarity index 90% rename from addons/dialogic/Modules/Background/default_background.tscn rename to addons/dialogic/Modules/Background/DefaultBackgroundScene/default_background.tscn index 0e5057446..e72fdc2cf 100644 --- a/addons/dialogic/Modules/Background/default_background.tscn +++ b/addons/dialogic/Modules/Background/DefaultBackgroundScene/default_background.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://cl6g6ymkhjven"] -[ext_resource type="Script" path="res://addons/dialogic/Modules/Background/default_background.gd" id="1_nkdrp"] +[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 diff --git a/addons/dialogic/Modules/Background/Transition/default_background_transition.gd b/addons/dialogic/Modules/Background/Transition/default_background_transition.gd new file mode 100644 index 000000000..dcda9e1c5 --- /dev/null +++ b/addons/dialogic/Modules/Background/Transition/default_background_transition.gd @@ -0,0 +1,14 @@ +extends DialogicBackgroundTransition + + +func _fade() -> void: + var shader := set_shader(this_folder.path_join("default_background_transition.gdshader")) + shader.set_shader_parameter("previous_background", prev_texture) + shader.set_shader_parameter("next_background", next_texture) + + var tween := create_tween() + tween.tween_property(bg_holder, "material:shader_parameter/progress", 1, time).from(0) + + await tween.finished + + transition_finished.emit() diff --git a/addons/dialogic/Modules/Background/default_background_transition.gdshader b/addons/dialogic/Modules/Background/Transition/default_background_transition.gdshader similarity index 99% rename from addons/dialogic/Modules/Background/default_background_transition.gdshader rename to addons/dialogic/Modules/Background/Transition/default_background_transition.gdshader index 5c3cf3947..7fc2cf9ed 100644 --- a/addons/dialogic/Modules/Background/default_background_transition.gdshader +++ b/addons/dialogic/Modules/Background/Transition/default_background_transition.gdshader @@ -20,7 +20,7 @@ void fragment() { 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); } diff --git a/addons/dialogic/Modules/Background/class_dialogic_background_transition.gd b/addons/dialogic/Modules/Background/class_dialogic_background_transition.gd new file mode 100644 index 000000000..0c2725352 --- /dev/null +++ b/addons/dialogic/Modules/Background/class_dialogic_background_transition.gd @@ -0,0 +1,38 @@ +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=this_folder.path_join("default_background_transition.gdshader")) -> ShaderMaterial: + if bg_holder: + bg_holder.material = ShaderMaterial.new() + bg_holder.material.shader = load(path_to_shader) + return bg_holder.material + return null diff --git a/addons/dialogic/Modules/Background/default_background_transition.tres b/addons/dialogic/Modules/Background/default_background_transition.tres deleted file mode 100644 index 6ebf42439..000000000 --- a/addons/dialogic/Modules/Background/default_background_transition.tres +++ /dev/null @@ -1,20 +0,0 @@ -[gd_resource type="Resource" script_class="DialogicTransition" load_steps=5 format=3 uid="uid://3ol086bnxiai"] - -[ext_resource type="Script" path="res://addons/dialogic/Modules/Background/dialogic_transition.gd" id="1_douvg"] -[ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/default_background_transition.gdshader" id="1_uctph"] - -[sub_resource type="Gradient" id="Gradient_n6t2j"] -offsets = PackedFloat32Array(1) -colors = PackedColorArray(0.498039, 0.498039, 0.498039, 1) - -[sub_resource type="GradientTexture1D" id="GradientTexture1D_fjhwy"] -gradient = SubResource("Gradient_n6t2j") - -[resource] -script = ExtResource("1_douvg") -shader = ExtResource("1_uctph") -base_overrides = { -"feather": 1.0, -"wipe_texture": SubResource("GradientTexture1D_fjhwy") -} -name = "Transition" diff --git a/addons/dialogic/Modules/Background/dialogic_transition.gd b/addons/dialogic/Modules/Background/dialogic_transition.gd deleted file mode 100644 index e19675d03..000000000 --- a/addons/dialogic/Modules/Background/dialogic_transition.gd +++ /dev/null @@ -1,83 +0,0 @@ -@tool -extends Resource -class_name DialogicTransition - -const default_shader = preload("res://addons/dialogic/Modules/Background/default_background_transition.gdshader") - -@export var shader: Shader = default_shader - -@export var inherits : DialogicTransition = null - -@export var base_overrides := {} - -@export var name := "Transition": - get: - if name.is_empty(): - return "Unkown Transition" - return name - - -func _init(_name:="") -> void: - if not _name.is_empty(): - name = _name - - -func realize_inheritance() -> void: - base_overrides = get_transition_overrides() - - inherits = null - changed.emit() - - -## This always returns the inheritance root's shader. -func get_shader() -> Shader: - var shader := get_inheritance_root().shader - - return shader if shader else default_shader - - -func set_parameter(name: String, value: Variant) -> void: - base_overrides[name] = value - - changed.emit() - - -func remove_paramter(name: String) -> void: - base_overrides.erase(name) - - changed.emit() - - -func inherits_anything() -> bool: - return inherits != null - - -func get_transition_overrides(inherited_only:=false) -> Dictionary: - var transition := self - var overrides := base_overrides.duplicate(true) if !inherited_only else {} - - while transition.inherits != null: - transition = transition.inherits - overrides.merge(transition.base_overrides) - - return overrides - - -func get_inheritance_root() -> DialogicTransition: - if inherits == null: - return self - - var transition : DialogicTransition = self - while transition.inherits != null: - transition = transition.inherits - - return transition - - -func clone() -> DialogicTransition: - var transition := DialogicTransition.new() - transition.name = name - transition.inherits = inherits - transition.base_overrides = base_overrides - - return transition diff --git a/addons/dialogic/Modules/Background/event_background.gd b/addons/dialogic/Modules/Background/event_background.gd index 6c2aaa110..9d4d03a04 100644 --- a/addons/dialogic/Modules/Background/event_background.gd +++ b/addons/dialogic/Modules/Background/event_background.gd @@ -17,7 +17,7 @@ var argument: String = "" ## The time the fade animation will take. Leave at 0 for instant change. var fade: float = 0.0 -var transition_path : String = "" +var transition : String = "" ################################################################################ @@ -30,19 +30,9 @@ func _execute() -> void: if Dialogic.Input.auto_skip.enabled: var time_per_event: float = Dialogic.Input.auto_skip.time_per_event final_fade_duration = min(fade, time_per_event) - - var transition: DialogicTransition - if !transition_path.is_empty(): - transition = load(transition_path) as DialogicTransition - else: - var default_transition_path = ProjectSettings.get_setting('dialogic/transition/default_transition','') - transition = load(default_transition_path) as DialogicTransition if !default_transition_path.is_empty() else null - - if transition: - dialogic.Backgrounds.update_background(scene, argument, final_fade_duration, transition) - else: - dialogic.Backgrounds.update_background(scene, argument, final_fade_duration) - + + dialogic.Backgrounds.update_background(scene, argument, final_fade_duration, transition) + finish() diff --git a/addons/dialogic/Modules/Background/index.gd b/addons/dialogic/Modules/Background/index.gd index 180a79d6f..034e3fb7a 100644 --- a/addons/dialogic/Modules/Background/index.gd +++ b/addons/dialogic/Modules/Background/index.gd @@ -5,8 +5,5 @@ extends DialogicIndexer func _get_events() -> Array: return [this_folder.path_join('event_background.gd')] -func _get_editors() -> Array: - return [this_folder.path_join('transition_editor.tscn')] - func _get_subsystems() -> Array: return [{'name':'Backgrounds', 'script':this_folder.path_join('subsystem_backgrounds.gd')}] diff --git a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd index 1a13aed3d..1e58ac67c 100644 --- a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd +++ b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd @@ -7,8 +7,8 @@ signal background_changed(info:Dictionary) var _tween: Tween var _tween_callbacks: Array[Callable] -var default_background_scene: PackedScene = load(get_script().resource_path.get_base_dir().path_join('default_background.tscn')) -const default_transition: DialogicTransition = preload("res://addons/dialogic/Modules/Background/default_background_transition.tres") +var default_background_scene: PackedScene = load(get_script().resource_path.get_base_dir().path_join('DefaultBackgroundScene/default_background.tscn')) +var default_transition: String = get_script().resource_path.get_base_dir().path_join('DefaultBackgroundScene/Background/default_background_transition.tres') #################################################################################################### ## STATE @@ -35,12 +35,15 @@ func load_game_state(load_flag:=LoadFlags.FULL_LOAD): ## 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:String = '', argument:String = '', fade_time:float = 0.0, transition: DialogicTransition = default_transition) -> void: +func update_background(scene:String = '', argument:String = '', fade_time:float = 0.0, transition_path:=default_transition) -> void: var background_holder: DialogicNode_BackgroundHolder = get_tree().get_first_node_in_group('dialogic_background_holders') if background_holder == null: return var info := {'scene':scene, 'argument':argument, 'fade_time':fade_time, 'same_scene':false} + dialogic.current_state_info['background_scene'] = scene + dialogic.current_state_info['background_argument'] = argument + var bg_set := false # First try just updating the existing scene. @@ -55,57 +58,59 @@ func update_background(scene:String = '', argument:String = '', fade_time:float bg_set = true info['same_scene'] = true - # If that didn't work, add a new scene, then cross-fade - if !bg_set: - var previous_material = background_holder.material - var material := ShaderMaterial.new() - background_holder.material = material - - material.shader = transition.shader - - # make sure material is clean and ready to go - material.set_shader_parameter("progress", 0) - # swap the next background into previous, as that is now the older frame - material.set_shader_parameter("previous_background", previous_material.get_shader_parameter("next_background") if previous_material else null) - material.set_shader_parameter("next_background", null) - - - if _tween: - _tween.kill() - - _tween = get_tree().create_tween() - - var parameter_overrides := transition.get_transition_overrides() - for parameter_override in parameter_overrides: - material.set_shader_parameter(parameter_override, parameter_overrides[parameter_override]) - - _tween.tween_method(func (progress: float): - material.set_shader_parameter("progress", progress) - , 0.0, 1.0, fade_time) - - ## remove previous backgrounds - for old_bg in background_holder.get_children(): - if old_bg is SubViewportContainer: - old_bg.get_meta('node')._custom_fade_out(fade_time) - _tween.chain().tween_callback(old_bg.queue_free) - - var new_node: SubViewportContainer - if scene.ends_with('.tscn') and ResourceLoader.exists(scene): - new_node = add_background_node(load(scene), background_holder) - if not new_node.get_meta('node') is DialogicBackground: - printerr("[Dialogic] Given background scene was not of type DialogicBackground!") - elif argument: - new_node = add_background_node(default_background_scene, background_holder) - else: - new_node = null - - if new_node: - new_node.get_meta('node')._update_background(argument, fade_time) - new_node.get_meta('node')._custom_fade_in(fade_time) - material.set_shader_parameter("next_background", new_node.get_child(0).get_texture()) + if bg_set: + background_changed.emit(info) + return + + + # +# + # + ## If that didn't work, add a new scene, then cross-fade + #var previous_material = background_holder.material + #var material := ShaderMaterial.new() + #background_holder.material = material +# + #material.shader = transition.shader +# + ## make sure material is clean and ready to go + #material.set_shader_parameter("progress", 0) + ## swap the next background into previous, as that is now the older frame + #material.set_shader_parameter("previous_background", previous_material.get_shader_parameter("next_background") if previous_material else null) + #material.set_shader_parameter("next_background", null) + + ## remove previous backgrounds + var old_viewport: SubViewportContainer = 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) + if not new_viewport.get_meta('node') is DialogicBackground: + printerr("[Dialogic] Given background scene was not of type DialogicBackground!") + return + elif argument: + new_viewport = add_background_node(default_background_scene, background_holder) + else: + new_viewport = null + + var trans_script :Script = load(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_node = old_viewport.get_meta('node', null) + trans_node.prev_texture = old_viewport.get_child(0).get_texture() + + if new_viewport: + trans_node.next_node = new_viewport.get_meta('node', null) + trans_node.next_texture = new_viewport.get_child(0).get_texture() + + add_child(trans_node) + trans_node._fade() - dialogic.current_state_info['background_scene'] = scene - dialogic.current_state_info['background_argument'] = argument background_changed.emit(info) @@ -128,6 +133,7 @@ func add_background_node(scene:PackedScene, parent:DialogicNode_BackgroundHolder 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 @@ -136,3 +142,6 @@ func add_background_node(scene:PackedScene, parent:DialogicNode_BackgroundHolder func has_background() -> bool: return !dialogic.current_state_info['background_scene'].is_empty() or !dialogic.current_state_info['background_argument'].is_empty() + +func guess_transition_file() -> void: + diff --git a/addons/dialogic/Modules/Background/transition_editor.gd b/addons/dialogic/Modules/Background/transition_editor.gd deleted file mode 100644 index d2cc3582f..000000000 --- a/addons/dialogic/Modules/Background/transition_editor.gd +++ /dev/null @@ -1,274 +0,0 @@ -@tool -extends DialogicEditor - -const default_transition_resource : DialogicTransition = preload("res://addons/dialogic/Modules/Background/default_background_transition.tres") - -var transitions: Array[DialogicTransition] = [] -var current_transition : DialogicTransition = null -var default_transition := "" - - -enum AddTransitionButtonOptions { - NewTransition = 2, - InheritedTransition = 3 -} - - -func _get_title() -> String: - return "Transition" - -func _register() -> void: - editors_manager.register_simple_editor(self) - alternative_text = "Change the look of the background transitions in your game" - -func _open(extra_info: Variant = null) -> void: - load_transition_list() - - -func _close() -> void: - save_transition_list() - save_transition() - -func _ready() -> void: - collect_transitions() - - setup_ui() - -func add_transition(file_path: String, transition: DialogicTransition, inherits: DialogicTransition= null) -> void: - transition.resource_path = file_path - transition.inherits = inherits - - ResourceSaver.save(transition, file_path) - transitions.append(transition) - - save_transition_list() - load_transition_list() - select_transition(transition) - -func delete_transition(transition: DialogicTransition) -> void: - if current_transition == transition: - current_transition = null - - for other_transition in transitions: - if other_transition.inherits == transition: - other_transition.realize_inheritance() - push_warning('[Dialogic] Transition "', other_transition.name,'" had to be realized because it inherited "', transition.name,'" which was deleted!') - - if transition.resource_path == default_transition: - default_transition = "" - - transitions.erase(transition) - save_transition_list() - -func realize_transition() -> void: - current_transition.realize_inheritance() - - select_transition(current_transition) - -func select_transition(transition: DialogicTransition) -> void: - DialogicUtil.set_editor_setting('latest_background_transition', transition.name) - for idx in range(%TransitionList.item_count): - if %TransitionList.get_item_metadata(idx) == transition: - %TransitionList.select(idx) - return - -func setup_ui() -> void: - %AddButton.icon = get_theme_icon("Add", "EditorIcons") - %DuplicateButton.icon = get_theme_icon("Duplicate", "EditorIcons") - %InheritanceButton.icon = get_theme_icon("GuiDropdown", "EditorIcons") - %RemoveButton.icon = get_theme_icon("Remove", "EditorIcons") - - %EditNameButton.icon = get_theme_icon("Edit", "EditorIcons") - %TestTransitionButton.icon = get_theme_icon("PlayCustom", "EditorIcons") - %MakeDefaultButton.icon = get_theme_icon("Favorites", "EditorIcons") - - %TransitionList.item_selected.connect(_on_transitionlist_selected) - %AddButton.get_popup().index_pressed.connect(_on_AddTranstitionMenu_selected) - %AddButton.about_to_popup.connect(_on_AddTransitionMenu_about_to_popup) - %InheritanceButton.get_popup().index_pressed.connect(_on_inheritance_index_pressed) - %TransitionView.hide() - %NoTransitionView.show() - -#region signal hooks -func _on_transitionlist_selected(index: int) -> void: - load_transition(%TransitionList.get_item_metadata(index)) - -func _on_AddTransitionMenu_about_to_popup() -> void: - %AddButton.get_popup().set_item_disabled(3, not %TransitionList.is_anything_selected()) - -func _on_AddTranstitionMenu_selected(index: int) -> void: - #TODO: consider making an option to inherrit from a transition on a public repo? - - match index: - AddTransitionButtonOptions.NewTransition: - var new_transition: DialogicTransition = default_transition_resource.clone() - - find_parent('EditorView').godot_file_dialog( - add_transition_undoable.bind(new_transition), - '*.tres', - EditorFileDialog.FILE_MODE_SAVE_FILE, - "Select folder for new transition") - - AddTransitionButtonOptions.InheritedTransition: - if %TransitionList.get_selected_items().is_empty(): - return - - find_parent('EditorView').godot_file_dialog( - add_transition_undoable.bind(DialogicTransition.new(), current_transition), - '*.tres', - EditorFileDialog.FILE_MODE_SAVE_FILE, - "Select folder for new transition") - -func add_transition_undoable(file_path: String, transition: DialogicTransition, inherits: DialogicTransition = null) -> void: - transition.name = _get_new_name(file_path.get_file().trim_suffix('.'+file_path.get_extension())) - var undo_redo: EditorUndoRedoManager = DialogicUtil.get_dialogic_plugin().get_undo_redo() - undo_redo.create_action('Add Transition', UndoRedo.MERGE_ALL) - undo_redo.add_do_method(self, "add_transition", file_path, transition, inherits) - undo_redo.add_do_method(self, "load_transition_list") - undo_redo.add_undo_method(self, "delete_transition", transition) - undo_redo.add_undo_method(self, "load_transition_list") - undo_redo.commit_action() - DialogicUtil.set_editor_setting('latest_background_transition', transition.name) - -func _on_inheritance_index_pressed(index:int) -> void: - if index == 0: - realize_transition() - -func _on_duplicate_button_pressed(): - if !%TransitionList.is_anything_selected(): - return - - find_parent('EditorView').godot_file_dialog( - add_transition_undoable.bind(current_transition.clone(), current_transition), - '', - EditorFileDialog.FILE_MODE_SAVE_FILE, - "Select folder for new transition") - -func _on_remove_button_pressed(): - if !%TransitionList.is_anything_selected(): - return - - if current_transition.name == default_transition: - push_warning("[Dialogic] You cannot delete the default transition!") - return - - delete_transition(current_transition) - load_transition_list() - -func _on_make_default_button_pressed(): - default_transition = current_transition.resource_path - save_transition_list() - load_transition_list() - -func _on_create_transition_button_pressed() -> void: - var new_transition: DialogicTransition = default_transition_resource.clone() - - find_parent('EditorView').godot_file_dialog( - add_transition_undoable.bind(new_transition), - '*.tres', - EditorFileDialog.FILE_MODE_SAVE_FILE, - "Select folder for new transition") - -#endregion - -func collect_transitions() -> void: -# for indexer in DialogicUtil.get_indexers(): -# for layout in indexer._get_layout_parts(): -# premade_style_parts[layout['path']] = layout - - var transition_list: Array = ProjectSettings.get_setting('dialogic/transition/transition_list', []) - for transition in transition_list: - if ResourceLoader.exists(transition): - var transition_res := load(transition) - if transition != null: - transitions.append(ResourceLoader.load(transition, "DialogicTransition")) - else: - print("[Dialogic] Failed to open transition '", transition, "'. Some dependency might be broken.") - else: - print("[Dialogic] Failed to open transition '", transition, "'. Might have been moved or deleted.") - - default_transition = ProjectSettings.get_setting('dialogic/transition/default_transition', '') - - -func load_transition_list() -> void: - var latest := DialogicUtil.get_editor_setting('latest_background_transition', '') - - %TransitionList.clear() - var idx := 0 - for transition in transitions: - %TransitionList.add_item(transition.name, get_theme_icon("PopupMenu", "EditorIcons")) - if transition.resource_path == default_transition: - %TransitionList.set_item_icon_modulate(idx, get_theme_color("warning_color", "Editor")) - if transition.name == latest: - %TransitionList.select(idx) - load_transition(transition) - %TransitionList.set_item_tooltip(idx, transition.resource_path) - %TransitionList.set_item_metadata(idx, transition) - idx += 1 - - if len(transitions) == 0: - %TransitionView.hide() - %NoTransitionView.show() - - elif !%TransitionList.is_anything_selected(): - %TransitionList.select(0) - load_transition(%TransitionList.get_item_metadata(0)) - - -func save_transition_list() -> void: - ProjectSettings.set_setting('dialogic/transition/transition_list', transitions.map(func(transition:DialogicTransition): return transition.resource_path)) - ProjectSettings.set_setting('dialogic/transition/default_transition', default_transition) - ProjectSettings.save() - -func save_transition() -> void: - if current_transition == null: - return - - print("[Dialogic] Saved ", current_transition.name) - ResourceSaver.save(current_transition) - - -func load_transition(transition: DialogicTransition) -> void: - if current_transition != null: - current_transition.changed.disconnect(save_transition) - save_transition() - current_transition = transition - if current_transition == null: - return - current_transition.changed.connect(save_transition) - - %BackgroundTransitionName.text = transition.name - if transition.resource_path == default_transition: - %MakeDefaultButton.tooltip_text = "Is Default" - %MakeDefaultButton.disabled = true - else: - %MakeDefaultButton.tooltip_text = "Make Default" - %MakeDefaultButton.disabled = false - - %TransitionEditor.load_transition(transition) - - %InheritanceButton.visible = transition.inherits_anything() - if %InheritanceButton.visible: - %InheritanceButton.text = "Inherits " + transition.inherits.name - - - DialogicUtil.set_editor_setting('latest_background_transition', transition.name) - - %TransitionView.show() - %NoTransitionView.hide() - -func _get_new_name(base_name: String) -> String: - var new_name_idx := 1 - var found_unique_name := false - var new_name := base_name - while not found_unique_name: - found_unique_name = true - for transition in transitions: - if transition.name == new_name: - new_name_idx += 1 - new_name = base_name+" "+str(new_name_idx) - found_unique_name = false - return new_name - - - diff --git a/addons/dialogic/Modules/Background/transition_editor.tscn b/addons/dialogic/Modules/Background/transition_editor.tscn deleted file mode 100644 index 51366d6e1..000000000 --- a/addons/dialogic/Modules/Background/transition_editor.tscn +++ /dev/null @@ -1,319 +0,0 @@ -[gd_scene load_steps=15 format=3 uid="uid://bnt7spjq5k6kt"] - -[ext_resource type="Script" path="res://addons/dialogic/Modules/Background/transition_editor.gd" id="1_mg8i8"] -[ext_resource type="PackedScene" uid="uid://dbpkta2tjsqim" path="res://addons/dialogic/Editor/Common/hint_tooltip_icon.tscn" id="2_n5tec"] -[ext_resource type="Script" path="res://addons/dialogic/Modules/Background/transition_setting_editor.gd" id="3_5uve6"] - -[sub_resource type="Image" id="Image_ebqxh"] -data = { -"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), -"format": "RGBA8", -"height": 16, -"mipmaps": false, -"width": 16 -} - -[sub_resource type="ImageTexture" id="ImageTexture_c81y7"] -image = SubResource("Image_ebqxh") - -[sub_resource type="Image" id="Image_kw1o5"] -data = { -"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), -"format": "RGBA8", -"height": 16, -"mipmaps": false, -"width": 16 -} - -[sub_resource type="ImageTexture" id="ImageTexture_xtj53"] -image = SubResource("Image_kw1o5") - -[sub_resource type="Theme" id="Theme_l6tyr"] - -[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tixgs"] - -[sub_resource type="Image" id="Image_svp6i"] -data = { -"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), -"format": "RGBA8", -"height": 16, -"mipmaps": false, -"width": 16 -} - -[sub_resource type="ImageTexture" id="ImageTexture_isjve"] -image = SubResource("Image_svp6i") - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0nh8y"] -bg_color = Color(1, 1, 1, 1) -corner_radius_top_left = 10 -corner_radius_top_right = 10 -corner_radius_bottom_right = 10 -corner_radius_bottom_left = 10 - -[sub_resource type="Image" id="Image_p1pql"] -data = { -"data": PackedByteArray(0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255), -"format": "RGBA8", -"height": 2, -"mipmaps": false, -"width": 2 -} - -[sub_resource type="ImageTexture" id="ImageTexture_yr3tj"] -image = SubResource("Image_p1pql") - -[node name="TransitionEditor" type="HSplitContainer"] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_right = -3.0 -offset_bottom = 3.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/separation = 0 -script = ExtResource("1_mg8i8") - -[node name="Panel" type="PanelContainer" parent="."] -custom_minimum_size = Vector2(150, 0) -layout_mode = 2 -size_flags_stretch_ratio = 0.2 -theme_type_variation = &"DialogicPanelA" - -[node name="VBox" type="VBoxContainer" parent="Panel"] -layout_mode = 2 - -[node name="Title" type="HBoxContainer" parent="Panel/VBox"] -layout_mode = 2 - -[node name="TransitionListTitle" type="Label" parent="Panel/VBox/Title"] -layout_mode = 2 -theme_type_variation = &"DialogicSubTitle" -text = "Transitions" - -[node name="HintTooltip" parent="Panel/VBox/Title" instance=ExtResource("2_n5tec")] -layout_mode = 2 -tooltip_text = "TODO" -texture = SubResource("ImageTexture_c81y7") -hint_text = "TODO" - -[node name="TransitionButtons" type="HBoxContainer" parent="Panel/VBox"] -layout_mode = 2 -alignment = 2 - -[node name="AddButton" type="MenuButton" parent="Panel/VBox/TransitionButtons"] -unique_name_in_owner = true -layout_mode = 2 -tooltip_text = "Add background transition" -icon = SubResource("ImageTexture_c81y7") -switch_on_hover = true -item_count = 4 -popup/item_0/text = "ADD STYLE" -popup/item_0/id = 0 -popup/item_0/disabled = true -popup/item_1/text = "" -popup/item_1/id = 0 -popup/item_1/separator = true -popup/item_2/text = "New Transition" -popup/item_2/id = 0 -popup/item_3/text = "Inherited Transition" -popup/item_3/id = 1 - -[node name="DuplicateButton" type="Button" parent="Panel/VBox/TransitionButtons"] -unique_name_in_owner = true -layout_mode = 2 -tooltip_text = "Duplicate transition" -icon = SubResource("ImageTexture_c81y7") -flat = true - -[node name="RemoveButton" type="Button" parent="Panel/VBox/TransitionButtons"] -unique_name_in_owner = true -layout_mode = 2 -tooltip_text = "Remove transition from list" -icon = SubResource("ImageTexture_c81y7") -flat = true - -[node name="MakeDefaultButton" type="Button" parent="Panel/VBox/TransitionButtons"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 4 -tooltip_text = "Make Default" -toggle_mode = true -icon = SubResource("ImageTexture_c81y7") -flat = true - -[node name="TransitionList" type="ItemList" parent="Panel/VBox"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_vertical = 3 -item_count = 1 -item_0/text = "Transition" -item_0/icon = SubResource("ImageTexture_xtj53") - -[node name="TransitionView" type="VBoxContainer" parent="."] -unique_name_in_owner = true -visible = false -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="HBox" type="HBoxContainer" parent="TransitionView"] -layout_mode = 2 -theme = SubResource("Theme_l6tyr") -theme_override_constants/separation = 0 - -[node name="BackgroundTransitionName" type="LineEdit" parent="TransitionView/HBox"] -unique_name_in_owner = true -layout_mode = 2 -theme_type_variation = &"DialogicTitle" -theme_override_styles/normal = SubResource("StyleBoxEmpty_tixgs") -theme_override_styles/focus = SubResource("StyleBoxEmpty_tixgs") -theme_override_styles/read_only = SubResource("StyleBoxEmpty_tixgs") -text = "Transition" -expand_to_text_length = true - -[node name="EditNameButton" type="Button" parent="TransitionView/HBox"] -unique_name_in_owner = true -layout_mode = 2 -tooltip_text = "Edit Name" -icon = SubResource("ImageTexture_c81y7") -flat = true - -[node name="InheritanceButton" type="MenuButton" parent="TransitionView/HBox"] -unique_name_in_owner = true -visible = false -layout_mode = 2 -text = "Inherits VN Transition" -icon = SubResource("ImageTexture_c81y7") -icon_alignment = 2 -item_count = 1 -popup/item_0/text = "Clear Inheritance" -popup/item_0/id = 0 - -[node name="TestTransitionButton" type="Button" parent="TransitionView/HBox"] -unique_name_in_owner = true -visible = false -layout_mode = 2 -size_flags_horizontal = 10 -tooltip_text = "Play current timeline with this style" -text = "Test Transition" -icon = SubResource("ImageTexture_c81y7") - -[node name="PanelContainer" type="PanelContainer" parent="TransitionView"] -layout_mode = 2 -size_flags_vertical = 3 -theme_type_variation = &"DialogicPanelB" - -[node name="TransitionEditor" type="HSplitContainer" parent="TransitionView/PanelContainer"] -unique_name_in_owner = true -layout_mode = 2 -script = ExtResource("3_5uve6") - -[node name="TransitionSettings" type="VBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="TransitionInfoHeader" type="HBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings"] -layout_mode = 2 - -[node name="TransitionName" type="Label" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoHeader"] -unique_name_in_owner = true -layout_mode = 2 -theme_type_variation = &"DialogicTitle" -text = "Default Transition Base" - -[node name="ExpandTransitionInfo" type="Button" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoHeader"] -unique_name_in_owner = true -layout_mode = 2 -icon = SubResource("ImageTexture_isjve") -flat = true - -[node name="TransitionInfoBody" type="VBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings"] -unique_name_in_owner = true -layout_mode = 2 - -[node name="HBox" type="HBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody"] -layout_mode = 2 - -[node name="Panel" type="PanelContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox"] -show_behind_parent = true -clip_children = 2 -layout_mode = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_0nh8y") - -[node name="SmallTransitionPreview" type="TextureRect" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Panel"] -unique_name_in_owner = true -layout_mode = 2 -texture = SubResource("ImageTexture_yr3tj") -expand_mode = 3 -stretch_mode = 6 - -[node name="Info" type="VBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox"] -layout_mode = 2 -size_flags_horizontal = 3 -theme_override_constants/separation = 0 - -[node name="HBoxContainer" type="HBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info"] -layout_mode = 2 -theme_override_constants/separation = 0 - -[node name="SmallTransitionAuthor" type="Label" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info/HBoxContainer"] -unique_name_in_owner = true -self_modulate = Color(1, 1, 1, 0.603922) -layout_mode = 2 -theme_type_variation = &"DialogicHintText" -text = "Dialogic" - -[node name="Description" type="HBoxContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info"] -layout_mode = 2 -theme_override_constants/separation = 0 - -[node name="Label" type="Label" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info/Description"] -layout_mode = 2 -theme_type_variation = &"DialogicHintText2" -text = "Info:" - -[node name="SmallTransitionDescription" type="Label" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoBody/HBox/Info/Description"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 1 -theme_type_variation = &"DialogicHintText2" -text = "A very simple base for transitions." -autowrap_mode = 3 -text_overrun_behavior = 4 - -[node name="TransitionSettingsTabs" type="TabContainer" parent="TransitionView/PanelContainer/TransitionEditor/TransitionSettings"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_vertical = 3 - -[node name="Margin" type="Control" parent="TransitionView"] -custom_minimum_size = Vector2(0, 10) -layout_mode = 2 - -[node name="NoTransitionView" type="VBoxContainer" parent="."] -unique_name_in_owner = true -layout_mode = 2 -alignment = 1 - -[node name="Label" type="Label" parent="NoTransitionView"] -layout_mode = 2 -text = "You have not setup any transitions." -horizontal_alignment = 1 -autowrap_mode = 3 - -[node name="CreateTransitionButton" type="Button" parent="NoTransitionView"] -layout_mode = 2 -size_flags_horizontal = 4 -tooltip_text = "Make a custom style from a variation of the fallback." -text = "Make my own!" - -[connection signal="pressed" from="Panel/VBox/TransitionButtons/DuplicateButton" to="." method="_on_duplicate_button_pressed"] -[connection signal="pressed" from="Panel/VBox/TransitionButtons/RemoveButton" to="." method="_on_remove_button_pressed"] -[connection signal="pressed" from="Panel/VBox/TransitionButtons/MakeDefaultButton" to="." method="_on_make_default_button_pressed"] -[connection signal="focus_exited" from="TransitionView/HBox/BackgroundTransitionName" to="." method="_on_layout_style_name_focus_exited"] -[connection signal="text_submitted" from="TransitionView/HBox/BackgroundTransitionName" to="." method="_on_layout_style_name_text_submitted"] -[connection signal="pressed" from="TransitionView/HBox/EditNameButton" to="." method="_on_edit_name_button_pressed"] -[connection signal="pressed" from="TransitionView/HBox/TestTransitionButton" to="." method="_on_test_style_button_pressed"] -[connection signal="pressed" from="TransitionView/PanelContainer/TransitionEditor/TransitionSettings/TransitionInfoHeader/ExpandTransitionInfo" to="TransitionView/PanelContainer/TransitionEditor" method="_on_expand_transition_info_pressed"] -[connection signal="pressed" from="NoTransitionView/CreateTransitionButton" to="." method="_on_create_transition_button_pressed"] diff --git a/addons/dialogic/Modules/Background/transition_setting_editor.gd b/addons/dialogic/Modules/Background/transition_setting_editor.gd deleted file mode 100644 index 877e374bd..000000000 --- a/addons/dialogic/Modules/Background/transition_setting_editor.gd +++ /dev/null @@ -1,264 +0,0 @@ -@tool -extends HSplitContainer - -var current_transition: DialogicTransition = null - -var customization_editor_info := {} - -func load_transition(transition: DialogicTransition) -> void: - current_transition = transition - - load_transition_settings_list() - -func load_transition_settings_list() -> void: - var overrides := current_transition.get_transition_overrides() - var inherrited_overrides := current_transition.get_transition_overrides(true) - - %SmallTransitionPreview.hide() - - load_transition_customization(overrides, inherrited_overrides) - -func load_transition_customization(overrides: Dictionary = {}, inherited_overrides: Dictionary = {}) -> void: - for child in %TransitionSettingsTabs.get_children(): - child.get_parent().remove_child(child) - child.queue_free() - - var shader = current_transition.get_shader() - - var settings := [] - - settings.append({'name':'Resource', 'added':false, 'id':&"GROUP"}) - - var transition_properties = current_transition.get_property_list() - var prop = transition_properties.filter(func (p: Variant) -> bool: return p['name'] == "shader")[0] - prop['id'] = &"SETTING" - settings.append(prop) - - if shader: - settings.append_array(collect_settings(shader.get_shader_uniform_list())) - - if settings.is_empty(): - var note := Label.new() - note.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART - note.text = "This layer has no exposed settings." - note.theme_type_variation = 'DialogicHintText2' - %TransitionSettingsTabs.add_child(note) - note.name = "General" - return - - var current_grid: GridContainer = null - - var label_bg_style = get_theme_stylebox("CanvasItemInfoOverlay", "EditorStyles").duplicate() - label_bg_style.content_margin_left = 5 - label_bg_style.content_margin_right = 5 - label_bg_style.content_margin_top = 5 - - var current_group_name := "" - var current_subgroup_name := "" - customization_editor_info = {} - - for i in settings: - match i['id']: - &"GROUP": - var main_scroll = ScrollContainer.new() - main_scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL - main_scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL - main_scroll.name = i['name'] - %TransitionSettingsTabs.add_child(main_scroll, true) - - current_grid = GridContainer.new() - current_grid.columns = 3 - current_grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL - main_scroll.add_child(current_grid) - current_group_name = i['name'].to_snake_case() - current_subgroup_name = "" - - &"SUBGROUP": - - # add separator - if current_subgroup_name: - current_grid.add_child(HSeparator.new()) - current_grid.get_child(-1).add_theme_constant_override('separation', 20) - current_grid.add_child(current_grid.get_child(-1).duplicate()) - current_grid.add_child(current_grid.get_child(-1).duplicate()) - - var title_label := Label.new() - title_label.text = i['name'] - title_label.theme_type_variation = "DialogicSection" - title_label.size_flags_horizontal = SIZE_EXPAND_FILL - current_grid.add_child(title_label, true) - - # add spaced to the grid - current_grid.add_child(Control.new()) - current_grid.add_child(Control.new()) - - current_subgroup_name = i['name'].to_snake_case() - - &"SETTING": - var label := Label.new() - label.text = str(i['name'].trim_prefix(current_group_name+'_').trim_prefix(current_subgroup_name+'_')).capitalize() - current_grid.add_child(label, true) - - customization_editor_info[i['name']] = {} - var current_value :Variant - var input :Node - - if current_group_name == "resource": - current_value = current_transition.shader - customization_editor_info[i['name']]['orig'] = preload("res://addons/dialogic/Modules/Background/default_background_transition.gdshader") - - else: - if i['name'] in inherited_overrides: - var override = inherited_overrides.get(i['name']) - customization_editor_info[i['name']]['orig'] = str_to_var(override) if override is String else override - else: - customization_editor_info[i['name']]['orig'] = RenderingServer.shader_get_parameter_default(shader.get_rid(), i['name']) - - if i['name'] in overrides: - var override = overrides.get(i['name']) - current_value = str_to_var(override) if override is String else override - else: - current_value = customization_editor_info[i['name']]['orig'] - - input= DialogicUtil.setup_script_property_edit_node(i, current_value, set_export_override) - - # TODO: remove manual overriding once resources are supported in dialogic utils - if i['type'] == TYPE_OBJECT: - input = EditorResourcePicker.new() - input.edited_resource = current_value - input.base_type = i['hint_string'] - - if current_group_name == "resource": - if current_transition.inherits_anything() and 'editable' in input: - input.editable = false - - #TODO: make this less specific so it can be used for more than one parameter - input.resource_changed.connect(func (resource: Resource) -> void: - current_transition.shader = resource as Shader - ) - - else: - input.resource_changed.connect(func (resource: Resource) -> void: - if resource != customization_editor_info[i.name]['orig']: - current_transition.set_parameter(i.name, resource) - customization_editor_info[i.name]['reset'].disabled = false - else: - current_transition.remove_paramter(i.name) - customization_editor_info[i.name]['reset'].disabled = true - ) - - - - input.size_flags_horizontal = SIZE_EXPAND_FILL - customization_editor_info[i['name']]['node'] = input - - var reset := Button.new() - reset.flat = true - reset.icon = get_theme_icon("Reload", "EditorIcons") - reset.tooltip_text = "Remove customization" - customization_editor_info[i['name']]['reset'] = reset - reset.disabled = current_value == customization_editor_info[i['name']]['orig'] - current_grid.add_child(reset) - if current_group_name == "resource": - reset.pressed.connect(func() : - var default_shader = customization_editor_info[i['name']]['orig'] - current_transition.shader = default_shader - customization_editor_info[i['name']]['reset'].disabled = true - set_customization_value(i['name'], default_shader) - ) - else: - reset.pressed.connect(_on_export_override_reset.bind(i['name'])) - current_grid.add_child(input) - - -func collect_settings(properties: Array) -> Array[Dictionary]: - var settings: Array[Dictionary] = [] - - var current_group := {} - var current_subgroup := {} - - for i in properties: - if i['usage'] & PROPERTY_USAGE_CATEGORY: - continue - - if (i['usage'] & PROPERTY_USAGE_GROUP): - current_group = i - current_group['added'] = false - current_group['id'] = &'GROUP' - current_subgroup = {} - - elif i['usage'] & PROPERTY_USAGE_SUBGROUP: - current_subgroup = i - current_subgroup['added'] = false - current_subgroup['id'] = &'SUBGROUP' - - elif i['usage'] & PROPERTY_USAGE_EDITOR: - if _is_reserved_uniform(i): - continue - - if current_group.get('name', '') == 'Private': - continue - - if current_group.is_empty(): - current_group = {'name':'Parameters', 'added':false, 'id':&"GROUP"} - - if current_group.get('added', true) == false: - settings.append(current_group) - current_group['added'] = true - - if current_subgroup.is_empty(): - current_subgroup = {'name':current_group['name'], 'added':false, 'id':&"SUBGROUP"} - - if current_subgroup.get('added', true) == false: - settings.append(current_subgroup) - current_subgroup['added'] = true - - i['id'] = &'SETTING' - settings.append(i) - return settings - - -func set_export_override(property_name: String, value: String = "") -> void: - if str_to_var(value) != customization_editor_info[property_name]['orig']: - current_transition.set_parameter(property_name, value) - customization_editor_info[property_name]['reset'].disabled = false - else: - current_transition.remove_paramter(property_name) - customization_editor_info[property_name]['reset'].disabled = true - - -func _on_export_override_reset(property_name: String) -> void: - current_transition.remove_paramter(property_name) - customization_editor_info[property_name]['reset'].disabled = true - set_customization_value(property_name, customization_editor_info[property_name]['orig']) - - -func set_customization_value(property_name:String, value:Variant) -> void: - var node : Node = customization_editor_info[property_name]['node'] - - if node is CheckBox: - node.button_pressed = true if value else false - elif node is LineEdit: - node.text = value - elif node is EditorResourcePicker: - node.edited_resource = value - elif node.has_method('set_value'): - node.set_value(0 if !value else value) - elif node is ColorPickerButton: - node.color = value - elif node is OptionButton: - node.select(value) - elif node is SpinBox: - node.value = 0 if !value else value - -func _is_reserved_uniform(uniform: Variant) -> bool: - return uniform["name"] == "progress" || uniform["name"] == "previous_background" || uniform["name"] == "next_background" - - -func _on_expand_transition_info_pressed() -> void: - if %TransitionInfoBody.visible: - %TransitionInfoBody.hide() - %ExpandTransitionInfo.icon = get_theme_icon("CodeFoldedRightArrow", "EditorIcons") - else: - %TransitionInfoBody.show() - %ExpandTransitionInfo.icon = get_theme_icon("CodeFoldDownArrow", "EditorIcons") diff --git a/addons/dialogic/Modules/Character/class_dialogic_animation.gd b/addons/dialogic/Modules/Character/class_dialogic_animation.gd index 83c5d198f..b050c0286 100644 --- a/addons/dialogic/Modules/Character/class_dialogic_animation.gd +++ b/addons/dialogic/Modules/Character/class_dialogic_animation.gd @@ -1,7 +1,7 @@ class_name DialogicAnimation extends Node -## Class that can be used to animate portraits. Can be extended to create animations. +## Class that can be used to animate portraits. Can be extended to create animations. signal finished_once signal finished @@ -23,7 +23,7 @@ func _ready(): connect('finished_once', finished_one_loop) -## To be overridden. Do the actual animating/tweening in here. +## To be overridden. Do the actual animating/tweening in here. ## Use the properties [node], [time], [end_position], [orig_pos]. func animate(): pass diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn index 31bbfbeb4..65bbafac7 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn @@ -1,12 +1,12 @@ [gd_scene load_steps=5 format=3 uid="uid://c1k5m0w3r40xf"] [ext_resource type="Script" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd" id="1_tu40u"] -[ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/default_background_transition.gdshader" id="1_ygjlc"] +[ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/Transition/default_background_transition.gdshader" id="2_4sv2g"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Background/node_background_holder.gd" id="2_ghan2"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_msuxf"] -shader = ExtResource("1_ygjlc") -shader_parameter/progress = null +shader = ExtResource("2_4sv2g") +shader_parameter/progress = 0.0 shader_parameter/feather = 0.1 shader_parameter/keep_aspect_ratio = false From 5224abcbbb4baa038b895d29f4d003f5a6bd340c Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Wed, 13 Dec 2023 20:07:42 +0100 Subject: [PATCH 10/13] Add special_resources system for PortraitAnimations and Transitions Also tries but fails to implement some transitions. --- .../default_background_transition.gd | 14 ----- .../Background/Transitions/simple_fade.gd | 13 ++++ .../Background/Transitions/simple_fade.tres | 8 +++ .../simple_fade_shader.gdshader} | 0 .../Transitions/swipe_left_to_right.gd | 7 +++ .../Transitions/swipe_left_to_right.tres | 7 +++ .../class_dialogic_background_transition.gd | 16 ++++- .../Modules/Background/event_background.gd | 23 +++---- addons/dialogic/Modules/Background/index.gd | 4 ++ .../Background/simple_swipe_transitions.gd | 11 ++++ .../Background/subsystem_backgrounds.gd | 16 ++--- .../Modules/Character/event_character.gd | 62 ++++++++----------- addons/dialogic/Modules/Character/index.gd | 4 +- .../Modules/Character/subsystem_portraits.gd | 9 ++- addons/dialogic/Modules/Clear/event_clear.gd | 2 +- .../full_background_layer.tscn | 2 +- addons/dialogic/Other/DialogicResourceUtil.gd | 31 +++++++++- addons/dialogic/Other/DialogicUtil.gd | 18 +----- addons/dialogic/Other/index_class.gd | 28 ++++++++- 19 files changed, 176 insertions(+), 99 deletions(-) delete mode 100644 addons/dialogic/Modules/Background/Transition/default_background_transition.gd create mode 100644 addons/dialogic/Modules/Background/Transitions/simple_fade.gd create mode 100644 addons/dialogic/Modules/Background/Transitions/simple_fade.tres rename addons/dialogic/Modules/Background/{Transition/default_background_transition.gdshader => Transitions/simple_fade_shader.gdshader} (100%) create mode 100644 addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.gd create mode 100644 addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.tres create mode 100644 addons/dialogic/Modules/Background/simple_swipe_transitions.gd diff --git a/addons/dialogic/Modules/Background/Transition/default_background_transition.gd b/addons/dialogic/Modules/Background/Transition/default_background_transition.gd deleted file mode 100644 index dcda9e1c5..000000000 --- a/addons/dialogic/Modules/Background/Transition/default_background_transition.gd +++ /dev/null @@ -1,14 +0,0 @@ -extends DialogicBackgroundTransition - - -func _fade() -> void: - var shader := set_shader(this_folder.path_join("default_background_transition.gdshader")) - shader.set_shader_parameter("previous_background", prev_texture) - shader.set_shader_parameter("next_background", next_texture) - - var tween := create_tween() - tween.tween_property(bg_holder, "material:shader_parameter/progress", 1, time).from(0) - - await tween.finished - - transition_finished.emit() diff --git a/addons/dialogic/Modules/Background/Transitions/simple_fade.gd b/addons/dialogic/Modules/Background/Transitions/simple_fade.gd new file mode 100644 index 000000000..92a5a2859 --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/simple_fade.gd @@ -0,0 +1,13 @@ +extends DialogicBackgroundTransition + + +func _fade() -> void: + var shader := set_shader(this_folder.path_join("simple_fade_shader.gdshader")) + 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() diff --git a/addons/dialogic/Modules/Background/Transitions/simple_fade.tres b/addons/dialogic/Modules/Background/Transitions/simple_fade.tres new file mode 100644 index 000000000..4873e0848 --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/simple_fade.tres @@ -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") diff --git a/addons/dialogic/Modules/Background/Transition/default_background_transition.gdshader b/addons/dialogic/Modules/Background/Transitions/simple_fade_shader.gdshader similarity index 100% rename from addons/dialogic/Modules/Background/Transition/default_background_transition.gdshader rename to addons/dialogic/Modules/Background/Transitions/simple_fade_shader.gdshader diff --git a/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.gd b/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.gd new file mode 100644 index 000000000..ea5cf15ec --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.gd @@ -0,0 +1,7 @@ +extends "res://addons/dialogic/Modules/Background/simple_swipe_transitions.gd" + +func _fade() -> void: + var shader := setup_swipe_shader() + shader.set_shader_parameter("wipe_texture", load(this_folder.path_join("swip_left_to_right.tres"))) + + tween_shader_progress() diff --git a/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.tres b/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.tres new file mode 100644 index 000000000..c72322693 --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.tres @@ -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.991164, 0.991164, 0.991164, 1, 0, 0, 0, 1) + +[resource] +gradient = SubResource("Gradient_skd6w") diff --git a/addons/dialogic/Modules/Background/class_dialogic_background_transition.gd b/addons/dialogic/Modules/Background/class_dialogic_background_transition.gd index 0c2725352..a0e30d8e2 100644 --- a/addons/dialogic/Modules/Background/class_dialogic_background_transition.gd +++ b/addons/dialogic/Modules/Background/class_dialogic_background_transition.gd @@ -30,9 +30,23 @@ func _fade() -> void: pass -func set_shader(path_to_shader:String=this_folder.path_join("default_background_transition.gdshader")) -> ShaderMaterial: +func set_shader(path_to_shader:String) -> ShaderMaterial: if bg_holder: 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") -> void: + if !bg_holder: + return + + if !bg_holder.material is ShaderMaterial: + return + + bg_holder.material.set_shader_parameter("progress", 0.0) + var tween := create_tween() + tween.tween_property(bg_holder, "material:shader_parameter/progress", 1.0, time) + await tween.finished + transition_finished.emit() diff --git a/addons/dialogic/Modules/Background/event_background.gd b/addons/dialogic/Modules/Background/event_background.gd index 9d4d03a04..77a2ad7c4 100644 --- a/addons/dialogic/Modules/Background/event_background.gd +++ b/addons/dialogic/Modules/Background/event_background.gd @@ -17,7 +17,7 @@ var argument: String = "" ## The time the fade animation will take. Leave at 0 for instant change. var fade: float = 0.0 -var transition : String = "" +var transition: String = "" ################################################################################ @@ -61,7 +61,7 @@ func get_shortcode_parameters() -> Dictionary: "scene" : {"property": "scene", "default": ""}, "arg" : {"property": "argument", "default": ""}, "fade" : {"property": "fade", "default": 0}, - "transition" : {"property": "transition_path", "default": ""}, + "transition" : {"property": "transition", "default": ""}, } @@ -76,26 +76,23 @@ func build_event_editor(): 'placeholder': "No background", 'editor_icon':["Image", "EditorIcons"]}, 'scene == ""') - add_header_edit('argument', ValueType.SINGLELINE_TEXT, {'left_text':'Argument:'}, 'scene != ""') - add_body_edit("fade", ValueType.FLOAT, {'left_text':'Fade Time:'}) - add_body_edit("scene", ValueType.FILE, + add_header_edit("scene", ValueType.FILE, {'left_text' :'Scene:', 'file_filter':'*.tscn, *.scn; Scene Files', 'placeholder': "Default scene", 'editor_icon':["PackedScene", "EditorIcons"]}) - add_body_edit("transition_path", ValueType.COMPLEX_PICKER, - {'left_text':'transition', - 'empty_text':'Default', + add_body_edit('argument', ValueType.SINGLELINE_TEXT, {'left_text':'Argument:'}, 'scene != ""') + add_body_edit("transition", ValueType.COMPLEX_PICKER, + {'left_text':'Transition:', + 'empty_text':'Simple Fade', 'suggestions_func':get_transition_suggestions, 'editor_icon':["PopupMenu", "EditorIcons"]}) + add_body_edit("fade", ValueType.FLOAT, {'left_text':'Fade Time:'}) func get_transition_suggestions(filter:String="") -> Dictionary: - var transitions := ProjectSettings.get_setting('dialogic/transition/transition_list', []) - print(transitions) + var transitions := DialogicResourceUtil.list_special_resources_of_type("BackgroundTransition") var suggestions := {} - suggestions["Default Transition"] = {'value': "", 'editor_icon': ["EditorHandleDisabled", "EditorIcons"]} for i in transitions: - var transition: DialogicTransition = load(i) - suggestions[transition.name] = {'value': transition.resource_path, 'editor_icon': ["PopupMenu", "EditorIcons"]} + suggestions[DialogicUtil.pretty_name(i)] = {'value': DialogicUtil.pretty_name(i), 'editor_icon': ["PopupMenu", "EditorIcons"]} return suggestions diff --git a/addons/dialogic/Modules/Background/index.gd b/addons/dialogic/Modules/Background/index.gd index 034e3fb7a..344cfc9af 100644 --- a/addons/dialogic/Modules/Background/index.gd +++ b/addons/dialogic/Modules/Background/index.gd @@ -7,3 +7,7 @@ func _get_events() -> Array: func _get_subsystems() -> Array: return [{'name':'Backgrounds', 'script':this_folder.path_join('subsystem_backgrounds.gd')}] + + +func _get_special_resources() -> Array[Dictionary]: + return list_special_resources("Transitions", "BackgroundTransition", ".gd") diff --git a/addons/dialogic/Modules/Background/simple_swipe_transitions.gd b/addons/dialogic/Modules/Background/simple_swipe_transitions.gd new file mode 100644 index 000000000..16300cc95 --- /dev/null +++ b/addons/dialogic/Modules/Background/simple_swipe_transitions.gd @@ -0,0 +1,11 @@ +extends DialogicBackgroundTransition + +func setup_swipe_shader() -> ShaderMaterial: + var shader := set_shader(this_folder.path_join("simple_fade_shader.gdshader")) + + shader.set_shader_parameter("feather", 0.2) + + shader.set_shader_parameter("previous_background", prev_texture) + shader.set_shader_parameter("next_background", next_texture) + + return shader diff --git a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd index 1e58ac67c..1480d598a 100644 --- a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd +++ b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd @@ -8,7 +8,7 @@ var _tween: Tween var _tween_callbacks: Array[Callable] var default_background_scene: PackedScene = load(get_script().resource_path.get_base_dir().path_join('DefaultBackgroundScene/default_background.tscn')) -var default_transition: String = get_script().resource_path.get_base_dir().path_join('DefaultBackgroundScene/Background/default_background_transition.tres') +var default_transition: String = get_script().resource_path.get_base_dir().path_join("Transitions/simple_fade.gd") #################################################################################################### ## STATE @@ -80,7 +80,9 @@ func update_background(scene:String = '', argument:String = '', fade_time:float #material.set_shader_parameter("next_background", null) ## remove previous backgrounds - var old_viewport: SubViewportContainer = background_holder.get_meta('current_viewport', null) + 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): @@ -93,7 +95,7 @@ func update_background(scene:String = '', argument:String = '', fade_time:float else: new_viewport = null - var trans_script :Script = load(transition_path) + var trans_script :Script = load(DialogicResourceUtil.guess_special_resource("BackgroundTransition", transition_path, default_transition)) var trans_node := Node.new() trans_node.set_script(trans_script) trans_node = (trans_node as DialogicBackgroundTransition) @@ -101,12 +103,14 @@ func update_background(scene:String = '', argument:String = '', fade_time:float trans_node.time = fade_time if old_viewport: - trans_node.prev_node = old_viewport.get_meta('node', null) + trans_node.prev_scene = old_viewport.get_meta('node', null) trans_node.prev_texture = old_viewport.get_child(0).get_texture() if new_viewport: - trans_node.next_node = new_viewport.get_meta('node', null) + 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) add_child(trans_node) trans_node._fade() @@ -143,5 +147,3 @@ func has_background() -> bool: return !dialogic.current_state_info['background_scene'].is_empty() or !dialogic.current_state_info['background_argument'].is_empty() -func guess_transition_file() -> void: - diff --git a/addons/dialogic/Modules/Character/event_character.gd b/addons/dialogic/Modules/Character/event_character.gd index 0f8f537eb..4b7e469dd 100644 --- a/addons/dialogic/Modules/Character/event_character.gd +++ b/addons/dialogic/Modules/Character/event_character.gd @@ -18,7 +18,7 @@ var character : DialogicCharacter = null var portrait: String = "" ## The index of the position this character should move to var position: int = 1 -## Path to an animation script (extending DialogicAnimation). +## Name of the animation script (extending DialogicAnimation). ## On Join/Leave empty (default) will fallback to the animations set in the settings. ## On Update empty will mean no animation. var animation_name: String = "" @@ -80,7 +80,10 @@ func _execute() -> void: var max_time: float = Dialogic.Input.auto_skip.time_per_event final_animation_length = min(max_time, animation_length) - await dialogic.Portraits.join_character(character, portrait, position, mirrored, z_index, extra_data, animation_name, final_animation_length, animation_wait) + await dialogic.Portraits.join_character( + character, portrait, position, + mirrored, z_index, extra_data, + animation_name, final_animation_length, animation_wait) Actions.LEAVE: var final_animation_length: float = animation_length @@ -202,7 +205,7 @@ func to_text() -> String: var shortcode := "[" if animation_name: - shortcode += 'animation="'+DialogicUtil.pretty_name(animation_name)+'"' + shortcode += 'animation="'+animation_name+'"' if animation_length != default_values.get('animation_length', 0.5): shortcode += ' length="'+str(animation_length)+'"' @@ -267,25 +270,20 @@ func from_text(string:String) -> void: if result.get_string('shortcode'): var shortcode_params = parse_shortcode_parameters(result.get_string('shortcode')) animation_name = shortcode_params.get('animation', '') - if animation_name != "": - if !animation_name.ends_with('.gd'): - animation_name = DialogicUtil.guess_animation_file(animation_name) - if !animation_name.ends_with('.gd'): - printerr("[Dialogic] Couldn't identify animation '"+animation_name+"'.") - animation_name = "" - - var animLength = shortcode_params.get('length', '0.5').to_float() - if typeof(animLength) == TYPE_FLOAT: - animation_length = animLength - else: - animation_length = animLength.to_float() - - animation_wait = DialogicUtil.str_to_bool(shortcode_params.get('wait', 'false')) - - #repeat is supported on Update, the other two should not be checking this - if action == Actions.UPDATE: - animation_repeats = int(shortcode_params.get('repeat', animation_repeats)) - position_move_time = float(shortcode_params.get('move_time', position_move_time)) + + var animLength = shortcode_params.get('length', '0.5').to_float() + if typeof(animLength) == TYPE_FLOAT: + animation_length = animLength + else: + animation_length = animLength.to_float() + + animation_wait = DialogicUtil.str_to_bool(shortcode_params.get('wait', 'false')) + + #repeat is supported on Update, the other two should not be checking this + if action == Actions.UPDATE: + animation_repeats = int(shortcode_params.get('repeat', animation_repeats)) + position_move_time = float(shortcode_params.get('move_time', position_move_time)) + #move time is only supported on Update, but it isnt part of the animations so its separate if action == Actions.UPDATE: position_move_time = float(shortcode_params.get('move_time', position_move_time)) @@ -298,10 +296,10 @@ func from_text(string:String) -> void: extra_data = shortcode_params.get('extra_data', "") -# this is only here to provide a list of default values -# this way the module manager can add custom default overrides to this event. -# this is also why some properties are commented out, -# because it's not recommended to overwrite them this way +## this is only here to provide a list of default values +## this way the module manager can add custom default overrides to this event. +## this is also why some properties are commented out, +## because it's not recommended to overwrite them this way func get_shortcode_parameters() -> Dictionary: return { #param_name : property_info @@ -452,16 +450,8 @@ func get_animation_suggestions(search_text:String) -> Dictionary: Actions.UPDATE: suggestions['None'] = {'value':"", 'editor_icon':["GuiRadioUnchecked", "EditorIcons"]} - match action: - Actions.JOIN: - for anim in DialogicUtil.get_portrait_animation_scripts(DialogicUtil.AnimationType.IN): - suggestions[DialogicUtil.pretty_name(anim)] = {'value':anim, 'editor_icon':["Animation", "EditorIcons"]} - Actions.LEAVE: - for anim in DialogicUtil.get_portrait_animation_scripts(DialogicUtil.AnimationType.OUT): - suggestions[DialogicUtil.pretty_name(anim)] = {'value':anim, 'editor_icon':["Animation", "EditorIcons"]} - Actions.UPDATE: - for anim in DialogicUtil.get_portrait_animation_scripts(DialogicUtil.AnimationType.ACTION): - suggestions[DialogicUtil.pretty_name(anim)] = {'value':anim, 'editor_icon':["Animation", "EditorIcons"]} + for anim in DialogicUtil.get_portrait_animation_scripts(action+1): + suggestions[DialogicUtil.pretty_name(anim)] = {'value':DialogicUtil.pretty_name(anim), 'editor_icon':["Animation", "EditorIcons"]} return suggestions diff --git a/addons/dialogic/Modules/Character/index.gd b/addons/dialogic/Modules/Character/index.gd index feaa1a37f..0e893c49e 100644 --- a/addons/dialogic/Modules/Character/index.gd +++ b/addons/dialogic/Modules/Character/index.gd @@ -17,5 +17,5 @@ func _get_text_effects() -> Array[Dictionary]: return [{'command':'portrait', 'subsystem':'Portraits', 'method':'text_effect_portrait', 'arg':true}] -func _get_portrait_animations() -> Array: - return list_dir('DefaultAnimations') +func _get_special_resources() -> Array[Dictionary]: + return list_special_resources('DefaultAnimations', 'PortraitAnimation') diff --git a/addons/dialogic/Modules/Character/subsystem_portraits.gd b/addons/dialogic/Modules/Character/subsystem_portraits.gd index 9eea6b391..8aabddc69 100644 --- a/addons/dialogic/Modules/Character/subsystem_portraits.gd +++ b/addons/dialogic/Modules/Character/subsystem_portraits.gd @@ -301,11 +301,11 @@ func join_character(character:DialogicCharacter, portrait:String, position_idx: character_joined.emit(info) if animation_name.is_empty(): - animation_name = ProjectSettings.get_setting('dialogic/animations/join_default', - get_script().resource_path.get_base_dir().path_join('DefaultAnimations/fade_in_up.gd')) + animation_name = ProjectSettings.get_setting('dialogic/animations/join_default', "Fade In Up") animation_length = _get_join_default_length() animation_wait = ProjectSettings.get_setting('dialogic/animations/join_default_wait', true) + animation_name = DialogicResourceUtil.guess_special_resource("PortraitAnimation", animation_name, "") if animation_name and animation_length > 0: var anim:DialogicAnimation = _animate_portrait(character_node, animation_name, animation_length) @@ -402,6 +402,9 @@ func change_character_extradata(character:DialogicCharacter, extra_data:="") -> func animate_character(character:DialogicCharacter, animation_path:String, length:float, repeats = 1) -> DialogicAnimation: if !is_character_joined(character): return null + + animation_path = DialogicResourceUtil.guess_special_resource("PortraitAnimation", animation_path, "") + return _animate_portrait(dialogic.current_state_info.portraits[character.resource_path].node, animation_path, length, repeats) @@ -434,6 +437,8 @@ func leave_character(character:DialogicCharacter, animation_name :String = "", a animation_length = _get_leave_default_length() animation_wait = ProjectSettings.get_setting('dialogic/animations/leave_default_wait', true) + animation_name = DialogicResourceUtil.guess_special_resource("PortraitAnimation", animation_name, "") + if !animation_name.is_empty(): var anim := animate_character(character, animation_name, animation_length) diff --git a/addons/dialogic/Modules/Clear/event_clear.gd b/addons/dialogic/Modules/Clear/event_clear.gd index 92c657401..506178b7e 100644 --- a/addons/dialogic/Modules/Clear/event_clear.gd +++ b/addons/dialogic/Modules/Clear/event_clear.gd @@ -34,7 +34,7 @@ func _execute() -> void: if clear_portraits and dialogic.has_subsystem('Portraits') and len(dialogic.Portraits.get_joined_characters()) != 0: if final_time == 0: - dialogic.Portraits.leave_all_characters(DialogicUtil.guess_animation_file('Instant In Or Out'), final_time, step_by_step) + dialogic.Portraits.leave_all_characters(DialogicResourceUtil.guess_special_resource("PortraitAnimation", 'Instant In Or Out'), final_time, step_by_step) else: dialogic.Portraits.leave_all_characters("", final_time, step_by_step) if step_by_step: await dialogic.get_tree().create_timer(final_time).timeout diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn index 65bbafac7..2a9c19399 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://c1k5m0w3r40xf"] [ext_resource type="Script" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd" id="1_tu40u"] -[ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/Transition/default_background_transition.gdshader" id="2_4sv2g"] +[ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/Transitions/simple_fade_shader.gdshader" id="2_4sv2g"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Background/node_background_holder.gd" id="2_ghan2"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_msuxf"] diff --git a/addons/dialogic/Other/DialogicResourceUtil.gd b/addons/dialogic/Other/DialogicResourceUtil.gd index 7bc72de49..fca1e9fbc 100644 --- a/addons/dialogic/Other/DialogicResourceUtil.gd +++ b/addons/dialogic/Other/DialogicResourceUtil.gd @@ -3,7 +3,7 @@ class_name DialogicResourceUtil static var label_cache := {} static var event_cache: Array[DialogicEvent] = [] - +static var special_resources : Array[Dictionary] = [] static func update() -> void: update_directory('.dch') @@ -26,8 +26,9 @@ static func get_directory(extension:String) -> Dictionary: static func set_directory(extension:String, directory:Dictionary) -> void: extension = extension.trim_prefix('.') - ProjectSettings.set_setting("dialogic/directories/"+extension+'_directory', directory) - ProjectSettings.save() + if Engine.is_editor_hint(): + ProjectSettings.set_setting("dialogic/directories/"+extension+'_directory', directory) + ProjectSettings.save() Engine.set_meta(extension+'_directory', directory) @@ -160,6 +161,30 @@ static func update_event_cache() -> Array: #endregion +static func update_special_resources() -> void: + special_resources = [] + for indexer in DialogicUtil.get_indexers(): + special_resources.append_array(indexer._get_special_resources()) + + +static func list_special_resources_of_type(type:String) -> Array: + if special_resources.is_empty(): + update_special_resources() + return special_resources.filter(func(x:Dictionary): return type == x.get('type','')).map(func(x:Dictionary): return x.get('path', '')) + + +static func guess_special_resource(type:String, name:String, default:="") -> String: + if special_resources.is_empty(): + update_special_resources() + if name.begins_with('res://'): + return name + for path in list_special_resources_of_type(type): + if DialogicUtil.pretty_name(path).to_lower() == name.to_lower(): + return path + return default + + + #region HELPERS ################################################################################ diff --git a/addons/dialogic/Other/DialogicUtil.gd b/addons/dialogic/Other/DialogicUtil.gd index 4f1b951cc..61a76d3fb 100644 --- a/addons/dialogic/Other/DialogicUtil.gd +++ b/addons/dialogic/Other/DialogicUtil.gd @@ -78,25 +78,9 @@ static func get_indexers(include_custom := true, force_reload := false) -> Array return indexers - - - -static func guess_animation_file(animation_name: String) -> String: - for file in DialogicUtil.get_portrait_animation_scripts(): - if DialogicUtil.pretty_name(animation_name) == DialogicUtil.pretty_name(file): - return file - return animation_name - - enum AnimationType {ALL, IN, OUT, ACTION} static func get_portrait_animation_scripts(type:=AnimationType.ALL, include_custom:=true) -> Array: - var animations := [] - if Engine.get_main_loop().has_meta('dialogic_animation_names'): - animations = Engine.get_main_loop().get_meta('dialogic_animation_names') - else: - for i in get_indexers(): - animations.append_array(i._get_portrait_animations()) - Engine.get_main_loop().set_meta('dialogic_animation_names', animations) + var animations := DialogicResourceUtil.list_special_resources_of_type("PortraitAnimation") return animations.filter( func(script): diff --git a/addons/dialogic/Other/index_class.gd b/addons/dialogic/Other/index_class.gd index 8813b30ff..efc8adc89 100644 --- a/addons/dialogic/Other/index_class.gd +++ b/addons/dialogic/Other/index_class.gd @@ -38,6 +38,8 @@ func _get_character_editor_sections() -> Array: return [] +#region TEXT EFFECTS & MODIFIERS + ## Should return array of dictionaries with the following keys:[br] ## "command" -> the text e.g. "speed"[br] ## "node_path" or "subsystem" -> whichever contains your effect method[br] @@ -50,16 +52,37 @@ func _get_text_effects() -> Array[Dictionary]: func _get_text_modifiers() -> Array[Dictionary]: return [] +#endregion + -## Should return array of animation scripts. -func _get_portrait_animations() -> Array: +## Return a list of resources, scripts, etc. +## These can later be retrieved with DialogicResourceUtil. +## Each dictionary should contain (at least "type" and "path"). +## E.g. {"type":"Animation", "path": "res://..."} +func _get_special_resources() -> Array[Dictionary]: return [] +#region HELPERS +################################################################################ + func list_dir(subdir:='') -> Array: return Array(DirAccess.get_files_at(this_folder.path_join(subdir))).map(func(file):return this_folder.path_join(subdir).path_join(file)) +func list_special_resources(subdir:='', type:='', extension:="") -> Array[Dictionary]: + var array := [] + for i in list_dir(subdir): + if extension.is_empty() or i.ends_with(extension): + array.append({'type':type, 'path':i}) + return Array(array, TYPE_DICTIONARY, "", null) + +#endregion + + +#region STYLES & LAYOUTS +################################################################################ + func _get_style_presets() -> Array[Dictionary]: return [] @@ -107,3 +130,4 @@ func scan_for_layout_parts() -> Array[Dictionary]: return style_list +#endregion From 642365e6ffb3224acf3bf69da7a7375ecfcf4923 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Wed, 13 Dec 2023 20:29:13 +0100 Subject: [PATCH 11/13] Fix transitions, add new transition --- .../Transitions/{ => Defaults}/simple_fade.gd | 2 +- .../Transitions/{ => Defaults}/simple_fade.tres | 0 .../Transitions/Defaults/swipe_left_to_right.gd | 10 ++++++++++ .../Transitions/Defaults/swipe_right_to_left.gd | 8 ++++++++ .../class_dialogic_background_transition.gd | 2 +- ...der.gdshader => default_transition_shader.gdshader} | 0 ...e_left_to_right.tres => simple_swipe_gradient.tres} | 2 +- .../{ => Transitions}/simple_swipe_transitions.gd | 7 +++++-- .../Background/Transitions/swipe_left_to_right.gd | 7 ------- addons/dialogic/Modules/Background/index.gd | 2 +- .../Modules/Background/subsystem_backgrounds.gd | 2 +- .../Layer_FullBackground/full_background_layer.tscn | 4 ++-- 12 files changed, 30 insertions(+), 16 deletions(-) rename addons/dialogic/Modules/Background/Transitions/{ => Defaults}/simple_fade.gd (81%) rename addons/dialogic/Modules/Background/Transitions/{ => Defaults}/simple_fade.tres (100%) create mode 100644 addons/dialogic/Modules/Background/Transitions/Defaults/swipe_left_to_right.gd create mode 100644 addons/dialogic/Modules/Background/Transitions/Defaults/swipe_right_to_left.gd rename addons/dialogic/Modules/Background/{ => Transitions}/class_dialogic_background_transition.gd (89%) rename addons/dialogic/Modules/Background/Transitions/{simple_fade_shader.gdshader => default_transition_shader.gdshader} (100%) rename addons/dialogic/Modules/Background/Transitions/{swipe_left_to_right.tres => simple_swipe_gradient.tres} (73%) rename addons/dialogic/Modules/Background/{ => Transitions}/simple_swipe_transitions.gd (50%) delete mode 100644 addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.gd diff --git a/addons/dialogic/Modules/Background/Transitions/simple_fade.gd b/addons/dialogic/Modules/Background/Transitions/Defaults/simple_fade.gd similarity index 81% rename from addons/dialogic/Modules/Background/Transitions/simple_fade.gd rename to addons/dialogic/Modules/Background/Transitions/Defaults/simple_fade.gd index 92a5a2859..917d367fb 100644 --- a/addons/dialogic/Modules/Background/Transitions/simple_fade.gd +++ b/addons/dialogic/Modules/Background/Transitions/Defaults/simple_fade.gd @@ -2,7 +2,7 @@ extends DialogicBackgroundTransition func _fade() -> void: - var shader := set_shader(this_folder.path_join("simple_fade_shader.gdshader")) + var shader := set_shader() shader.set_shader_parameter("wipe_texture", load(this_folder.path_join("simple_fade.tres"))) shader.set_shader_parameter("feather", 1) diff --git a/addons/dialogic/Modules/Background/Transitions/simple_fade.tres b/addons/dialogic/Modules/Background/Transitions/Defaults/simple_fade.tres similarity index 100% rename from addons/dialogic/Modules/Background/Transitions/simple_fade.tres rename to addons/dialogic/Modules/Background/Transitions/Defaults/simple_fade.tres diff --git a/addons/dialogic/Modules/Background/Transitions/Defaults/swipe_left_to_right.gd b/addons/dialogic/Modules/Background/Transitions/Defaults/swipe_left_to_right.gd new file mode 100644 index 000000000..32084e92e --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/Defaults/swipe_left_to_right.gd @@ -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() diff --git a/addons/dialogic/Modules/Background/Transitions/Defaults/swipe_right_to_left.gd b/addons/dialogic/Modules/Background/Transitions/Defaults/swipe_right_to_left.gd new file mode 100644 index 000000000..14005d9aa --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/Defaults/swipe_right_to_left.gd @@ -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() diff --git a/addons/dialogic/Modules/Background/class_dialogic_background_transition.gd b/addons/dialogic/Modules/Background/Transitions/class_dialogic_background_transition.gd similarity index 89% rename from addons/dialogic/Modules/Background/class_dialogic_background_transition.gd rename to addons/dialogic/Modules/Background/Transitions/class_dialogic_background_transition.gd index a0e30d8e2..4f916f0ac 100644 --- a/addons/dialogic/Modules/Background/class_dialogic_background_transition.gd +++ b/addons/dialogic/Modules/Background/Transitions/class_dialogic_background_transition.gd @@ -30,7 +30,7 @@ func _fade() -> void: pass -func set_shader(path_to_shader:String) -> ShaderMaterial: +func set_shader(path_to_shader:String=DialogicUtil.get_module_path('Background').path_join("Transitions/default_transition_shader.gdshader")) -> ShaderMaterial: if bg_holder: bg_holder.material = ShaderMaterial.new() bg_holder.material.shader = load(path_to_shader) diff --git a/addons/dialogic/Modules/Background/Transitions/simple_fade_shader.gdshader b/addons/dialogic/Modules/Background/Transitions/default_transition_shader.gdshader similarity index 100% rename from addons/dialogic/Modules/Background/Transitions/simple_fade_shader.gdshader rename to addons/dialogic/Modules/Background/Transitions/default_transition_shader.gdshader diff --git a/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.tres b/addons/dialogic/Modules/Background/Transitions/simple_swipe_gradient.tres similarity index 73% rename from addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.tres rename to addons/dialogic/Modules/Background/Transitions/simple_swipe_gradient.tres index c72322693..8f8a2a550 100644 --- a/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.tres +++ b/addons/dialogic/Modules/Background/Transitions/simple_swipe_gradient.tres @@ -1,7 +1,7 @@ [gd_resource type="GradientTexture2D" load_steps=2 format=3 uid="uid://cweb3y3xc4uw0"] [sub_resource type="Gradient" id="Gradient_skd6w"] -colors = PackedColorArray(0.991164, 0.991164, 0.991164, 1, 0, 0, 0, 1) +colors = PackedColorArray(0, 0, 0, 1, 0.991164, 0.991164, 0.991164, 1) [resource] gradient = SubResource("Gradient_skd6w") diff --git a/addons/dialogic/Modules/Background/simple_swipe_transitions.gd b/addons/dialogic/Modules/Background/Transitions/simple_swipe_transitions.gd similarity index 50% rename from addons/dialogic/Modules/Background/simple_swipe_transitions.gd rename to addons/dialogic/Modules/Background/Transitions/simple_swipe_transitions.gd index 16300cc95..5705fc709 100644 --- a/addons/dialogic/Modules/Background/simple_swipe_transitions.gd +++ b/addons/dialogic/Modules/Background/Transitions/simple_swipe_transitions.gd @@ -1,9 +1,12 @@ extends DialogicBackgroundTransition func setup_swipe_shader() -> ShaderMaterial: - var shader := set_shader(this_folder.path_join("simple_fade_shader.gdshader")) + 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.2) + shader.set_shader_parameter("feather", 0.3) shader.set_shader_parameter("previous_background", prev_texture) shader.set_shader_parameter("next_background", next_texture) diff --git a/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.gd b/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.gd deleted file mode 100644 index ea5cf15ec..000000000 --- a/addons/dialogic/Modules/Background/Transitions/swipe_left_to_right.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends "res://addons/dialogic/Modules/Background/simple_swipe_transitions.gd" - -func _fade() -> void: - var shader := setup_swipe_shader() - shader.set_shader_parameter("wipe_texture", load(this_folder.path_join("swip_left_to_right.tres"))) - - tween_shader_progress() diff --git a/addons/dialogic/Modules/Background/index.gd b/addons/dialogic/Modules/Background/index.gd index 344cfc9af..e25806421 100644 --- a/addons/dialogic/Modules/Background/index.gd +++ b/addons/dialogic/Modules/Background/index.gd @@ -10,4 +10,4 @@ func _get_subsystems() -> Array: func _get_special_resources() -> Array[Dictionary]: - return list_special_resources("Transitions", "BackgroundTransition", ".gd") + return list_special_resources("Transitions/Defaults", "BackgroundTransition", ".gd") diff --git a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd index 1480d598a..904659727 100644 --- a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd +++ b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd @@ -8,7 +8,7 @@ var _tween: Tween var _tween_callbacks: Array[Callable] var default_background_scene: PackedScene = load(get_script().resource_path.get_base_dir().path_join('DefaultBackgroundScene/default_background.tscn')) -var default_transition: String = get_script().resource_path.get_base_dir().path_join("Transitions/simple_fade.gd") +var default_transition: String = get_script().resource_path.get_base_dir().path_join("Transitions/Defaults/simple_fade.gd") #################################################################################################### ## STATE diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn index 2a9c19399..6c9fef591 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=5 format=3 uid="uid://c1k5m0w3r40xf"] [ext_resource type="Script" path="res://addons/dialogic/Modules/DefaultLayoutParts/Layer_FullBackground/full_background_layer.gd" id="1_tu40u"] -[ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/Transitions/simple_fade_shader.gdshader" id="2_4sv2g"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Background/node_background_holder.gd" id="2_ghan2"] +[ext_resource type="Shader" path="res://addons/dialogic/Modules/Background/Transitions/default_transition_shader.gdshader" id="2_mwc4m"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_msuxf"] -shader = ExtResource("2_4sv2g") +shader = ExtResource("2_mwc4m") shader_parameter/progress = 0.0 shader_parameter/feather = 0.1 shader_parameter/keep_aspect_ratio = false From 463b7eddfd666e0ebe349a9abf2dac18e57811af Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Thu, 14 Dec 2023 10:39:19 +0100 Subject: [PATCH 12/13] Some more default transitions --- .../Transitions/Defaults/push_down.gd | 7 +++++ .../Transitions/Defaults/push_left.gd | 7 +++++ .../Transitions/Defaults/push_right.gd | 7 +++++ .../Transitions/Defaults/push_up.gd | 7 +++++ .../Defaults/swipe_diagonal_up_left.gd | 8 +++++ .../class_dialogic_background_transition.gd | 12 ++++--- .../push_transition_shader.gdshader | 17 ++++++++++ .../Transitions/simple_push_transitions.gd | 9 ++++++ .../Modules/Background/event_background.gd | 5 +-- .../Background/subsystem_backgrounds.gd | 31 ++++++------------- 10 files changed, 83 insertions(+), 27 deletions(-) create mode 100644 addons/dialogic/Modules/Background/Transitions/Defaults/push_down.gd create mode 100644 addons/dialogic/Modules/Background/Transitions/Defaults/push_left.gd create mode 100644 addons/dialogic/Modules/Background/Transitions/Defaults/push_right.gd create mode 100644 addons/dialogic/Modules/Background/Transitions/Defaults/push_up.gd create mode 100644 addons/dialogic/Modules/Background/Transitions/Defaults/swipe_diagonal_up_left.gd create mode 100644 addons/dialogic/Modules/Background/Transitions/push_transition_shader.gdshader create mode 100644 addons/dialogic/Modules/Background/Transitions/simple_push_transitions.gd diff --git a/addons/dialogic/Modules/Background/Transitions/Defaults/push_down.gd b/addons/dialogic/Modules/Background/Transitions/Defaults/push_down.gd new file mode 100644 index 000000000..80154d9de --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/Defaults/push_down.gd @@ -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) + diff --git a/addons/dialogic/Modules/Background/Transitions/Defaults/push_left.gd b/addons/dialogic/Modules/Background/Transitions/Defaults/push_left.gd new file mode 100644 index 000000000..778e4735b --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/Defaults/push_left.gd @@ -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) + diff --git a/addons/dialogic/Modules/Background/Transitions/Defaults/push_right.gd b/addons/dialogic/Modules/Background/Transitions/Defaults/push_right.gd new file mode 100644 index 000000000..a7799eb34 --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/Defaults/push_right.gd @@ -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) + diff --git a/addons/dialogic/Modules/Background/Transitions/Defaults/push_up.gd b/addons/dialogic/Modules/Background/Transitions/Defaults/push_up.gd new file mode 100644 index 000000000..e75ec9291 --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/Defaults/push_up.gd @@ -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) + diff --git a/addons/dialogic/Modules/Background/Transitions/Defaults/swipe_diagonal_up_left.gd b/addons/dialogic/Modules/Background/Transitions/Defaults/swipe_diagonal_up_left.gd new file mode 100644 index 000000000..787ed404f --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/Defaults/swipe_diagonal_up_left.gd @@ -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() diff --git a/addons/dialogic/Modules/Background/Transitions/class_dialogic_background_transition.gd b/addons/dialogic/Modules/Background/Transitions/class_dialogic_background_transition.gd index 4f916f0ac..f35ce6d39 100644 --- a/addons/dialogic/Modules/Background/Transitions/class_dialogic_background_transition.gd +++ b/addons/dialogic/Modules/Background/Transitions/class_dialogic_background_transition.gd @@ -32,13 +32,17 @@ func _fade() -> void: 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") -> void: +func tween_shader_progress(progress_parameter:="progress") -> PropertyTweener: if !bg_holder: return @@ -47,6 +51,6 @@ func tween_shader_progress(progress_parameter:="progress") -> void: bg_holder.material.set_shader_parameter("progress", 0.0) var tween := create_tween() - tween.tween_property(bg_holder, "material:shader_parameter/progress", 1.0, time) - await tween.finished - transition_finished.emit() + var tweener := tween.tween_property(bg_holder, "material:shader_parameter/progress", 1.0, time) + tween.tween_callback(emit_signal.bind('transition_finished')) + return tweener diff --git a/addons/dialogic/Modules/Background/Transitions/push_transition_shader.gdshader b/addons/dialogic/Modules/Background/Transitions/push_transition_shader.gdshader new file mode 100644 index 000000000..0d29bf16f --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/push_transition_shader.gdshader @@ -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)); + } +} diff --git a/addons/dialogic/Modules/Background/Transitions/simple_push_transitions.gd b/addons/dialogic/Modules/Background/Transitions/simple_push_transitions.gd new file mode 100644 index 000000000..43f1d749a --- /dev/null +++ b/addons/dialogic/Modules/Background/Transitions/simple_push_transitions.gd @@ -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 diff --git a/addons/dialogic/Modules/Background/event_background.gd b/addons/dialogic/Modules/Background/event_background.gd index 77a2ad7c4..0f4ee60cd 100644 --- a/addons/dialogic/Modules/Background/event_background.gd +++ b/addons/dialogic/Modules/Background/event_background.gd @@ -16,7 +16,7 @@ var scene: String = "" var argument: String = "" ## 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: String = "" @@ -61,7 +61,8 @@ func get_shortcode_parameters() -> Dictionary: "scene" : {"property": "scene", "default": ""}, "arg" : {"property": "argument", "default": ""}, "fade" : {"property": "fade", "default": 0}, - "transition" : {"property": "transition", "default": ""}, + "transition" : {"property": "transition", "default": "", + "suggestions": get_transition_suggestions}, } diff --git a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd index 904659727..1a088c296 100644 --- a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd +++ b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd @@ -41,13 +41,15 @@ func update_background(scene:String = '', argument:String = '', fade_time:float return var info := {'scene':scene, 'argument':argument, 'fade_time':fade_time, 'same_scene':false} - dialogic.current_state_info['background_scene'] = scene - dialogic.current_state_info['background_argument'] = argument var bg_set := false # First try just updating the existing scene. if scene == dialogic.current_state_info.get('background_scene', ''): + + if 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 @@ -58,28 +60,13 @@ func update_background(scene:String = '', argument:String = '', fade_time:float 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 - - # -# - # - ## If that didn't work, add a new scene, then cross-fade - #var previous_material = background_holder.material - #var material := ShaderMaterial.new() - #background_holder.material = material -# - #material.shader = transition.shader -# - ## make sure material is clean and ready to go - #material.set_shader_parameter("progress", 0) - ## swap the next background into previous, as that is now the older frame - #material.set_shader_parameter("previous_background", previous_material.get_shader_parameter("next_background") if previous_material else null) - #material.set_shader_parameter("next_background", null) - - ## remove previous backgrounds var old_viewport: SubViewportContainer = null if background_holder.has_meta('current_viewport'): old_viewport = background_holder.get_meta('current_viewport', null) @@ -105,7 +92,8 @@ func update_background(scene:String = '', argument:String = '', fade_time:float 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) + 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() @@ -114,6 +102,7 @@ func update_background(scene:String = '', argument:String = '', fade_time:float add_child(trans_node) trans_node._fade() + trans_node.transition_finished.connect(trans_node.queue_free) background_changed.emit(info) From 38c04d79f91b3113040145b851d0cc428cf28055 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Fri, 15 Dec 2023 15:53:16 +0100 Subject: [PATCH 13/13] Make sure "is DialogicBackground" check is done before required --- .../dialogic/Modules/Background/subsystem_backgrounds.gd | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd index 1a088c296..72a1eca90 100644 --- a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd +++ b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd @@ -74,9 +74,6 @@ func update_background(scene:String = '', argument:String = '', fade_time:float var new_viewport: SubViewportContainer if scene.ends_with('.tscn') and ResourceLoader.exists(scene): new_viewport = add_background_node(load(scene), background_holder) - if not new_viewport.get_meta('node') is DialogicBackground: - printerr("[Dialogic] Given background scene was not of type DialogicBackground!") - return elif argument: new_viewport = add_background_node(default_background_scene, background_holder) else: @@ -111,6 +108,12 @@ func add_background_node(scene:PackedScene, parent:DialogicNode_BackgroundHolder 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!") + v_con.queue_free() + viewport.queue_free() + b_scene.queue_free() + return null parent.add_child(v_con) v_con.visible = false