framework update
This commit is contained in:
+1
-7
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
local dversion = 372
|
||||
local dversion = 373
|
||||
local major, minor = "DetailsFramework-1.0", dversion
|
||||
local DF, oldminor = LibStub:NewLibrary(major, minor)
|
||||
|
||||
@@ -382,12 +382,6 @@ local embed_functions = {
|
||||
"SendScriptComm",
|
||||
}
|
||||
|
||||
DF.WidgetFunctions = {
|
||||
GetCapsule = function(self)
|
||||
return self.MyObject
|
||||
end,
|
||||
}
|
||||
|
||||
DF.table = {}
|
||||
|
||||
function DF:GetFrameworkFolder()
|
||||
|
||||
+51
-73
@@ -1,6 +1,6 @@
|
||||
|
||||
local DF = _G ["DetailsFramework"]
|
||||
if (not DF or not DetailsFrameworkCanLoad) then
|
||||
local detailsFramework = _G["DetailsFramework"]
|
||||
if (not detailsFramework or not DetailsFrameworkCanLoad) then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -10,18 +10,18 @@ local loadedAPILabelFunctions = false
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "label",
|
||||
SetHook = DF.SetHook,
|
||||
RunHooksForWidget = DF.RunHooksForWidget,
|
||||
SetHook = detailsFramework.SetHook,
|
||||
RunHooksForWidget = detailsFramework.RunHooksForWidget,
|
||||
|
||||
dversion = DF.dversion,
|
||||
dversion = detailsFramework.dversion,
|
||||
}
|
||||
|
||||
--check if there's a metaPrototype already existing
|
||||
if (_G[DF.GlobalWidgetControlNames["label"]]) then
|
||||
if (_G[detailsFramework.GlobalWidgetControlNames["label"]]) then
|
||||
--get the already existing metaPrototype
|
||||
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames ["label"]]
|
||||
local oldMetaPrototype = _G[detailsFramework.GlobalWidgetControlNames ["label"]]
|
||||
--check if is older
|
||||
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then
|
||||
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < detailsFramework.dversion) ) then
|
||||
--the version is older them the currently loading one
|
||||
--copy the new values into the old metatable
|
||||
for funcName, _ in pairs(metaPrototype) do
|
||||
@@ -30,11 +30,13 @@ do
|
||||
end
|
||||
else
|
||||
--first time loading the framework
|
||||
_G[DF.GlobalWidgetControlNames ["label"]] = metaPrototype
|
||||
_G[detailsFramework.GlobalWidgetControlNames ["label"]] = metaPrototype
|
||||
end
|
||||
end
|
||||
|
||||
local LabelMetaFunctions = _G[DF.GlobalWidgetControlNames ["label"]]
|
||||
local LabelMetaFunctions = _G[detailsFramework.GlobalWidgetControlNames ["label"]]
|
||||
|
||||
detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.SetPointMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
@@ -46,31 +48,32 @@ local LabelMetaFunctions = _G[DF.GlobalWidgetControlNames ["label"]]
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--shown
|
||||
local gmember_shown = function(object)
|
||||
return object:IsShown()
|
||||
end
|
||||
--get text
|
||||
local gmember_text = function(object)
|
||||
return object.label:GetText()
|
||||
end
|
||||
|
||||
--text width
|
||||
local gmember_width = function(object)
|
||||
return object.label:GetStringWidth()
|
||||
end
|
||||
|
||||
--text height
|
||||
local gmember_height = function(object)
|
||||
return object.label:GetStringHeight()
|
||||
end
|
||||
|
||||
--text color
|
||||
local gmember_textcolor = function(object)
|
||||
return object.label:GetTextColor()
|
||||
end
|
||||
|
||||
--text font
|
||||
local gmember_textfont = function(object)
|
||||
local fontface = object.label:GetFont()
|
||||
return fontface
|
||||
end
|
||||
|
||||
--text size
|
||||
local gmember_textsize = function(object)
|
||||
local _, fontsize = object.label:GetFont()
|
||||
@@ -78,7 +81,9 @@ local LabelMetaFunctions = _G[DF.GlobalWidgetControlNames ["label"]]
|
||||
end
|
||||
|
||||
LabelMetaFunctions.GetMembers = LabelMetaFunctions.GetMembers or {}
|
||||
LabelMetaFunctions.GetMembers["shown"] = gmember_shown
|
||||
detailsFramework:Mixin(LabelMetaFunctions.GetMembers, detailsFramework.LayeredRegionMetaFunctionsGet)
|
||||
detailsFramework:Mixin(LabelMetaFunctions.GetMembers, detailsFramework.DefaultMetaFunctionsGet)
|
||||
|
||||
LabelMetaFunctions.GetMembers["width"] = gmember_width
|
||||
LabelMetaFunctions.GetMembers["height"] = gmember_height
|
||||
LabelMetaFunctions.GetMembers["text"] = gmember_text
|
||||
@@ -105,39 +110,27 @@ local LabelMetaFunctions = _G[DF.GlobalWidgetControlNames ["label"]]
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--show
|
||||
local smember_show = function(object, value)
|
||||
if (value) then
|
||||
return object:Show()
|
||||
else
|
||||
return object:Hide()
|
||||
end
|
||||
end
|
||||
--hide
|
||||
local smember_hide = function(object, value)
|
||||
if (not value) then
|
||||
return object:Show()
|
||||
else
|
||||
return object:Hide()
|
||||
end
|
||||
end
|
||||
--text
|
||||
local smember_text = function(object, value)
|
||||
return object.label:SetText(value)
|
||||
end
|
||||
|
||||
--text color
|
||||
local smember_textcolor = function(object, value)
|
||||
local value1, value2, value3, value4 = DF:ParseColors(value)
|
||||
local value1, value2, value3, value4 = detailsFramework:ParseColors(value)
|
||||
return object.label:SetTextColor(value1, value2, value3, value4)
|
||||
end
|
||||
|
||||
--text font
|
||||
local smember_textfont = function(object, value)
|
||||
return DF:SetFontFace(object.label, value)
|
||||
return detailsFramework:SetFontFace(object.label, value)
|
||||
end
|
||||
|
||||
--text size
|
||||
local smember_textsize = function(object, value)
|
||||
return DF:SetFontSize(object.label, value)
|
||||
return detailsFramework:SetFontSize(object.label, value)
|
||||
end
|
||||
|
||||
--text align
|
||||
local smember_textalign = function(object, value)
|
||||
if (value == "<") then
|
||||
@@ -149,6 +142,7 @@ local LabelMetaFunctions = _G[DF.GlobalWidgetControlNames ["label"]]
|
||||
end
|
||||
return object.label:SetJustifyH(value)
|
||||
end
|
||||
|
||||
--text valign
|
||||
local smember_textvalign = function(object, value)
|
||||
if (value == "^") then
|
||||
@@ -160,24 +154,28 @@ local LabelMetaFunctions = _G[DF.GlobalWidgetControlNames ["label"]]
|
||||
end
|
||||
return object.label:SetJustifyV(value)
|
||||
end
|
||||
|
||||
--field size width
|
||||
local smember_width = function(object, value)
|
||||
return object.label:SetWidth(value)
|
||||
end
|
||||
|
||||
--field size height
|
||||
local smember_height = function(object, value)
|
||||
return object.label:SetHeight(value)
|
||||
end
|
||||
|
||||
--outline (shadow)
|
||||
local smember_outline = function(object, value)
|
||||
DF:SetFontOutline(object.label, value)
|
||||
detailsFramework:SetFontOutline(object.label, value)
|
||||
end
|
||||
|
||||
--text rotation
|
||||
local smember_rotation = function(object, rotation)
|
||||
if (type(rotation) == "number") then
|
||||
if (not object.__rotationAnimation) then
|
||||
object.__rotationAnimation = DF:CreateAnimationHub(object.label)
|
||||
object.__rotationAnimation.rotator = DF:CreateAnimation(object.__rotationAnimation, "rotation", 1, 0, 0)
|
||||
object.__rotationAnimation = detailsFramework:CreateAnimationHub(object.label)
|
||||
object.__rotationAnimation.rotator = detailsFramework:CreateAnimation(object.__rotationAnimation, "rotation", 1, 0, 0)
|
||||
object.__rotationAnimation.rotator:SetEndDelay(10^8)
|
||||
object.__rotationAnimation.rotator:SetSmoothProgress(1)
|
||||
end
|
||||
@@ -188,8 +186,9 @@ local LabelMetaFunctions = _G[DF.GlobalWidgetControlNames ["label"]]
|
||||
end
|
||||
|
||||
LabelMetaFunctions.SetMembers = LabelMetaFunctions.SetMembers or {}
|
||||
LabelMetaFunctions.SetMembers["show"] = smember_show
|
||||
LabelMetaFunctions.SetMembers["hide"] = smember_hide
|
||||
detailsFramework:Mixin(LabelMetaFunctions.SetMembers, detailsFramework.LayeredRegionMetaFunctionsSet)
|
||||
detailsFramework:Mixin(LabelMetaFunctions.SetMembers, detailsFramework.DefaultMetaFunctionsSet)
|
||||
|
||||
LabelMetaFunctions.SetMembers["align"] = smember_textalign
|
||||
LabelMetaFunctions.SetMembers["valign"] = smember_textvalign
|
||||
LabelMetaFunctions.SetMembers["text"] = smember_text
|
||||
@@ -218,63 +217,42 @@ local LabelMetaFunctions = _G[DF.GlobalWidgetControlNames ["label"]]
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> methods
|
||||
|
||||
--show & hide
|
||||
function LabelMetaFunctions:IsShown()
|
||||
return self.label:IsShown()
|
||||
end
|
||||
function LabelMetaFunctions:Show()
|
||||
return self.label:Show()
|
||||
end
|
||||
function LabelMetaFunctions:Hide()
|
||||
return self.label:Hide()
|
||||
end
|
||||
|
||||
--text text
|
||||
function LabelMetaFunctions:SetTextTruncated(text, maxWidth)
|
||||
self.widget:SetText(text)
|
||||
DF:TruncateText(self.widget, maxWidth)
|
||||
detailsFramework:TruncateText(self.widget, maxWidth)
|
||||
end
|
||||
|
||||
--textcolor
|
||||
function LabelMetaFunctions:SetTextColor(r, g, b, a)
|
||||
r, g, b, a = DF:ParseColors(r, g, b, a)
|
||||
r, g, b, a = detailsFramework:ParseColors(r, g, b, a)
|
||||
return self.label:SetTextColor(r, g, b, a)
|
||||
end
|
||||
|
||||
-- setpoint
|
||||
function LabelMetaFunctions:SetPoint(v1, v2, v3, v4, v5)
|
||||
v1, v2, v3, v4, v5 = DF:CheckPoints(v1, v2, v3, v4, v5, self)
|
||||
if (not v1) then
|
||||
print("Invalid parameter for SetPoint")
|
||||
return
|
||||
end
|
||||
return self.widget:SetPoint(v1, v2, v3, v4, v5)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function LabelMetaFunctions:SetTemplate(template)
|
||||
if (template.size) then
|
||||
DF:SetFontSize(self.label, template.size)
|
||||
detailsFramework:SetFontSize(self.label, template.size)
|
||||
end
|
||||
if (template.color) then
|
||||
local r, g, b, a = DF:ParseColors(template.color)
|
||||
local r, g, b, a = detailsFramework:ParseColors(template.color)
|
||||
self:SetTextColor(r, g, b, a)
|
||||
end
|
||||
if (template.font) then
|
||||
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
|
||||
local font = SharedMedia:Fetch("font", template.font)
|
||||
DF:SetFontFace(self.label, font)
|
||||
detailsFramework:SetFontFace(self.label, font)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
function DF:CreateLabel(parent, text, size, color, font, member, name, layer)
|
||||
return DF:NewLabel(parent, nil, name, member, text, font, size, color, layer)
|
||||
function detailsFramework:CreateLabel(parent, text, size, color, font, member, name, layer)
|
||||
return detailsFramework:NewLabel(parent, nil, name, member, text, font, size, color, layer)
|
||||
end
|
||||
|
||||
function DF:NewLabel(parent, container, name, member, text, font, size, color, layer)
|
||||
function detailsFramework:NewLabel(parent, container, name, member, text, font, size, color, layer)
|
||||
if (not parent) then
|
||||
return error("Details! Framework: parent not found.", 2)
|
||||
end
|
||||
@@ -283,12 +261,12 @@ function DF:NewLabel(parent, container, name, member, text, font, size, color, l
|
||||
end
|
||||
|
||||
if (not name) then
|
||||
name = "DetailsFrameworkLabelNumber" .. DF.LabelNameCounter
|
||||
DF.LabelNameCounter = DF.LabelNameCounter + 1
|
||||
name = "DetailsFrameworkLabelNumber" .. detailsFramework.LabelNameCounter
|
||||
detailsFramework.LabelNameCounter = detailsFramework.LabelNameCounter + 1
|
||||
end
|
||||
|
||||
if (name:find("$parent")) then
|
||||
local parentName = DF.GetParentName(parent)
|
||||
local parentName = detailsFramework.GetParentName(parent)
|
||||
name = name:gsub("$parent", parentName)
|
||||
end
|
||||
|
||||
@@ -328,12 +306,12 @@ function DF:NewLabel(parent, container, name, member, text, font, size, color, l
|
||||
LabelObject.label:SetText(text)
|
||||
|
||||
if (color) then
|
||||
local r, g, b, a = DF:ParseColors(color)
|
||||
local r, g, b, a = detailsFramework:ParseColors(color)
|
||||
LabelObject.label:SetTextColor(r, g, b, a)
|
||||
end
|
||||
|
||||
if (size and type(size) == "number") then
|
||||
DF:SetFontSize(LabelObject.label, size)
|
||||
detailsFramework:SetFontSize(LabelObject.label, size)
|
||||
end
|
||||
|
||||
LabelObject.HookList = {
|
||||
|
||||
+96
-22
@@ -1,21 +1,75 @@
|
||||
|
||||
local DF = _G ["DetailsFramework"]
|
||||
if (not DF or not DetailsFrameworkCanLoad) then
|
||||
local detailsFramework = _G["DetailsFramework"]
|
||||
if (not detailsFramework or not DetailsFrameworkCanLoad) then
|
||||
return
|
||||
end
|
||||
|
||||
local _
|
||||
|
||||
DF.DefaultMetaFunctionsGet = {
|
||||
parent = function(object)
|
||||
return object:GetParent()
|
||||
detailsFramework.WidgetFunctions = {
|
||||
GetCapsule = function(self)
|
||||
return self.MyObject
|
||||
end,
|
||||
|
||||
GetObject = function(self)
|
||||
return self.MyObject
|
||||
end,
|
||||
}
|
||||
|
||||
DF.DefaultMetaFunctionsSet = {
|
||||
detailsFramework.DefaultMetaFunctionsGet = {
|
||||
parent = function(object)
|
||||
return object:GetParent()
|
||||
end,
|
||||
|
||||
shown = function(object)
|
||||
return object:IsShown()
|
||||
end,
|
||||
}
|
||||
|
||||
detailsFramework.DefaultMetaFunctionsSet = {
|
||||
parent = function(object, value)
|
||||
return object:SetParent(value)
|
||||
end,
|
||||
|
||||
show = function(object, value)
|
||||
if (value) then
|
||||
return object:Show()
|
||||
else
|
||||
return object:Hide()
|
||||
end
|
||||
end,
|
||||
|
||||
hide = function(object, value)
|
||||
if (value) then
|
||||
return object:Hide()
|
||||
else
|
||||
return object:Show()
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
detailsFramework.DefaultMetaFunctionsSet.shown = detailsFramework.DefaultMetaFunctionsSet.show
|
||||
|
||||
detailsFramework.LayeredRegionMetaFunctionsSet = {
|
||||
drawlayer = function(object, value)
|
||||
object.image:SetDrawLayer(value)
|
||||
end,
|
||||
|
||||
sublevel = function(object, value)
|
||||
local drawLayer = object:GetDrawLayer()
|
||||
object:SetDrawLayer(drawLayer, value)
|
||||
end,
|
||||
}
|
||||
|
||||
detailsFramework.LayeredRegionMetaFunctionsGet = {
|
||||
drawlayer = function(object)
|
||||
return object.image:GetDrawLayer()
|
||||
end,
|
||||
|
||||
sublevel = function(object)
|
||||
local _, subLevel = object.image:GetDrawLayer()
|
||||
return subLevel
|
||||
end,
|
||||
}
|
||||
|
||||
local doublePoint = {
|
||||
@@ -23,12 +77,19 @@ local doublePoint = {
|
||||
["rights"] = true,
|
||||
["tops"] = true,
|
||||
["bottoms"] = true,
|
||||
|
||||
["left-left"] = true,
|
||||
["right-right"] = true,
|
||||
["top-top"] = true,
|
||||
["bottom-bottom"] = true,
|
||||
|
||||
["bottom-top"] = true,
|
||||
["top-bottom"] = true,
|
||||
["right-left"] = true,
|
||||
["left-right"] = true,
|
||||
}
|
||||
|
||||
DF.SetPointMixin = {
|
||||
detailsFramework.SetPointMixin = {
|
||||
SetPoint = function(object, anchorName1, anchorObject, anchorName2, xOffset, yOffset)
|
||||
if (doublePoint[anchorName1]) then
|
||||
object:ClearAllPoints()
|
||||
@@ -58,6 +119,18 @@ DF.SetPointMixin = {
|
||||
object:SetPoint("bottomleft", anchorTo, "bottomleft", xOffset, yOffset)
|
||||
object:SetPoint("bottomright", anchorTo, "bottomright", -xOffset, yOffset)
|
||||
|
||||
elseif (anchorName1 == "left-left") then
|
||||
object:SetPoint("left", anchorTo, "left", xOffset, yOffset)
|
||||
|
||||
elseif (anchorName1 == "right-right") then
|
||||
object:SetPoint("right", anchorTo, "right", xOffset, yOffset)
|
||||
|
||||
elseif (anchorName1 == "top-top") then
|
||||
object:SetPoint("top", anchorTo, "top", xOffset, yOffset)
|
||||
|
||||
elseif (anchorName1 == "bottom-bottom") then
|
||||
object:SetPoint("bottom", anchorTo, "bottom", xOffset, yOffset)
|
||||
|
||||
elseif (anchorName1 == "bottom-top") then
|
||||
object:SetPoint("bottomleft", anchorTo, "topleft", xOffset, yOffset)
|
||||
object:SetPoint("bottomright", anchorTo, "topright", -xOffset, yOffset)
|
||||
@@ -68,7 +141,11 @@ DF.SetPointMixin = {
|
||||
|
||||
elseif (anchorName1 == "right-left") then
|
||||
object:SetPoint("topright", anchorTo, "topleft", xOffset, -yOffset)
|
||||
object:SetPoint("bottomright", anchorTo, "bottomright", xOffset, yOffset)
|
||||
object:SetPoint("bottomright", anchorTo, "bottomleft", xOffset, yOffset)
|
||||
|
||||
elseif (anchorName1 == "left-right") then
|
||||
object:SetPoint("topleft", anchorTo, "topright", xOffset, -yOffset)
|
||||
object:SetPoint("bottomleft", anchorTo, "bottomright", xOffset, yOffset)
|
||||
end
|
||||
|
||||
return
|
||||
@@ -77,7 +154,7 @@ DF.SetPointMixin = {
|
||||
xOffset = xOffset or 0
|
||||
yOffset = yOffset or 0
|
||||
|
||||
anchorName1, anchorObject, anchorName2, xOffset, yOffset = DF:CheckPoints(anchorName1, anchorObject, anchorName2, xOffset, yOffset, object)
|
||||
anchorName1, anchorObject, anchorName2, xOffset, yOffset = detailsFramework:CheckPoints(anchorName1, anchorObject, anchorName2, xOffset, yOffset, object)
|
||||
if (not anchorName1) then
|
||||
error("SetPoint: Invalid parameter.")
|
||||
return
|
||||
@@ -87,7 +164,7 @@ DF.SetPointMixin = {
|
||||
}
|
||||
|
||||
--mixin for options functions
|
||||
DF.OptionsFunctions = {
|
||||
detailsFramework.OptionsFunctions = {
|
||||
SetOption = function (self, optionName, optionValue)
|
||||
if (self.options) then
|
||||
self.options [optionName] = optionValue
|
||||
@@ -97,7 +174,7 @@ DF.OptionsFunctions = {
|
||||
end
|
||||
|
||||
if (self.OnOptionChanged) then
|
||||
DF:Dispatch (self.OnOptionChanged, self, optionName, optionValue)
|
||||
detailsFramework:Dispatch (self.OnOptionChanged, self, optionName, optionValue)
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -119,13 +196,13 @@ DF.OptionsFunctions = {
|
||||
|
||||
BuildOptionsTable = function (self, defaultOptions, userOptions)
|
||||
self.options = self.options or {}
|
||||
DF.table.deploy (self.options, userOptions or {})
|
||||
DF.table.deploy (self.options, defaultOptions or {})
|
||||
detailsFramework.table.deploy (self.options, userOptions or {})
|
||||
detailsFramework.table.deploy (self.options, defaultOptions or {})
|
||||
end
|
||||
}
|
||||
|
||||
--payload mixin
|
||||
DF.PayloadMixin = {
|
||||
detailsFramework.PayloadMixin = {
|
||||
ClearPayload = function(self)
|
||||
self.payload = {}
|
||||
end,
|
||||
@@ -157,12 +234,12 @@ DF.PayloadMixin = {
|
||||
|
||||
--does not copy wow objects, just pass them to the new table, tables strings and numbers are copied entirely
|
||||
DuplicatePayload = function(self)
|
||||
local duplicatedPayload = DF.table.duplicate({}, self.payload)
|
||||
local duplicatedPayload = detailsFramework.table.duplicate({}, self.payload)
|
||||
return duplicatedPayload
|
||||
end,
|
||||
}
|
||||
|
||||
DF.ScrollBoxFunctions = {
|
||||
detailsFramework.ScrollBoxFunctions = {
|
||||
Refresh = function(self)
|
||||
--hide all frames and tag as not in use
|
||||
for index, frame in ipairs(self.Frames) do
|
||||
@@ -176,7 +253,7 @@ DF.ScrollBoxFunctions = {
|
||||
offset = self:GetOffsetFaux()
|
||||
end
|
||||
|
||||
DF:CoreDispatch((self:GetName() or "ScrollBox") .. ":Refresh()", self.refresh_func, self, self.data, offset, self.LineAmount)
|
||||
detailsFramework:CoreDispatch((self:GetName() or "ScrollBox") .. ":Refresh()", self.refresh_func, self, self.data, offset, self.LineAmount)
|
||||
|
||||
for index, frame in ipairs(self.Frames) do
|
||||
if (not frame._InUse) then
|
||||
@@ -411,7 +488,7 @@ local SortByMemberReverse = function (t1, t2)
|
||||
return t1[SortMember] < t2[SortMember]
|
||||
end
|
||||
|
||||
DF.SortFunctions = {
|
||||
detailsFramework.SortFunctions = {
|
||||
Sort = function(self, thisTable, memberName, isReverse)
|
||||
SortMember = memberName
|
||||
if (not isReverse) then
|
||||
@@ -420,7 +497,4 @@ DF.SortFunctions = {
|
||||
table.sort(thisTable, SortByMemberReverse)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+45
-94
@@ -1,29 +1,28 @@
|
||||
|
||||
local DF = _G ["DetailsFramework"]
|
||||
if (not DF or not DetailsFrameworkCanLoad) then
|
||||
local detailsFramework = _G["DetailsFramework"]
|
||||
if (not detailsFramework or not DetailsFrameworkCanLoad) then
|
||||
return
|
||||
end
|
||||
|
||||
local _
|
||||
local loadstring = loadstring
|
||||
|
||||
local APIImageFunctions = false
|
||||
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "image",
|
||||
SetHook = DF.SetHook,
|
||||
RunHooksForWidget = DF.RunHooksForWidget,
|
||||
SetHook = detailsFramework.SetHook,
|
||||
RunHooksForWidget = detailsFramework.RunHooksForWidget,
|
||||
|
||||
dversion = DF.dversion,
|
||||
dversion = detailsFramework.dversion,
|
||||
}
|
||||
|
||||
--check if there's a metaPrototype already existing
|
||||
if (_G[DF.GlobalWidgetControlNames["image"]]) then
|
||||
if (_G[detailsFramework.GlobalWidgetControlNames["image"]]) then
|
||||
--get the already existing metaPrototype
|
||||
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["image"]]
|
||||
local oldMetaPrototype = _G[detailsFramework.GlobalWidgetControlNames["image"]]
|
||||
--check if is older
|
||||
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then
|
||||
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < detailsFramework.dversion) ) then
|
||||
--the version is older them the currently loading one
|
||||
--copy the new values into the old metatable
|
||||
for funcName, _ in pairs(metaPrototype) do
|
||||
@@ -32,13 +31,13 @@ do
|
||||
end
|
||||
else
|
||||
--first time loading the framework
|
||||
_G[DF.GlobalWidgetControlNames["image"]] = metaPrototype
|
||||
_G[detailsFramework.GlobalWidgetControlNames["image"]] = metaPrototype
|
||||
end
|
||||
end
|
||||
|
||||
local ImageMetaFunctions = _G[DF.GlobalWidgetControlNames["image"]]
|
||||
local ImageMetaFunctions = _G[detailsFramework.GlobalWidgetControlNames["image"]]
|
||||
|
||||
DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--metatables
|
||||
@@ -50,11 +49,6 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--members
|
||||
|
||||
--shown
|
||||
local gmember_shown = function(object)
|
||||
return object:IsShown()
|
||||
end
|
||||
|
||||
--frame width
|
||||
local gmember_width = function(object)
|
||||
return object.image:GetWidth()
|
||||
@@ -90,19 +84,10 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
return object.image:GetTexCoord()
|
||||
end
|
||||
|
||||
local gmember_drawlayer = function(object)
|
||||
return object.image:GetDrawLayer()
|
||||
end
|
||||
|
||||
local gmember_sublevel = function(object)
|
||||
local _, subLevel = object.image:GetDrawLayer()
|
||||
return subLevel
|
||||
end
|
||||
|
||||
ImageMetaFunctions.GetMembers = ImageMetaFunctions.GetMembers or {}
|
||||
DF:Mixin(ImageMetaFunctions.GetMembers, DF.DefaultMetaFunctionsGet)
|
||||
detailsFramework:Mixin(ImageMetaFunctions.GetMembers, detailsFramework.DefaultMetaFunctionsGet)
|
||||
detailsFramework:Mixin(ImageMetaFunctions.GetMembers, detailsFramework.LayeredRegionMetaFunctionsGet)
|
||||
|
||||
ImageMetaFunctions.GetMembers["shown"] = gmember_shown
|
||||
ImageMetaFunctions.GetMembers["alpha"] = gmember_alpha
|
||||
ImageMetaFunctions.GetMembers["width"] = gmember_width
|
||||
ImageMetaFunctions.GetMembers["height"] = gmember_height
|
||||
@@ -111,8 +96,6 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
ImageMetaFunctions.GetMembers["desaturated"] = gmember_saturation
|
||||
ImageMetaFunctions.GetMembers["atlas"] = gmember_atlas
|
||||
ImageMetaFunctions.GetMembers["texcoord"] = gmember_texcoord
|
||||
ImageMetaFunctions.GetMembers["drawlayer"] = gmember_drawlayer
|
||||
ImageMetaFunctions.GetMembers["sublevel"] = gmember_sublevel
|
||||
|
||||
ImageMetaFunctions.__index = function(object, key)
|
||||
local func = ImageMetaFunctions.GetMembers[key]
|
||||
@@ -130,35 +113,17 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--show
|
||||
local smember_show = function(object, value)
|
||||
if (value) then
|
||||
return object:Show()
|
||||
else
|
||||
return object:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
--hide
|
||||
local smember_hide = function(object, value)
|
||||
if (not value) then
|
||||
return object:Show()
|
||||
else
|
||||
return object:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
--texture
|
||||
local smember_texture = function(object, value)
|
||||
if (type (value) == "table") then
|
||||
local r, g, b, a = DF:ParseColors(value)
|
||||
object.image:SetTexture (r, g, b, a or 1)
|
||||
if (type(value) == "table") then
|
||||
local r, g, b, a = detailsFramework:ParseColors(value)
|
||||
object.image:SetTexture(r, g, b, a or 1)
|
||||
else
|
||||
if (DF:IsHtmlColor (value)) then
|
||||
local r, g, b, a = DF:ParseColors(value)
|
||||
object.image:SetTexture (r, g, b, a or 1)
|
||||
if (detailsFramework:IsHtmlColor(value)) then
|
||||
local r, g, b, a = detailsFramework:ParseColors(value)
|
||||
object.image:SetTexture(r, g, b, a or 1)
|
||||
else
|
||||
object.image:SetTexture (value)
|
||||
object.image:SetTexture(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -180,13 +145,13 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
|
||||
--color
|
||||
local smember_color = function(object, value)
|
||||
local r, g, b, a = DF:ParseColors(value)
|
||||
local r, g, b, a = detailsFramework:ParseColors(value)
|
||||
object.image:SetColorTexture(r, g, b, a or 1)
|
||||
end
|
||||
|
||||
--vertex color
|
||||
local smember_vertexcolor = function(object, value)
|
||||
local r, g, b, a = DF:ParseColors(value)
|
||||
local r, g, b, a = detailsFramework:ParseColors(value)
|
||||
object.image:SetVertexColor(r, g, b, a or 1)
|
||||
end
|
||||
|
||||
@@ -215,23 +180,12 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
end
|
||||
end
|
||||
|
||||
--draw layer
|
||||
local smember_drawlayer = function(object, value)
|
||||
object.image:SetDrawLayer(value)
|
||||
end
|
||||
|
||||
--sub level of the draw layer
|
||||
local smember_sublevel = function(object, value)
|
||||
local drawLayer = object:GetDrawLayer()
|
||||
object:SetDrawLayer(drawLayer, value)
|
||||
end
|
||||
|
||||
--gradient
|
||||
local smember_gradient = function(object, value)
|
||||
if (type(value) == "table" and value.gradient and value.fromColor and value.toColor) then
|
||||
object.image:SetColorTexture(1, 1, 1, 1)
|
||||
local fromColor = DF:FormatColor("tablemembers", value.fromColor)
|
||||
local toColor = DF:FormatColor("tablemembers", value.toColor)
|
||||
local fromColor = detailsFramework:FormatColor("tablemembers", value.fromColor)
|
||||
local toColor = detailsFramework:FormatColor("tablemembers", value.toColor)
|
||||
object.image:SetGradient(value.gradient, fromColor, toColor)
|
||||
else
|
||||
error("texture.gradient expect a table{gradient = 'gradient type', fromColor = 'color', toColor = 'color'}")
|
||||
@@ -239,10 +193,9 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
end
|
||||
|
||||
ImageMetaFunctions.SetMembers = ImageMetaFunctions.SetMembers or {}
|
||||
DF:Mixin(ImageMetaFunctions.SetMembers, DF.DefaultMetaFunctionsSet)
|
||||
detailsFramework:Mixin(ImageMetaFunctions.SetMembers, detailsFramework.DefaultMetaFunctionsSet)
|
||||
detailsFramework:Mixin(ImageMetaFunctions.SetMembers, detailsFramework.LayeredRegionMetaFunctionsSet)
|
||||
|
||||
ImageMetaFunctions.SetMembers["show"] = smember_show
|
||||
ImageMetaFunctions.SetMembers["hide"] = smember_hide
|
||||
ImageMetaFunctions.SetMembers["alpha"] = smember_alpha
|
||||
ImageMetaFunctions.SetMembers["width"] = smember_width
|
||||
ImageMetaFunctions.SetMembers["height"] = smember_height
|
||||
@@ -253,8 +206,6 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
ImageMetaFunctions.SetMembers["blackwhite"] = smember_desaturated
|
||||
ImageMetaFunctions.SetMembers["desaturated"] = smember_desaturated
|
||||
ImageMetaFunctions.SetMembers["atlas"] = smember_atlas
|
||||
ImageMetaFunctions.SetMembers["drawlayer"] = smember_drawlayer
|
||||
ImageMetaFunctions.SetMembers["sublevel"] = smember_sublevel
|
||||
ImageMetaFunctions.SetMembers["gradient"] = smember_gradient
|
||||
|
||||
ImageMetaFunctions.__newindex = function(object, key, value)
|
||||
@@ -279,34 +230,34 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
end
|
||||
|
||||
function ImageMetaFunctions:SetGradient(gradientType, fromColor, toColor)
|
||||
fromColor = DF:FormatColor("tablemembers", fromColor)
|
||||
toColor = DF:FormatColor("tablemembers", toColor)
|
||||
fromColor = detailsFramework:FormatColor("tablemembers", fromColor)
|
||||
toColor = detailsFramework:FormatColor("tablemembers", toColor)
|
||||
self.image:SetGradient(gradientType, fromColor, toColor)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--object constructor
|
||||
|
||||
function DF:CreateTexture(parent, texture, width, height, layer, coords, member, name)
|
||||
return DF:NewImage(parent, texture, width, height, layer, coords, member, name)
|
||||
function detailsFramework:CreateTexture(parent, texture, width, height, layer, coords, member, name)
|
||||
return detailsFramework:NewImage(parent, texture, width, height, layer, coords, member, name)
|
||||
end
|
||||
|
||||
function DF:CreateImage(parent, texture, width, height, layer, coords, member, name)
|
||||
return DF:NewImage(parent, texture, width, height, layer, coords, member, name)
|
||||
function detailsFramework:CreateImage(parent, texture, width, height, layer, coords, member, name)
|
||||
return detailsFramework:NewImage(parent, texture, width, height, layer, coords, member, name)
|
||||
end
|
||||
|
||||
function DF:NewImage(parent, texture, width, height, layer, texCoord, member, name)
|
||||
function detailsFramework:NewImage(parent, texture, width, height, layer, texCoord, member, name)
|
||||
if (not parent) then
|
||||
return error("Details! FrameWork: parent not found.", 2)
|
||||
end
|
||||
|
||||
if (not name) then
|
||||
name = "DetailsFrameworkPictureNumber" .. DF.PictureNameCounter
|
||||
DF.PictureNameCounter = DF.PictureNameCounter + 1
|
||||
name = "DetailsFrameworkPictureNumber" .. detailsFramework.PictureNameCounter
|
||||
detailsFramework.PictureNameCounter = detailsFramework.PictureNameCounter + 1
|
||||
end
|
||||
|
||||
if (name:find("$parent")) then
|
||||
local parentName = DF.GetParentName(parent)
|
||||
local parentName = detailsFramework.GetParentName(parent)
|
||||
name = name:gsub("$parent", parentName)
|
||||
end
|
||||
|
||||
@@ -325,7 +276,7 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
ImageObject.image = parent:CreateTexture(name, layer or "OVERLAY")
|
||||
ImageObject.widget = ImageObject.image
|
||||
|
||||
DF:Mixin(ImageObject.image, DF.WidgetFunctions)
|
||||
detailsFramework:Mixin(ImageObject.image, detailsFramework.WidgetFunctions)
|
||||
|
||||
if (not APIImageFunctions) then
|
||||
APIImageFunctions = true
|
||||
@@ -352,19 +303,19 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
if (texture) then
|
||||
if (type(texture) == "table") then
|
||||
if (texture.gradient) then
|
||||
if (DF.IsDragonflight()) then
|
||||
if (detailsFramework.IsDragonflight()) then
|
||||
ImageObject.image:SetColorTexture(1, 1, 1, 1)
|
||||
local fromColor = DF:FormatColor("tablemembers", texture.fromColor)
|
||||
local toColor = DF:FormatColor("tablemembers", texture.toColor)
|
||||
local fromColor = detailsFramework:FormatColor("tablemembers", texture.fromColor)
|
||||
local toColor = detailsFramework:FormatColor("tablemembers", texture.toColor)
|
||||
ImageObject.image:SetGradient(texture.gradient, fromColor, toColor)
|
||||
else
|
||||
local fromR, fromG, fromB, fromA = DF:ParseColors(texture.fromColor)
|
||||
local toR, toG, toB, toA = DF:ParseColors(texture.toColor)
|
||||
local fromR, fromG, fromB, fromA = detailsFramework:ParseColors(texture.fromColor)
|
||||
local toR, toG, toB, toA = detailsFramework:ParseColors(texture.toColor)
|
||||
ImageObject.image:SetColorTexture(1, 1, 1, 1)
|
||||
ImageObject.image:SetGradientAlpha(texture.gradient, fromR, fromG, fromB, fromA, toR, toG, toB, toA)
|
||||
end
|
||||
else
|
||||
local r, g, b, a = DF:ParseColors(texture)
|
||||
local r, g, b, a = detailsFramework:ParseColors(texture)
|
||||
ImageObject.image:SetColorTexture(r, g, b, a)
|
||||
end
|
||||
|
||||
@@ -373,8 +324,8 @@ DF:Mixin(ImageMetaFunctions, DF.SetPointMixin)
|
||||
if (isAtlas) then
|
||||
ImageObject.image:SetAtlas(texture)
|
||||
else
|
||||
if (DF:IsHtmlColor(texture)) then
|
||||
local r, g, b = DF:ParseColors(texture)
|
||||
if (detailsFramework:IsHtmlColor(texture)) then
|
||||
local r, g, b = detailsFramework:ParseColors(texture)
|
||||
ImageObject.image:SetColorTexture(r, g, b)
|
||||
else
|
||||
ImageObject.image:SetTexture(texture)
|
||||
|
||||
Reference in New Issue
Block a user