Skip to content

Commit

Permalink
Framework Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Nov 23, 2020
1 parent 4ec2f57 commit 9f2f998
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 34 deletions.
2 changes: 1 addition & 1 deletion libs/DF/LibDFramework-1.0.toc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Interface: 90001
## Interface: 90002
## Title: Lib: LibDFramework-1.0
## Notes: Base Framework for many Addons

Expand Down
21 changes: 10 additions & 11 deletions libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 218
local dversion = 220

local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
Expand Down Expand Up @@ -3399,13 +3399,13 @@ function DF:CoreDispatch (context, func, ...)
error (errortext)
end

local okay, result1, result2, result3, result4 = pcall (func, ...)
if (not okay) then
local stack = debugstack(2)
local errortext = "D!Framework (" .. context .. ") error: " .. result1 .. "\n====================\n" .. stack .. "\n====================\n"
error (errortext)
end
local okay, result1, result2, result3, result4 = xpcall(func, geterrorhandler(), ...)

--if (not okay) then --when using pcall
--local stack = debugstack(2)
--local errortext = "D!Framework (" .. context .. ") error: " .. result1 .. "\n====================\n" .. stack .. "\n====================\n"
--error (errortext)
--end

return result1, result2, result3, result4
end
Expand Down Expand Up @@ -4204,10 +4204,9 @@ end
end
}

function DF:SetEnvironment(func, environmentHandle)
function DF:SetEnvironment(func, environmentHandle, newEnvironment)
environmentHandle = environmentHandle or DF.DefaultSecureScriptEnvironmentHandle

local newEnvironment = {}
newEnvironment = newEnvironment or {}

setmetatable(newEnvironment, environmentHandle)
_G.setfenv(func, newEnvironment)
Expand Down
36 changes: 20 additions & 16 deletions libs/DF/normal_bar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -534,29 +534,29 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
return
end
end

local OnMouseDown = function (frame, button)
local capsule = frame.MyObject
local kill = capsule:RunHooksForWidget ("OnMouseDown", frame, button, capsule)
if (kill) then
return
end

if (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
if (not frame.isLocked and frame:IsMovable()) then
frame.MyObject.container.isMoving = true
frame.MyObject.container:StartMoving()
end
end
end

local OnMouseUp = function (frame, button)
local capsule = frame.MyObject
local kill = capsule:RunHooksForWidget ("OnMouseUp", frame, button, capsule)
if (kill) then
return
end

if (frame.MyObject.container.isMoving) then
frame.MyObject.container:StopMovingOrSizing()
frame.MyObject.container.isMoving = false
Expand All @@ -565,22 +565,22 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]

------------------------------------------------------------------------------------------------------------
--> timer

function BarMetaFunctions:OnTimerEnd()
local capsule = self
local kill = capsule:RunHooksForWidget ("OnTimerEnd", self.widget, capsule)
if (kill) then
return
end

self.timer_texture:Hide()
self.timer_textureR:Hide()
self.div_timer:Hide()
self:Hide()
self.timer = false
end

function BarMetaFunctions:CancelTimerBar (no_timer_end)
function BarMetaFunctions:CancelTimerBar(no_timer_end)
if (not self.HasTimer) then
return
end
Expand All @@ -592,7 +592,11 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
self.statusbar:SetScript ("OnUpdate", nil)
end
end

self.righttext = ""
self.timer_texture:Hide()
self.timer_textureR:Hide()

if (not no_timer_end) then
self:OnTimerEnd()
end
Expand All @@ -601,6 +605,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
local OnUpdate = function (self, elapsed)
--> percent of elapsed
local pct = abs (self.end_timer - GetTime() - self.tempo) / self.tempo

if (self.inverse) then
self.t:SetWidth (self.total_size * pct)
else
Expand All @@ -624,7 +629,6 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
end

function BarMetaFunctions:SetTimer (tempo, end_at)

if (end_at) then
self.statusbar.tempo = end_at - tempo
self.statusbar.remaining = end_at - GetTime()
Expand All @@ -637,13 +641,13 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]

self.statusbar.total_size = self.statusbar:GetWidth()
self.statusbar.inverse = self.BarIsInverse
self (0)

self(0)

self.div_timer:Show()
self.background:Show()
self:Show()

if (self.LeftToRight) then
self.timer_texture:Hide()
self.timer_textureR:Show()
Expand All @@ -659,19 +663,19 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
self.timer_texture:SetPoint ("left", self.statusbar, "left")
self.div_timer:SetPoint ("left", self.timer_texture, "right", -16, -1)
end

if (self.BarIsInverse) then
self.statusbar.t:SetWidth (1)
else
self.statusbar.t:SetWidth (self.statusbar.total_size)
end

self.timer = true

self.HasTimer = true
self.TimerScheduled = DF:ScheduleTimer ("StartTimeBarAnimation", 0.1, self)
end

function DF:StartTimeBarAnimation (timebar)
timebar.TimerScheduled = nil
timebar.statusbar:SetScript ("OnUpdate", OnUpdate)
Expand Down
5 changes: 5 additions & 0 deletions libs/DF/panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7302,6 +7302,11 @@ DF.StatusBarFunctions = {
end

healthBarMetaFunctions.UpdateHealth = function (self)
-- update max health regardless to avoid weird wrong values on UpdateMaxHealth sometimes
-- local maxHealth = UnitHealthMax (self.displayedUnit)
-- self:SetMinMaxValues (0, maxHealth)
-- self.currentHealthMax = maxHealth

local health = UnitHealth (self.displayedUnit)
self.currentHealth = health
PixelUtil.SetStatusBarValue (self, health)
Expand Down
11 changes: 5 additions & 6 deletions libs/DF/slider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -847,23 +847,22 @@ local SwitchOnClick = function (self, button, forced_value, value)
slider._thumb:SetPoint ("right", slider.widget, "right")
end
end

if (slider.OnSwitch and not forced_value) then
local value = _rawget (slider, "value")
if (slider.return_func) then
value = slider:return_func (value)
end

--> safe call
local success, errorText = pcall (slider.OnSwitch, slider, slider.FixedValue, value)

local success, errorText = xpcall (slider.OnSwitch, geterrorhandler(), slider, slider.FixedValue, value)
if (not success) then
error ("Details! Framework: OnSwitch() " .. (button.GetName and button:GetName() or "-NONAME-") .. " error: " .. (errorText or ""))
end

--> trigger hooks
slider:RunHooksForWidget ("OnSwitch", slider, slider.FixedValue, value)
end

end

local default_switch_func = function (self, passed_value)
Expand Down

0 comments on commit 9f2f998

Please sign in to comment.