net.dreditor.ui.menus 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.
Binary file
@@ -0,0 +1,79 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.EventObjectServices;
3
+ using UnityEngine;
4
+ using UnityEngine.Serialization;
5
+ using UnityEngine.UI;
6
+
7
+ namespace DREditor.UI.Menus
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ /// <remarks></remarks>
13
+ [ClassHeader("")]
14
+ public class ChapterUIImage : IntWithEventListener
15
+ {
16
+ /// <summary>
17
+ ///
18
+ /// </summary>
19
+ [Divider]
20
+ [Tooltip("")]
21
+ [FormerlySerializedAs("image")]
22
+ [SerializeField] protected Image chapterImage = null;
23
+
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ [Tooltip("")]
28
+ [SerializeField] protected Sprite defaultSprite = null;
29
+
30
+
31
+ /// <summary>
32
+ ///
33
+ /// </summary>
34
+ [Header("")]
35
+ [Divider]
36
+ [Tooltip("")]
37
+ [SerializeField] protected int enableIDX = -1;
38
+
39
+ /// <summary>
40
+ ///
41
+ /// </summary>
42
+ [Tooltip("")]
43
+ [SerializeField] protected int disableIDX = -1;
44
+
45
+
46
+ /// <summary>
47
+ ///
48
+ /// </summary>
49
+ [Header("")]
50
+ [Divider]
51
+ [Tooltip("")]
52
+ [SerializeField] protected Sprite[] sprites = null;
53
+
54
+
55
+ /// <inheritdoc/>
56
+ protected override void OnValueChanged(int updatedValue)
57
+ {
58
+ base.OnValueChanged(updatedValue);
59
+
60
+ ChangeUI(updatedValue);
61
+ }
62
+
63
+ /// <summary>
64
+ ///
65
+ /// </summary>
66
+ /// <param name="chapterIndex"></param>
67
+ protected virtual void ChangeUI(int chapterIndex)
68
+ {
69
+ if (chapterIndex == enableIDX)
70
+ chapterImage.enabled = true;
71
+
72
+ if (chapterIndex == disableIDX)
73
+ chapterImage.enabled = false;
74
+
75
+ if (chapterIndex < sprites.Length)
76
+ chapterImage.sprite = sprites[chapterIndex] != null ? sprites[chapterIndex] : defaultSprite;
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 05bdf963ec644c645adeeeb95e31d2d7
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,92 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.EventObjectServices;
3
+ using TMPro;
4
+ using UnityEngine;
5
+ using UnityEngine.Serialization;
6
+
7
+ namespace DREditor.UI.Menus
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ /// <remarks></remarks>
13
+ [ClassHeader("")]
14
+ public partial class ChapterUIText : IntWithEventListener
15
+ {
16
+ /// <summary>
17
+ ///
18
+ /// </summary>
19
+ [Divider]
20
+ [Tooltip("")]
21
+ [FormerlySerializedAs("textO")]
22
+ [SerializeField] protected TextMeshProUGUI chapterText = null;
23
+
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ [Tooltip("")]
28
+ [SerializeField] protected TextUIPositionPair defaultText;
29
+
30
+
31
+ /// <summary>
32
+ ///
33
+ /// </summary>
34
+ [Header("")]
35
+ [Divider]
36
+ [Tooltip("")]
37
+ [SerializeField] protected int enableIDX = -1;
38
+
39
+ /// <summary>
40
+ ///
41
+ /// </summary>
42
+ [Tooltip("")]
43
+ [SerializeField] protected int disableIDX = -1;
44
+
45
+
46
+ /// <summary>
47
+ ///
48
+ /// </summary>
49
+ [Header("")]
50
+ [Divider]
51
+ [Tooltip("")]
52
+ [SerializeField] protected TextUIPositionPair[] texts = null;
53
+
54
+
55
+ /// <inheritdoc/>
56
+ protected override void OnValueChanged(int updatedValue)
57
+ {
58
+ base.OnValueChanged(updatedValue);
59
+
60
+ ChangeUI(updatedValue);
61
+ }
62
+
63
+ /// <summary>
64
+ ///
65
+ /// </summary>
66
+ /// <param name="chapterIndex"></param>
67
+ protected virtual void ChangeUI(int chapterIndex)
68
+ {
69
+ if (chapterIndex >= 0 && chapterIndex < texts.Length)
70
+ SetTextPair(texts[chapterIndex]);
71
+ else
72
+ SetTextPair(defaultText);
73
+
74
+ if (chapterIndex == enableIDX)
75
+ chapterText.enabled = true;
76
+
77
+ if (chapterIndex == disableIDX)
78
+ chapterText.enabled = false;
79
+ }
80
+
81
+ /// <summary>
82
+ ///
83
+ /// </summary>
84
+ /// <param name="pair"></param>
85
+ protected virtual void SetTextPair(TextUIPositionPair pair)
86
+ {
87
+ chapterText.text = pair.text;
88
+
89
+ chapterText.gameObject.transform.localPosition = pair.position;
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 9a7900e8a74de9d4aa11e57456365aaf
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,28 @@
1
+ {
2
+ "name": "DREditor.UI.Menus",
3
+ "rootNamespace": "",
4
+ "references": [
5
+ "DREditor",
6
+ "DREditor.UI",
7
+ "Unity.TextMeshPro",
8
+ "Unity.InputSystem",
9
+ "DREditor.EventObjectServices",
10
+ "DREditor.States",
11
+ "DREditor.Fading",
12
+ "DREditor.Progressing.Handling",
13
+ "DREditor.Controls",
14
+ "DREditor.Audio",
15
+ "DREditor.UIHandling",
16
+ "DREditor.DialogueMechanics.Investigation",
17
+ "DREditor.Investigations"
18
+ ],
19
+ "includePlatforms": [],
20
+ "excludePlatforms": [],
21
+ "allowUnsafeCode": false,
22
+ "overrideReferences": false,
23
+ "precompiledReferences": [],
24
+ "autoReferenced": true,
25
+ "defineConstraints": [],
26
+ "versionDefines": [],
27
+ "noEngineReferences": false
28
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: eca1c04d9d6cb474f9793955e8f7085e
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,109 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using UnityEngine;
3
+ using UnityEngine.Serialization;
4
+ using UnityEngine.UI;
5
+
6
+ namespace DREditor.UI.Menus
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ /// <remarks></remarks>
12
+ [ClassHeader(nameof(SelectHandler) +
13
+ "\n\n")]
14
+ [DefaultExecutionOrder(-1)]
15
+ public class ImageSelectHandler : SelectHandler
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [Tooltip("")]
21
+ [SerializeField] protected Image image = null;
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Tooltip("")]
27
+ [FormerlySerializedAs("selectImage")]
28
+ [SerializeField] protected Sprite selectedSprite = null;
29
+
30
+
31
+ /// <summary>
32
+ ///
33
+ /// </summary>
34
+ [Header("")]
35
+ [Divider]
36
+ [Tooltip("")]
37
+ [SerializeField] protected bool colorImage = false;
38
+
39
+ /// <summary>
40
+ ///
41
+ /// </summary>
42
+ [Tooltip("")]
43
+ [FormerlySerializedAs("initialText")]
44
+ [SerializeField] protected Color initialColor = Color.black;
45
+
46
+ /// <summary>
47
+ ///
48
+ /// </summary>
49
+ [Tooltip("")]
50
+ [FormerlySerializedAs("selectText")]
51
+ [SerializeField] protected Color selectedColor = Color.white;
52
+
53
+ /// <summary>
54
+ ///
55
+ /// </summary>
56
+ [Divider]
57
+
58
+ [Tooltip("")]
59
+ [SerializeField] protected bool enableMode = false;
60
+
61
+
62
+ /// <summary>
63
+ ///
64
+ /// </summary>
65
+ protected Sprite initialSprite = null;
66
+
67
+
68
+ /// <summary>
69
+ ///
70
+ /// </summary>
71
+ protected virtual void Awake()
72
+ {
73
+ if (!image)
74
+ image = GetComponent<Image>();
75
+
76
+ if (!enableMode && image)
77
+ initialSprite = image.sprite;
78
+
79
+ if (colorImage)
80
+ initialColor = image.color;
81
+ }
82
+
83
+ /// <inheritdoc/>
84
+ public override void Select()
85
+ {
86
+ if (enableMode && !image.enabled)
87
+ image.enabled = true;
88
+
89
+ if (!enableMode && image && selectedSprite)
90
+ image.sprite = selectedSprite;
91
+
92
+ if (colorImage)
93
+ image.color = selectedColor;
94
+ }
95
+
96
+ /// <inheritdoc/>
97
+ public override void Deselect()
98
+ {
99
+ if (enableMode && image.enabled)
100
+ image.enabled = false;
101
+
102
+ if (!enableMode && image)
103
+ image.sprite = initialSprite;
104
+
105
+ if (colorImage)
106
+ image.color = initialColor;
107
+ }
108
+ }
109
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 46ab4d7e2da580f4faf14f01eaa7913c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/MainMenu.cs ADDED
@@ -0,0 +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
+ }
231
+ }
@@ -0,0 +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: