From b67f08db5c2da7dd5f50549adda7143b5e917523 Mon Sep 17 00:00:00 2001 From: XoXFaby Date: Sat, 18 May 2024 23:55:31 +0200 Subject: [PATCH] v3.0.3 --- CHANGELOG.md | 4 + ConfigManager.cs | 553 ++++++++++++++++++++++++++++++++ ModComponents/Buffs.cs | 56 ++++ ModComponents/ItemCounters.cs | 33 ++ ModComponents/ItemStats.cs | 462 ++++++++++++++++++++++++++ ModComponents/Language.cs | 2 +- ModComponents/StatsDisplay.cs | 38 +++ Utils/ModCompat.cs | 46 +++ Utils/ProcCoefficientCatalog.cs | 46 +++ Utils/ProcItemCatalog.cs | 140 ++++++++ Utils/Utils.cs | 33 ++ 11 files changed, 1412 insertions(+), 1 deletion(-) create mode 100644 ConfigManager.cs create mode 100644 ModComponents/Buffs.cs create mode 100644 ModComponents/ItemCounters.cs create mode 100644 ModComponents/ItemStats.cs create mode 100644 ModComponents/StatsDisplay.cs create mode 100644 Utils/ModCompat.cs create mode 100644 Utils/ProcCoefficientCatalog.cs create mode 100644 Utils/ProcItemCatalog.cs create mode 100644 Utils/Utils.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 225b60b8..a9d2b774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +v3.0.3 fix broken mods + +v3.0.2 update readme i think + v3.0.1 updated icon sorry v3: core functionality only, stripped other useless features. diff --git a/ConfigManager.cs b/ConfigManager.cs new file mode 100644 index 00000000..742d1783 --- /dev/null +++ b/ConfigManager.cs @@ -0,0 +1,553 @@ +using BepInEx; +using BepInEx.Configuration; +using System; +using UnityEngine; +using System.Collections.Generic; +using System.Linq; +using RoR2; + +namespace BetterUI +{ + internal static class ConfigManager + { + // Files + + public static ConfigFile ConfigFileComponents; + public static ConfigFile ConfigFileMisc; + public static ConfigFile ConfigFileAdvancedIcons; + public static ConfigFile ConfigFileBuffs; + public static ConfigFile ConfigFileCommandImprovements; + public static ConfigFile ConfigFileDPSMeter; + public static ConfigFile ConfigFileItemCounters; + public static ConfigFile ConfigFileStatsDisplay; + public static ConfigFile ConfigFileSorting; + + // Components + + public static ConfigEntry ComponentsAdvancedIcons; + public static ConfigEntry ComponentsBuffTimers; + public static ConfigEntry ComponentsCommandImprovements; + public static ConfigEntry ComponentsDPSMeter; + public static ConfigEntry ComponentsItemCounters; + public static ConfigEntry ComponentsItemSorting; + public static ConfigEntry ComponentsMisc; + public static ConfigEntry ComponentsStatsDisplay; + + // Misc + + public static ConfigEntry MiscShowHidden; + public static ConfigEntry MiscAdvancedPickupNotificationsItems; + public static ConfigEntry MiscAdvancedPickupNotificationsEquipements; + public static ConfigEntry MiscHidePickupNotificiationsItems; + public static ConfigEntry MiscHidePickupNotificiationsEquipements; + public static ConfigEntry MiscHidePickupNotificiationsArtifacts; + public static ConfigEntry MiscShowPickupDescription; + public static ConfigEntry MiscPickupDescriptionAdvanced; + + // AdvancedIcons + + public static ConfigEntry AdvancedIconsItemAdvancedDescriptions; + public static ConfigEntry AdvancedIconsItemItemStatsIntegration; + public static ConfigEntry AdvancedIconsEquipementShowCooldownStacks; + public static ConfigEntry AdvancedIconsEquipementAdvancedDescriptions; + public static ConfigEntry AdvancedIconsEquipementShowBaseCooldown; + public static ConfigEntry AdvancedIconsEquipementShowCalculatedCooldown; + public static ConfigEntry AdvancedIconsSkillShowCooldownStacks; + public static ConfigEntry AdvancedIconsSkillShowBaseCooldown; + public static ConfigEntry AdvancedIconsSkillShowCalculatedCooldown; + public static ConfigEntry AdvancedIconsSkillShowProcCoefficient; + public static ConfigEntry AdvancedIconsSkillCalculateSkillProcEffects; + + // Buffs + + public static ConfigEntry BuffTimers; + public static ConfigEntry BuffTimersDecimal; + public static ConfigEntry BuffTooltips; + public static ConfigEntry BuffTimersPosition; + public static TMPro.TextAlignmentOptions BuffTimersTextAlignmentOption; + public static ConfigEntry BuffTimersFontSize; + + // CommandImprovements + + public static ConfigEntry CommandResizeCommandWindow; + public static ConfigEntry CommandRemoveBackgroundBlur; + public static ConfigEntry CommandCloseOnEscape; + public static ConfigEntry CommandCloseOnWASD; + public static ConfigEntry CommandCloseOnCustom; + public static ConfigEntry CommandTooltipsShow; + public static ConfigEntry CommandTooltipsItemStatsBeforeAfter; + public static ConfigEntry CommandCountersShow; + public static ConfigEntry CommandCountersHideOnZero; + public static ConfigEntry CommandCountersPosition; + public static TMPro.TextAlignmentOptions CommandCountersTextAlignmentOption; + public static ConfigEntry CommandCountersFontSize; + public static ConfigEntry CommandCountersPrefix; + + // DPSMeter + + public static ConfigEntry DPSMeterTimespan; + public static ConfigEntry DPSMeterWindowShow; + public static ConfigEntry DPSMeterWindowIncludeMinions; + public static ConfigEntry DPSMeterWindowBackground; + public static ConfigEntry DPSMeterWindowHideWhenTyping; + public static ConfigEntry DPSMeterWindowAnchorMin; + public static ConfigEntry DPSMeterWindowAnchorMax; + public static ConfigEntry DPSMeterWindowPosition; + public static ConfigEntry DPSMeterWindowPivot; + public static ConfigEntry DPSMeterWindowSize; + public static ConfigEntry DPSMeterWindowAngle; + + // ItemCounters + + public static ConfigEntry ItemCountersShowItemCounters; + public static ConfigEntry ItemCountersShowItemScore; + public static ConfigEntry ItemCountersItemScoreFromTier; + public static ConfigEntry ItemCountersShowItemSum; + public static ConfigEntry ItemCountersItemSumTiersString; + public static List ItemCountersItemSumTiers; + public static ConfigEntry ItemCountersShowItemsByTier; + public static ConfigEntry ItemCountersItemsByTierOrderString; + public static List ItemCountersItemsByTierOrder; + public static ConfigEntry ItemCountersTierScoreTier1; + public static ConfigEntry ItemCountersTierScoreTier2; + public static ConfigEntry ItemCountersTierScoreTier3; + public static ConfigEntry ItemCountersTierScoreLunar; + public static ConfigEntry ItemCountersTierScoreBoss; + public static ConfigEntry ItemCountersTierScoreNoTier; + public static Dictionary ItemCountersTierScores; + public static Dictionary ItemCountersItemScores; + + // StatsDisplay + + public static ConfigEntry StatsDisplayEnable; + public static ConfigEntry StatsDisplayStatString; + public static ConfigEntry StatsDisplayStatStringCustomBind; + public static ConfigEntry StatsDisplayCustomBind; + public static ConfigEntry StatsDisplayShowCustomBindOnly; + public static ConfigEntry StatsDisplayToggleOnBind; + public static ConfigEntry StatsDisplayPanelBackground; + public static ConfigEntry StatsDisplayAttachToObjectivePanel; + public static ConfigEntry StatsDisplayWindowAnchorMin; + public static ConfigEntry StatsDisplayWindowAnchorMax; + public static ConfigEntry StatsDisplayWindowPosition; + public static ConfigEntry StatsDisplayWindowPivot; + public static ConfigEntry StatsDisplayWindowSize; + public static ConfigEntry StatsDisplayWindowAngle; + + // Sorting + + public static ConfigEntry SortingSortItemsInventory; + public static ConfigEntry SortingSortItemsCommand; + public static ConfigEntry SortingSortItemsScrapper; + public static ConfigEntry SortingTierOrderString; + public static int[] SortingTierOrder; + public static ConfigEntry SortingSortOrder; + public static ConfigEntry SortingSortOrderCommand; + public static ConfigEntry SortingSortOrderScrapper; + + // Internal + + /* + * NOTE: + * When renaming a config entry within the same config file, place both the new Section + Key + * and the old Section + Key in the dictionary below. + * + * By creating a rename mapping, we're able to + * 1) transfer the old entry's value to the new entry's value. + * 2) remove the old entry from the config file. + * + * This let's us update config files without users' configs suddenly changing. + */ + static IReadOnlyDictionary<(string, string), (string, string)> previousEntryMap = new Dictionary<(string, string), (string, string)>() + { + // Current config section & key pairs. Previous config section & key pairs. + { ("Components", "AdvancedIcons"), ("Components", "AdvanedIcons") }, + { ("Misc", "AdvancedPickupNotificationsEquipment"), ("Misc", "AdvancedPickupNotificationsEquipements") }, + { ("Misc", "HidePickupNotificationsItems"), ("Misc", "HidePickupNotificiationsItems") }, + { ("Misc", "HidePickupNotificationsEquipment"), ("Misc", "HidePickupNotificiationsEquipements") }, + { ("Misc", "HidePickupNotificationsArtifacts"), ("Misc", "HidePickupNotificiationsArtifacts") }, + { ("Equipment Improvements", "ShowCooldownStacks"), ("Equipement Improvements", "ShowCooldownStacks") }, + { ("Equipment Improvements", "AdvancedDescriptions"), ("Equipement Improvements", "AdvancedDescriptions") }, + { ("Equipment Improvements", "BaseCooldown"), ("Equipement Improvements", "BaseCooldown") }, + { ("Equipment Improvements", "CalculatedCooldown"), ("Equipement Improvements", "CalculatedCooldown") }, + { ("Components", "Buffs"), ("Components", "BuffTimers") }, + }; + + 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); + + // Components + + ComponentsAdvancedIcons = Bind(ConfigFileComponents, "Components", "AdvancedIcons", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); + + ComponentsBuffTimers = Bind(ConfigFileComponents, "Components", "Buffs", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); + + ComponentsCommandImprovements = Bind(ConfigFileComponents, "Components", "CommandImprovements", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); + + ComponentsDPSMeter = Bind(ConfigFileComponents, "Components", "DPSMeter", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); + + ComponentsItemCounters = Bind(ConfigFileComponents, "Components", "ItemCounters", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); + + ComponentsItemSorting = Bind(ConfigFileComponents, "Components", "ItemSorting", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); + + 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 + + MiscShowHidden = Bind(ConfigFileMisc, "Misc", "ShowHidden", false, "Show hidden items in the item inventory."); + + MiscAdvancedPickupNotificationsItems = Bind(ConfigFileMisc, "Misc", "AdvancedPickupNotificationsItems", false, "Show advanced descriptions when picking up an item."); + + MiscAdvancedPickupNotificationsEquipements = Bind(ConfigFileMisc, "Misc", "AdvancedPickupNotificationsEquipment", false, "Show advanced descriptions when picking up equipment."); + + MiscHidePickupNotificiationsItems = Bind(ConfigFileMisc, "Misc", "HidePickupNotificationsItems", false, "Hide pickup notifications for items."); + + MiscHidePickupNotificiationsEquipements = Bind(ConfigFileMisc, "Misc", "HidePickupNotificationsEquipment", false, "Hide pickup notifications for equipment."); + + MiscHidePickupNotificiationsArtifacts = Bind(ConfigFileMisc, "Misc", "HidePickupNotificationsArtifacts", false, "Hide pickup notifications for artifacts."); + + 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 + + AdvancedIconsItemAdvancedDescriptions = Bind(ConfigFileAdvancedIcons, "Item Improvements", "AdvancedDescriptions", true, "Show advanced descriptions when hovering over an item."); + + AdvancedIconsItemItemStatsIntegration = Bind(ConfigFileAdvancedIcons, "Item Improvements", "ItemStatsIntegration", true, "Show ItemStats where applicable."); + + AdvancedIconsEquipementShowCooldownStacks = Bind(ConfigFileAdvancedIcons, "Equipment Improvements", "ShowCooldownStacks", true, "Show the cooldown for your equipment when charging multiple stacks."); + + AdvancedIconsEquipementAdvancedDescriptions = Bind(ConfigFileAdvancedIcons, "Equipment Improvements", "AdvancedDescriptions", true, "Show advanced descriptions when hovering over equipment."); + + AdvancedIconsEquipementShowBaseCooldown = Bind(ConfigFileAdvancedIcons, "Equipment Improvements", "BaseCooldown", true, "Show the base cooldown when hovering over equipment."); + + AdvancedIconsEquipementShowCalculatedCooldown = Bind(ConfigFileAdvancedIcons, "Equipment Improvements", "CalculatedCooldown", true, "Show the calculated cooldown based on your items when hovering over equipment."); + + AdvancedIconsSkillShowCooldownStacks = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "ShowCooldownStacks", true, "Show the cooldown for skills when charging multiple stacks."); + + AdvancedIconsSkillShowBaseCooldown = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "BaseCooldown", true, "Show the base cooldown when hovering over a skill."); + + AdvancedIconsSkillShowCalculatedCooldown = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "CalculatedCooldown", true, "Show the calculated cooldown based on your items when hovering over a skill."); + + 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 + + BuffTimers = Bind(ConfigFileBuffs, "Buffs", "BuffTimers", true, "Show buff timers (host only)."); + + BuffTimersDecimal = Bind(ConfigFileBuffs, "Buffs", "BuffTimersDecimal", true, "Show 1 decimal point when timer is below 10."); + + BuffTooltips = Bind(ConfigFileBuffs, "Buffs", "BuffTooltips", true, "Show buff tooltips."); + + BuffTimersPosition = Bind(ConfigFileBuffs, "Buffs", "CountersPosition", "TopRight", + "Location of buff timer text.\n" + + "Valid options:\n" + + "TopLeft\n" + + "TopRight\n" + + "BottomLeft\n" + + "BottomRight\n" + + "Center\n"); + + 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 + + CommandResizeCommandWindow = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "ResizeCommandWindow", true, "Resize the command window depending on the number of items."); + + CommandRemoveBackgroundBlur = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "RemoveBackgroundBlur", true, "Remove the blur behind the command window that hides the rest of the UI."); + + CommandCloseOnEscape = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CloseOnEscape", true, "Close the command/scrapper window when you press escape."); + + CommandCloseOnWASD = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CloseOnWASD", true, "Close the command/scrapper window when you press W, A, S, or D."); + + CommandCloseOnCustom = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CloseOnCustom", "", "Close the command/scrapper window when you press the key selected here.\n" + + "Example: space\n" + + "Must be lowercase. Leave blank to disable."); + + CommandTooltipsShow = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "TooltipsShow", true, "Show tooltips in the command and scrapper windows."); + + CommandTooltipsItemStatsBeforeAfter = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "TooltipsItemStatsBeforeAfter", true, "Show the ItemStats before and after picking up the item."); + + CommandCountersShow = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersShow", true, "Show counters in the command and scrapper windows."); + + CommandCountersHideOnZero = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersHideOnZero", false, "Hide counters when they are zero."); + + CommandCountersPosition = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersPosition", "TopRight", + "Location of the command item counter.\n" + + "Valid options:\n" + + "TopLeft\n" + + "TopRight\n" + + "BottomLeft\n" + + "BottomRight\n" + + "Center\n"); + + CommandCountersTextAlignmentOption = (TMPro.TextAlignmentOptions)Enum.Parse(typeof(TMPro.TextAlignmentOptions), CommandCountersPosition.Value, true); + + 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 + + DPSMeterTimespan = Bind(ConfigFileDPSMeter, "DPSMeter", "Timespan", 5f, "Calculate DPS across this many seconds."); + + DPSMeterWindowShow = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowShow", true, "Show a dedicated DPSMeter."); + + DPSMeterWindowIncludeMinions = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowIncludeMinions", true, "Include minions such as turrets and drones in the DPS meter."); + + DPSMeterWindowBackground = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowBackground", true, "Whether or not the DPS window should have a background."); + + DPSMeterWindowHideWhenTyping = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowHideWhenTyping", true, "Whether or not the DPS window should be hidden when typing into the chat box."); + + DPSMeterWindowAnchorMin = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowAnchorMin", new Vector2(0, 0), + "Screen position the lower left window corner is anchored to.\n" + + "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + + "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); + + DPSMeterWindowAnchorMax = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowAnchorMax", new Vector2(0, 0f), + "Screen position the upper right window corner is anchored to.\n" + + "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + + "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); + + DPSMeterWindowPosition = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowPosition", new Vector2(120, 240), "Position of the DPSMeter window relative to the anchor."); + + DPSMeterWindowPivot = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowPivot", new Vector2(0, 1), "Pivot of the DPSMeter window.\n" + + "Window Position is from the anchor to the pivot."); + + 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 + + ItemCountersShowItemCounters = Bind(ConfigFileItemCounters, "ItemCounters", "ShowItemCounters", true, "Enable/Disable ItemCounters entirely."); + + ItemCountersShowItemScore = Bind(ConfigFileItemCounters, "ItemCounters", "ShowItemScore", true, "Show your item score."); + + ItemCountersItemScoreFromTier = Bind(ConfigFileItemCounters, "ItemCounters", "ItemScoreFromTier", true, "Whether or not the ItemScore should be based on tier. If disabled, the per-item settings will be used."); + + ItemCountersShowItemSum = Bind(ConfigFileItemCounters, "ItemCounters", "ShowItemSum", true, "Show the how many items you have."); + + ItemCountersItemSumTiersString = Bind(ConfigFileItemCounters, "ItemCounters", "ItemSumTiersString", "01234", "Which tiers to include in the ItemSum.\n0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier"); + + ItemCountersItemSumTiers = ItemCountersItemSumTiersString.Value.ToCharArray().Select(c => (ItemTier)char.GetNumericValue(c)).ToList(); + + + ItemCountersShowItemsByTier = Bind(ConfigFileItemCounters, "ItemCounters", "ShowItemsByTier", true, "Show how many items you have, by tier."); + + ItemCountersItemsByTierOrderString = Bind(ConfigFileItemCounters, "ItemCounters", "ItemsByTierOrderString", "43210", "Which tiers to include in the ItemsByTier, in order.\n0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier"); + + ItemCountersItemsByTierOrder = ItemCountersItemsByTierOrderString.Value.ToCharArray().Select(c => (ItemTier)char.GetNumericValue(c)).ToList(); + + ItemCountersTierScoreTier1 = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Tier1", 1f, "Score for Tier 1 items."); + ItemCountersTierScoreTier2 = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Tier2", 3f, "Score for Tier 2 items."); + ItemCountersTierScoreTier3 = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Tier3", 12f, "Score for Tier 3 items."); + ItemCountersTierScoreLunar = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Lunar", 0f, "Score for Lunar items."); + ItemCountersTierScoreBoss = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Boss", 4f, "Score for Boss items."); + ItemCountersTierScoreNoTier = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "NoTier", 0f, "Score for items without a tier."); + + ItemCountersTierScores = new Dictionary() + { + { ItemTier.Tier1, ItemCountersTierScoreTier1.Value }, + { ItemTier.VoidTier1, ItemCountersTierScoreTier1.Value }, + { ItemTier.Tier2, ItemCountersTierScoreTier2.Value}, + { ItemTier.VoidTier2, ItemCountersTierScoreTier2.Value}, + { ItemTier.Tier3, ItemCountersTierScoreTier3.Value}, + { ItemTier.VoidTier3, ItemCountersTierScoreTier3.Value}, + { ItemTier.Lunar, ItemCountersTierScoreLunar.Value}, + { ItemTier.Boss, ItemCountersTierScoreBoss.Value}, + { ItemTier.VoidBoss, ItemCountersTierScoreBoss.Value}, + { ItemTier.NoTier, ItemCountersTierScoreNoTier.Value}, + }; + + + ItemCountersItemScores = new Dictionary(); + + + // StatsDisplay + + StatsDisplayEnable = Bind(ConfigFileStatsDisplay, "StatsDisplay", "Enable", true, "Enable/Disable the StatsDisplay entirely."); + + StatsDisplayStatString = Bind(ConfigFileStatsDisplay, "StatsDisplay", "StatString", + "" + + "Stats\n" + + "Luck: $luck\n" + + "Base Damage: $dmg\n" + + "Crit Chance: $luckcrit%\n" + + "Attack Speed: $atkspd\n" + + "Armor: $armor | $armordmgreduction%\n" + + "Regen: $regen\n" + + "Speed: $velocity\n" + + "Jumps: $jumps/$maxjumps\n" + + "Kills: $killcount\n" + + "Mountain Shrines: $mountainshrines\n", + "You may format the StatString using formatting tags such as color, size, bold, underline, italics. See Readme for more.\n" + + "Valid Parameters:\n" + + string.Join(" ", StatsDisplay.regexmap.Keys)); + + StatsDisplayStatStringCustomBind = Bind(ConfigFileStatsDisplay, "StatsDisplay", "StatStringCustomBind", + "" + + "Stats\n" + + "Luck: $luck\n" + + "Experience: $exp/$maxexp\n" + + "Base Damage: $dmg\n" + + "Crit Chance: $crit%\n" + + "Crit w/ Luck: $luckcrit%\n" + + "Crit Damage: $critdamage\n" + + "Attack Speed: $atkspd\n" + + "Armor: $armor | $armordmgreduction%\n" + + "Regen: $regen\n" + + "Speed: $velocity\n" + + "Jumps: $jumps/$maxjumps\n" + + "Kills: $killcount\n" + + "Mountain Shrines: $mountainshrines\n" + + "Difficulty: $difficulty\n" + + "Blue Portal: $blueportal\n" + + "Gold Portal: $goldportal\n" + + "Celestial Portal: $celestialportal\n" + + "Void Portal: $voidportal\n", + "StatDisplay string to show when the custom bind is being pressed. This can be the same or different from the normal StatString."); + + StatsDisplayCustomBind = Bind(ConfigFileStatsDisplay, "StatsDisplay", "CustomBind", "tab", "Bind to show secondary StatsDisplay string.\n" + + "Example: space\n" + + "Must be lowercase. Leave blank to disable."); + + StatsDisplayShowCustomBindOnly = Bind(ConfigFileStatsDisplay, "StatsDisplay", "ShowCustomBindOnly", false, "Only show the StatsDisplay when the scoreboard is open."); + + StatsDisplayToggleOnBind = Bind(ConfigFileStatsDisplay, "StatsDisplay", "ToggleOnBind", false, "Toggle the StatsDisplay when the bind is pressed rather than showing it when it is held."); + + StatsDisplayPanelBackground = Bind(ConfigFileStatsDisplay, "StatsDisplay", "PanelBackground", true, "Whether or not the StatsDisplay panel should have a background."); + + StatsDisplayAttachToObjectivePanel = Bind(ConfigFileStatsDisplay, "StatsDisplay", "AttachToObjectivePanel", true, "Whether to attach the stats display to the objective panel.\n" + + "If not, it will be a free-floating window that can be moved with the options below."); + + StatsDisplayWindowAnchorMin = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowAnchorMin", new Vector2(1, 0.5f), + "Screen position the lower left window corner is anchored to.\n" + + "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + + "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); + + StatsDisplayWindowAnchorMax = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowAnchorMax", new Vector2(1, 0.5f), + "Screen position the upper right window corner is anchored to.\n" + + "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + + "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); + + StatsDisplayWindowPosition = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowPosition", new Vector2(-210, 100), "Position of the StatsDisplay window relative to the anchor."); + + StatsDisplayWindowPivot = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowPivot", new Vector2(0, 0.5f), "Pivot of the StatsDisplay window.\n" + + "Window Position is from the anchor to the pivot."); + + 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 + + SortingSortItemsInventory = Bind(ConfigFileSorting, "Sorting", "SortItemsInventory", true, "Sort items in the inventory and scoreboard."); + + SortingSortItemsCommand = Bind(ConfigFileSorting, "Sorting", "SortItemsCommand", true, "Sort items in the command window."); + + SortingSortItemsScrapper = Bind(ConfigFileSorting, "Sorting", "SortItemsScrapper", true, "Sort items in the scrapper window."); + + SortingTierOrderString = Bind(ConfigFileSorting, "Sorting", "TierOrder", "012345", "Tiers in ascending order, left to right.\n0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier"); + + SortingTierOrder = new int[] + { + SortingTierOrderString.Value.IndexOf('0'), + SortingTierOrderString.Value.IndexOf('1'), + SortingTierOrderString.Value.IndexOf('2'), + SortingTierOrderString.Value.IndexOf('3'), + SortingTierOrderString.Value.IndexOf('4'), + SortingTierOrderString.Value.IndexOf('5'), + }; + + SortingSortOrder = Bind(ConfigFileSorting, "Sorting", "SortOrder", "S134", + "What to sort the items by, most important to least important.\n" + + "Find the full details and an example in the Readme on Thunderstore/Github.\n" + + "0 = Tier Ascending\n" + + "1 = Tier Descending\n" + + "2 = Stack Size Ascending\n" + + "3 = Stack Size Descending\n" + + "4 = Pickup Order\n" + + "5 = Pickup Order Reversed\n" + + "6 = Alphabetical\n" + + "7 = Alphabetical Reversed\n" + + "8 = Random\n" + + "i = ItemIndex\n" + + "I = ItemIndex Descending\n" + + "\n" + + "Tag Based:\n" + + "s = Scrap First\n" + + "S = Scrap Last\n" + + "d = Damage First\n" + + "D = Damage Last\n" + + "h = Healing First\n" + + "H = Healing Last\n" + + "u = Utility First\n" + + "U = Utility Last\n" + + "o = On Kill Effect First\n" + + "O = On Kill Effect Last\n" + + "e = Equipment Related First\n" + + "E = Equipment Related Last\n" + + "p = Sprint Related First\n" + + "P = Sprint Related Last"); + + SortingSortOrderCommand = Bind(ConfigFileSorting, "Sorting", "SortOrderCommand", "6", + "Sort order for the command window.\n" + + "The command window has a special sort option \"C\" which will place the last selected item in the middle.\n" + + "Note: This option must be the last one in the SortOrderCommand option."); + + SortingSortOrderScrapper = Bind(ConfigFileSorting, "Sorting", "SortOrderScrapper", "134", + "Sort order for the scrapper window."); + + } + + /// + /// Automatically transfers the value of old config entries to new config entries based on + /// . Old config entries are deleted after their value has + /// been transferred.
+ /// Wraps . + ///
+ /// File containing the config entry.. + /// Section/category/group of the setting. Settings are grouped by this. + /// Name of the setting. + /// Value of the setting if the setting was not created yet. + /// Simple description of the setting shown to the user. + /// Type of the value contained in this setting. + static ConfigEntry Bind(ConfigFile config, string section, string key, T defaultValue, string description) + { + var currentEntry = config.Bind(section, key, defaultValue, description); + + if (previousEntryMap.ContainsKey((section, key))) + { + var previousTuple = previousEntryMap[(section, key)]; + var previousDefinition = new ConfigDefinition(previousTuple.Item1, previousTuple.Item2); + // ConfigFile has to Bind to a Section + Key before it knows that it's in the file. + var previousEntry = config.Bind(previousDefinition, "If you ever set your config option to this, it's your own fault", new ConfigDescription(description)); + if(previousEntry.Value != "If you ever set your config option to this, it's your own fault") + { + // Let ConfigBaseEntry deal with type parsing. + currentEntry.SetSerializedValue(previousEntry.GetSerializedValue()); + } + config.Remove(previousDefinition); + } + + return currentEntry; + } + } +} diff --git a/ModComponents/Buffs.cs b/ModComponents/Buffs.cs new file mode 100644 index 00000000..f9c12b99 --- /dev/null +++ b/ModComponents/Buffs.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; + +using UnityEngine; +using RoR2; +using BetterUI.ModCompatibility; + +namespace BetterUI +{ + [Obsolete("This feature of BetterUI has been removed.")] + public static class Buffs + { + + [Obsolete("This feature of BetterUI has been removed.")] + public static void RegisterName(BuffDef buffDef, string nameToken) + { + + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static void RegisterDescription(BuffDef buffDef, string descriptionToken) + { + + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static void RegisterBuffInfo(BuffDef buffDef, string nameToken = null, string descriptionToken = null) + { + + } + [Obsolete("This feature of BetterUI has been removed.")] + public static void RegisterBuffInfo(BuffDef buffDef, BuffInfo buffInfo) + { + + } + [Obsolete("This feature of BetterUI has been removed.")] + public static string GetName(BuffDef buffDef) + { + return ""; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static string GetDescription(BuffDef buffDef) + { + return ""; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public struct BuffInfo + { + public string nameToken; + public string descriptionToken; + } + } +} diff --git a/ModComponents/ItemCounters.cs b/ModComponents/ItemCounters.cs new file mode 100644 index 00000000..a7b577ab --- /dev/null +++ b/ModComponents/ItemCounters.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Linq; + +using RoR2; +using RoR2.UI; +using BepInEx.Configuration; + +namespace BetterUI +{ + [Obsolete("This feature of BetterUI has been removed.")] + public static class ItemCounters + { + + [Obsolete("This feature of BetterUI has been removed.")] + public static float GetTierScore(ItemTierDef itemTierDef) + { + return 0; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static float GetTierScore(ItemTier tier) + { + return 0; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static float GetItemScore(ItemDef itemDef) + { + return 0; + } + } +} diff --git a/ModComponents/ItemStats.cs b/ModComponents/ItemStats.cs new file mode 100644 index 00000000..f0b66196 --- /dev/null +++ b/ModComponents/ItemStats.cs @@ -0,0 +1,462 @@ +using System; +using System.Collections.Generic; +using System.Text; +using RoR2; + +namespace BetterUI +{ + public static class ItemStats + { + [Obsolete("This feature of BetterUI has been removed.")] + public static readonly Dictionary itemProcInfos = new Dictionary(); + + + + [Obsolete("This feature of BetterUI has been removed.")] + public static List GetItemStats(ItemDef itemDef) + { + return null; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static List GetItemTags(ItemStat itemStat) + { + return null; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static List GetItemModifers(ItemTag itemTag) + { + return null; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static ItemStat RegisterStat(ItemDef itemDef, string nameToken, float value, StackingFormula stackingFormula = null, StatFormatter statFormatter = null, ItemTag itemTag = null) + { + return null; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static ItemStat RegisterStat( + ItemDef itemDef, + string nameToken, + float value, + float stackValue, + StackingFormula stackingFormula = null, + StatFormatter statFormatter = null, + ItemTag itemTag = null + ) + { + return null; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static ItemStat RegisterStat( + ItemDef itemDef, + string nameToken, + float value, + float stackValue, + int stackLimit, + StackingFormula stackingFormula = null, + StatFormatter statFormatter = null, + ItemTag itemTag = null + ) + { + return null; + } + + public static ItemStat RegisterStat(ItemDef itemDef, ItemStat itemStat, ItemTag itemTag) + { + return null; + } + + + [Obsolete("This feature of BetterUI has been removed.")] + public static ItemModifier RegisterModifier( + ItemTag itemTag, + ItemDef itemDef, + ItemModifier.ModificationFormula modificationFormula, + float modifier, + float? stackModifier = null, + string nameToken = null, + string pluralNameToken = null, + ItemModifier.ModificationLocator modificationLocator = null, + ItemModifier.ModificationChecker modificationChecker = null, + ItemModifier.ModificationCounter modificationCounter = null + ) + { + + return null; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static ItemModifier RegisterModifier( + ItemTag itemTag, + string nameToken, + ItemModifier.ModificationFormula modificationFormula, + ItemModifier.ModificationLocator modificationLocator, + ItemModifier.ModificationChecker modificationChecker, + ItemModifier.ModificationCounter modificationCounter, + string pluralNameToken = null) + { + return null; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static ItemModifier RegisterModifier(ItemTag itemTag, ItemModifier itemModfier) + { + return null; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static ItemTag RegisterTag(ItemStat itemStat, ItemTag itemTag) + { + return null; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static void GetItemStats(StringBuilder stringBuilder, ItemDef itemDef, int stacks, CharacterMaster master) + { + + } + + + + [Obsolete("This feature of BetterUI has been removed.")] + public class StatFormatter + { + public delegate void Formatter(StringBuilder stringBuilder, float value, CharacterMaster master); + public Formatter statFormatter; + public string style; + public string color; + public string customFormatTag; + public string customFormatClosingTag; + public string prefix; + public string suffix; + public string pluralSuffix; + public string format = "{0:0.##}"; + public bool bold; + public bool italic; + public bool underline; + public bool strikethrough; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter LuckChance = new StatFormatter() + { + + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter Chance = new StatFormatter() + { + + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter Gold = new StatFormatter() + { + + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter Charges = new StatFormatter() + { + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter Percent = new StatFormatter() + { + + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter HP = new StatFormatter() + { + + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter Seconds = new StatFormatter() + { + + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter Armor = new StatFormatter() + { + + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter Regen = new StatFormatter() + { + + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter Range = new StatFormatter() + { + + }; + + [Obsolete("This feature of BetterUI has been removed.")] + public static StatFormatter Damage = new StatFormatter() + { + + }; + + + [Obsolete("This feature of BetterUI has been removed.")] + public void FormatString(StringBuilder stringBuilder, float value, CharacterMaster master) + { + + } + + } + + + + [Obsolete("This feature of BetterUI has been removed.")] + public delegate float StackingFormula(float value, float extraStackValue, int stacks); + + [Obsolete("This feature of BetterUI has been removed.")] + public static float LinearStacking(float value, float extraStackValue, int stacks) + { + return 0; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static float ExponentialStackingPlusOne(float value, float extraStackValue, int stacks) + { + return 0; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static float ExponentialStacking(float value, float extraStackValue, int stacks) + { + return 0; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static float NegativeExponentialStacking(float value, float extraStackValue, int stacks) + { + return 0; + } + [Obsolete("Deprecated: Use DivideByStacksPlusOne instead.")] + public static float DivideByBonusStacks(float value, float extraStackValue, int stacks) + { + return 0; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static float DivideByStacksPlusOne(float value, float extraStackValue, int stacks) + { + return 0; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static float DivideByStacks(float value, float extraStackValue, int stacks) + { + return 0; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static float FocusedConvergenceStacking(float value, float extraStackValue, int stacks) + { + return 0; + } + public static float HyperbolicStacking(float value, float extraStackValue, int stacks) + { + return 0; + } + public static float NoStacking(float value, float extraStackValue, int stacks) + { + return 0; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public delegate int CapFormula(float value, float extraStackValue, float procCoefficient); + + [Obsolete("This feature of BetterUI has been removed.")] + public static int LinearCap(float value, float extraStackValue, float procCoefficient) + { + return 0; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public class ItemProcInfo + { + public float value; + public float extraStackValue; + public StatFormatter statFormatter; + public StackingFormula stackingFormula; + public CapFormula capFormula; + + [Obsolete("This feature of BetterUI has been removed.")] + public void GetOutputString(StringBuilder stringBuilder, int stacks, CharacterMaster master, float procCoefficient) + { + + } + [Obsolete("This feature of BetterUI has been removed.")] + public float GetValue(int stacks) + { + return 0; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public float GetCap(float procCoefficient) + { + return 0; + } + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static void RegisterProc(ItemIndex itemIndex, ItemProcInfo itemProcInfo) + { + + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static void RegisterProc(ItemIndex itemIndex, float value, float? extraStackValue = null, StatFormatter statFormatter = null, StackingFormula stackingFormula = null, CapFormula capFormula = null) + { + } + + + [Obsolete("This feature of BetterUI has been removed.")] + public static void RegisterProc(ItemDef itemDef, ItemProcInfo itemProcInfo) + { + + } + [Obsolete("This feature of BetterUI has been removed.")] + public static void RegisterProc(ItemDef itemDef, float value, float? extraStackValue = null, StatFormatter statFormatter = null, StackingFormula stackingFormula = null, CapFormula capFormula = null) + { + + } + + [Obsolete("This feature of BetterUI has been removed.")] + public class ItemStat + { + public string nameToken; + public StackingFormula stackingFormula; + public float value; + public float stackValue; + public int stackLimit = int.MaxValue; + public StatFormatter statFormatter; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public class ItemModifier + { + public delegate float ModificationFormula(float value, float modifier, float stacks, float stackModifier); + public static ModificationFormula ExponentialBonus = (value, modifier, stackModifier, stacks) => (1 - value) - (1 - value) * (1 - modifier) * (float)Math.Pow(1 - stackModifier, stacks - 1); + public static ModificationFormula PositiveExponentialBonus = (value, modifier, stackModifier, stacks) => value * modifier * (float)Math.Pow(1 - stackModifier, stacks - 1); + public static ModificationFormula PercentBonus = (value, modifier, stackModifier, stacks) => value * ((modifier + (stackModifier * (stacks - 1))) / 100); + public static ModificationFormula LuckBonus = (value, modifier, stackModifier, stacks) => + { + return Math.Min(1, Utils.LuckCalc(value, modifier)) - value; + }; + public static ModificationFormula AlliesBonus = (value, modifier, stackModifier, stacks) => + { + return value * modifier; + }; + public static ModificationFormula FlatBonus = (value, modifier, stackModifier, stacks) => + { + return value + modifier + stackModifier * stacks; + }; + + public delegate float ModificationLocator(CharacterMaster master); + public static ModificationLocator LuckLocator = (master) => master.luck; + public static ModificationLocator AlliesLocator = (master) => Math.Max(TeamComponent.GetTeamMembers(master.GetBody().teamComponent.teamIndex).Count - 1, 0); + + public delegate bool ModificationChecker(CharacterMaster master, ItemModifier itemModifier); + public static ModificationChecker ItemChecker = (master, itemModifier) => master.inventory.GetItemCount(itemModifier.itemDef) > 0; + public static ModificationChecker TeamItemChecker = (master, itemModifier) => Util.GetItemCountForTeam(master.GetBody().teamComponent.teamIndex, itemModifier.itemDef.itemIndex, true, true) > master.inventory.GetItemCount(itemModifier.itemDef); + public static ModificationChecker LuckChecker = (master, itemModifier) => master.luck != 0; + public static ModificationChecker AlliesChecker = (master, itemModifier) => Math.Max(TeamComponent.GetTeamMembers(master.GetBody().teamComponent.teamIndex).Count - 1, 0) > 1; + + public delegate float ModificationCounter(CharacterMaster master, ItemModifier itemModifier); + public static ModificationCounter ItemCounter = (master, itemModifier) => master.inventory.GetItemCount(itemModifier.itemDef); + public static ModificationCounter TeamItemCounter = (master, itemModifier) => Util.GetItemCountForTeam(master.GetBody().teamComponent.teamIndex, itemModifier.itemDef.itemIndex, true, true) - master.inventory.GetItemCount(itemModifier.itemDef); + public static ModificationCounter LuckCounter = (master, itemModifier) => master.luck; + public static ModificationCounter AlliesCounter = (master, itemModifier) => Math.Max(TeamComponent.GetTeamMembers(master.GetBody().teamComponent.teamIndex).Count - 1, 0); + + public string nameToken; + public string pluralNameToken; + public ModificationFormula modificationFormula; + public ItemDef itemDef; + public ModificationLocator modificationLocator; + public ModificationChecker modificationChecker; + public ModificationCounter modificationCounter; + public float modifier; + public float stackModifier; + + [Obsolete("This feature of BetterUI has been removed.")] + public bool GetModificationActive(CharacterMaster master) + { + return modificationChecker(master, this); + } + + [Obsolete("This feature of BetterUI has been removed.")] + public float GetModificationCount(CharacterMaster master) + { + return modificationCounter(master, this); + } + [Obsolete("This feature of BetterUI has been removed.")] + public float GetModifiedValue(float value, CharacterMaster master, float count) + { + if (modificationLocator != null) + { + return modificationFormula(value, modificationLocator(master), stackModifier, count); + } + else + { + return modificationFormula(value, modifier, stackModifier, count); + } + } + } + + + [Obsolete("This feature of BetterUI has been removed.")] + public class ItemTag + { + public static ItemTag Damage; + public static ItemTag Healing; + public static ItemTag Luck; + public static ItemTag LuckStat; + public static ItemTag EquipmentCooldown; + public static ItemTag SkillCooldown; + public static ItemTag Allies; + public static ItemTag MaxHealth; + public static ItemTag TitanDamage; + public static ItemTag TitanHealth; + public static ItemTag MovementSpeed; + static ItemTag() + { + Damage = new ItemTag(); + Healing = new ItemTag(); + Luck = new ItemTag(); + LuckStat = new ItemTag(); + EquipmentCooldown = new ItemTag(); + Allies = new ItemTag(); + MaxHealth = new ItemTag(); + TitanDamage = new ItemTag(); + TitanHealth = new ItemTag(); + SkillCooldown = new ItemTag(); + MovementSpeed = new ItemTag(); + } + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static class Styles + { + public const string Damage = "cIsDamage"; + public const string Healing = "cIsHealing"; + public const string Mono = "cMono"; + public const string Stack = "cStack"; + public const string Health = "cIsHealth"; + public const string Void = "cIsVoid"; + public const string Death = "cDeath"; + public const string UserSetting = "cUserSetting"; + public const string Artifact = "cArtifact"; + public const string Sub = "cSub"; + public const string Event = "cEvent"; + public const string WorldEvent = "cWorldEvent"; + public const string KeywordName = "cKeywordName"; + public const string Shrine = "cShrine"; + } + } +} diff --git a/ModComponents/Language.cs b/ModComponents/Language.cs index dc77a078..a466651c 100644 --- a/ModComponents/Language.cs +++ b/ModComponents/Language.cs @@ -14,7 +14,7 @@ public static class Language internal class UpdateChecker : UnityEngine.MonoBehaviour { const string apiUrl = "https://weblate.faby.dev/api/components/ror2/betterui/translations/"; - void Awake() + void Start() { StartCoroutine(CheckForUpdate()); } diff --git a/ModComponents/StatsDisplay.cs b/ModComponents/StatsDisplay.cs new file mode 100644 index 00000000..723e62d7 --- /dev/null +++ b/ModComponents/StatsDisplay.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; +using System.Text.RegularExpressions; + +using RoR2; +using BepInEx; +using UnityEngine; +using UnityEngine.UI; +using TMPro; + + + +namespace BetterUI +{ + public static class StatsDisplay + { + + public delegate string DisplayCallback(CharacterBody characterBody); + + internal static void Hook() { } + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddStatsDisplay(string token, Func displayCallback) + { + + } + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddStatsDisplay(string token, DisplayCallback displayCallback) + { + + } + + + + + } +} diff --git a/Utils/ModCompat.cs b/Utils/ModCompat.cs new file mode 100644 index 00000000..d45bc5c7 --- /dev/null +++ b/Utils/ModCompat.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; +using RoR2; + +namespace BetterUI +{ + namespace ModCompatibility + { + internal static class BetterAPICompatibility + { + internal static class Buffs + { + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddName(BuffDef buffDef, string nameToken) + { + } + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddDescription(BuffDef buffDef, string descriptionToken) + { + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddInfo(BuffDef buffDef, string nameToken = null, string descriptionToken = null) + { + } + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddInfo(BuffDef buffDef, BetterUI.Buffs.BuffInfo buffInfo) + { + + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static string GetName(BuffDef buffDef) + { + return ""; + } + [Obsolete("This feature of BetterUI has been removed.")] + public static string GetDescription(BuffDef buffDef) + { + return ""; + } + } + } + } +} \ No newline at end of file diff --git a/Utils/ProcCoefficientCatalog.cs b/Utils/ProcCoefficientCatalog.cs new file mode 100644 index 00000000..17425171 --- /dev/null +++ b/Utils/ProcCoefficientCatalog.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; + +namespace BetterUI +{ + public static class ProcCoefficientCatalog + { + [Obsolete("This feature of BetterUI has been removed.")] + public struct ProcCoefficientInfo + { + public string name; + public float procCoefficient; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddSkill(string skillDef, List procCoefficientInfoList) + { + } + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddSkill(string skillDef, ProcCoefficientInfo procCoefficientInfo) + { + } + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddSkill(string skillDef, string name, float procCoefficient) + { + } + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddToSkill(string skillDef, ProcCoefficientInfo procCoefficientInfo) + { + + } + [Obsolete("This feature of BetterUI has been removed.")] + public static void AddToSkill(string skillDef, string name, float procCoefficient) + { + } + [Obsolete("This feature of BetterUI has been removed.")] + public static List GetProcCoefficientInfo(string skillDef) + { + return null; + } + + + } +} diff --git a/Utils/ProcItemCatalog.cs b/Utils/ProcItemCatalog.cs new file mode 100644 index 00000000..52f72100 --- /dev/null +++ b/Utils/ProcItemCatalog.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Text; +using RoR2; + +namespace BetterUI +{ + [Obsolete] + public static class ProcItemsCatalog + { + [Obsolete] + private static StringBuilder formatterStringBuilder = new StringBuilder(); + + + public static string ChanceFormatter(float value, float procCoefficient, float luck, bool canCap, int cap) + { + formatterStringBuilder.Clear(); + formatterStringBuilder.Append(""); + formatterStringBuilder.Append(Math.Min(100, 100 * Utils.LuckCalc(value * procCoefficient, luck)).ToString("0.##")); + formatterStringBuilder.Append("%"); + return formatterStringBuilder.ToString(); + } + + public static string HPFormatter(float value, float procCoefficient, float luck, bool canCap, int cap) + { + formatterStringBuilder.Clear(); + formatterStringBuilder.Append(""); + formatterStringBuilder.Append(value * procCoefficient); + formatterStringBuilder.Append(" HP"); + return formatterStringBuilder.ToString(); + } + + public static string RangeFormatter(float value, float procCoefficient, float luck, bool canCap, int cap) + { + formatterStringBuilder.Clear(); + formatterStringBuilder.Append(""); + formatterStringBuilder.Append(value * procCoefficient); + formatterStringBuilder.Append("m "); + return formatterStringBuilder.ToString(); + } + + public delegate string EffectFormatter(float value, float procCoefficient, float luck, bool canCap, int cap); + public class FormatterTranslater + { + EffectFormatter effectFormatter; + internal FormatterTranslater(EffectFormatter effectFormatter) + { + this.effectFormatter = effectFormatter; + } + + public void Formatter(StringBuilder stringBuilder, float value, CharacterMaster master) + { + stringBuilder.Append(effectFormatter(value, 1, 1, false, 1)); + } + } + + + [Obsolete] + public delegate float StackingFormula(float value, float extraStackValue, int stacks); + [Obsolete] + public static StackingFormula LinearStacking = ItemStats.LinearStacking; + [Obsolete] + public static StackingFormula ExponentialStacking = ItemStats.ExponentialStacking; + [Obsolete] + public static StackingFormula HyperbolicStacking = ItemStats.HyperbolicStacking; + [Obsolete] + public static StackingFormula NoStacking = ItemStats.NoStacking; + + [Obsolete] + public delegate int CapFormula(float value, float extraStackValue, float procCoefficient); + [Obsolete] + public static CapFormula LinearCap = ItemStats.LinearCap; + + [Obsolete] + public class EffectInfo + { + public float value; + public float extraStackValue; + public EffectFormatter effectFormatter; + public StackingFormula stackingFormula; + public CapFormula capFormula; + + public ItemStats.ItemProcInfo ToItemProcInfo() + { + var itemProcInfo = new ItemStats.ItemProcInfo() + { + value = value, + extraStackValue = extraStackValue, + statFormatter = new ItemStats.StatFormatter() + { + statFormatter = (new FormatterTranslater(effectFormatter)).Formatter + }, + stackingFormula = new ItemStats.StackingFormula(stackingFormula), + capFormula = new ItemStats.CapFormula(capFormula) + }; + return itemProcInfo; + } + } + + [Obsolete("Removed, please use BetterUI.ItemStats.RegisterEffect", true)] + public static void AddEffect(ItemIndex itemIndex, EffectInfo effectInfo) + { + if (itemIndex <= ItemIndex.None) + { + UnityEngine.Debug.LogError("ERROR: AddEffect was passed ItemIndex.None or below, this likely means you tried to register your effect before the item catalog was ready. Please use ItemCatalog.availability.CallWhenAvailable or pass an ItemDef directly."); + return; + } + AddEffect(ItemCatalog.GetItemDef(itemIndex), effectInfo); + } + + [Obsolete("Removed, please use BetterUI.ItemStats.RegisterEffect", true)] + public static void AddEffect(ItemIndex itemIndex, float value, float? extraStackValue = null, EffectFormatter effectFormatter = null, StackingFormula stackingFormula = null, CapFormula capFormula = null) + { + if (itemIndex <= ItemIndex.None) + { + UnityEngine.Debug.LogError("ERROR: AddEffect was passed ItemIndex.None or below, this likely means you tried to register your effect before the item catalog was ready. Please use ItemCatalog.availability.CallWhenAvailable or pass an ItemDef directly."); + return; + } + AddEffect(ItemCatalog.GetItemDef(itemIndex), value, extraStackValue, effectFormatter, stackingFormula, capFormula); + } + + [Obsolete("Removed, please use BetterUI.ItemStats.RegisterEffect", true)] + public static void AddEffect(ItemDef itemDef, EffectInfo effectInfo) + { + ItemStats.RegisterProc(itemDef, effectInfo.ToItemProcInfo()); + } + + [Obsolete("Removed, please use BetterUI.ItemStats.RegisterEffect", true)] + public static void AddEffect(ItemDef itemDef, float value, float? extraStackValue = null, EffectFormatter effectFormatter = null, StackingFormula stackingFormula = null, CapFormula capFormula = null) + { + AddEffect(itemDef, new EffectInfo() { + value = value, + extraStackValue = extraStackValue ?? value, + effectFormatter = effectFormatter ?? ChanceFormatter, + stackingFormula = stackingFormula ?? LinearStacking, + capFormula = capFormula + }); + } + } +} diff --git a/Utils/Utils.cs b/Utils/Utils.cs new file mode 100644 index 00000000..5d08760b --- /dev/null +++ b/Utils/Utils.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using RoR2.Skills; +using R2API.Utils; + +[assembly: ManualNetworkRegistration] +namespace BetterUI +{ + static class Utils + { + + + [Obsolete("This feature of BetterUI has been removed.")] + public static float LuckCalc(float chance, float luck) + { + return 0; + } + + [Obsolete("This feature of BetterUI has been removed.")] + public static int TheREALFindSkillIndexByName(String skillDefName) + { + return 0; + } + } +} + +namespace R2API.Utils +{ + [AttributeUsage(AttributeTargets.Assembly)] + public class ManualNetworkRegistrationAttribute : Attribute { } +} \ No newline at end of file