diff --git a/addons/dialogic/plugin.gd b/addons/dialogic/plugin.gd index 75df7e6..5f6729d 100644 --- a/addons/dialogic/plugin.gd +++ b/addons/dialogic/plugin.gd @@ -95,6 +95,8 @@ func _make_visible(visible:bool) -> void: func _save_external_data() -> void: if _editor_view_and_manager_exist(): editor_view.editors_manager.save_current_resource() + + DialogicResourceUtil.update_directory('.tres') func _get_unsaved_status(for_scene:String) -> String: diff --git a/addons/dialogic_additions/Quest/event_quest_activate.gd b/addons/dialogic_additions/Quest/event_quest_activate.gd new file mode 100644 index 0000000..32a53f5 --- /dev/null +++ b/addons/dialogic_additions/Quest/event_quest_activate.gd @@ -0,0 +1,55 @@ +@tool +extends DialogicEvent +class_name DialogicQuestActivateEvent + + +# Define properties of the event here +var quest_resource: String + +func _execute() -> void: + var resource = ResourceLoader.load(quest_resource) + QuestManager.ChangeQuestStatus(resource,QuestEventUtils.QuestStatus.ACTIVE) + QuestManager.SetFollowQuest(resource) + finish() # called to continue with the next event + + +#region INITIALIZE +################################################################################ +# Set fixed settings of this event +func _init() -> void: + event_name = "Activate Quest" + event_category = "Quest" + + + +#endregion + +#region SAVING/LOADING +################################################################################ +func get_shortcode() -> String: + return "quest_activate" + +func get_shortcode_parameters() -> Dictionary: + return { + #param_name : property_info + "quest_resource" : {"property": "quest_resource", "default": ""}, + } + +# You can alternatively overwrite these 3 functions: to_text(), from_text(), is_valid_event() +#endregion + + +#region EDITOR REPRESENTATION +################################################################################ + +func build_event_editor() -> void: + add_header_label("Activate Quest") + add_header_edit( + "quest_resource", + ValueType.DYNAMIC_OPTIONS, + { + "mode":2, + "suggestions_func":QuestEventUtils.quest_resource_suggestrions + }) + +#endregion diff --git a/addons/dialogic_additions/Quest/event_quest_activate.gd.uid b/addons/dialogic_additions/Quest/event_quest_activate.gd.uid new file mode 100644 index 0000000..bf7f2d5 --- /dev/null +++ b/addons/dialogic_additions/Quest/event_quest_activate.gd.uid @@ -0,0 +1 @@ +uid://br3a7napsjmg3 diff --git a/addons/dialogic_additions/Quest/event_quest_complete.gd b/addons/dialogic_additions/Quest/event_quest_complete.gd new file mode 100644 index 0000000..018be7b --- /dev/null +++ b/addons/dialogic_additions/Quest/event_quest_complete.gd @@ -0,0 +1,55 @@ +@tool +extends DialogicEvent +class_name DialogicQuestCompleteEvent + + +# Define properties of the event here +var quest_resource: String + +func _execute() -> void: + var resource = ResourceLoader.load(quest_resource) + QuestManager.ChangeQuestStatus(resource,QuestEventUtils.QuestStatus.DONE) + QuestManager.SetFollowQuest(null) + finish() # called to continue with the next event + + +#region INITIALIZE +################################################################################ +# Set fixed settings of this event +func _init() -> void: + event_name = "Complete Quest" + event_category = "Quest" + + + +#endregion + +#region SAVING/LOADING +################################################################################ +func get_shortcode() -> String: + return "quest_complete" + +func get_shortcode_parameters() -> Dictionary: + return { + #param_name : property_info + "quest_resource" : {"property": "quest_resource", "default": ""}, + } + +# You can alternatively overwrite these 3 functions: to_text(), from_text(), is_valid_event() +#endregion + + +#region EDITOR REPRESENTATION +################################################################################ + +func build_event_editor() -> void: + add_header_label("Complete Quest") + add_header_edit( + "quest_resource", + ValueType.DYNAMIC_OPTIONS, + { + "mode":2, + "suggestions_func":QuestEventUtils.quest_resource_suggestrions + }) + +#endregion diff --git a/addons/dialogic_additions/Quest/event_quest_complete.gd.uid b/addons/dialogic_additions/Quest/event_quest_complete.gd.uid new file mode 100644 index 0000000..d51ec37 --- /dev/null +++ b/addons/dialogic_additions/Quest/event_quest_complete.gd.uid @@ -0,0 +1 @@ +uid://c8mtjwpe7c0h diff --git a/addons/dialogic_additions/Quest/event_utils.gd b/addons/dialogic_additions/Quest/event_utils.gd new file mode 100644 index 0000000..4ea02c1 --- /dev/null +++ b/addons/dialogic_additions/Quest/event_utils.gd @@ -0,0 +1,33 @@ +class_name QuestEventUtils + +enum QuestStatus{ + HIDDEN = 0, + ACTIVE = 1, + DONE = 2, + CANCLED = 3 +} + + +static func quest_resource_suggestrions(search_text:String) -> Dictionary: + var ret_val = {} + var quest_paths = get_all_file_paths("res://resources/quests") + + for path in quest_paths: + var res = ResourceLoader.load(path) + ret_val[res.id]= {"value":path, "tooltip":res.title + "\n\n" + res.description} + + return ret_val + +static func get_all_file_paths(path: String) -> Array[String]: + var file_paths: Array[String] = [] + var dir = DirAccess.open(path) + dir.list_dir_begin() + var file_name = dir.get_next() + while file_name != "": + var file_path = path + "/" + file_name + if dir.current_is_dir(): + file_paths += get_all_file_paths(file_path) + else: + file_paths.append(file_path) + file_name = dir.get_next() + return file_paths diff --git a/addons/dialogic_additions/Quest/event_utils.gd.uid b/addons/dialogic_additions/Quest/event_utils.gd.uid new file mode 100644 index 0000000..8604381 --- /dev/null +++ b/addons/dialogic_additions/Quest/event_utils.gd.uid @@ -0,0 +1 @@ +uid://d1x2343wpkdku diff --git a/addons/dialogic_additions/Quest/index.gd b/addons/dialogic_additions/Quest/index.gd new file mode 100644 index 0000000..7f49210 --- /dev/null +++ b/addons/dialogic_additions/Quest/index.gd @@ -0,0 +1,8 @@ +@tool +extends DialogicIndexer + +func _get_events() -> Array: + return [ + this_folder.path_join('event_quest_activate.gd'), + this_folder.path_join('event_quest_complete.gd') + ] diff --git a/addons/dialogic_additions/Quest/index.gd.uid b/addons/dialogic_additions/Quest/index.gd.uid new file mode 100644 index 0000000..806a846 --- /dev/null +++ b/addons/dialogic_additions/Quest/index.gd.uid @@ -0,0 +1 @@ +uid://wup1fvm05rqv