Exemple #1
0
 private void Start()
 {
     SkMenuControllerStatus = SkUtilities.Status.Loading;
     SkUtilities.Logz(new string[2] {
         "CONTROLLER", "NOTIFY"
     }, new string[2] {
         "LOADING...", "WAITING FOR TOOLBOX."
     });
     SkModuleController = base.gameObject.AddComponent <SkModuleController>();
 }
 public void Start()
 {
     SkMainStatus = SkUtilities.Status.Loading;
     SkUtilities.Logz(new string[2] {
         "TOOLBOX", "NOTIFY"
     }, new string[2] {
         "LOADING...", "MODULES LOADING..."
     });
     BeginMainMenu();
     menuController = GetComponent <SkMenuController>();
     if (MenuOptions.Count > 0 && menuController != null)
     {
         SkMainStatus = SkUtilities.Status.Loading;
     }
     else
     {
         SkMainStatus = SkUtilities.Status.Error;
     }
     Init();
 }
 public void Update()
 {
     if (!FirstLoad)
     {
         if (SkMainStatus == SkUtilities.Status.Loading && NeedLoadModules && !NeedRetry)
         {
             foreach (SkBaseModule menuOption in MenuOptions)
             {
                 SkUtilities.Logz(new string[3] {
                     "TOOLBOX", "MODULE", "NOTIFY"
                 }, new string[2]
                 {
                     "NAME: " + menuOption.ModuleName.ToUpper(),
                     "STATUS: " + menuOption.ModuleStatus.ToString().ToUpper()
                 });
                 if (menuOption.ModuleStatus != SkUtilities.Status.Ready)
                 {
                     NeedRetry = true;
                     RetryModule.Add(menuOption);
                 }
             }
             if (!NeedRetry)
             {
                 SkMainStatus = SkUtilities.Status.Ready;
                 ErrorMonitor = true;
                 RetryCount   = 1;
             }
             if (SkMainStatus == SkUtilities.Status.Ready && MenuOptions.Count > 0)
             {
                 NeedLoadModules = false;
                 SkUtilities.Logz(new string[2] {
                     "TOOLBOX", "NOTIFY"
                 }, new string[2]
                 {
                     MenuOptions.Count + " MODULES LOADED",
                     "TOOLBOX READY."
                 });
             }
             else if (SkMainStatus == SkUtilities.Status.Error || MenuOptions.Count <= 0)
             {
                 SkUtilities.Logz(new string[2] {
                     "TOOLBOX", "NOTIFY"
                 }, new string[2]
                 {
                     MenuOptions.Count + " MODULES LOADED",
                     "TOOLBOX FAILED TO LOAD MODULES."
                 }, LogType.Error);
             }
         }
         else if (SkMainStatus == SkUtilities.Status.Loading && NeedRetry)
         {
             if (RetryCount < RetryCountMax + 1)
             {
                 for (int i = 0; i < RetryModule?.Count; i++)
                 {
                     SkUtilities.Logz(new string[4]
                     {
                         "TOOLBOX",
                         "MODULE",
                         "NOTIFY",
                         "RECHECK " + RetryCount
                     }, new string[2]
                     {
                         "NAME: " + RetryModule[i].ModuleName.ToUpper(),
                         "STATUS: " + RetryModule[i].ModuleStatus.ToString().ToUpper()
                     });
                     if (RetryModule[i].ModuleStatus != SkUtilities.Status.Ready)
                     {
                         SkMainStatus = SkUtilities.Status.Loading;
                         NeedRetry    = true;
                     }
                     else if (RetryModule[i].ModuleStatus == SkUtilities.Status.Ready)
                     {
                         RetryModule.Remove(RetryModule[i]);
                         if (RetryModule.Count == 0)
                         {
                             SkMainStatus = SkUtilities.Status.Ready;
                             break;
                         }
                     }
                 }
                 RetryCount++;
             }
             if (MenuOptions.Count <= 0)
             {
                 SkMainStatus = SkUtilities.Status.Error;
             }
             if (SkMainStatus == SkUtilities.Status.Ready)
             {
                 ErrorMonitor = true;
                 RetryCount   = 1;
                 SkUtilities.Logz(new string[2] {
                     "TOOLBOX", "NOTIFY"
                 }, new string[2]
                 {
                     MenuOptions.Count + " MODULES LOADED",
                     "TOOLBOX READY."
                 });
             }
             else if (RetryCount >= RetryCountMax + 1)
             {
                 SkUtilities.Logz(new string[2] {
                     "TOOLBOX", "NOTIFY"
                 }, new string[2] {
                     "MODULE NOT MOVING TO READY STATUS.", "UNLOADING THE MODULE(S)."
                 }, LogType.Warning);
                 foreach (SkBaseModule item in RetryModule)
                 {
                     if (item.ModuleStatus != SkUtilities.Status.Ready)
                     {
                         item.RemoveModule();
                         MenuOptions.Remove(item);
                     }
                 }
                 RetryModule.Clear();
                 NeedRetry    = false;
                 SkMainStatus = SkUtilities.Status.Loading;
                 menuController.UpdateMenuOptions(MenuOptions);
             }
         }
     }
     else
     {
         FirstLoad = false;
     }
     if (ErrorMonitor)
     {
         for (int j = 0; j < MenuOptions?.Count; j++)
         {
             SkBaseModule skBaseModule = MenuOptions[j];
             if ((object)skBaseModule != null && skBaseModule.ModuleStatus == SkUtilities.Status.Error && !RetryModule.Contains(MenuOptions[j]))
             {
                 SkUtilities.Logz(new string[2] {
                     "TOOLBOX", "NOTIFY"
                 }, new string[2]
                 {
                     "MODULE IN ERROR STATUS.",
                     "CHECKING MODULE: " + MenuOptions[j].ModuleName.ToUpper()
                 }, LogType.Warning);
                 RetryModule.Add(MenuOptions[j]);
                 continue;
             }
             SkBaseModule skBaseModule2 = MenuOptions[j];
             if ((object)skBaseModule2 != null && skBaseModule2.ModuleStatus == SkUtilities.Status.Unload)
             {
                 SkUtilities.Logz(new string[2] {
                     "TOOLBOX", "NOTIFY"
                 }, new string[1] {
                     "MODULE READY TO UNLOAD. UNLOADING MODULE: " + MenuOptions[j].ModuleName.ToUpper()
                 }, LogType.Warning);
                 MenuOptions[j].RemoveModule();
                 MenuOptions.Remove(MenuOptions[j]);
                 menuController.UpdateMenuOptions(MenuOptions);
             }
         }
         List <SkBaseModule> retryModule = RetryModule;
         if (retryModule != null && retryModule.Count > 0 && RetryCount < RetryCountMax + 1)
         {
             for (int k = 0; k < RetryModule.Count; k++)
             {
                 if (RetryModule[k].ModuleStatus == SkUtilities.Status.Ready)
                 {
                     RetryModule.Remove(RetryModule[k]);
                     SkUtilities.Logz(new string[2] {
                         "TOOLBOX", "NOTIFY"
                     }, new string[2]
                     {
                         "MODULE READY.",
                         "MODULE: " + MenuOptions[k].ModuleName.ToUpper()
                     });
                     if (RetryModule.Count == 0)
                     {
                         break;
                     }
                 }
             }
             RetryCount++;
         }
         else
         {
             List <SkBaseModule> retryModule2 = RetryModule;
             if (retryModule2 != null && retryModule2.Count > 0 && RetryCount >= RetryCountMax + 1)
             {
                 foreach (SkBaseModule item2 in RetryModule)
                 {
                     if (item2.ModuleStatus != SkUtilities.Status.Ready)
                     {
                         SkUtilities.Logz(new string[2] {
                             "TOOLBOX", "NOTIFY"
                         }, new string[2]
                         {
                             "COULD NOT RESOLVE ERROR.",
                             "UNLOADING THE MODULE: " + item2.ModuleName.ToUpper()
                         }, LogType.Warning);
                         item2.RemoveModule();
                         MenuOptions.Remove(item2);
                     }
                 }
                 RetryModule.Clear();
                 RetryCount = 1;
                 menuController.UpdateMenuOptions(MenuOptions);
                 if (MenuOptions.Count == 0)
                 {
                     SkMainStatus = SkUtilities.Status.Error;
                     SkUtilities.Logz(new string[2] {
                         "TOOLBOX", "NOTIFY"
                     }, new string[2] {
                         "NO MODULES LOADED.", "TOOLBOX ENTERING ERROR STATE."
                     }, LogType.Error);
                 }
             }
         }
     }
     OnUpdate();
 }
 internal void Unload()
 {
     ModuleStatus = SkUtilities.Status.Unload;
 }
 internal void Error()
 {
     ModuleStatus = SkUtilities.Status.Error;
 }
 internal void Loading()
 {
     ModuleStatus = SkUtilities.Status.Loading;
 }
 internal void Ready()
 {
     ModuleStatus = SkUtilities.Status.Ready;
 }
