net.dreditor.textdisplaying 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.
Files changed (92) hide show
  1. package/.attestation.p7m +0 -0
  2. package/CGLineTextDisplayer.cs +12 -12
  3. package/CGLineTextDisplayer.cs.meta +11 -11
  4. package/ClearTextOnLineEnd.cs +17 -17
  5. package/ClearTextOnLineEnd.cs.meta +11 -11
  6. package/ColorByCharacterTextModifier.cs +45 -45
  7. package/ColorByCharacterTextModifier.cs.meta +11 -11
  8. package/DREditor.TextDisplaying.asmdef +19 -19
  9. package/DREditor.TextDisplaying.asmdef.meta +7 -7
  10. package/DialogueLineTextDisplayer.cs +187 -187
  11. package/DialogueLineTextDisplayer.cs.meta +11 -11
  12. package/DisplayFormattedString.cs +68 -68
  13. package/DisplayFormattedString.cs.meta +1 -1
  14. package/DisplayOwnedIntCurrency.cs +56 -56
  15. package/DisplayOwnedIntCurrency.cs.meta +1 -1
  16. package/HighlightTextModifier.cs +70 -70
  17. package/HighlightTextModifier.cs.meta +11 -11
  18. package/ITextDisplayerHandler.cs +22 -22
  19. package/ITextDisplayerHandler.cs.meta +11 -11
  20. package/OptionsTextMessage.cs +53 -53
  21. package/OptionsTextMessage.cs.meta +11 -11
  22. package/OptionsTextSpeedMessage.cs +82 -82
  23. package/OptionsTextSpeedMessage.cs.meta +11 -11
  24. package/RegexEscapeModifier.cs +43 -43
  25. package/RegexEscapeModifier.cs.meta +11 -11
  26. package/ReplaceGroup.cs +33 -33
  27. package/ReplaceGroup.cs.meta +11 -11
  28. package/ReplaceTextModifier.cs +53 -53
  29. package/ReplaceTextModifier.cs.meta +11 -11
  30. package/ReplaceTextModifierBase.cs +18 -18
  31. package/ReplaceTextModifierBase.cs.meta +11 -11
  32. package/{Samples → Samples~}/CGDialogueUIVisible.asset +21 -21
  33. package/{Samples → Samples~}/CGDialogueUIVisible.asset.meta +8 -8
  34. package/{Samples → Samples~}/CGTextBox.asset +21 -21
  35. package/{Samples → Samples~}/CGTextBox.asset.meta +8 -8
  36. package/{Samples → Samples~}/CG_Line_Text_Displayer.prefab +147 -147
  37. package/{Samples → Samples~}/CG_Line_Text_Displayer.prefab.meta +7 -7
  38. package/{Samples → Samples~}/Clear_Text_On_Line_End.prefab +46 -46
  39. package/{Samples → Samples~}/Clear_Text_On_Line_End.prefab.meta +7 -7
  40. package/{Samples → Samples~}/Color_By_Character_Text_Modifier.prefab +51 -51
  41. package/{Samples → Samples~}/Color_By_Character_Text_Modifier.prefab.meta +7 -7
  42. package/{Samples → Samples~}/DRE_TextDebugging.unity +492 -492
  43. package/{Samples → Samples~}/DRE_TextDebugging.unity.meta +7 -7
  44. package/{Samples → Samples~}/DialogueTextBox.asset +21 -21
  45. package/{Samples → Samples~}/DialogueTextBox.asset.meta +8 -8
  46. package/{Samples → Samples~}/Dialogue_Line_Text_Displayer.prefab +142 -142
  47. package/{Samples → Samples~}/Dialogue_Line_Text_Displayer.prefab.meta +7 -7
  48. package/{Samples → Samples~}/Highlight_Text_Modifier.prefab +49 -49
  49. package/{Samples → Samples~}/Highlight_Text_Modifier.prefab.meta +7 -7
  50. package/{Samples → Samples~}/Option_Message_UI_ETemplate.prefab +335 -335
  51. package/{Samples → Samples~}/Option_Message_UI_ETemplate.prefab.meta +7 -7
  52. package/{Samples → Samples~}/OptionsUITextSpeedMessage.asset +21 -21
  53. package/{Samples → Samples~}/OptionsUITextSpeedMessage.asset.meta +8 -8
  54. package/{Samples → Samples~}/Regex_Escape_Modifier.prefab +47 -47
  55. package/{Samples → Samples~}/Regex_Escape_Modifier.prefab.meta +7 -7
  56. package/{Samples → Samples~}/Replace_Text_Modifier.prefab +49 -49
  57. package/{Samples → Samples~}/Replace_Text_Modifier.prefab.meta +7 -7
  58. package/{Samples → Samples~}/Symbol_Color_Text_Modifier.prefab +50 -50
  59. package/{Samples → Samples~}/Symbol_Color_Text_Modifier.prefab.meta +7 -7
  60. package/{Samples → Samples~}/Symbol_Protag_UI_Modifier.prefab +48 -48
  61. package/{Samples → Samples~}/Symbol_Protag_UI_Modifier.prefab.meta +7 -7
  62. package/{Samples → Samples~}/Text_Display_Debugger.prefab +467 -467
  63. package/{Samples → Samples~}/Text_Display_Debugger.prefab.meta +7 -7
  64. package/{Samples → Samples~}/Text_Displayer.prefab +624 -624
  65. package/{Samples → Samples~}/Text_Displayer.prefab.meta +7 -7
  66. package/{Samples → Samples~}/TrialDialogueTextBox.asset +21 -21
  67. package/{Samples → Samples~}/TrialDialogueTextBox.asset.meta +8 -8
  68. package/{Samples → Samples~}/Trial_Dialogue_Line_Text_Displayer.prefab +82 -82
  69. package/{Samples → Samples~}/Trial_Dialogue_Line_Text_Displayer.prefab.meta +7 -7
  70. package/SetTextDisplaySpeed.cs +59 -59
  71. package/SetTextDisplaySpeed.cs.meta +11 -11
  72. package/SymbolColorTextModifier.cs +24 -24
  73. package/SymbolColorTextModifier.cs.meta +11 -11
  74. package/SymbolProtagUIModifier.cs +41 -41
  75. package/SymbolProtagUIModifier.cs.meta +11 -11
  76. package/SymbolTextModifier.cs +47 -47
  77. package/SymbolTextModifier.cs.meta +11 -11
  78. package/TMPMarquee.cs +177 -177
  79. package/TMPMarquee.cs.meta +11 -11
  80. package/TMPMarqueeBase.cs +103 -103
  81. package/TMPMarqueeBase.cs.meta +1 -1
  82. package/TextDisplayDebugger.cs +86 -86
  83. package/TextDisplayDebugger.cs.meta +11 -11
  84. package/TextDisplayModifier.cs +28 -28
  85. package/TextDisplayModifier.cs.meta +11 -11
  86. package/TextDisplayer.cs +254 -254
  87. package/TextDisplayer.cs.meta +11 -11
  88. package/TextDisplayerBase.cs +106 -106
  89. package/TextDisplayerBase.cs.meta +11 -11
  90. package/package.json +42 -37
  91. package/package.json.meta +7 -7
  92. package/Samples.meta +0 -8
