Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions Features/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,35 @@ private List<ServerSpecificSettingBase> GetSettings(ReferenceHub hub)
if (Plugin.Instance.Config.AllowPinnedContent)
settings.AddRange(Pinned.Values.SelectMany(pin => pin));

if (LoadedMenus.First(x => x.CheckAccess(hub) && x.MenuRelated == null) != this || Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne)
List<Menu> availableMainMenus = LoadedMenus
.Where(x => x.CheckAccess(hub) && x.MenuRelated == null)
.ToList();

int availableMainMenusCount = availableMainMenus.Count;
Menu firstMainMenu = availableMainMenus.FirstOrDefault();

bool isActualRootMenu = Id == 0;
bool shouldAddBackButton = !isActualRootMenu &&
(MenuRelated != null ||
availableMainMenusCount > 1 ||
Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne);

if (shouldAddBackButton)
{
if (MenuRelated != null)
settings.Add(new SSButton(0, string.Format(Plugin.Instance.Translation.ReturnTo.Label, Menu.GetMenu(MenuRelated)?.Name ?? "Unknown"),
{
Menu parentMenu = GetMenu(MenuRelated);
settings.Add(new SSButton(0, string.Format(Plugin.Instance.Translation.ReturnTo.Label, parentMenu?.Name ?? "Unknown"),
Plugin.Instance.Translation.ReturnTo.ButtonText));
}
else
{
settings.Add(new SSButton(0, Plugin.Instance.Translation.ReturnToMenu.Label,
Plugin.Instance.Translation.ReturnToMenu.ButtonText));
}
}

if (LoadedMenus.First(x => x.CheckAccess(hub) && x.MenuRelated == null) == this && !Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne)
if (firstMainMenu == this && !Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne)
settings.Add(new SSGroupHeader(Name));
else
{
Expand All @@ -339,7 +357,7 @@ private List<ServerSpecificSettingBase> GetSettings(ReferenceHub hub)
foreach (Menu s in LoadedMenus.Where(x => x.MenuRelated == GetType() && x != this))
settings.Add(new SSButton(s.Id, string.Format(Plugin.Instance.Translation.OpenMenu.Label, s.Name), Plugin.Instance.Translation.OpenMenu.ButtonText, null, string.IsNullOrEmpty(Description) ? null : Description));

if (LoadedMenus.First(x => x.CheckAccess(hub) && x.MenuRelated == null) != this || Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne)
if (firstMainMenu != this || Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne)
settings.Add(new SSGroupHeader(Name, false, Description));

if (this is AssemblyMenu assemblyMenu &&
Expand Down
2 changes: 1 addition & 1 deletion SSMenuSystem.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<Content Include="SSMenuSystem.ruleset" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ExMod.Exiled" Version="9.6.1" />
<PackageReference Include="ExMod.Exiled" Version="9.7.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
7 changes: 4 additions & 3 deletions SSMenuSystem.sln.DotSettings.user
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATiming_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F203eddabefab4de1a27f4639e2fd981138800_003F76_003F2e4dd9bd_003FTiming_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATMP_005FInputField_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F290c97dfc18e41e8ad466d19041a16ef62c00_003F75_003F78c74139_003FTMP_005FInputField_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AUserSettingsEntryDescription_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8aae45512e444fd9b0c99e166b7684932fba00_003F41_003Fd5d085ab_003FUserSettingsEntryDescription_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;
&lt;Assembly Path="/home/sky/Projects/Tools/C/SCPSL plugins/Assembly-CSharp-Publicized.dll" /&gt;
&lt;Assembly Path="/home/sky/.nuget/packages/exmod.exiled/9.6.0-beta3/lib/net48/Exiled.Loader.dll" /&gt;
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="\home\sky\Projects\Tools\C\SCPSL plugins\Assembly-CSharp-Publicized.dll" /&gt;&#xD;
&lt;Assembly Path="\home\sky\.nuget\packages\exmod.exiled\9.6.0-beta3\lib\net48\Exiled.Loader.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Users\Alexomur\Desktop\projects\EXILED\Dev\Assembly-CSharp-firstpass.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String>
</wpf:ResourceDictionary>