Skip to content

Commit

Permalink
Framework update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Dec 14, 2022
1 parent 6542699 commit 55f2159
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 47 deletions.
68 changes: 34 additions & 34 deletions Libs/DF/dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,60 +48,60 @@ DF:Mixin(DropDownMetaFunctions, DF.ScriptHookMixin)
------------------------------------------------------------------------------------------------------------
--members
--selected value
local gmember_value = function(object)
local gmemberValue = function(object)
return object:GetValue()
end

--tooltip
local gmember_tooltip = function(object)
local gmemberTooltip = function(object)
return object:GetTooltip()
end

--shown
local gmember_shown = function(object)
local gmemberShown = function(object)
return object:IsShown()
end

--frame width
local gmember_width = function(object)
local gmemberWidth = function(object)
return object.button:GetWidth()
end

--frame height
local gmember_height = function(object)
local gmemberHeight = function(object)
return object.button:GetHeight()
end

--current text
local gmember_text = function(object)
local gmemberText = function(object)
return object.label:GetText()
end

--menu creation function
local gmember_function = function(object)
local gmemberFunction = function(object)
return object:GetFunction()
end

--menu width
local gmember_menuwidth = function(object)
local gmemberMenuWidth = function(object)
return rawget(object, "realsizeW")
end

--menu height
local gmember_menuheight = function(object)
local gmemberMenuHeight = function(object)
return rawget(object, "realsizeH")
end

DropDownMetaFunctions.GetMembers = DropDownMetaFunctions.GetMembers or {}
DropDownMetaFunctions.GetMembers["value"] = gmember_value
DropDownMetaFunctions.GetMembers["text"] = gmember_text
DropDownMetaFunctions.GetMembers["shown"] = gmember_shown
DropDownMetaFunctions.GetMembers["width"] = gmember_width
DropDownMetaFunctions.GetMembers["menuwidth"] = gmember_menuwidth
DropDownMetaFunctions.GetMembers["height"] = gmember_height
DropDownMetaFunctions.GetMembers["menuheight"] = gmember_menuheight
DropDownMetaFunctions.GetMembers["tooltip"] = gmember_tooltip
DropDownMetaFunctions.GetMembers["func"] = gmember_function
DropDownMetaFunctions.GetMembers["value"] = gmemberValue
DropDownMetaFunctions.GetMembers["text"] = gmemberText
DropDownMetaFunctions.GetMembers["shown"] = gmemberShown
DropDownMetaFunctions.GetMembers["width"] = gmemberWidth
DropDownMetaFunctions.GetMembers["menuwidth"] = gmemberMenuWidth
DropDownMetaFunctions.GetMembers["height"] = gmemberHeight
DropDownMetaFunctions.GetMembers["menuheight"] = gmemberMenuHeight
DropDownMetaFunctions.GetMembers["tooltip"] = gmemberTooltip
DropDownMetaFunctions.GetMembers["func"] = gmemberFunction

DropDownMetaFunctions.__index = function(object, key)
local func = DropDownMetaFunctions.GetMembers[key]
Expand All @@ -120,12 +120,12 @@ DF:Mixin(DropDownMetaFunctions, DF.ScriptHookMixin)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

--tooltip
local smember_tooltip = function(object, value)
local smemberTooltip = function(object, value)
return object:SetTooltip(value)
end

--show
local smember_show = function(object, value)
local smemberShow = function(object, value)
if (value) then
return object:Show()
else
Expand All @@ -134,7 +134,7 @@ DF:Mixin(DropDownMetaFunctions, DF.ScriptHookMixin)
end

--hide
local smember_hide = function(object, value)
local smemberHide = function(object, value)
if (not value) then
return object:Show()
else
Expand All @@ -143,39 +143,39 @@ DF:Mixin(DropDownMetaFunctions, DF.ScriptHookMixin)
end

--frame width
local smember_width = function(object, value)
local smemberWidth = function(object, value)
return object.dropdown:SetWidth(value)
end

--frame height
local smember_height = function(object, value)
local smemberHeight = function(object, value)
return object.dropdown:SetHeight(value)
end

--menu creation function
local smember_function = function(object, value)
local smemberFunction = function(object, value)
return object:SetFunction(value)
end

--menu width
local smember_menuwidth = function(object, value)
local smemberMenuWidth = function(object, value)
object:SetMenuSize(value, nil)
end

--menu height
local smember_menuheight = function(object, value)
local smemberMenuHeight = function(object, value)
object:SetMenuSize(nil, value)
end

