private void AddRefill(RefillProcessor refill) { refill.CurrencyClass.Values = RefillCurrencyNames; var refillRoot = new BaseSettingsDrawer("", GetUniqDrawerId()); RefillMenuRootMenu.Children.Insert(RefillMenuRootMenu.Children.Count - 1, refillRoot); refillRoot.Children.Add(new ComboBoxSettingDrawer(refill.CurrencyClass, "Currency", GetUniqDrawerId())); refill.Amount.Max = refill.MaxStackAmount; refillRoot.Children.Add(new IntegerSettingsDrawer(refill.Amount, "Amount", GetUniqDrawerId())); refillRoot.Children.Add(new IntegerSettingsDrawer(refill.InventPosX, "Inventory Pos X", GetUniqDrawerId())); refillRoot.Children.Add(new IntegerSettingsDrawer(refill.InventPosY, "Inventory Pos Y", GetUniqDrawerId())); var removeButton = new ButtonNode(); var removeButtonDrawer = new ButtonSettingDrawer(removeButton, "Delete Refill", GetUniqDrawerId()); refillRoot.Children.Add(removeButtonDrawer); removeButton.OnPressed += delegate { RefillMenuRootMenu.Children.Remove(refillRoot); Settings.Refills.Remove(refill); }; }
private void AddRefill(RefillProcessor refill) { refill.CurrencyClass.Values = RefillCurrencyNames; var refillRoot = new BaseSettingsDrawer { SettingName = "", SettingId = GetUniqDrawerId() }; RefillMenuRootMenu.Children.Insert(RefillMenuRootMenu.Children.Count - 1, refillRoot); refillRoot.Children.Add(new ComboBoxSettingDrawer(refill.CurrencyClass) { SettingName = "Currency", SettingId = GetUniqDrawerId() }); refillRoot.Children.Add(new IntegerSettingsDrawer(refill.Amount) { SettingName = "Amount", SettingId = GetUniqDrawerId() }); refillRoot.Children.Add(new IntegerSettingsDrawer(refill.InventPosX) { SettingName = "Inventory Pos X", SettingId = GetUniqDrawerId() }); refillRoot.Children.Add(new IntegerSettingsDrawer(refill.InventPosY) { SettingName = "Inventory Pos Y", SettingId = GetUniqDrawerId() }); var removeButton = new ButtonNode(); var removeButtonDrawer = new ButtonSettingDrawer(removeButton) { SettingName = "Delete Refill", SettingId = GetUniqDrawerId() }; refillRoot.Children.Add(removeButtonDrawer); removeButton.OnPressed += delegate { RefillMenuRootMenu.Children.Remove(refillRoot); Settings.Refills.Remove(refill); }; }
private List <StashTabNode> StashTabNodes = new List <StashTabNode>(); //This is for hot reload, we will unload it private void GenerateStashieSettingsMenu() //Separate func cuz we can call it in anu moment to reload all menu { if (FiltersMenuRootMenu != null) { SettingsDrawers.Remove(FiltersMenuRootMenu); } if (RefillMenuRootMenu != null) { SettingsDrawers.Remove(RefillMenuRootMenu); } FiltersMenuRootMenu = new BaseSettingsDrawer("Filters", GetUniqDrawerId()); SettingsDrawers.Add(FiltersMenuRootMenu); var submenu = new Dictionary <string, BaseSettingsDrawer>(); foreach (var customFilter in _customFilters) { if (!Settings.FilterOptions.TryGetValue(customFilter.Name, out var tabNode)) { tabNode = new StashTabNode(); Settings.FilterOptions.Add(customFilter.Name, tabNode); } StashTabNodes.Add(tabNode); StashTabController.RegisterStashNode(tabNode); var filterParent = FiltersMenuRootMenu; if (!string.IsNullOrEmpty(customFilter.SubmenuName)) { if (!submenu.TryGetValue(customFilter.SubmenuName, out filterParent)) { filterParent = new BaseSettingsDrawer(customFilter.SubmenuName, GetUniqDrawerId()); FiltersMenuRootMenu.Children.Add(filterParent); submenu.Add(customFilter.SubmenuName, filterParent); } } filterParent.Children.Add(new StashTabNodeSettingDrawer(tabNode, customFilter.Name, GetUniqDrawerId())); customFilter.StashIndexNode = tabNode; } RefillMenuRootMenu = new CheckboxSettingDrawer(Settings.RefillCurrency, "Refill Currency", GetUniqDrawerId()); SettingsDrawers.Add(RefillMenuRootMenu); RefillMenuRootMenu.Children.Add(new StashTabNodeSettingDrawer(Settings.CurrencyStashTab, "Currency Tab", GetUniqDrawerId())); StashTabController.RegisterStashNode(Settings.CurrencyStashTab); RefillMenuRootMenu.Children.Add(new CheckboxSettingDrawer(Settings.AllowHaveMore, "Allow Have More", GetUniqDrawerId())); var refillRoot = new BaseSettingsDrawer("Refills:", GetUniqDrawerId()); RefillMenuRootMenu.Children.Add(refillRoot); var addTabButton = new ButtonNode(); var addTabButtonDrawer = new ButtonSettingDrawer(addTabButton, "Add Refill", GetUniqDrawerId()); RefillMenuRootMenu.Children.Add(addTabButtonDrawer); addTabButton.OnPressed += delegate { var newRefill = new RefillProcessor(); AddRefill(newRefill); Settings.Refills.Add(newRefill); }; foreach (var refill in Settings.Refills) { AddRefill(refill); } }
public static List <RefillProcessor> Parse(string pluginDir) { var refills = new List <RefillProcessor>(); var refillConfigPath = Path.Combine(pluginDir, REFILL_CONFIG); if (!File.Exists(refillConfigPath)) { return(refills); } var configLines = File.ReadAllLines(refillConfigPath); for (var i = 0; i < configLines.Length; i++) { var configLine = configLines[i]; configLine = configLine.Replace("\t", ""); if (configLine.Replace(" ", "").Length == 0) { continue; } if (configLine.StartsWith(SYMBOL_IGNORE) || configLine.StartsWith(SYMBOL_IGNORE2)) { continue; } var newRefill = new RefillProcessor(); var nameIndex = configLine.IndexOf(SYMBOL_NAMEDIVIDER, StringComparison.Ordinal); if (nameIndex == -1) { DebugWindow.LogMsg($"Refill parser: Can't find refill name in line: {configLine}. Name should have \":\" divider.", 10); continue; } newRefill.MenuName = configLine.Substring(0, nameIndex); TrimName(ref newRefill.MenuName); configLine = configLine.Substring(nameIndex + SYMBOL_NAMEDIVIDER.Length); var configLineParams = configLine.Split(SYMBOL_PARAMETERSDIVIDER); if (configLineParams.Length != 4) { DebugWindow.LogMsg( $"Refill parser: Config line should have 4 parameters (ClassName,StackSize,InventoryX,InventoryY): {configLine}, Ignoring refill..", 10); continue; } newRefill.CurrencyClass = configLineParams[0]; TrimName(ref newRefill.CurrencyClass); if (!int.TryParse(configLineParams[1], out newRefill.StackSize)) { DebugWindow.LogMsg( $"Refill parser: Can't parse StackSize from 2nd parameter in line: {configLine} (line num: {i + 1}), Ignoring refill..", 10); continue; } if (!int.TryParse(configLineParams[2], out newRefill.InventPos.X)) { DebugWindow.LogMsg( $"Refill parser: Can't parse InventoryX from 3rd parameter in line: {configLine} (line num: {i + 1}), Ignoring refill..", 10); continue; } if (newRefill.InventPos.X < 1 || newRefill.InventPos.X > 12) { DebugWindow.LogMsg( $"Refill parser: InventoryX should be in range 1-12, current value: {newRefill.InventPos.X} (line num: {i + 1}), Ignoring refill..", 10); continue; } if (!int.TryParse(configLineParams[3], out newRefill.InventPos.Y)) { DebugWindow.LogMsg( $"Refill parser: Can't parse InventoryY from 4th parameter in line: {configLine} (line num: {i + 1}), Ignoring refill..", 10); continue; } if (newRefill.InventPos.Y < 1 || newRefill.InventPos.Y > 5) { DebugWindow.LogMsg( $"Refill parser: InventPosY should be in range 1-5, current value: {newRefill.InventPos.Y} (line num: {i + 1}), Ignoring refill..", 10); continue; } // Convert to zero based index. newRefill.InventPos.X--; newRefill.InventPos.Y--; refills.Add(newRefill); } return(refills); }