Exemple #8
0
 private void Update()
 {
     if (SkCommandProcessor.altOnScreenControls)
     {
         if (SkConfigEntry.OAltToggle != null && SkConfigEntry.OAltUp != null && SkConfigEntry.OAltDown != null && SkConfigEntry.OAltChoose != null && SkConfigEntry.OAltBack != null)
         {
             contextTipInfo1          = SkConfigEntry.OAltToggle.Value + "/" + SkConfigEntry.OAltUp.Value + "/" + SkConfigEntry.OAltDown.Value;
             contextTipInfo2          = SkConfigEntry.OAltChoose.Value + " Button";
             contextTipInfo3          = SkConfigEntry.OAltBack.Value + " Button";
             keyBindings["selToggle"] = (KeyCode)Enum.Parse(typeof(KeyCode), SkConfigEntry.OAltToggle.Value);
             keyBindings["selUp"]     = (KeyCode)Enum.Parse(typeof(KeyCode), SkConfigEntry.OAltUp.Value);
             keyBindings["selDown"]   = (KeyCode)Enum.Parse(typeof(KeyCode), SkConfigEntry.OAltDown.Value);
             keyBindings["selChoose"] = (KeyCode)Enum.Parse(typeof(KeyCode), SkConfigEntry.OAltChoose.Value);
             keyBindings["selBack"]   = (KeyCode)Enum.Parse(typeof(KeyCode), SkConfigEntry.OAltBack.Value);
         }
         else
         {
             contextTipInfo1          = "Home/PgUp/PgDn";
             contextTipInfo2          = "Insert Button";
             contextTipInfo3          = "Delete Button";
             keyBindings["selToggle"] = KeyCode.Home;
             keyBindings["selUp"]     = KeyCode.PageUp;
             keyBindings["selDown"]   = KeyCode.PageDown;
             keyBindings["selChoose"] = KeyCode.Insert;
             keyBindings["selBack"]   = KeyCode.Delete;
         }
     }
     else
     {
         contextTipInfo1          = "NumPad Arrows";
         contextTipInfo2          = "NumPad 5 to Select";
         contextTipInfo3          = "NumPad . to Back";
         keyBindings["selToggle"] = KeyCode.Keypad0;
         keyBindings["selUp"]     = KeyCode.Keypad8;
         keyBindings["selDown"]   = KeyCode.Keypad2;
         keyBindings["selChoose"] = KeyCode.Keypad5;
         keyBindings["selBack"]   = KeyCode.KeypadPeriod;
     }
     if (InitialCheck)
     {
         List <SkBaseModule> menuOptions = MenuOptions;
         if (menuOptions != null && menuOptions.Count == 0)
         {
             UpdateMenuOptions(SkModuleController.GetOptions());
         }
         else
         {
             SkMenuControllerStatus = SkUtilities.Status.Ready;
             if (SkMenuControllerStatus == SkUtilities.Status.Ready && SkModuleController.SkMainStatus == SkUtilities.Status.Ready)
             {
                 InitialCheck = false;
                 SkUtilities.Logz(new string[2] {
                     "CONTROLLER", "NOTIFY"
                 }, new string[1] {
                     "READY."
                 });
             }
         }
     }
     if (Input.GetKeyDown(keyBindings["selToggle"]) && !Console.IsVisible() && !Chat.instance.m_input.isFocused)
     {
         firstRun = false;
         MenuOpen = !MenuOpen;
     }
     if (!MenuOpen)
     {
         return;
     }
     if (!SubMenuOpen)
     {
         if (Input.GetKeyDown(keyBindings["selDown"]))
         {
             SubMenuSelection = 1;
             if (MenuSelection != maxSelectionOption)
             {
                 MenuSelection++;
             }
             else
             {
                 MenuSelection = 1;
             }
         }
         if (Input.GetKeyDown(keyBindings["selUp"]))
         {
             SubMenuSelection = 1;
             if (MenuSelection != 1)
             {
                 MenuSelection--;
             }
             else
             {
                 MenuSelection = maxSelectionOption;
             }
         }
         if (Input.GetKeyDown(keyBindings["selChoose"]))
         {
             try
             {
                 RunMethod(MenuOptions[MenuSelection - 1].CallerEntry.ItemClass);
             }
             catch (Exception ex)
             {
                 SkUtilities.Logz(new string[2] {
                     "CONTROLLER", "ERROR"
                 }, new string[1] {
                     ex.Message
                 });
             }
         }
     }
     else
     {
         if (Input.GetKeyDown(keyBindings["selDown"]))
         {
             if (SubMenuSelection != subMaxSelectionOption)
             {
                 SubMenuSelection++;
             }
             else
             {
                 SubMenuSelection = 1;
             }
         }
         if (Input.GetKeyDown(keyBindings["selUp"]))
         {
             if (SubMenuSelection != 1)
             {
                 SubMenuSelection--;
             }
             else
             {
                 SubMenuSelection = subMaxSelectionOption;
             }
         }
         if (Input.GetKeyDown(keyBindings["selChoose"]))
         {
             SubMenuOpen = false;
             try
             {
                 RunMethod(SubMenuOptionsDisplay[SubMenuSelection - 1].ItemClass);
             }
             catch (Exception)
             {
                 try
                 {
                     if (SubMenuOptionsDisplay[SubMenuSelection - 1].ItemText.Equals("Next >"))
                     {
                         IncreasePage();
                     }
                     else if (SubMenuOptionsDisplay[SubMenuSelection - 1].ItemText.Equals("< Previous"))
                     {
                         DecreasePage();
                     }
                     else
                     {
                         RunMethod(SubMenuOptionsDisplay[SubMenuSelection - 1].ItemClassStr, SubMenuOptionsDisplay[SubMenuSelection - 1].ItemText);
                     }
                 }
                 catch (Exception ex2)
                 {
                     SkUtilities.Logz(new string[2] {
                         "CONTROLLER", "ERROR"
                     }, new string[1] {
                         ex2.Message
                     });
                 }
             }
         }
     }
     if (Input.GetKeyDown(keyBindings["selBack"]))
     {
         if (!SubMenuOpen)
         {
             MenuOpen = false;
         }
         SubMenuOpen = false;
     }
 }