net.dreditor.textdisplaying 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.
- package/CGLineTextDisplayer.cs +13 -0
- package/CGLineTextDisplayer.cs.meta +11 -0
- package/ClearTextOnLineEnd.cs +18 -0
- package/ClearTextOnLineEnd.cs.meta +11 -0
- package/ColorByCharacterTextModifier.cs +46 -0
- package/ColorByCharacterTextModifier.cs.meta +11 -0
- package/DREditor.TextDisplaying.asmdef +20 -0
- package/DREditor.TextDisplaying.asmdef.meta +7 -0
- package/DialogueLineTextDisplayer.cs +188 -0
- package/DialogueLineTextDisplayer.cs.meta +11 -0
- package/DisplayFormattedString.cs +69 -0
- package/DisplayFormattedString.cs.meta +2 -0
- package/DisplayOwnedIntCurrency.cs +57 -0
- package/DisplayOwnedIntCurrency.cs.meta +2 -0
- package/HighlightTextModifier.cs +71 -0
- package/HighlightTextModifier.cs.meta +11 -0
- package/ITextDisplayerHandler.cs +23 -0
- package/ITextDisplayerHandler.cs.meta +11 -0
- package/OptionsTextMessage.cs +54 -0
- package/OptionsTextMessage.cs.meta +11 -0
- package/OptionsTextSpeedMessage.cs +83 -0
- package/OptionsTextSpeedMessage.cs.meta +11 -0
- package/RegexEscapeModifier.cs +44 -0
- package/RegexEscapeModifier.cs.meta +11 -0
- package/ReplaceGroup.cs +34 -0
- package/ReplaceGroup.cs.meta +11 -0
- package/ReplaceTextModifier.cs +54 -0
- package/ReplaceTextModifier.cs.meta +11 -0
- package/ReplaceTextModifierBase.cs +19 -0
- package/ReplaceTextModifierBase.cs.meta +11 -0
- package/Samples/CGDialogueUIVisible.asset +21 -0
- package/Samples/CGDialogueUIVisible.asset.meta +8 -0
- package/Samples/CGTextBox.asset +21 -0
- package/Samples/CGTextBox.asset.meta +8 -0
- package/Samples/CG_Line_Text_Displayer.prefab +147 -0
- package/Samples/CG_Line_Text_Displayer.prefab.meta +7 -0
- package/Samples/Clear_Text_On_Line_End.prefab +46 -0
- package/Samples/Clear_Text_On_Line_End.prefab.meta +7 -0
- package/Samples/Color_By_Character_Text_Modifier.prefab +51 -0
- package/Samples/Color_By_Character_Text_Modifier.prefab.meta +7 -0
- package/Samples/DRE_TextDebugging.unity +492 -0
- package/Samples/DRE_TextDebugging.unity.meta +7 -0
- package/Samples/DialogueTextBox.asset +21 -0
- package/Samples/DialogueTextBox.asset.meta +8 -0
- package/Samples/Dialogue_Line_Text_Displayer.prefab +142 -0
- package/Samples/Dialogue_Line_Text_Displayer.prefab.meta +7 -0
- package/Samples/Highlight_Text_Modifier.prefab +49 -0
- package/Samples/Highlight_Text_Modifier.prefab.meta +7 -0
- package/Samples/Option_Message_UI_ETemplate.prefab +335 -0
- package/Samples/Option_Message_UI_ETemplate.prefab.meta +7 -0
- package/Samples/OptionsUITextSpeedMessage.asset +21 -0
- package/Samples/OptionsUITextSpeedMessage.asset.meta +8 -0
- package/Samples/Regex_Escape_Modifier.prefab +47 -0
- package/Samples/Regex_Escape_Modifier.prefab.meta +7 -0
- package/Samples/Replace_Text_Modifier.prefab +49 -0
- package/Samples/Replace_Text_Modifier.prefab.meta +7 -0
- package/Samples/Symbol_Color_Text_Modifier.prefab +50 -0
- package/Samples/Symbol_Color_Text_Modifier.prefab.meta +7 -0
- package/Samples/Symbol_Protag_UI_Modifier.prefab +48 -0
- package/Samples/Symbol_Protag_UI_Modifier.prefab.meta +7 -0
- package/Samples/Text_Display_Debugger.prefab +467 -0
- package/Samples/Text_Display_Debugger.prefab.meta +7 -0
- package/Samples/Text_Displayer.prefab +624 -0
- package/Samples/Text_Displayer.prefab.meta +7 -0
- package/Samples/TrialDialogueTextBox.asset +21 -0
- package/Samples/TrialDialogueTextBox.asset.meta +8 -0
- package/Samples/Trial_Dialogue_Line_Text_Displayer.prefab +82 -0
- package/Samples/Trial_Dialogue_Line_Text_Displayer.prefab.meta +7 -0
- package/Samples.meta +8 -0
- package/SetTextDisplaySpeed.cs +60 -0
- package/SetTextDisplaySpeed.cs.meta +11 -0
- package/SymbolColorTextModifier.cs +25 -0
- package/SymbolColorTextModifier.cs.meta +11 -0
- package/SymbolProtagUIModifier.cs +42 -0
- package/SymbolProtagUIModifier.cs.meta +11 -0
- package/SymbolTextModifier.cs +48 -0
- package/SymbolTextModifier.cs.meta +11 -0
- package/TMPMarquee.cs +178 -0
- package/TMPMarquee.cs.meta +11 -0
- package/TMPMarqueeBase.cs +104 -0
- package/TMPMarqueeBase.cs.meta +2 -0
- package/TextDisplayDebugger.cs +87 -0
- package/TextDisplayDebugger.cs.meta +11 -0
- package/TextDisplayModifier.cs +29 -0
- package/TextDisplayModifier.cs.meta +11 -0
- package/TextDisplayer.cs +255 -0
- package/TextDisplayer.cs.meta +11 -0
- package/TextDisplayerBase.cs +107 -0
- package/TextDisplayerBase.cs.meta +11 -0
- package/package.json +37 -6
- package/package.json.meta +7 -0
- package/README.md +0 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
|
|
3
|
+
namespace DREditor.TextDisplaying
|
|
4
|
+
{
|
|
5
|
+
/// <summary>
|
|
6
|
+
///
|
|
7
|
+
/// </summary>
|
|
8
|
+
public class CGLineTextDisplayer : DialogueLineTextDisplayer
|
|
9
|
+
{
|
|
10
|
+
/// <inheritdoc/>
|
|
11
|
+
protected override bool SkipDisplayingText() => !inCGMode.Value && !inVideoMode.Value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
|
|
6
|
+
namespace DREditor.TextDisplaying
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
[ClassHeader(nameof(DialogueComponent) + ", " + nameof(ILineEndProcess) +
|
|
12
|
+
"\n\n")]
|
|
13
|
+
public class ClearTextOnLineEnd : DialogueComponent, ILineEndProcess
|
|
14
|
+
{
|
|
15
|
+
/// <inheritdoc/>
|
|
16
|
+
public virtual void LineEndProcess(Line currentLine = null) => ServiceLocator.GetService<ITextDisplayerHandler>().ClearText();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Dialogues;
|
|
3
|
+
using TMPro;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.TextDisplaying
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
[ClassHeader(nameof(TextDisplayModifier) +
|
|
12
|
+
"\n\n")]
|
|
13
|
+
public class ColorByCharacterTextModifier : TextDisplayModifier
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
[Tooltip("")]
|
|
19
|
+
[SerializeField] protected string characterFirstName = "Tutorial";
|
|
20
|
+
|
|
21
|
+
/// <summary>
|
|
22
|
+
///
|
|
23
|
+
/// </summary>
|
|
24
|
+
[Tooltip("")]
|
|
25
|
+
[SerializeField] protected Color characterTextColor = new(0.27776733f, 0.735849023f, 0.136525407f, 255);
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
///
|
|
29
|
+
/// </summary>
|
|
30
|
+
[Tooltip("")]
|
|
31
|
+
[SerializeField] protected Color32 normalColor = new(255, 255, 255, 255);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/// <summary>
|
|
35
|
+
///
|
|
36
|
+
/// </summary>
|
|
37
|
+
public override string ApplyModification(string text, Line currentLine = null, TMP_Text box = null)
|
|
38
|
+
{
|
|
39
|
+
bool useTutorialColor = currentLine.Speaker != null && currentLine.Speaker.FirstName.Equals(characterFirstName);
|
|
40
|
+
|
|
41
|
+
box.color = useTutorialColor ? characterTextColor : normalColor;
|
|
42
|
+
|
|
43
|
+
return text;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "DREditor.TextDisplaying",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"Unity.InputSystem",
|
|
6
|
+
"Unity.TextMeshPro",
|
|
7
|
+
"DREditor",
|
|
8
|
+
"DREditor.Input",
|
|
9
|
+
"DREditor.Controls"
|
|
10
|
+
],
|
|
11
|
+
"includePlatforms": [],
|
|
12
|
+
"excludePlatforms": [],
|
|
13
|
+
"allowUnsafeCode": false,
|
|
14
|
+
"overrideReferences": false,
|
|
15
|
+
"precompiledReferences": [],
|
|
16
|
+
"autoReferenced": true,
|
|
17
|
+
"defineConstraints": [],
|
|
18
|
+
"versionDefines": [],
|
|
19
|
+
"noEngineReferences": false
|
|
20
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
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.EventObjects;
|
|
5
|
+
using DREditor.Services;
|
|
6
|
+
using System.Collections;
|
|
7
|
+
using TMPro;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
namespace DREditor.TextDisplaying
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
[ClassHeader(nameof(DialogueComponent) + ", " + nameof(ITextDisplayerHandler) + ", " + nameof(ILineTextDisplayRoutine) +
|
|
16
|
+
"\n\n")]
|
|
17
|
+
public class DialogueLineTextDisplayer : DialogueComponent, ITextDisplayerHandler, ILineTextDisplayRoutine
|
|
18
|
+
{
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
[Tooltip("")]
|
|
23
|
+
[SerializeField] protected TextDisplayerBase TextDisplayer = null;
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
[Tooltip("")]
|
|
29
|
+
[SerializeField] protected TextMeshProUGUI dialogueBox = null;
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
[Tooltip("")]
|
|
35
|
+
[SerializeField] protected GameObjectWithEvent globalBox = null;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
[Tooltip("")]
|
|
41
|
+
[SerializeField] protected BoolWithEvent inTrialMode = null;
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
///
|
|
45
|
+
/// </summary>
|
|
46
|
+
[Tooltip("")]
|
|
47
|
+
[SerializeField] protected BoolWithEvent inFastForwardMode = null;
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
///
|
|
51
|
+
/// </summary>
|
|
52
|
+
[Tooltip("")]
|
|
53
|
+
[SerializeField] protected BoolWithEvent inCGMode = null;
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
///
|
|
57
|
+
/// </summary>
|
|
58
|
+
[Tooltip("")]
|
|
59
|
+
[SerializeField] protected BoolWithEvent inVideoMode = null;
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
///
|
|
63
|
+
/// </summary>
|
|
64
|
+
[Tooltip("")]
|
|
65
|
+
[SerializeField] protected BoolWithEvent cgDialogueUIVisible = null;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
/// <summary>
|
|
69
|
+
///
|
|
70
|
+
/// </summary>
|
|
71
|
+
protected TMP_Text initializedGlobalBox;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
protected virtual void OnEnable()
|
|
75
|
+
{
|
|
76
|
+
if (globalBox != null)
|
|
77
|
+
globalBox.AddListener(OnGlobalBoxUpdated);
|
|
78
|
+
|
|
79
|
+
if (globalBox.Value != null)
|
|
80
|
+
OnGlobalBoxUpdated(globalBox.Value);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected virtual void OnDisable()
|
|
84
|
+
{
|
|
85
|
+
if (globalBox != null)
|
|
86
|
+
globalBox.RemoveListener(OnGlobalBoxUpdated);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// <summary>
|
|
90
|
+
///
|
|
91
|
+
/// </summary>
|
|
92
|
+
/// <param name="globalBox"></param>
|
|
93
|
+
protected virtual void OnGlobalBoxUpdated(GameObject globalBox)
|
|
94
|
+
{
|
|
95
|
+
if (globalBox != null)
|
|
96
|
+
globalBox.TryGetComponent(out initializedGlobalBox);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/// <inheritdoc/>
|
|
101
|
+
public virtual TMP_Text GetTextBox() => dialogueBox != null ? dialogueBox : initializedGlobalBox;
|
|
102
|
+
|
|
103
|
+
/// <inheritdoc/>
|
|
104
|
+
public virtual void ClearText() => TextDisplayer.ClearText();
|
|
105
|
+
|
|
106
|
+
/// <inheritdoc/>
|
|
107
|
+
public virtual bool ShouldProcess(Line currentLine)
|
|
108
|
+
{
|
|
109
|
+
if (TextDisplayer.ShouldProcess(currentLine))
|
|
110
|
+
return true;
|
|
111
|
+
|
|
112
|
+
bool result = !SkipDisplayingText() && !inFastForwardMode.Value;
|
|
113
|
+
|
|
114
|
+
if (inFastForwardMode.Value && !SkipDisplayingText())
|
|
115
|
+
{
|
|
116
|
+
ForceRegisterActiveService();
|
|
117
|
+
|
|
118
|
+
TextDisplayer.DisplayText(GetTextBox(), currentLine);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// <inheritdoc/>
|
|
125
|
+
public virtual IEnumerator LineTextDisplay(Line currentLine)
|
|
126
|
+
{
|
|
127
|
+
if (SkipDisplayingText())
|
|
128
|
+
yield break;
|
|
129
|
+
|
|
130
|
+
ForceRegisterActiveService();
|
|
131
|
+
|
|
132
|
+
DisplayTextProcess(currentLine);
|
|
133
|
+
|
|
134
|
+
yield return WaitForTextToFinishDisplaying();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// <summary>
|
|
138
|
+
///
|
|
139
|
+
/// </summary>
|
|
140
|
+
/// <returns></returns>
|
|
141
|
+
protected virtual bool SkipDisplayingText() => inCGMode.Value || inVideoMode.Value;
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
/// <summary>
|
|
145
|
+
///
|
|
146
|
+
/// </summary>
|
|
147
|
+
protected virtual void ForceRegisterActiveService()
|
|
148
|
+
{
|
|
149
|
+
if (!ServiceLocator.HasService<ITextDisplayerHandler>())
|
|
150
|
+
ServiceLocator.Register<ITextDisplayerHandler>(this);
|
|
151
|
+
else if (ServiceLocator.GetService<ITextDisplayerHandler>() != (ITextDisplayerHandler)this)
|
|
152
|
+
ReplaceActiveService();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// <summary>
|
|
156
|
+
///
|
|
157
|
+
/// </summary>
|
|
158
|
+
protected virtual void ReplaceActiveService()
|
|
159
|
+
{
|
|
160
|
+
ServiceLocator.Unregister(ServiceLocator.GetService<ITextDisplayerHandler>());
|
|
161
|
+
|
|
162
|
+
ServiceLocator.Register<ITextDisplayerHandler>(this);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/// <summary>
|
|
166
|
+
///
|
|
167
|
+
/// </summary>
|
|
168
|
+
/// <param name="line"></param>
|
|
169
|
+
protected virtual void DisplayTextProcess(Line line)
|
|
170
|
+
{
|
|
171
|
+
if (!cgDialogueUIVisible.Value && (inCGMode.Value || inVideoMode.Value))
|
|
172
|
+
cgDialogueUIVisible.SetValue(true);
|
|
173
|
+
|
|
174
|
+
TextDisplayer.DisplayText(GetTextBox(), line);
|
|
175
|
+
|
|
176
|
+
TextDisplayer.SetWaitingForClick(true);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/// <summary>
|
|
180
|
+
///
|
|
181
|
+
/// </summary>
|
|
182
|
+
protected virtual IEnumerator WaitForTextToFinishDisplaying()
|
|
183
|
+
{
|
|
184
|
+
while (TextDisplayer.IsWaitingForClick() && !inFastForwardMode.Value)
|
|
185
|
+
yield return null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using TMPro;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.TextDisplaying
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
public abstract class DisplayFormattedString : MonoBehaviour
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
[Header("")]
|
|
16
|
+
[Space]
|
|
17
|
+
[Tooltip("")]
|
|
18
|
+
[SerializeField] protected TMP_Text display;
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
///
|
|
22
|
+
/// </summary>
|
|
23
|
+
[Tooltip("")]
|
|
24
|
+
[SerializeField] protected string prefix = "x";
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
///
|
|
28
|
+
/// </summary>
|
|
29
|
+
[Tooltip("")]
|
|
30
|
+
[SerializeField] protected string format = "{0:000}";
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
///
|
|
34
|
+
/// </summary>
|
|
35
|
+
[Tooltip("")]
|
|
36
|
+
[SerializeField] protected string suffix = "";
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
protected virtual void Awake()
|
|
40
|
+
{
|
|
41
|
+
if (display == null)
|
|
42
|
+
UnityEngine.Debug.LogError($"ALERT: The {nameof(display)} field must be assigned to!");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
///
|
|
48
|
+
/// </summary>
|
|
49
|
+
public virtual void Display() => display.SetText(CreateDisplayString());
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
/// <returns></returns>
|
|
55
|
+
protected virtual string CreateDisplayString() => prefix + CreateFormattedString() + suffix;
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
///
|
|
59
|
+
/// </summary>
|
|
60
|
+
/// <returns></returns>
|
|
61
|
+
protected virtual string CreateFormattedString() => string.Format(format, GetObjectToBeFormatted());
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
///
|
|
65
|
+
/// </summary>
|
|
66
|
+
/// <returns></returns>
|
|
67
|
+
protected abstract object GetObjectToBeFormatted();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.EventObjects;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.TextDisplaying
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
[ClassHeader(nameof(DisplayFormattedString) +
|
|
11
|
+
"\n\n")]
|
|
12
|
+
public class DisplayOwnedIntCurrency : DisplayFormattedString
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[Header("")]
|
|
18
|
+
[Divider]
|
|
19
|
+
[Tooltip("")]
|
|
20
|
+
[SerializeField] protected IntWithEvent currency = null;
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
///
|
|
24
|
+
/// </summary>
|
|
25
|
+
[Tooltip("")]
|
|
26
|
+
[SerializeField] protected IntWithEvent paidAmount = null;
|
|
27
|
+
|
|
28
|
+
/// <summary>
|
|
29
|
+
///
|
|
30
|
+
/// </summary>
|
|
31
|
+
[Tooltip("")]
|
|
32
|
+
[SerializeField] protected bool neverNegative = true;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
///
|
|
37
|
+
/// </summary>
|
|
38
|
+
protected readonly int Zero = 0;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/// <inheritdoc/>
|
|
42
|
+
protected override object GetObjectToBeFormatted() => ResultIsInBounds() ? RemovedFromCurrency() : Zero;
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
///
|
|
46
|
+
/// </summary>
|
|
47
|
+
/// <returns></returns>
|
|
48
|
+
protected virtual bool ResultIsInBounds() => !neverNegative || paidAmount.Value <= currency.Value;
|
|
49
|
+
|
|
50
|
+
/// <summary>
|
|
51
|
+
///
|
|
52
|
+
/// </summary>
|
|
53
|
+
/// <returns></returns>
|
|
54
|
+
protected virtual float RemovedFromCurrency() => currency.Value - paidAmount.Value;
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Dialogues;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using System.Text.RegularExpressions;
|
|
5
|
+
using TMPro;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.TextDisplaying
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
[ClassHeader(nameof(TextDisplayModifier) +
|
|
14
|
+
"\n\n")]
|
|
15
|
+
public class HighlightTextModifier : TextDisplayModifier
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Tooltip("")]
|
|
21
|
+
[SerializeField] protected char encapsulateSymbol = '@';
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[Tooltip("")]
|
|
27
|
+
[SerializeField] protected string highlightTextStartTag = "<gradient=\"HitText\">";
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
[Tooltip("")]
|
|
33
|
+
[SerializeField] protected string highlightTextEndTag = "</gradient>";
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/// <inheritdoc/>
|
|
37
|
+
public override string ApplyModification(string text, Line currentLine = null, TMP_Text box = null)
|
|
38
|
+
=> HighlightPair(text, text.Count(x => x == encapsulateSymbol));
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
///
|
|
42
|
+
/// </summary>
|
|
43
|
+
/// <param name="text"></param>
|
|
44
|
+
/// <param name="totalSymbolCount"></param>
|
|
45
|
+
/// <returns></returns>
|
|
46
|
+
protected virtual string HighlightPair(string text, int totalSymbolCount)
|
|
47
|
+
{
|
|
48
|
+
// Apply the highlighted color to the text using HTML tags
|
|
49
|
+
for (int i = 0; i < totalSymbolCount; i++)
|
|
50
|
+
text = TextColorInator(text, !(i % 2 == 0));
|
|
51
|
+
|
|
52
|
+
return text;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
///
|
|
57
|
+
/// </summary>
|
|
58
|
+
/// <param name="text"></param>
|
|
59
|
+
/// <param name="isEndEncapsulationSymbol"></param>
|
|
60
|
+
/// <returns></returns>
|
|
61
|
+
/// <remarks></remarks>
|
|
62
|
+
protected virtual string TextColorInator(string text, bool isEndEncapsulationSymbol)
|
|
63
|
+
{
|
|
64
|
+
var regex = new Regex(Regex.Escape(encapsulateSymbol.ToString()));
|
|
65
|
+
|
|
66
|
+
string tagReplaceString = !isEndEncapsulationSymbol ? highlightTextStartTag : highlightTextEndTag;
|
|
67
|
+
|
|
68
|
+
return regex.Replace(text, tagReplaceString, 1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using TMPro;
|
|
3
|
+
|
|
4
|
+
namespace DREditor.TextDisplaying
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
///
|
|
8
|
+
/// </summary>
|
|
9
|
+
/// <remarks></remarks>
|
|
10
|
+
public interface ITextDisplayerHandler
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
/// <returns></returns>
|
|
16
|
+
TMP_Text GetTextBox();
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
void ClearText();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.EventObjects;
|
|
3
|
+
using TMPro;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.TextDisplaying
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
[ClassHeader("")]
|
|
12
|
+
public class OptionsTextMessage : MonoBehaviour
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[Tooltip("")]
|
|
18
|
+
[SerializeField] protected StringWithEvent optionsUIMessage = null;
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
///
|
|
22
|
+
/// </summary>
|
|
23
|
+
[Tooltip("")]
|
|
24
|
+
[SerializeField] protected TextMeshProUGUI box = null;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
///
|
|
29
|
+
/// </summary>
|
|
30
|
+
protected virtual void OnEnable() => optionsUIMessage.AddListener(PlayMessage);
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
///
|
|
34
|
+
/// </summary>
|
|
35
|
+
protected virtual void OnDisable() => optionsUIMessage.RemoveListener(PlayMessage);
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/// <summary>
|
|
39
|
+
///
|
|
40
|
+
/// </summary>
|
|
41
|
+
/// <param name="message"></param>
|
|
42
|
+
public virtual void PlayMessage(string message)
|
|
43
|
+
{
|
|
44
|
+
ClearBox();
|
|
45
|
+
|
|
46
|
+
box.text = message;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
///
|
|
51
|
+
/// </summary>
|
|
52
|
+
protected virtual void ClearBox() => box.text = "";
|
|
53
|
+
}
|
|
54
|
+
}
|