Skip to content

Commit

Permalink
Layout behaviour setting (#1479)
Browse files Browse the repository at this point in the history
You can now choose what should happen to the layout scene after the dialog has ended. 
- `Delete` will delete the node on timeline end.
- `Hide` will hide the node on timeline end. It will be reused on the next start() call.
- `Keep` does nothing. It will also be reused on the next start() call. 

Also makes sure .start() returns a refence to the scene node. Useful to pause the game but not the dialoge.

Additional small fix in game_ui.tscn
  • Loading branch information
Jowan-Spooner authored Mar 20, 2023
1 parent d6bf596 commit 47b8aea
Show file tree
Hide file tree
Showing 4 changed files with 687 additions and 854 deletions.
15 changes: 11 additions & 4 deletions addons/dialogic/Editor/Settings/settings_general.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func _ready() -> void:

func refresh() -> void:
%PhysicsTimerButton.button_pressed = DialogicUtil.is_physics_timer()

%ExtensionsFolderPicker.set_value(DialogicUtil.get_project_setting('dialogic/extensions_folder', 'res://addons/dialogic_additions'))

# Color Palett
%LayoutNodeEndBehaviour.select(ProjectSettings.get_setting('dialogic/layout/end_behaviour', 0))
%ExtensionsFolderPicker.set_value(ProjectSettings.get_setting('dialogic/extensions_folder', 'res://addons/dialogic_additions'))
# Color Palette
color_palette = DialogicUtil.get_color_palette()
var _scale := DialogicUtil.get_editor_scale()
for n in %Colors.get_children():
Expand Down Expand Up @@ -71,6 +71,12 @@ func _on_ExtensionsFolder_value_changed(property:String, value:String) -> void:
ProjectSettings.set_setting('dialogic/extensions_folder', value)
ProjectSettings.save()


func _on_layout_node_end_behaviour_item_selected(index:int) -> void:
ProjectSettings.set_setting('dialogic/layout/end_behaviour', index)
ProjectSettings.save()


################################################################################
## EXTENSION CREATOR
################################################################################
Expand Down Expand Up @@ -177,3 +183,4 @@ func load_game_state():
%CreateExtensionButton.show()

find_parent('EditorView').plugin_reference.get_editor_interface().get_resource_filesystem().scan_sources()

1,438 changes: 634 additions & 804 deletions addons/dialogic/Editor/Settings/settings_general.tscn

Large diffs are not rendered by default.

53 changes: 38 additions & 15 deletions addons/dialogic/Other/DialogicGameHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func _ready() -> void:
collect_subsystems()

clear()


timeline_ended.connect(_on_timeline_ended)


################################################################################
Expand Down Expand Up @@ -82,7 +83,7 @@ func start_timeline(timeline_resource:Variant, label_or_idx:Variant = "") -> voi
if label_or_idx >-1:
current_event_idx = label_or_idx -1

emit_signal('timeline_started')
timeline_started.emit()
handle_next_event()


Expand All @@ -105,7 +106,7 @@ func end_timeline() -> void:
current_timeline = null
current_timeline_events = []
clear()
emit_signal("timeline_ended")
timeline_ended.emit()


func handle_next_event(ignore_argument:Variant = "") -> void:
Expand Down Expand Up @@ -148,10 +149,6 @@ func handle_event(event_index:int) -> void:
func clear() -> bool:
for subsystem in get_children():
subsystem.clear_game_state()

# Clearing existing Dialogic main nodes
for i in get_tree().get_nodes_in_group('dialogic_main_node'):
i.queue_free()

# Resetting variables
current_timeline = null
Expand Down Expand Up @@ -494,18 +491,44 @@ func process_timeline(timeline: DialogicTimeline) -> DialogicTimeline:
################################################################################
## FOR END USER
################################################################################
func start(timeline, single_instance = true):
var dialog_scene_path: String = DialogicUtil.get_project_setting(
'dialogic/layout/layout_scene', DialogicUtil.get_default_layout())
func start(timeline, single_instance = true) -> Node:
var scene :Node = null
if single_instance:
if get_tree().get_nodes_in_group('dialogic_main_node').is_empty():
var scene = load(dialog_scene_path).instantiate()
DialogicUtil.apply_scene_export_overrides(scene, ProjectSettings.get_setting('dialogic/layout/export_overrides', {}))
# if none exists, create a new one
if !is_instance_valid(get_tree().get_meta('dialogic_layout_node', '')):
scene = load(DialogicUtil.get_project_setting(
'dialogic/layout/layout_scene',
DialogicUtil.get_default_layout())
).instantiate()
DialogicUtil.apply_scene_export_overrides(
scene,
ProjectSettings.get_setting('dialogic/layout/export_overrides', {})
)
get_parent().call_deferred("add_child", scene)
get_tree().set_meta('dialogic_layout_node', scene)
# otherwise use existing scene
else:
scene = get_tree().get_meta('dialogic_layout_node', null)
scene.show()
Dialogic.start_timeline(timeline)
return scene


func get_layout_node() -> Node:
return get_tree().get_meta('dialogic_layout_node', null)


func _on_timeline_ended():
print("wowie")
if is_instance_valid(get_tree().get_meta('dialogic_layout_node', '')):
match ProjectSettings.get_setting('dialogic/layout/end_behaviour', 0):
0:
get_tree().get_meta('dialogic_layout_node', '').queue_free()
1:
get_tree().get_meta('dialogic_layout_node', '').hide()


func is_running() -> bool:
if get_tree().get_nodes_in_group('dialogic_main_node').is_empty():
func has_active_layout_node() -> bool:
if !is_instance_valid(get_tree().get_meta('dialogic_layout_node', null)) or !get_tree().get_meta('dialogic_layout_node').visible:
return false
return true
35 changes: 4 additions & 31 deletions game_ui.tscn
Original file line number Diff line number Diff line change
@@ -1,45 +1,22 @@
[gd_scene load_steps=12 format=3 uid="uid://bodlkbe7qcbqs"]
[gd_scene load_steps=10 format=3 uid="uid://bodlkbe7qcbqs"]

[ext_resource type="Script" path="res://addons/dialogic/Events/Background/node_background_holder.gd" id="1_7xoxi"]
[ext_resource type="Script" path="res://addons/dialogic/Events/Text/node_dialog_text.gd" id="1_pyeja"]
[ext_resource type="Script" path="res://addons/dialogic/Events/Choice/node_choice_button.gd" id="2_0chsi"]
[ext_resource type="Script" path="res://addons/dialogic/Events/Text/node_next_indicator.gd" id="2_8o2ju"]
[ext_resource type="Script" path="res://addons/dialogic/Events/Text/node_input_handler.gd" id="2_cul8m"]
[ext_resource type="Texture2D" uid="uid://bbqfq3s7qrduv" path="res://icon.svg" id="3_y357o"]
[ext_resource type="Texture2D" uid="uid://bvqgwmds7enrv" path="res://icon.svg" id="3_y357o"]
[ext_resource type="Script" path="res://addons/dialogic/Events/Text/node_name_label.gd" id="3_yr5sj"]
[ext_resource type="Script" path="res://addons/dialogic/Events/Character/node_portrait_position.gd" id="7_sijvi"]
[ext_resource type="Script" path="res://addons/dialogic/Events/Character/node_portrait_holder.gd" id="8_mhj1c"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8d420"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0.176471, 0.180392, 0.254902, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8

[sub_resource type="Theme" id="Theme_x6eit"]
ChoiceButton/base_type = &"Button"
ChoiceButton/styles/normal = SubResource("StyleBoxFlat_8d420")

[node name="GameUI" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_x6eit")
[node name="GameUI" type="CanvasLayer"]

[node name="DialogicNode_BackgroundHolder" type="CanvasLayer" parent="."]
layer = -1
script = ExtResource("1_7xoxi")

[node name="ColorRect2" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
Expand All @@ -48,7 +25,6 @@ grow_vertical = 2
color = Color(0.0431373, 0.0431373, 0.0431373, 0.490196)

[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
Expand All @@ -62,7 +38,6 @@ rotation = 0.000493497
color = Color(0.0470588, 0.0470588, 0.0470588, 0.811765)

[node name="VBoxContainer2" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
Expand All @@ -85,9 +60,8 @@ hide_when_empty = false
clip_contents = false
layout_mode = 2
text = "This is some default text that is as long as it needs to be for me to see where the dialog box and it's limits are."
fit_content_height = true
fit_content = true
script = ExtResource("1_pyeja")
Align = 1

[node name="DNextIndicator" type="Control" parent="VBoxContainer2/DialogicNode_DialogText"]
layout_mode = 1
Expand Down Expand Up @@ -172,7 +146,6 @@ script = ExtResource("7_sijvi")
[node name="DialogicNode_PortraitPosition2" type="Marker2D" parent="."]
position = Vector2(983, 656)
script = ExtResource("7_sijvi")
position_index = 1

[node name="DialogicNode_PortraitHolder" type="CanvasLayer" parent="."]
script = ExtResource("8_mhj1c")

0 comments on commit 47b8aea

Please sign in to comment.