net.dreditor.ui.menus 0.1.6 → 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/MainMenu.cs CHANGED
@@ -1,231 +1,231 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- using DREditor.Dialogues.Events;
3
- using DREditor.EventObjects;
4
- using DREditor.Fading;
5
- using DREditor.Services;
6
- using System.Collections;
7
- using UnityEngine;
8
- using UnityEngine.Events;
9
- using UnityEngine.EventSystems;
10
-
11
- namespace DREditor.UI.Menus
12
- {
13
- /// <summary>
14
- ///
15
- /// </summary>
16
- [ClassHeader(nameof(ISceneEventListener) +
17
- "\n\n")]
18
- public class MainMenu : MonoBehaviour, ISceneEventListener
19
- {
20
- /// <summary>
21
- ///
22
- /// </summary>
23
- [Header("")]
24
- [Divider]
25
- [Tooltip("")]
26
- [SerializeField] protected GameObject firstObjectToBeSelected = null;
27
-
28
- /// <summary>
29
- ///
30
- /// </summary>
31
- [Tooltip("")]
32
- [SerializeField] protected MenuGroupBase firstMenuGroupSelected = null;
33
-
34
- /// <summary>
35
- ///
36
- /// </summary>
37
- [Tooltip("")]
38
- [SerializeField] protected MenuGroupBase loadGroup = null;
39
-
40
- /// <summary>
41
- ///
42
- /// </summary>
43
- [Tooltip("")]
44
- [SerializeField] protected string applyDataEventString = "ApplyCurrentData";
45
-
46
-
47
- /// <summary>
48
- ///
49
- /// </summary>
50
- [Header("")]
51
- [Divider]
52
- [Tooltip("")]
53
- [SerializeField] protected BoolWithEvent hasLoadedSaveData = null;
54
-
55
- /// <summary>
56
- ///
57
- /// </summary>
58
- [Tooltip("")]
59
- [SerializeField] protected BoolWithEvent startedNewWithLoaded = null;
60
-
61
- /// <summary>
62
- ///
63
- /// </summary>
64
- [Tooltip("")]
65
- [SerializeField] protected BoolWithEvent firstTimeLoaded = null;
66
-
67
- /// <summary>
68
- ///
69
- /// </summary>
70
- [Tooltip("")]
71
- [SerializeField] protected SceneEvent onFadeOutComplete = null;
72
-
73
-
74
- /// <summary>
75
- ///
76
- /// </summary>
77
- [Header("")]
78
- [Divider]
79
- [Tooltip("")]
80
- [SerializeField] protected float firstInitializeBufferTime = 1.5f;
81
-
82
- /// <summary>
83
- ///
84
- /// </summary>
85
- [Tooltip("")]
86
- [SerializeField] protected float fadeOutBufferTime = 1;
87
-
88
- /// <summary>
89
- ///
90
- /// </summary>
91
- [Tooltip("")]
92
- [SerializeField] protected float firstGroupRevealBufferTime = 1;
93
-
94
- [Space]
95
-
96
- [Space]
97
-
98
- [Header("")]
99
- [SerializeField] protected UnityEvent OnLoadIntoMainMenu;
100
-
101
-
102
- /// <summary>
103
- ///
104
- /// </summary>
105
- protected virtual void Start() => EvaluateMainMenuState();
106
-
107
- /// <summary>
108
- ///
109
- /// </summary>
110
- protected virtual void EvaluateMainMenuState()
111
- {
112
- if (!firstTimeLoaded.Value && !hasLoadedSaveData.Value)
113
- FirstTimeReachedMainMenu();
114
- else if (startedNewWithLoaded.Value)
115
- StartedNewGameOnLoadedFile();
116
- else if (firstTimeLoaded.Value && hasLoadedSaveData.Value)
117
- LoadedFile();
118
- else
119
- FirstTimeReachedMainMenu();
120
- }
121
-
122
- /// <summary>
123
- ///
124
- /// </summary>
125
- protected virtual void FirstTimeReachedMainMenu()
126
- {
127
- if (!firstTimeLoaded.Value && !hasLoadedSaveData.Value)
128
- UnityEngine.Debug.Log($"{ToString()}: First Time Reached Main Menu");
129
- else
130
- UnityEngine.Debug.LogWarning($"{ToString()}: MainMenu Start: No CurrentDRESaveData");
131
-
132
- firstTimeLoaded.SetValue(true);
133
-
134
- StartCoroutine(OnFirstTimeRoutine());
135
- }
136
-
137
- /// <summary>
138
- ///
139
- /// </summary>
140
- /// <returns></returns>
141
- protected virtual IEnumerator OnFirstTimeRoutine()
142
- {
143
- yield return new WaitForSecondsRealtime(firstInitializeBufferTime);
144
-
145
- if (ServiceLocator.HasService<GlobalFade>() && ServiceLocator.GetService<GlobalFade>().IsDark)
146
- ServiceLocator.GetService<GlobalFade>().FadeOut(fadeOutBufferTime);
147
-
148
- OnLoadIntoMainMenu?.Invoke();
149
-
150
- yield return new WaitForSeconds(firstGroupRevealBufferTime);
151
-
152
- InitializeFirstGroupStartUp();
153
- }
154
-
155
- /// <summary>
156
- ///
157
- /// </summary>
158
- protected virtual void InitializeFirstGroupStartUp()
159
- {
160
- firstMenuGroupSelected.Show();
161
-
162
- EventSystem.current.SetSelectedGameObject(firstObjectToBeSelected);
163
-
164
- ServiceLocator.GetService<UIHandlerBase>().SetCurrent(firstObjectToBeSelected);
165
- }
166
-
167
-
168
- /// <summary>
169
- ///
170
- /// </summary>
171
- protected virtual void StartedNewGameOnLoadedFile()
172
- {
173
- UnityEngine.Debug.Log($"{ToString()}: Player started New Game on Loaded File");
174
-
175
- startedNewWithLoaded.SetValue(false);
176
-
177
- LoadedFile();
178
- }
179
-
180
- /// <summary>
181
- ///
182
- /// </summary>
183
- protected virtual void LoadedFile() => StartCoroutine(LoadGroupStart());
184
-
185
- /// <summary>
186
- ///
187
- /// </summary>
188
- /// <returns></returns>
189
- protected virtual IEnumerator LoadGroupStart()
190
- {
191
- UnityEngine.Debug.Log($"{ToString()}: Player Loaded in with save data");
192
-
193
- if (ServiceLocator.GetService<GlobalFade>().isTransitioning)
194
- yield return new WaitUntil(() => !ServiceLocator.GetService<GlobalFade>().isTransitioning);
195
-
196
- yield return null;
197
-
198
- LoadGroupStartProcess();
199
- }
200
-
201
- /// <summary>
202
- ///
203
- /// </summary>
204
- protected virtual void LoadGroupStartProcess()
205
- {
206
- ServiceLocator.GetService<GlobalFade>().FadeOut(fadeOutBufferTime);
207
-
208
- OnLoadIntoMainMenu?.Invoke();
209
-
210
- onFadeOutComplete.RegisterListener(this);
211
-
212
- if (hasLoadedSaveData.Value)
213
- {
214
- DialogueEventSystem.TriggerEvent(applyDataEventString);
215
-
216
- hasLoadedSaveData.Invoke();
217
- }
218
- else
219
- UnityEngine.Debug.LogError($"ALERT: {nameof(MainMenu)}: CRITICAL ERROR: DRESaveData Not found. :(");
220
- }
221
-
222
-
223
- /// <inheritdoc/>
224
- public virtual void OnEventRaised()
225
- {
226
- onFadeOutComplete.UnregisterListener(this);
227
-
228
- loadGroup.Show();
229
- }
230
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues.Events;
3
+ using DREditor.EventObjects;
4
+ using DREditor.Fading;
5
+ using DREditor.Services;
6
+ using System.Collections;
7
+ using UnityEngine;
8
+ using UnityEngine.Events;
9
+ using UnityEngine.EventSystems;
10
+
11
+ namespace DREditor.UI.Menus
12
+ {
13
+ /// <summary>
14
+ ///
15
+ /// </summary>
16
+ [ClassHeader(nameof(ISceneEventListener) +
17
+ "\n\n")]
18
+ public class MainMenu : MonoBehaviour, ISceneEventListener
19
+ {
20
+ /// <summary>
21
+ ///
22
+ /// </summary>
23
+ [Header("")]
24
+ [Divider]
25
+ [Tooltip("")]
26
+ [SerializeField] protected GameObject firstObjectToBeSelected = null;
27
+
28
+ /// <summary>
29
+ ///
30
+ /// </summary>
31
+ [Tooltip("")]
32
+ [SerializeField] protected MenuGroupBase firstMenuGroupSelected = null;
33
+
34
+ /// <summary>
35
+ ///
36
+ /// </summary>
37
+ [Tooltip("")]
38
+ [SerializeField] protected MenuGroupBase loadGroup = null;
39
+
40
+ /// <summary>
41
+ ///
42
+ /// </summary>
43
+ [Tooltip("")]
44
+ [SerializeField] protected string applyDataEventString = "ApplyCurrentData";
45
+
46
+
47
+ /// <summary>
48
+ ///
49
+ /// </summary>
50
+ [Header("")]
51
+ [Divider]
52
+ [Tooltip("")]
53
+ [SerializeField] protected BoolWithEvent hasLoadedSaveData = null;
54
+
55
+ /// <summary>
56
+ ///
57
+ /// </summary>
58
+ [Tooltip("")]
59
+ [SerializeField] protected BoolWithEvent startedNewWithLoaded = null;
60
+
61
+ /// <summary>
62
+ ///
63
+ /// </summary>
64
+ [Tooltip("")]
65
+ [SerializeField] protected BoolWithEvent firstTimeLoaded = null;
66
+
67
+ /// <summary>
68
+ ///
69
+ /// </summary>
70
+ [Tooltip("")]
71
+ [SerializeField] protected SceneEvent onFadeOutComplete = null;
72
+
73
+
74
+ /// <summary>
75
+ ///
76
+ /// </summary>
77
+ [Header("")]
78
+ [Divider]
79
+ [Tooltip("")]
80
+ [SerializeField] protected float firstInitializeBufferTime = 1.5f;
81
+
82
+ /// <summary>
83
+ ///
84
+ /// </summary>
85
+ [Tooltip("")]
86
+ [SerializeField] protected float fadeOutBufferTime = 1;
87
+
88
+ /// <summary>
89
+ ///
90
+ /// </summary>
91
+ [Tooltip("")]
92
+ [SerializeField] protected float firstGroupRevealBufferTime = 1;
93
+
94
+ [Space]
95
+
96
+ [Space]
97
+
98
+ [Header("")]
99
+ [SerializeField] protected UnityEvent OnLoadIntoMainMenu;
100
+
101
+
102
+ /// <summary>
103
+ ///
104
+ /// </summary>
105
+ protected virtual void Start() => EvaluateMainMenuState();
106
+
107
+ /// <summary>
108
+ ///
109
+ /// </summary>
110
+ protected virtual void EvaluateMainMenuState()
111
+ {
112
+ if (!firstTimeLoaded.Value && !hasLoadedSaveData.Value)
113
+ FirstTimeReachedMainMenu();
114
+ else if (startedNewWithLoaded.Value)
115
+ StartedNewGameOnLoadedFile();
116
+ else if (firstTimeLoaded.Value && hasLoadedSaveData.Value)
117
+ LoadedFile();
118
+ else
119
+ FirstTimeReachedMainMenu();
120
+ }
121
+
122
+ /// <summary>
123
+ ///
124
+ /// </summary>
125
+ protected virtual void FirstTimeReachedMainMenu()
126
+ {
127
+ if (!firstTimeLoaded.Value && !hasLoadedSaveData.Value)
128
+ UnityEngine.Debug.Log($"{ToString()}: First Time Reached Main Menu");
129
+ else
130
+ UnityEngine.Debug.LogWarning($"{ToString()}: MainMenu Start: No CurrentDRESaveData");
131
+
132
+ firstTimeLoaded.SetValue(true);
133
+
134
+ StartCoroutine(OnFirstTimeRoutine());
135
+ }
136
+
137
+ /// <summary>
138
+ ///
139
+ /// </summary>
140
+ /// <returns></returns>
141
+ protected virtual IEnumerator OnFirstTimeRoutine()
142
+ {
143
+ yield return new WaitForSecondsRealtime(firstInitializeBufferTime);
144
+
145
+ if (ServiceLocator.HasService<GlobalFade>() && ServiceLocator.GetService<GlobalFade>().IsDark)
146
+ ServiceLocator.GetService<GlobalFade>().FadeOut(fadeOutBufferTime);
147
+
148
+ OnLoadIntoMainMenu?.Invoke();
149
+
150
+ yield return new WaitForSeconds(firstGroupRevealBufferTime);
151
+
152
+ InitializeFirstGroupStartUp();
153
+ }
154
+
155
+ /// <summary>
156
+ ///
157
+ /// </summary>
158
+ protected virtual void InitializeFirstGroupStartUp()
159
+ {
160
+ firstMenuGroupSelected.Show();
161
+
162
+ EventSystem.current.SetSelectedGameObject(firstObjectToBeSelected);
163
+
164
+ ServiceLocator.GetService<UIHandlerBase>().SetCurrent(firstObjectToBeSelected);
165
+ }
166
+
167
+
168
+ /// <summary>
169
+ ///
170
+ /// </summary>
171
+ protected virtual void StartedNewGameOnLoadedFile()
172
+ {
173
+ UnityEngine.Debug.Log($"{ToString()}: Player started New Game on Loaded File");
174
+
175
+ startedNewWithLoaded.SetValue(false);
176
+
177
+ LoadedFile();
178
+ }
179
+
180
+ /// <summary>
181
+ ///
182
+ /// </summary>
183
+ protected virtual void LoadedFile() => StartCoroutine(LoadGroupStart());
184
+
185
+ /// <summary>
186
+ ///
187
+ /// </summary>
188
+ /// <returns></returns>
189
+ protected virtual IEnumerator LoadGroupStart()
190
+ {
191
+ UnityEngine.Debug.Log($"{ToString()}: Player Loaded in with save data");
192
+
193
+ if (ServiceLocator.GetService<GlobalFade>().isTransitioning)
194
+ yield return new WaitUntil(() => !ServiceLocator.GetService<GlobalFade>().isTransitioning);
195
+
196
+ yield return null;
197
+
198
+ LoadGroupStartProcess();
199
+ }
200
+
201
+ /// <summary>
202
+ ///
203
+ /// </summary>
204
+ protected virtual void LoadGroupStartProcess()
205
+ {
206
+ ServiceLocator.GetService<GlobalFade>().FadeOut(fadeOutBufferTime);
207
+
208
+ OnLoadIntoMainMenu?.Invoke();
209
+
210
+ onFadeOutComplete.RegisterListener(this);
211
+
212
+ if (hasLoadedSaveData.Value)
213
+ {
214
+ DialogueEventSystem.TriggerEvent(applyDataEventString);
215
+
216
+ hasLoadedSaveData.Invoke();
217
+ }
218
+ else
219
+ UnityEngine.Debug.LogError($"ALERT: {nameof(MainMenu)}: CRITICAL ERROR: DRESaveData Not found. :(");
220
+ }
221
+
222
+
223
+ /// <inheritdoc/>
224
+ public virtual void OnEventRaised()
225
+ {
226
+ onFadeOutComplete.UnregisterListener(this);
227
+
228
+ loadGroup.Show();
229
+ }
230
+ }
231
231
  }
package/MainMenu.cs.meta CHANGED
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 52007a209ddbe9047aa76341b9cfc604
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 52007a209ddbe9047aa76341b9cfc604
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: