Skip to content

Commit

Permalink
ModSettings Groups -> Submenus
Browse files Browse the repository at this point in the history
  • Loading branch information
AuriRex committed Jun 20, 2023
1 parent 7246460 commit 5453ca8
Show file tree
Hide file tree
Showing 6 changed files with 335 additions and 139 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace TheArchive.Core.Attributes
{
[AttributeUsage(AttributeTargets.Assembly)]
public class ModInlineUncategorizedSettingsIntoMainMenu : Attribute
{
}
}
64 changes: 57 additions & 7 deletions TheArchive.Core/Core/FeaturesAPI/FeatureGroups.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,62 @@
namespace TheArchive.Core.FeaturesAPI
using System;
using System.Collections.Generic;
using System.Linq;

namespace TheArchive.Core.FeaturesAPI
{
public static class FeatureGroups
{
public static string Accessibility => "Accessibility";
public static string Special => "Misc";
public static string Dev => "Developer";
public static string Backport => "Backport";
public static string QualityOfLife => "Quality of Life";
public static string LocalProgression => "Local Progression";
public static Group Get(string name) => Group.Get(name);

public class Group
{
private static readonly HashSet<Group> _allGroups = new HashSet<Group>();

public static Group Get(string name)
{
return _allGroups.FirstOrDefault(g => g.Name == name);
}

public string Name { get; private set; }
public bool InlineSettings { get; internal set; }
public bool IsNewlyCreated { get; private set; } = true;

public static Group GetOrCreate(string name, Action<Group> groupModification = null)
{
var group = _allGroups.FirstOrDefault(g => g.Name == name);

if (group != null)
group.IsNewlyCreated = false;

group ??= new Group(name);

groupModification?.Invoke(group);

return group;
}

private Group(string name)
{
Name = name;

_allGroups.Add(this);
}

public override string ToString()
{
return Name;
}

public static implicit operator string(Group g) => g.Name;
}

public static Group Accessibility { get; private set; } = Group.GetOrCreate("Accessibility");
public static Group Fixes { get; private set; } = Group.GetOrCreate("Fixes");
public static Group Hud { get; private set; } = Group.GetOrCreate("HUD / UI");
public static Group Special { get; private set; } = Group.GetOrCreate("Misc");
public static Group Dev { get; private set; } = Group.GetOrCreate("Developer");
public static Group Backport { get; private set; } = Group.GetOrCreate("Backport");
public static Group QualityOfLife { get; private set; } = Group.GetOrCreate("Quality of Life");
public static Group LocalProgression { get; private set; } = Group.GetOrCreate("Local Progression"); // , group => group.InlineSettings = true
}
}
1 change: 1 addition & 0 deletions TheArchive.IL2CPP/ArchiveIL2CPPModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using UnityEngine.CrashReportHandler;

[assembly: ModDefaultFeatureGroupName("TheArchive")]
[assembly: ModInlineUncategorizedSettingsIntoMainMenu]
namespace TheArchive
{
public class ArchiveIL2CPPModule : IArchiveModule
Expand Down
Loading

0 comments on commit 5453ca8

Please sign in to comment.