net.dreditor.backlog 0.0.0-stage → 0.1.6

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.
@@ -0,0 +1,53 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues;
3
+ using DREditor.Saving;
4
+ using System.Collections.Generic;
5
+ using UnityEngine;
6
+
7
+ namespace DREditor.Backlogging
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ [ClassHeader("")]
13
+ public class BacklogHandler : BacklogHandlerBase, IDRESaveable, IDRELoadable
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ [Tooltip("")]
19
+ [SerializeField] protected Backlog backlog = null;
20
+
21
+ /// <summary>
22
+ ///
23
+ /// </summary>
24
+ [Tooltip("")]
25
+ [SerializeField] protected string dataSaveKey = "BackData";
26
+
27
+
28
+ /// <inheritdoc/>
29
+ public override object[] GetBacklogLines() => backlog.GetLinesArray();
30
+
31
+ /// <inheritdoc/>
32
+ public override void ClearLines() => backlog.Lines.Clear();
33
+
34
+ /// <inheritdoc/>
35
+ public override void AddLine(object o = null)
36
+ {
37
+ if (o != null && o is BacklogLines line)
38
+ backlog.AddLine(line.Charfile, line.Text, line.AliasNum, line.Color, line.Voice);
39
+ }
40
+
41
+ /// <inheritdoc/>
42
+ public override object SaveBacklog() => backlog.Save();
43
+
44
+ /// <inheritdoc/>
45
+ public override void LoadBacklog(object o = null) => backlog.Load((BacklogData)o);
46
+
47
+ /// <inheritdoc/>
48
+ public virtual void Save(Dictionary<string, object> saveData) => saveData.Set(dataSaveKey, (BacklogData)SaveBacklog());
49
+
50
+ /// <inheritdoc/>
51
+ public virtual void Load(Dictionary<string, object> saveDatas) => LoadBacklog(saveDatas.Get<BacklogData>(dataSaveKey));
52
+ }
53
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4a27659b646b46a4eae71455b1dbc54c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,93 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.EventObjects;
3
+ using DREditor.Services;
4
+ using UnityEngine;
5
+
6
+ namespace DREditor.Backlogging
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ public abstract class BacklogHandlerBase : MonoBehaviour, ISceneEventListener
12
+ {
13
+ /// <summary>
14
+ ///
15
+ /// </summary>
16
+ [Header("")]
17
+ [Divider]
18
+ [Tooltip("")]
19
+ [SerializeField] protected SceneEvent startedNewGame = null;
20
+
21
+
22
+ /// <summary>
23
+ ///
24
+ /// </summary>
25
+ protected virtual void OnEnable()
26
+ {
27
+ RegisterThisService();
28
+
29
+ startedNewGame.RegisterListener(this);
30
+ }
31
+
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ protected virtual void OnDisable()
36
+ {
37
+ UnregisterThisService();
38
+
39
+ startedNewGame.UnregisterListener(this);
40
+ }
41
+
42
+ /// <summary>
43
+ ///
44
+ /// </summary>
45
+ protected virtual void RegisterThisService()
46
+ {
47
+ if (!ServiceLocator.HasService<BacklogHandlerBase>())
48
+ ServiceLocator.Register(this);
49
+ }
50
+
51
+ /// <summary>
52
+ ///
53
+ /// </summary>
54
+ protected virtual void UnregisterThisService()
55
+ {
56
+ if (ServiceLocator.GetService<BacklogHandlerBase>() == this)
57
+ ServiceLocator.Unregister(this);
58
+ }
59
+
60
+ /// <summary>
61
+ ///
62
+ /// </summary>
63
+ /// <returns></returns>
64
+ public abstract object[] GetBacklogLines();
65
+
66
+ /// <summary>
67
+ ///
68
+ /// </summary>
69
+ public abstract void ClearLines();
70
+
71
+ /// <summary>
72
+ ///
73
+ /// </summary>
74
+ /// <param name="o"></param>
75
+ public abstract void AddLine(object o = null);
76
+
77
+ /// <summary>
78
+ ///
79
+ /// </summary>
80
+ /// <returns></returns>
81
+ public abstract object SaveBacklog();
82
+
83
+ /// <summary>
84
+ ///
85
+ /// </summary>
86
+ /// <param name="o"></param>
87
+ public abstract void LoadBacklog(object o = null);
88
+
89
+
90
+ /// <inheritdoc/>
91
+ public virtual void OnEventRaised() => ClearLines();
92
+ }
93
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 71438e3b7ae94a642ade28b22d295334
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,47 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues;
3
+ using DREditor.Dialogues.LineReading;
4
+ using DREditor.Services;
5
+ using DREditor.TextDisplaying;
6
+
7
+ namespace DREditor.Backlogging
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ [ClassHeader(nameof(ILineEndProcess) +
13
+ "\n\n")]
14
+ public class BacklogLineHandler : DialogueComponent, ILineEndProcess
15
+ {
16
+ /// <inheritdoc/>
17
+ public virtual void LineEndProcess(Line currentLine) => AddLineToBacklog(currentLine);
18
+
19
+ /// <summary>
20
+ ///
21
+ /// </summary>
22
+ /// <param name="currentLine"></param>
23
+ protected virtual void AddLineToBacklog(Line currentLine)
24
+ {
25
+ if (currentLine.Speaker != null)
26
+ ServiceLocator.GetService<BacklogHandlerBase>().AddLine(CreateBacklogLine(currentLine));
27
+ }
28
+
29
+ /// <summary>
30
+ ///
31
+ /// </summary>
32
+ /// <param name="currentLine"></param>
33
+ /// <returns></returns>
34
+ protected virtual BacklogLines CreateBacklogLine(Line currentLine) =>
35
+ new(
36
+ currentLine.Speaker,
37
+ ServiceLocator.GetService<ITextDisplayerHandler>().GetTextBox().text,
38
+ currentLine.AliasNumber - 1,
39
+ #if FMOD_UNITY
40
+ currentLine.VoiceSFX,
41
+ #else
42
+ currentLine.VoiceSFX.name,
43
+ #endif
44
+ ServiceLocator.GetService<ITextDisplayerHandler>().GetTextBox().color
45
+ );
46
+ }
47
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c9d18d42d87b29145bd97a1f8b3b1735
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/BacklogSlot.cs ADDED
@@ -0,0 +1,252 @@
1
+ // Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ // Original Author: LeotheDev
3
+ using DREditor.Characters;
4
+ using DREditor.Dialogues;
5
+ using DREditor.UI;
6
+ using System.Linq;
7
+ using TMPro;
8
+ using UnityEngine;
9
+ using UnityEngine.UI;
10
+
11
+ namespace DREditor.Backlogging
12
+ {
13
+ /// <summary>
14
+ ///
15
+ /// </summary>
16
+ [ClassHeader("")]
17
+ public class BacklogSlot : MonoBehaviour, IGridIconSlot
18
+ {
19
+ /// <summary>
20
+ ///
21
+ /// </summary>
22
+ [Header("")]
23
+ [Divider]
24
+ [Tooltip("")]
25
+ [SerializeField] protected CharacterDatabase characterDatabase = null;
26
+
27
+ /// <summary>
28
+ ///
29
+ /// </summary>
30
+ [Tooltip("")]
31
+ [SerializeField] protected Backlog backlog = null;
32
+
33
+ /// <summary>
34
+ ///
35
+ /// </summary>
36
+ [Tooltip("")]
37
+ [SerializeField] protected string headmasterFirstName = "Tozu";
38
+
39
+ /// <summary>
40
+ ///
41
+ /// </summary>
42
+ [Tooltip("")]
43
+ [SerializeField] private BacklogMugBind[] Mugshots;
44
+
45
+
46
+ /// <summary>
47
+ ///
48
+ /// </summary>
49
+ [Header("")]
50
+ [Divider]
51
+ [Tooltip("")]
52
+ [SerializeField] protected GameObject voiceIcon = null;
53
+
54
+ /// <summary>
55
+ ///
56
+ /// </summary>
57
+ [Tooltip("")]
58
+ [SerializeField] protected Image overlayImage = null;
59
+
60
+ /// <summary>
61
+ ///
62
+ /// </summary>
63
+ [Tooltip("")]
64
+ [SerializeField] protected Sprite overlayOn;
65
+
66
+ /// <summary>
67
+ ///
68
+ /// </summary>
69
+ [Tooltip("")]
70
+ [SerializeField] protected Sprite overlayOff;
71
+
72
+ /// <summary>
73
+ ///
74
+ /// </summary>
75
+ [Tooltip("")]
76
+ [SerializeField] protected TextMeshProUGUI backlogText = null;
77
+
78
+ /// <summary>
79
+ ///
80
+ /// </summary>
81
+ [Tooltip("")]
82
+ [SerializeField] protected Image mugshotImage = null;
83
+
84
+ /// <summary>
85
+ ///
86
+ /// </summary>
87
+ [Tooltip("")]
88
+ [SerializeField] protected RawImage nameplate = null;
89
+
90
+
91
+ /// <inheritdoc/>
92
+ public virtual void ClearSlotState() => DisplayEmptyBacklogEntry();
93
+
94
+ /// <summary>
95
+ ///
96
+ /// </summary>
97
+ protected virtual void DisplayEmptyBacklogEntry()
98
+ {
99
+ mugshotImage.gameObject.SetActive(false);
100
+
101
+ overlayImage.sprite = overlayOff;
102
+
103
+ nameplate.gameObject.SetActive(false);
104
+
105
+ voiceIcon.SetActive(false);
106
+
107
+ backlogText.text = string.Empty;
108
+ }
109
+
110
+
111
+ /// <inheritdoc/>
112
+ public virtual void UpdateSlot(int globalIndex, bool selected)
113
+ => UpdateBacklogSlot(backlog.Lines.ToArray().Reverse().ToArray()[globalIndex], selected);
114
+
115
+ /// <summary>
116
+ ///
117
+ /// </summary>
118
+ /// <param name="entry"></param>
119
+ /// <param name="localSelected"></param>
120
+ protected virtual void UpdateBacklogSlot(BacklogLines entry, bool localSelected)
121
+ {
122
+ Character character = characterDatabase.GetCharacter(entry.CharFirstName);
123
+
124
+ if (character == null)
125
+ return;
126
+
127
+ EvaluateMugshot(character, localSelected, entry.AliasNum);
128
+
129
+ nameplate.gameObject.SetActive(true);
130
+
131
+ nameplate.texture = entry.AliasNum != -1
132
+ ? characterDatabase.GetCharacter(entry.CharFirstName).Aliases[entry.AliasNum].Nameplate
133
+ : characterDatabase.GetCharacter(entry.CharFirstName).Nameplate;
134
+
135
+ overlayImage.sprite = localSelected ? overlayOn : overlayOff;
136
+
137
+ backlogText.text = entry.Text;
138
+
139
+ backlogText.color = entry.Color;
140
+
141
+ voiceIcon.SetActive(!string.IsNullOrEmpty(entry.Voice));
142
+ }
143
+
144
+ /// <summary>
145
+ ///
146
+ /// </summary>
147
+ /// <param name="character"></param>
148
+ /// <param name="localSelected"></param>
149
+ /// <param name="entryAliasNum"></param>
150
+ protected virtual void EvaluateMugshot(Character character, bool localSelected, int entryAliasNum)
151
+ {
152
+ if (MugshotValid())
153
+ PopulateMugshot(character, localSelected, entryAliasNum);
154
+ }
155
+
156
+ /// <summary>
157
+ ///
158
+ /// </summary>
159
+ /// <returns></returns>
160
+ protected virtual bool MugshotValid() => Mugshots != null && Mugshots.Length != 0;
161
+
162
+ /// <summary>
163
+ ///
164
+ /// </summary>
165
+ /// <param name="character"></param>
166
+ /// <param name="localSelected"></param>
167
+ /// <param name="entryAliasNum"></param>
168
+ protected virtual void PopulateMugshot(Character character, bool localSelected, int entryAliasNum)
169
+ {
170
+ BacklogMugBind mug = Mugshots.First(f => f != null && f.charaName == character.FirstName);
171
+
172
+ if (mug != null && mug.Mug_ON != null && mug.Mug_OFF != null)
173
+ {
174
+ mugshotImage.gameObject.SetActive(true);
175
+
176
+ mugshotImage.sprite = localSelected ? mug.Mug_ON : mug.Mug_OFF;
177
+
178
+ mugshotImage.transform.SetSiblingIndex(localSelected ? mugshotImage.transform.parent.childCount : 0);
179
+ }
180
+
181
+ if (mug == null || (character.FirstName == headmasterFirstName && entryAliasNum == 0))
182
+ mugshotImage.gameObject.SetActive(false);
183
+ }
184
+
185
+ #if UNITY_EDITOR
186
+ /// <summary>
187
+ ///
188
+ /// </summary>
189
+ [ContextMenu("Generate Mugshot List")]
190
+ public void GenerateMugshotList()
191
+ {
192
+ if (characterDatabase != null)
193
+ {
194
+ Mugshots = new BacklogMugBind[characterDatabase.Characters.Count];
195
+
196
+ for (int i = 0; i < characterDatabase.Characters.Count; i++)
197
+ Mugshots[i] = new(characterDatabase.Characters[i].FirstName, UnityEditor.Selection.objects);
198
+ }
199
+ else
200
+ UnityEngine.Debug.LogWarning("ALERT: Must have Character Database assigned.");
201
+ }
202
+ #endif
203
+
204
+ /// <summary>
205
+ ///
206
+ /// </summary>
207
+ [System.Serializable]
208
+ sealed class BacklogMugBind
209
+ {
210
+ /// <summary>
211
+ ///
212
+ /// </summary>
213
+ [Tooltip("")]
214
+ [SerializeField] internal string charaName;
215
+
216
+ /// <summary>
217
+ ///
218
+ /// </summary>
219
+ [Tooltip("")]
220
+ [SerializeField] internal Sprite Mug_ON;
221
+
222
+ /// <summary>
223
+ ///
224
+ /// </summary>
225
+ [Tooltip("")]
226
+ [SerializeField] internal Sprite Mug_OFF;
227
+
228
+ /// <summary>
229
+ ///
230
+ /// </summary>
231
+ /// <param name="charaName"></param>
232
+ /// <param name="objects"></param>
233
+ internal BacklogMugBind(string charaName, Object[] objects)
234
+ {
235
+ this.charaName = charaName;
236
+
237
+ UnityEngine.Debug.Log(nameof(BacklogMugBind) + ": Note when importing. " +
238
+ "Ensure you select all the headshot images of all characters so that they can be assigned.");
239
+
240
+ UnityEngine.Debug.Log(nameof(BacklogMugBind) + ": Note when importing. Ensure that the names of the mug shot sprites " +
241
+ "contain the characters name, and the words \"Selected\" or \"Unselected\" for proper importing.");
242
+
243
+ foreach (var sprite in objects)
244
+ if (sprite.name.Contains(charaName))
245
+ if (sprite.name.Contains("Unselected"))
246
+ Mug_OFF = (Sprite)sprite;
247
+ else
248
+ Mug_ON = (Sprite)sprite;
249
+ }
250
+ }
251
+ }
252
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 8acb6b541e1be7243af2af6b5b232703
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: