From 2e4d39e51db14ac60a4ea07234d783fa3fac98ed Mon Sep 17 00:00:00 2001 From: Arne Kiesewetter Date: Thu, 9 Jul 2026 23:39:32 +0200 Subject: [PATCH] Update for Resonite 2026.7.7.829 and cleanup for newer C# / dependencies Fixes #17 --- .github/workflows/build.yml | 16 +-- .github/workflows/publish.yml | 5 +- ComponentSelectorAdditions.sln | 9 ++ .../CaseSensitivityFix.cs | 3 - .../CategoryOverride.cs | 3 - .../CategoryOverrideHandler.cs | 9 +- ComponentSelectorAdditions/ComponentResult.cs | 5 - .../ComponentSelectorAdditions.csproj | 34 ++---- .../CurrentPathIndicator.cs | 10 +- ComponentSelectorAdditions/DefaultConfig.cs | 26 +---- ComponentSelectorAdditions/DefaultHandler.cs | 100 +++++++--------- .../Events/BuildButtonEvent.cs | 5 - .../Events/BuildCategoryButtonEvent.cs | 5 - .../Events/BuildComponentButtonEvent.cs | 5 - .../Events/BuildCustomGenericBuilder.cs | 7 +- .../Events/BuildGroupButtonEvent.cs | 5 - .../Events/BuildSelectorEvent.cs | 1 - .../Events/EnumerateCategoriesEvent.cs | 3 - .../Events/EnumerateComponentsEvent.cs | 4 - .../Events/EnumerateConcreteGenericsEvent.cs | 3 - .../Events/IEnumerateSelectorResultEvent.cs | 3 - .../Events/PostProcessButtonsEvent.cs | 19 +-- .../FavoritesCategories.cs | 110 ++++++++---------- ComponentSelectorAdditions/FavoritesConfig.cs | 19 ++- ComponentSelectorAdditions/FixedBackButton.cs | 16 +-- .../FixedCancelButton.cs | 16 +-- .../GenericPresetsConfig.cs | 9 +- .../GenericPresetsHandler.cs | 46 +------- ComponentSelectorAdditions/Injector.cs | 16 +-- ComponentSelectorAdditions/Locale/de.json | 37 ++++-- ComponentSelectorAdditions/Locale/en.json | 38 ++++-- .../RecentsCategories.cs | 51 +++----- ComponentSelectorAdditions/RecentsConfig.cs | 23 ++-- ComponentSelectorAdditions/SearchBar.cs | 51 +++----- ComponentSelectorAdditions/SearchConfig.cs | 32 +++-- ComponentSelectorAdditions/SelectorPath.cs | 13 +-- .../SelectorSearchBar.cs | 6 - .../UIBuilderExtensions.cs | 5 - Directory.Build.props | 33 +----- 39 files changed, 280 insertions(+), 521 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0386f5..164dffa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,12 +43,9 @@ jobs: - name: Setup Dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.x + dotnet-version: 10.x source-url: https://nuget.pkg.github.com/ResoniteModdingGroup/index.json - - name: Add MonkeyLoader NuGet Source - run: dotnet nuget add source https://pkg.munally.com/MonkeyModdingTroop/index.json - - name: Restore NuGet Package Cache uses: actions/cache/restore@v4 with: @@ -69,10 +66,6 @@ jobs: - name: Move NuGet Packages run: mv (Get-ChildItem -Recurse ./ -Include *.nupkg) ./ - - # Removes the version number from the package name - - name: Rename NuGet Packages - run: Get-ChildItem -Include *.nupkg -Path ./* | Rename-Item -NewName { $_.Name -Replace '\.\d+\.\d+\.\d+.*$','.nupkg' } # Publish the NuGet package(s) as an artifact, so they can be used in the following jobs - name: Upload NuGet Packages Artifact @@ -81,7 +74,7 @@ jobs: name: NuGet Packages if-no-files-found: error retention-days: 7 - path: ./*.nupkg + path: ./ComponentSelectorAdditions.nupkg # Only when it's not from a PR to avoid any funny packages in the cache - name: Save NuGet Package Cache @@ -98,12 +91,9 @@ jobs: - name: Setup Dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.x + dotnet-version: 10.x source-url: https://nuget.pkg.github.com/ResoniteModdingGroup/index.json - - name: Add MonkeyLoader NuGet Source - run: dotnet nuget add source https://pkg.munally.com/MonkeyModdingTroop/index.json - - name: Restore NuGet Package Cache uses: actions/cache/restore@v4 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3fe7a28..3e65cc7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -68,11 +68,8 @@ jobs: - name: Setup Dotnet uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.x + dotnet-version: 10.x source-url: https://nuget.pkg.github.com/ResoniteModdingGroup/index.json - - - name: Add MonkeyLoader NuGet Source - run: dotnet nuget add source https://pkg.munally.com/MonkeyModdingTroop/index.json # Publish all NuGet packages to the GitHub feed # Use --skip-duplicate to prevent errors if a package with the same version already exists. diff --git a/ComponentSelectorAdditions.sln b/ComponentSelectorAdditions.sln index 946dcda..7607e9c 100644 --- a/ComponentSelectorAdditions.sln +++ b/ComponentSelectorAdditions.sln @@ -11,6 +11,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" + ProjectSection(SolutionItems) = preProject + .github\workflows\build.yml = .github\workflows\build.yml + .github\workflows\publish.yml = .github\workflows\publish.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -25,6 +31,9 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {07124CF9-EE3D-4A7E-A2F8-8FD07966E423} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7D505B2E-FBA2-4F50-BC1C-838BC8DF0D5C} EndGlobalSection diff --git a/ComponentSelectorAdditions/CaseSensitivityFix.cs b/ComponentSelectorAdditions/CaseSensitivityFix.cs index 68b5f37..74b9a67 100644 --- a/ComponentSelectorAdditions/CaseSensitivityFix.cs +++ b/ComponentSelectorAdditions/CaseSensitivityFix.cs @@ -1,10 +1,7 @@ using FrooxEngine; using HarmonyLib; using MonkeyLoader.Patching; -using System; -using System.Collections.Generic; using System.Reflection; -using System.Text; namespace ComponentSelectorAdditions { diff --git a/ComponentSelectorAdditions/CategoryOverride.cs b/ComponentSelectorAdditions/CategoryOverride.cs index 1ad6eb9..1bb2d91 100644 --- a/ComponentSelectorAdditions/CategoryOverride.cs +++ b/ComponentSelectorAdditions/CategoryOverride.cs @@ -1,8 +1,5 @@ using ComponentSelectorAdditions.Events; using FrooxEngine; -using System; -using System.Collections.Generic; -using System.Text; namespace ComponentSelectorAdditions { diff --git a/ComponentSelectorAdditions/CategoryOverrideHandler.cs b/ComponentSelectorAdditions/CategoryOverrideHandler.cs index 544a43b..9ede50c 100644 --- a/ComponentSelectorAdditions/CategoryOverrideHandler.cs +++ b/ComponentSelectorAdditions/CategoryOverrideHandler.cs @@ -2,18 +2,15 @@ using EnumerableToolkit; using FrooxEngine; using MonkeyLoader.Resonite; -using System; -using System.Collections.Generic; using System.Collections.Immutable; -using System.Linq; -using System.Text; namespace ComponentSelectorAdditions { internal sealed class CategoryOverrideHandler : ResoniteCancelableEventHandlerMonkey { - private static readonly Dictionary, HashSet> _overridesByCategory = new(); + private static readonly Dictionary, HashSet> _overridesByCategory = []; + /// public override bool CanBeDisabled => true; /// @@ -26,7 +23,7 @@ public static bool AddOverride(CategoryOverride categoryOverride) => _overridesByCategory.GetOrCreateValue(categoryOverride.TargetCategory).Add(categoryOverride); public static IEnumerable GetOverrides(CategoryNode category) - => _overridesByCategory.TryGetValue(category, out var overrides) ? overrides.AsSafeEnumerable() : Enumerable.Empty(); + => _overridesByCategory.TryGetValue(category, out var overrides) ? overrides.AsSafeEnumerable() : []; public static bool HasAnyOverride(CategoryNode category) => _overridesByCategory.TryGetValue(category, out var overrides) && overrides.Count > 0; diff --git a/ComponentSelectorAdditions/ComponentResult.cs b/ComponentSelectorAdditions/ComponentResult.cs index aac0201..cbc5051 100644 --- a/ComponentSelectorAdditions/ComponentResult.cs +++ b/ComponentSelectorAdditions/ComponentResult.cs @@ -1,12 +1,7 @@ using Elements.Core; using FrooxEngine; -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace ComponentSelectorAdditions { diff --git a/ComponentSelectorAdditions/ComponentSelectorAdditions.csproj b/ComponentSelectorAdditions/ComponentSelectorAdditions.csproj index cdee5bf..3b9e23f 100644 --- a/ComponentSelectorAdditions/ComponentSelectorAdditions.csproj +++ b/ComponentSelectorAdditions/ComponentSelectorAdditions.csproj @@ -1,16 +1,9 @@ - + - ComponentSelectorAdditions - $(AssemblyTitle).dll - ComponentSelectorAdditions - - - - True ComponentSelectorAdditions Component Selector Additions Banane9 - 0.10.0-beta + 0.10.1-beta This MonkeyLoader mod for Resonite overhauls the Component Selector / Protoflux Node Selector to have a search, as well as favorites and recents categories. README.md LGPL-3.0-or-later @@ -19,29 +12,16 @@ mod; mods; monkeyloader; resonite; component; attacher; selector; protoflux; node; picker; search; favorites - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + diff --git a/ComponentSelectorAdditions/CurrentPathIndicator.cs b/ComponentSelectorAdditions/CurrentPathIndicator.cs index 5569ff1..40af41c 100644 --- a/ComponentSelectorAdditions/CurrentPathIndicator.cs +++ b/ComponentSelectorAdditions/CurrentPathIndicator.cs @@ -3,22 +3,14 @@ using FrooxEngine.UIX; using MonkeyLoader.Patching; using MonkeyLoader.Resonite; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ComponentSelectorAdditions { internal sealed class CurrentPathIndicator : ResoniteEventHandlerMonkey { public override bool CanBeDisabled => true; - public override int Priority => HarmonyLib.Priority.Normal; - - protected override bool AppliesTo(BuildSelectorFooterEvent eventData) => Enabled; - protected override IEnumerable GetFeaturePatches() => Enumerable.Empty(); + public override int Priority => HarmonyLib.Priority.Normal; protected override void Handle(BuildSelectorFooterEvent eventData) { diff --git a/ComponentSelectorAdditions/DefaultConfig.cs b/ComponentSelectorAdditions/DefaultConfig.cs index b6e7e4d..576bfeb 100644 --- a/ComponentSelectorAdditions/DefaultConfig.cs +++ b/ComponentSelectorAdditions/DefaultConfig.cs @@ -1,6 +1,5 @@ using Elements.Core; using MonkeyLoader.Configuration; -using System; using System.Diagnostics.CodeAnalysis; namespace ComponentSelectorAdditions @@ -8,24 +7,19 @@ namespace ComponentSelectorAdditions /// /// Contains settings for the buttons generated by default. /// - public sealed class DefaultConfig : ConfigSection + public sealed class DefaultConfig : SingletonConfigSection { - private static readonly DefiningConfigKey _directButtonHeight = new("DirectButtonHeight", "The height of a button that is targeting the direct child of the current category, in canvas units. The default value is 32.", () => 32) + private readonly DefiningConfigKey _directButtonHeight = new("DirectButtonHeight", "The height of a button that is targeting the direct child of the current category, in canvas units. The default value is 32.", () => 32) { new ConfigKeyRange(32, 64) }; - private static readonly DefiningConfigKey _indirectButtonHeight = new("IndirectButtonHeight", "The height of a button that is not targeting a direct child of the current category and has to fit a category path as well, in canvas units. The default value is 48.", () => 48) + private readonly DefiningConfigKey _indirectButtonHeight = new("IndirectButtonHeight", "The height of a button that is not targeting a direct child of the current category and has to fit a category path as well, in canvas units. The default value is 48.", () => 48) { new ConfigKeyRange(32, 64) }; - private static readonly DefiningConfigKey _separateConcreteGenericColor = new("separateConcreteGenericColor", "The color to use for concrete generic buttons, if defined. Defaults to a blend between the generic component buttons' green and the non-generic component buttons' cyan.", () => colorX.FromHexCode("#255447")); - - /// - /// Gets this config's instance. - /// - public static DefaultConfig Instance { get; private set; } = null!; + private readonly DefiningConfigKey _separateConcreteGenericColor = new("separateConcreteGenericColor", "The color to use for concrete generic buttons, if defined. Defaults to a blend between the generic component buttons' green and the non-generic component buttons' cyan.", () => colorX.FromHexCode("#255447")); /// public override string Description => "Contains settings for the buttons generated by default."; @@ -59,16 +53,8 @@ public sealed class DefaultConfig : ConfigSection /// public override Version Version { get; } = new Version(1, 0, 0); - /// - /// Creates an instance of this config once. - /// - /// + /// public DefaultConfig() - { - if (Instance is not null) - throw new InvalidOperationException(); - - Instance = this; - } + { } } } \ No newline at end of file diff --git a/ComponentSelectorAdditions/DefaultHandler.cs b/ComponentSelectorAdditions/DefaultHandler.cs index 80a653e..31ecab1 100644 --- a/ComponentSelectorAdditions/DefaultHandler.cs +++ b/ComponentSelectorAdditions/DefaultHandler.cs @@ -4,14 +4,7 @@ using FrooxEngine; using HarmonyLib; using MonkeyLoader.Events; -using MonkeyLoader.Patching; using MonkeyLoader.Resonite; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.IO; using MonkeyLoader.Resonite.UI; namespace ComponentSelectorAdditions @@ -19,16 +12,17 @@ namespace ComponentSelectorAdditions /// /// Handles the default behavior for the events. /// - public sealed class DefaultHandler : ConfiguredResoniteMonkey, - ICancelableEventHandler, ICancelableEventHandler, - ICancelableEventHandler, ICancelableEventHandler, ICancelableEventHandler, + public sealed class DefaultHandler + : ConfiguredResoniteCancelableEventHandlerMonkey, IEventHandler, IEventHandler { /// - public int Priority => HarmonyLib.Priority.Normal; + public override int Priority => HarmonyLib.Priority.Normal; /// - public bool SkipCanceled => true; + public override bool SkipCanceled => true; /// /// Formats the path from the to the @@ -125,7 +119,33 @@ public static void MakePermanentButton(UIBuilder ui, LocaleString name, colorX t ui.PopStyle(); } - void ICancelableEventHandler.Handle(EnumerateComponentsEvent eventData) + void IEventHandler.Handle(EnumerateConcreteGenericsEvent eventData) + { + foreach (var concreteGeneric in WorkerInitializer.GetCommonGenericTypes(eventData.Component)) + eventData.AddItem(concreteGeneric); + } + + void IEventHandler.Handle(BuildCustomGenericBuilder eventData) + { + var ui = eventData.UI; + var selector = eventData.Selector; + + if (!eventData.AddsGenericArgumentInputs) + { + foreach (var genericArgument in eventData.GenericArguments) + { + var textField = MakeGenericArgumentInput(ui, eventData.Component, genericArgument, selector.GenericArgumentPrefiller.Target); + + selector._customGenericArguments.Add(textField); + } + } + + if (!eventData.AddsCreateCustomTypeButton) + eventData.CreateCustomTypeButton = ui.Button((LocaleString)string.Empty, RadiantUI_Constants.BUTTON_COLOR, selector.OnCreateCustomType, .35f); + } + + /// + protected override void Handle(EnumerateComponentsEvent eventData) { var types = eventData.RootCategory.Elements; @@ -143,7 +163,8 @@ static IEnumerable GetAllSubElements(CategoryNode category) eventData.Canceled = true; } - void ICancelableEventHandler.Handle(EnumerateCategoriesEvent eventData) + /// + protected override void Handle(EnumerateCategoriesEvent eventData) { if (!eventData.Path.HasGroup) { @@ -154,7 +175,8 @@ void ICancelableEventHandler.Handle(EnumerateCategorie eventData.Canceled = true; } - void ICancelableEventHandler.Handle(BuildGroupButtonEvent eventData) + /// + protected override void Handle(BuildGroupButtonEvent eventData) { var selector = eventData.Selector; @@ -168,32 +190,8 @@ void ICancelableEventHandler.Handle(BuildGroupButtonEvent eventData.Canceled = true; } - void IEventHandler.Handle(EnumerateConcreteGenericsEvent eventData) - { - foreach (var concreteGeneric in WorkerInitializer.GetCommonGenericTypes(eventData.Component)) - eventData.AddItem(concreteGeneric); - } - - void IEventHandler.Handle(BuildCustomGenericBuilder eventData) - { - var ui = eventData.UI; - var selector = eventData.Selector; - - if (!eventData.AddsGenericArgumentInputs) - { - foreach (var genericArgument in eventData.GenericArguments) - { - var textField = MakeGenericArgumentInput(ui, eventData.Component, genericArgument, selector.GenericArgumentPrefiller.Target); - - selector._customGenericArguments.Add(textField); - } - } - - if (!eventData.AddsCreateCustomTypeButton) - eventData.CreateCustomTypeButton = ui.Button((LocaleString)string.Empty, RadiantUI_Constants.BUTTON_COLOR, selector.OnCreateCustomType, .35f); - } - - void ICancelableEventHandler.Handle(BuildComponentButtonEvent eventData) + /// + protected override void Handle(BuildComponentButtonEvent eventData) { var path = eventData.Path; var selector = eventData.Selector; @@ -212,7 +210,8 @@ void ICancelableEventHandler.Handle(BuildComponentBut eventData.Canceled = true; } - void ICancelableEventHandler.Handle(BuildCategoryButtonEvent eventData) + /// + protected override void Handle(BuildCategoryButtonEvent eventData) { MakePermanentButton(eventData.UI, GetPrettyPath(eventData.ItemCategory, eventData.RootCategory), RadiantUI_Constants.Sub.YELLOW, @@ -222,19 +221,9 @@ void ICancelableEventHandler.Handle(BuildCategoryButto eventData.Canceled = true; } - /// - protected override IEnumerable GetFeaturePatches() => Enumerable.Empty(); - /// protected override bool OnLoaded() { - Mod.RegisterEventHandler(this); - Mod.RegisterEventHandler(this); - - Mod.RegisterEventHandler(this); - Mod.RegisterEventHandler(this); - Mod.RegisterEventHandler(this); - Mod.RegisterEventHandler(this); Mod.RegisterEventHandler(this); @@ -246,13 +235,6 @@ protected override bool OnShutdown(bool applicationExiting) { if (!applicationExiting) { - Mod.UnregisterEventHandler(this); - Mod.UnregisterEventHandler(this); - - Mod.UnregisterEventHandler(this); - Mod.UnregisterEventHandler(this); - Mod.UnregisterEventHandler(this); - Mod.UnregisterEventHandler(this); Mod.UnregisterEventHandler(this); } diff --git a/ComponentSelectorAdditions/Events/BuildButtonEvent.cs b/ComponentSelectorAdditions/Events/BuildButtonEvent.cs index 9ea6e70..0adf394 100644 --- a/ComponentSelectorAdditions/Events/BuildButtonEvent.cs +++ b/ComponentSelectorAdditions/Events/BuildButtonEvent.cs @@ -1,11 +1,6 @@ using FrooxEngine; using FrooxEngine.UIX; using MonkeyLoader.Resonite.Events; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ComponentSelectorAdditions.Events { diff --git a/ComponentSelectorAdditions/Events/BuildCategoryButtonEvent.cs b/ComponentSelectorAdditions/Events/BuildCategoryButtonEvent.cs index a54444d..86074df 100644 --- a/ComponentSelectorAdditions/Events/BuildCategoryButtonEvent.cs +++ b/ComponentSelectorAdditions/Events/BuildCategoryButtonEvent.cs @@ -1,10 +1,5 @@ using FrooxEngine; using FrooxEngine.UIX; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ComponentSelectorAdditions.Events { diff --git a/ComponentSelectorAdditions/Events/BuildComponentButtonEvent.cs b/ComponentSelectorAdditions/Events/BuildComponentButtonEvent.cs index 48ae7b2..c9063f6 100644 --- a/ComponentSelectorAdditions/Events/BuildComponentButtonEvent.cs +++ b/ComponentSelectorAdditions/Events/BuildComponentButtonEvent.cs @@ -1,10 +1,5 @@ using FrooxEngine; using FrooxEngine.UIX; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ComponentSelectorAdditions.Events { diff --git a/ComponentSelectorAdditions/Events/BuildCustomGenericBuilder.cs b/ComponentSelectorAdditions/Events/BuildCustomGenericBuilder.cs index c38198a..fbc65f2 100644 --- a/ComponentSelectorAdditions/Events/BuildCustomGenericBuilder.cs +++ b/ComponentSelectorAdditions/Events/BuildCustomGenericBuilder.cs @@ -2,12 +2,7 @@ using FrooxEngine; using FrooxEngine.UIX; using MonkeyLoader.Resonite.Events; -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ComponentSelectorAdditions.Events { @@ -19,7 +14,7 @@ namespace ComponentSelectorAdditions.Events /// public sealed class BuildCustomGenericBuilder : BuildUIEvent { - internal readonly HashSet public sealed class SearchConfig : SingletonConfigSection { - private static readonly DefiningConfigKey _alwaysSearchRoot = new("AlwaysSearchRoot", "Always starts searching from the root category, regardless of the current one.", () => false); + private readonly DefiningConfigKey _alwaysSearchRoot = new("AlwaysSearchRoot", "Always starts searching from the root category, regardless of the current one.", () => false); - private static readonly Dictionary _excludedCategories = new(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _excludedCategories = new(StringComparer.OrdinalIgnoreCase); - private static readonly DefiningConfigKey _includeOpenGenericsWithGenericArgument = new("IncludeOpenGenericsWithGenericArgument", "Include the open generic versions of components / nodes in the results even when the generic argument can be applied to them successfully.", () => false); + private readonly DefiningConfigKey _includeOpenGenericsWithGenericArgument = new("IncludeOpenGenericsWithGenericArgument", "Include the open generic versions of components / nodes in the results even when the generic argument can be applied to them successfully.", () => false); - private static readonly DefiningConfigKey _maxResultCount = new("MaxResultCount", "The maximum number of component / node results to display. 'Better' results are listed first. Categories don't count.", () => 64) + private readonly DefiningConfigKey _maxResultCount = new("MaxResultCount", "The maximum number of component / node results to display. 'Better' results are listed first. Categories don't count.", () => 64) { new ConfigKeyRange(1, 128) }; - private static readonly DefiningConfigKey _searchRefreshDelay = new("SearchRefreshDelay", "Time to wait after search input change before refreshing the results. 0 to always refresh.", () => .4f) + private readonly DefiningConfigKey _searchRefreshDelay = new("SearchRefreshDelay", "Time to wait after search input change before refreshing the results. 0 to always refresh.", () => .4f) { - new ConfigKeyQuantity(new UnitConfiguration("s", "0", " ", new [] {"s", "ms"}), null, 0, 2) + new ConfigKeyQuantity(new UnitConfiguration("s", "0", " ", ["s", "ms"]), null, 0, 2) }; - private static readonly DefiningConfigKey _userExcludedCategories = new("UserExcludedCategories", "Excludes specific categories from being searched into by path (case sensitive). Separate entries by semicolon. Search will work when started inside them.", () => "/ProtoFlux"); + private readonly DefiningConfigKey _userExcludedCategories = new("UserExcludedCategories", "Excludes specific categories from being searched into by path (case sensitive). Separate entries by semicolon. Search will work when started inside them.", () => "/ProtoFlux"); - private static readonly char[] _userExclusionSeparator = new[] { ';' }; + private readonly char[] _userExclusionSeparator = [';']; /// /// Gets whether the search always searches from the root category of the component selector / node browser. @@ -70,7 +65,8 @@ public sealed class SearchConfig : SingletonConfigSection /// public override Version Version { get; } = new(1, 0, 0); - static SearchConfig() + /// + public SearchConfig() { _userExcludedCategories.Changed += UserExcludedCategoriesChanged; } @@ -150,20 +146,20 @@ protected override void OnLoad(JObject source, JsonSerializer jsonSerializer) LoadUserExcludedCategories(_userExcludedCategories); } - private static void LoadUserExcludedCategories(string? categoryList) + private void LoadUserExcludedCategories(string? categoryList) { foreach (var category in ProcessCategoryString(categoryList)) _excludedCategories.TryAdd(category, true); } - private static IEnumerable ProcessCategoryString(string? categoryList) + private IEnumerable ProcessCategoryString(string? categoryList) => categoryList? .Split(_userExclusionSeparator, StringSplitOptions.RemoveEmptyEntries) .Select(category => category.Trim()) .Where(category => !string.IsNullOrWhiteSpace(category)) - ?? Enumerable.Empty(); + ?? []; - private static void UserExcludedCategoriesChanged(object sender, ConfigKeyChangedEventArgs configKeyChangedEventArgs) + private void UserExcludedCategoriesChanged(object sender, ConfigKeyChangedEventArgs configKeyChangedEventArgs) { foreach (var category in ProcessCategoryString(configKeyChangedEventArgs.OldValue)) { diff --git a/ComponentSelectorAdditions/SelectorPath.cs b/ComponentSelectorAdditions/SelectorPath.cs index e0cb8cc..f7664fc 100644 --- a/ComponentSelectorAdditions/SelectorPath.cs +++ b/ComponentSelectorAdditions/SelectorPath.cs @@ -1,10 +1,5 @@ using HarmonyLib; -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ComponentSelectorAdditions { @@ -21,9 +16,9 @@ public sealed class SelectorPath private static readonly char _genericParamEnd = '>'; private static readonly char _genericParamStart = '<'; - private static readonly char[] _pathSeparators = { '/', '\\' }; + private static readonly char[] _pathSeparators = ['/', '\\']; - private static readonly char[] _searchSplits = new[] { ' ', '.', ',', ';', '?', '!', '+', '|', '&', '`', '´', '"', '(', ')', '/', '\\', '\n', '\r', '\t' }; + private static readonly char[] _searchSplits = [' ', '.', ',', ';', '?', '!', '+', '|', '&', '`', '´', '"', '(', ')', '/', '\\', '\n', '\r', '\t']; /// /// Gets whether this path targets a generic type. @@ -86,7 +81,7 @@ public sealed class SelectorPath /// /// Gets this path's search fragments (before the generic argument). /// - public string[] SearchFragments { get; } = Array.Empty(); + public string[] SearchFragments { get; } = []; /// /// Gets this path's generic argument for the search. @@ -125,7 +120,7 @@ internal SelectorPath(string? rawPath, string? search, bool genericType, string? Group = group; IsSelectorRoot = isSelectorRoot; - PathSegments = rawPath?.Split(_pathSeparators, StringSplitOptions.RemoveEmptyEntries).ToArray() ?? Array.Empty(); + PathSegments = rawPath?.Split(_pathSeparators, StringSplitOptions.RemoveEmptyEntries).ToArray() ?? []; Path = $"/{PathSegments.Join(delimiter: "/")}"; } } diff --git a/ComponentSelectorAdditions/SelectorSearchBar.cs b/ComponentSelectorAdditions/SelectorSearchBar.cs index 64d8eb3..d796219 100644 --- a/ComponentSelectorAdditions/SelectorSearchBar.cs +++ b/ComponentSelectorAdditions/SelectorSearchBar.cs @@ -1,11 +1,5 @@ using FrooxEngine; using FrooxEngine.UIX; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; namespace ComponentSelectorAdditions { diff --git a/ComponentSelectorAdditions/UIBuilderExtensions.cs b/ComponentSelectorAdditions/UIBuilderExtensions.cs index 34b5eb5..48a8bcf 100644 --- a/ComponentSelectorAdditions/UIBuilderExtensions.cs +++ b/ComponentSelectorAdditions/UIBuilderExtensions.cs @@ -1,11 +1,6 @@ using Elements.Core; using FrooxEngine.UIX; using FrooxEngine; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ComponentSelectorAdditions { diff --git a/Directory.Build.props b/Directory.Build.props index 5e1a83a..1799b63 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,42 +1,17 @@ - - Library - net9.0 - $(AssemblyTitle).dll - 11.0 - enable - true - True - portable - True - - true - - - https://nuget.pkg.github.com/MonkeyModdingTroop/index.json; - https://nuget.pkg.github.com/ResoniteModdingGroup/index.json - - - README.md - git - False - True - True - snupkg - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true true - false + false - $(MSBuildThisFileDirectory)Resonite - C:\Program Files (x86)\Steam\steamapps\common\Resonite - $(HOME)/.steam/steam/steamapps/common/Resonite + $(MSBuildThisFileDirectory)Resonite D:/Files/Games/Resonite/app + G:\SteamLibrary\steamapps\common\Resonite