diff --git a/ConfigManager.cs b/ConfigManager.cs index 742d1783..4a882544 100644 --- a/ConfigManager.cs +++ b/ConfigManager.cs @@ -119,7 +119,6 @@ internal static class ConfigManager // StatsDisplay - public static ConfigEntry StatsDisplayEnable; public static ConfigEntry StatsDisplayStatString; public static ConfigEntry StatsDisplayStatStringCustomBind; public static ConfigEntry StatsDisplayCustomBind; @@ -175,17 +174,29 @@ internal static class ConfigManager static ConfigManager() { - ConfigFileComponents = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Components.cfg", true); - ConfigFileMisc = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Misc.cfg", true); - ConfigFileAdvancedIcons = new ConfigFile(Paths.ConfigPath + "\\BetterUI-AdvancedIcons.cfg", true); - ConfigFileBuffs = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Buffs.cfg", true); - ConfigFileCommandImprovements = new ConfigFile(Paths.ConfigPath + "\\BetterUI-CommandImprovements.cfg", true); - ConfigFileDPSMeter = new ConfigFile(Paths.ConfigPath + "\\BetterUI-DPSMeter.cfg", true); - ConfigFileItemCounters = new ConfigFile(Paths.ConfigPath + "\\BetterUI-ItemCounters.cfg", true); - ConfigFileStatsDisplay = new ConfigFile(Paths.ConfigPath + "\\BetterUI-StatsDisplay.cfg", true); - ConfigFileSorting = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Sorting.cfg", true); + BindComponentsConfig(); + + if (ComponentsMisc.Value) + BindMiscConfig(); + if (ComponentsAdvancedIcons.Value) + BindAdvancedIconsConfig(); + if (ComponentsBuffTimers.Value) + BindBuffsConfig(); + if (ComponentsCommandImprovements.Value) + BindCommandScrapperImprovementsConfig(); + if (ComponentsDPSMeter.Value) + BindDPSMeterConfig(); + if (ComponentsItemCounters.Value) + BindItemCountersConfig(); + if (ComponentsStatsDisplay.Value) + BindStatsDisplayConfig(); + if (ComponentsItemSorting.Value) + BindSortingConfig(); + } - // Components + static void BindComponentsConfig() + { + ConfigFileComponents = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Components.cfg", true); ComponentsAdvancedIcons = Bind(ConfigFileComponents, "Components", "AdvancedIcons", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); @@ -202,8 +213,11 @@ static ConfigManager() ComponentsMisc = Bind(ConfigFileComponents, "Components", "Misc", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); ComponentsStatsDisplay = Bind(ConfigFileComponents, "Components", "StatsDisplay", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); + } - // Misc + static void BindMiscConfig() + { + ConfigFileMisc = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Misc.cfg", true); MiscShowHidden = Bind(ConfigFileMisc, "Misc", "ShowHidden", false, "Show hidden items in the item inventory."); @@ -220,8 +234,11 @@ static ConfigManager() MiscShowPickupDescription = Bind(ConfigFileMisc, "Misc", "ShowPickupDescription", true, "Show the item description on the interaction pop-up."); MiscPickupDescriptionAdvanced = Bind(ConfigFileMisc, "Misc", "PickupDescriptionAdvanced", false, "Show advanced descriptions for the interaction pop-up."); + } - // Advanced Icons + static void BindAdvancedIconsConfig() + { + ConfigFileAdvancedIcons = new ConfigFile(Paths.ConfigPath + "\\BetterUI-AdvancedIcons.cfg", true); AdvancedIconsItemAdvancedDescriptions = Bind(ConfigFileAdvancedIcons, "Item Improvements", "AdvancedDescriptions", true, "Show advanced descriptions when hovering over an item."); @@ -244,8 +261,11 @@ static ConfigManager() AdvancedIconsSkillShowProcCoefficient = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "ShowProcCoefficient", true, "Show the proc coefficient when hovering over a skill."); AdvancedIconsSkillCalculateSkillProcEffects = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "CalculateProcEffects", true, "Show the effects of carried items, adjusted for each skill's proc coefficient."); + } - // Buffs + static void BindBuffsConfig() + { + ConfigFileBuffs = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Buffs.cfg", true); BuffTimers = Bind(ConfigFileBuffs, "Buffs", "BuffTimers", true, "Show buff timers (host only)."); @@ -265,8 +285,11 @@ static ConfigManager() BuffTimersTextAlignmentOption = (TMPro.TextAlignmentOptions)Enum.Parse(typeof(TMPro.TextAlignmentOptions), BuffTimersPosition.Value, true); BuffTimersFontSize = Bind(ConfigFileBuffs, "Buffs", "CountersFontSize", 23f, "Size of the buff timer text."); + } - // Command / Scrapper Improvements + static void BindCommandScrapperImprovementsConfig() + { + ConfigFileCommandImprovements = new ConfigFile(Paths.ConfigPath + "\\BetterUI-CommandImprovements.cfg", true); CommandResizeCommandWindow = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "ResizeCommandWindow", true, "Resize the command window depending on the number of items."); @@ -302,8 +325,11 @@ static ConfigManager() CommandCountersFontSize = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersFontSize", 20f, "Size of the command item counter text."); CommandCountersPrefix = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersPrefix", "x", "Prefix for the command item counter. Example 'x' will show x0, x1, x2, etc.\nCan be empty."); + } - // DPSMeter + static void BindDPSMeterConfig() + { + ConfigFileDPSMeter = new ConfigFile(Paths.ConfigPath + "\\BetterUI-DPSMeter.cfg", true); DPSMeterTimespan = Bind(ConfigFileDPSMeter, "DPSMeter", "Timespan", 5f, "Calculate DPS across this many seconds."); @@ -333,8 +359,11 @@ static ConfigManager() DPSMeterWindowSize = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowSize", new Vector2(350, 45), "Size of the DPSMeter window."); DPSMeterWindowAngle = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowAngle", new Vector3(0, -6, 0), "Angle of the DPSMeter window."); + } - // ItemCounters + static void BindItemCountersConfig() + { + ConfigFileItemCounters = new ConfigFile(Paths.ConfigPath + "\\BetterUI-ItemCounters.cfg", true); ItemCountersShowItemCounters = Bind(ConfigFileItemCounters, "ItemCounters", "ShowItemCounters", true, "Enable/Disable ItemCounters entirely."); @@ -378,11 +407,11 @@ static ConfigManager() ItemCountersItemScores = new Dictionary(); + } - - // StatsDisplay - - StatsDisplayEnable = Bind(ConfigFileStatsDisplay, "StatsDisplay", "Enable", true, "Enable/Disable the StatsDisplay entirely."); + static void BindStatsDisplayConfig() + { + ConfigFileStatsDisplay = new ConfigFile(Paths.ConfigPath + "\\BetterUI-StatsDisplay.cfg", true); StatsDisplayStatString = Bind(ConfigFileStatsDisplay, "StatsDisplay", "StatString", "" + @@ -455,8 +484,11 @@ static ConfigManager() StatsDisplayWindowSize = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowSize", new Vector2(200, 600), "Size of the StatsDisplay window."); StatsDisplayWindowAngle = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowAngle", new Vector3(0, 6, 0), "Angle of the StatsDisplay window."); + } - // Sorting + static void BindSortingConfig() + { + ConfigFileSorting = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Sorting.cfg", true); SortingSortItemsInventory = Bind(ConfigFileSorting, "Sorting", "SortItemsInventory", true, "Sort items in the inventory and scoreboard."); @@ -514,7 +546,6 @@ static ConfigManager() SortingSortOrderScrapper = Bind(ConfigFileSorting, "Sorting", "SortOrderScrapper", "134", "Sort order for the scrapper window."); - } /// diff --git a/ModComponents/CommandImprovements.cs b/ModComponents/CommandImprovements.cs index 6df5f09f..e5215633 100644 --- a/ModComponents/CommandImprovements.cs +++ b/ModComponents/CommandImprovements.cs @@ -18,8 +18,7 @@ static CommandImprovements() internal static void Hook() { if (ConfigManager.CommandResizeCommandWindow.Value || - ConfigManager.SortingSortItemsCommand.Value || - ConfigManager.SortingSortItemsScrapper.Value) + ConfigManager.ComponentsItemSorting.Value && (ConfigManager.SortingSortItemsCommand.Value || ConfigManager.SortingSortItemsScrapper.Value)) { BetterUIPlugin.Hooks.Add("SetPickupOptions", PickupPickerPanel_SetPickupOptions); } @@ -136,14 +135,14 @@ public static void PickupPickerPanel_SetPickupOptions(Action().enabled = false; } - if (ConfigManager.SortingSortItemsCommand.Value) + if (ConfigManager.ComponentsItemSorting.Value && ConfigManager.SortingSortItemsCommand.Value) { sortOrder = ConfigManager.SortingSortOrderCommand.Value; break; } goto default; case "SCRAPPER_CONTEXT": - if (ConfigManager.SortingSortItemsScrapper.Value) + if (ConfigManager.ComponentsItemSorting.Value && ConfigManager.SortingSortItemsScrapper.Value) { sortOrder = ConfigManager.SortingSortOrderScrapper.Value; break; @@ -154,34 +153,36 @@ public static void PickupPickerPanel_SetPickupOptions(Action PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex != EquipmentIndex.None)) + if (ConfigManager.ComponentsItemSorting.Value) { - foreach (RoR2.PickupPickerController.Option option in options) + Inventory inventory = LocalUserManager.GetFirstLocalUser().cachedMasterController.master.inventory; + + if (options.All(option => PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex != EquipmentIndex.None)) { - availableIndex[(int)PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex] = option.available; - } + foreach (RoR2.PickupPickerController.Option option in options) + { + availableIndex[(int)PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex] = option.available; + } - List sortedItems = ItemSorting.sortItems(options.Select(option => PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex).ToList(), sortOrder); + List sortedItems = ItemSorting.sortItems(options.Select(option => PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex).ToList(), sortOrder); - sortedItems.Select(equipemntIndex => new RoR2.PickupPickerController.Option { pickupIndex = PickupCatalog.FindPickupIndex(equipemntIndex), available = availableIndex[(int)equipemntIndex] }).ToArray().CopyTo(sortedOptions, 0); ; - sortedOptions.Select(option => Array.IndexOf(options, option)).ToArray().CopyTo(optionMap, 0); - options = sortedOptions.Take(options.Length).ToArray(); - } - else if (options.All(option => PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex != ItemIndex.None)) - { - foreach (RoR2.PickupPickerController.Option option in options) - { - availableIndex[(int)PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex] = option.available; + sortedItems.Select(equipemntIndex => new RoR2.PickupPickerController.Option { pickupIndex = PickupCatalog.FindPickupIndex(equipemntIndex), available = availableIndex[(int)equipemntIndex] }).ToArray().CopyTo(sortedOptions, 0); ; + sortedOptions.Select(option => Array.IndexOf(options, option)).ToArray().CopyTo(optionMap, 0); + options = sortedOptions.Take(options.Length).ToArray(); } + else if (options.All(option => PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex != ItemIndex.None)) + { + foreach (RoR2.PickupPickerController.Option option in options) + { + availableIndex[(int)PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex] = option.available; + } - List sortedItems = ItemSorting.sortItems(options.Select(option => PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex).ToList(), inventory, sortOrder); + List sortedItems = ItemSorting.sortItems(options.Select(option => PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex).ToList(), inventory, sortOrder); - sortedItems.Select(itemIndex => new RoR2.PickupPickerController.Option { pickupIndex = PickupCatalog.FindPickupIndex(itemIndex), available = availableIndex[(int)itemIndex] }).ToArray().CopyTo(sortedOptions, 0); - sortedOptions.Select(option => Array.IndexOf(options, option)).ToArray().CopyTo(optionMap, 0); - options = sortedOptions.Take(options.Length).ToArray(); + sortedItems.Select(itemIndex => new RoR2.PickupPickerController.Option { pickupIndex = PickupCatalog.FindPickupIndex(itemIndex), available = availableIndex[(int)itemIndex] }).ToArray().CopyTo(sortedOptions, 0); + sortedOptions.Select(option => Array.IndexOf(options, option)).ToArray().CopyTo(optionMap, 0); + options = sortedOptions.Take(options.Length).ToArray(); + } } orig(self, options); diff --git a/ModComponents/StatsDisplay.cs b/ModComponents/StatsDisplay.cs index 79dc403a..4c06cbb9 100644 --- a/ModComponents/StatsDisplay.cs +++ b/ModComponents/StatsDisplay.cs @@ -100,7 +100,7 @@ static StatsDisplay() regexpattern = new Regex(@"(\" + String.Join(@"|\", sortedKeys) + ")"); - if (ConfigManager.StatsDisplayEnable.Value) + if (ConfigManager.ComponentsStatsDisplay.Value) { RoR2.Run.onRunStartGlobal += runStartGlobal; } @@ -137,7 +137,7 @@ internal static void runStartGlobal(RoR2.Run self) } static void onHUDAwake(RoR2.UI.HUD self) { - if (ConfigManager.StatsDisplayEnable.Value) + if (ConfigManager.ComponentsStatsDisplay.Value) { statsDisplayContainer = new GameObject("StatsDisplayContainer"); RectTransform rectTransform = statsDisplayContainer.AddComponent();