From 4ba4740ce4bc90de67a5ee22fd55617dc4d12aff Mon Sep 17 00:00:00 2001 From: inyawfaze Date: Thu, 21 Nov 2024 18:49:37 +0100 Subject: [PATCH] Integrated Classic support - Seperate .toc which does not load HelpTips and some widgets - adjusted constants and defaults - removes unsupported widgets from builder - removes unsupported health formats - helper functions for missing AuraUtil - seperate aura tooltip handling - several util functions --- Cell_UnitFrames_Vanilla.toc | 88 +++++++++ Core/Init.lua | 5 + Core/OnLoad.lua | 4 +- Data/Constants.lua | 66 +++++-- Data/Defaults.lua | 326 +++++++++++++++++++------------- Locales/enUS.lua | 1 + Menu/Builder.lua | 189 ++++++++++-------- Menu/GeneralTab.lua | 20 +- Menu/Menu.lua | 20 +- Menu/UnitFramesTab.lua | 8 + UnitFrames/EditMode.lua | 21 +- UnitFrames/MenuOptions.lua | 16 +- UnitFrames/OnLoad.lua | 95 ++++++++-- UnitFrames/UnitButton.lua | 12 +- Util/HideBlizzard.lua | 3 + Util/Utils.lua | 123 +++++++++++- Widgets/Auras/Auras.lua | 23 ++- Widgets/Bars/CastBar.lua | 33 +++- Widgets/Bars/HealthBar.lua | 5 +- Widgets/Misc/Fader.lua | 32 +++- Widgets/Texts/CustomFormats.lua | 186 +++++++++--------- Widgets/Texts/HealthText.lua | 103 +++++----- 22 files changed, 945 insertions(+), 434 deletions(-) create mode 100644 Cell_UnitFrames_Vanilla.toc diff --git a/Cell_UnitFrames_Vanilla.toc b/Cell_UnitFrames_Vanilla.toc new file mode 100644 index 0000000..96de9e3 --- /dev/null +++ b/Cell_UnitFrames_Vanilla.toc @@ -0,0 +1,88 @@ +## Interface: 110005 +## SavedVariables: CUF_DB +## IconTexture: Interface\ICONS\spell_progenitor_buff + +## Title: Cell - Unit Frames +## Author: Vollmer +## Version: @project-version@ +## X-Date: @project-date-iso@ +## X-License: MIT +## X-Curse-Project-ID: 1085605 +## X-Wago-ID: ZKxqRdGk + +## Dependencies: Cell + +## Notes: Unitframes for our beloved Cell! + +Locales/LoadLocales.xml +Core/Init.lua +Core/Events.lua + +Data/Constants.lua +Util/Utils.lua +Util/PixelPerfect.lua +Data/Defaults.lua +Data/Database.lua +Data/DBUtil.lua +Data/Revise.lua + +Util/Handler.lua +Util/HideBlizzard.lua +# Util/HelpTips.lua + +Debug/DebugWindow.lua +Debug/Debug.lua + +Core/SlashCommands.lua + +Menu/Builder.lua +Menu/AuraFilterList.lua +Menu/Menu.lua +Menu/ImportExport.lua +Menu/GeneralTab.lua +Menu/UnitFramesTab.lua +Menu/WidgetsTab.lua +Menu/FaderTab.lua +Menu/ColorTab.lua + +Widgets/Common.lua + +Widgets/Texts/BaseTextWidget.lua +Widgets/Texts/CustomFormats.lua +Widgets/Texts/NameText.lua +Widgets/Texts/HealthText.lua +Widgets/Texts/PowerText.lua +Widgets/Texts/LevelText.lua +Widgets/Texts/CustomText.lua + +Widgets/Bars/HealthBar.lua +Widgets/Bars/PowerBar.lua +# Widgets/Bars/ShieldBar.lua +Widgets/Bars/CastBar.lua +# Widgets/Bars/ClassBar.lua +# Widgets/Bars/HealAbsorb.lua + +Widgets/Icons/RaidIcon.lua +# Widgets/Icons/RoleIcon.lua # this could get reintegrated via LibGroupInfo support +Widgets/Icons/LeaderIcon.lua +Widgets/Icons/CombatIcon.lua +Widgets/Icons/ReadyCheckIcon.lua +Widgets/Icons/RestingIcon.lua + +Widgets/Auras/Auras.lua +Widgets/Auras/Updater.lua +Widgets/Auras/Dispels.lua +Widgets/Auras/Totems.lua + +Widgets/Misc/Fader.lua + +UnitFrames/UnitButton.xml +UnitFrames/UnitButton.lua +UnitFrames/OnLoad.lua +UnitFrames/MenuOptions.lua +UnitFrames/EditMode.lua + +API/Common.lua +API/CustomAnchors.lua + +Core/OnLoad.lua \ No newline at end of file diff --git a/Core/Init.lua b/Core/Init.lua index 4b0cd0f..cb37732 100644 --- a/Core/Init.lua +++ b/Core/Init.lua @@ -34,6 +34,11 @@ CUF.PixelPerfect = {} ---@field testMode boolean ---@field isMenuOpen boolean ---@field isRetail boolean +---@field isVanilla boolean +---@field isBCC boolean +---@field isWrath boolean +---@field isCata boolean +---@field isTWW boolean ---@field selectedTab string ---@field selectedSubTab string ---@field inEditMode boolean diff --git a/Core/OnLoad.lua b/Core/OnLoad.lua index 6a71eff..94d6829 100644 --- a/Core/OnLoad.lua +++ b/Core/OnLoad.lua @@ -16,7 +16,9 @@ local function OnCellInitialUpdateLayout(_layout) CUF.vars.selectedUnit = CUF.constants.UNIT.PLAYER CUF.vars.selectedWidget = CUF.constants.WIDGET_KIND.NAME_TEXT CUF.vars.selectedLayout = Cell.vars.currentLayout - CUF.vars.isRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE + + -- moved the game version vars to constants, since they load ealier but depend on it + CUF.vars.inEditMode = false -- Hide Blizzard Frames diff --git a/Data/Constants.lua b/Data/Constants.lua index 888c8e6..8bd0f1f 100644 --- a/Data/Constants.lua +++ b/Data/Constants.lua @@ -14,17 +14,33 @@ local function OnAddonLoaded() end CUF:RegisterCallback("AddonLoaded", "CUF_Constants_OnAddonLoaded", OnAddonLoaded) + +-- detect the different game versions +CUF.vars.isRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE +CUF.vars.isVanilla = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC +CUF.vars.isBCC = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC and LE_EXPANSION_LEVEL_CURRENT == LE_EXPANSION_BURNING_CRUSADE +CUF.vars.isWrath = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC +CUF.vars.isCata = WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC +CUF.vars.isTWW = LE_EXPANSION_LEVEL_CURRENT == LE_EXPANSION_WAR_WITHIN ----@enum Unit +---@class Unit const.UNIT = { PLAYER = "player", TARGET = "target", - FOCUS = "focus", PET = "pet", TARGET_TARGET = "targettarget", - BOSS = "boss", } +-- Focus was introduced with TBC +if not CUF.vars.isVanilla then + const.UNIT.FOCUS = "focus" +end + +-- Boss frames were intoduced with Wrath +if not CUF.vars.isVanilla and not CUF.vars.isBCC then + const.UNIT.BOSS = "boss" +end + ---@enum TitleCasedUnits -- Used for frame titles const.TITLE_CASED_UNITS = { @@ -57,26 +73,29 @@ const.PowerTextFormat = { CUSTOM = "custom" } ----@enum HealthTextFormat +---@class HealthTextFormat const.HealthTextFormat = { PERCENTAGE = "percentage", NUMBER = "number", NUMBER_SHORT = "number-short", - PERCENTAGE_ABSORBS = "percentage-absorbs", - PERCENTAGE_ABSORBS_MERGED = "percentage-absorbs-merged", PERCENTAGE_DEFICIT = "percentage-deficit", - NUMBER_ABSORBS_SHORT = "number-absorbs-short", - NUMBER_ABSORBS_MERGED_SHORT = "number-absorbs-merged-short", NUMBER_DEFICIT = "number-deficit", NUMBER_DEFICIT_SHORT = "number-deficit-short", CURRENT_SHORT_PERCENTAGE = "current-short-percentage", - ABSORBS_ONLY = "absorbs-only", - ABSORBS_ONLY_SHORT = "absorbs-only-short", - ABSORBS_ONLY_PERCENTAGE = "absorbs-only-percentage", CUSTOM = "custom", } ----@enum WIDGET_KIND +if CUF.vars.isRetail then + const.HealthTextFormat.PERCENTAGE_ABSORBS = "percentage-absorbs" + const.HealthTextFormat.PERCENTAGE_ABSORBS_MERGED = "percentage-absorbs-merged" + const.HealthTextFormat.NUMBER_ABSORBS_SHORT = "number-absorbs-short" + const.HealthTextFormat.NUMBER_ABSORBS_MERGED_SHORT = "number-absorbs-merged-short" + const.HealthTextFormat.ABSORBS_ONLY = "absorbs-only" + const.HealthTextFormat.ABSORBS_ONLY_SHORT = "absorbs-only-short" + const.HealthTextFormat.ABSORBS_ONLY_PERCENTAGE = "absorbs-only-percentage" +end + +---@class WIDGET_KIND const.WIDGET_KIND = { NAME_TEXT = "nameText", HEALTH_TEXT = "healthText", @@ -86,20 +105,23 @@ const.WIDGET_KIND = { BUFFS = "buffs", DEBUFFS = "debuffs", RAID_ICON = "raidIcon", - ROLE_ICON = "roleIcon", LEADER_ICON = "leaderIcon", COMBAT_ICON = "combatIcon", - SHIELD_BAR = "shieldBar", READY_CHECK_ICON = "readyCheckIcon", RESTING_ICON = "restingIcon", CAST_BAR = "castBar", - CLASS_BAR = "classBar", - HEAL_ABSORB = "healAbsorb", DISPELS = "dispels", TOTEMS = "totems", FADER = "fader" } +if CUF.vars.isRetail then + const.WIDGET_KIND.CLASS_BAR = "classBar" + const.WIDGET_KIND.HEAL_ABSORB = "healAbsorb" + const.WIDGET_KIND.SHIELD_BAR = "shieldBar" + const.WIDGET_KIND.ROLE_ICON = "roleIcon" +end + ---@enum OPTION_KIND const.OPTION_KIND = { ENABLED = "enabled", @@ -325,10 +347,18 @@ const.BlizzardFrameTypes = { CUF.constants.UNIT.PLAYER, CUF.constants.UNIT.TARGET, CUF.constants.UNIT.TARGET_TARGET, - CUF.constants.UNIT.FOCUS, CUF.constants.UNIT.PET, - CUF.constants.UNIT.BOSS, "playerCastBar", "buffFrame", "debuffFrame", } + +-- Focus was introduced with TBC +if not CUF.vars.isVanilla then + table.insert(const.BlizzardFrameTypes, CUF.constants.UNIT.FOCUS) +end + +-- Boss frames were intoduced with Wrath +if not CUF.vars.isVanilla and not CUF.vars.isBCC then + table.insert(const.BlizzardFrameTypes, CUF.constants.UNIT.BOSS) +end diff --git a/Data/Defaults.lua b/Data/Defaults.lua index a4d5fa0..bca0bed 100644 --- a/Data/Defaults.lua +++ b/Data/Defaults.lua @@ -133,12 +133,6 @@ Defaults.Colors = { interruptible = { 0.2, 0.57, 0.5, 1 }, nonInterruptible = { 0.43, 0.43, 0.43, 1 }, background = { 0, 0, 0, 0.8 }, - stageZero = { 0.2, 0.57, 0.5, 1 }, - stageOne = { 0.3, 0.47, 0.45, 1 }, - stageTwo = { 0.4, 0.4, 0.4, 1 }, - stageThree = { 0.54, 0.3, 0.3, 1 }, - stageFour = { 0.65, 0.2, 0.3, 1 }, - fullyCharged = { 0.77, 0.1, 0.2, 1 }, }, reaction = { friendly = { 0.29, 0.69, 0.3, 1 }, @@ -148,20 +142,57 @@ Defaults.Colors = { useClassColorForPet = false, swapHostileHealthAndLossColors = false, }, - essence = { + comboPoints = { + ["1"] = { 0.76, 0.3, 0.3, 1 }, + ["2"] = { 0.79, 0.56, 0.3, 1 }, + ["3"] = { 0.82, 0.82, 0.3, 1 }, + ["4"] = { 0.56, 0.79, 0.3, 1 }, + ["5"] = { 0.43, 0.77, 0.3, 1 }, + }, + unitFrames = { + barColor = { 0.06, 0.07, 0.07, 1 }, + lossColor = { 0.52, 0.21, 0.19, 1 }, + fullColor = { 0.2, 0.2, 1, 1 }, + deathColor = { 0.47, 0.47, 0.47, 1 }, + useFullColor = false, + useDeathColor = false, + barAlpha = 1, + lossAlpha = 1, + backgroundAlpha = 1, + }, +} + +if CUF.vars.isRetail then + + Defaults.Colors.castBar = { + texture = "Interface\\Buttons\\WHITE8X8", + interruptible = { 0.2, 0.57, 0.5, 1 }, + nonInterruptible = { 0.43, 0.43, 0.43, 1 }, + background = { 0, 0, 0, 0.8 }, + stageZero = { 0.2, 0.57, 0.5, 1 }, + stageOne = { 0.3, 0.47, 0.45, 1 }, + stageTwo = { 0.4, 0.4, 0.4, 1 }, + stageThree = { 0.54, 0.3, 0.3, 1 }, + stageFour = { 0.65, 0.2, 0.3, 1 }, + fullyCharged = { 0.77, 0.1, 0.2, 1 }, + }; + + Defaults.Colors.essence = { ["1"] = { 0.2, 0.57, 0.5, 1 }, ["2"] = { 0.2, 0.57, 0.5, 1 }, ["3"] = { 0.2, 0.57, 0.5, 1 }, ["4"] = { 0.2, 0.57, 0.5, 1 }, ["5"] = { 0.2, 0.57, 0.5, 1 }, ["6"] = { 0.2, 0.57, 0.5, 1 }, - }, - classResources = { + }; + + Defaults.Colors.classResources = { holyPower = { 0.9, 0.89, 0.04, 1 }, arcaneCharges = { 0, 0.62, 1, 1 }, soulShards = { 0.58, 0.51, 0.8, 1 }, - }, - comboPoints = { + }; + + Defaults.Colors.comboPoints = { ["1"] = { 0.76, 0.3, 0.3, 1 }, ["2"] = { 0.79, 0.56, 0.3, 1 }, ["3"] = { 0.82, 0.82, 0.3, 1 }, @@ -170,46 +201,40 @@ Defaults.Colors = { ["6"] = { 0.3, 0.76, 0.3, 1 }, ["7"] = { 0.36, 0.82, 0.54, 1 }, charged = { 0.15, 0.64, 1, 1 }, - }, - chi = { + }; + + Defaults.Colors.chi = { ["1"] = { 0.72, 0.77, 0.31, 1 }, ["2"] = { 0.58, 0.74, 0.36, 1 }, ["3"] = { 0.49, 0.72, 0.38, 1 }, ["4"] = { 0.38, 0.7, 0.42, 1 }, ["5"] = { 0.26, 0.67, 0.46, 1 }, ["6"] = { 0.13, 0.64, 0.5, 1 }, - }, - runes = { + }; + + Defaults.Colors.runes = { bloodRune = { 1.0, 0.24, 0.24, 1 }, frostRune = { 0.24, 1.0, 1.0, 1 }, unholyRune = { 0.24, 1.0, 0.24, 1 }, - }, - shieldBar = { + }; + + Defaults.Colors.shieldBar = { texture = "Interface\\Buttons\\WHITE8X8", color = { 1, 1, 0, 0.25 }, overShield = { 1, 1, 1, 1 }, - }, - healAbsorb = { + }; + + Defaults.Colors.healAbsorb = { texture = "Interface\\AddOns\\Cell\\Media\\shield", color = { 1, 0.1, 0.1, 1 }, overAbsorb = { 1, 1, 1, 1 }, invertColor = false, - }, - unitFrames = { - barColor = { 0.06, 0.07, 0.07, 1 }, - lossColor = { 0.52, 0.21, 0.19, 1 }, - fullColor = { 0.2, 0.2, 1, 1 }, - deathColor = { 0.47, 0.47, 0.47, 1 }, - useFullColor = false, - useDeathColor = false, - barAlpha = 1, - lossAlpha = 1, - backgroundAlpha = 1, - }, - classBar = { + }; + + Defaults.Colors.classBar = { texture = "Interface\\Buttons\\WHITE8X8", - } -} + }; +end Defaults.ColorsMenuOrder = { castBar = { @@ -217,13 +242,6 @@ Defaults.ColorsMenuOrder = { { "background", "rgb" }, { "interruptible", "rgb" }, { "nonInterruptible", "rgb" }, - { "Empowers", "seperator" }, - { "stageZero", "rgb" }, - { "stageOne", "rgb" }, - { "stageTwo", "rgb" }, - { "stageThree", "rgb" }, - { "stageFour", "rgb" }, - { "fullyCharged", "rgb" } }, reaction = { { "friendly", "rgb" }, @@ -234,20 +252,46 @@ Defaults.ColorsMenuOrder = { { "hostileUnits", "seperator" }, { "swapHostileHealthAndLossColors", "toggle" } }, - essence = { - { "1", "rgb" }, - { "2", "rgb" }, - { "3", "rgb" }, - { "4", "rgb" }, - { "5", "rgb" }, - { "6", "rgb" }, + comboPoints = { + { "1", "rgb" }, + { "2", "rgb" }, + { "3", "rgb" }, + { "4", "rgb" }, + { "5", "rgb" }, }, - classResources = { - { "holyPower", "rgb" }, - { "soulShards", "rgb" }, - { "arcaneCharges", "rgb" }, + unitFrames = { + { "barColor", "rgb" }, + { "", "newline" }, + { "lossColor", "rgb" }, + { "", "newline" }, + { "fullColor", "rgb" }, + { "useFullColor", "toggle" }, + { "", "newline" }, + { "deathColor", "rgb" }, + { "useDeathColor", "toggle" }, + { "barAlpha", "slider-percent" }, + { "lossAlpha", "slider-percent" }, + { "backgroundAlpha", "slider-percent" }, }, - comboPoints = { +} + +if CUF.vars.isRetail then + + Defaults.ColorsMenuOrder.castBar = { + { "texture", "texture" }, + { "background", "rgb" }, + { "interruptible", "rgb" }, + { "nonInterruptible", "rgb" }, + { "Empowers", "seperator" }, + { "stageZero", "rgb" }, + { "stageOne", "rgb" }, + { "stageTwo", "rgb" }, + { "stageThree", "rgb" }, + { "stageFour", "rgb" }, + { "fullyCharged", "rgb" }, + }; + + Defaults.ColorsMenuOrder.comboPoints = { { "1", "rgb" }, { "2", "rgb" }, { "3", "rgb" }, @@ -256,49 +300,55 @@ Defaults.ColorsMenuOrder = { { "6", "rgb" }, { "7", "rgb" }, { "charged", "rgb" }, - }, - chi = { + }; + + Defaults.ColorsMenuOrder.essence = { { "1", "rgb" }, { "2", "rgb" }, { "3", "rgb" }, { "4", "rgb" }, { "5", "rgb" }, { "6", "rgb" }, - }, - runes = { + }; + + Defaults.ColorsMenuOrder.classResources = { + { "holyPower", "rgb" }, + { "soulShards", "rgb" }, + { "arcaneCharges", "rgb" }, + }; + + Defaults.ColorsMenuOrder.chi = { + { "1", "rgb" }, + { "2", "rgb" }, + { "3", "rgb" }, + { "4", "rgb" }, + { "5", "rgb" }, + { "6", "rgb" }, + }; + + Defaults.ColorsMenuOrder.runes = { { "bloodRune", "rgb" }, { "frostRune", "rgb" }, { "unholyRune", "rgb" }, - }, - shieldBar = { + }; + + Defaults.ColorsMenuOrder.shieldBar = { { "texture", "texture" }, { "color", "rgb" }, { "overShield", "rgb" }, - }, - healAbsorb = { + }; + + Defaults.ColorsMenuOrder.healAbsorb = { { "texture", "texture" }, { "color", "rgb" }, { "overAbsorb", "rgb" }, { "invertColor", "toggle" }, - }, - unitFrames = { - { "barColor", "rgb" }, - { "", "newline" }, - { "lossColor", "rgb" }, - { "", "newline" }, - { "fullColor", "rgb" }, - { "useFullColor", "toggle" }, - { "", "newline" }, - { "deathColor", "rgb" }, - { "useDeathColor", "toggle" }, - { "barAlpha", "slider-percent" }, - { "lossAlpha", "slider-percent" }, - { "backgroundAlpha", "slider-percent" }, - }, - classBar = { + }; + + Defaults.ColorsMenuOrder.classBar = { { "texture", "texture" }, - } -} + }; +end ---@class Defaults.BlizzardFrames Defaults.BlizzardFrames = {} @@ -640,14 +690,6 @@ Defaults.Widgets = { relativePoint = "CENTER", }, }, -- MARK: Widgets (Bars) - ---@type ShieldBarWidgetTable - shieldBar = { - enabled = false, - frameLevel = 9, - point = "RIGHT", - reverseFill = false, - overShield = false, - }, ---@type CastBarWidgetTable castBar = { enabled = false, @@ -756,6 +798,17 @@ Defaults.Widgets = { } } +if CUF.vars.isRetail then + ---@type ShieldBarWidgetTable + Defaults.Widgets.shieldBar = { + enabled = false, + frameLevel = 9, + point = "RIGHT", + reverseFill = false, + overShield = false, + } +end + -- Boss Widgets Defaults.Widgets_Boss = { ---@type AuraWidgetTable @@ -878,7 +931,6 @@ Defaults.Layouts = { leaderIcon = Defaults.Widgets.leaderIcon, combatIcon = Defaults.Widgets.combatIcon, readyCheckIcon = Defaults.Widgets.readyCheckIcon, - shieldBar = Defaults.Widgets.shieldBar, castBar = Defaults.Widgets.castBar, healAbsorb = Defaults.Widgets.healAbsorb, dispels = Defaults.Widgets.dispels, @@ -892,45 +944,6 @@ Defaults.Layouts = { healthBarColorType = CUF.constants.UnitButtonColorType.CELL, healthLossColorType = CUF.constants.UnitButtonColorType.CUSTOM, }, - focus = { - enabled = false, - powerSize = 2, - size = { 100, 30 }, - position = { -300, 125 }, - widgets = { - nameText = Defaults.Widgets.nameText, - healthText = Defaults.Widgets.healthText, - powerText = Defaults.Widgets.powerText, - levelText = Defaults.Widgets.levelText, - customText = Defaults.Widgets.customText, - buffs = Defaults.Widgets.buffs, - debuffs = Defaults.Widgets.debuffs, - raidIcon = Defaults.Widgets.raidIcon, - roleIcon = Defaults.Widgets.roleIcon, - leaderIcon = Defaults.Widgets.leaderIcon, - combatIcon = Defaults.Widgets.combatIcon, - readyCheckIcon = Defaults.Widgets.readyCheckIcon, - shieldBar = Defaults.Widgets.shieldBar, - castBar = Defaults.Widgets.castBar, - healAbsorb = Defaults.Widgets.healAbsorb, - dispels = Defaults.Widgets.dispels, - fader = Defaults.Widgets.fader - }, - anchorToParent = false, - parent = CUF.constants.UNIT.PLAYER, - anchorPosition = { - point = "BOTTOMLEFT", - relativePoint = "TOPLEFT", - offsetX = 0, - offsetY = 10 - }, - sameSizeAsPlayer = false, - clickCast = false, - barOrientation = "horizontal", - powerFilter = false, - healthBarColorType = CUF.constants.UnitButtonColorType.CELL, - healthLossColorType = CUF.constants.UnitButtonColorType.CUSTOM, - }, targettarget = { enabled = false, powerSize = 2, @@ -974,7 +987,6 @@ Defaults.Layouts = { buffs = Defaults.Widgets.buffs, debuffs = Defaults.Widgets.debuffs, raidIcon = Defaults.Widgets.raidIcon, - shieldBar = Defaults.Widgets.shieldBar, castBar = Defaults.Widgets.castBar, healAbsorb = Defaults.Widgets.healAbsorb, dispels = Defaults.Widgets.dispels, @@ -995,7 +1007,53 @@ Defaults.Layouts = { healthBarColorType = CUF.constants.UnitButtonColorType.CELL, healthLossColorType = CUF.constants.UnitButtonColorType.CUSTOM, }, - boss = { +} + +-- Focus was introduced with TBC +if not CUF.vars.isVanilla then + Defaults.Layouts.focus = { + enabled = false, + powerSize = 2, + size = { 100, 30 }, + position = { -300, 125 }, + widgets = { + nameText = Defaults.Widgets.nameText, + healthText = Defaults.Widgets.healthText, + powerText = Defaults.Widgets.powerText, + levelText = Defaults.Widgets.levelText, + customText = Defaults.Widgets.customText, + buffs = Defaults.Widgets.buffs, + debuffs = Defaults.Widgets.debuffs, + raidIcon = Defaults.Widgets.raidIcon, + roleIcon = Defaults.Widgets.roleIcon, + leaderIcon = Defaults.Widgets.leaderIcon, + combatIcon = Defaults.Widgets.combatIcon, + readyCheckIcon = Defaults.Widgets.readyCheckIcon, + castBar = Defaults.Widgets.castBar, + healAbsorb = Defaults.Widgets.healAbsorb, + dispels = Defaults.Widgets.dispels, + fader = Defaults.Widgets.fader + }, + anchorToParent = false, + parent = CUF.constants.UNIT.PLAYER, + anchorPosition = { + point = "BOTTOMLEFT", + relativePoint = "TOPLEFT", + offsetX = 0, + offsetY = 10 + }, + sameSizeAsPlayer = false, + clickCast = false, + barOrientation = "horizontal", + powerFilter = false, + healthBarColorType = CUF.constants.UnitButtonColorType.CELL, + healthLossColorType = CUF.constants.UnitButtonColorType.CUSTOM, + } +end + +-- Boss frames were intoduced with Wrath +if not CUF.vars.isVanilla and not CUF.vars.isBCC then + Defaults.Layouts.boss = { enabled = false, powerSize = 4, spacing = 50, @@ -1012,7 +1070,6 @@ Defaults.Layouts = { levelText = Defaults.Widgets.levelText, customText = Defaults.Widgets.customText, raidIcon = Defaults.Widgets.raidIcon, - shieldBar = Defaults.Widgets.shieldBar, buffs = Defaults.Widgets_Boss.buffs, debuffs = Defaults.Widgets_Boss.debuffs, castBar = Defaults.Widgets_Boss.castBar, @@ -1021,7 +1078,14 @@ Defaults.Layouts = { healthBarColorType = CUF.constants.UnitButtonColorType.CELL, healthLossColorType = CUF.constants.UnitButtonColorType.CUSTOM, } -} +end + +if CUF.vars.isRetail then + Defaults.Layouts.target.widgets.shieldBar = Defaults.Widgets.shieldBar; + Defaults.Layouts.pet.widgets.shieldBar = Defaults.Widgets.shieldBar; + Defaults.Layouts.focus.widgets.shieldBar = Defaults.Widgets.shieldBar; + Defaults.Layouts.boss.widgets.shieldBar = Defaults.Widgets.shieldBar; +end Defaults.Layouts[CUF.constants.UNIT.PLAYER].widgets.fader.enabled = false Defaults.Layouts[CUF.constants.UNIT.PLAYER].widgets.fader.range = false diff --git a/Locales/enUS.lua b/Locales/enUS.lua index caa1073..9119f70 100644 --- a/Locales/enUS.lua +++ b/Locales/enUS.lua @@ -123,6 +123,7 @@ L.ShowEmpowerName = "Show Empower Name" L.ShowBorder = "Show Border" L.ShowIcon = "Show Icon" L.Zoom = "Zoom" +L.Channeling = "Channeling" L.UseFullyChargedTooltip = "Use fully charged color for the final stage" L.ShowEmpowerNameTooltip = "Show the spell name for Empowers" diff --git a/Menu/Builder.lua b/Menu/Builder.lua index e03149e..ba7b952 100644 --- a/Menu/Builder.lua +++ b/Menu/Builder.lua @@ -23,7 +23,7 @@ Builder.singleOptionWidth = 117 Builder.dualOptionWidth = 117 * 2 Builder.tripleOptionWidth = 117 * 3 ----@enum MenuOptions +---@class MenuOptions Builder.MenuOptions = { TextColor = 1, TextWidth = 2, @@ -46,15 +46,12 @@ Builder.MenuOptions = { FullAnchor = 19, ColorPicker = 20, CastBarGeneral = 21, - ClassBarOptions = 22, CastBarTimer = 23, CastBarSpell = 24, CastBarSpark = 25, - CastBarEmpower = 26, CastBarBorder = 27, CastBarIcon = 28, NameFormat = 29, - ShieldBarOptions = 30, CustomText = 31, DispelsOptions = 32, TrueSingleSizeOptions = 33, @@ -63,6 +60,12 @@ Builder.MenuOptions = { HideOutOfCombat = 36 } +if CUF.vars.isRetail then + Builder.MenuOptions.ClassBarOptions = 22; + Builder.MenuOptions.CastBarEmpower = 26; + Builder.MenuOptions.ShieldBarOptions = 30; +end + ------------------------------------------------- -- MARK: Build Menu ------------------------------------------------- @@ -817,37 +820,56 @@ end ---@param widgetName WIDGET_KIND ---@return HealthFormatOptions function Builder:CreateHealthFormatOptions(parent, widgetName) - local healthFormats = { - { "32%", - const.HealthTextFormat.PERCENTAGE, }, - { "32+25% |cFFA7A7A7+" .. L["shields"], - const.HealthTextFormat.PERCENTAGE_ABSORBS }, - { "57% |cFFA7A7A7+" .. L["shields"], - const.HealthTextFormat.PERCENTAGE_ABSORBS_MERGED }, - { "-67%", - const.HealthTextFormat.PERCENTAGE_DEFICIT }, - { "21377", - const.HealthTextFormat.NUMBER }, - { F:FormatNumber(21377), - const.HealthTextFormat.NUMBER_SHORT }, - { F:FormatNumber(21377) .. "+" .. F:FormatNumber(16384) .. " |cFFA7A7A7+" .. L["shields"], - const.HealthTextFormat.NUMBER_ABSORBS_SHORT }, - { F:FormatNumber(21377 + 16384) .. " |cFFA7A7A7+" .. L["shields"], - const.HealthTextFormat.NUMBER_ABSORBS_MERGED_SHORT }, - { "-44158", - const.HealthTextFormat.NUMBER_DEFICIT }, - { F:FormatNumber(-44158), - const.HealthTextFormat.NUMBER_DEFICIT_SHORT }, - { F:FormatNumber(21377) .. " 32% |cFFA7A7A7HP", - const.HealthTextFormat.CURRENT_SHORT_PERCENTAGE }, - { "16384 |cFFA7A7A7" .. L["shields"], - const.HealthTextFormat.ABSORBS_ONLY }, - { F:FormatNumber(16384) .. " |cFFA7A7A7" .. L["shields"], - const.HealthTextFormat.ABSORBS_ONLY_SHORT }, - { "25% |cFFA7A7A7" .. L["shields"], - const.HealthTextFormat.ABSORBS_ONLY_PERCENTAGE }, - { L["Custom"], const.HealthTextFormat.CUSTOM } - } + -- support partial definitions + -- maybe move the example text into the const.HealthTextFormat? + -- that could make it iterable / 1:1 usable + local healthFormats = {} + + if const.HealthTextFormat.PERCENTAGE then + table.insert(healthFormats, { "32%", const.HealthTextFormat.PERCENTAGE }) + end + if const.HealthTextFormat.PERCENTAGE_ABSORBS then + table.insert(healthFormats, { "32+25% |cFFA7A7A7+" .. L["shields"], const.HealthTextFormat.PERCENTAGE_ABSORBS }) + end + if const.HealthTextFormat.PERCENTAGE_ABSORBS_MERGED then + table.insert(healthFormats, { "57% |cFFA7A7A7+" .. L["shields"], const.HealthTextFormat.PERCENTAGE_ABSORBS_MERGED }) + end + if const.HealthTextFormat.PERCENTAGE_DEFICIT then + table.insert(healthFormats, { "-67%", const.HealthTextFormat.PERCENTAGE_DEFICIT }) + end + if const.HealthTextFormat.NUMBER then + table.insert(healthFormats, { "21377", const.HealthTextFormat.NUMBER }) + end + if const.HealthTextFormat.NUMBER_SHORT then + table.insert(healthFormats, { F:FormatNumber(21377), const.HealthTextFormat.NUMBER_SHORT }) + end + if const.HealthTextFormat.NUMBER_ABSORBS_SHORT then + table.insert(healthFormats, { F:FormatNumber(21377) .. "+" .. F:FormatNumber(16384) .. " |cFFA7A7A7+" .. L["shields"], const.HealthTextFormat.NUMBER_ABSORBS_SHORT }) + end + if const.HealthTextFormat.NUMBER_ABSORBS_MERGED_SHORT then + table.insert(healthFormats, { F:FormatNumber(21377 + 16384) .. " |cFFA7A7A7+" .. L["shields"], const.HealthTextFormat.NUMBER_ABSORBS_MERGED_SHORT }) + end + if const.HealthTextFormat.NUMBER_DEFICIT then + table.insert(healthFormats, { "-44158", const.HealthTextFormat.NUMBER_DEFICIT }) + end + if const.HealthTextFormat.NUMBER_DEFICIT_SHORT then + table.insert(healthFormats, { F:FormatNumber(-44158), const.HealthTextFormat.NUMBER_DEFICIT_SHORT }) + end + if const.HealthTextFormat.CURRENT_SHORT_PERCENTAGE then + table.insert(healthFormats, { F:FormatNumber(21377) .. " 32% |cFFA7A7A7HP", const.HealthTextFormat.CURRENT_SHORT_PERCENTAGE }) + end + if const.HealthTextFormat.ABSORBS_ONLY then + table.insert(healthFormats, { "16384 |cFFA7A7A7" .. L["shields"], const.HealthTextFormat.ABSORBS_ONLY }) + end + if const.HealthTextFormat.ABSORBS_ONLY_SHORT then + table.insert(healthFormats, { F:FormatNumber(16384) .. " |cFFA7A7A7" .. L["shields"], const.HealthTextFormat.ABSORBS_ONLY_SHORT }) + end + if const.HealthTextFormat.ABSORBS_ONLY_PERCENTAGE then + table.insert(healthFormats, { "25% |cFFA7A7A7" .. L["shields"], const.HealthTextFormat.ABSORBS_ONLY_PERCENTAGE }) + end + if const.HealthTextFormat.CUSTOM then + table.insert(healthFormats, { L["Custom"], const.HealthTextFormat.CUSTOM }) + end ---@class HealthFormatOptions: OptionsFrame local f = CUF:CreateFrame(nil, parent, 1, 1, true, true) @@ -1633,36 +1655,38 @@ end -- MARK: Class Bar ------------------------------------------------- ----@param parent Frame ----@param widgetName WIDGET_KIND ----@return ClassBarOptions -function Builder:CreateClassBarOptions(parent, widgetName) - ---@class ClassBarOptions: OptionsFrame - local f = CUF:CreateFrame(nil, parent, 1, 1, true, true) - f.id = "ClassBarOptions" - f.optionHeight = 120 - - -- First Row - f.anchorOptions = self:CreateAnchorOptions(f, widgetName, nil, -1000, 1000) - f.anchorOptions:SetPoint("TOPLEFT", 0, -5) - - -- Second Row - f.sizeOptions = self:CreateSizeOptions(f, widgetName, 0, 500) - self:AnchorBelow(f.sizeOptions, f.anchorOptions.anchorDropdown) - - f.spacing = self:CreateSlider(f, widgetName, L["Spacing"], nil, -1, 50, - const.OPTION_KIND.SPACING) - self:AnchorRight(f.spacing, f.sizeOptions.sizeHeightSlider) - - -- Third Row - f.verticalFill = self:CreateCheckBox(f, widgetName, L.VerticalFill, const.OPTION_KIND.VERTICAL_FILL) - self:AnchorBelow(f.verticalFill, f.sizeOptions.sizeWidthSlider) - - f.sameSizeAsHealthBar = self:CreateCheckBox(f, widgetName, L.SameSizeAsHealthBar, - const.OPTION_KIND.SAME_SIZE_AS_HEALTH_BAR) - self:AnchorRightOfCB(f.sameSizeAsHealthBar, f.verticalFill) - - return f +if CUF.vars.isRetail then + ---@param parent Frame + ---@param widgetName WIDGET_KIND + ---@return ClassBarOptions + function Builder:CreateClassBarOptions(parent, widgetName) + ---@class ClassBarOptions: OptionsFrame + local f = CUF:CreateFrame(nil, parent, 1, 1, true, true) + f.id = "ClassBarOptions" + f.optionHeight = 120 + + -- First Row + f.anchorOptions = self:CreateAnchorOptions(f, widgetName, nil, -1000, 1000) + f.anchorOptions:SetPoint("TOPLEFT", 0, -5) + + -- Second Row + f.sizeOptions = self:CreateSizeOptions(f, widgetName, 0, 500) + self:AnchorBelow(f.sizeOptions, f.anchorOptions.anchorDropdown) + + f.spacing = self:CreateSlider(f, widgetName, L["Spacing"], nil, -1, 50, + const.OPTION_KIND.SPACING) + self:AnchorRight(f.spacing, f.sizeOptions.sizeHeightSlider) + + -- Third Row + f.verticalFill = self:CreateCheckBox(f, widgetName, L.VerticalFill, const.OPTION_KIND.VERTICAL_FILL) + self:AnchorBelow(f.verticalFill, f.sizeOptions.sizeWidthSlider) + + f.sameSizeAsHealthBar = self:CreateCheckBox(f, widgetName, L.SameSizeAsHealthBar, + const.OPTION_KIND.SAME_SIZE_AS_HEALTH_BAR) + self:AnchorRightOfCB(f.sameSizeAsHealthBar, f.verticalFill) + + return f + end end ------------------------------------------------- @@ -1752,16 +1776,20 @@ function Builder:CreateCustomTextOptions(parent, widgetName) tagHint:SetScript("OnClick", function() W.ShowTooltipFrame() - CUF.HelpTips:Acknowledge(tagHint, L.HelpTip_TagHintButton) + if CUF.vars.isRetail then + CUF.HelpTips:Acknowledge(tagHint, L.HelpTip_TagHintButton) + end end) - CUF.HelpTips:Show(tagHint, { - text = L.HelpTip_TagHintButton, - dbKey = "tagHintButton_Builder", - buttonStyle = HelpTip.ButtonStyle.None, - alignment = HelpTip.Alignment.Center, - targetPoint = HelpTip.Point.LeftEdgeCenter, - }) + if CUF.vars.isRetail then + CUF.HelpTips:Show(tagHint, { + text = L.HelpTip_TagHintButton, + dbKey = "tagHintButton_Builder", + buttonStyle = HelpTip.ButtonStyle.None, + alignment = HelpTip.Alignment.Center, + targetPoint = HelpTip.Point.LeftEdgeCenter, + }) + end -- Color local items = { @@ -2010,11 +2038,8 @@ Builder.MenuFuncs = { [Builder.MenuOptions.CastBarTimer] = Builder.CreateCastBarTimerFontOptions, [Builder.MenuOptions.CastBarSpell] = Builder.CreateCastBarSpellFontOptions, [Builder.MenuOptions.CastBarSpark] = Builder.CreateCastBarSparkOptions, - [Builder.MenuOptions.CastBarEmpower] = Builder.CreateCastBarEmpowerOptions, [Builder.MenuOptions.CastBarBorder] = Builder.CreatCastBarBorderOptions, [Builder.MenuOptions.CastBarIcon] = Builder.CreateCastBarIconOptions, - [Builder.MenuOptions.ClassBarOptions] = Builder.CreateClassBarOptions, - [Builder.MenuOptions.ShieldBarOptions] = Builder.CreateShieldBarOptions, [Builder.MenuOptions.CustomText] = Builder.CreateCustomTextOptions, [Builder.MenuOptions.DispelsOptions] = Builder.CreateDispelsOptions, [Builder.MenuOptions.TrueSingleSizeOptions] = Builder.CreateTrueSingleSizeOptions, @@ -2022,3 +2047,15 @@ Builder.MenuFuncs = { [Builder.MenuOptions.HideAtMaxLevel] = Builder.CreateHideAtMaxLevel, [Builder.MenuOptions.HideOutOfCombat] = Builder.CreateHideOutOfCombat, } + +if Builder.MenuOptions.CastBarEmpower then + Builder.MenuFuncs[Builder.MenuOptions.CastBarEmpower] = Builder.CreateCastBarEmpowerOptions; +end + +if Builder.MenuOptions.ClassBarOptions then + Builder.MenuFuncs[Builder.MenuOptions.ClassBarOptions] = Builder.CreateClassBarOptions; +end + +if Builder.MenuOptions.ShieldBarOptions then + Builder.MenuFuncs[Builder.MenuOptions.ShieldBarOptions] = Builder.CreateShieldBarOptions; +end diff --git a/Menu/GeneralTab.lua b/Menu/GeneralTab.lua index 5b1d355..58281ab 100644 --- a/Menu/GeneralTab.lua +++ b/Menu/GeneralTab.lua @@ -285,17 +285,21 @@ function Misc:Create() self.blizzardFramesButton = CUF:CreateButton(self.frame, L["Blizzard Frames"], { 195, 20 }, function() self:ShowBlizzardFramesPopup() - CUF.HelpTips:Acknowledge(self.blizzardFramesButton, L.HelpTip_BlizzardFramesToggle) + if CUF.vars.isRetail then + CUF.HelpTips:Acknowledge(self.blizzardFramesButton, L.HelpTip_BlizzardFramesToggle) + end end) self.blizzardFramesButton:SetPoint("TOPLEFT", self.useScalingCB, "BOTTOMLEFT", 0, -10) - CUF.HelpTips:Show(self.blizzardFramesButton, { - text = L.HelpTip_BlizzardFramesToggle, - dbKey = "blizzardFramesToggle", - buttonStyle = HelpTip.ButtonStyle.None, - alignment = HelpTip.Alignment.Center, - targetPoint = HelpTip.Point.TopEdgeCenter, - }) + if CUF.vars.isRetail then + CUF.HelpTips:Show(self.blizzardFramesButton, { + text = L.HelpTip_BlizzardFramesToggle, + dbKey = "blizzardFramesToggle", + buttonStyle = HelpTip.ButtonStyle.None, + alignment = HelpTip.Alignment.Center, + targetPoint = HelpTip.Point.TopEdgeCenter, + }) + end ---@class BlizzardFramesPopup: Frame, BackdropTemplate self.blizzardFramesPopup = CUF:CreateFrame("CUF_Misc_BlizzardFramesPopup", self.frame, 195, 10) diff --git a/Menu/Menu.lua b/Menu/Menu.lua index bfd4757..26a936d 100644 --- a/Menu/Menu.lua +++ b/Menu/Menu.lua @@ -290,7 +290,9 @@ function menu:CreateMenu() editModeButton:SetScript("OnClick", function() CUF.uFuncs:EditMode() - CUF.HelpTips:Acknowledge(editModeButton, L.HelpTip_EditModeToggle) + if CUF.vars.isRetail then + CUF.HelpTips:Acknowledge(editModeButton, L.HelpTip_EditModeToggle) + end end) editModeButton:SetScript("OnHide", function() CUF.uFuncs:EditMode(false) @@ -298,13 +300,15 @@ function menu:CreateMenu() self.editModeButton = editModeButton self.editModeButton:Hide() - CUF.HelpTips:Show(editModeButton, { - text = L.HelpTip_EditModeToggle, - dbKey = "editModeToggle", - buttonStyle = HelpTip.ButtonStyle.None, - alignment = HelpTip.Alignment.Left, - targetPoint = HelpTip.Point.LeftEdgeCenter, - }) + if CUF.vars.isRetail then + CUF.HelpTips:Show(editModeButton, { + text = L.HelpTip_EditModeToggle, + dbKey = "editModeToggle", + buttonStyle = HelpTip.ButtonStyle.None, + alignment = HelpTip.Alignment.Left, + targetPoint = HelpTip.Point.LeftEdgeCenter, + }) + end hooksecurefunc(optionsFrame, "Hide", function() self:HideMenu() diff --git a/Menu/UnitFramesTab.lua b/Menu/UnitFramesTab.lua index f690215..928bfd4 100644 --- a/Menu/UnitFramesTab.lua +++ b/Menu/UnitFramesTab.lua @@ -94,6 +94,7 @@ function unitFramesTab:InitUnits() local prevButton local prevAnchor local idx = 1 + local rowsUsed = 1 for _, fn in pairs(self.unitsToAdd) do ---@type UnitsMenuPage @@ -104,6 +105,7 @@ function unitFramesTab:InitUnits() if prevButton then -- Max 4 buttons per row if idx % 4 == 0 then + rowsUsed = rowsUsed + 1 unit.pageButton:SetPoint("BOTTOMLEFT", prevAnchor, "TOPLEFT", 0, 0) idx = 1 prevAnchor = unit.pageButton @@ -122,6 +124,12 @@ function unitFramesTab:InitUnits() table.insert(self.unitPageButtons, unit.pageButton) end + + -- Prevent the edit mode button from colliding with the unitPane CreateTitledPane + if rowsUsed == 1 then + self.window:SetHeight(self.window:GetHeight() + self.paneHeight) + self.unitPane:SetHeight(self.unitPane:GetHeight() + self.paneHeight) + end end ---@param unit function diff --git a/UnitFrames/EditMode.lua b/UnitFrames/EditMode.lua index 8901ac6..e3560c8 100644 --- a/UnitFrames/EditMode.lua +++ b/UnitFrames/EditMode.lua @@ -435,10 +435,13 @@ local colors = { [const.UNIT.PLAYER] = { 1, 0, 0 }, [const.UNIT.TARGET] = { 1, 0.5, 0 }, [const.UNIT.TARGET_TARGET] = { 1, 1, 0 }, - [const.UNIT.FOCUS] = { 0, 1, 0 }, [const.UNIT.PET] = { 0, 0.5, 1 }, } +if const.UNIT.FOCUS then + colors[const.UNIT.FOCUS] = { 0, 1, 0 }; +end + ---@param widget Widget ---@param unit Unit ---@param unitOverlay CUFOverlayBox @@ -656,13 +659,15 @@ local function ShowOverlays() local overlay = overlays[unit] or CreateOverlayBox(CUF.unitButtons[unit], unit) if unit == "player" then - CUF.HelpTips:Show(overlay, { - text = L.HelpTip_EditModeOverlay, - dbKey = "editModeOverlay", - buttonStyle = HelpTip.ButtonStyle.GotIt, - alignment = HelpTip.Alignment.Center, - targetPoint = HelpTip.Point.TopEdgeCenter, - }) + if CUF.vars.isRetail then + CUF.HelpTips:Show(overlay, { + text = L.HelpTip_EditModeOverlay, + dbKey = "editModeOverlay", + buttonStyle = HelpTip.ButtonStyle.GotIt, + alignment = HelpTip.Alignment.Center, + targetPoint = HelpTip.Point.TopEdgeCenter, + }) + end end overlay.fadeIn:Play() diff --git a/UnitFrames/MenuOptions.lua b/UnitFrames/MenuOptions.lua index deb53d1..ccc270c 100644 --- a/UnitFrames/MenuOptions.lua +++ b/UnitFrames/MenuOptions.lua @@ -242,13 +242,15 @@ local function AddUnitsToMenu() end if CUF.unitButtons.boss and CUF.unitButtons.boss.boss1 then - CUF.HelpTips:Show(unitPage.spacingSlider, { - text = format(L.HelpTip_BossFramePreview, L.Boss, L.player), - dbKey = "bossFramePreview", - buttonStyle = HelpTip.ButtonStyle.GotIt, - alignment = HelpTip.Alignment.Left, - targetPoint = HelpTip.Point.LeftEdgeCenter, - }, CUF.unitButtons.boss.boss1) + if CUF.vars.isRetail then + CUF.HelpTips:Show(unitPage.spacingSlider, { + text = format(L.HelpTip_BossFramePreview, L.Boss, L.player), + dbKey = "bossFramePreview", + buttonStyle = HelpTip.ButtonStyle.GotIt, + alignment = HelpTip.Alignment.Left, + targetPoint = HelpTip.Point.LeftEdgeCenter, + }, CUF.unitButtons.boss.boss1) + end end else ---@type CheckButton diff --git a/UnitFrames/OnLoad.lua b/UnitFrames/OnLoad.lua index 5dc1cf4..c48656d 100644 --- a/UnitFrames/OnLoad.lua +++ b/UnitFrames/OnLoad.lua @@ -16,7 +16,64 @@ local GetUnitName = GetUnitName local UnitGUID = UnitGUID local GetAuraDataByAuraInstanceID = C_UnitAuras.GetAuraDataByAuraInstanceID -local ForEachAura = AuraUtil.ForEachAura +local AuraFilters = (AuraUtil and AuraUtil.AuraFilters or { + Helpful = "HELPFUL", + Harmful = "HARMFUL", + Raid = "RAID", + IncludeNameplateOnly = "INCLUDE_NAME_PLATE_ONLY", + Player = "PLAYER", + Cancelable = "CANCELABLE", + NotCancelable = "NOT_CANCELABLE", + Maw = "MAW", +}); + +local AuraUpdateChangedType = (AuraUtil and AuraUtil.AuraUpdateChangedType or EnumUtil.MakeEnum( + "None", + "Debuff", + "Buff", + "Dispel" +)); + +local function ForEachAura(...) + if AuraUtil.ForEachAura then return AuraUtil.ForEachAura(...) end + + local function ForEachAuraHelper(unit, filter, func, usePackedAura, continuationToken, ...) + -- continuationToken is the first return value of UnitAuraSlots() + local n = select('#', ...); + for i=1, n do + local slot = select(i, ...); + local done; + local auraInfo = C_UnitAuras.GetAuraDataBySlot(unit, slot); + + -- Protect against GetAuraDataBySlot desyncing with GetAuraSlots + if auraInfo then + if usePackedAura then + done = func(auraInfo); + else + done = func(AuraUtil.UnpackAuraData(auraInfo)); + end + end + if done then + -- if func returns true then no further slots are needed, so don't return continuationToken + return nil; + end + end + return continuationToken; + end + + local function ForEachAura(unit, filter, maxCount, func, usePackedAura) + if maxCount and maxCount <= 0 then + return; + end + local continuationToken; + repeat + -- continuationToken is the first return value of UnitAuraSltos + continuationToken = ForEachAuraHelper(unit, filter, func, usePackedAura, C_UnitAuras.GetAuraSlots(unit, filter, maxCount, continuationToken)); + until continuationToken == nil; + end + + return ForEachAura(...) +end ------------------------------------------------- -- MARK: Aura tables @@ -56,25 +113,25 @@ end ---@return AuraUtil.AuraUpdateChangedType local function ProcessAura(aura, ignoreBuffs, ignoreDebuffs) if aura == nil then - return AuraUtil.AuraUpdateChangedType.None; + return AuraUpdateChangedType.None; end if aura.isNameplateOnly then - return AuraUtil.AuraUpdateChangedType.None; + return AuraUpdateChangedType.None; end if aura.isHarmful and not ignoreDebuffs then aura.dispelName = CheckDebuffType(aura.dispelName, aura.spellId) if aura.dispelName ~= "" then - return AuraUtil.AuraUpdateChangedType.Dispel + return AuraUpdateChangedType.Dispel end - return AuraUtil.AuraUpdateChangedType.Debuff + return AuraUpdateChangedType.Debuff elseif aura.isHelpful and not ignoreBuffs then - return AuraUtil.AuraUpdateChangedType.Buff + return AuraUpdateChangedType.Buff end - return AuraUtil.AuraUpdateChangedType.None; + return AuraUpdateChangedType.None; end --- Perform a full aura update for a unit @@ -90,20 +147,20 @@ local function ParseAllAuras(self, ignoreBuffs, ignoreDebuffs) ---@param aura AuraData local function HandleAura(aura) local type = ProcessAura(aura, ignoreBuffs, ignoreDebuffs) - if type == AuraUtil.AuraUpdateChangedType.Debuff or type == AuraUtil.AuraUpdateChangedType.Dispel then + if type == AuraUpdateChangedType.Debuff or type == AuraUpdateChangedType.Dispel then self._auraDebuffCache[aura.auraInstanceID] = aura - elseif type == AuraUtil.AuraUpdateChangedType.Buff then + elseif type == AuraUpdateChangedType.Buff or type == AuraUpdateChangedType.None then self._auraBuffCache[aura.auraInstanceID] = aura end end if not ignoreDebuffs then - ForEachAura(self.states.unit, AuraUtil.AuraFilters.Harmful, batchCount, + ForEachAura(self.states.unit, AuraFilters.Harmful, batchCount, HandleAura, usePackedAura) end if not ignoreBuffs then - ForEachAura(self.states.unit, AuraUtil.AuraFilters.Helpful, batchCount, + ForEachAura(self.states.unit, AuraFilters.Helpful, batchCount, HandleAura, usePackedAura) end @@ -136,11 +193,11 @@ local function UpdateAurasInternal(self, event, unit, unitAuraUpdateInfo) for _, aura in ipairs(unitAuraUpdateInfo.addedAuras) do local type = ProcessAura(aura, self._ignoreBuffs, self._ignoreDebuffs) - if type == AuraUtil.AuraUpdateChangedType.Debuff or type == AuraUtil.AuraUpdateChangedType.Dispel then + if type == AuraUpdateChangedType.Debuff or type == AuraUpdateChangedType.Dispel then self._auraDebuffCache[aura.auraInstanceID] = aura debuffsChanged = true - dispelsChanged = type == AuraUtil.AuraUpdateChangedType.Dispel - elseif type == AuraUtil.AuraUpdateChangedType.Buff then + dispelsChanged = type == AuraUpdateChangedType.Dispel + elseif type == AuraUpdateChangedType.Buff then self._auraBuffCache[aura.auraInstanceID] = aura buffsChanged = true end @@ -603,11 +660,13 @@ function CUFUnitButton_OnLoad(button) button.healthLossColorType = const.UnitButtonColorType.CELL -- ping system - Mixin(button, PingableType_UnitFrameMixin) - button:SetAttribute("ping-receiver", true) + if CUF.vars.isRetail then + Mixin(button, PingableType_UnitFrameMixin) + button:SetAttribute("ping-receiver", true) - function button:GetTargetPingGUID() - return button.__unitGuid + function button:GetTargetPingGUID() + return button.__unitGuid + end end ---@param widget WIDGET_KIND diff --git a/UnitFrames/UnitButton.lua b/UnitFrames/UnitButton.lua index d5202c7..e0fb5cc 100644 --- a/UnitFrames/UnitButton.lua +++ b/UnitFrames/UnitButton.lua @@ -243,11 +243,13 @@ function U:SetOrientation(button, orientation, rotateTexture) -- update actions --I.UpdateActionsOrientation(button, orientation) - if button:HasWidget(const.WIDGET_KIND.SHIELD_BAR) then - W.UpdateShieldBarWidget(button, button._baseUnit) - end - if button:HasWidget(const.WIDGET_KIND.HEAL_ABSORB) then - button.widgets.healAbsorb:SetOrientation(orientation) + if CUF.vars.isRetail then + if button:HasWidget(const.WIDGET_KIND.SHIELD_BAR) then + W.UpdateShieldBarWidget(button, button._baseUnit) + end + if button:HasWidget(const.WIDGET_KIND.HEAL_ABSORB) then + button.widgets.healAbsorb:SetOrientation(orientation) + end end end diff --git a/Util/HideBlizzard.lua b/Util/HideBlizzard.lua index c87a083..cbe2893 100644 --- a/Util/HideBlizzard.lua +++ b/Util/HideBlizzard.lua @@ -55,6 +55,9 @@ function CUF:HideBlizzardUnitFrame(type) if _G.PlayerCastingBarFrame then HideFrame(_G.PlayerCastingBarFrame) end + if CUF.vars.isVanilla and _G.CastingBarFrame then + HideFrame(_G.CastingBarFrame) + end elseif type == "target" and _G.TargetFrame then HideFrame(_G.TargetFrame) elseif type == "focus" and _G.FocusFrame then diff --git a/Util/Utils.lua b/Util/Utils.lua index e0518c3..f178e8f 100644 --- a/Util/Utils.lua +++ b/Util/Utils.lua @@ -13,6 +13,7 @@ local Util = CUF.Util local const = CUF.constants local GetWeaponEnchantInfo = GetWeaponEnchantInfo +local UnitSelectionType = UnitSelectionType ------------------------------------------------- -- MARK: Prop Hunting @@ -447,6 +448,15 @@ function Util:GetPowerColor(unit) return r, g, b end +-- Helper fallback function for older game versions, blizzards function was introduced with BFA +---@param unit UnitToken +function Util:UnitSelectionType(unit) + if UnitIsFriend(unit, "player") then return 3 end + if UnitIsEnemy(unit, "player") then return 0 end + if UnitIsUnit(unit, "pet") or UnitIsOtherPlayersPet(unit) then return 4 end + return 999 +end + ---@param unit UnitToken ---@param class? string ---@param guid? string @@ -460,7 +470,7 @@ function Util:GetUnitClassColor(unit, class, guid) return F:GetClassColor(class) end - local selectionType = UnitSelectionType(unit) + local selectionType = UnitSelectionType and UnitSelectionType(unit) or Util:UnitSelectionType(unit) -- Friendly if selectionType == 3 then @@ -637,6 +647,117 @@ function Util:GetWeaponEnchantInfo() end end +do + local function ForEachAuraHelperByIndex(unit, filter, func) + for i = 1, 40 do + local auraInfo = C_UnitAuras.GetAuraDataByIndex(unit, i, filter); + if auraInfo and func(auraInfo) then + return i; + end + end + return nil; + end + + ---@param unit UnitToken + ---@param auraInstanceID number + ---@param filter "HELPFUL" | "HARMFUL" + ---@return string? + function Util:GetAuraIndexByAuraInstanceID(unit, auraInstanceID, filter) + local func = function(aura) + if aura.auraInstanceID == auraInstanceID then return aura end + end + return ForEachAuraHelperByIndex(unit, filter, func); + end +end + +local ChannelDurationLUT = { + [698] = 10* 60000, --Ritual of Summoning + [605] = 1* 60000, --Mind Control + [19305] = 6000, --Starshards + [18540] = 1* 60000, --Ritual of Doom + [1515] = 20000, --Tame Beast + [10] = 8000, --Blizzard + [689] = 5000, --Drain Life + [11684] = 15000, --Hellfire + [5740] = 8000, --Rain of Fire + [10797] = 6000, --Starshards + [740] = 10000, --Tranquility + [1120] = 15000, --Drain Soul + [12051] = 8000, --Evocation + [16914] = 10000, --Hurricane + [14295] = 6000, --Volley + [5143] = 3000, --Arcane Missiles + [1002] = 1* 60000, --Eyes of the Beast + [1949] = 15000, --Hellfire + [11704] = 5000, --Drain Mana + [10187] = 8000, --Blizzard + [136] = 5000, --Mend Pet + [11678] = 8000, --Rain of Fire + [126] = 45000, --Eye of Kilrogg + [6197] = 1* 60000, --Eagle Eye + [755] = 10000, --Health Funnel + [10912] = 1* 60000, --Mind Control + [6196] = 1* 60000, --Far Sight + [11700] = 5000, --Drain Life + [10911] = 1* 60000, --Mind Control + [17402] = 10000, --Hurricane + [17401] = 10000, --Hurricane + [6141] = 8000, --Blizzard + [25345] = 5000, --Arcane Missiles + [11683] = 15000, --Hellfire + [9863] = 10000, --Tranquility + [5138] = 5000, --Drain Mana + [11675] = 15000, --Drain Soul + [2096] = 1* 60000, --Mind Vision + [10185] = 8000, --Blizzard + [8427] = 8000, --Blizzard + [8289] = 15000, --Drain Soul + [709] = 5000, --Drain Life + [10909] = 1* 60000, --Mind Vision + [11693] = 10000, --Health Funnel + [1510] = 6000, --Volley + [6226] = 5000, --Drain Mana + [19296] = 6000, --Starshards + [5144] = 4000, --Arcane Missiles + [19302] = 6000, --Starshards + [3700] = 10000, --Health Funnel + [10186] = 8000, --Blizzard + [10211] = 5000, --Arcane Missiles + [3662] = 5000, --Mend Pet + [8288] = 15000, --Drain Soul + [11703] = 5000, --Drain Mana + [699] = 5000, --Drain Life + [5145] = 5000, --Arcane Missiles + [8417] = 5000, --Arcane Missiles + [10212] = 5000, --Arcane Missiles + [11677] = 8000, --Rain of Fire + [11695] = 10000, --Health Funnel + [3661] = 5000, --Mend Pet + [3699] = 10000, --Health Funnel + [6219] = 8000, --Rain of Fire + [8416] = 5000, --Arcane Missiles + [11699] = 5000, --Drain Life + [13542] = 5000, --Mend Pet + [3111] = 5000, --Mend Pet + [3698] = 10000, --Health Funnel + [11694] = 10000, --Health Funnel + [19299] = 6000, --Starshards + [13544] = 5000, --Mend Pet + [19303] = 6000, --Starshards + [19304] = 6000, --Starshards + [7651] = 5000, --Drain Life + [8918] = 10000, --Tranquility + [9862] = 10000, --Tranquility + [13543] = 5000, --Mend Pet + [14294] = 6000, --Volley +} + +---@param spellID number +---@return number +function Util:GetSpellChannelDuration(spellID) + return ChannelDurationLUT[spellID] or 0 +end + ------------------------------------------------- -- MARK: Unit Info ------------------------------------------------- diff --git a/Widgets/Auras/Auras.lua b/Widgets/Auras/Auras.lua index e6743c1..36134d4 100644 --- a/Widgets/Auras/Auras.lua +++ b/Widgets/Auras/Auras.lua @@ -77,16 +77,27 @@ local function Icons_ShowTooltip(icons, show, hideInCombat) if (hideInCombat and InCombatLockdown()) or icons._isSelected then return end GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") - if icons.id == "buffs" then - if self.isTempEnchant then - GameTooltip:SetInventoryItem("player", self.auraInstanceID); + if CUF.vars.isRetail then + if icons.id == "buffs" then + if self.isTempEnchant then + GameTooltip:SetInventoryItem("player", self.auraInstanceID); + else + GameTooltip:SetUnitBuffByAuraInstanceID(icons._owner.states.displayedUnit, self.auraInstanceID, + icons.auraFilter); + end else - GameTooltip:SetUnitBuffByAuraInstanceID(icons._owner.states.displayedUnit, self.auraInstanceID, + GameTooltip:SetUnitDebuffByAuraInstanceID(icons._owner.states.displayedUnit, self.auraInstanceID, icons.auraFilter); end else - GameTooltip:SetUnitDebuffByAuraInstanceID(icons._owner.states.displayedUnit, self.auraInstanceID, - icons.auraFilter); + -- The aura index is not stored along the auraInstanceId and is prone to change on ever new buff on the unit + -- So it's either rebuilding a mapping on every single buff update or looking for the index on demand + local auraIndex = Util:GetAuraIndexByAuraInstanceID(icons._owner.states.displayedUnit, self.auraInstanceID, icons.auraFilter) + if icons.id == "buffs" then + GameTooltip:SetUnitBuff(icons._owner.states.displayedUnit, auraIndex, icons.auraFilter); + else + GameTooltip:SetUnitDebuff(icons._owner.states.displayedUnit, auraIndex, icons.auraFilter); + end end end) diff --git a/Widgets/Bars/CastBar.lua b/Widgets/Bars/CastBar.lua index efe1863..18d73e4 100644 --- a/Widgets/Bars/CastBar.lua +++ b/Widgets/Bars/CastBar.lua @@ -2,6 +2,7 @@ local CUF = select(2, ...) local F = Cell.funcs +local L = CUF.L ---@class CUF.widgets local W = CUF.widgets @@ -202,7 +203,7 @@ end ---@param event ("UNIT_SPELLCAST_START" | "UNIT_SPELLCAST_CHANNEL_START" | "UNIT_SPELLCAST_EMPOWER_START")? ---@param unit UnitToken ---@param castGUID WOWGUID? -function CastStart(button, event, unit, castGUID) +function CastStart(button, event, unit, castGUID,...) if not ShouldShow(button, unit) then return end local castBar = button.widgets.castBar @@ -218,6 +219,26 @@ function CastStart(button, event, unit, castGUID) event = (numStages and numStages > 0) and "UNIT_SPELLCAST_EMPOWER_START" or "UNIT_SPELLCAST_CHANNEL_START" end + -- In era UnitChannelInfo does not return information for some unit token (e.g. target) + -- if we actually want this we currently need to fake it + if CUF.vars.isVanilla then + if not name then + spellID = ... + if spellID then + local spellChannelDuration = CUF.Util:GetSpellChannelDuration(spellID) + if spellChannelDuration ~= 0 then + local spellInfo = C_Spell.GetSpellInfo(spellID); + name = spellInfo.name + displayName = L.Channeling + texture = spellInfo.originalIconID + local fakeTime = (GetTime()*1000) + startTime, endTime = fakeTime, fakeTime + spellChannelDuration + isTradeSkill, notInterruptible = false, nil + end + end + end + end + if (not name) or (castBar.onlyShowInterrupt and notInterruptible) then castBar:ResetAttributes() castBar:Hide() @@ -227,10 +248,12 @@ function CastStart(button, event, unit, castGUID) castBar.casting = event == "UNIT_SPELLCAST_START" castBar.channeling = event == "UNIT_SPELLCAST_CHANNEL_START" - castBar.empowering = event == "UNIT_SPELLCAST_EMPOWER_START" - if castBar.empowering then - endTime = endTime + GetUnitEmpowerHoldAtMaxTime(unit) + if CUF.vars.isRetail then + castBar.empowering = event == "UNIT_SPELLCAST_EMPOWER_START" + if castBar.empowering then + endTime = endTime + GetUnitEmpowerHoldAtMaxTime(unit) + end end castBar:ClearStages() @@ -261,7 +284,7 @@ function CastStart(button, event, unit, castGUID) castBar:Show() - if castBar.empowering then + if CUF.vars.isRetail and castBar.empowering then castBar:AddStages(numStages) end end diff --git a/Widgets/Bars/HealthBar.lua b/Widgets/Bars/HealthBar.lua index 7b1a4e5..7eb09d3 100644 --- a/Widgets/Bars/HealthBar.lua +++ b/Widgets/Bars/HealthBar.lua @@ -23,6 +23,7 @@ local UnitIsFriend = UnitIsFriend local UnitHealth = UnitHealth local UnitHealthMax = UnitHealthMax local UnitIsDeadOrGhost = UnitIsDeadOrGhost +local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs ------------------------------------------------- -- MARK: Button Update HealthBar @@ -100,7 +101,9 @@ local function UpdateUnitHealthState(button) button.states.health = health button.states.healthMax = healthMax - button.states.totalAbsorbs = UnitGetTotalAbsorbs(unit) + if CUF.vars.isRetail then + button.states.totalAbsorbs = UnitGetTotalAbsorbs(unit) + end if healthMax == 0 then button.states.healthPercent = 0 diff --git a/Widgets/Misc/Fader.lua b/Widgets/Misc/Fader.lua index 31770c3..897fed4 100644 --- a/Widgets/Misc/Fader.lua +++ b/Widgets/Misc/Fader.lua @@ -60,22 +60,42 @@ Handler:RegisterWidget(W.FaderWidget, const.WIDGET_KIND.FADER) -- MARK: Checks ------------------------------------------------- -local DEFAULT_HARM_SPELLS = { - ["WARLOCK"] = 234153, -- Drain Life - ["EVOKER"] = 361469, -- Living Flame -} +local DEFAULT_HARM_SPELLS = {} +if CUF.vars.isRetail then + DEFAULT_HARM_SPELLS = { + ["WARLOCK"] = 234153, -- Drain Life + ["EVOKER"] = 361469, -- Living Flame + } +-- it seems C_Spell.IsSpellInRange always returns true on era servers... +-- elseif CUF.vars.isVanilla then +-- DEFAULT_HARM_SPELLS = { +-- ["HUNTER"] = 14266, -- Raptor Strike to enable melee detection +-- } +end ---@param self FaderWidget ---@param unit UnitToken local function RangeCheck(self, unit) local inRange = F:IsInRange(unit) - -- Hack to circumvent override issue with C_Spell.IsSpellInRange and override spells if not inRange and UnitCanAttack("player", unit) then - local overrideSpell = DEFAULT_HARM_SPELLS[UnitClassBase("player")] + local playerClass = UnitClassBase("player") + + -- Hack to circumvent override issue with C_Spell.IsSpellInRange and override spells + local overrideSpell = DEFAULT_HARM_SPELLS[playerClass] if overrideSpell then inRange = C_Spell.IsSpellInRange(overrideSpell, unit) or false end + + -- Hack to enable hunter melee detection on era + -- C_Spell.IsSpellInRange always returns true for melee spells + -- even IsActionInRange always returns true for melee spells... + if not inRange and CUF.vars.isVanilla and playerClass == "HUNTER" and UnitCanAttack("player", unit) then + -- duel range check, 7 yards + -- this is not accurate to melee range + -- but enables the frames to not get faded at least + inRange = CheckInteractDistance(unit, 3) + end end return inRange diff --git a/Widgets/Texts/CustomFormats.lua b/Widgets/Texts/CustomFormats.lua index 2ef1663..32e8f87 100644 --- a/Widgets/Texts/CustomFormats.lua +++ b/Widgets/Texts/CustomFormats.lua @@ -38,8 +38,8 @@ local UnitHealth = UnitHealth local UnitPowerMax = UnitPowerMax local UnitPowerType = UnitPowerType local UnitHealthMax = UnitHealthMax -local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs -local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs +local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs -- Function is still not present in classic cata, orgiginally made available in mists. +local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs -- Function is still not present in classic cata, orgiginally made available in mists. ------------------------------------------------- -- MARK: Formatting Functions @@ -439,98 +439,100 @@ W:AddTag("perdefhp:short", "UNIT_HEALTH UNIT_MAXHEALTH", function(unit) end, "Health", "-20%") -- MARK: Absorbs -W:AddTag("abs", "UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - return FormatNumberNoZeroes(UnitGetTotalAbsorbs(unit)) -end, "Health", "25000") -W:AddTag("abs:short", "UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - return FormatNumberShortNoZeroes(UnitGetTotalAbsorbs(unit)) -end, "Health", "25K") -W:AddTag("perabs", "UNIT_ABSORB_AMOUNT_CHANGED UNIT_MAXHEALTH", function(unit) - local maxhp = UnitHealthMax(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return FormatPercentNoZeroes(maxhp, totalAbsorbs) -end, "Health", "50.20%") -W:AddTag("perabs:short", "UNIT_ABSORB_AMOUNT_CHANGED UNIT_MAXHEALTH", function(unit) - local maxhp = UnitHealthMax(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return FormatPercentShortNoZeroes(maxhp, totalAbsorbs) -end, "Health", "50%") - --- MARK: Combine -W:AddTag("curhp:abs", "UNIT_HEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local curhp = UnitHealth(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return CombineFormats(FormatNumber(curhp), FormatNumberNoZeroes(totalAbsorbs)) -end, "Health", "35000 + 5000") -W:AddTag("curhp:abs:short", "UNIT_HEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local curhp = UnitHealth(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return CombineFormats(FormatNumberShort(curhp), FormatNumberShortNoZeroes(totalAbsorbs)) -end, "Health", "35K + 5K") -W:AddTag("perhp:perabs", "UNIT_HEALTH UNIT_MAXHEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local curhp = UnitHealth(unit) - local maxhp = UnitHealthMax(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return CombineFormats(FormatPercent(maxhp, curhp), FormatPercentNoZeroes(maxhp, totalAbsorbs)) -end, "Health", "75.20% + 15%") -W:AddTag("perhp:perabs:short", "UNIT_HEALTH UNIT_MAXHEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local curhp = UnitHealth(unit) - local maxhp = UnitHealthMax(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return CombineFormats(FormatPercentShort(maxhp, curhp), FormatPercentShortNoZeroes(maxhp, totalAbsorbs)) -end, "Health", "75% + 15%") - --- MARK: Merge -W:AddTag("curhp:abs:merge", "UNIT_HEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local curhp = UnitHealth(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return FormatNumber(curhp + totalAbsorbs) -end, "Health", "40000") -W:AddTag("curhp:abs:merge:short", "UNIT_HEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local curhp = UnitHealth(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return FormatNumberShort(curhp + totalAbsorbs) -end, "Health", "40K") -W:AddTag("perhp:perabs:merge", "UNIT_HEALTH UNIT_MAXHEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local curhp = UnitHealth(unit) - local maxhp = UnitHealthMax(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return FormatPercent(maxhp, (curhp + totalAbsorbs)) -end, "Health", "90.20%") -W:AddTag("perhp:perabs:merge:short", "UNIT_HEALTH UNIT_MAXHEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local curhp = UnitHealth(unit) - local maxhp = UnitHealthMax(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return FormatPercentShort(maxhp, (curhp + totalAbsorbs)) -end, "Health", "90%") -W:AddTag("abs:healabs:merge", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local totalHealAbsorbs = UnitGetTotalHealAbsorbs(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return FormatNumberNoZeroes(totalAbsorbs - totalHealAbsorbs) -end, "Health", "40000") -W:AddTag("abs:healabs:merge:short", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED UNIT_ABSORB_AMOUNT_CHANGED", function(unit) - local totalHealAbsorbs = UnitGetTotalHealAbsorbs(unit) - local totalAbsorbs = UnitGetTotalAbsorbs(unit) - return FormatNumberShortNoZeroes(totalAbsorbs - totalHealAbsorbs) -end, "Health", "-40k") +if CUF.vars.isRetail then + W:AddTag("abs", "UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + return FormatNumberNoZeroes(UnitGetTotalAbsorbs(unit)) + end, "Health", "25000") + W:AddTag("abs:short", "UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + return FormatNumberShortNoZeroes(UnitGetTotalAbsorbs(unit)) + end, "Health", "25K") + W:AddTag("perabs", "UNIT_ABSORB_AMOUNT_CHANGED UNIT_MAXHEALTH", function(unit) + local maxhp = UnitHealthMax(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return FormatPercentNoZeroes(maxhp, totalAbsorbs) + end, "Health", "50.20%") + W:AddTag("perabs:short", "UNIT_ABSORB_AMOUNT_CHANGED UNIT_MAXHEALTH", function(unit) + local maxhp = UnitHealthMax(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return FormatPercentShortNoZeroes(maxhp, totalAbsorbs) + end, "Health", "50%") + + -- MARK: Combine + W:AddTag("curhp:abs", "UNIT_HEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local curhp = UnitHealth(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return CombineFormats(FormatNumber(curhp), FormatNumberNoZeroes(totalAbsorbs)) + end, "Health", "35000 + 5000") + W:AddTag("curhp:abs:short", "UNIT_HEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local curhp = UnitHealth(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return CombineFormats(FormatNumberShort(curhp), FormatNumberShortNoZeroes(totalAbsorbs)) + end, "Health", "35K + 5K") + W:AddTag("perhp:perabs", "UNIT_HEALTH UNIT_MAXHEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local curhp = UnitHealth(unit) + local maxhp = UnitHealthMax(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return CombineFormats(FormatPercent(maxhp, curhp), FormatPercentNoZeroes(maxhp, totalAbsorbs)) + end, "Health", "75.20% + 15%") + W:AddTag("perhp:perabs:short", "UNIT_HEALTH UNIT_MAXHEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local curhp = UnitHealth(unit) + local maxhp = UnitHealthMax(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return CombineFormats(FormatPercentShort(maxhp, curhp), FormatPercentShortNoZeroes(maxhp, totalAbsorbs)) + end, "Health", "75% + 15%") + + -- MARK: Merge + W:AddTag("curhp:abs:merge", "UNIT_HEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local curhp = UnitHealth(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return FormatNumber(curhp + totalAbsorbs) + end, "Health", "40000") + W:AddTag("curhp:abs:merge:short", "UNIT_HEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local curhp = UnitHealth(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return FormatNumberShort(curhp + totalAbsorbs) + end, "Health", "40K") + W:AddTag("perhp:perabs:merge", "UNIT_HEALTH UNIT_MAXHEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local curhp = UnitHealth(unit) + local maxhp = UnitHealthMax(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return FormatPercent(maxhp, (curhp + totalAbsorbs)) + end, "Health", "90.20%") + W:AddTag("perhp:perabs:merge:short", "UNIT_HEALTH UNIT_MAXHEALTH UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local curhp = UnitHealth(unit) + local maxhp = UnitHealthMax(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return FormatPercentShort(maxhp, (curhp + totalAbsorbs)) + end, "Health", "90%") + W:AddTag("abs:healabs:merge", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local totalHealAbsorbs = UnitGetTotalHealAbsorbs(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return FormatNumberNoZeroes(totalAbsorbs - totalHealAbsorbs) + end, "Health", "40000") + W:AddTag("abs:healabs:merge:short", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED UNIT_ABSORB_AMOUNT_CHANGED", function(unit) + local totalHealAbsorbs = UnitGetTotalHealAbsorbs(unit) + local totalAbsorbs = UnitGetTotalAbsorbs(unit) + return FormatNumberShortNoZeroes(totalAbsorbs - totalHealAbsorbs) + end, "Health", "-40k") -- MARK: Heal Absorbs -W:AddTag("healabs", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED", function(unit) - return FormatNumberNoZeroes(UnitGetTotalHealAbsorbs(unit)) -end, "Health", "20000") -W:AddTag("healabs:short", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED", function(unit) - return FormatNumberShortNoZeroes(UnitGetTotalHealAbsorbs(unit)) -end, "Health", "20K") -W:AddTag("perhealabs", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED UNIT_MAXHEALTH", function(unit) - local maxhp = UnitHealthMax(unit) - local totalHealAbsorbs = UnitGetTotalHealAbsorbs(unit) - return FormatPercentNoZeroes(maxhp, totalHealAbsorbs) -end, "Health", "40.20%") -W:AddTag("perhealabs:short", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED UNIT_MAXHEALTH", function(unit) - local maxhp = UnitHealthMax(unit) - local totalHealAbsorbs = UnitGetTotalHealAbsorbs(unit) - return FormatPercentShortNoZeroes(maxhp, totalHealAbsorbs) -end, "Health", "40%") + W:AddTag("healabs", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED", function(unit) + return FormatNumberNoZeroes(UnitGetTotalHealAbsorbs(unit)) + end, "Health", "20000") + W:AddTag("healabs:short", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED", function(unit) + return FormatNumberShortNoZeroes(UnitGetTotalHealAbsorbs(unit)) + end, "Health", "20K") + W:AddTag("perhealabs", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED UNIT_MAXHEALTH", function(unit) + local maxhp = UnitHealthMax(unit) + local totalHealAbsorbs = UnitGetTotalHealAbsorbs(unit) + return FormatPercentNoZeroes(maxhp, totalHealAbsorbs) + end, "Health", "40.20%") + W:AddTag("perhealabs:short", "UNIT_HEAL_ABSORB_AMOUNT_CHANGED UNIT_MAXHEALTH", function(unit) + local maxhp = UnitHealthMax(unit) + local totalHealAbsorbs = UnitGetTotalHealAbsorbs(unit) + return FormatPercentShortNoZeroes(maxhp, totalHealAbsorbs) + end, "Health", "40%") +end -- MARK: Power W:AddTag("curpp", "UNIT_POWER_FREQUENT UNIT_DISPLAYPOWER", function(unit) diff --git a/Widgets/Texts/HealthText.lua b/Widgets/Texts/HealthText.lua index a89e667..6d6472d 100644 --- a/Widgets/Texts/HealthText.lua +++ b/Widgets/Texts/HealthText.lua @@ -18,8 +18,8 @@ local L = CUF.L local UnitHealth = UnitHealth local UnitHealthMax = UnitHealthMax -local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs -local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs +local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs -- Function is still not present in classic cata, orgiginally made available in mists. +local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs -- Function is still not present in classic cata, orgiginally made available in mists. ------------------------------------------------- -- MARK: AddWidget @@ -96,16 +96,18 @@ local function Enable(self) self._owner:AddEventListener("UNIT_HEALTH", UpdateFrequent, unitLess) self._owner:AddEventListener("UNIT_MAXHEALTH", UpdateFrequent, unitLess) - if self._showingAbsorbs then - self._owner:AddEventListener("UNIT_ABSORB_AMOUNT_CHANGED", UpdateFrequent, unitLess) - else - self._owner:RemoveEventListener("UNIT_ABSORB_AMOUNT_CHANGED", UpdateFrequent) - end + if CUF.vars.isRetail then + if self._showingAbsorbs then + self._owner:AddEventListener("UNIT_ABSORB_AMOUNT_CHANGED", UpdateFrequent, unitLess) + else + self._owner:RemoveEventListener("UNIT_ABSORB_AMOUNT_CHANGED", UpdateFrequent) + end - if self._showingHealAbsorbs then - self._owner:AddEventListener("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", UpdateFrequent, unitLess) - else - self._owner:RemoveEventListener("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", UpdateFrequent) + if self._showingHealAbsorbs then + self._owner:AddEventListener("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", UpdateFrequent, unitLess) + else + self._owner:RemoveEventListener("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", UpdateFrequent) + end end -- Full update @@ -119,8 +121,10 @@ end local function Disable(self) self._owner:RemoveEventListener("UNIT_HEALTH", UpdateFrequent) self._owner:RemoveEventListener("UNIT_MAXHEALTH", UpdateFrequent) - self._owner:RemoveEventListener("UNIT_ABSORB_AMOUNT_CHANGED", UpdateFrequent) - self._owner:RemoveEventListener("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", UpdateFrequent) + if CUF.vars.isRetail then + self._owner:RemoveEventListener("UNIT_ABSORB_AMOUNT_CHANGED", UpdateFrequent) + self._owner:RemoveEventListener("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", UpdateFrequent) + end end ------------------------------------------------- @@ -137,6 +141,11 @@ end local function GetHealthInfo(unit, absorbs, healAbsorbs) local health = UnitHealth(unit) or 0 local healthMax = UnitHealthMax(unit) or 0 + + if not CUF.vars.isRetail then + return health, healthMax, 0, 0 + end + local totalAbsorbs = absorbs and UnitGetTotalAbsorbs(unit) or 0 local healAborbs = healAbsorbs and UnitGetTotalHealAbsorbs(unit) or 0 return health, healthMax, totalAbsorbs, healAborbs @@ -282,18 +291,20 @@ end local function SetHealth_Custom(self) local formatFn, events = W.GetTagFunction(self.textFormat, "Health") - local hasAbsorb, hasHealAbsorb = false, false - for event, _ in pairs(events) do - if event == "UNIT_ABSORB_AMOUNT_CHANGED" then - hasAbsorb = true - elseif event == "UNIT_HEAL_ABSORB_AMOUNT_CHANGED" then - hasHealAbsorb = true + if CUF.vars.isRetail then + local hasAbsorb, hasHealAbsorb = false, false + for event, _ in pairs(events) do + if event == "UNIT_ABSORB_AMOUNT_CHANGED" then + hasAbsorb = true + elseif event == "UNIT_HEAL_ABSORB_AMOUNT_CHANGED" then + hasHealAbsorb = true + end end + + self._showingAbsorbs = hasAbsorb + self._showingHealAbsorbs = hasHealAbsorb end - self._showingAbsorbs = hasAbsorb - self._showingHealAbsorbs = hasHealAbsorb - self.SetValue = function() self:SetText(formatFn(nil, self._owner.states.unit)) end @@ -310,12 +321,6 @@ local function HealthText_SetFormat(self, format) if format == const.HealthTextFormat.PERCENTAGE then self._showingAbsorbs = false self.SetValue = SetHealth_Percentage - elseif format == const.HealthTextFormat.PERCENTAGE_ABSORBS then - self._showingAbsorbs = true - self.SetValue = SetHealth_Percentage_Absorbs - elseif format == const.HealthTextFormat.PERCENTAGE_ABSORBS_MERGED then - self._showingAbsorbs = true - self.SetValue = SetHealth_Percentage_Absorbs_Merged elseif format == const.HealthTextFormat.PERCENTAGE_DEFICIT then self._showingAbsorbs = false self.SetValue = SetHealth_Percentage_Deficit @@ -325,12 +330,6 @@ local function HealthText_SetFormat(self, format) elseif format == const.HealthTextFormat.NUMBER_SHORT then self._showingAbsorbs = false self.SetValue = SetHealth_Number_Short - elseif format == const.HealthTextFormat.NUMBER_ABSORBS_SHORT then - self._showingAbsorbs = true - self.SetValue = SetHealth_Number_Absorbs_Short - elseif format == const.HealthTextFormat.NUMBER_ABSORBS_MERGED_SHORT then - self._showingAbsorbs = true - self.SetValue = SetHealth_Number_Absorbs_Merged_Short elseif format == const.HealthTextFormat.NUMBER_DEFICIT then self._showingAbsorbs = false self.SetValue = SetHealth_Number_Deficit @@ -340,19 +339,37 @@ local function HealthText_SetFormat(self, format) elseif format == const.HealthTextFormat.CURRENT_SHORT_PERCENTAGE then self._showingAbsorbs = false self.SetValue = SetHealth_Current_Short_Percentage - elseif format == const.HealthTextFormat.ABSORBS_ONLY then - self._showingAbsorbs = true - self.SetValue = SetHealth_Absorbs_Only - elseif format == const.HealthTextFormat.ABSORBS_ONLY_SHORT then - self._showingAbsorbs = true - self.SetValue = SetHealth_Absorbs_Only_Short - elseif format == const.HealthTextFormat.ABSORBS_ONLY_PERCENTAGE then - self._showingAbsorbs = true - self.SetValue = SetHealth_Absorbs_Only_Percentage elseif format == const.HealthTextFormat.CUSTOM then self:SetHealth_Custom() end + if CUF.vars.isRetail then + if format == const.HealthTextFormat.PERCENTAGE_ABSORBS then + self._showingAbsorbs = true + self.SetValue = SetHealth_Percentage_Absorbs + elseif format == const.HealthTextFormat.PERCENTAGE_ABSORBS_MERGED then + self._showingAbsorbs = true + self.SetValue = SetHealth_Percentage_Absorbs_Merged + elseif format == const.HealthTextFormat.NUMBER_ABSORBS_SHORT then + self._showingAbsorbs = true + self.SetValue = SetHealth_Number_Absorbs_Short + elseif format == const.HealthTextFormat.NUMBER_ABSORBS_MERGED_SHORT then + self._showingAbsorbs = true + self.SetValue = SetHealth_Number_Absorbs_Merged_Short + elseif format == const.HealthTextFormat.ABSORBS_ONLY then + self._showingAbsorbs = true + self.SetValue = SetHealth_Absorbs_Only + elseif format == const.HealthTextFormat.ABSORBS_ONLY_SHORT then + self._showingAbsorbs = true + self.SetValue = SetHealth_Absorbs_Only_Short + elseif format == const.HealthTextFormat.ABSORBS_ONLY_PERCENTAGE then + self._showingAbsorbs = true + self.SetValue = SetHealth_Absorbs_Only_Percentage + end + else + self._showingAbsorbs = false + end + if not self.enabled then return end self:Enable() end