Skip to content

Commit

Permalink
Integrate with ComponentAttacherSearch excluded categories
Browse files Browse the repository at this point in the history
  • Loading branch information
Banane9 committed Mar 29, 2023
1 parent 1cb7475 commit f36da15
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
18 changes: 13 additions & 5 deletions ComponentAttacherRecents/ComponentAttacherRecents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ComponentAttacherRecents : NeosMod
public override string Author => "Banane9";
public override string Link => "https://github.com/Banane9/NeosComponentAttacherRecents";
public override string Name => "ComponentAttacherRecents";
public override string Version => "1.0.0";
public override string Version => "1.1.0";

private static List<string> Recents => Config.GetValue(RecentComponents);

Expand All @@ -58,7 +58,15 @@ public override void OnEngineInit()
harmony.PatchAll();

Config.OnThisConfigurationChanged += Config_OnThisConfigurationChanged;
Engine.Current.OnReady += () => RecentsCategory = WorkerInitializer.ComponentLibrary.GetSubcategory(RecentsPath);

Engine.Current.OnReady += () =>
{
RecentsCategory = WorkerInitializer.ComponentLibrary.GetSubcategory(RecentsPath);
if (ModLoader.Mods().FirstOrDefault(mod => mod.Name == "ComponentAttacherSearch") is NeosModBase searchMod
&& (searchMod.GetConfiguration()?.TryGetValue(new ModConfigurationKey<HashSet<string>>("ExcludedCategories"), out var excludedCategories) ?? false))
excludedCategories.Add(RecentsPath);
};
}

private static void TrimRecentComponents()
Expand Down Expand Up @@ -98,7 +106,7 @@ public static void BuildUIPostfix(string path, bool genericType, SyncRef<Slot> _
}
}

private static void addRecentComponent(Type type)
private static void AddRecentComponent(Type type)
{
if (!Recents.Remove(type.FullName))
RecentsCategory.AddElement(type);
Expand Down Expand Up @@ -126,10 +134,10 @@ private static void updateRecentComponents(Type type)
return;

if (!type.IsGenericType || Config.GetValue(TrackConcreteComponents))
addRecentComponent(type);
AddRecentComponent(type);

if (type.IsGenericType && Config.GetValue(TrackGenericComponents))
addRecentComponent(type.GetGenericTypeDefinition());
AddRecentComponent(type.GetGenericTypeDefinition());

TrimRecentComponents();
}
Expand Down
6 changes: 3 additions & 3 deletions ComponentAttacherRecents/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Banane9")]
[assembly: AssemblyProduct("ComponentAttacherRecents")]
[assembly: AssemblyCopyright("Copyright © Banane9 2022")]
[assembly: AssemblyCopyright("Copyright © Banane9 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

0 comments on commit f36da15

Please sign in to comment.