DropDownMetaFunctions.SetMembers = DropDownMetaFunctions.SetMembers or {}
DropDownMetaFunctions.SetMembers["tooltip"] = smember_tooltip
DropDownMetaFunctions.SetMembers["show"] = smember_show
DropDownMetaFunctions.SetMembers["hide"] = smember_hide
DropDownMetaFunctions.SetMembers["width"] = smember_width
DropDownMetaFunctions.SetMembers["menuwidth"] = smember_menuwidth
DropDownMetaFunctions.SetMembers["height"] = smember_height
DropDownMetaFunctions.SetMembers["menuheight"] = smember_menuheight
DropDownMetaFunctions.SetMembers["func"] = smember_function
DropDownMetaFunctions.SetMembers["tooltip"] = smemberTooltip
DropDownMetaFunctions.SetMembers["show"] = smemberShow
DropDownMetaFunctions.SetMembers["hide"] = smemberHide
DropDownMetaFunctions.SetMembers["width"] = smemberWidth
DropDownMetaFunctions.SetMembers["menuwidth"] = smemberMenuWidth
DropDownMetaFunctions.SetMembers["height"] = smemberHeight
DropDownMetaFunctions.SetMembers["menuheight"] = smemberMenuHeight
DropDownMetaFunctions.SetMembers["func"] = smemberFunction

DropDownMetaFunctions.__newindex = function(object, key, value)
local func = DropDownMetaFunctions.SetMembers[key]
Expand Down
2 changes: 1 addition & 1 deletion Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 403
local dversion = 405
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)

