mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
show different plugin gamemodes in lobby view pane
This commit is contained in:
1 parent
06c746c632
commit
0e3b6be5be
2 files changed
+29
-8
No files matched your search
@@ -24,9 +24,11 @@ public static class LobbyViewPanePatches
|
|||||||
{
|
{
|
||||||
private static int SelectedModIdx { get; set; }
|
private static int SelectedModIdx { get; set; }
|
||||||
|
|
||||||
|
private static MiraPluginInfo[] Plugins => MiraPluginManager.Instance.PluginsWithOptionsOrGameModes;
|
||||||
|
|
||||||
private static MiraPluginInfo? SelectedMod => SelectedModIdx == 0
|
private static MiraPluginInfo? SelectedMod => SelectedModIdx == 0
|
||||||
? null
|
? null
|
||||||
: MiraPluginManager.Instance.RegisteredPluginsWithOptions[SelectedModIdx - 1];
|
: Plugins[SelectedModIdx - 1];
|
||||||
|
|
||||||
private static PassiveButton? ModifiersTabButton { get; set; }
|
private static PassiveButton? ModifiersTabButton { get; set; }
|
||||||
|
|
||||||
@@ -76,7 +78,7 @@ public static class LobbyViewPanePatches
|
|||||||
(UnityAction)(() =>
|
(UnityAction)(() =>
|
||||||
{
|
{
|
||||||
SelectedModIdx += 1;
|
SelectedModIdx += 1;
|
||||||
if (SelectedModIdx > MiraPluginManager.Instance.RegisteredPluginsWithOptions.Length)
|
if (SelectedModIdx > Plugins.Length)
|
||||||
{
|
{
|
||||||
SelectedModIdx = 0;
|
SelectedModIdx = 0;
|
||||||
}
|
}
|
||||||
@@ -100,7 +102,7 @@ public static class LobbyViewPanePatches
|
|||||||
SelectedModIdx -= 1;
|
SelectedModIdx -= 1;
|
||||||
if (SelectedModIdx < 0)
|
if (SelectedModIdx < 0)
|
||||||
{
|
{
|
||||||
SelectedModIdx = MiraPluginManager.Instance.RegisteredPluginsWithOptions.Length;
|
SelectedModIdx = Plugins.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
Refresh(__instance);
|
Refresh(__instance);
|
||||||
@@ -109,7 +111,22 @@ public static class LobbyViewPanePatches
|
|||||||
|
|
||||||
private static void Refresh(LobbyViewSettingsPane menu)
|
private static void Refresh(LobbyViewSettingsPane menu)
|
||||||
{
|
{
|
||||||
ModifiersTabButton?.gameObject.SetActive(SelectedModIdx != 0);
|
if (SelectedMod == null)
|
||||||
|
{
|
||||||
|
ModifiersTabButton?.gameObject.SetActive(false);
|
||||||
|
menu.rolesTabButton.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var showModifierButton = SelectedMod.InternalOptionGroups.Any(m =>
|
||||||
|
m.ParentMenu is MenuCategory.Modifiers || m.OptionableType?.IsAssignableTo(typeof(BaseModifier)) == true);
|
||||||
|
var showRolesButton = SelectedMod.InternalOptionGroups.Any(r =>
|
||||||
|
r.ParentMenu is MenuCategory.Roles || r.OptionableType?.IsAssignableTo(typeof(ICustomRole)) == true);
|
||||||
|
|
||||||
|
ModifiersTabButton?.gameObject.SetActive(showModifierButton);
|
||||||
|
menu.rolesTabButton.gameObject.SetActive(showRolesButton);
|
||||||
|
}
|
||||||
|
|
||||||
menu.gameModeText.text = SelectedMod?.PluginInfo.Metadata.Name ?? "Main";
|
menu.gameModeText.text = SelectedMod?.PluginInfo.Metadata.Name ?? "Main";
|
||||||
menu.RefreshTab();
|
menu.RefreshTab();
|
||||||
menu.scrollBar.ScrollToTop();
|
menu.scrollBar.ScrollToTop();
|
||||||
@@ -142,7 +159,7 @@ public static class LobbyViewPanePatches
|
|||||||
[HarmonyPatch(nameof(LobbyViewSettingsPane.DrawNormalTab))]
|
[HarmonyPatch(nameof(LobbyViewSettingsPane.DrawNormalTab))]
|
||||||
public static bool DrawNormalTabPatch(LobbyViewSettingsPane __instance)
|
public static bool DrawNormalTabPatch(LobbyViewSettingsPane __instance)
|
||||||
{
|
{
|
||||||
if (SelectedModIdx == 0 || SelectedMod == null)
|
if ((CustomGameModeManager.IsClassic() || CustomGameModeManager.IsHideNSeek()) && (SelectedModIdx == 0 || SelectedMod == null))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -153,7 +170,9 @@ public static class LobbyViewPanePatches
|
|||||||
}
|
}
|
||||||
|
|
||||||
var filteredGroups = SelectedMod.InternalOptionGroups
|
var filteredGroups = SelectedMod.InternalOptionGroups
|
||||||
.Where(x => x is { ParentMenu: not MenuCategory.Modifiers, OptionableType: null } && x.GroupVisible());
|
.Where(x => (x is { ParentMenu: not MenuCategory.Modifiers, OptionableType: null }
|
||||||
|
|| x.OptionableType?.IsAssignableTo(typeof(AbstractGameMode)) == true)
|
||||||
|
&& x.GroupVisible());
|
||||||
|
|
||||||
DrawOptions(__instance, filteredGroups);
|
DrawOptions(__instance, filteredGroups);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ public sealed class MiraPluginManager
|
|||||||
{
|
{
|
||||||
private readonly Dictionary<Assembly, MiraPluginInfo> _registeredPlugins = [];
|
private readonly Dictionary<Assembly, MiraPluginInfo> _registeredPlugins = [];
|
||||||
|
|
||||||
internal MiraPluginInfo[] RegisteredPlugins { get; private set; } = null!;
|
internal MiraPluginInfo[] RegisteredPlugins { get; private set; } = [];
|
||||||
internal MiraPluginInfo[] RegisteredPluginsWithOptions { get; private set; } = null!;
|
internal MiraPluginInfo[] RegisteredPluginsWithOptions { get; private set; } = [];
|
||||||
|
internal MiraPluginInfo[] PluginsWithOptionsOrGameModes { get; private set; } = [];
|
||||||
|
|
||||||
internal Dictionary<MiraPluginInfo, List<Type>> QueuedRoleRegistrations { get; } = [];
|
internal Dictionary<MiraPluginInfo, List<Type>> QueuedRoleRegistrations { get; } = [];
|
||||||
internal static MiraPluginManager Instance { get; private set; } = new();
|
internal static MiraPluginManager Instance { get; private set; } = new();
|
||||||
@@ -253,6 +254,7 @@ public sealed class MiraPluginManager
|
|||||||
// Cache all the registered plugins into an array for easy access
|
// Cache all the registered plugins into an array for easy access
|
||||||
RegisteredPlugins = [.. _registeredPlugins.Values];
|
RegisteredPlugins = [.. _registeredPlugins.Values];
|
||||||
RegisteredPluginsWithOptions = [.. RegisteredPlugins.Where(m => m.MiraPlugin.DisplayOnOptionsMenu)];
|
RegisteredPluginsWithOptions = [.. RegisteredPlugins.Where(m => m.MiraPlugin.DisplayOnOptionsMenu)];
|
||||||
|
PluginsWithOptionsOrGameModes = [..RegisteredPlugins.Where(m => m.MiraPlugin.DisplayOnOptionsMenu || m.GameModes.Count > 0)];
|
||||||
|
|
||||||
ModifierManager.Modifiers = new ReadOnlyCollection<BaseModifier>(ModifierManager.InternalModifiers);
|
ModifierManager.Modifiers = new ReadOnlyCollection<BaseModifier>(ModifierManager.InternalModifiers);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user