Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 17683f8
Author: Jowan-Spooner <42868150+Jowan-Spooner@users.noreply.github.com>
Date:   Fri Jan 26 18:55:38 2024 +0100

    Rename the Other folder to Core (dialogic-godot#2047)

    * Rename the Other folder to Core

    * Add a small auto-update

    * Fix unit test

commit ce2a734
Author: Jowan-Spooner <42868150+Jowan-Spooner@users.noreply.github.com>
Date:   Fri Jan 26 18:55:03 2024 +0100

    Allow specifying parent to add layout (dialogic-godot#2048)

    - fixes dialogic-godot#2029

commit c33a560
Author: Dabbles in too many things <mitch.zais@gmail.com>
Date:   Fri Jan 26 09:54:52 2024 -0800

    Avoid null get_tree() call (dialogic-godot#2052)

    get_tree() can return null when the Dialogic view isn't open but this function is being called by an external system. No node tree exists to wait for or manipulate, so errors are spammed.
  • Loading branch information
Invertex committed Jan 27, 2024
1 parent b13ff3e commit fae7712
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/resources/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ renderer/rendering_method.mobile="gl_compatibility"

[autoload]

Dialogic="*res://addons/dialogic/Other/DialogicGameHandler.gd"
Dialogic="*res://addons/dialogic/Core/DialogicGameHandler.gd"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static func get_module_path(name:String, builtin:=true) -> String:


static func update_autoload_subsystem_access() -> void:
var script: Script = load("res://addons/dialogic/Other/DialogicGameHandler.gd")
var script: Script = load("res://addons/dialogic/Core/DialogicGameHandler.gd")

var new_subsystem_access_list := "#region SUBSYSTEMS\n"

Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions addons/dialogic/Editor/Common/update_install_window.gd
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ func _on_update_manager_downdload_completed(result:int):


func _on_resources_reimported(resources:Array) -> void:
await get_tree().process_frame
get_parent().move_to_foreground()
if is_inside_tree():
await get_tree().process_frame
get_parent().move_to_foreground()


func markdown_to_bbcode(text:String) -> String:
Expand Down
15 changes: 10 additions & 5 deletions addons/dialogic/Modules/Style/subsystem_styles.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func load_game_state(load_flag:=LoadFlags.FULL_LOAD):
#region MAIN METHODS
####################################################################################################

func load_style(style_name:="", is_base_style:=true) -> Node:
func load_style(style_name:="", parent:Node = null, is_base_style:=true) -> Node:
var style := DialogicUtil.get_style_by_name(style_name)

var signal_info := {'style':style_name}
Expand All @@ -34,7 +34,6 @@ func load_style(style_name:="", is_base_style:=true) -> Node:
dialogic.current_state_info['base_style'] = style_name

var previous_layout := get_layout_node()

if is_instance_valid(previous_layout) and previous_layout.has_meta('style'):
signal_info['previous'] = previous_layout.get_meta('style').name

Expand All @@ -55,11 +54,14 @@ func load_style(style_name:="", is_base_style:=true) -> Node:
return

else:
parent = previous_layout.get_parent()

previous_layout.get_parent().remove_child(previous_layout)
previous_layout.queue_free()


# if this is another style:
var new_layout := create_layout(style)
var new_layout := create_layout(style, parent)
new_layout.ready.connect(reload_current_info_into_new_style)

style_changed.emit(signal_info)
Expand All @@ -69,7 +71,7 @@ func load_style(style_name:="", is_base_style:=true) -> Node:

## Method that adds a layout scene with all the necessary layers.
## The layout scene will be added to the tree root and returned.
func create_layout(style:DialogicStyle) -> DialogicLayoutBase:
func create_layout(style:DialogicStyle, parent:Node = null) -> DialogicLayoutBase:

# Load base scene
var base_scene: DialogicLayoutBase
Expand Down Expand Up @@ -104,7 +106,10 @@ func create_layout(style:DialogicStyle) -> DialogicLayoutBase:

base_scene.set_meta('style', style)

dialogic.get_parent().call_deferred("add_child", base_scene)
if parent == null:
parent = dialogic.get_parent()
parent.call_deferred("add_child", base_scene)

dialogic.get_tree().set_meta('dialogic_layout_node', base_scene)

return base_scene
Expand Down
2 changes: 1 addition & 1 deletion addons/dialogic/Modules/Text/event_text.gd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func _execute() -> void:

if character:
if dialogic.has_subsystem('Styles') and character.custom_info.get('style', null):
dialogic.Styles.load_style(character.custom_info.style, false)
dialogic.Styles.load_style(character.custom_info.style, null, false)
await dialogic.get_tree().process_frame


Expand Down
7 changes: 6 additions & 1 deletion addons/dialogic/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extends EditorPlugin
## Preload the main panel scene
const MainPanel := preload("res://addons/dialogic/Editor/editor_main.tscn")
const PLUGIN_NAME := "Dialogic"
const PLUGIN_HANDLER_PATH := "res://addons/dialogic/Other/DialogicGameHandler.gd"
const PLUGIN_HANDLER_PATH := "res://addons/dialogic/Core/DialogicGameHandler.gd"
const PLUGIN_ICON_PATH := "res://addons/dialogic/Editor/Images/plugin-icon.svg"

## References used by various other scripts to quickly reference these things
Expand Down Expand Up @@ -40,6 +40,11 @@ func _enter_tree() -> void:
get_editor_interface().get_editor_main_screen().add_child(editor_view)
_make_visible(false)

# Auto-update the singleton path for alpha users
# TODO remove at some point during beta or later
remove_autoload_singleton(PLUGIN_NAME)
add_autoload_singleton(PLUGIN_NAME, PLUGIN_HANDLER_PATH)


func _exit_tree() -> void:
if editor_view:
Expand Down

0 comments on commit fae7712

Please sign in to comment.