diff --git a/libs/DF/LibDFramework-1.0.toc b/libs/DF/LibDFramework-1.0.toc index 5f5426ab..a1ab4868 100644 --- a/libs/DF/LibDFramework-1.0.toc +++ b/libs/DF/LibDFramework-1.0.toc @@ -1,4 +1,4 @@ -## Interface: 90001 +## Interface: 90002 ## Title: Lib: LibDFramework-1.0 ## Notes: Base Framework for many Addons diff --git a/libs/DF/fw.lua b/libs/DF/fw.lua index 7516dab3..acc4593a 100644 --- a/libs/DF/fw.lua +++ b/libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 218 +local dversion = 220 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary (major, minor) @@ -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 @@ -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) diff --git a/libs/DF/normal_bar.lua b/libs/DF/normal_bar.lua index ee77536a..f37735dd 100644 --- a/libs/DF/normal_bar.lua +++ b/libs/DF/normal_bar.lua @@ -534,14 +534,14 @@ 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 @@ -549,14 +549,14 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]] 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 @@ -565,14 +565,14 @@ 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() @@ -580,7 +580,7 @@ local BarMetaFunctions = _G[DF.GlobalWidgetControlNames ["normal_bar"]] self.timer = false end - function BarMetaFunctions:CancelTimerBar (no_timer_end) + function BarMetaFunctions:CancelTimerBar(no_timer_end) if (not self.HasTimer) then return end @@ -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 @@ -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 @@ -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() @@ -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() @@ -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) diff --git a/libs/DF/panel.lua b/libs/DF/panel.lua index 604c5dad..65713aaa 100644 --- a/libs/DF/panel.lua +++ b/libs/DF/panel.lua @@ -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) diff --git a/libs/DF/slider.lua b/libs/DF/slider.lua index a2e25fde..c87ad1a7 100644 --- a/libs/DF/slider.lua +++ b/libs/DF/slider.lua @@ -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)