Skip to content

Commit f0cd6d6

Browse files
authored
Merge pull request #23 from bisterix-studio/tighten-up-ux
Improve first-time use UX and add some error handling where there is no Dialogue Sequence present
2 parents d8f8d86 + 2f07197 commit f0cd6d6

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

addons/parley/components/sidebar.gd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ var dialogue_ast_filter: String = "": set = _set_dialogue_ast_filter
1616
@onready var node_list: ItemList = %NodesItemList
1717
@onready var dialogue_sequences_list: ItemList = %DialogueSequencesList
1818
@onready var current_dialogue_sequence_label: LineEdit = %CurrentDialogueSequence
19+
@onready var manage_dialogue_sequence_button: Button = %ManageDialogueSequenceButton
20+
@onready var no_dialogue_sequence_warning_button: Button = %NoDialogueSequenceWarningButton
1921

2022

2123
signal dialogue_ast_selected(dialogue_ast: ParleyDialogueSequenceAst)
@@ -29,6 +31,7 @@ func _ready() -> void:
2931
dialogue_asts = []
3032
_set_current_dialogue_ast(current_dialogue_ast)
3133
current_dialogue_sequence_label.tooltip_text = "Edit the Dialogue Sequence"
34+
no_dialogue_sequence_warning_button.tooltip_text = "No Dialogue Sequence opened. Please create or open one via the Parley file menu in the top left-hand side."
3235
#endregion
3336

3437

@@ -93,8 +96,12 @@ func _render_current_dialogue_sequence() -> void:
9396
if current_dialogue_sequence_label:
9497
if current_dialogue_ast and current_dialogue_ast.resource_path:
9598
current_dialogue_sequence_label.text = current_dialogue_ast.resource_path.get_file()
99+
no_dialogue_sequence_warning_button.hide()
100+
manage_dialogue_sequence_button.show()
96101
else:
97102
current_dialogue_sequence_label.text = "No Dialogue Sequence Selected"
103+
no_dialogue_sequence_warning_button.show()
104+
manage_dialogue_sequence_button.hide()
98105
#endregion
99106

100107

addons/parley/components/sidebar.tscn

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
[gd_scene load_steps=5 format=3 uid="uid://bl5g47dhb7hmk"]
1+
[gd_scene load_steps=6 format=3 uid="uid://bl5g47dhb7hmk"]
22

33
[ext_resource type="Script" uid="uid://dbqp7dc5s5e3n" path="res://addons/parley/components/sidebar.gd" id="1_d0u7e"]
44
[ext_resource type="Texture2D" uid="uid://cr4knibdm85n1" path="res://addons/parley/assets/Search.svg" id="2_sqyhy"]
55
[ext_resource type="Texture2D" uid="uid://c4qx01xbrjp7h" path="res://addons/parley/assets/Edit.svg" id="3_l7xuh"]
6+
[ext_resource type="Texture2D" uid="uid://drrcpeyo5x1ih" path="res://addons/parley/assets/Warning.svg" id="4_0tc7b"]
67

78
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_l7xuh"]
89
content_margin_left = 12.0
@@ -74,9 +75,15 @@ placeholder_text = "No Dialogue Sequence Selected"
7475
editable = false
7576

7677
[node name="ManageDialogueSequenceButton" type="Button" parent="VSplitContainer/DialogueSequenceContainer/VBoxContainer/ManageDialogueSequenceContainer"]
78+
unique_name_in_owner = true
7779
layout_mode = 2
7880
icon = ExtResource("3_l7xuh")
7981

82+
[node name="NoDialogueSequenceWarningButton" type="Button" parent="VSplitContainer/DialogueSequenceContainer/VBoxContainer/ManageDialogueSequenceContainer"]
83+
unique_name_in_owner = true
84+
layout_mode = 2
85+
icon = ExtResource("4_0tc7b")
86+
8087
[node name="NodeList" type="VBoxContainer" parent="VSplitContainer/DialogueSequenceContainer/VBoxContainer"]
8188
layout_mode = 2
8289
size_flags_vertical = 3

