net.dreditor.ui.savingloading 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.UI.SavingLoading.asmdef +23 -0
- package/DREditor.UI.SavingLoading.asmdef.meta +7 -0
- package/PostSavePoint.cs +58 -0
- package/PostSavePoint.cs.meta +11 -0
- package/ReturnToMenuOnPauseMenu.cs +114 -0
- package/ReturnToMenuOnPauseMenu.cs.meta +11 -0
- package/Samples~/DRE_SavePoint.unity +262 -0
- package/Samples~/DRE_SavePoint.unity.meta +7 -0
- package/Samples~/Save_Point_Canvas_Shell.prefab +169 -0
- package/Samples~/Save_Point_Canvas_Shell.prefab.meta +7 -0
- package/Samples~/Save_Point_Canvas_Template.prefab +563 -0
- package/Samples~/Save_Point_Canvas_Template.prefab.meta +7 -0
- package/Samples~/Save_Point_System_Template.prefab +1434 -0
- package/Samples~/Save_Point_System_Template.prefab.meta +7 -0
- package/SaveDataDisplayerBase.cs +25 -0
- package/SaveDataDisplayerBase.cs.meta +11 -0
- package/SaveDateDisplayer.cs +147 -0
- package/SaveDateDisplayer.cs.meta +11 -0
- package/SaveLoadMenu.cs +299 -0
- package/SaveLoadMenu.cs.meta +11 -0
- package/SaveLoadMenuBase.cs +123 -0
- package/SaveLoadMenuBase.cs.meta +11 -0
- package/SavePointUI.cs +240 -0
- package/SavePointUI.cs.meta +11 -0
- package/SavePointUIBase.cs +135 -0
- package/SavePointUIBase.cs.meta +11 -0
- package/SavePointUIGameState.cs +121 -0
- package/SavePointUIGameState.cs.meta +11 -0
- package/SaveSlot.cs +82 -0
- package/SaveSlot.cs.meta +11 -0
- package/SaveSlotBase.cs +100 -0
- package/SaveSlotBase.cs.meta +11 -0
- package/SaveTitleDisplayer.cs +205 -0
- package/SaveTitleDisplayer.cs.meta +11 -0
- package/package.json +44 -4
- package/package.json.meta +7 -0
- package/README.md +0 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.UI.SavingLoading
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
public abstract class SaveDataDisplayerBase : MonoBehaviour
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
/// <param name="saveDatas"></param>
|
|
16
|
+
/// <param name="id"></param>
|
|
17
|
+
public abstract void Display(Dictionary<string, object> saveDatas, int id);
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
/// <param name="id"></param>
|
|
23
|
+
public abstract void OnSaveNotFound(int id);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Saving;
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.Globalization;
|
|
6
|
+
using TMPro;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
|
|
9
|
+
namespace DREditor.UI.SavingLoading
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
///
|
|
13
|
+
/// </summary>
|
|
14
|
+
[ClassHeader(nameof(SaveDataDisplayerBase) +
|
|
15
|
+
"\n\n")]
|
|
16
|
+
public class SaveDateDisplayer : SaveDataDisplayerBase
|
|
17
|
+
{
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
[Tooltip("")]
|
|
22
|
+
[SerializeField] protected bool debugLogs = false;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
[Header("")]
|
|
29
|
+
[Divider]
|
|
30
|
+
[Tooltip("")]
|
|
31
|
+
[SerializeField] protected TextMeshProUGUI date = null;
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
///
|
|
35
|
+
/// </summary>
|
|
36
|
+
[Tooltip("")]
|
|
37
|
+
[SerializeField] protected TextMeshProUGUI timeOfSave = null;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
///
|
|
42
|
+
/// </summary>
|
|
43
|
+
[Header("")]
|
|
44
|
+
[Divider]
|
|
45
|
+
[Tooltip("")]
|
|
46
|
+
[SerializeField] protected string dateFormat = "MM/dd/yyyy";
|
|
47
|
+
|
|
48
|
+
/// <summary>
|
|
49
|
+
///
|
|
50
|
+
/// </summary>
|
|
51
|
+
[Tooltip("")]
|
|
52
|
+
[SerializeField] protected string timeFormat = "HH:mm:ss";
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
///
|
|
57
|
+
/// </summary>
|
|
58
|
+
protected Dictionary<string, object> saveDatas;
|
|
59
|
+
|
|
60
|
+
/// <summary>
|
|
61
|
+
///
|
|
62
|
+
/// </summary>
|
|
63
|
+
protected readonly string yearKey = "Year";
|
|
64
|
+
|
|
65
|
+
/// <summary>
|
|
66
|
+
///
|
|
67
|
+
/// </summary>
|
|
68
|
+
protected readonly string monthKey = "Month";
|
|
69
|
+
|
|
70
|
+
/// <summary>
|
|
71
|
+
///
|
|
72
|
+
/// </summary>
|
|
73
|
+
protected readonly string dayKey = "Day";
|
|
74
|
+
|
|
75
|
+
/// <summary>
|
|
76
|
+
///
|
|
77
|
+
/// </summary>
|
|
78
|
+
protected readonly string hourKey = "Hour";
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
protected readonly string minuteKey = "Minute";
|
|
84
|
+
|
|
85
|
+
/// <summary>
|
|
86
|
+
///
|
|
87
|
+
/// </summary>
|
|
88
|
+
protected readonly string secondKey = "Second";
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
/// <inheritdoc/>
|
|
92
|
+
public override void Display(Dictionary<string, object> saveDatas, int id)
|
|
93
|
+
{
|
|
94
|
+
this.saveDatas = saveDatas;
|
|
95
|
+
|
|
96
|
+
DateTime dateTime = GetSaveFileDateTime();
|
|
97
|
+
|
|
98
|
+
date.text = dateTime.ToString(dateFormat, CultureInfo.InvariantCulture);
|
|
99
|
+
|
|
100
|
+
timeOfSave.text = dateTime.ToString(timeFormat, CultureInfo.InvariantCulture);
|
|
101
|
+
|
|
102
|
+
this.saveDatas = null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// <summary>
|
|
106
|
+
///
|
|
107
|
+
/// </summary>
|
|
108
|
+
/// <returns></returns>
|
|
109
|
+
protected virtual DateTime GetSaveFileDateTime()
|
|
110
|
+
{
|
|
111
|
+
if (debugLogs)
|
|
112
|
+
LogDateTime();
|
|
113
|
+
|
|
114
|
+
return new DateTime(
|
|
115
|
+
saveDatas.Get<int>(yearKey),
|
|
116
|
+
saveDatas.Get<int>(monthKey),
|
|
117
|
+
saveDatas.Get<int>(dayKey),
|
|
118
|
+
saveDatas.Get<int>(hourKey),
|
|
119
|
+
saveDatas.Get<int>(minuteKey),
|
|
120
|
+
saveDatas.Get<int>(secondKey));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/// <summary>
|
|
124
|
+
///
|
|
125
|
+
/// </summary>
|
|
126
|
+
protected virtual void LogDateTime()
|
|
127
|
+
{
|
|
128
|
+
UnityEngine.Debug.Log(saveDatas.Values.Count);
|
|
129
|
+
|
|
130
|
+
UnityEngine.Debug.Log(
|
|
131
|
+
saveDatas.Get<int>(yearKey)
|
|
132
|
+
+ " " + saveDatas.Get<int>(monthKey)
|
|
133
|
+
+ " " + saveDatas.Get<int>(dayKey)
|
|
134
|
+
+ " " + saveDatas.Get<int>(hourKey)
|
|
135
|
+
+ " " + saveDatas.Get<int>(minuteKey)
|
|
136
|
+
+ " " + saveDatas.Get<int>(secondKey));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// <inheritdoc/>
|
|
140
|
+
public override void OnSaveNotFound(int id)
|
|
141
|
+
{
|
|
142
|
+
date.text = "";
|
|
143
|
+
|
|
144
|
+
timeOfSave.text = "";
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
package/SaveLoadMenu.cs
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Dialogues;
|
|
3
|
+
using DREditor.Dialogues.Events;
|
|
4
|
+
using DREditor.SaveManaging;
|
|
5
|
+
using DREditor.Services;
|
|
6
|
+
using System.Collections;
|
|
7
|
+
using System.Collections.Generic;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
using UnityEngine.Events;
|
|
10
|
+
using UnityEngine.EventSystems;
|
|
11
|
+
using UnityEngine.Serialization;
|
|
12
|
+
|
|
13
|
+
namespace DREditor.UI.SavingLoading
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
/// <remarks></remarks>
|
|
19
|
+
[DefaultExecutionOrder(1)]
|
|
20
|
+
[ClassHeader("")]
|
|
21
|
+
public class SaveLoadMenu : SaveLoadMenuBase
|
|
22
|
+
{
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[Divider]
|
|
27
|
+
[Tooltip("")]
|
|
28
|
+
[SerializeField] protected bool onPauseMenu = false;
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
///
|
|
32
|
+
/// </summary>
|
|
33
|
+
[Tooltip("")]
|
|
34
|
+
[FormerlySerializedAs("SlotList")]
|
|
35
|
+
[SerializeField] protected List<SaveSlotBase> saveSlots = new();
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
[Tooltip("")]
|
|
41
|
+
[SerializeField] protected SelectableMenuGroupBase saveLoadGroup = null;
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
///
|
|
45
|
+
/// </summary>
|
|
46
|
+
[Tooltip("")]
|
|
47
|
+
[SerializeField] protected MenuGroupBase savePopUp = null;
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
///
|
|
51
|
+
/// </summary>
|
|
52
|
+
[Tooltip("")]
|
|
53
|
+
[SerializeField] protected MenuGroupBase overwritePopUp = null;
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
///
|
|
57
|
+
/// </summary>
|
|
58
|
+
[Tooltip("")]
|
|
59
|
+
[SerializeField] protected MenuGroupBase loadPopUp = null;
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
///
|
|
63
|
+
/// </summary>
|
|
64
|
+
[Tooltip("")]
|
|
65
|
+
[SerializeField] protected ReturnToMenuOnPauseMenu ReturnToMenuPauseHandler = null;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
[Header("")]
|
|
69
|
+
[SerializeField] protected UnityEvent OnSelectedLockedSaveSlot;
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
///
|
|
74
|
+
/// </summary>
|
|
75
|
+
[Header("")]
|
|
76
|
+
[Divider]
|
|
77
|
+
[Tooltip("")]
|
|
78
|
+
[SerializeField] protected string loadGameFileEventString = "LoadGameFile";
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
[Tooltip("")]
|
|
84
|
+
[SerializeField] protected string applyDataEventString = "ApplyCurrentData";
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/// <summary>
|
|
88
|
+
///
|
|
89
|
+
/// </summary>
|
|
90
|
+
protected virtual void Start()
|
|
91
|
+
{
|
|
92
|
+
for (int i = 0; i < saveSlots.Count; i++)
|
|
93
|
+
saveSlots[i].SetID(i);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// <summary>
|
|
97
|
+
///
|
|
98
|
+
/// </summary>
|
|
99
|
+
protected virtual void OnEnable()
|
|
100
|
+
{
|
|
101
|
+
SetSubscriptionsToSaveSlots(true);
|
|
102
|
+
|
|
103
|
+
SetSubscriptionToPopUps(true);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// <summary>
|
|
107
|
+
///
|
|
108
|
+
/// </summary>
|
|
109
|
+
protected virtual void OnDisable()
|
|
110
|
+
{
|
|
111
|
+
SetSubscriptionsToSaveSlots(false);
|
|
112
|
+
|
|
113
|
+
SetSubscriptionToPopUps(false);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/// <summary>
|
|
117
|
+
///
|
|
118
|
+
/// </summary>
|
|
119
|
+
/// <param name="subscribing"></param>
|
|
120
|
+
protected virtual void SetSubscriptionsToSaveSlots(bool subscribing)
|
|
121
|
+
{
|
|
122
|
+
foreach (var slot in saveSlots)
|
|
123
|
+
{
|
|
124
|
+
if (subscribing)
|
|
125
|
+
{
|
|
126
|
+
slot.OnSlotClicked += SetCurrentSaveSlot;
|
|
127
|
+
|
|
128
|
+
slot.button.onClick.AddListener(EvaluatePopUp);
|
|
129
|
+
}
|
|
130
|
+
else
|
|
131
|
+
{
|
|
132
|
+
slot.OnSlotClicked -= SetCurrentSaveSlot;
|
|
133
|
+
|
|
134
|
+
slot.button.onClick.RemoveListener(EvaluatePopUp);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// <summary>
|
|
140
|
+
///
|
|
141
|
+
/// </summary>
|
|
142
|
+
/// <param name="subscribing"></param>
|
|
143
|
+
protected virtual void SetSubscriptionToPopUps(bool subscribing)
|
|
144
|
+
{
|
|
145
|
+
SelectSlotOnPopUpEnd(savePopUp, subscribing);
|
|
146
|
+
|
|
147
|
+
SelectSlotOnPopUpEnd(overwritePopUp, subscribing);
|
|
148
|
+
|
|
149
|
+
SelectSlotOnPopUpEnd(loadPopUp, subscribing);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/// <summary>
|
|
153
|
+
///
|
|
154
|
+
/// </summary>
|
|
155
|
+
/// <param name="popUp"></param>
|
|
156
|
+
/// <param name="subscribing"></param>
|
|
157
|
+
protected virtual void SelectSlotOnPopUpEnd(MenuGroupBase popUp, bool subscribing)
|
|
158
|
+
{
|
|
159
|
+
if (popUp == null)
|
|
160
|
+
return;
|
|
161
|
+
|
|
162
|
+
if (subscribing)
|
|
163
|
+
popUp.EndEvents.AddListener(SelectSlot);
|
|
164
|
+
else
|
|
165
|
+
popUp.EndEvents.RemoveListener(SelectSlot);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/// <summary>
|
|
169
|
+
///
|
|
170
|
+
/// </summary>
|
|
171
|
+
/// <param name="currentSlot"></param>
|
|
172
|
+
protected virtual void SetCurrentSaveSlot(SaveSlotBase currentSlot) => base.currentSlot = currentSlot;
|
|
173
|
+
|
|
174
|
+
/// <summary>
|
|
175
|
+
///
|
|
176
|
+
/// </summary>
|
|
177
|
+
protected virtual void EvaluatePopUp()
|
|
178
|
+
{
|
|
179
|
+
saveLoadGroup.SetLastSelected(currentSlot.gameObject);
|
|
180
|
+
|
|
181
|
+
if (saveMode)
|
|
182
|
+
{
|
|
183
|
+
saveLoadGroup.RemoveBackInput();
|
|
184
|
+
|
|
185
|
+
if (currentSlot.HasSaveData())
|
|
186
|
+
overwritePopUp.Show();
|
|
187
|
+
else
|
|
188
|
+
savePopUp.Show();
|
|
189
|
+
}
|
|
190
|
+
else if (currentSlot.HasSaveData())
|
|
191
|
+
{
|
|
192
|
+
saveLoadGroup.RemoveBackInput();
|
|
193
|
+
|
|
194
|
+
loadPopUp.Show();
|
|
195
|
+
}
|
|
196
|
+
else
|
|
197
|
+
OnSelectedLockedSaveSlot?.Invoke();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/// <summary>
|
|
201
|
+
///
|
|
202
|
+
/// </summary>
|
|
203
|
+
protected virtual void SelectSlot()
|
|
204
|
+
{
|
|
205
|
+
EventSystem.current.SetSelectedGameObject(currentSlot.gameObject);
|
|
206
|
+
|
|
207
|
+
ServiceLocator.GetService<UIHandlerBase>().SetCurrent(currentSlot.gameObject);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
/// <inheritdoc/>
|
|
212
|
+
public override void LoadCurrentSlot()
|
|
213
|
+
{
|
|
214
|
+
ServiceLocator.GetService<IDialogueManager>().GetManagerComponent<DialogueDataClearer>().ClearSaveData();
|
|
215
|
+
|
|
216
|
+
DialogueEventSystem.TriggerEvent(loadGameFileEventString, saveFilePreText + currentSlot.GetID());
|
|
217
|
+
|
|
218
|
+
if (onPauseMenu)
|
|
219
|
+
MoveToMenuOnFileSelected();
|
|
220
|
+
else // On the Main Menu Screen
|
|
221
|
+
DialogueEventSystem.TriggerEvent(applyDataEventString);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/// <summary>
|
|
225
|
+
///
|
|
226
|
+
/// </summary>
|
|
227
|
+
protected virtual void MoveToMenuOnFileSelected()
|
|
228
|
+
{
|
|
229
|
+
ServiceLocator.GetService<MenuState>().SetSelect(false);
|
|
230
|
+
|
|
231
|
+
loadPopUp.Hide();
|
|
232
|
+
|
|
233
|
+
loadPopUp.RemoveBackInput();
|
|
234
|
+
|
|
235
|
+
EventSystem.current.SetSelectedGameObject(null);
|
|
236
|
+
|
|
237
|
+
saveLoadGroup.SetLastSelected(currentSlot.gameObject);
|
|
238
|
+
|
|
239
|
+
saveLoadGroup.RemoveBackInput();
|
|
240
|
+
|
|
241
|
+
StartCoroutine(ReturnToMenuPauseHandler.FadeToMenu());
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
/// <summary>
|
|
246
|
+
///
|
|
247
|
+
/// </summary>
|
|
248
|
+
protected override void LoadSlotsUI()
|
|
249
|
+
{
|
|
250
|
+
if (useCoroutineFileLoading)
|
|
251
|
+
StartCoroutine(LoadSlotProcess());
|
|
252
|
+
else
|
|
253
|
+
PopulateSlotsUI();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/// <summary>
|
|
257
|
+
///
|
|
258
|
+
/// </summary>
|
|
259
|
+
protected virtual IEnumerator LoadSlotProcess()
|
|
260
|
+
{
|
|
261
|
+
for (int i = 0; i < saveSlots.Count; i++)
|
|
262
|
+
if (SaveSystem.SaveFileExists(saveFilePreText + i))
|
|
263
|
+
yield return FoundSaveRoutine(saveSlots[i]);
|
|
264
|
+
else
|
|
265
|
+
saveSlots[i].OnSaveNotFound();
|
|
266
|
+
|
|
267
|
+
yield break;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/// <summary>
|
|
271
|
+
///
|
|
272
|
+
/// </summary>
|
|
273
|
+
/// <param name="slot"></param>
|
|
274
|
+
/// <remarks></remarks>
|
|
275
|
+
protected virtual IEnumerator FoundSaveRoutine(SaveSlotBase slot)
|
|
276
|
+
{
|
|
277
|
+
slot.OnSaveFound();
|
|
278
|
+
|
|
279
|
+
yield return null;
|
|
280
|
+
|
|
281
|
+
yield return null;
|
|
282
|
+
|
|
283
|
+
yield break;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
/// <summary>
|
|
288
|
+
///
|
|
289
|
+
/// </summary>
|
|
290
|
+
protected virtual void PopulateSlotsUI()
|
|
291
|
+
{
|
|
292
|
+
for (int i = 0; i < saveSlots.Count; i++)
|
|
293
|
+
if (SaveSystem.SaveFileExists(saveFilePreText + i))
|
|
294
|
+
saveSlots[i].OnSaveFound();
|
|
295
|
+
else
|
|
296
|
+
saveSlots[i].OnSaveNotFound();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Dialogues.Events;
|
|
3
|
+
using System.Collections;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using UnityEngine.Events;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.UI.SavingLoading
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
public abstract class SaveLoadMenuBase : MonoBehaviour
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[Header("")]
|
|
18
|
+
[Divider]
|
|
19
|
+
[Tooltip("")]
|
|
20
|
+
[SerializeField] protected string saveFilePreText = "save";
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
///
|
|
24
|
+
/// </summary>
|
|
25
|
+
[Tooltip("")]
|
|
26
|
+
[SerializeField] protected bool useCoroutineFileLoading = false;
|
|
27
|
+
|
|
28
|
+
/// <summary>
|
|
29
|
+
///
|
|
30
|
+
/// </summary>
|
|
31
|
+
[Tooltip("")]
|
|
32
|
+
[SerializeField] protected string saveGameFileEvent = "SaveGameFile";
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
[Header("")]
|
|
36
|
+
[Divider]
|
|
37
|
+
[SerializeField] protected UnityEvent OnSave;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
///
|
|
42
|
+
/// </summary>
|
|
43
|
+
protected SaveSlotBase currentSlot = null;
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
///
|
|
47
|
+
/// </summary>
|
|
48
|
+
protected bool saveMode = false;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
/// <param name="action"></param>
|
|
55
|
+
public virtual void AddOnSaveListener(UnityAction action) => OnSave.AddListener(action);
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
///
|
|
59
|
+
/// </summary>
|
|
60
|
+
/// <param name="action"></param>
|
|
61
|
+
public virtual void RemoveOnSaveListener(UnityAction action) => OnSave.RemoveListener(action);
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
///
|
|
65
|
+
/// </summary>
|
|
66
|
+
/// <remarks></remarks>
|
|
67
|
+
public virtual void SetSaveMode()
|
|
68
|
+
{
|
|
69
|
+
saveMode = true;
|
|
70
|
+
|
|
71
|
+
LoadSlotsUI();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
///
|
|
76
|
+
/// </summary>
|
|
77
|
+
/// <remarks></remarks>
|
|
78
|
+
public virtual void SetLoadMode()
|
|
79
|
+
{
|
|
80
|
+
saveMode = false;
|
|
81
|
+
|
|
82
|
+
LoadSlotsUI();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/// <summary>
|
|
86
|
+
///
|
|
87
|
+
/// </summary>
|
|
88
|
+
protected abstract void LoadSlotsUI();
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
/// <summary>
|
|
92
|
+
///
|
|
93
|
+
/// </summary>
|
|
94
|
+
/// <remarks></remarks>
|
|
95
|
+
public virtual void SaveCurrentSlot()
|
|
96
|
+
{
|
|
97
|
+
DialogueEventSystem.TriggerEvent(saveGameFileEvent, saveFilePreText + currentSlot.GetID());
|
|
98
|
+
|
|
99
|
+
StartCoroutine(BufferPostSave());
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// <summary>
|
|
103
|
+
///
|
|
104
|
+
/// </summary>
|
|
105
|
+
/// <returns></returns>
|
|
106
|
+
protected virtual IEnumerator BufferPostSave()
|
|
107
|
+
{
|
|
108
|
+
yield return null;
|
|
109
|
+
|
|
110
|
+
LoadSlotsUI();
|
|
111
|
+
|
|
112
|
+
OnSave?.Invoke();
|
|
113
|
+
|
|
114
|
+
yield break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/// <summary>
|
|
118
|
+
///
|
|
119
|
+
/// </summary>
|
|
120
|
+
/// <remarks></remarks>
|
|
121
|
+
public abstract void LoadCurrentSlot();
|
|
122
|
+
}
|
|
123
|
+
}
|