Disabled Bindings.xml to avoid taints in 10.0

This commit is contained in:
Tercio Jose
2022-10-20 09:47:48 -03:00
parent 33e6a45f8d
commit a9e858d864
76 changed files with 1200 additions and 1411 deletions
+444 -461
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -6,8 +6,8 @@ if (not DF or not DetailsFrameworkCanLoad) then
end
local _
local _rawset = rawset --lua local
local _rawget = rawget --lua local
local rawset = rawset --lua local
local rawget = rawget --lua local
local APIHelpFunctions = false
local HelpMetaFunctions = {}
@@ -21,7 +21,7 @@ local HelpMetaFunctions = {}
return func (_table, _member_requested)
end
local fromMe = _rawget (_table, _member_requested)
local fromMe = rawget (_table, _member_requested)
if (fromMe) then
return fromMe
end
@@ -36,7 +36,7 @@ local HelpMetaFunctions = {}
if (func) then
return func (_table, _value)
else
return _rawset (_table, _key, _value)
return rawset (_table, _key, _value)
end
end
+26 -27
View File
@@ -1,61 +1,60 @@
local DF = _G ["DetailsFramework"]
local DF = _G["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
return
return
end
local UnitExists = UnitExists
local atan2 = math.atan2
local pi = math.pi
local abs = math.abs
local abs = math.abs
SMALL_FLOAT = 0.000001
--find distance between two players
function DF:GetDistance_Unit (unit1, unit2)
function DF:GetDistance_Unit(unit1, unit2)
if (UnitExists(unit1) and UnitExists(unit2)) then
local u1X, u1Y = UnitPosition (unit1)
local u2X, u2Y = UnitPosition (unit2)
local u1X, u1Y = UnitPosition(unit1)
local u2X, u2Y = UnitPosition(unit2)
local dX = u2X - u1X
local dY = u2Y - u1Y
return ((dX*dX) + (dY*dY)) ^ .5
end
return 0
end
--find distance between two points
function DF:GetDistance_Point (x1, y1, x2, y2)
function DF:GetDistance_Point(x1, y1, x2, y2)
local dx = x2 - x1
local dy = y2 - y1
return ((dx * dx) + (dy * dy)) ^ .5
end
--find a rotation for an object from a point to another point
function DF:FindLookAtRotation (x1, y1, x2, y2)
function DF:FindLookAtRotation(x1, y1, x2, y2)
return atan2 (y2 - y1, x2 - x1) + pi
end
--find the value scale between two given values. e.g: value of 500 in a range 0-100 result in 10 in a scale for 0-10
function DF:MapRangeClamped(inputX, inputY, outputX, outputY, value)
return DF:GetRangeValue (outputX, outputY, Clamp (DF:GetRangePercent (inputX, inputY, value), 0, 1))
return DF:GetRangeValue(outputX, outputY, Clamp(DF:GetRangePercent(inputX, inputY, value), 0, 1))
end
--find the value scale between two given values. e.g: value of 75 in a range 0-100 result in 7.5 in a scale for 0-10
function DF:MapRangeUnclamped (inputX, inputY, outputX, outputY, value)
return DF:GetRangeValue (outputX, outputY, DF:GetRangePercent (inputX, inputY, value))
function DF:MapRangeUnclamped(inputX, inputY, outputX, outputY, value)
return DF:GetRangeValue(outputX, outputY, DF:GetRangePercent(inputX, inputY, value))
end
--find the normalized percent of the value in the range. e.g range of 200-400 and a value of 250 result in 0.25
function DF:GetRangePercent (minValue, maxValue, value)
function DF:GetRangePercent(minValue, maxValue, value)
return (value - minValue) / max((maxValue - minValue), SMALL_FLOAT)
end
--find the value in the range given from a normalized percent. e.g range of 200-400 and a percent of 0.8 result in 360
function DF:GetRangeValue (minValue, maxValue, percent)
return Lerp (minValue, maxValue, percent)
function DF:GetRangeValue(minValue, maxValue, percent)
return Lerp(minValue, maxValue, percent)
end
function DF:GetColorRangeValue(r1, g1, b1, r2, g2, b2, value)
@@ -66,7 +65,7 @@ function DF:GetColorRangeValue(r1, g1, b1, r2, g2, b2, value)
end
--dot product of two 2D Vectors
function DF:GetDotProduct (value1, value2)
function DF:GetDotProduct(value1, value2)
return (value1.x * value2.x) + (value1.y * value2.y)
end
@@ -77,12 +76,12 @@ function DF:GetBezierPoint(value, point1, point2, point3)
end
--normalized value 0-1 result in the value on the range given, e.g 200-400 range with a value of .5 result in 300
function DF:LerpNorm (minValue, maxValue, value)
function DF:LerpNorm(minValue, maxValue, value)
return (minValue + value * (maxValue - minValue))
end
--change the color by the deltaTime
function DF:LerpLinearColor (deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
function DF:LerpLinearColor(deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
deltaTime = deltaTime * interpSpeed
local r = r1 + (r2 - r1) * deltaTime
local g = g1 + (g2 - g1) * deltaTime
@@ -91,37 +90,37 @@ function DF:LerpLinearColor (deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
end
--check if a number is near another number by a tolerance
function DF:IsNearlyEqual (value1, value2, tolerance)
function DF:IsNearlyEqual(value1, value2, tolerance)
tolerance = tolerance or SMALL_FLOAT
return abs(value1 - value2) <= tolerance
end
--check if a number is near zero
function DF:IsNearlyZero (value, tolerance)
function DF:IsNearlyZero(value, tolerance)
tolerance = tolerance or SMALL_FLOAT
return abs(value) <= tolerance
end
--check if a number is within a two other numbers, if isInclusive is true, it'll include the max value
function DF:IsWithin (minValue, maxValue, value, isInclusive)
function DF:IsWithin(minValue, maxValue, value, isInclusive)
if (isInclusive) then
return ((value >= minValue) and (value <= maxValue))
return ((value >= minValue) and (value <= maxValue))
else
return ((value >= minValue) and (value < maxValue))
end
end
--dont allow a number ot be lower or bigger than a certain range
function DF:Clamp (minValue, maxValue, value)
function DF:Clamp(minValue, maxValue, value)
return value < minValue and minValue or value < maxValue and value or maxValue
end
--from http://lua-users.org/wiki/SimpleRound cut fractions on a float
function DF:Round (num, numDecimalPlaces)
function DF:Round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function DF:ScaleBack ()
function DF:ScaleBack()
end
+19 -24
View File
@@ -1,20 +1,15 @@
local DF = _G ["DetailsFramework"]
local DF = _G["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
return
return
end
local _
local _rawset = rawset --lua locals
local _rawget = rawget --lua locals
local _setmetatable = setmetatable --lua locals
local _unpack = unpack --lua locals
local type = type --lua locals
local _math_floor = math.floor --lua locals
local _unpack = unpack
local type = type
local _math_floor = math.floor
local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
local cleanfunction = function() end
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
local APIBarFunctions
do
@@ -26,7 +21,7 @@ do
--check if there's a metaPrototype already existing
if (_G[DF.GlobalWidgetControlNames["normal_bar"]]) then
--get the already existing metaPrototype
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames ["normal_bar"]]
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["normal_bar"]]
--check if is older
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then
--the version is older them the currently loading one
@@ -37,7 +32,7 @@ do
end
else
--first time loading the framework
_G[DF.GlobalWidgetControlNames ["normal_bar"]] = metaPrototype
_G[DF.GlobalWidgetControlNames["normal_bar"]] = metaPrototype
end
end
@@ -47,15 +42,15 @@ DF:Mixin(BarMetaFunctions, DF.ScriptHookMixin)
------------------------------------------------------------------------------------------------------------
--metatables
BarMetaFunctions.__call = function(_table, value)
BarMetaFunctions.__call = function(object, value)
if (not value) then
return _table.statusbar:GetValue()
return object.statusbar:GetValue()
else
return _table.statusbar:SetValue(value)
return object.statusbar:SetValue(value)
end
end
BarMetaFunctions.__add = function(v1, v2)
BarMetaFunctions.__add = function(v1, v2)
if (type(v1) == "table") then
local v = v1.statusbar:GetValue()
v = v + v2
@@ -67,7 +62,7 @@ DF:Mixin(BarMetaFunctions, DF.ScriptHookMixin)
end
end
BarMetaFunctions.__sub = function(v1, v2)
BarMetaFunctions.__sub = function(v1, v2)
if (type(v1) == "table") then
local v = v1.statusbar:GetValue()
v = v - v2
@@ -168,7 +163,7 @@ DF:Mixin(BarMetaFunctions, DF.ScriptHookMixin)
return func (_table, _member_requested)
end
local fromMe = _rawget (_table, _member_requested)
local fromMe = rawget (_table, _member_requested)
if (fromMe) then
return fromMe
end
@@ -350,7 +345,7 @@ DF:Mixin(BarMetaFunctions, DF.ScriptHookMixin)
if (func) then
return func (_table, _value)
else
return _rawset (_table, _key, _value)
return rawset (_table, _key, _value)
end
end
@@ -444,13 +439,13 @@ DF:Mixin(BarMetaFunctions, DF.ScriptHookMixin)
-- tooltip
function BarMetaFunctions:SetTooltip (tooltip)
if (tooltip) then
return _rawset (self, "have_tooltip", tooltip)
return rawset (self, "have_tooltip", tooltip)
else
return _rawset (self, "have_tooltip", nil)
return rawset (self, "have_tooltip", nil)
end
end
function BarMetaFunctions:GetTooltip()
return _rawget (self, "have_tooltip")
return rawget (self, "have_tooltip")
end
-- frame levels
@@ -855,7 +850,7 @@ function DF:NewBar (parent, container, name, member, w, h, value, texture_name)
BarObject.statusbar:SetScript("OnMouseUp", OnMouseUp)
--set class
_setmetatable(BarObject, BarMetaFunctions)
setmetatable(BarObject, BarMetaFunctions)
--set texture
if (texture_name) then
+18 -18
View File
@@ -298,10 +298,10 @@ detailsFramework.LayoutFrame = {
local smember_locked = function(_object, _value)
if (_value) then
_object.frame:SetMovable(false)
return rawset (_object, "is_locked", true)
return rawset(_object, "is_locked", true)
else
_object.frame:SetMovable(true)
rawset (_object, "is_locked", false)
rawset(_object, "is_locked", false)
return
end
end
@@ -313,7 +313,7 @@ detailsFramework.LayoutFrame = {
--close with right button
local smember_right_close = function(_object, _value)
return rawset (_object, "rightButtonClose", _value)
return rawset(_object, "rightButtonClose", _value)
end
PanelMetaFunctions.SetMembers = PanelMetaFunctions.SetMembers or {}
@@ -332,7 +332,7 @@ detailsFramework.LayoutFrame = {
if (func) then
return func (_table, _value)
else
return rawset (_table, _key, _value)
return rawset(_table, _key, _value)
end
end
@@ -451,9 +451,9 @@ detailsFramework.LayoutFrame = {
-- tooltip
function PanelMetaFunctions:SetTooltip (tooltip)
if (tooltip) then
return rawset (self, "have_tooltip", tooltip)
return rawset(self, "have_tooltip", tooltip)
else
return rawset (self, "have_tooltip", nil)
return rawset(self, "have_tooltip", nil)
end
end
function PanelMetaFunctions:GetTooltip()
@@ -5644,18 +5644,18 @@ local default_load_conditions_frame_options = {
function detailsFramework:CreateLoadFilterParser (callback)
local f = CreateFrame("frame")
f:RegisterEvent ("PLAYER_ENTERING_WORLD")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
if IS_WOW_PROJECT_MAINLINE then
f:RegisterEvent ("PLAYER_SPECIALIZATION_CHANGED")
f:RegisterEvent ("PLAYER_TALENT_UPDATE")
f:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
f:RegisterEvent("PLAYER_TALENT_UPDATE")
end
f:RegisterEvent ("PLAYER_ROLES_ASSIGNED")
f:RegisterEvent ("ZONE_CHANGED_NEW_AREA")
f:RegisterEvent("PLAYER_ROLES_ASSIGNED")
f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
if IS_WOW_PROJECT_MAINLINE then
f:RegisterEvent ("CHALLENGE_MODE_START")
f:RegisterEvent("CHALLENGE_MODE_START")
end
f:RegisterEvent ("ENCOUNTER_START")
f:RegisterEvent ("PLAYER_REGEN_ENABLED")
f:RegisterEvent("ENCOUNTER_START")
f:RegisterEvent("PLAYER_REGEN_ENABLED")
f:SetScript("OnEvent", function(self, event, ...)
if (event == "ENCOUNTER_START") then
@@ -7031,7 +7031,7 @@ detailsFramework.StatusBarFunctions = {
if (isUnitEvent) then
self:RegisterUnitEvent (event, self.displayedUnit, self.unit)
else
self:RegisterEvent (event)
self:RegisterEvent(event)
end
end
end
@@ -7362,7 +7362,7 @@ detailsFramework.PowerFrameFunctions = {
if (isUnitEvent) then
self:RegisterUnitEvent (event, self.displayedUnit)
else
self:RegisterEvent (event)
self:RegisterEvent(event)
end
end
@@ -7799,7 +7799,7 @@ detailsFramework.CastFrameFunctions = {
if (isUnitEvent) then
self:RegisterUnitEvent (event, unit)
else
self:RegisterEvent (event)
self:RegisterEvent(event)
end
end
end
@@ -8777,7 +8777,7 @@ end
for index, eventTable in ipairs(self.UnitFrameEvents) do
local event, isUnitEvent = unpack(eventTable)
if (not isUnitEvent) then
self:RegisterEvent (event)
self:RegisterEvent(event)
else
self:RegisterUnitEvent (event, self.unit, self.displayedUnit ~= unit and self.displayedUnit or nil)
end
+3 -3
View File
@@ -71,7 +71,7 @@ local CreateImageEditorFrame = function()
local topSlider = DF:NewSlider (editorWindow, nil, "$parentTopSlider", "topSlider", 100, 100, 0.1, 100, 0.1, 0)
topSlider:SetAllPoints(editorWindow.widget)
topSlider:SetOrientation ("VERTICAL")
topSlider:SetOrientation("VERTICAL")
topSlider.backdrop = nil
topSlider.fractional = true
topSlider:SetHook("OnEnter", function() return true end)
@@ -102,7 +102,7 @@ local CreateImageEditorFrame = function()
local bottomSlider = DF:NewSlider (editorWindow, nil, "$parentBottomSlider", "bottomSlider", 100, 100, 0.1, 100, 0.1, 100)
bottomSlider:SetAllPoints(editorWindow.widget)
bottomSlider:SetOrientation ("VERTICAL")
bottomSlider:SetOrientation("VERTICAL")
bottomSlider.backdrop = nil
bottomSlider.fractional = true
bottomSlider:SetHook("OnEnter", function() return true end)
@@ -311,7 +311,7 @@ local CreateImageEditorFrame = function()
alphaFrame:Hide()
local alphaSlider = DF:NewSlider (alphaFrame, nil, "$parentAlphaSlider", "alphaSlider", 30, 220, 1, 100, 1, edit_texture:GetAlpha()*100)
alphaSlider:SetPoint("top", alphaFrame, "top", 0, -5)
alphaSlider:SetOrientation ("VERTICAL")
alphaSlider:SetOrientation("VERTICAL")
alphaSlider.thumb:SetSize(40, 30)
--leftSlider.backdrop = nil
--leftSlider.fractional = true
+2 -2
View File
@@ -1,11 +1,11 @@
local DF = _G ["DetailsFramework"]
local DF = _G["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
return
end
local C_Timer = _G.C_Timer
local unpack = _G.unpack
local unpack = table.unpack or _G.unpack
--make a namespace for schedules
DF.Schedules = DF.Schedules or {}
+101 -114
View File
@@ -603,7 +603,7 @@ DF:Mixin(DFSliderMetaFunctions, DF.ScriptHookMixin)
DFSliderMetaFunctions.editbox_typevalue = editbox
end
local pvalue = self.previous_value [2]
local pvalue = self.previous_value[2]
self:SetValue(pvalue)
self.typing_value = true
@@ -628,190 +628,176 @@ DF:Mixin(DFSliderMetaFunctions, DF.ScriptHookMixin)
end
local OnMouseDown = function(slider, button)
slider.MyObject.IsValueChanging = true
local object = slider.MyObject
object.IsValueChanging = true
local capsule = slider.MyObject
local kill = capsule:RunHooksForWidget("OnMouseDown", slider, button, capsule)
local kill = object:RunHooksForWidget("OnMouseDown", slider, button, object)
if (kill) then
return
end
if (button == "RightButton") then
slider.MyObject:TypeValue()
object:TypeValue()
end
end
local OnMouseUp = function(slider, button)
slider.MyObject.IsValueChanging = nil
local object = slider.MyObject
object.IsValueChanging = nil
local capsule = slider.MyObject
local kill = capsule:RunHooksForWidget("OnMouseUp", slider, button, capsule)
local kill = object:RunHooksForWidget("OnMouseUp", slider, button, object)
if (kill) then
return
end
end
local OnHide = function(slider)
local capsule = slider.MyObject
local kill = capsule:RunHooksForWidget("OnHide", slider, capsule)
local object = slider.MyObject
local kill = object:RunHooksForWidget("OnHide", slider, object)
if (kill) then
return
end
if (slider.MyObject.typing_value) then
if (object.typing_value) then
DFSliderMetaFunctions.editbox_typevalue:ClearFocus()
DFSliderMetaFunctions.editbox_typevalue:SetText("")
slider.MyObject.typing_valu = false
object.typing_valu = false
end
end
local OnShow = function(slider)
local capsule = slider.MyObject
local kill = capsule:RunHooksForWidget("OnShow", slider, capsule)
local object = slider.MyObject
local kill = object:RunHooksForWidget("OnShow", slider, object)
if (kill) then
return
end
end
local table_insert = table.insert
local table_remove = table.remove
local OnValueChanged = function(slider)
local object = slider.MyObject
local amt
if (slider.MyObject.useDecimals) then
if (object.useDecimals) then
amt = slider:GetValue()
else
amt = do_precision(slider:GetValue())
end
if (slider.MyObject.typing_value and not slider.MyObject.typing_can_change) then
slider.MyObject:SetValue(slider.MyObject.typing_value_started)
if (object.typing_value and not object.typing_can_change) then
object:SetValue(object.typing_value_started)
return
end
table_insert (slider.MyObject.previous_value, 1, amt)
table_remove (slider.MyObject.previous_value, 4)
local capsule = slider.MyObject
table.insert(object.previous_value, 1, amt)
table.remove(object.previous_value, 4)
--some plugins registered OnValueChanged and others with OnValueChange
local kill = capsule:RunHooksForWidget("OnValueChanged", slider, capsule.FixedValue, amt, capsule)
if (kill) then
return
end
local kill = capsule:RunHooksForWidget("OnValueChange", slider, capsule.FixedValue, amt, capsule)
local kill = object:RunHooksForWidget("OnValueChanged", slider, object.FixedValue, amt, object)
if (kill) then
return
end
if (slider.MyObject.OnValueChanged) then
slider.MyObject.OnValueChanged (slider, slider.MyObject.FixedValue, amt)
local kill = object:RunHooksForWidget("OnValueChange", slider, object.FixedValue, amt, object)
if (kill) then
return
end
if (object.OnValueChanged) then
object.OnValueChanged(slider, object.FixedValue, amt)
end
if (amt < 10 and amt >= 1) then
amt = "0"..amt
amt = "0" .. amt
end
if (slider.MyObject.useDecimals) then
if (object.useDecimals) then
slider.amt:SetText(string.format("%.2f", amt))
else
slider.amt:SetText(math.floor(amt))
end
slider.MyObject.ivalue = amt
object.ivalue = amt
end
------------------------------------------------------------------------------------------------------------
--object constructor
local SwitchOnClick = function(self, button, forced_value, value)
local object = self.MyObject
local slider = self.MyObject
if (rawget(slider, "lockdown")) then
if (rawget(object, "lockdown")) then
return
end
if (forced_value) then
rawset (slider, "value", not value)
rawset(object, "value", not value)
end
if (rawget(slider, "value")) then --actived
rawset (slider, "value", false)
if (rawget(object, "value")) then --actived
rawset(object, "value", false)
if (slider.backdrop_disabledcolor) then
slider:SetBackdropColor(unpack(slider.backdrop_disabledcolor))
if (object.backdrop_disabledcolor) then
object:SetBackdropColor(unpack(object.backdrop_disabledcolor))
else
slider:SetBackdropColor(1, 0, 0, 0.4)
object:SetBackdropColor(1, 0, 0, 0.4)
end
if (slider.is_checkbox) then
slider.checked_texture:Hide()
if (object.is_checkbox) then
object.checked_texture:Hide()
else
slider._text:SetText(slider._ltext)
slider._thumb:ClearAllPoints()
slider._thumb:SetPoint("left", slider.widget, "left")
object._text:SetText(object._ltext)
object._thumb:ClearAllPoints()
object._thumb:SetPoint("left", object.widget, "left")
end
else
rawset (slider, "value", true)
if (slider.backdrop_enabledcolor) then
slider:SetBackdropColor(unpack(slider.backdrop_enabledcolor))
rawset(object, "value", true)
if (object.backdrop_enabledcolor) then
object:SetBackdropColor(unpack(object.backdrop_enabledcolor))
else
slider:SetBackdropColor(0, 0, 1, 0.4)
object:SetBackdropColor(0, 0, 1, 0.4)
end
if (slider.is_checkbox) then
slider.checked_texture:Show()
if (object.is_checkbox) then
object.checked_texture:Show()
else
slider._text:SetText(slider._rtext)
slider._thumb:ClearAllPoints()
slider._thumb:SetPoint("right", slider.widget, "right")
object._text:SetText(object._rtext)
object._thumb:ClearAllPoints()
object._thumb:SetPoint("right", object.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)
if (object.OnSwitch and not forced_value) then
local value = rawget(object, "value")
if (object.return_func) then
value = object:return_func (value)
end
local success, errorText = xpcall(slider.OnSwitch, geterrorhandler(), slider, slider.FixedValue, value)
local success, errorText = xpcall(object.OnSwitch, geterrorhandler(), object, object.FixedValue, value)
if (not success) then
return
end
--trigger hooks
slider:RunHooksForWidget("OnSwitch", slider, slider.FixedValue, value)
object:RunHooksForWidget("OnSwitch", object, object.FixedValue, value)
end
end
local default_switch_func = function(self, passed_value)
if (self.value) then
return false
else
return true
end
end
local switch_get_value = function(self)
return self.value
end
local switch_set_value = function(self, value)
if (self.switch_func) then
value = self:switch_func (value)
value = self:switch_func(value)
end
SwitchOnClick (self.widget, nil, true, value)
end
local switch_set_fixparameter = function(self, value)
rawset (self, "FixedValue", value)
rawset(self, "FixedValue", value)
end
local switch_disable = function(self)
if (self.is_checkbox) then
self.checked_texture:Hide()
else
@@ -825,8 +811,9 @@ local switch_disable = function(self)
end
self:SetAlpha(.4)
rawset (self, "lockdown", true)
rawset(self, "lockdown", true)
end
local switch_enable = function(self)
if (self.is_checkbox) then
if (rawget(self, "value")) then
@@ -845,7 +832,7 @@ local switch_enable = function(self)
end
self:SetAlpha(1)
return rawset (self, "lockdown", false)
return rawset(self, "lockdown", false)
end
local set_switch_func = function(self, newFunction)
@@ -858,12 +845,11 @@ local set_as_checkbok = function(self)
checked:SetTexture([[Interface\Buttons\UI-CheckBox-Check]])
checked:SetPoint("center", self.button, "center", -1, -1)
local size_pct = self:GetWidth()/32
checked:SetSize(32*size_pct, 32*size_pct)
checked:SetSize(32 * size_pct, 32 * size_pct)
self.checked_texture = checked
self._thumb:Hide()
self._text:Hide()
self.is_checkbox = true
if (rawget(self, "value")) then
@@ -881,39 +867,39 @@ local set_as_checkbok = function(self)
self:SetBackdropColor(0, 0, 1, 0.4)
end
end
end
function DF:CreateSwitch(parent, on_switch, default_value, w, h, ltext, rtext, member, name, color_inverted, switch_func, return_func, with_label, switch_template, label_template)
local switch, label = DF:NewSwitch (parent, parent, name, member, w or 60, h or 20, ltext, rtext, default_value, color_inverted, switch_func, return_func, with_label, switch_template, label_template)
if (on_switch) then
switch.OnSwitch = on_switch
function DF:CreateSwitch(parent, onSwitch, defaultValue, width, height, leftText, rightText, member, name, colorInverted, switchFunc, returnFunc, withLabel, switch_template, label_template)
local switch, label = DF:NewSwitch(parent, parent, name, member, width or 60, height or 20, leftText, rightText, defaultValue, colorInverted, switchFunc, returnFunc, withLabel, switch_template, label_template)
if (onSwitch) then
switch.OnSwitch = onSwitch
end
return switch, label
end
function DF:NewSwitch (parent, container, name, member, w, h, ltext, rtext, default_value, color_inverted, switch_func, return_func, with_label, switch_template, label_template)
function DF:NewSwitch(parent, container, name, member, width, height, leftText, rightText, defaultValue, colorInverted, switch_func, return_func, with_label, switch_template, label_template)
--early checks
if (not name) then
name = "DetailsFrameWorkSlider" .. DF.SwitchCounter
DF.SwitchCounter = DF.SwitchCounter + 1
elseif (not parent) then
return error("Details! FrameWork: parent not found.", 2)
end
if (not container) then
container = parent
end
--defaults
ltext = ltext or "OFF"
rtext = rtext or "ON"
leftText = leftText or "OFF"
rightText = rightText or "ON"
--build frames
w = w or 60
h = h or 20
width = width or 60
height = height or 20
local slider = DF:NewButton(parent, container, name, member, w, h)
local slider = DF:NewButton(parent, container, name, member, width, height)
slider.HookList.OnSwitch = {}
slider.switch_func = switch_func
@@ -928,7 +914,7 @@ function DF:NewSwitch (parent, container, name, member, w, h, ltext, rtext, defa
slider.SetSwitchFunction = set_switch_func
if (member) then
parent [member] = slider
parent[member] = slider
end
slider:SetBackdrop({edgeFile = [[Interface\Buttons\UI-SliderBar-Border]], edgeSize = 8,
@@ -936,7 +922,7 @@ function DF:NewSwitch (parent, container, name, member, w, h, ltext, rtext, defa
local thumb = slider:CreateTexture(nil, "artwork")
thumb:SetTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
thumb:SetSize(34+(h*0.2), h*1.2)
thumb:SetSize(34+(height*0.2), height*1.2)
thumb:SetAlpha(0.7)
thumb:SetPoint("left", slider.widget, "left")
@@ -946,15 +932,15 @@ function DF:NewSwitch (parent, container, name, member, w, h, ltext, rtext, defa
slider._text = text
slider._thumb = thumb
slider._ltext = ltext
slider._rtext = rtext
slider._ltext = leftText
slider._rtext = rightText
slider.thumb = thumb
slider.invert_colors = color_inverted
slider.invert_colors = colorInverted
slider:SetScript("OnClick", SwitchOnClick)
slider:SetValue(default_value)
slider:SetValue(defaultValue)
slider.isSwitch = true
@@ -977,7 +963,6 @@ function DF:NewSwitch (parent, container, name, member, w, h, ltext, rtext, defa
end
function DFSliderMetaFunctions:SetTemplate(template)
--slider e switch
if (template.width) then
self:SetWidth(template.width)
@@ -1052,9 +1037,11 @@ function DF:NewSlider (parent, container, name, member, width, height, minValue,
name = "DetailsFrameworkSlider" .. DF.SliderCounter
DF.SliderCounter = DF.SliderCounter + 1
end
if (not parent) then
return error("Details! FrameWork: parent not found.", 2)
end
if (not container) then
container = parent
end
@@ -1067,7 +1054,7 @@ function DF:NewSlider (parent, container, name, member, width, height, minValue,
local SliderObject = {type = "slider", dframework = true}
if (member) then
parent [member] = SliderObject
parent[member] = SliderObject
end
if (parent.dframework) then
@@ -1077,7 +1064,7 @@ function DF:NewSlider (parent, container, name, member, width, height, minValue,
container = container.widget
end
--defaults
--defaults
minValue = minValue or 1
maxValue = maxValue or 2
step = step or 1
@@ -1086,9 +1073,9 @@ function DF:NewSlider (parent, container, name, member, width, height, minValue,
width = width or 130
height = height or 19
--default members:
SliderObject.lockdown = false
SliderObject.container = container
--default members
SliderObject.lockdown = false
SliderObject.container = container
SliderObject.slider = CreateFrame("slider", name, parent,"BackdropTemplate")
SliderObject.widget = SliderObject.slider
@@ -1107,7 +1094,7 @@ function DF:NewSlider (parent, container, name, member, width, height, minValue,
for funcName, funcAddress in pairs(idx) do
if (not DFSliderMetaFunctions[funcName]) then
DFSliderMetaFunctions[funcName] = function(object, ...)
local x = loadstring ( "return _G['"..object.slider:GetName().."']:"..funcName.."(...)")
local x = loadstring( "return _G['" .. object.slider:GetName() .. "']:" .. funcName .. "(...)")
return x(...)
end
end
@@ -1117,7 +1104,7 @@ function DF:NewSlider (parent, container, name, member, width, height, minValue,
SliderObject.slider.MyObject = SliderObject
SliderObject.slider:SetWidth(width)
SliderObject.slider:SetHeight(height)
SliderObject.slider:SetOrientation ("horizontal")
SliderObject.slider:SetOrientation("horizontal")
SliderObject.slider:SetMinMaxValues(minValue, maxValue)
SliderObject.slider:SetValue(defaultValue)
SliderObject.ivalue = defaultValue
@@ -1284,14 +1271,14 @@ DF.AdjustmentSliderFunctions = {
--button can be the left or right button
OnButtonDownkHook = function(button)
button = button.MyObject
local object = button.MyObject
--change the icon
if (button.direction == "center") then
if (object.direction == "center") then
DF:DisableOnEnterScripts()
end
local adjustmentSlider = button:GetParent()
local adjustmentSlider = object:GetParent()
adjustmentSlider.NextTick = GetTime() + 0.05
--save where the mouse is on the moment of the click
@@ -1301,7 +1288,7 @@ DF.AdjustmentSliderFunctions = {
adjustmentSlider.initialMouseX = mouseX
adjustmentSlider.initialMouseY = mouseY
adjustmentSlider.buttonPressed = button.direction
adjustmentSlider.buttonPressed = object.direction
--start monitoring the mouse moviment
adjustmentSlider.buttonPressedTime = GetTime()
@@ -1310,21 +1297,21 @@ DF.AdjustmentSliderFunctions = {
--button can be the left or right button
OnButtonUpHook = function(button)
button = button.MyObject
local object = button.MyObject
--change the icon
if (button.direction == "center") then
if (object.direction == "center") then
DF:EnableOnEnterScripts()
end
local adjustmentSlider = button:GetParent()
local adjustmentSlider = object:GetParent()
--check if the mouse did not moved at all, if not send a callback with a value of 1
local mouseX, mouseY = GetCursorPosition()
if (mouseX == adjustmentSlider.MouseX and mouseY == adjustmentSlider.MouseY and adjustmentSlider.buttonPressedTime+0.5 > GetTime()) then
if (button.direction == "left") then
if (object.direction == "left") then
DF.AdjustmentSliderFunctions.RunCallback(adjustmentSlider, -1, 0, true)
elseif (button.direction == "right") then
elseif (object.direction == "right") then
DF.AdjustmentSliderFunctions.RunCallback(adjustmentSlider, 1, 0, true)
end
end
+9 -9
View File
@@ -5,9 +5,9 @@ if (not DF or not DetailsFrameworkCanLoad) then
end
local _
local _rawset = rawset --lua local
local _rawget = rawget --lua local
local _setmetatable = setmetatable --lua local
local rawset = rawset --lua local
local rawget = rawget --lua local
local setmetatable = setmetatable --lua local
local _unpack = unpack --lua local
local type = type --lua local
local _math_floor = math.floor --lua local
@@ -175,7 +175,7 @@ DF:Mixin(SplitBarMetaFunctions, DF.ScriptHookMixin)
return func (_table, _member_requested)
end
local fromMe = _rawget (_table, _member_requested)
local fromMe = rawget (_table, _member_requested)
if (fromMe) then
return fromMe
end
@@ -324,7 +324,7 @@ DF:Mixin(SplitBarMetaFunctions, DF.ScriptHookMixin)
if (func) then
return func (_table, _value)
else
return _rawset (_table, _key, _value)
return rawset (_table, _key, _value)
end
end
@@ -433,13 +433,13 @@ DF:Mixin(SplitBarMetaFunctions, DF.ScriptHookMixin)
-- tooltip
function SplitBarMetaFunctions:SetTooltip (tooltip)
if (tooltip) then
return _rawset (self, "have_tooltip", tooltip)
return rawset (self, "have_tooltip", tooltip)
else
return _rawset (self, "have_tooltip", nil)
return rawset (self, "have_tooltip", nil)
end
end
function SplitBarMetaFunctions:GetTooltip()
return _rawget (self, "have_tooltip")
return rawget (self, "have_tooltip")
end
-- frame levels
@@ -798,7 +798,7 @@ function DF:NewSplitBar (parent, container, name, member, w, h)
SplitBarObject.statusbar:SetScript("OnMouseUp", OnMouseUp)
SplitBarObject.statusbar:SetScript("OnSizeChanged", OnSizeChanged)
_setmetatable(SplitBarObject, SplitBarMetaFunctions)
setmetatable(SplitBarObject, SplitBarMetaFunctions)
return SplitBarObject
end
+11 -170
View File
@@ -5,7 +5,6 @@ if (not DF or not DetailsFrameworkCanLoad) then
end
local _
local loadstring = loadstring --lua local
local APITextEntryFunctions = false
do
@@ -624,8 +623,8 @@ function DF:NewTextEntry(parent, container, name, member, width, height, func, p
return newTextEntryObject, withLabel
end
function DF:NewSpellEntry(parent, func, w, h, param1, param2, member, name)
local editbox = DF:NewTextEntry(parent, parent, name, member, w, h, func, param1, param2)
function DF:NewSpellEntry(parent, func, width, height, param1, param2, member, name)
local editbox = DF:NewTextEntry(parent, parent, name, member, width, height, func, param1, param2)
return editbox
end
@@ -645,114 +644,6 @@ local function_setfocus = function(self)
return self.editbox:SetFocus(true)
end
------------------------------------------------------------------------------------
--auto complete
-- block -------------------
--code author Saiket from http://www.wowinterface.com/forums/showpost.php?p=245759&postcount=6
--- @return StartPos, EndPos of highlight in this editbox.
local function GetTextHighlight ( self )
local Text, Cursor = self:GetText(), self:GetCursorPosition();
self:Insert( "" ); -- Delete selected text
local TextNew, CursorNew = self:GetText(), self:GetCursorPosition();
-- Restore previous text
self:SetText( Text );
self:SetCursorPosition( Cursor );
local Start, End = CursorNew, #Text - ( #TextNew - CursorNew );
self:HighlightText( Start, End );
return Start, End;
end
local StripColors;
do
local CursorPosition, CursorDelta;
--- Callback for gsub to remove unescaped codes.
local function StripCodeGsub ( Escapes, Code, End )
if ( #Escapes % 2 == 0 ) then -- Doesn't escape Code
if ( CursorPosition and CursorPosition >= End - 1 ) then
CursorDelta = CursorDelta - #Code;
end
return Escapes;
end
end
--- Removes a single escape sequence.
local function StripCode ( Pattern, Text, OldCursor )
CursorPosition, CursorDelta = OldCursor, 0;
return Text:gsub( Pattern, StripCodeGsub ), OldCursor and CursorPosition + CursorDelta;
end
--- Strips Text of all color escape sequences.
-- @param Cursor Optional cursor position to keep track of.
-- @return Stripped text, and the updated cursor position if Cursor was given.
function StripColors ( Text, Cursor )
Text, Cursor = StripCode( "(|*)(|c%x%x%x%x%x%x%x%x)()", Text, Cursor );
return StripCode( "(|*)(|r)()", Text, Cursor );
end
end
local COLOR_END = "|r";
--- Wraps this editbox's selected text with the given color.
local function ColorSelection ( self, ColorCode )
local Start, End = GetTextHighlight( self );
local Text, Cursor = self:GetText(), self:GetCursorPosition();
if ( Start == End ) then -- Nothing selected
--Start, End = Cursor, Cursor; -- Wrap around cursor
return; -- Wrapping the cursor in a color code and hitting backspace crashes the client!
end
-- Find active color code at the end of the selection
local ActiveColor;
if ( End < #Text ) then -- There is text to color after the selection
local ActiveEnd;
local CodeEnd, _, Escapes, Color = 0;
while ( true ) do
_, CodeEnd, Escapes, Color = Text:find( "(|*)(|c%x%x%x%x%x%x%x%x)", CodeEnd + 1 );
if ( not CodeEnd or CodeEnd > End ) then
break;
end
if ( #Escapes % 2 == 0 ) then -- Doesn't escape Code
ActiveColor, ActiveEnd = Color, CodeEnd;
end
end
if ( ActiveColor ) then
-- Check if color gets terminated before selection ends
CodeEnd = 0;
while ( true ) do
_, CodeEnd, Escapes = Text:find( "(|*)|r", CodeEnd + 1 );
if ( not CodeEnd or CodeEnd > End ) then
break;
end
if ( CodeEnd > ActiveEnd and #Escapes % 2 == 0 ) then -- Terminates ActiveColor
ActiveColor = nil;
break;
end
end
end
end
local Selection = Text:sub( Start + 1, End );
-- Remove color codes from the selection
local Replacement, CursorReplacement = StripColors( Selection, Cursor - Start );
self:SetText( ( "" ):join(
Text:sub( 1, Start ),
ColorCode, Replacement, COLOR_END,
ActiveColor or "", Text:sub( End + 1 )
) );
-- Restore cursor and highlight, adjusting for wrapper text
Cursor = Start + CursorReplacement;
if ( CursorReplacement > 0 ) then -- Cursor beyond start of color code
Cursor = Cursor + #ColorCode;
end
if ( CursorReplacement >= #Replacement ) then -- Cursor beyond end of color
Cursor = Cursor + #COLOR_END;
end
self:SetCursorPosition( Cursor );
-- Highlight selection and wrapper
self:HighlightText( Start, #ColorCode + ( #Replacement - #Selection ) + #COLOR_END + End );
end
-- end of the block ---------------------
local get_last_word = function(self)
self.lastword = ""
local cursor_pos = self.editbox:GetCursorPosition()
@@ -951,8 +842,7 @@ local AutoComplete_OnChar = function(editboxWidget, char, capsule)
editboxWidget.ignore_input = false
end
function TextEntryMetaFunctions:SetAsAutoComplete (poolName, poolTable, shouldOptimize)
function TextEntryMetaFunctions:SetAsAutoComplete(poolName, poolTable, shouldOptimize)
if (not self.SetHook) then
--self is borderframe
self = self.editbox
@@ -996,23 +886,21 @@ end
local set_speciallua_editor_font_size = function(borderFrame, newSize)
local file, size, flags = borderFrame.editbox:GetFont()
borderFrame.editbox:SetFont (file, newSize, flags)
borderFrame.editboxlines:SetFont (file, newSize, flags)
borderFrame.editbox:SetFont(file, newSize, flags)
borderFrame.editboxlines:SetFont(file, newSize, flags)
end
function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent, showLineNumbers)
function DF:NewSpecialLuaEditorEntry(parent, width, height, member, name, nointent, showLineNumbers)
if (name:find("$parent")) then
local parentName = DF.GetParentName(parent)
name = name:gsub("$parent", parentName)
end
local borderframe = CreateFrame("Frame", name, parent,"BackdropTemplate")
borderframe:SetSize(w, h)
borderframe:SetSize(width, height)
if (member) then
parent [member] = borderframe
parent[member] = borderframe
end
local scrollframe = CreateFrame("ScrollFrame", name, borderframe, "UIPanelScrollFrameTemplate, BackdropTemplate")
@@ -1024,7 +912,7 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent, show
scrollframe.editbox:SetScript("OnCursorChanged", _G.ScrollingEdit_OnCursorChanged)
scrollframe.editbox:SetScript("OnEscapePressed", _G.EditBox_ClearFocus)
scrollframe.editbox:SetFontObject("GameFontHighlightSmall")
scrollframe:SetScrollChild (scrollframe.editbox)
scrollframe:SetScrollChild(scrollframe.editbox)
--line number
if (showLineNumbers) then
@@ -1039,7 +927,7 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent, show
scrollframeNumberLines.editbox:SetPoint("topleft", borderframe, "topleft", 10, -10)
scrollframeNumberLines.editbox:SetPoint("bottomright", borderframe, "bottomright", -30, 10)
scrollframeNumberLines:SetScrollChild (scrollframeNumberLines.editbox)
scrollframeNumberLines:SetScrollChild(scrollframeNumberLines.editbox)
scrollframeNumberLines:EnableMouseWheel(false)
for i = 1, 1000 do
@@ -1111,7 +999,7 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent, show
borderframe.SetTemplate = TextEntryMetaFunctions.SetTemplate
if (not nointent) then
IndentationLib.enable (scrollframe.editbox, nil, 4)
IndentationLib.enable(scrollframe.editbox, nil, 4)
end
borderframe:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
@@ -1133,51 +1021,4 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent, show
borderframe.editbox.borderframe = borderframe
return borderframe
end
-- encryption table
local base64chars = {[0]='A',[1]='B',[2]='C',[3]='D',[4]='E',[5]='F',[6]='G',[7]='H',[8]='I',[9]='J',[10]='K',[11]='L',[12]='M',[13]='N',[14]='O',[15]='P',[16]='Q',[17]='R',[18]='S',[19]='T',[20]='U',[21]='V',[22]='W',[23]='X',[24]='Y',[25]='Z',[26]='a',[27]='b',[28]='c',[29]='d',[30]='e',[31]='f',[32]='g',[33]='h',[34]='i',[35]='j',[36]='k',[37]='l',[38]='m',[39]='n',[40]='o',[41]='p',[42]='q',[43]='r',[44]='s',[45]='t',[46]='u',[47]='v',[48]='w',[49]='x',[50]='y',[51]='z',[52]='0',[53]='1',[54]='2',[55]='3',[56]='4',[57]='5',[58]='6',[59]='7',[60]='8',[61]='9',[62]='-',[63]='_'}
-- decryption table
local base64bytes = {['A']=0,['B']=1,['C']=2,['D']=3,['E']=4,['F']=5,['G']=6,['H']=7,['I']=8,['J']=9,['K']=10,['L']=11,['M']=12,['N']=13,['O']=14,['P']=15,['Q']=16,['R']=17,['S']=18,['T']=19,['U']=20,['V']=21,['W']=22,['X']=23,['Y']=24,['Z']=25,['a']=26,['b']=27,['c']=28,['d']=29,['e']=30,['f']=31,['g']=32,['h']=33,['i']=34,['j']=35,['k']=36,['l']=37,['m']=38,['n']=39,['o']=40,['p']=41,['q']=42,['r']=43,['s']=44,['t']=45,['u']=46,['v']=47,['w']=48,['x']=49,['y']=50,['z']=51,['0']=52,['1']=53,['2']=54,['3']=55,['4']=56,['5']=57,['6']=58,['7']=59,['8']=60,['9']=61,['-']=62,['_']=63,['=']=nil}
-- shift left
local function lsh (value,shift)
return (value*(2^shift)) % 256
end
-- shift right
local function rsh (value,shift)
return math.floor(value/2^shift) % 256
end
-- return single bit (for OR)
local function bit (x,b)
return (x % 2^b - x % 2^(b-1) > 0)
end
local function lor (x,y)
local result = 0
for p=1,8 do result = result + (((bit(x,p) or bit(y,p)) == true) and 2^(p-1) or 0) end
return result
end
function DF.EncodeString (data)
local bytes = {}
local result = ""
for spos=0,string.len(data)-1,3 do
for byte=1,3 do bytes[byte] = string.byte(string.sub(data,(spos+byte))) or 0 end
result = string.format('%s%s%s%s%s',result,base64chars[rsh(bytes[1],2)],base64chars[lor(lsh((bytes[1] % 4),4), rsh(bytes[2],4))] or "=",((#data-spos) > 1) and base64chars[lor(lsh(bytes[2] % 16,2), rsh(bytes[3],6))] or "=",((#data-spos) > 2) and base64chars[(bytes[3] % 64)] or "=")
end
return result
end
function DF.DecodeString (data)
local chars = {}
local result=""
for dpos=0,string.len(data)-1,4 do
for char=1,4 do chars[char] = base64bytes[(string.sub(data,(dpos+char),(dpos+char)) or "=")] end
result = string.format('%s%s%s%s',result,string.char(lor(lsh(chars[1],2), rsh(chars[2],4))),(chars[3] ~= nil) and string.char(lor(lsh(chars[2],4), rsh(chars[3],2))) or "",(chars[4] ~= nil) and string.char(lor(lsh(chars[3],6) % 192, (chars[4]))) or "")
end
return result
end