com.wallstop-studios.dxmessaging 3.1.0 → 3.2.1

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 (139) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/Editor/Analyzers/BaseCallLogMessageParser.cs.meta +3 -3
  3. package/Editor/Analyzers/BaseCallReportAggregator.cs.meta +3 -3
  4. package/Editor/Analyzers/DxMessagingConsoleHarvester.cs +8 -8
  5. package/Editor/Analyzers/DxMessagingConsoleHarvester.cs.meta +3 -3
  6. package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs +171 -13
  7. package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs.meta +3 -3
  8. package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs +391 -96
  9. package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs.meta +3 -3
  10. package/Editor/CustomEditors/MessageAwareComponentInspectorView.cs +279 -0
  11. package/Editor/CustomEditors/MessageAwareComponentInspectorView.cs.meta +11 -0
  12. package/Editor/DxMessagingEditorPalette.cs +66 -0
  13. package/Editor/DxMessagingEditorPalette.cs.meta +11 -0
  14. package/Editor/DxMessagingEditorTheme.cs +200 -0
  15. package/Editor/DxMessagingEditorTheme.cs.meta +11 -0
  16. package/Editor/DxMessagingMenu.cs.meta +3 -3
  17. package/Editor/DxMessagingSceneBuildProcessor.cs.meta +3 -3
  18. package/Editor/Icons/dxmessaging-icon-256.png +0 -0
  19. package/Editor/Icons/dxmessaging-icon-256.png.meta +156 -0
  20. package/Editor/Icons/dxmessaging-icon-32.png +0 -0
  21. package/Editor/Icons/dxmessaging-icon-32.png.meta +156 -0
  22. package/Editor/Icons/dxmessaging-icon-48.png +0 -0
  23. package/Editor/Icons/dxmessaging-icon-48.png.meta +156 -0
  24. package/Editor/Icons.meta +8 -0
  25. package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs +2 -3
  26. package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs.meta +3 -3
  27. package/Editor/Settings/DxMessagingSettingsProvider.cs +368 -33
  28. package/Editor/SetupCscRsp.cs +232 -163
  29. package/Editor/Testing/MessagingComponentEditorHarness.cs +11 -4
  30. package/Editor/Theme/DxMessagingTheme.uss +255 -0
  31. package/Editor/Theme/DxMessagingTheme.uss.meta +11 -0
  32. package/Editor/Theme/DxTokens.uss +90 -0
  33. package/Editor/Theme/DxTokens.uss.meta +11 -0
  34. package/Editor/Theme.meta +8 -0
  35. package/Editor/Windows/DxMessagingFlowGraphWindow.cs +5513 -0
  36. package/Editor/Windows/DxMessagingFlowGraphWindow.cs.meta +11 -0
  37. package/Editor/Windows/DxMessagingMessageMonitorWindow.cs +2288 -0
  38. package/Editor/Windows/DxMessagingMessageMonitorWindow.cs.meta +11 -0
  39. package/Editor/Windows.meta +8 -0
  40. package/README.md +84 -35
  41. package/Runtime/Analyzers.meta +8 -0
  42. package/Runtime/AssemblyInfo.cs +1 -0
  43. package/Runtime/Core/Attributes/DxIgnoreMissingBaseCallAttribute.cs.meta +3 -3
  44. package/Runtime/Core/Diagnostics/MessageEmissionData.cs +29 -1
  45. package/Runtime/Core/DxMessagingStaticState.cs.meta +3 -3
  46. package/Runtime/Core/Extensions/MessageBusExtensions.cs.meta +3 -3
  47. package/Runtime/Core/Extensions/MessageExtensions.cs +4 -5
  48. package/Runtime/Core/Extensions/MessageExtensions.cs.meta +3 -3
  49. package/Runtime/Core/Helper/MessageCache.cs +56 -23
  50. package/Runtime/Core/IMessage.cs.meta +3 -3
  51. package/Runtime/Core/InstanceId.cs.meta +3 -3
  52. package/Runtime/Core/Internal/FlatDispatch.cs +32 -0
  53. package/Runtime/Core/Internal/TypedSlots.cs +45 -7
  54. package/Runtime/Core/MessageBus/DiagnosticsTarget.cs.meta +3 -3
  55. package/Runtime/Core/MessageBus/GlobalMessageBusProvider.cs.meta +3 -3
  56. package/Runtime/Core/MessageBus/IMessageBus.cs +63 -28
  57. package/Runtime/Core/MessageBus/IMessageBus.cs.meta +3 -3
  58. package/Runtime/Core/MessageBus/IMessageBusProvider.cs.meta +3 -3
  59. package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs.meta +3 -3
  60. package/Runtime/Core/MessageBus/MessageBus.cs +1135 -626
  61. package/Runtime/Core/MessageBus/MessageBus.cs.meta +3 -3
  62. package/Runtime/Core/MessageBus/MessageBusRebindMode.cs.meta +3 -3
  63. package/Runtime/Core/MessageBus/MessageBusRegistration.cs +207 -0
  64. package/Runtime/Core/MessageBus/MessageBusRegistration.cs.meta +11 -0
  65. package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs.meta +3 -3
  66. package/Runtime/Core/MessageBus/MessagingRegistration.cs.meta +3 -3
  67. package/Runtime/Core/MessageBus/RegistrationLog.cs +25 -12
  68. package/Runtime/Core/MessageBus/RegistrationLog.cs.meta +3 -3
  69. package/Runtime/Core/MessageHandler.cs +1886 -1082
  70. package/Runtime/Core/MessageHandler.cs.meta +3 -3
  71. package/Runtime/Core/MessageRegistrationHandle.cs +19 -5
  72. package/Runtime/Core/MessageRegistrationHandle.cs.meta +3 -3
  73. package/Runtime/Core/MessageRegistrationToken.cs +1932 -895
  74. package/Runtime/Core/MessageRegistrationToken.cs.meta +3 -3
  75. package/Runtime/Core/Messages/IBroadcastMessage.cs.meta +3 -3
  76. package/Runtime/Core/Messages/ITargetedMessage.cs.meta +3 -3
  77. package/Runtime/Core/Messages/IUntargetedMessage.cs.meta +3 -3
  78. package/Runtime/Core/Messages/SourcedStringMessage.cs.meta +3 -3
  79. package/Runtime/Core/MessagingDebug.cs.meta +3 -3
  80. package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs.meta +3 -3
  81. package/Runtime/Unity/DxMessagingRuntimeInitializer.cs.meta +3 -3
  82. package/Runtime/Unity/InitialGlobalMessageBusProvider.cs.meta +3 -3
  83. package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs.meta +3 -3
  84. package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs.meta +3 -3
  85. package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs.meta +3 -3
  86. package/Runtime/Unity/MessageAwareComponent.cs.meta +3 -3
  87. package/Runtime/Unity/MessageBusProviderHandle.cs.meta +3 -3
  88. package/Runtime/Unity/MessagingComponent.cs.meta +3 -3
  89. package/Runtime/Unity/MessagingComponentInstaller.cs.meta +3 -3
  90. package/Runtime/Unity/ScriptableMessageBusProvider.cs.meta +3 -3
  91. package/Samples~/DI/Reflex/SampleInstaller.cs.meta +3 -3
  92. package/Samples~/DI/VContainer/SampleLifetimeScope.cs.meta +3 -3
  93. package/Samples~/DI/Zenject/SampleInstaller.cs.meta +3 -3
  94. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.cs +173 -0
  95. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.cs.meta +11 -0
  96. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.unity +424 -0
  97. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.unity.meta +7 -0
  98. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingReceiver.cs +185 -0
  99. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingReceiver.cs.meta +11 -0
  100. package/Samples~/Diagnostics Tooling Exerciser/Messages.cs +46 -0
  101. package/Samples~/Diagnostics Tooling Exerciser/Messages.cs.meta +11 -0
  102. package/Samples~/Diagnostics Tooling Exerciser/README.md +53 -0
  103. package/Samples~/Diagnostics Tooling Exerciser/README.md.meta +7 -0
  104. package/Samples~/Diagnostics Tooling Exerciser/WallstopStudios.DxMessaging.DiagnosticsToolingExerciser.Sample.asmdef +13 -0
  105. package/Samples~/Diagnostics Tooling Exerciser/WallstopStudios.DxMessaging.DiagnosticsToolingExerciser.Sample.asmdef.meta +7 -0
  106. package/Samples~/Diagnostics Tooling Exerciser.meta +8 -0
  107. package/Samples~/Mini Combat/Boot.cs.meta +3 -3
  108. package/Samples~/Mini Combat/Enemy.cs.meta +3 -3
  109. package/Samples~/Mini Combat/Messages.cs.meta +3 -3
  110. package/Samples~/Mini Combat/Player.cs.meta +3 -3
  111. package/Samples~/Mini Combat/README.md +1 -1
  112. package/Samples~/Mini Combat/UIOverlay.cs.meta +3 -3
  113. package/Samples~/Mini Combat/Walkthrough.md +3 -3
  114. package/Samples~/UI Buttons + Inspector/DiagnosticsEnabler.cs.meta +3 -3
  115. package/Samples~/UI Buttons + Inspector/Messages.cs.meta +3 -3
  116. package/Samples~/UI Buttons + Inspector/MessagingObserver.cs.meta +3 -3
  117. package/Samples~/UI Buttons + Inspector/UIButtonEmitter.cs.meta +3 -3
  118. package/SourceGenerators/Directory.Build.props +5 -5
  119. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs.meta +3 -3
  120. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj +12 -11
  121. package/docs/images/DxMessaging-banner.svg +79 -0
  122. package/docs/images/DxMessaging-banner.svg.meta +53 -0
  123. package/docs/images.meta +8 -0
  124. package/docs.meta +8 -0
  125. package/package.json +17 -5
  126. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  127. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll.meta +0 -0
  128. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll +0 -0
  129. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll.meta +0 -0
  130. /package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll +0 -0
  131. /package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll.meta +0 -0
  132. /package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll +0 -0
  133. /package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll.meta +0 -0
  134. /package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  135. /package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll.meta +0 -0
  136. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll +0 -0
  137. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll.meta +0 -0
  138. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
  139. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll.meta +0 -0
