diff --git a/MainForm.cs b/MainForm.cs index d32be43..9b1a7cb 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -317,14 +317,14 @@ namespace WACCALauncher defVerMenu.Add(new ConfigMenuItem("Return to settings", ConfigMenuAction.Return)); - var mainMenu = new List() { + var mainMenu = new ConfigMenu(new List() { new ConfigMenuItem("set default version", ConfigMenuAction.Submenu, submenu: defVerMenu), new ConfigMenuItem("test VFD", ConfigMenuAction.Command, method: vfd_test), new ConfigMenuItem("exit to windows", ConfigMenuAction.Command, method: Application.Exit), new ConfigMenuItem("launch game", ConfigMenuAction.Return) - }; + }); - _menuManager = new MenuManager(mainMenu, "Launcher Settings"); + _menuManager = new MenuManager(mainMenu); waccaListTest.AssignMenuManager(_menuManager); _loadingLabel.Font = _menuFont; @@ -590,13 +590,12 @@ namespace WACCALauncher public readonly string Name; private readonly ConfigMenuAction _action; private readonly Action _method; - public readonly List submenu; + private readonly ConfigMenu ParentMenu; + public ConfigMenu Submenu { get; private set; } private readonly List _options; private readonly Version _version; - public Label label; - - public ConfigMenuItem(string name, ConfigMenuAction action = ConfigMenuAction.None, Action method = null, List submenu = null, List options = null, Version version = null) { + public ConfigMenuItem(string name, ConfigMenuAction action = ConfigMenuAction.None, Action method = null, ConfigMenu submenu = null, List options = null, Version version = null) { this.Name = name; this._action = action; @@ -610,21 +609,11 @@ namespace WACCALauncher throw new ArgumentException($"Menu item '{name}' was defined with VersionSelect type, but has no version associated."); this._method = method; - this.submenu = submenu; + this.Submenu = submenu; this._options = options; this._version = version; } - public void Activate() - { - label.ForeColor = Color.Red; - } - - public void Deactivate() - { - label.ForeColor = Color.White; - } - public void Select(MainForm form) { if (_action == ConfigMenuAction.Command) @@ -632,11 +621,11 @@ namespace WACCALauncher // only works with static methods, why this._method(); } - else if (_action == ConfigMenuAction.Submenu && submenu != null) + else if (_action == ConfigMenuAction.Submenu && Submenu != null) { Console.WriteLine("attempting submenu"); - form._menuManager.NavigateToSubMenu(Name); - form.waccaListTest.Update(); + form._menuManager.NavigateToSubmenu(this); + //form.waccaListTest.Update(); //form.GenerateMenu(_submenu); } else if (_action == ConfigMenuAction.ItemSelect && _options != null) @@ -664,22 +653,52 @@ namespace WACCALauncher } } + public class ConfigMenu + { + public List Items; + private ConfigMenu ParentMenu; + } + public class MenuManager { - private List currentMenu; + private ConfigMenu _rootMenu; + private ConfigMenu _currentMenu; public readonly string name; - public MenuManager(List menu, string menuName) + public MenuManager(ConfigMenu root) { - currentMenu = menu; - name = menuName; + _rootMenu = root; + _currentMenu = _rootMenu; } - public List GetCurrentMenu() + public ConfigMenu GetCurrentMenu() { - return currentMenu; + return _currentMenu; } + public void NavigateToSubmenu(int index) + { + if (index >= 0 && index < _currentMenu.Items.Count) + { + var selectedMenuItem = _currentMenu.Items[index]; + if (selectedMenuItem.Submenu != null) + { + selectedMenuItem.Submenu.ParentContainer = _currentMenu; + _currentMenu = selectedMenuItem.Submenu; + } + } + } + + public void NavigateBack() + { + if (_currentContainer.ParentContainer != null) + { + _currentContainer = _currentContainer.ParentContainer; + } + } + + /* + public void NavigateToSubMenu(string optionName) { if (optionName != string.Empty && optionName != null) @@ -699,6 +718,7 @@ namespace WACCALauncher // currentMenu = currentMenu[0].Parent.SubItems; // } //} + */ } } diff --git a/WACCALauncher.csproj b/WACCALauncher.csproj index ba4fa89..06278c2 100644 --- a/WACCALauncher.csproj +++ b/WACCALauncher.csproj @@ -39,13 +39,13 @@ - ..\WACCAHelper\packages\ini-parser.2.5.2\lib\net20\INIFileParser.dll + packages\ini-parser.2.5.2\lib\net20\INIFileParser.dll - ..\WACCAHelper\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll + packages\SharpDX.4.2.0\lib\net45\SharpDX.dll - ..\WACCAHelper\packages\SharpDX.DirectInput.4.2.0\lib\net45\SharpDX.DirectInput.dll + packages\SharpDX.DirectInput.4.2.0\lib\net45\SharpDX.DirectInput.dll