Expand Down
91 changes: 79 additions & 12 deletions Libs/DF/panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7966,7 +7966,7 @@ detailsFramework.CastFrameFunctions = {
--[[if not self.spellEndTime then
self:UpdateChannelInfo(self.unit)
end]]--
self.value = self.spellEndTime - GetTime()
self.value = self.empowered and (GetTime() - self.spellStartTime) or (self.spellEndTime - GetTime())
end

self:RunHooksForWidget("OnShow", self, self.unit)
Expand Down Expand Up @@ -8005,7 +8005,7 @@ detailsFramework.CastFrameFunctions = {
self.percentText:SetText(format("%.1f", abs(self.value - self.maxValue)))

elseif (self.channeling) then
local remainingTime = abs(self.value)
local remainingTime = self.empowered and abs(self.value - self.maxValue) or abs(self.value)
if (remainingTime > 999) then
self.percentText:SetText("")
else
Expand Down Expand Up @@ -8035,14 +8035,15 @@ detailsFramework.CastFrameFunctions = {
--update spark position
local sparkPosition = self.value / self.maxValue * self:GetWidth()
self.Spark:SetPoint("center", self, "left", sparkPosition + self.Settings.SparkOffset, 0)


--in order to allow the lazy tick run, it must return true, it tell that the cast didn't finished
return true
end,

--tick function for channeling casts
OnTick_Channeling = function(self, deltaTime)
self.value = self.value - deltaTime
self.value = self.empowered and self.value + deltaTime or self.value - deltaTime

if (self:CheckCastIsDone()) then
return
Expand All @@ -8053,6 +8054,8 @@ detailsFramework.CastFrameFunctions = {
--update spark position
local sparkPosition = self.value / self.maxValue * self:GetWidth()
self.Spark:SetPoint("center", self, "left", sparkPosition + self.Settings.SparkOffset, 0)

self:CreateOrUpdateEmpoweredPips()

return true
end,
Expand Down Expand Up @@ -8185,6 +8188,14 @@ detailsFramework.CastFrameFunctions = {
if (not self:IsValid (unit, name, isTradeSkill, true)) then
return
end

--empowered? no!
self.holdAtMaxTime = nil
self.empowered = false
self.curStage = nil
self.numStages = nil
self.empStages = nil
self:CreateOrUpdateEmpoweredPips()

--setup cast
self.casting = true
Expand Down Expand Up @@ -8239,6 +8250,51 @@ detailsFramework.CastFrameFunctions = {

self:RunHooksForWidget("OnCastStart", self, self.unit, "UNIT_SPELLCAST_START")
end,

CreateOrUpdateEmpoweredPips = function(self, unit, numStages, startTime, endTime)
unit = unit or self.unit
numStages = numStages or self.numStages
startTime = startTime or ((self.spellStartTime or 0) * 1000)
endTime = endTime or ((self.spellEndTime or 0) * 1000)

if not self.empStages or not numStages or numStages <= 0 then
self.stagePips = self.stagePips or {}
for i, stagePip in pairs(self.stagePips) do
stagePip:Hide()
end
return
end

local width = self:GetWidth()
local height = self:GetHeight()
for i = 1, numStages, 1 do
local curStartTime = self.empStages[i] and self.empStages[i].start
local curEndTime = self.empStages[i] and self.empStages[i].finish
local curDuration = curEndTime - curStartTime
local offset = width * curEndTime / (endTime - startTime) * 1000
if curDuration > -1 then

stagePip = self.stagePips[i]
if not stagePip then
stagePip = self:CreateTexture(nil, "overlay", nil, 2)
stagePip:SetBlendMode("ADD")
stagePip:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]])
stagePip:SetTexCoord(11/32,18/32,9/32,23/32)
stagePip:SetSize(2, height)
--stagePip = CreateFrame("FRAME", nil, self, "CastingBarFrameStagePipTemplate")
self.stagePips[i] = stagePip
end

stagePip:ClearAllPoints()
--stagePip:SetPoint("TOP", self, "TOPLEFT", offset, -1)
--stagePip:SetPoint("BOTTOM", self, "BOTTOMLEFT", offset, 1)
--stagePip.BasePip:SetVertexColor(1, 1, 1, 1)
stagePip:SetPoint("CENTER", self, "LEFT", offset, 0)
stagePip:SetVertexColor(1, 1, 1, 1)
stagePip:Show()
end
end
end,

UpdateChannelInfo = function(self, unit, ...)
local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = UnitChannelInfo (unit)
Expand All @@ -8250,15 +8306,22 @@ detailsFramework.CastFrameFunctions = {

--empowered?
self.empStages = {}
self.stagePips = self.stagePips or {}
for i, stagePip in pairs(self.stagePips) do
stagePip:Hide()
end

if numStages and numStages > 0 then
self.holdAtMaxTime = GetUnitEmpowerHoldAtMaxTime(unit)
self.holdAtMaxTime = GetUnitEmpowerHoldAtMaxTime(self.unit)
self.empowered = true
self.numStages = numStages


local lastStageEndTime = 0
for i = 1, numStages do
self.empStages[i] = {
start = lastStageEndTime,
finish = lastStageEndTime - GetUnitEmpowerStageDuration(unit, i - 1) / 1000,
finish = lastStageEndTime + GetUnitEmpowerStageDuration(unit, i - 1) / 1000,
}
lastStageEndTime = self.empStages[i].finish

Expand All @@ -8270,10 +8333,14 @@ detailsFramework.CastFrameFunctions = {
if (self.Settings.ShowEmpoweredDuration) then
endTime = endTime + self.holdAtMaxTime
end

--create/update pips
self:CreateOrUpdateEmpoweredPips(unit, numStages, startTime, endTime)
else
self.holdAtMaxTime = 0
self.holdAtMaxTime = nil
self.empowered = false
self.curStage = 0
self.curStage = nil
self.numStages = nil
end

--setup cast
Expand All @@ -8289,9 +8356,9 @@ detailsFramework.CastFrameFunctions = {
self.spellTexture = texture
self.spellStartTime = startTime / 1000
self.spellEndTime = endTime / 1000
self.value = self.spellEndTime - GetTime()
self.value = self.empowered and (GetTime() - self.spellStartTime) or (self.spellEndTime - GetTime())
self.maxValue = self.spellEndTime - self.spellStartTime
self.numStages = numStages
self.reverseChanneling = self.empowered

self:SetMinMaxValues(0, self.maxValue)
self:SetValue(self.value)
Expand Down Expand Up @@ -8494,13 +8561,13 @@ detailsFramework.CastFrameFunctions = {
--update the cast time
self.spellStartTime = startTime / 1000
self.spellEndTime = endTime / 1000
self.value = self.spellEndTime - GetTime()
self.value = self.empowered and (GetTime() - self.spellStartTime) or (self.spellEndTime - GetTime())
self.maxValue = self.spellEndTime - self.spellStartTime

if (self.value < 0) then
if (self.value < 0 or self.value >= self.maxValue) then
self.value = 0
end

self.maxValue = self.spellEndTime - self.spellStartTime
self:SetMinMaxValues(0, self.maxValue)
self:SetValue(self.value)
end,
Expand Down
2 changes: 2 additions & 0 deletions Libs/DF/spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,8 @@ DF.CrowdControlSpells = {
[183752] = "DEMONHUNTER", --Disrupt

[331866] = "COVENANT|VENTHYR", --Agent of Chaos (Nadia soulbind)

[372245] = "EVOKER", --Terror of the Skies
}

-- additionals for classic
Expand Down

0 comments on commit 55f2159

Please sign in to comment.