diff --git a/.idea/.idea.SSMenuSystem/.idea/discord.xml b/.idea/.idea.SSMenuSystem/.idea/discord.xml
index 30bab2a..912db82 100644
--- a/.idea/.idea.SSMenuSystem/.idea/discord.xml
+++ b/.idea/.idea.SSMenuSystem/.idea/discord.xml
@@ -1,7 +1,14 @@
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EventHandler.cs b/EventHandler.cs
index 6a82991..92251d3 100644
--- a/EventHandler.cs
+++ b/EventHandler.cs
@@ -36,6 +36,7 @@ private static void SyncChangedGroup(ReferenceHub hub)
public static void OnReceivingInput(ReferenceHub hub, ServerSpecificSettingBase ss)
{
+ Log.Debug("Received input for hub " + hub.nicknameSync.MyNick + ": " + ss.Label + " - " + ss.SettingId + "(" + ss.GetType().Name + ")");
try
{
if (Parameters.SyncCache.TryGetValue(hub, out List value))
@@ -45,6 +46,13 @@ public static void OnReceivingInput(ReferenceHub hub, ServerSpecificSettingBase
return;
}
+ // return to menu
+ if (ss.SettingId == -999)
+ {
+ Menu.LoadForPlayer(hub, null);
+ return;
+ }
+
if (ss.OriginalDefinition != null)
{
ss.Label = ss.OriginalDefinition.Label;
@@ -54,12 +62,7 @@ public static void OnReceivingInput(ReferenceHub hub, ServerSpecificSettingBase
else // is a pin or header
ss.SettingId -= Menu.GetCurrentPlayerMenu(hub)?.Hash ?? 0;
- // return to menu
- if (ss.SettingId == -999)
- {
- Menu.LoadForPlayer(hub, null);
- return;
- }
+ Log.Debug("Values after Originial definition: " + ss.Label + " - " + ss.SettingId + "(" + ss.GetType().Name + ")");
// check permissions
Menu menu = Menu.GetCurrentPlayerMenu(hub);
@@ -91,8 +94,9 @@ public static void OnReceivingInput(ReferenceHub hub, ServerSpecificSettingBase
// load method when input is used on specific menu.
else if (menu != null)
{
- if (ss.SettingId < 0)
- Menu.LoadForPlayer(hub, menu.TryGetSubMenu(ss.SettingId));
+ //if (ss.SettingId < 0)
+ if (menu.TryGetSubMenu(ss.SettingId, out Menu subMenu))
+ Menu.LoadForPlayer(hub, subMenu);
else
{
if (menu.InternalSettingsSync[hub].Any(x => x.SettingId == ss.SettingId))
@@ -100,10 +104,29 @@ public static void OnReceivingInput(ReferenceHub hub, ServerSpecificSettingBase
else
menu.InternalSettingsSync[hub].Add(ss);
- ServerSpecificSettingBase s = menu.SentSettings.TryGetValue(hub, out ServerSpecificSettingBase[] customSettings) ? customSettings.FirstOrDefault(b => b.SettingId == ss.SettingId) : null;
+ ServerSpecificSettingBase s = menu.SentSettings.TryGetValue(hub, out ServerSpecificSettingBase[] customSettings)
+ ? customSettings.FirstOrDefault(b => b.SettingId == ss.SettingId)
+ : null;
+
+ s ??= customSettings?.FirstOrDefault(b => b.SettingId == ss.SettingId - menu.Hash);
+
+ s ??= customSettings?.First(b => b.SettingId - menu.Hash == ss.SettingId);
+
+ if (customSettings != null)
+ {
+ foreach (ServerSpecificSettingBase tkt in customSettings)
+ {
+ Log.Debug("Values found in sent settings for target hub: " + tkt.Label + " - " + tkt.SettingId + "(removed hash: " + (tkt.SettingId - menu.Hash) + ")" + "(" + tkt.GetType().Name + ")");
+ }
+ }
+ else
+ Log.Error("No sent settings found.");
+
if (s == null)
throw new Exception("Failed to find the sent setting.");
+ Log.Debug("Value found in sent settings " + s.Label + " - " + s.SettingId + "(" + s.GetType().Name + ")");
+
switch (s)
{
case Button wBtn:
diff --git a/Examples/LightSpawnerExample.cs b/Examples/LightSpawnerExample.cs
index 7a9cdcc..7728845 100644
--- a/Examples/LightSpawnerExample.cs
+++ b/Examples/LightSpawnerExample.cs
@@ -9,6 +9,7 @@
using SSMenuSystem.Features;
using SSMenuSystem.Features.Wrappers;
using UserSettings.ServerSpecific;
+using Log = SSMenuSystem.Features.Log;
namespace SSMenuSystem.Examples
{
diff --git a/Examples/PrimitiveSpawnerExample.cs b/Examples/PrimitiveSpawnerExample.cs
index 270d70e..f4939de 100644
--- a/Examples/PrimitiveSpawnerExample.cs
+++ b/Examples/PrimitiveSpawnerExample.cs
@@ -3,7 +3,6 @@
using System.Globalization;
using System.Linq;
using AdminToys;
-using Exiled.Events.Commands.Hub;
using GameCore;
using Mirror;
using SSMenuSystem.Features;
diff --git a/Features/Menu.cs b/Features/Menu.cs
index ac941af..f2433bd 100644
--- a/Features/Menu.cs
+++ b/Features/Menu.cs
@@ -171,8 +171,10 @@ public static void Register(Menu menu)
Log.Debug($"loading Server Specific menu {menu.Name}...");
if (CheckSameId(menu))
throw new ArgumentException($"another menu with id {menu.Id} is already registered. can't load {menu.Name}.");
- if (menu.Id >= 0)
- throw new ArgumentException($"menus ids must be < 0 (to let space for parameters and 0 is only for Main Menu).");
+ if (menu.Id == 0)
+ throw new ArgumentException("Menus id must not be equal to 0. 0 is reserved for Main Menu.");
+ /*if (menu.Id >= 0)
+ //throw new ArgumentException($"menus ids must be < 0 (to let space for parameters and 0 is only for Main Menu).");*/
if (string.IsNullOrEmpty(menu.Name))
throw new ArgumentException($"menus name cannot be null or empty.");
if (Menus.Any(x => x.Name == menu.Name))
@@ -301,11 +303,8 @@ private static ServerSpecificSettingBase[] GetMainMenu(ReferenceHub hub)
return mainMenu.ToArray();
mainMenu.Add(new SSGroupHeader("Main Menu"));
- foreach (Menu menu in LoadedMenus.Where(x => x.CheckAccess(hub)))
- {
- if (menu.MenuRelated == null)
- mainMenu.Add(new SSButton(menu.Id, string.Format(Plugin.Instance.Translation.OpenMenu.Label, menu.Name), Plugin.Instance.Translation.OpenMenu.ButtonText, null, string.IsNullOrEmpty(menu.Description) ? null : menu.Description));
- }
+ foreach (Menu menu in LoadedMenus.Where(x => x.CheckAccess(hub) && x.MenuRelated == null))
+ mainMenu.Add(new SSButton(menu.Id, string.Format(Plugin.Instance.Translation.OpenMenu.Label, menu.Name), Plugin.Instance.Translation.OpenMenu.ButtonText, null, string.IsNullOrEmpty(menu.Description) ? null : menu.Description));
mainMenu.AddRange(GetGlobalKeybindings(hub, null));
@@ -406,7 +405,7 @@ private static ServerSpecificSettingBase[] GetGlobalKeybindings(ReferenceHub hub
foreach (KeyValuePair