net.dreditor.presents 0.0.0-stage → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.attestation.p7m +0 -0
- package/DREditor.Presents.asmdef +16 -0
- package/DREditor.Presents.asmdef.meta +7 -0
- package/Editor/CreatePresentsWizard.cs +160 -0
- package/Editor/CreatePresentsWizard.cs.meta +11 -0
- package/Editor/DREditor.Presents.Editor.asmdef +18 -0
- package/Editor/DREditor.Presents.Editor.asmdef.meta +7 -0
- package/Editor/DescriptionsByIDOption.cs +106 -0
- package/Editor/DescriptionsByIDOption.cs.meta +2 -0
- package/Editor/PresentDatabaseEditor.cs +184 -0
- package/Editor/PresentDatabaseEditor.cs.meta +11 -0
- package/Editor/PresentEditor.cs +153 -0
- package/Editor/PresentEditor.cs.meta +11 -0
- package/Editor/PresentGoogleSheetsImportOption.cs +55 -0
- package/Editor/PresentGoogleSheetsImportOption.cs.meta +2 -0
- package/Editor/PresentImportOptionBase.cs +132 -0
- package/Editor/PresentImportOptionBase.cs.meta +2 -0
- package/Editor/PresentReactionLevelOption.cs +81 -0
- package/Editor/PresentReactionLevelOption.cs.meta +2 -0
- package/Editor/PresentUtility.cs +42 -0
- package/Editor/PresentUtility.cs.meta +11 -0
- package/Editor/ReactionByIDCharactersOption.cs +136 -0
- package/Editor/ReactionByIDCharactersOption.cs.meta +2 -0
- package/Editor/ReactionByIDOption.cs +54 -0
- package/Editor/ReactionByIDOption.cs.meta +2 -0
- package/Editor/ReactionImportOption.cs +74 -0
- package/Editor/ReactionImportOption.cs.meta +2 -0
- package/Editor/ReactionImporter.cs +59 -0
- package/Editor/ReactionImporter.cs.meta +11 -0
- package/Editor/RenamePresentsByIDOption.cs +96 -0
- package/Editor/RenamePresentsByIDOption.cs.meta +2 -0
- package/Editor/StudentReactionCollectionEditor.cs +104 -0
- package/Editor/StudentReactionCollectionEditor.cs.meta +2 -0
- package/Editor/StudentReactionEditor.cs +83 -0
- package/Editor/StudentReactionEditor.cs.meta +2 -0
- package/Editor.meta +8 -0
- package/IAmountablePresent.cs +29 -0
- package/IAmountablePresent.cs.meta +2 -0
- package/INewPresentObtained.cs +22 -0
- package/INewPresentObtained.cs.meta +2 -0
- package/IPresentData.cs +10 -0
- package/IPresentData.cs.meta +2 -0
- package/IPresentManager.cs +38 -0
- package/IPresentManager.cs.meta +2 -0
- package/IReactionEntry.cs +21 -0
- package/IReactionEntry.cs.meta +2 -0
- package/Present.cs +24 -0
- package/Present.cs.meta +11 -0
- package/PresentData.cs +50 -0
- package/PresentData.cs.meta +11 -0
- package/PresentDatabase.cs +28 -0
- package/PresentDatabase.cs.meta +11 -0
- package/PresentManager.cs +71 -0
- package/PresentManager.cs.meta +11 -0
- package/PresentManagerBase.cs +35 -0
- package/PresentManagerBase.cs.meta +2 -0
- package/PresentReactionLevel.cs +12 -0
- package/PresentReactionLevel.cs.meta +11 -0
- package/PresentSaveBase.cs +26 -0
- package/PresentSaveBase.cs.meta +2 -0
- package/ReactionLevelDatabase.cs +35 -0
- package/ReactionLevelDatabase.cs.meta +11 -0
- package/Samples~/Present_Manager.prefab +54 -0
- package/Samples~/Present_Manager.prefab.meta +7 -0
- package/StudentReaction.cs +28 -0
- package/StudentReaction.cs.meta +2 -0
- package/StudentReactionCollection.cs +45 -0
- package/StudentReactionCollection.cs.meta +2 -0
- package/package.json +37 -4
- package/package.json.meta +7 -0
- package/README.md +0 -3
package/.attestation.p7m
ADDED
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "DREditor.Presents",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"DREditor"
|
|
6
|
+
],
|
|
7
|
+
"includePlatforms": [],
|
|
8
|
+
"excludePlatforms": [],
|
|
9
|
+
"allowUnsafeCode": false,
|
|
10
|
+
"overrideReferences": false,
|
|
11
|
+
"precompiledReferences": [],
|
|
12
|
+
"autoReferenced": true,
|
|
13
|
+
"defineConstraints": [],
|
|
14
|
+
"versionDefines": [],
|
|
15
|
+
"noEngineReferences": false
|
|
16
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For DREditor
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using DREditor.Characters;
|
|
4
|
+
using DREditor.Editor.Utility;
|
|
5
|
+
using System;
|
|
6
|
+
using System.Collections.Generic;
|
|
7
|
+
using System.Linq;
|
|
8
|
+
using System.Text.RegularExpressions;
|
|
9
|
+
using UnityEditor;
|
|
10
|
+
using UnityEngine;
|
|
11
|
+
|
|
12
|
+
namespace DREditor.Presents.Editor
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
public class CreatePresentsWizard : ScriptableWizard
|
|
18
|
+
{
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
[Header("")]
|
|
23
|
+
[Divider]
|
|
24
|
+
[Tooltip("")]
|
|
25
|
+
[SerializeField] protected int startID = 0;
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
///
|
|
29
|
+
/// </summary>
|
|
30
|
+
[Tooltip("")]
|
|
31
|
+
[SerializeField] protected bool spriteHasIDNum = false;
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
///
|
|
35
|
+
/// </summary>
|
|
36
|
+
[ShowIf(nameof(IDWillBeInSpriteName))]
|
|
37
|
+
[Tooltip("")]
|
|
38
|
+
[SerializeField] protected string matchSpriteID = @"\d+";
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
///
|
|
43
|
+
/// </summary>
|
|
44
|
+
protected CharacterDatabase database;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
[MenuItem("DREditor/FTE/Create Presents")]
|
|
48
|
+
static void CreateWizard() => DisplayWizard<CreatePresentsWizard>("Create Materials", "Create");
|
|
49
|
+
|
|
50
|
+
protected virtual void OnEnable() => database = DatabaseUtility.LoadDatabase<CharacterDatabase>();
|
|
51
|
+
|
|
52
|
+
protected virtual void OnWizardCreate()
|
|
53
|
+
{
|
|
54
|
+
try
|
|
55
|
+
{
|
|
56
|
+
AssetDatabase.StartAssetEditing();
|
|
57
|
+
|
|
58
|
+
CreatePresents();
|
|
59
|
+
}
|
|
60
|
+
finally
|
|
61
|
+
{
|
|
62
|
+
AssetDatabase.StopAssetEditing();
|
|
63
|
+
|
|
64
|
+
AssetDatabase.SaveAssets();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// <summary>
|
|
69
|
+
///
|
|
70
|
+
/// </summary>
|
|
71
|
+
protected virtual void CreatePresents()
|
|
72
|
+
{
|
|
73
|
+
var textures = Selection.GetFiltered(typeof(Texture2D), SelectionMode.Assets).Cast<Texture2D>();
|
|
74
|
+
|
|
75
|
+
int id = startID;
|
|
76
|
+
|
|
77
|
+
foreach (var texture in textures)
|
|
78
|
+
{
|
|
79
|
+
string path = AssetDatabase.GetAssetPath(texture);
|
|
80
|
+
|
|
81
|
+
Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
|
82
|
+
|
|
83
|
+
path = path[..path.LastIndexOf(".")] + ".asset";
|
|
84
|
+
|
|
85
|
+
if (PresentAlreadyExists(path))
|
|
86
|
+
continue;
|
|
87
|
+
|
|
88
|
+
CreatePresent(path, id, sprite);
|
|
89
|
+
|
|
90
|
+
id += 1;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/// <summary>
|
|
95
|
+
///
|
|
96
|
+
/// </summary>
|
|
97
|
+
/// <param name="path"></param>
|
|
98
|
+
/// <returns></returns>
|
|
99
|
+
protected virtual bool PresentAlreadyExists(string path)
|
|
100
|
+
{
|
|
101
|
+
bool result = AssetDatabase.LoadAssetAtPath(path, typeof(Present)) != null;
|
|
102
|
+
|
|
103
|
+
if (result)
|
|
104
|
+
UnityEngine.Debug.LogWarning("ALERT: Can't create present, it already exists: " + path);
|
|
105
|
+
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// <summary>
|
|
110
|
+
///
|
|
111
|
+
/// </summary>
|
|
112
|
+
/// <param name="path"></param>
|
|
113
|
+
/// <param name="id"></param>
|
|
114
|
+
/// <param name="image"></param>
|
|
115
|
+
protected virtual void CreatePresent(string path, int id, Sprite image)
|
|
116
|
+
{
|
|
117
|
+
List<Character> characters = database.GetFTECharacterList();
|
|
118
|
+
|
|
119
|
+
var present = CreateInstance<Present>();
|
|
120
|
+
|
|
121
|
+
present.DisplayName = image.name;
|
|
122
|
+
|
|
123
|
+
present.ID = EvaluatePresentID(image, id);
|
|
124
|
+
|
|
125
|
+
present.Image = image;
|
|
126
|
+
|
|
127
|
+
StudentReactionCollection collection = new();
|
|
128
|
+
|
|
129
|
+
foreach (Character character in characters)
|
|
130
|
+
{
|
|
131
|
+
StudentReaction reaction = new()
|
|
132
|
+
{
|
|
133
|
+
Character = character
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
collection.studentReactions.Add(reaction);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
present.attributes.Add(collection);
|
|
140
|
+
|
|
141
|
+
AssetDatabase.CreateAsset(present, path);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/// <summary>
|
|
145
|
+
///
|
|
146
|
+
/// </summary>
|
|
147
|
+
/// <param name="sprite"></param>
|
|
148
|
+
/// <param name="id"></param>
|
|
149
|
+
/// <returns></returns>
|
|
150
|
+
protected virtual int EvaluatePresentID(Sprite sprite, int id)
|
|
151
|
+
=> IDWillBeInSpriteName() ? Int32.Parse(Regex.Match(sprite.name, matchSpriteID).Value) : id;
|
|
152
|
+
|
|
153
|
+
/// <summary>
|
|
154
|
+
///
|
|
155
|
+
/// </summary>
|
|
156
|
+
/// <returns></returns>
|
|
157
|
+
protected virtual bool IDWillBeInSpriteName() => spriteHasIDNum;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
#endif
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "DREditor.Presents.Editor",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"DREditor",
|
|
6
|
+
"DREditor.Editor",
|
|
7
|
+
"DREditor.Presents"
|
|
8
|
+
],
|
|
9
|
+
"includePlatforms": [],
|
|
10
|
+
"excludePlatforms": [],
|
|
11
|
+
"allowUnsafeCode": false,
|
|
12
|
+
"overrideReferences": false,
|
|
13
|
+
"precompiledReferences": [],
|
|
14
|
+
"autoReferenced": true,
|
|
15
|
+
"defineConstraints": [],
|
|
16
|
+
"versionDefines": [],
|
|
17
|
+
"noEngineReferences": false
|
|
18
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.Linq;
|
|
6
|
+
using System.Text.RegularExpressions;
|
|
7
|
+
using UnityEditor;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
namespace DREditor.Presents.Editor
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
[Serializable]
|
|
16
|
+
public class DescriptionsByIDOption : PresentGoogleSheetsImportOption
|
|
17
|
+
{
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
[Header("")]
|
|
22
|
+
[Divider]
|
|
23
|
+
[Header("")]
|
|
24
|
+
[ReadOnly]
|
|
25
|
+
[Tooltip("")]
|
|
26
|
+
[SerializeField] protected string googleSheetsRegex = "\\t(.+)";
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
protected Dictionary<int, string> entries;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/// <inheritdoc/>
|
|
36
|
+
public override void Invoke()
|
|
37
|
+
{
|
|
38
|
+
List<int> ids = CollectIDs(GetMatches());
|
|
39
|
+
|
|
40
|
+
List<string> words = GetListOfNamesGoogleSheetFormat(googleSheetsRegex);
|
|
41
|
+
|
|
42
|
+
if (HasInvalidPairCount(ids.Count != words.Count))
|
|
43
|
+
return;
|
|
44
|
+
|
|
45
|
+
CreatePairing(ids, words, out entries);
|
|
46
|
+
|
|
47
|
+
AssetDatabase.StartAssetEditing();
|
|
48
|
+
|
|
49
|
+
ImportDescriptions();
|
|
50
|
+
|
|
51
|
+
AssetDatabase.StopAssetEditing();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// <summary>
|
|
55
|
+
///
|
|
56
|
+
/// </summary>
|
|
57
|
+
/// <returns></returns>
|
|
58
|
+
protected virtual string[] GetMatches()
|
|
59
|
+
{
|
|
60
|
+
var matched = Regex.Matches(textArea, "\\d+\\t");
|
|
61
|
+
|
|
62
|
+
return matched.Select(m => m.Value).ToArray();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// <summary>
|
|
66
|
+
///
|
|
67
|
+
/// </summary>
|
|
68
|
+
/// <param name="condition"></param>
|
|
69
|
+
/// <returns></returns>
|
|
70
|
+
protected virtual bool HasInvalidPairCount(bool condition)
|
|
71
|
+
{
|
|
72
|
+
if (condition)
|
|
73
|
+
{
|
|
74
|
+
EditorUtility.DisplayDialog("Sheet Format Incorrect: Inconsistent " +
|
|
75
|
+
"ID's and Name count", "Please Copy each column on your google sheets with the ID and Name to" +
|
|
76
|
+
" use this functionality!", "OK");
|
|
77
|
+
|
|
78
|
+
Close();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return condition;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
///
|
|
86
|
+
/// </summary>
|
|
87
|
+
protected virtual void ImportDescriptions()
|
|
88
|
+
{
|
|
89
|
+
foreach (Present present in presentDatabase.presents)
|
|
90
|
+
{
|
|
91
|
+
if (entries.ContainsKey(present.ID))
|
|
92
|
+
{
|
|
93
|
+
if (entries[present.ID] == present.DisplayName)
|
|
94
|
+
continue;
|
|
95
|
+
|
|
96
|
+
present.Description = entries[present.ID];
|
|
97
|
+
|
|
98
|
+
EditorUtility.SetDirty(present);
|
|
99
|
+
}
|
|
100
|
+
else
|
|
101
|
+
UnityEngine.Debug.Log("Couldn't find import data to match with ID: " + present.ID);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
#endif
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// Original Author: KHeartz
|
|
2
|
+
// Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
3
|
+
#if UNITY_EDITOR
|
|
4
|
+
using DREditor.Editor.Utility;
|
|
5
|
+
using System;
|
|
6
|
+
using System.Text.RegularExpressions;
|
|
7
|
+
using UnityEditor;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
namespace DREditor.Presents.Editor
|
|
11
|
+
{
|
|
12
|
+
[CustomEditor(typeof(PresentDatabase))]
|
|
13
|
+
public class PresentDatabaseEditor : UnityEditor.Editor
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
protected PresentDatabase database;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
protected virtual void OnEnable() => database = target as PresentDatabase;
|
|
22
|
+
|
|
23
|
+
/// <inheritdoc/>
|
|
24
|
+
public override void OnInspectorGUI()
|
|
25
|
+
{
|
|
26
|
+
CreateForm();
|
|
27
|
+
|
|
28
|
+
EditorUtility.SetDirty(database);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
protected virtual void CreateForm()
|
|
35
|
+
{
|
|
36
|
+
DisplayHeader();
|
|
37
|
+
|
|
38
|
+
RestorePresentIDsFromImageButton();
|
|
39
|
+
|
|
40
|
+
if (ImportPresents())
|
|
41
|
+
return;
|
|
42
|
+
|
|
43
|
+
ClearPresentsButton();
|
|
44
|
+
|
|
45
|
+
if (AddNewPresent())
|
|
46
|
+
return;
|
|
47
|
+
|
|
48
|
+
DisplayPresentPreviews();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
protected virtual void DisplayHeader()
|
|
55
|
+
{
|
|
56
|
+
HandyFields.Label("Present Database");
|
|
57
|
+
|
|
58
|
+
if (database != null && database.presents != null)
|
|
59
|
+
HandyFields.Label("Present Count: " + database.presents.Count);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
///
|
|
64
|
+
/// </summary>
|
|
65
|
+
/// <returns></returns>
|
|
66
|
+
protected virtual bool ImportPresents()
|
|
67
|
+
{
|
|
68
|
+
bool result = HandyFields.Button("Import Presents", "Adds all currently selected Present assets in the project to the database.");
|
|
69
|
+
|
|
70
|
+
if (result)
|
|
71
|
+
foreach (var present in Selection.objects)
|
|
72
|
+
database.presents.Add((Present)present);
|
|
73
|
+
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// <summary>
|
|
78
|
+
///
|
|
79
|
+
/// </summary>
|
|
80
|
+
protected virtual void ClearPresentsButton()
|
|
81
|
+
{
|
|
82
|
+
if (HandyFields.Button("Clear Presents") &&
|
|
83
|
+
EditorUtility.DisplayDialog("Clear Presents", "Are you sure you want to clear presents?", "Yes", "No"))
|
|
84
|
+
database.presents.Clear();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// <summary>
|
|
88
|
+
///
|
|
89
|
+
/// </summary>
|
|
90
|
+
/// <returns></returns>
|
|
91
|
+
protected virtual bool AddNewPresent()
|
|
92
|
+
{
|
|
93
|
+
if (HandyFields.Button("Add New Present"))
|
|
94
|
+
database.presents.Add(CreateInstance<Present>());
|
|
95
|
+
|
|
96
|
+
return database.presents == null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/// <summary>
|
|
100
|
+
///
|
|
101
|
+
/// </summary>
|
|
102
|
+
protected virtual void DisplayPresentPreviews()
|
|
103
|
+
{
|
|
104
|
+
if (database != null && database.presents != null)
|
|
105
|
+
for (int i = 0; i < database.presents.Count; i++)
|
|
106
|
+
using (new GUILayout.HorizontalScope("Box"))
|
|
107
|
+
DisplayPresentPreview(i);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/// <summary>
|
|
111
|
+
///
|
|
112
|
+
/// </summary>
|
|
113
|
+
/// <param name="i"></param>
|
|
114
|
+
protected virtual void DisplayPresentPreview(int i)
|
|
115
|
+
{
|
|
116
|
+
ShowPresentImage(database.presents[i]);
|
|
117
|
+
|
|
118
|
+
SelectPresent(database.presents[i], i);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/// <summary>
|
|
122
|
+
///
|
|
123
|
+
/// </summary>
|
|
124
|
+
/// <param name="present"></param>
|
|
125
|
+
protected virtual void ShowPresentImage(Present present)
|
|
126
|
+
{
|
|
127
|
+
using (new EditorGUILayout.VerticalScope())
|
|
128
|
+
GUILayout.Label(AssetPreview.GetAssetPreview(present.Image));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// <summary>
|
|
132
|
+
///
|
|
133
|
+
/// </summary>
|
|
134
|
+
/// <param name="present"></param>
|
|
135
|
+
/// <param name="index"></param>
|
|
136
|
+
protected virtual void SelectPresent(Present present, int index)
|
|
137
|
+
{
|
|
138
|
+
GUILayout.FlexibleSpace();
|
|
139
|
+
|
|
140
|
+
database.presents[index] = HandyFields.UnityField(present, 200, 40);
|
|
141
|
+
|
|
142
|
+
RemovePresentButton(index);
|
|
143
|
+
|
|
144
|
+
GUILayout.FlexibleSpace();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/// <summary>
|
|
148
|
+
///
|
|
149
|
+
/// </summary>
|
|
150
|
+
/// <param name="index"></param>
|
|
151
|
+
protected virtual void RemovePresentButton(int index)
|
|
152
|
+
{
|
|
153
|
+
if (HandyFields.Button("X"))
|
|
154
|
+
database.presents.RemoveAt(index);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/// <summary>
|
|
158
|
+
///
|
|
159
|
+
/// </summary>
|
|
160
|
+
protected virtual void RestorePresentIDsFromImageButton()
|
|
161
|
+
{
|
|
162
|
+
if (HandyFields.Button("Restore Present IDs from their image"))
|
|
163
|
+
RestorePresentIDsFromImage();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/// <summary>
|
|
167
|
+
///
|
|
168
|
+
/// </summary>
|
|
169
|
+
protected virtual void RestorePresentIDsFromImage()
|
|
170
|
+
{
|
|
171
|
+
foreach (Present present in database.presents)
|
|
172
|
+
{
|
|
173
|
+
if (present.Image != null)
|
|
174
|
+
{
|
|
175
|
+
present.ID = Int32.Parse(Regex.Match(present.Image.name, @"\d+").Value);
|
|
176
|
+
|
|
177
|
+
EditorUtility.SetDirty(present);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#endif
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Original Author: KHeartz
|
|
2
|
+
// Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
3
|
+
#if UNITY_EDITOR
|
|
4
|
+
using DREditor.Editor.Toolbox;
|
|
5
|
+
using DREditor.Editor.Utility;
|
|
6
|
+
using System.Collections.Generic;
|
|
7
|
+
using System.Linq;
|
|
8
|
+
using UnityEditor;
|
|
9
|
+
|
|
10
|
+
namespace DREditor.Presents.Editor
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
[CustomEditor(typeof(Present))]
|
|
16
|
+
public class PresentEditor : InventoryItemEditor, INestedEditorCacheable
|
|
17
|
+
{
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
protected Present present;
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
protected SerializedProperty propID;
|
|
27
|
+
|
|
28
|
+
/// <summary>
|
|
29
|
+
///
|
|
30
|
+
/// </summary>
|
|
31
|
+
protected Dictionary<object, bool> visibilityCaches = new();
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
///
|
|
35
|
+
/// </summary>
|
|
36
|
+
protected Dictionary<object, int> indexCaches = new();
|
|
37
|
+
|
|
38
|
+
/// <summary>
|
|
39
|
+
///
|
|
40
|
+
/// </summary>
|
|
41
|
+
protected List<object> dataCaches = new();
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
///
|
|
45
|
+
/// </summary>
|
|
46
|
+
protected bool showUI = false;
|
|
47
|
+
|
|
48
|
+
/// <summary>
|
|
49
|
+
///
|
|
50
|
+
/// </summary>
|
|
51
|
+
protected InterfaceEditor<IPresentData> presentDataEditor;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/// <summary>
|
|
55
|
+
///
|
|
56
|
+
/// </summary>
|
|
57
|
+
private readonly string AttributesFieldName = "attributes";
|
|
58
|
+
|
|
59
|
+
/// <summary>
|
|
60
|
+
///
|
|
61
|
+
/// </summary>
|
|
62
|
+
protected readonly string IDPropertyString = "id";
|
|
63
|
+
|
|
64
|
+
/// <summary>
|
|
65
|
+
///
|
|
66
|
+
/// </summary>
|
|
67
|
+
protected readonly string IDLabel = "ID No. ";
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
public Dictionary<object, bool> VisibilityCaches => visibilityCaches;
|
|
71
|
+
|
|
72
|
+
public Dictionary<object, int> IndexCaches => indexCaches;
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
/// <inheritdoc/>
|
|
76
|
+
protected override void OnEnable()
|
|
77
|
+
{
|
|
78
|
+
present = target as Present;
|
|
79
|
+
|
|
80
|
+
base.OnEnable();
|
|
81
|
+
|
|
82
|
+
presentDataEditor = new(this, present.attributes, true);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/// <inheritdoc/>
|
|
86
|
+
protected override void InitializeSerializedProperties()
|
|
87
|
+
{
|
|
88
|
+
base.InitializeSerializedProperties();
|
|
89
|
+
|
|
90
|
+
propID = serializedObject.FindProperty(IDPropertyString);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// <inheritdoc/>
|
|
94
|
+
public override void OnInspectorGUI()
|
|
95
|
+
{
|
|
96
|
+
serializedObject.Update();
|
|
97
|
+
|
|
98
|
+
HandyFields.Label(nameof(Present));
|
|
99
|
+
|
|
100
|
+
DisplayItemData();
|
|
101
|
+
|
|
102
|
+
EditorUtility.SetDirty(present);
|
|
103
|
+
|
|
104
|
+
serializedObject.ApplyModifiedProperties();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/// <inheritdoc/>
|
|
108
|
+
protected override void DisplayItemData()
|
|
109
|
+
{
|
|
110
|
+
base.DisplayItemData();
|
|
111
|
+
|
|
112
|
+
DisplayAttributes();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/// <summary>
|
|
116
|
+
///
|
|
117
|
+
/// </summary>
|
|
118
|
+
protected virtual void DisplayAttributes()
|
|
119
|
+
{
|
|
120
|
+
var presentDataProperty = serializedObject.FindProperty(AttributesFieldName);
|
|
121
|
+
|
|
122
|
+
presentDataEditor.DisplayInterfaceInstances(presentDataProperty, this, presentDataProperty, presentDataEditor);
|
|
123
|
+
|
|
124
|
+
showUI = presentDataEditor.showDiaEvents;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// <inheritdoc/>
|
|
128
|
+
protected override void DisplayName()
|
|
129
|
+
{
|
|
130
|
+
base.DisplayName();
|
|
131
|
+
|
|
132
|
+
DisplayID();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// <summary>
|
|
136
|
+
///
|
|
137
|
+
/// </summary>
|
|
138
|
+
protected virtual void DisplayID() => HandyFields.HardPropertyField(IDLabel, propID);
|
|
139
|
+
|
|
140
|
+
/// <inheritdoc/>
|
|
141
|
+
public virtual void AddData(object obj) => dataCaches.Add(obj);
|
|
142
|
+
|
|
143
|
+
/// <inheritdoc/>
|
|
144
|
+
public virtual bool TryGetData<T>(out T data)
|
|
145
|
+
{
|
|
146
|
+
data = dataCaches.OfType<T>().FirstOrDefault();
|
|
147
|
+
|
|
148
|
+
return data != null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
#endif
|