Skip to content

Commit 359ba7b

Browse files
committed
feat(quests and tasks): default quest and task definition can now be excluded from inspectors
Two new settings options have been added to hide the defulat quest and or task definition when adding new items.
1 parent cc23082 commit 359ba7b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Assets/com.fluid.quest-journal/Editor/Scripts/Utilities/TypesToMenu.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
5+
using CleverCrow.Fluid.QuestJournals.Quests;
6+
using CleverCrow.Fluid.QuestJournals.Tasks;
7+
using UnityEngine;
58

69
namespace CleverCrow.Fluid.QuestJournals.Editors.Utilities {
710
public class TypesToMenu<T> {
@@ -18,12 +21,19 @@ public TypesToMenu () {
1821
}
1922

2023
private static List<TypeEntry> GetTypeEntries () {
24+
var settings = Resources.Load<QuestJournalSettings>("QuestJournalSettings");
25+
var hideQuestDefault = settings == null ? false : settings.HideDefaultQuestDefinition;
26+
var hideTaskDefault = settings == null ? false : settings.HideDefaultTaskDefinition;
27+
2128
var list = new List<TypeEntry>();
2229
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) {
2330
foreach (var type in assembly.GetTypes()) {
2431
if (!type.IsSubclassOf(typeof(T)) || type.IsAbstract) continue;
2532
var attr = type.GetCustomAttribute<CreateMenuAttribute>();
2633

34+
if (hideQuestDefault && type == typeof(QuestDefinition)) continue;
35+
if (hideTaskDefault && type == typeof(TaskDefinition)) continue;
36+
2737
list.Add(new TypeEntry {
2838
type = type,
2939
path = attr?.Path ?? type.FullName,

Assets/com.fluid.quest-journal/Editor/com.fluid.quest-journal.Editor.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"rootNamespace": "",
44
"references": [
55
"com.fluid.quest-journal",
6-
"com.fluid.adnc-utilities.Editor"
6+
"com.fluid.adnc-utilities.Editor",
7+
"com.fluid.simple-settings"
78
],
89
"includePlatforms": [
910
"Editor"

Assets/com.fluid.quest-journal/Runtime/Scripts/Settings/QuestJournalSettings.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@
77
namespace CleverCrow.Fluid.QuestJournals {
88
[CreateAssetMenu(fileName = "QuestJournalSettings", menuName = "Fluid/Quest Journal/Settings")]
99
public class QuestJournalSettings : SettingsBase<QuestJournalSettings> {
10+
[Tooltip("Link your database here so the journal assets can be globally accessed")]
1011
[SerializeField]
1112
private QuestDatabase _database;
1213

14+
[Tooltip("Quests that will be automatically injected when the game begins. Overwritten on save and load")]
1315
[SerializeField]
1416
private List<QuestDefinitionBase> _startingQuests;
1517

18+
[Tooltip("Hide the default quest definition. Useful if you have your own custom quest definition class and don't want to see the default one in the inspector")]
19+
[SerializeField]
20+
bool _hideDefaultQuestDefinition;
21+
22+
[Tooltip("Hide the default task definition. Useful if you have your own custom task definition class and don't want to see the default one in the inspector")]
23+
[SerializeField]
24+
bool _hideDefaultTaskDefinition;
25+
1626
[Header("Debug")]
1727

1828
[Tooltip("Quests started automatically while using the Unity editor mode (excluded from runtime)")]
@@ -27,5 +37,7 @@ public class QuestJournalSettings : SettingsBase<QuestJournalSettings> {
2737
public List<QuestDefinitionBase> StartingQuests => _startingQuests;
2838
public List<QuestDebugEntry> DebugQuests => _debugQuests;
2939
public List<TaskDefinition> DebugTasks => _debugTasks;
40+
public bool HideDefaultQuestDefinition => _hideDefaultQuestDefinition;
41+
public bool HideDefaultTaskDefinition => _hideDefaultTaskDefinition;
3042
}
3143
}

0 commit comments

Comments
 (0)