diff --git a/Libs/DF/definitions.lua b/Libs/DF/definitions.lua index 597f15287..567e73d84 100644 --- a/Libs/DF/definitions.lua +++ b/Libs/DF/definitions.lua @@ -14,3 +14,4 @@ ---@field Mixin fun(self:table, target:table, ...) : table ---@field SetButtonTexture fun(self:table, button:button|df_button, texture:atlasname|texturepath|textureid) ---@field CreateFadeAnimation fun(self:table, UIObject:uiobject, fadeInTime:number?, fadeOutTime:number?, fadeInAlpha:number?, fadeOutAlpha:number?) +---@field UnitGroupRolesAssigned fun(self:table, unitId: unit, specId: specializationid) : string diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 37ef328d8..212c5f8b7 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 456 +local dversion = 457 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary(major, minor) @@ -233,14 +233,22 @@ end ---return the role of the unit, this is safe to use for all versions of wow ---@param unitId string +---@param specId number ---@return string -function DF.UnitGroupRolesAssigned(unitId) +function DF.UnitGroupRolesAssigned(unitId, specId) if (not DF.IsTimewalkWoW()) then --Was function exist check. TBC has function, returns NONE. -Flamanis 5/16/2022 local role = UnitGroupRolesAssigned(unitId) + if (specId == 1473) then + return "SUPPORT" + end + if (role == "NONE" and UnitIsUnit(unitId, "player")) then local specializationIndex = GetSpecialization() or 0 local id, name, description, icon, role, primaryStat = GetSpecializationInfo(specializationIndex) + if (id == 1473) then + return "SUPPORT" + end return id and role or "NONE" end diff --git a/Libs/DF/mixins.lua b/Libs/DF/mixins.lua index 75ad673e3..a34d37fc4 100644 --- a/Libs/DF/mixins.lua +++ b/Libs/DF/mixins.lua @@ -351,7 +351,13 @@ detailsFramework.PayloadMixin = { ---mixin to use with DetailsFramework:Mixin(table, detailsFramework.ScriptHookMixin) --- ----@class DetailsFramework.ScriptHookMixin +---@class df_scripthookmixin +---@field HookList table +---@field SetHook fun(self: table, hookType: string, func: function) +---@field HasHook fun(self: table, hookType: string, func: function) +---@field RunHooksForWidget fun(self: table, event: string, ...) +---@field ClearHooks fun(self: table) + detailsFramework.ScriptHookMixin = { RunHooksForWidget = function(self, event, ...) local hooks = self.HookList[event] @@ -991,6 +997,29 @@ detailsFramework.ValueMixin = { statusBar: --]=] +---@class df_statusbarmixin : table +---@field SetTexture fun(self: table, texture: string, isTemporary: boolean) +---@field ResetTexture fun(self: table) +---@field GetTexture fun(self: table) : string +---@field SetAtlas fun(self: table, atlasName: string) +---@field GetAtlas fun(self: table) : string +---@field SetTexCoord fun(self: table, ...) +---@field GetTexCoord fun(self: table) : number, number, number, number +---@field SetColor fun(self: table, ...) +---@field GetColor fun(self: table) : number, number, number, number +---@field SetMaskTexture fun(self: table, texture: string) +---@field GetMaskTexture fun(self: table) : string +---@field SetMaskTexCoord fun(self: table, ...) +---@field GetMaskTexCoord fun(self: table) : number, number, number, number +---@field SetMaskAtlas fun(self: table, atlasName: string) +---@field GetMaskAtlas fun(self: table) : string +---@field AddMaskTexture fun(self: table, texture: string) +---@field SetBorderTexture fun(self: table, texture: string) +---@field GetBorderTexture fun(self: table) : string +---@field SetBorderColor fun(self: table, ...) +---@field GetBorderColor fun(self: table) : number, number, number, number + + detailsFramework.StatusBarFunctions = { SetTexture = function(self, texture, isTemporary) self.barTexture:SetTexture(texture) @@ -1046,20 +1075,6 @@ detailsFramework.StatusBarFunctions = { self.barTextureMask:GetTexture() end, - --SetMaskTexCoord = function(self, ...) --MaskTexture doesn't not support texcoord - -- if (not self:HasTextureMask()) then - -- return - -- end - -- self.barTextureMask:SetTexCoord(...) - --end, - - --GetMaskTexCoord = function(self, ...) - -- if (not self:HasTextureMask()) then - -- return - -- end - -- self.barTextureMask:GetTexCoord() - --end, - SetMaskAtlas = function(self, atlasName) if (not self:HasTextureMask()) then return diff --git a/Libs/DF/unitframe.lua b/Libs/DF/unitframe.lua index a6262c195..888acf4b7 100644 --- a/Libs/DF/unitframe.lua +++ b/Libs/DF/unitframe.lua @@ -28,6 +28,8 @@ local GetUnitPowerBarInfoByID = GetUnitPowerBarInfoByID local IsInGroup = IsInGroup local UnitPowerType = UnitPowerType local UnitIsConnected = UnitIsConnected +local UnitPlayerControlled = UnitPlayerControlled +local UnitIsTapDenied = UnitIsTapDenied local max = math.max local min = math.min local abs = math.abs @@ -59,6 +61,38 @@ local cleanfunction = function() end healthBar:SetTexture(texture) --]=] +---@class df_healthbarsettings : table +---@field CanTick boolean +---@field ShowHealingPrediction boolean +---@field ShowShields boolean +---@field BackgroundColor table +---@field Texture texturepath|textureid|atlasname +---@field ShieldIndicatorTexture texturepath|textureid|atlasname +---@field ShieldGlowTexture texturepath|textureid|atlasname +---@field ShieldGlowWidth number +---@field Width number +---@field Height number + +---@class df_healthbar : statusbar, df_scripthookmixin, df_statusbarmixin +---@field unit unit +---@field displayedUnit unit +---@field currentHealth number +---@field currentHealthMax number +---@field WidgetType string +---@field Settings df_healthbarsettings +---@field background texture +---@field incomingHealIndicator texture +---@field shieldAbsorbIndicator texture +---@field healAbsorbIndicator texture +---@field shieldAbsorbGlow texture +---@field barTexture texture +---@field SetUnit fun(self:df_healthbar, unit:unit, displayedUnit:unit) +---@field GetTexture fun(self:df_healthbar) : texture +---@field SetTexture fun(self:df_healthbar, texture:texturepath|textureid|atlasname) +---@field SetColor fun(self:df_healthbar, red:number, green:number, blue:number, alpha:number) +---@field UpdateHealPrediction fun(self:df_healthbar) +---@field UpdateHealth fun(self:df_healthbar) +---@field UpdateMaxHealth fun(self:df_healthbar) --healthBar meta prototype local healthBarMetaPrototype = { @@ -69,7 +103,7 @@ local cleanfunction = function() end --check if there's a metaPrototype already existing if (_G[detailsFramework.GlobalWidgetControlNames["healthBar"]]) then --get the already existing metaPrototype - local oldMetaPrototype = _G[detailsFramework.GlobalWidgetControlNames ["healthBar"]] + local oldMetaPrototype = _G[detailsFramework.GlobalWidgetControlNames["healthBar"]] --check if is older if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < detailsFramework.dversion) ) then --the version is older them the currently loading one @@ -132,7 +166,6 @@ local cleanfunction = function() end --setup the castbar to be used by another unit healthBarMetaFunctions.SetUnit = function(self, unit, displayedUnit) if (self.unit ~= unit or self.displayedUnit ~= displayedUnit or unit == nil) then - self.unit = unit self.displayedUnit = displayedUnit or unit @@ -181,9 +214,9 @@ local cleanfunction = function() end else --remove all registered events for _, eventTable in ipairs(self.HealthBarEvents) do - local event = eventTable [1] + local event = eventTable[1] if event then - self:UnregisterEvent (event) + self:UnregisterEvent(event) end end @@ -348,7 +381,6 @@ local cleanfunction = function() end self:UpdateHealPrediction() end - healthBarMetaFunctions.UNIT_HEAL_PREDICTION = function(self, ...) self:UpdateMaxHealth() self:UpdateHealth() @@ -368,8 +400,7 @@ local cleanfunction = function() end end -- ~healthbar -function detailsFramework:CreateHealthBar (parent, name, settingsOverride) - +function detailsFramework:CreateHealthBar(parent, name, settingsOverride) assert(name or parent:GetName(), "DetailsFramework:CreateHealthBar parameter 'name' omitted and parent has no name.") local healthBar = CreateFrame("StatusBar", name or (parent:GetName() .. "HealthBar"), parent, "BackdropTemplate") @@ -695,6 +726,37 @@ end @settingsOverride = table with keys and values to replace the defaults from the framework --]=] +---@class df_castbarsettings : table +---@field NoFadeEffects boolean if true it won't play fade effects when a cast if finished +---@field ShowTradeSkills boolean if true, it shows cast for trade skills, e.g. creating an icon with blacksmith +---@field ShowShield boolean if true, shows the shield above the spell icon for non interruptible casts +---@field CanTick boolean if true it will run its OnTick function every tick. +---@field ShowCastTime boolean if true, show the remaining time to finish the cast, lazy tick must be enabled +---@field FadeInTime number amount of time in seconds to go from zero to 100% alpha when starting to cast +---@field FadeOutTime number amount of time in seconds to go from 100% to zero alpha when the cast finishes +---@field CanLazyTick boolean if true, it'll execute the lazy tick function, it ticks in a much slower pace comparece with the regular tick +---@field LazyUpdateCooldown number amount of time to wait for the next lazy update, this updates non critical things like the cast timer +---@field ShowEmpoweredDuration boolean full hold time for empowered spells +---@field FillOnInterrupt boolean +---@field HideSparkOnInterrupt boolean +---@field Width number +---@field Height number +---@field Colors df_castcolors +---@field BackgroundColor table +---@field Texture texturepath|textureid +---@field BorderShieldWidth number +---@field BorderShieldHeight number +---@field BorderShieldCoords table +---@field BorderShieldTexture number +---@field SpellIconWidth number +---@field SpellIconHeight number +---@field ShieldIndicatorTexture texturepath|textureid +---@field ShieldGlowTexture texturepath|textureid +---@field SparkTexture texturepath|textureid +---@field SparkWidth number +---@field SparkHeight number +---@field SparkOffset number + detailsFramework.CastFrameFunctions = { WidgetType = "castBar", @@ -807,7 +869,7 @@ detailsFramework.CastFrameFunctions = { SetDefaultColor = function(self, colorType, r, g, b, a) assert(type(colorType) == "string", "DetailsFramework: CastBar:SetDefaultColor require a string in the first argument.") - self.Colors [colorType]:SetColor (r, g, b, a) + self.Colors[colorType]:SetColor(r, g, b, a) end, --this get a color suggestion based on the type of cast being shown in the cast bar @@ -835,7 +897,7 @@ detailsFramework.CastFrameFunctions = { --update all colors of the cast bar UpdateCastColor = function(self) local castColor = self:GetCastColor() - self:SetColor (castColor) --SetColor handles with ParseColors() + self:SetColor(castColor) --SetColor handles with ParseColors() end, --initial checks to know if this is a valid cast and should show the cast bar, if this fails the cast bar won't show @@ -869,7 +931,6 @@ detailsFramework.CastFrameFunctions = { --this check if the cast did reach 100% in the statusbar, mostly called from OnTick CheckCastIsDone = function(self, event, isFinished) - --check max value if (not isFinished and not self.finished) then if (self.casting) then @@ -894,10 +955,10 @@ detailsFramework.CastFrameFunctions = { --the cast is finished if (isFinished) then if (self.casting) then - self.UNIT_SPELLCAST_STOP (self, self.unit, self.unit, self.castID, self.spellID) + self.UNIT_SPELLCAST_STOP(self, self.unit, self.unit, self.castID, self.spellID) elseif (self.channeling) then - self.UNIT_SPELLCAST_CHANNEL_STOP (self, self.unit, self.unit, self.castID, self.spellID) + self.UNIT_SPELLCAST_CHANNEL_STOP(self, self.unit, self.unit, self.castID, self.spellID) end return true @@ -918,12 +979,12 @@ detailsFramework.CastFrameFunctions = { --register events if (unit) then for _, eventTable in ipairs(self.CastBarEvents) do - local event = eventTable [1] - local isUnitEvent = eventTable [2] + local event = eventTable[1] + local isUnitEvent = eventTable[2] if event then if (isUnitEvent) then - self:RegisterUnitEvent (event, unit) + self:RegisterUnitEvent(event, unit) else self:RegisterEvent(event) end @@ -950,13 +1011,13 @@ detailsFramework.CastFrameFunctions = { self:CancelScheduleToHide() --self:PLAYER_ENTERING_WORLD (unit, unit) - self:OnEvent ("PLAYER_ENTERING_WORLD", unit, unit) + self:OnEvent("PLAYER_ENTERING_WORLD", unit, unit) else for _, eventTable in ipairs(self.CastBarEvents) do - local event = eventTable [1] + local event = eventTable[1] if event then - self:UnregisterEvent (event) + self:UnregisterEvent(event) end end @@ -1029,7 +1090,7 @@ detailsFramework.CastFrameFunctions = { if (self.unit) then if (self.casting) then - local name, text, texture, startTime = CastInfo.UnitCastingInfo (self.unit) + local name, text, texture, startTime = CastInfo.UnitCastingInfo(self.unit) if (name) then --[[if not self.spellStartTime then self:UpdateCastingInfo(self.unit) @@ -1040,7 +1101,7 @@ detailsFramework.CastFrameFunctions = { self:RunHooksForWidget("OnShow", self, self.unit) elseif (self.channeling) then - local name, text, texture, endTime = CastInfo.UnitChannelInfo (self.unit) + local name, text, texture, endTime = CastInfo.UnitChannelInfo(self.unit) if (name) then --[[if not self.spellEndTime then self:UpdateChannelInfo(self.unit) @@ -1141,7 +1202,7 @@ detailsFramework.CastFrameFunctions = { OnTick = function(self, deltaTime) if (self.casting) then - if (not self:OnTick_Casting (deltaTime)) then + if (not self:OnTick_Casting(deltaTime)) then return end @@ -1153,7 +1214,7 @@ detailsFramework.CastFrameFunctions = { end elseif (self.channeling) then - if (not self:OnTick_Channeling (deltaTime)) then + if (not self:OnTick_Channeling(deltaTime)) then return end @@ -1192,7 +1253,7 @@ detailsFramework.CastFrameFunctions = { --animation calls Animation_FadeOut = function(self) - self:ScheduleToHide (false) + self:ScheduleToHide(false) if (self.fadeInAnimation:IsPlaying()) then self.fadeInAnimation:Stop() @@ -1236,8 +1297,8 @@ detailsFramework.CastFrameFunctions = { end, PLAYER_ENTERING_WORLD = function(self, unit, arg1) - local isChannel = CastInfo.UnitChannelInfo (unit) - local isRegularCast = CastInfo.UnitCastingInfo (unit) + local isChannel = CastInfo.UnitChannelInfo(unit) + local isRegularCast = CastInfo.UnitCastingInfo(unit) if (isChannel) then self.channeling = true @@ -1261,10 +1322,10 @@ detailsFramework.CastFrameFunctions = { end, UpdateCastingInfo = function(self, unit) - local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = CastInfo.UnitCastingInfo (unit) + local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = CastInfo.UnitCastingInfo(unit) --is valid? - if (not self:IsValid (unit, name, isTradeSkill, true)) then + if (not self:IsValid(unit, name, isTradeSkill, true)) then return end @@ -1320,13 +1381,10 @@ detailsFramework.CastFrameFunctions = { --update the interrupt cast border self:UpdateInterruptState() - end, UNIT_SPELLCAST_START = function(self, unit) - self:UpdateCastingInfo(unit) - self:RunHooksForWidget("OnCastStart", self, self.unit, "UNIT_SPELLCAST_START") end, @@ -1352,8 +1410,7 @@ detailsFramework.CastFrameFunctions = { local curDuration = curEndTime - curStartTime local offset = width * curEndTime / (endTime - startTime) * 1000 if curDuration > -1 then - - stagePip = self.stagePips[i] + local stagePip = self.stagePips[i] if not stagePip then stagePip = self:CreateTexture(nil, "overlay", nil, 2) stagePip:SetBlendMode("ADD") @@ -1396,7 +1453,6 @@ detailsFramework.CastFrameFunctions = { self.empowered = true self.numStages = numStages - local lastStageEndTime = 0 for i = 1, numStages do self.empStages[i] = { @@ -1473,9 +1529,7 @@ detailsFramework.CastFrameFunctions = { end, UNIT_SPELLCAST_CHANNEL_START = function(self, unit, ...) - self:UpdateChannelInfo(unit, ...) - self:RunHooksForWidget("OnCastStart", self, self.unit, "UNIT_SPELLCAST_CHANNEL_START") end, @@ -1613,12 +1667,12 @@ detailsFramework.CastFrameFunctions = { end local castColor = self:GetCastColor() - self:SetColor (castColor) --SetColor handles with ParseColors() + self:SetColor(castColor) --SetColor handles with ParseColors() self.percentText:Hide() self.Text:SetText(INTERRUPTED) --auto locale within the global namespace - self:ScheduleToHide (1) + self:ScheduleToHide(1) end end, @@ -1640,7 +1694,7 @@ detailsFramework.CastFrameFunctions = { UNIT_SPELLCAST_CHANNEL_UPDATE = function(self, unit, ...) local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = CastInfo.UnitChannelInfo (unit) - if (not self:IsValid (unit, name, isTradeSkill)) then + if (not self:IsValid(unit, name, isTradeSkill)) then return end @@ -1671,11 +1725,68 @@ detailsFramework.CastFrameFunctions = { self:UpdateCastColor() self:UpdateInterruptState() end, - } detailsFramework:Mixin(detailsFramework.CastFrameFunctions, detailsFramework.ScriptHookMixin) +---@alias caststage_color +---| "Casting" +---| "Channeling" +---| "Interrupted" +---| "Failed" +---| "NotInterruptable" +---| "Finished" + +---@class df_castcolors : table +---@field Casting table +---@field Channeling table +---@field Interrupted table +---@field Failed table +---@field NotInterruptable table +---@field Finished table + +---@class df_castbar : statusbar, df_scripthookmixin, df_statusbarmixin, df_castbarsettings +---@field unit string +---@field displayedUnit string +---@field WidgetType string +---@field value number +---@field maxValue number +---@field spellStartTime number +---@field spellEndTime number +---@field empowered boolean +---@field curStage number +---@field numStages number +---@field empStages {start:number, finish:number}[] +---@field stagePips texture[] +---@field holdAtMaxTime number +---@field casting boolean +---@field channeling boolean +---@field interrupted boolean +---@field failed boolean +---@field finished boolean +---@field canInterrupt boolean +---@field spellID spellid +---@field castID number +---@field spellName spellname +---@field spellTexture textureid +---@field Colors df_castcolors +---@field background texture +---@field extraBackground texture +---@field Text fontstring +---@field BorderShield texture +---@field Icon texture +---@field Spark texture +---@field percentText fontstring +---@field barTexture texture +---@field flashTexture texture +---@field fadeOutAnimation animationgroup +---@field fadeInAnimation animationgroup +---@field flashAnimation animationgroup +---@field SetUnit fun(self:df_castbar, unit:string) +---@field SetDefaultColor fun(self:df_castbar, colorType: caststage_color, red:any, green:number?, blue:number?, alpha:number?) +---@field UpdateCastColor fun(self:df_castbar) after setting a new color, call this function to update the bar color (while casting or channeling) +---@field GetCastColor fun(self:df_castbar) return a table with the color values for the current state of the casting process + -- ~castbar function detailsFramework:CreateCastBar(parent, name, settingsOverride) @@ -1716,11 +1827,11 @@ function detailsFramework:CreateCastBar(parent, name, settingsOverride) castBar:SetStatusBarTexture(castBar.barTexture) --animations fade in and out - local fadeOutAnimationHub = detailsFramework:CreateAnimationHub (castBar, detailsFramework.CastFrameFunctions.Animation_FadeOutStarted, detailsFramework.CastFrameFunctions.Animation_FadeOutFinished) + local fadeOutAnimationHub = detailsFramework:CreateAnimationHub(castBar, detailsFramework.CastFrameFunctions.Animation_FadeOutStarted, detailsFramework.CastFrameFunctions.Animation_FadeOutFinished) fadeOutAnimationHub.alpha1 = detailsFramework:CreateAnimation(fadeOutAnimationHub, "ALPHA", 1, 1, 1, 0) castBar.fadeOutAnimation = fadeOutAnimationHub - local fadeInAnimationHub = detailsFramework:CreateAnimationHub (castBar, detailsFramework.CastFrameFunctions.Animation_FadeInStarted, detailsFramework.CastFrameFunctions.Animation_FadeInFinished) + local fadeInAnimationHub = detailsFramework:CreateAnimationHub(castBar, detailsFramework.CastFrameFunctions.Animation_FadeInStarted, detailsFramework.CastFrameFunctions.Animation_FadeInFinished) fadeInAnimationHub.alpha1 = detailsFramework:CreateAnimation(fadeInAnimationHub, "ALPHA", 1, 0.150, 0, 1) castBar.fadeInAnimation = fadeInAnimationHub @@ -1733,7 +1844,7 @@ function detailsFramework:CreateCastBar(parent, name, settingsOverride) flashTexture:SetBlendMode("ADD") castBar.flashTexture = flashTexture - local flashAnimationHub = detailsFramework:CreateAnimationHub (flashTexture, function() flashTexture:Show() end, function() flashTexture:Hide() end) + local flashAnimationHub = detailsFramework:CreateAnimationHub(flashTexture, function() flashTexture:Show() end, function() flashTexture:Hide() end) detailsFramework:CreateAnimation(flashAnimationHub, "ALPHA", 1, 0.2, 0, 0.8) detailsFramework:CreateAnimation(flashAnimationHub, "ALPHA", 2, 0.2, 1, 0) castBar.flashAnimation = flashAnimationHub @@ -1781,6 +1892,7 @@ end --]=] + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --unit frame @@ -1789,6 +1901,32 @@ end return unit and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit) end + ---@class df_unitframesettings : table + ---@field ClearUnitOnHide boolean + ---@field ShowCastBar boolean + ---@field ShowPowerBar boolean + ---@field ShowUnitName boolean + ---@field ShowBorder boolean + ---@field CanModifyHealhBarColor boolean + ---@field ColorByAggro boolean + ---@field FixedHealthColor boolean + ---@field UseFriendlyClassColor boolean + ---@field UseEnemyClassColor boolean + ---@field ShowTargetOverlay boolean + ---@field BorderColor table + ---@field CanTick boolean + ---@field Width number + ---@field Height number + ---@field PowerBarHeight number + ---@field CastBarHeight number + + ---@class df_unitframemixin + ---@field WidgetType string + ---@field Settings df_unitframesettings + ---@field SetHealthBarColor fun(self:df_unitframe, r:number, g:number?, b:number?, a:number?) + ---@field SetUnit fun(self:df_unitframe, unit:string) sets the unit to be shown in the unit frame + ---@field OnTick fun(self:df_unitframe, deltaTime:number?) if CanTick is true, this function will be called every frame + detailsFramework.UnitFrameFunctions = { WidgetType = "unitFrame", @@ -1846,9 +1984,9 @@ end }, Initialize = function(self) - self.border:SetBorderColor (self.Settings.BorderColor) + self.border:SetBorderColor(self.Settings.BorderColor) - PixelUtil.SetWidth (self, self.Settings.Width, 1) + PixelUtil.SetWidth(self, self.Settings.Width, 1) PixelUtil.SetHeight(self, self.Settings.Height, 1) PixelUtil.SetPoint(self.powerBar, "bottomleft", self, "bottomleft", 0, 0, 1, 1) @@ -1862,7 +2000,7 @@ end end, SetHealthBarColor = function(self, r, g, b, a) - self.healthBar:SetColor (r, g, b, a) + self.healthBar:SetColor(r, g, b, a) end, --register all events which will be used by the unit frame @@ -1895,7 +2033,7 @@ end UnregisterEvents = function(self) for index, eventTable in ipairs(self.UnitFrameEvents) do local event, firstUnit, secondUnit = unpack(eventTable) - self:UnregisterEvent (event) + self:UnregisterEvent(event) end self:SetScript("OnEvent", nil) @@ -1909,17 +2047,17 @@ end --when an event happen for this unit, send it to the apropriate function OnEvent = function(self, event, ...) --run the function for this event - local eventFunc = self [event] + local eventFunc = self[event] if (eventFunc) then --is this event an unit event? - if (self.IsUnitEvent [event]) then + if (self.IsUnitEvent[event]) then local unit = ... --check if is for this unit (even if the event is registered only for the unit) if (unit == self.unit or unit == self.displayedUnit) then - eventFunc (self, ...) + eventFunc(self, ...) end else - eventFunc (self, ...) + eventFunc(self, ...) end end end, @@ -2033,7 +2171,7 @@ end r, g, b = detailsFramework:ParseColors(r) end - self:SetHealthBarColor (r, g, b) + self:SetHealthBarColor(r, g, b) return end @@ -2041,15 +2179,15 @@ end if (self.Settings.FixedHealthColor) then local FixedHealthColor = self.Settings.FixedHealthColor r, g, b = FixedHealthColor.r, FixedHealthColor.g, FixedHealthColor.b - self:SetHealthBarColor (r, g, b) + self:SetHealthBarColor(r, g, b) return end --check if the unit is a player - if (UnitIsPlayer (unit)) then + if (UnitIsPlayer(unit)) then --check if the unit is disconnected (in case it is a player - if (not UnitIsConnected (unit)) then - self:SetHealthBarColor (.5, .5, .5) + if (not UnitIsConnected(unit)) then + self:SetHealthBarColor(.5, .5, .5) return end @@ -2058,50 +2196,50 @@ end if (self.Settings.UseFriendlyClassColor) then local _, className = UnitClass(unit) if (className) then - local classColor = RAID_CLASS_COLORS [className] + local classColor = RAID_CLASS_COLORS[className] if (classColor) then - self:SetHealthBarColor (classColor.r, classColor.g, classColor.b) + self:SetHealthBarColor(classColor.r, classColor.g, classColor.b) return end end else - self:SetHealthBarColor (0, 1, 0) + self:SetHealthBarColor(0, 1, 0) return end else if (self.Settings.UseEnemyClassColor) then local _, className = UnitClass(unit) if (className) then - local classColor = RAID_CLASS_COLORS [className] + local classColor = RAID_CLASS_COLORS[className] if (classColor) then - self:SetHealthBarColor (classColor.r, classColor.g, classColor.b) + self:SetHealthBarColor(classColor.r, classColor.g, classColor.b) return end end else - self:SetHealthBarColor (1, 0, 0) + self:SetHealthBarColor(1, 0, 0) return end end end --is tapped? - if (isUnitTapDenied (unit)) then - self:SetHealthBarColor (.6, .6, .6) + if (isUnitTapDenied(unit)) then + self:SetHealthBarColor(.6, .6, .6) return end --is this is a npc attacking the player? if (self.Settings.ColorByAggro) then - local _, threatStatus = UnitDetailedThreatSituation ("player", unit) + local _, threatStatus = UnitDetailedThreatSituation("player", unit) if (threatStatus) then - self:SetHealthBarColor (1, 0, 0) + self:SetHealthBarColor(1, 0, 0) return end end -- get the regular color by selection - r, g, b = UnitSelectionColor (unit) + r, g, b = UnitSelectionColor(unit) self:SetHealthBarColor (r, g, b) end, @@ -2112,7 +2250,7 @@ end end --unit name without realm names by default - local name = UnitName (self.unit) + local name = UnitName(self.unit) self.unitName:SetText(name) self.unitName:Show() end, @@ -2213,6 +2351,22 @@ end end, } +---@class df_unitframe : button, df_unitframemixin +---@field unit string +---@field displayedUnit string +---@field guid guid +---@field class class +---@field name actorname +---@field unitInVehicle boolean +---@field border frame +---@field overlayFrame frame +---@field unitName fontstring +---@field healthBar df_healthbar +---@field castBar df_castbar +---@field powerBar df_powerbar +---@field targetOverlay texture +---@field Settings table + -- ~unitframe local globalBaseFrameLevel = 1 -- to be increased + used across each new plate function detailsFramework:CreateUnitFrame(parent, name, unitFrameSettingsOverride, healthBarSettingsOverride, castBarSettingsOverride, powerBarSettingsOverride)