@@ -0,0 +1,279 @@
1
+ namespace DxMessaging.Editor.CustomEditors
2
+ {
3
+ #if UNITY_EDITOR
4
+ using System;
5
+ using DxMessaging.Editor;
6
+ using DxMessaging.Editor.Analyzers;
7
+ using UnityEngine;
8
+ using UnityEngine.UIElements;
9
+
10
+ internal static class MessageAwareComponentInspectorView
11
+ {
12
+ internal const string RootName = "dxmessaging-inspector-warning";
13
+ internal const string TitleLabelName = "dxmessaging-inspector-warning-title";
14
+ internal const string BodyLabelName = "dxmessaging-inspector-warning-body";
15
+ internal const string MethodListName = "dxmessaging-inspector-warning-methods";
16
+ internal const string StaleCacheNoteName = "dxmessaging-inspector-warning-stale-note";
17
+ internal const string OpenScriptButtonName = "dxmessaging-inspector-warning-open-script";
18
+ internal const string IgnoreTypeButtonName = "dxmessaging-inspector-warning-ignore-type";
19
+ internal const string StopIgnoringButtonName =
20
+ "dxmessaging-inspector-warning-stop-ignoring";
21
+
22
+ internal const string RootClassName = "dxmessaging-inspector-warning";
23
+ internal const string StateNoneClassName = "dxmessaging-inspector-warning--none";
24
+ internal const string StateInfoClassName = "dxmessaging-inspector-warning--info";
25
+ internal const string StateWarningClassName = "dxmessaging-inspector-warning--warning";
26
+ internal const string TitleClassName = "dxmessaging-inspector-warning__title";
27
+ internal const string BodyClassName = "dxmessaging-inspector-warning__body";
28
+ internal const string MethodListClassName = "dxmessaging-inspector-warning__methods";
29
+ internal const string MethodClassName = "dxmessaging-inspector-warning__method";
30
+ internal const string StaleCacheNoteClassName = "dxmessaging-inspector-warning__stale-note";
31
+ internal const string ActionRowClassName = "dxmessaging-inspector-warning__actions";
32
+ internal const string ActionButtonClassName = "dxmessaging-inspector-warning__button";
33
+
34
+ private static readonly Color InfoColor = DxMessagingEditorPalette.Untargeted;
35
+ private static readonly Color WarningColor = DxMessagingEditorPalette.Amber;
36
+
37
+ internal static VisualElement Create(
38
+ MessageAwareComponentInspectorState state,
39
+ MessageAwareComponentInspectorViewActions actions
40
+ )
41
+ {
42
+ VisualElement root = CreateRoot(state);
43
+ switch (state.Kind)
44
+ {
45
+ case MessageAwareComponentInspectorStateKind.None:
46
+ return root;
47
+ case MessageAwareComponentInspectorStateKind.HarvesterUnavailable:
48
+ PopulateInfo(
49
+ root,
50
+ "Inspector overlay unavailable",
51
+ "DxMessaging inspector overlay is disabled on this Unity version. Check the console for DXMSG006/007/009 warnings instead.",
52
+ InfoColor
53
+ );
54
+ return root;
55
+ case MessageAwareComponentInspectorStateKind.IgnoredType:
56
+ PopulateInfo(
57
+ root,
58
+ "Base-call check ignored",
59
+ $"{state.FullName} is excluded from the DxMessaging base-call check.",
60
+ InfoColor
61
+ );
62
+ AddActionRow(
63
+ root,
64
+ CreateActionButton(
65
+ StopIgnoringButtonName,
66
+ "Stop ignoring",
67
+ actions.OnStopIgnoring,
68
+ state
69
+ )
70
+ );
71
+ return root;
72
+ case MessageAwareComponentInspectorStateKind.MissingBaseCallWarning:
73
+ PopulateWarning(root, state, actions);
74
+ return root;
75
+ default:
76
+ return root;
77
+ }
78
+ }
79
+
80
+ private static VisualElement CreateRoot(MessageAwareComponentInspectorState state)
81
+ {
82
+ VisualElement root = new() { name = RootName };
83
+ DxMessagingEditorTheme.Apply(root);
84
+ root.AddToClassList(RootClassName);
85
+ root.style.marginTop = 6;
86
+ root.style.marginBottom = 6;
87
+
88
+ switch (state.Kind)
89
+ {
90
+ case MessageAwareComponentInspectorStateKind.None:
91
+ root.AddToClassList(StateNoneClassName);
92
+ break;
93
+ case MessageAwareComponentInspectorStateKind.MissingBaseCallWarning:
94
+ root.AddToClassList(StateWarningClassName);
95
+ break;
96
+ default:
97
+ root.AddToClassList(StateInfoClassName);
98
+ break;
99
+ }
100
+
101
+ return root;
102
+ }
103
+
104
+ private static void PopulateInfo(
105
+ VisualElement root,
106
+ string titleText,
107
+ string bodyText,
108
+ Color borderColor
109
+ )
110
+ {
111
+ ConfigurePanel(root, borderColor);
112
+ root.AddToClassList(DxMessagingEditorTheme.AdmonitionClassName);
113
+ root.AddToClassList(DxMessagingEditorTheme.NoteClassName);
114
+ root.Add(CreateLabel(TitleLabelName, TitleClassName, titleText, bold: true));
115
+ root.Add(CreateLabel(BodyLabelName, BodyClassName, bodyText, bold: false));
116
+ }
117
+
118
+ private static void PopulateWarning(
119
+ VisualElement root,
120
+ MessageAwareComponentInspectorState state,
121
+ MessageAwareComponentInspectorViewActions actions
122
+ )
123
+ {
124
+ ConfigurePanel(root, WarningColor);
125
+ root.AddToClassList(DxMessagingEditorTheme.AdmonitionClassName);
126
+ root.AddToClassList(DxMessagingEditorTheme.WarningClassName);
127
+ root.Add(
128
+ CreateLabel(
129
+ TitleLabelName,
130
+ TitleClassName,
131
+ "Missing MessageAwareComponent base calls",
132
+ bold: true
133
+ )
134
+ );
135
+ root.Add(
136
+ CreateLabel(
137
+ BodyLabelName,
138
+ BodyClassName,
139
+ $"{state.FullName} has lifecycle methods that do not chain to MessageAwareComponent. DxMessaging will not function on this component. See docs/reference/analyzers.md.",
140
+ bold: false
141
+ )
142
+ );
143
+ root.Add(CreateMethodList(state));
144
+
145
+ if (!state.IsFreshThisSession)
146
+ {
147
+ root.Add(
148
+ CreateLabel(
149
+ StaleCacheNoteName,
150
+ StaleCacheNoteClassName,
151
+ "Report is cached from previous session; refreshing...",
152
+ bold: false
153
+ )
154
+ );
155
+ }
156
+
157
+ AddActionRow(
158
+ root,
159
+ CreateActionButton(
160
+ OpenScriptButtonName,
161
+ "Open Script",
162
+ actions.OnOpenScript,
163
+ state
164
+ ),
165
+ CreateActionButton(
166
+ IgnoreTypeButtonName,
167
+ "Ignore this type",
168
+ actions.OnIgnoreType,
169
+ state
170
+ )
171
+ );
172
+ }
173
+
174
+ private static void ConfigurePanel(VisualElement root, Color borderColor)
175
+ {
176
+ DxMessagingEditorTheme.ApplyCompleteBorder(root, borderColor);
177
+ root.style.paddingTop = 8;
178
+ root.style.paddingRight = 10;
179
+ root.style.paddingBottom = 8;
180
+ root.style.paddingLeft = 10;
181
+ }
182
+
183
+ private static Label CreateLabel(string name, string className, string text, bool bold)
184
+ {
185
+ Label label = new(text) { name = name };
186
+ label.AddToClassList(className);
187
+ label.style.whiteSpace = WhiteSpace.Normal;
188
+ if (bold)
189
+ {
190
+ label.style.unityFontStyleAndWeight = FontStyle.Bold;
191
+ }
192
+ return label;
193
+ }
194
+
195
+ private static VisualElement CreateMethodList(MessageAwareComponentInspectorState state)
196
+ {
197
+ VisualElement methodList = new() { name = MethodListName };
198
+ methodList.AddToClassList(MethodListClassName);
199
+ methodList.style.marginTop = 5;
200
+
201
+ if (state.Entry == null || state.Entry.missingBaseFor == null)
202
+ {
203
+ return methodList;
204
+ }
205
+
206
+ foreach (string missingMethod in state.Entry.missingBaseFor)
207
+ {
208
+ Label method = CreateLabel(
209
+ name: null,
210
+ className: MethodClassName,
211
+ text: $"{missingMethod}: {BaseCallTypeScannerCore.GetMissingBaseConsequenceLine(missingMethod, state.FullName)}",
212
+ bold: false
213
+ );
214
+ method.style.marginTop = 2;
215
+ methodList.Add(method);
216
+ }
217
+
218
+ return methodList;
219
+ }
220
+
221
+ private static Button CreateActionButton(
222
+ string name,
223
+ string text,
224
+ Action<MessageAwareComponentInspectorState> action,
225
+ MessageAwareComponentInspectorState state
226
+ )
227
+ {
228
+ Button button = new() { name = name, text = text };
229
+ button.AddToClassList(ActionButtonClassName);
230
+ button.AddToClassList(DxMessagingEditorTheme.ButtonGhostClassName);
231
+ if (action != null)
232
+ {
233
+ button.RegisterCallback<ClickEvent>(_ => action.Invoke(state));
234
+ }
235
+ button.SetEnabled(action != null);
236
+ return button;
237
+ }
238
+
239
+ private static void AddActionRow(VisualElement root, params Button[] buttons)
240
+ {
241
+ VisualElement row = new();
242
+ row.AddToClassList(ActionRowClassName);
243
+ row.style.flexDirection = FlexDirection.Row;
244
+ row.style.marginTop = 7;
245
+
246
+ foreach (Button button in buttons)
247
+ {
248
+ button.style.marginRight = 6;
249
+ row.Add(button);
250
+ }
251
+
252
+ root.Add(row);
253
+ }
254
+ }
255
+
256
+ internal readonly struct MessageAwareComponentInspectorViewActions
257
+ {
258
+ internal MessageAwareComponentInspectorViewActions(
259
+ Action<MessageAwareComponentInspectorState> onOpenScript,
260
+ Action<MessageAwareComponentInspectorState> onIgnoreType,
261
+ Action<MessageAwareComponentInspectorState> onStopIgnoring
262
+ )
263
+ {
264
+ OnOpenScript = onOpenScript;
265
+ OnIgnoreType = onIgnoreType;
266
+ OnStopIgnoring = onStopIgnoring;
267
+ }
268
+
269
+ internal static MessageAwareComponentInspectorViewActions None { get; } =
270
+ new(onOpenScript: null, onIgnoreType: null, onStopIgnoring: null);
271
+
272
+ internal Action<MessageAwareComponentInspectorState> OnOpenScript { get; }
273
+
274
+ internal Action<MessageAwareComponentInspectorState> OnIgnoreType { get; }
275
+
276
+ internal Action<MessageAwareComponentInspectorState> OnStopIgnoring { get; }
277
+ }
278
+ #endif
279
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 7d6bd0a3d2954c51b8c017f57a7955a1
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,66 @@
1
+ #if UNITY_EDITOR
2
+ namespace DxMessaging.Editor
3
+ {
4
+ using System;
5
+ using UnityEngine;
6
+
7
+ internal static class DxMessagingEditorPalette
8
+ {
9
+ internal static readonly Color Amber = FromHex(0xf4, 0xa8, 0x36);
10
+ internal static readonly Color AmberSoft = FromHex(0xff, 0xd4, 0x8e);
11
+ internal static readonly Color Untargeted = FromHex(0x7f, 0xa6, 0xd8);
12
+ internal static readonly Color Targeted = FromHex(0xec, 0x46, 0x61);
13
+ internal static readonly Color Broadcast = FromHex(0x7f, 0xb8, 0x8a);
14
+ internal static readonly Color Trace = FromHex(0x7f, 0xa6, 0xd8);
15
+ internal static readonly Color TraceMessage = FromHex(0x7f, 0xb8, 0x8a);
16
+ internal static readonly Color TraceTarget = FromHex(0xff, 0xd4, 0x8e);
17
+ internal static readonly Color BorderSoft = new(0.14f, 0.17f, 0.22f, 0.32f);
18
+ internal static readonly Color Border = new(0.14f, 0.17f, 0.22f, 0.38f);
19
+ internal static readonly Color BorderPanel = new(0.14f, 0.17f, 0.22f, 0.42f);
20
+ internal static readonly Color BorderStrong = new(0.14f, 0.17f, 0.22f, 0.52f);
21
+ internal static readonly Color SelectedWash = new(0.96f, 0.66f, 0.21f, 0.1f);
22
+
23
+ internal const string UntargetedKind = "Untargeted";
24
+ internal const string TargetedKind = "Targeted";
25
+ internal const string BroadcastKind = "Broadcast";
26
+
27
+ internal static Color RouteKindColor(string routeKind)
28
+ {
29
+ switch (NormalizeRouteKind(routeKind))
30
+ {
31
+ case UntargetedKind:
32
+ return Untargeted;
33
+ case TargetedKind:
34
+ return Targeted;
35
+ case BroadcastKind:
36
+ return Broadcast;
37
+ default:
38
+ return Amber;
39
+ }
40
+ }
41
+
42
+ internal static string NormalizeRouteKind(string routeKind)
43
+ {
44
+ string value = string.IsNullOrWhiteSpace(routeKind) ? string.Empty : routeKind.Trim();
45
+ if (value.StartsWith(UntargetedKind, StringComparison.Ordinal))
46
+ {
47
+ return UntargetedKind;
48
+ }
49
+ if (value.StartsWith(TargetedKind, StringComparison.Ordinal))
50
+ {
51
+ return TargetedKind;
52
+ }
53
+ if (value.StartsWith(BroadcastKind, StringComparison.Ordinal))
54
+ {
55
+ return BroadcastKind;
56
+ }
57
+ return string.Empty;
58
+ }
59
+
60
+ private static Color FromHex(byte red, byte green, byte blue)
61
+ {
62
+ return new Color(red / 255f, green / 255f, blue / 255f, 1f);
63
+ }
64
+ }
65
+ }
66
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a7e3720a22a0ca67c818278d404071e2
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,200 @@
1
+ #if UNITY_EDITOR
2
+ namespace DxMessaging.Editor
3
+ {
4
+ using System;
5
+ using UnityEditor;
6
+ using UnityEngine;
7
+ using UnityEngine.UIElements;
8
+
9
+ internal static class DxMessagingEditorTheme
10
+ {
11
+ internal const string PackageRoot = "Packages/com.wallstop-studios.dxmessaging";
12
+ internal const string TokensUssPath = PackageRoot + "/Editor/Theme/DxTokens.uss";
13
+ internal const string ThemeUssPath = PackageRoot + "/Editor/Theme/DxMessagingTheme.uss";
14
+ internal const string IconDir = PackageRoot + "/Editor/Icons";
15
+ internal const string Icon32FileName = "dxmessaging-icon-32.png";
16
+ internal const string Icon48FileName = "dxmessaging-icon-48.png";
17
+ internal const string Icon256FileName = "dxmessaging-icon-256.png";
18
+
19
+ internal const string ThemeClassName = "dx-theme";
20
+ internal const string LightSkinClassName = "dx-light";
21
+ internal const string DarkSkinClassName = "dx-dark";
22
+ internal const string WindowClassName = "dx-window";
23
+ internal const string ToolbarClassName = "dx-toolbar";
24
+ internal const string ToolButtonClassName = "dx-tool-btn";
25
+ internal const string SearchClassName = "dx-search";
26
+ internal const string CardClassName = "dx-card";
27
+ internal const string CardLabelClassName = "dx-card__label";
28
+ internal const string EmptyClassName = "dx-empty";
29
+ internal const string EmptyTitleClassName = "dx-empty__title";
30
+ internal const string EmptyBodyClassName = "dx-empty__body";
31
+ internal const string ButtonAccentClassName = "dx-btn-accent";
32
+ internal const string ButtonGhostClassName = "dx-btn-ghost";
33
+ internal const string AdmonitionClassName = "dx-admonition";
34
+ internal const string NoteClassName = "dx-note";
35
+ internal const string WarningClassName = "dx-warning";
36
+ internal const string TypeBadgeClassName = "dx-typebadge";
37
+ internal const string TypeBadgeUntargetedClassName = "dx-typebadge--u";
38
+ internal const string TypeBadgeTargetedClassName = "dx-typebadge--t";
39
+ internal const string TypeBadgeBroadcastClassName = "dx-typebadge--b";
40
+ internal const int CompleteBorderWidth = 1;
41
+
42
+ internal static void Apply(VisualElement root)
43
+ {
44
+ if (root == null)
45
+ {
46
+ return;
47
+ }
48
+
49
+ root.AddToClassList(ThemeClassName);
50
+ root.EnableInClassList(LightSkinClassName, !EditorGUIUtility.isProSkin);
51
+ root.EnableInClassList(DarkSkinClassName, EditorGUIUtility.isProSkin);
52
+ AddStyleSheet(root, TokensUssPath);
53
+ AddStyleSheet(root, ThemeUssPath);
54
+ }
55
+
56
+ internal static void ApplyWindow(VisualElement root)
57
+ {
58
+ Apply(root);
59
+ root?.AddToClassList(WindowClassName);
60
+ }
61
+
62
+ internal static void ApplyCompleteBorder(VisualElement element, Color borderColor)
63
+ {
64
+ if (element == null)
65
+ {
66
+ return;
67
+ }
68
+
69
+ element.style.borderTopWidth = CompleteBorderWidth;
70
+ element.style.borderRightWidth = CompleteBorderWidth;
71
+ element.style.borderBottomWidth = CompleteBorderWidth;
72
+ element.style.borderLeftWidth = CompleteBorderWidth;
73
+ element.style.borderTopColor = borderColor;
74
+ element.style.borderRightColor = borderColor;
75
+ element.style.borderBottomColor = borderColor;
76
+ element.style.borderLeftColor = borderColor;
77
+ }
78
+
79
+ internal static StyleSheet LoadTokensStylesheet()
80
+ {
81
+ return LoadStyleSheet(TokensUssPath);
82
+ }
83
+
84
+ internal static StyleSheet LoadThemeStylesheet()
85
+ {
86
+ return LoadStyleSheet(ThemeUssPath);
87
+ }
88
+
89
+ internal static Texture2D LoadIcon(string fileName = Icon32FileName)
90
+ {
91
+ if (string.IsNullOrWhiteSpace(fileName))
92
+ {
93
+ return null;
94
+ }
95
+
96
+ return AssetDatabase.LoadAssetAtPath<Texture2D>(IconDir + "/" + fileName);
97
+ }
98
+
99
+ internal static void AddRouteKindTypeBadgeClasses(VisualElement element, string routeKind)
100
+ {
101
+ if (element == null)
102
+ {
103
+ return;
104
+ }
105
+
106
+ element.AddToClassList(TypeBadgeClassName);
107
+ switch (DxMessagingEditorPalette.NormalizeRouteKind(routeKind))
108
+ {
109
+ case DxMessagingEditorPalette.UntargetedKind:
110
+ element.AddToClassList(TypeBadgeUntargetedClassName);
111
+ break;
112
+ case DxMessagingEditorPalette.TargetedKind:
113
+ element.AddToClassList(TypeBadgeTargetedClassName);
114
+ break;
115
+ case DxMessagingEditorPalette.BroadcastKind:
116
+ element.AddToClassList(TypeBadgeBroadcastClassName);
117
+ break;
118
+ }
119
+ }
120
+
121
+ /// <summary>
122
+ /// Builds a themed empty-state block: a centered <c>.dx-empty</c> container holding an
123
+ /// optional bold <c>.dx-empty__title</c> headline and a muted, wrapping
124
+ /// <c>.dx-empty__body</c> detail label. Callers may name the title/body labels so tests
125
+ /// and callbacks can query them.
126
+ /// </summary>
127
+ internal static VisualElement CreateEmptyState(
128
+ string title,
129
+ string body,
130
+ string bodyName = null,
131
+ string titleName = null
132
+ )
133
+ {
134
+ VisualElement container = new();
135
+ container.AddToClassList(EmptyClassName);
136
+
137
+ if (!string.IsNullOrWhiteSpace(title))
138
+ {
139
+ Label titleLabel = new(title);
140
+ if (!string.IsNullOrWhiteSpace(titleName))
141
+ {
142
+ titleLabel.name = titleName;
143
+ }
144
+ titleLabel.AddToClassList(EmptyTitleClassName);
145
+ container.Add(titleLabel);
146
+ }
147
+
148
+ if (!string.IsNullOrWhiteSpace(body))
149
+ {
150
+ Label bodyLabel = new(body);
151
+ if (!string.IsNullOrWhiteSpace(bodyName))
152
+ {
153
+ bodyLabel.name = bodyName;
154
+ }
155
+ bodyLabel.AddToClassList(EmptyBodyClassName);
156
+ bodyLabel.style.whiteSpace = WhiteSpace.Normal;
157
+ container.Add(bodyLabel);
158
+ }
159
+
160
+ return container;
161
+ }
162
+
163
+ private static StyleSheet LoadStyleSheet(string path)
164
+ {
165
+ return AssetDatabase.LoadAssetAtPath<StyleSheet>(path);
166
+ }
167
+
168
+ private static void AddStyleSheet(VisualElement root, string path)
169
+ {
170
+ StyleSheet styleSheet = LoadStyleSheet(path);
171
+ if (styleSheet == null)
172
+ {
173
+ DxMessagingEditorLog.LogWarning(
174
+ $"DxMessaging editor stylesheet was not found at '{path}'.",
175
+ exception: null
176
+ );
177
+ return;
178
+ }
179
+
180
+ if (!HasStyleSheet(root, styleSheet))
181
+ {
182
+ root.styleSheets.Add(styleSheet);
183
+ }
184
+ }
185
+
186
+ private static bool HasStyleSheet(VisualElement root, StyleSheet styleSheet)
187
+ {
188
+ for (int index = 0; index < root.styleSheets.count; index++)
189
+ {
190
+ if (root.styleSheets[index] == styleSheet)
191
+ {
192
+ return true;
193
+ }
194
+ }
195
+
196
+ return false;
197
+ }
198
+ }
199
+ }
200
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 8a7ce3f2ef322b9eab805825f0fa2e08
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: