Skip to content

Commit 10b8258

Browse files
committed
Make concrete generics (and typed nodes) show up as direct search results instead of being hidden in groups
Implements #12
1 parent 3945c7b commit 10b8258

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

ComponentSelectorAdditions/Injector.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private static void BuildCategoryUI(ComponentSelector selector, UIBuilder ui, Se
137137
groupCounter = new KeyCounter<string>();
138138
groupNames = new HashSet<string>();
139139

140-
foreach (var component in enumerateComponentsData.Items.Where(component => component.HasGroup))
140+
foreach (var component in enumerateComponentsData.Items.Where(component => component.HasGroup && !component.IsConcreteGeneric))
141141
groupCounter.Increment(component.Group!);
142142
}
143143

@@ -146,7 +146,8 @@ private static void BuildCategoryUI(ComponentSelector selector, UIBuilder ui, Se
146146
if (path.HasGroup && component.Group != path.Group)
147147
continue;
148148

149-
if (!path.HasGroup && component.HasGroup && groupCounter![component.Group] > 1)
149+
if (!path.HasGroup && component.HasGroup && groupCounter![component.Group] > 1
150+
&& !component.IsConcreteGeneric && !(path.HasSearchGeneric && component.Type.Name.EndsWith(path.SearchGeneric, StringComparison.OrdinalIgnoreCase)))
150151
{
151152
if (groupNames!.Add(component.Group))
152153
OnBuildGroupButton(selector, ui, rootCategory, component);
@@ -164,21 +165,21 @@ private static void BuildGenericTypeUI(ComponentSelector selector, UIBuilder ui,
164165
backButton = null;
165166

166167
var type = Type.GetType(path.PathSegments[^1]);
167-
selector._genericType.Value = type;
168+
selector._genericType.Value = type!;
168169

169170
if (!doNotGenerateBack)
170171
backButton = ui.Button("ComponentSelector.Back".AsLocaleKey(), RadiantUI_Constants.BUTTON_COLOR, selector.OnOpenCategoryPressed, path.OpenParentCategoryPath, 0.35f);
171172

172173
ui.Text("ComponentSelector.CustomGenericArguments".AsLocaleKey());
173174

174-
var customGenericBuilderData = OnBuildCustomGenericBuilder(selector, ui, type);
175+
var customGenericBuilderData = OnBuildCustomGenericBuilder(selector, ui, type!);
175176
customGenericButton = customGenericBuilderData.CreateCustomTypeButton!;
176177
otherAddedButtons = customGenericBuilderData.OtherAddedButtonsSet;
177178

178179
ui.Panel();
179180
ui.NestOut();
180181

181-
var concreteGenericsEventData = OnEnumerateConcreteGenerics(selector, type);
182+
var concreteGenericsEventData = OnEnumerateConcreteGenerics(selector, type!);
182183

183184
if (concreteGenericsEventData.Items.Any())
184185
{

0 commit comments

Comments
 (0)