addons/parley/main_panel.gd

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,27 +292,36 @@ func _on_new_dialogue_sequence_modal_dialogue_ast_created(new_dialogue_ast: Parl
292292

293293

294294
func _on_insert_id_pressed(type: ParleyDialogueSequenceAst.Type) -> void:
295+
if not dialogue_ast:
296+
push_warning(ParleyUtils.log.warn_msg("Unable to add Node of type %s to the Dialogue Sequence. Dialogue Sequence is not currently loaded into Parley. Please open one via the file menu in the top left-hand side." % ParleyDialogueSequenceAst.get_type_name(type)))
297+
return
295298
var ast_node: Variant = dialogue_ast.add_new_node(type, (graph_view.scroll_offset + graph_view.size * 0.5) / graph_view.zoom)
296299
if ast_node:
297300
await refresh()
298301

299302

300303
func _on_save_pressed() -> void:
301-
_save_dialogue()
304+
var result: int = _save_dialogue()
305+
if result != OK:
306+
return
302307
# This is needed to reset the Graph and ensure
303308
# that no weirdness is going to happen. For example
304309
# move the group nodes after a save when refresh isn't present
305310
await refresh()
306311

307312

308-
func _save_dialogue() -> void:
313+
func _save_dialogue() -> int:
314+
if not dialogue_ast or not dialogue_ast.resource_path:
315+
push_error(ParleyUtils.log.error_msg("Unable to save Dialogue Sequence. Dialogue Sequence does not exist in the file system, please create one using the file menu in the top left-hand side"))
316+
return ERR_DOES_NOT_EXIST
309317
var ok: int = ResourceSaver.save(dialogue_ast)
310318
if ok != OK:
311319
push_warning(ParleyUtils.log.warn_msg("Error saving the Dialogue AST: %d" % [ok]))
312-
return
320+
return ok
313321
# This is needed to correctly reload upon file saves
314322
if Engine.is_editor_hint():
315323
EditorInterface.get_resource_filesystem().reimport_files([dialogue_ast.resource_path])
324+
return OK
316325

317326
func _on_arrange_nodes_button_pressed() -> void:
318327
selected_node_id = null
@@ -325,13 +334,19 @@ func _on_refresh_button_pressed() -> void:
325334

326335
func _on_test_dialogue_from_start_button_pressed() -> void:
327336
# TODO: dialogue is technically async so we should ideally wait here
328-
_save_dialogue()
337+
var result: int = _save_dialogue()
338+
if result != OK:
339+
push_error("Error saving Dialogue Sequence: %s. Unable to start Dialogue Sequence testing from start..." % error_string(result))
340+
return
329341
if parley_manager:
330342
parley_manager.run_test_dialogue_from_start(dialogue_ast)
331343

332344
func _on_test_dialogue_from_selected_button_pressed() -> void:
333345
# TODO: dialogue is technically async so we should ideally wait here
334-
_save_dialogue()
346+
var result: int = _save_dialogue()
347+
if result != OK:
348+
push_error("Error saving Dialogue Sequence: %s. Unable to start Dialogue Sequence testing from Node %s..." % [error_string(result), selected_node_id])
349+
return
335350
if parley_manager:
336351
parley_manager.run_test_dialogue_from_selected(dialogue_ast, selected_node_id)
337352
#endregion
@@ -620,7 +635,10 @@ func _on_sidebar_edit_dialogue_ast_pressed(selected_dialogue_ast_for_edit: Parle
620635

621636

622637
func _on_edit_dialogue_sequence_modal_dialogue_ast_edited(_dialogue_ast: ParleyDialogueSequenceAst) -> void:
623-
_save_dialogue()
638+
var result: int = _save_dialogue()
639+
if result != OK:
640+
push_error("Error saving Dialogue Sequence: %s." % error_string(result))
641+
return
624642
# This is needed to reset the Graph and ensure
625643
# that no weirdness is going to happen. For example
626644
# move the group nodes after a save when refresh isn't present

addons/parley/parley_runtime.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func run_dialogue(ctx: Context, dialogue_sequence_ast: DialogueSequenceAst, star
2727
var current_scene: Node = _get_current_scene()
2828
var dialogue_balloon_path: String = Settings.get_setting(Constants.DIALOGUE_BALLOON_PATH)
2929
if not ResourceLoader.exists(dialogue_balloon_path):
30-
print_rich(Utils.log.info_msg("Dialogue balloon does not exist at: %s. Stopping..."))
30+
print_rich(Utils.log.info_msg("Dialogue balloon does not exist at: %s. Stopping..." % dialogue_balloon_path))
3131
return
3232
var dialogue_balloon_scene: PackedScene = load(dialogue_balloon_path)
3333
var balloon: Node = dialogue_balloon_scene.instantiate()

docs/latest/getting-started/installation.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ Editor.
2121
5. Complete the first time installation by following the
2222
[first-time installation instructions](#first-time-installation) below.
2323

24+
> [tip]: If you experience compilation errors after downloading Parley, an easy
25+
> way of rectifying this is to restart your Godot project. If the problem
26+
> persists however, please raise an issue
27+
> [here](https://github.com/bisterix-studio/parley/issue).
28+
2429
### Option 2: Download and install
2530

2631
1. Download the compressed zip file from the
@@ -32,6 +37,11 @@ Editor.
3237
3. Complete the first-time installation by following the
3338
[first-time installation instructions](#first-time-installation) below.
3439

40+
> [tip]: If you experience compilation errors after extracting the Parley zip
41+
> file, an easy way of rectifying this is to restart your Godot project. If the
42+
> problem persists however, please raise an issue
43+
> [here](https://github.com/bisterix-studio/parley/issue).
44+
3545
### First-time installation
3646

3747
![installation](../../../www/static/docs/installation/installation.gif)

0 commit comments

Comments
 (0)