Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 54 additions & 23 deletions ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ internal static class ConfigManager

// StatsDisplay

public static ConfigEntry<bool> StatsDisplayEnable;
public static ConfigEntry<String> StatsDisplayStatString;
public static ConfigEntry<String> StatsDisplayStatStringCustomBind;
public static ConfigEntry<String> StatsDisplayCustomBind;
Expand Down Expand Up @@ -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.");

Expand All @@ -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.");

Expand All @@ -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.");

Expand All @@ -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).");

Expand All @@ -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.");

Expand Down Expand Up @@ -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.");

Expand Down Expand Up @@ -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.");

Expand Down Expand Up @@ -378,11 +407,11 @@ static ConfigManager()


ItemCountersItemScores = new Dictionary<ItemDef, float>();
}


// 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",
"<color=#FFFFFF>" +
Expand Down Expand Up @@ -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.");

Expand Down Expand Up @@ -514,7 +546,6 @@ static ConfigManager()

SortingSortOrderScrapper = Bind(ConfigFileSorting, "Sorting", "SortOrderScrapper", "134",
"Sort order for the scrapper window.");

}

/// <summary>
Expand Down
51 changes: 26 additions & 25 deletions ModComponents/CommandImprovements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RoR2.UI.PickupPickerPanel, RoR2.PickupPickerController.Option[]>("SetPickupOptions", PickupPickerPanel_SetPickupOptions);
}
Expand Down Expand Up @@ -136,14 +135,14 @@ public static void PickupPickerPanel_SetPickupOptions(Action<RoR2.UI.PickupPicke
{
self.transform.GetComponent<LeTai.Asset.TranslucentImage.TranslucentImage>().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;
Expand All @@ -154,34 +153,36 @@ public static void PickupPickerPanel_SetPickupOptions(Action<RoR2.UI.PickupPicke
return;
}


Inventory inventory = LocalUserManager.GetFirstLocalUser().cachedMasterController.master.inventory;

if (options.All(option => 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<EquipmentIndex> sortedItems = ItemSorting.sortItems(options.Select(option => PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex).ToList(), sortOrder);
List<EquipmentIndex> 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<ItemIndex> sortedItems = ItemSorting.sortItems(options.Select(option => PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex).ToList(), inventory, sortOrder);
List<ItemIndex> 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);
Expand Down
4 changes: 2 additions & 2 deletions ModComponents/StatsDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static StatsDisplay()
regexpattern = new Regex(@"(\" + String.Join(@"|\", sortedKeys) + ")");


if (ConfigManager.StatsDisplayEnable.Value)
if (ConfigManager.ComponentsStatsDisplay.Value)
{
RoR2.Run.onRunStartGlobal += runStartGlobal;
}
Expand Down Expand Up @@ -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<RectTransform>();
Expand Down