package/TextDisplayer.cs CHANGED
@@ -1,255 +1,255 @@
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.Input;
6
- using DREditor.Services;
7
- using System.Collections;
8
- using System.Collections.Generic;
9
- using System.Linq;
10
- using System.Text.RegularExpressions;
11
- using TMPro;
12
- using UnityEngine;
13
- using UnityEngine.InputSystem;
14
-
15
- namespace DREditor.TextDisplaying
16
- {
17
- /// <summary>
18
- ///
19
- /// </summary>
20
- [ClassHeader(nameof(TextDisplayerBase) + ", " + nameof(IToTitleScreen) + ", " + nameof(ILineRoutine) +
21
- "\n\n")]
22
- public class TextDisplayer : TextDisplayerBase
23
- {
24
- /// <summary>
25
- ///
26
- /// </summary>
27
- [Tooltip("")]
28
- [SerializeField] protected InputActionReference submit = null;
29
-
30
- /// <summary>
31
- ///
32
- /// </summary>
33
- [Tooltip("")]
34
- [SerializeField] protected BoolWithEvent inTrialMode = null;
35
-
36
- /// <summary>
37
- ///
38
- /// </summary>
39
- [Tooltip("")]
40
- [SerializeField] protected BoolWithEvent inFastForwardMode = null;
41
-
42
- /// <summary>
43
- ///
44
- /// </summary>
45
- [Tooltip("")]
46
- [SerializeField] protected float bufferTextMultiplier = 0.01f;
47
-
48
-
49
- /// <summary>
50
- ///
51
- /// </summary>
52
- [Header("")]
53
- [Divider]
54
- [Tooltip("")]
55
- [SerializeField] protected List<TextDisplayModifier> textModifiers = new();
56
-
57
-
58
- /// <summary>
59
- ///
60
- /// </summary>
61
- protected bool skipText = false;
62
-
63
- /// <summary>
64
- ///
65
- /// </summary>
66
- protected bool skipTextStarted = false;
67
-
68
-
69
- /// <inheritdoc/>
70
- public override void DisplayText(TMP_Text textBox, Line line)
71
- {
72
- if (inFastForwardMode.Value)
73
- {
74
- InitializeTextBox(textBox);
75
-
76
- string preparedText = ApplyTextModifications(line);
77
-
78
- PrepareTextBox(preparedText);
79
-
80
- if (TextBoxIsEmpty(line))
81
- return;
82
-
83
- ResolveDisplayingText(preparedText);
84
- }
85
- else
86
- StartCoroutine(DisplayTextRoutine(textBox, line));
87
- }
88
-
89
- /// <summary>
90
- ///
91
- /// </summary>
92
- /// <param name="textBox"></param>
93
- /// <param name="currentLine"></param>
94
- /// <returns></returns>
95
- protected virtual IEnumerator DisplayTextRoutine(TMP_Text textBox, Line currentLine)
96
- {
97
- InitializeTextBox(textBox);
98
-
99
- string preparedText = ApplyTextModifications(currentLine);
100
-
101
- PrepareTextBox(preparedText);
102
-
103
- if (TextBoxIsEmpty(currentLine))
104
- yield break;
105
-
106
- yield return DisplayTextAnimation(preparedText);
107
-
108
- ResolveDisplayingText(preparedText);
109
- }
110
-
111
- /// <summary>
112
- ///
113
- /// </summary>
114
- /// <param name="textBox"></param>
115
- protected virtual void InitializeTextBox(TMP_Text textBox)
116
- {
117
- box = textBox;
118
-
119
- skipText = false;
120
- }
121
-
122
- /// <summary>
123
- ///
124
- /// </summary>
125
- /// <param name="preparedText"></param>
126
- protected virtual void PrepareTextBox(string preparedText)
127
- {
128
- box.maxVisibleCharacters = 0;
129
-
130
- box.text = preparedText;
131
- }
132
-
133
- /// <summary>
134
- ///
135
- /// </summary>
136
- /// <param name="currentLine"></param>
137
- /// <returns></returns>
138
- protected virtual bool TextBoxIsEmpty(Line currentLine)
139
- {
140
- bool result = string.IsNullOrEmpty(box.text) || SkipDisplayingLine(currentLine);
141
-
142
- if (result)
143
- {
144
- SetWaitingForClick(false);
145
-
146
- ServiceLocator.GetService<IInputManager>().Disable();
147
-
148
- inFastForwardMode.SetValue(true);
149
-
150
- ServiceLocator.GetService<IDialogueManager>()
151
- .GetComponentsInChildren<MonoBehaviour>()
152
- .OfType<ILineReader>()
153
- .FirstOrDefault().OnLineEndEvent += OnLineSkipped;
154
- }
155
-
156
- return result;
157
- }
158
-
159
- /// <summary>
160
- ///
161
- /// </summary>
162
- protected virtual void OnLineSkipped()
163
- {
164
- ServiceLocator.GetService<IDialogueManager>()
165
- .GetComponentsInChildren<MonoBehaviour>()
166
- .OfType<ILineReader>()
167
- .FirstOrDefault().OnLineEndEvent -= OnLineSkipped;
168
-
169
- inFastForwardMode.SetValue(false);
170
-
171
- ServiceLocator.GetService<IInputManager>().Enable();
172
- }
173
-
174
- /// <summary>
175
- ///
176
- /// </summary>
177
- /// <param name="currentLine"></param>
178
- /// <returns></returns>
179
- protected virtual string ApplyTextModifications(Line currentLine)
180
- {
181
- string preparedText = currentLine.Text;
182
-
183
- foreach (var modifier in textModifiers)
184
- preparedText = modifier.ApplyModification(preparedText, currentLine, box);
185
-
186
- return preparedText;
187
- }
188
-
189
- /// <summary>
190
- ///
191
- /// </summary>
192
- /// <param name="preparedText"></param>
193
- /// <returns></returns>
194
- protected virtual IEnumerator DisplayTextAnimation(string preparedText)
195
- {
196
- string textWithoutHTMLTags = Regex.Replace(preparedText, "<.*?>", string.Empty);
197
-
198
- for (int i = 0; i < textWithoutHTMLTags.Length && !skipText; i++)
199
- {
200
- if (i == 1 && !skipTextStarted)
201
- StartCoroutine(SkipText());
202
-
203
- box.maxVisibleCharacters = i;
204
-
205
- if (!inFastForwardMode.Value)
206
- yield return new WaitForSecondsRealtime(textDisplaySpeed * bufferTextMultiplier);
207
- }
208
-
209
- box.maxVisibleCharacters += 1;
210
- }
211
-
212
- /// <summary>
213
- ///
214
- /// </summary>
215
- /// <returns></returns>
216
- protected virtual IEnumerator SkipText()
217
- {
218
- skipTextStarted = true;
219
-
220
- while (IsWaitingForClick())
221
- if (submit.action.triggered || inFastForwardMode.Value)
222
- break;
223
- else
224
- yield return null;
225
-
226
- skipTextStarted = false;
227
-
228
- skipText = true;
229
- }
230
-
231
- /// <inheritdoc/>
232
- public override bool ShouldProcess(Line currentLine)
233
- {
234
- foreach (var modifier in textModifiers)
235
- if (modifier is ILineRoutine routineCheck && routineCheck.ShouldProcess(currentLine))
236
- return true;
237
-
238
- return false;
239
- }
240
-
241
- /// <summary>
242
- ///
243
- /// </summary>
244
- /// <param name="currentLine"></param>
245
- /// <returns></returns>
246
- protected virtual bool SkipDisplayingLine(Line currentLine)
247
- {
248
- foreach (var modifier in textModifiers)
249
- if (modifier.SkipLine(currentLine))
250
- return true;
251
-
252
- return false;
253
- }
254
- }
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.Input;
6
+ using DREditor.Services;
7
+ using System.Collections;
8
+ using System.Collections.Generic;
9
+ using System.Linq;
10
+ using System.Text.RegularExpressions;
11
+ using TMPro;
12
+ using UnityEngine;
13
+ using UnityEngine.InputSystem;
14
+
15
+ namespace DREditor.TextDisplaying
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [ClassHeader(nameof(TextDisplayerBase) + ", " + nameof(IToTitleScreen) + ", " + nameof(ILineRoutine) +
21
+ "\n\n")]
22
+ public class TextDisplayer : TextDisplayerBase
23
+ {
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ [Tooltip("")]
28
+ [SerializeField] protected InputActionReference submit = null;
29
+
30
+ /// <summary>
31
+ ///
32
+ /// </summary>
33
+ [Tooltip("")]
34
+ [SerializeField] protected BoolWithEvent inTrialMode = null;
35
+
36
+ /// <summary>
37
+ ///
38
+ /// </summary>
39
+ [Tooltip("")]
40
+ [SerializeField] protected BoolWithEvent inFastForwardMode = null;
41
+
42
+ /// <summary>
43
+ ///
44
+ /// </summary>
45
+ [Tooltip("")]
46
+ [SerializeField] protected float bufferTextMultiplier = 0.01f;
47
+
48
+
49
+ /// <summary>
50
+ ///
51
+ /// </summary>
52
+ [Header("")]
53
+ [Divider]
54
+ [Tooltip("")]
55
+ [SerializeField] protected List<TextDisplayModifier> textModifiers = new();
56
+
57
+
58
+ /// <summary>
59
+ ///
60
+ /// </summary>
61
+ protected bool skipText = false;
62
+
63
+ /// <summary>
64
+ ///
65
+ /// </summary>
66
+ protected bool skipTextStarted = false;
67
+
68
+
69
+ /// <inheritdoc/>
70
+ public override void DisplayText(TMP_Text textBox, Line line)
71
+ {
72
+ if (inFastForwardMode.Value)
73
+ {
74
+ InitializeTextBox(textBox);
75
+
76
+ string preparedText = ApplyTextModifications(line);
77
+
78
+ PrepareTextBox(preparedText);
79
+
80
+ if (TextBoxIsEmpty(line))
81
+ return;
82
+
83
+ ResolveDisplayingText(preparedText);
84
+ }
85
+ else
86
+ StartCoroutine(DisplayTextRoutine(textBox, line));
87
+ }
88
+
89
+ /// <summary>
90
+ ///
91
+ /// </summary>
92
+ /// <param name="textBox"></param>
93
+ /// <param name="currentLine"></param>
94
+ /// <returns></returns>
95
+ protected virtual IEnumerator DisplayTextRoutine(TMP_Text textBox, Line currentLine)
96
+ {
97
+ InitializeTextBox(textBox);
98
+
99
+ string preparedText = ApplyTextModifications(currentLine);
100
+
101
+ PrepareTextBox(preparedText);
102
+
103
+ if (TextBoxIsEmpty(currentLine))
104
+ yield break;
105
+
106
+ yield return DisplayTextAnimation(preparedText);
107
+
108
+ ResolveDisplayingText(preparedText);
109
+ }
110
+
111
+ /// <summary>
112
+ ///
113
+ /// </summary>
114
+ /// <param name="textBox"></param>
115
+ protected virtual void InitializeTextBox(TMP_Text textBox)
116
+ {
117
+ box = textBox;
118
+
119
+ skipText = false;
120
+ }
121
+
122
+ /// <summary>
123
+ ///
124
+ /// </summary>
125
+ /// <param name="preparedText"></param>
126
+ protected virtual void PrepareTextBox(string preparedText)
127
+ {
128
+ box.maxVisibleCharacters = 0;
129
+
130
+ box.text = preparedText;
131
+ }
132
+
133
+ /// <summary>
134
+ ///
135
+ /// </summary>
136
+ /// <param name="currentLine"></param>
137
+ /// <returns></returns>
138
+ protected virtual bool TextBoxIsEmpty(Line currentLine)
139
+ {
140
+ bool result = string.IsNullOrEmpty(box.text) || SkipDisplayingLine(currentLine);
141
+
142
+ if (result)
143
+ {
144
+ SetWaitingForClick(false);
145
+
146
+ ServiceLocator.GetService<IInputManager>().Disable();
147
+
148
+ inFastForwardMode.SetValue(true);
149
+
150
+ ServiceLocator.GetService<IDialogueManager>()
151
+ .GetComponentsInChildren<MonoBehaviour>()
152
+ .OfType<ILineReader>()
153
+ .FirstOrDefault().OnLineEndEvent += OnLineSkipped;
154
+ }
155
+
156
+ return result;
157
+ }
158
+
159
+ /// <summary>
160
+ ///
161
+ /// </summary>
162
+ protected virtual void OnLineSkipped()
163
+ {
164
+ ServiceLocator.GetService<IDialogueManager>()
165
+ .GetComponentsInChildren<MonoBehaviour>()
166
+ .OfType<ILineReader>()
167
+ .FirstOrDefault().OnLineEndEvent -= OnLineSkipped;
168
+
169
+ inFastForwardMode.SetValue(false);
170
+
171
+ ServiceLocator.GetService<IInputManager>().Enable();
172
+ }
173
+
174
+ /// <summary>
175
+ ///
176
+ /// </summary>
177
+ /// <param name="currentLine"></param>
178
+ /// <returns></returns>
179
+ protected virtual string ApplyTextModifications(Line currentLine)
180
+ {
181
+ string preparedText = currentLine.Text;
182
+
183
+ foreach (var modifier in textModifiers)
184
+ preparedText = modifier.ApplyModification(preparedText, currentLine, box);
185
+
186
+ return preparedText;
187
+ }
188
+
189
+ /// <summary>
190
+ ///
191
+ /// </summary>
192
+ /// <param name="preparedText"></param>
193
+ /// <returns></returns>
194
+ protected virtual IEnumerator DisplayTextAnimation(string preparedText)
195
+ {
196
+ string textWithoutHTMLTags = Regex.Replace(preparedText, "<.*?>", string.Empty);
197
+
198
+ for (int i = 0; i < textWithoutHTMLTags.Length && !skipText; i++)
199
+ {
200
+ if (i == 1 && !skipTextStarted)
201
+ StartCoroutine(SkipText());
202
+
203
+ box.maxVisibleCharacters = i;
204
+
205
+ if (!inFastForwardMode.Value)
206
+ yield return new WaitForSecondsRealtime(textDisplaySpeed * bufferTextMultiplier);
207
+ }
208
+
209
+ box.maxVisibleCharacters += 1;
210
+ }
211
+
212
+ /// <summary>
213
+ ///
214
+ /// </summary>
215
+ /// <returns></returns>
216
+ protected virtual IEnumerator SkipText()
217
+ {
218
+ skipTextStarted = true;
219
+
220
+ while (IsWaitingForClick())
221
+ if (submit.action.triggered || inFastForwardMode.Value)
222
+ break;
223
+ else
224
+ yield return null;
225
+
226
+ skipTextStarted = false;
227
+
228
+ skipText = true;
229
+ }
230
+
231
+ /// <inheritdoc/>
232
+ public override bool ShouldProcess(Line currentLine)
233
+ {
234
+ foreach (var modifier in textModifiers)
235
+ if (modifier is ILineRoutine routineCheck && routineCheck.ShouldProcess(currentLine))
236
+ return true;
237
+
238
+ return false;
239
+ }
240
+
241
+ /// <summary>
242
+ ///
243
+ /// </summary>
244
+ /// <param name="currentLine"></param>
245
+ /// <returns></returns>
246
+ protected virtual bool SkipDisplayingLine(Line currentLine)
247
+ {
248
+ foreach (var modifier in textModifiers)
249
+ if (modifier.SkipLine(currentLine))
250
+ return true;
251
+
252
+ return false;
253
+ }
254
+ }
255
255
  }
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: f3492cdc359150243afb2bdc3571069f
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: f3492cdc359150243afb2bdc3571069f
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: