updates
This commit is contained in:
@@ -0,0 +1,665 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
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
|
||||
local loadstring = loadstring --> lua local
|
||||
|
||||
local cleanfunction = function() end
|
||||
local APIButtonFunctions = false
|
||||
local ButtonMetaFunctions = {}
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
|
||||
ButtonMetaFunctions.__call = function (_table, value, ...)
|
||||
return self.func (_table.param1, _table.param2, value, ...)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--> tooltip
|
||||
local gmember_tooltip = function (_object)
|
||||
return _object:GetTooltip()
|
||||
end
|
||||
--> shown
|
||||
local gmember_shown = function (_object)
|
||||
return _object:IsShown()
|
||||
end
|
||||
--> frame width
|
||||
local gmember_width = function (_object)
|
||||
return _object.button:GetWidth()
|
||||
end
|
||||
--> frame height
|
||||
local gmember_height = function (_object)
|
||||
return _object.button:GetHeight()
|
||||
end
|
||||
--> text
|
||||
local gmember_text = function (_object)
|
||||
return _object.button.text:GetText()
|
||||
end
|
||||
--> function
|
||||
local gmember_function = function (_object)
|
||||
return _rawget (_object, "func")
|
||||
end
|
||||
--> text color
|
||||
local gmember_textcolor = function (_object)
|
||||
return _object.button.text:GetTextColor()
|
||||
end
|
||||
--> text font
|
||||
local gmember_textfont = function (_object)
|
||||
local fontface = _object.button.text:GetFont()
|
||||
return fontface
|
||||
end
|
||||
--> text size
|
||||
local gmember_textsize = function (_object)
|
||||
local _, fontsize = _object.button.text:GetFont()
|
||||
return fontsize
|
||||
end
|
||||
--> texture
|
||||
local gmember_texture = function (_object)
|
||||
return {_object.button:GetNormalTexture(), _object.button:GetHighlightTexture(), _object.button:GetPushedTexture(), _object.button:GetDisabledTexture()}
|
||||
end
|
||||
--> locked
|
||||
local gmember_locked = function (_object)
|
||||
return _rawget (_object, "is_locked")
|
||||
end
|
||||
|
||||
local get_members_function_index = {
|
||||
["tooltip"] = gmember_tooltip,
|
||||
["shown"] = gmember_shown,
|
||||
["width"] = gmember_width,
|
||||
["height"] = gmember_height,
|
||||
["text"] = gmember_text,
|
||||
["clickfunction"] = gmember_function,
|
||||
["texture"] = gmember_texture,
|
||||
["locked"] = gmember_locked,
|
||||
["fontcolor"] = gmember_textcolor,
|
||||
["fontface"] = gmember_textfont,
|
||||
["fontsize"] = gmember_textsize,
|
||||
["textcolor"] = gmember_textcolor, --alias
|
||||
["textfont"] = gmember_textfont, --alias
|
||||
["textsize"] = gmember_textsize --alias
|
||||
}
|
||||
|
||||
ButtonMetaFunctions.__index = function (_table, _member_requested)
|
||||
|
||||
local func = get_members_function_index [_member_requested]
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = _rawget (_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
return ButtonMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--> tooltip
|
||||
local smember_tooltip = function (_object, _value)
|
||||
return _object:SetTooltip (_value)
|
||||
end
|
||||
--> 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
|
||||
--> frame width
|
||||
local smember_width = function (_object, _value)
|
||||
return _object.button:SetWidth (_value)
|
||||
end
|
||||
--> frame height
|
||||
local smember_height = function (_object, _value)
|
||||
return _object.button:SetHeight (_value)
|
||||
end
|
||||
--> text
|
||||
local smember_text = function (_object, _value)
|
||||
return _object.button.text:SetText (_value)
|
||||
end
|
||||
--> function
|
||||
local smember_function = function (_object, _value)
|
||||
return _rawset (_object, "func", _value)
|
||||
end
|
||||
--> text color
|
||||
local smember_textcolor = function (_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (_value)
|
||||
return _object.button.text:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
--> text font
|
||||
local smember_textfont = function (_object, _value)
|
||||
return _detalhes:SetFontFace (_object.button.text, _value)
|
||||
end
|
||||
--> text size
|
||||
local smember_textsize = function (_object, _value)
|
||||
return _detalhes:SetFontSize (_object.button.text, _value)
|
||||
end
|
||||
--> texture
|
||||
local smember_texture = function (_object, _value)
|
||||
if (_type (_value) == "table") then
|
||||
local _value1, _value2, _value3, _value4 = unpack (_value)
|
||||
if (_value1) then
|
||||
_object.button:SetNormalTexture (_value1)
|
||||
end
|
||||
if (_value2) then
|
||||
_object.button:SetHighlightTexture (_value2, "ADD")
|
||||
end
|
||||
if (_value3) then
|
||||
_object.button:SetPushedTexture (_value3)
|
||||
end
|
||||
if (_value4) then
|
||||
_object.button:SetDisabledTexture (_value4)
|
||||
end
|
||||
else
|
||||
_object.button:SetNormalTexture (_value)
|
||||
_object.button:SetHighlightTexture (_value, "ADD")
|
||||
_object.button:SetPushedTexture (_value)
|
||||
_object.button:SetDisabledTexture (_value)
|
||||
end
|
||||
return
|
||||
end
|
||||
--> locked
|
||||
local smember_locked = function (_object, _value)
|
||||
if (_value) then
|
||||
_object.button:SetMovable (false)
|
||||
return _rawset (_object, "is_locked", true)
|
||||
else
|
||||
_object.button:SetMovable (true)
|
||||
_rawset (_object, "is_locked", false)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local set_members_function_index = {
|
||||
["tooltip"] = smember_tooltip,
|
||||
["show"] = smember_show,
|
||||
["hide"] = smember_hide,
|
||||
["width"] = smember_width,
|
||||
["height"] = smember_height,
|
||||
["text"] = smember_text,
|
||||
["clickfunction"] = smember_function,
|
||||
["textcolor"] = smember_textcolor,
|
||||
["textfont"] = smember_textfont,
|
||||
["textsize"] = smember_textsize,
|
||||
["texture"] = smember_texture,
|
||||
["locked"] = smember_locked,
|
||||
}
|
||||
|
||||
ButtonMetaFunctions.__newindex = function (_table, _key, _value)
|
||||
local func = set_members_function_index [_key]
|
||||
if (func) then
|
||||
return func (_table, _value)
|
||||
else
|
||||
return _rawset (_table, _key, _value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> methods
|
||||
|
||||
--> show & hide
|
||||
function ButtonMetaFunctions:IsShown()
|
||||
return self.button:IsShown()
|
||||
end
|
||||
function ButtonMetaFunctions:Show()
|
||||
return self.button:Show()
|
||||
end
|
||||
function ButtonMetaFunctions:Hide()
|
||||
return self.button:Hide()
|
||||
end
|
||||
|
||||
-- setpoint
|
||||
function ButtonMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
||||
v1, v2, v3, v4, v5 = gump: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
|
||||
|
||||
-- sizes
|
||||
function ButtonMetaFunctions:SetSize (w, h)
|
||||
if (w) then
|
||||
self.button:SetWidth (w)
|
||||
end
|
||||
if (h) then
|
||||
return self.button:SetHeight (h)
|
||||
end
|
||||
end
|
||||
|
||||
-- tooltip
|
||||
function ButtonMetaFunctions:SetTooltip (tooltip)
|
||||
if (tooltip) then
|
||||
return _rawset (self, "have_tooltip", tooltip)
|
||||
else
|
||||
return _rawset (self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
function ButtonMetaFunctions:GetTooltip()
|
||||
return _rawget (self, "have_tooltip")
|
||||
end
|
||||
|
||||
-- functions
|
||||
function ButtonMetaFunctions:SetClickFunction (func, param1, param2, clicktype)
|
||||
if (not clicktype or string.find (string.lower (clicktype), "left")) then
|
||||
if (func) then
|
||||
_rawset (self, "func", func)
|
||||
else
|
||||
_rawset (self, "func", cleanfunction)
|
||||
end
|
||||
|
||||
if (param1) then
|
||||
_rawset (self, "param1", param1)
|
||||
end
|
||||
if (param2) then
|
||||
_rawset (self, "param2", param2)
|
||||
end
|
||||
|
||||
elseif (clicktype or string.find (string.lower (clicktype), "right")) then
|
||||
if (func) then
|
||||
_rawset (self, "funcright", func)
|
||||
else
|
||||
_rawset (self, "funcright", cleanfunction)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- text
|
||||
function ButtonMetaFunctions:SetText (text)
|
||||
if (text) then
|
||||
self.button.text:SetText (text)
|
||||
else
|
||||
self.button.text:SetText (nil)
|
||||
end
|
||||
end
|
||||
|
||||
-- textcolor
|
||||
function ButtonMetaFunctions:SetTextColor (color)
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (color)
|
||||
return self.button.text:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
|
||||
-- textsize
|
||||
function ButtonMetaFunctions:SetTextSize (size)
|
||||
return _detalhes:SetFontSize (self.button.text, _value)
|
||||
end
|
||||
|
||||
-- textfont
|
||||
function ButtonMetaFunctions:SetTextFont (font)
|
||||
return _detalhes:SetFontFace (_object.button.text, _value)
|
||||
end
|
||||
|
||||
-- textures
|
||||
function ButtonMetaFunctions:SetTexture (normal, highlight, pressed, disabled)
|
||||
if (normal) then
|
||||
self.button:SetNormalTexture (normal)
|
||||
elseif (_type (normal) ~= "boolean") then
|
||||
self.button:SetNormalTexture (nil)
|
||||
end
|
||||
|
||||
if (_type (highlight) == "boolean") then
|
||||
if (highlight and normal and _type (normal) ~= "boolean") then
|
||||
self.button:SetHighlightTexture (normal, "ADD")
|
||||
end
|
||||
elseif (highlight == nil) then
|
||||
self.button:SetHighlightTexture (nil)
|
||||
else
|
||||
self.button:SetHighlightTexture (highlight, "ADD")
|
||||
end
|
||||
|
||||
if (_type (pressed) == "boolean") then
|
||||
if (pressed and normal and _type (normal) ~= "boolean") then
|
||||
self.button:SetPushedTexture (normal)
|
||||
end
|
||||
elseif (pressed == nil) then
|
||||
self.button:SetPushedTexture (nil)
|
||||
else
|
||||
self.button:SetPushedTexture (pressed, "ADD")
|
||||
end
|
||||
|
||||
if (_type (disabled) == "boolean") then
|
||||
if (disabled and normal and _type (normal) ~= "boolean") then
|
||||
self.button:SetDisabledTexture (normal)
|
||||
end
|
||||
elseif (disabled == nil) then
|
||||
self.button:SetDisabledTexture (nil)
|
||||
else
|
||||
self.button:SetDisabledTexture (disabled, "ADD")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- frame levels
|
||||
function ButtonMetaFunctions:GetFrameLevel()
|
||||
return self.button:GetFrameLevel()
|
||||
end
|
||||
function ButtonMetaFunctions:SetFrameLevel (level, frame)
|
||||
if (not frame) then
|
||||
return self.button:SetFrameLevel (level)
|
||||
else
|
||||
local framelevel = frame:GetFrameLevel (frame) + level
|
||||
return self.button:SetFrameLevel (framelevel)
|
||||
end
|
||||
end
|
||||
|
||||
-- frame stratas
|
||||
function ButtonMetaFunctions:SetFrameStrata()
|
||||
return self.button:GetFrameStrata()
|
||||
end
|
||||
function ButtonMetaFunctions:SetFrameStrata (strata)
|
||||
if (_type (strata) == "table") then
|
||||
self.button:SetFrameStrata (strata:GetFrameStrata())
|
||||
else
|
||||
self.button:SetFrameStrata (strata)
|
||||
end
|
||||
end
|
||||
|
||||
-- enabled
|
||||
function ButtonMetaFunctions:IsEnabled()
|
||||
return self.button:IsEnabled()
|
||||
end
|
||||
function ButtonMetaFunctions:Enable()
|
||||
return self.button:Enable()
|
||||
end
|
||||
function ButtonMetaFunctions:Disable()
|
||||
return self.button:Disable()
|
||||
end
|
||||
|
||||
-- exec
|
||||
function ButtonMetaFunctions:Exec()
|
||||
return self.func (self.param1, self.param2)
|
||||
end
|
||||
function ButtonMetaFunctions:Click()
|
||||
return self.func (self.param1, self.param2)
|
||||
end
|
||||
function ButtonMetaFunctions:RightClick()
|
||||
return self.funcright()
|
||||
end
|
||||
|
||||
--> hooks
|
||||
function ButtonMetaFunctions:SetHook (hookType, func)
|
||||
if (func) then
|
||||
_rawset (self, hookType.."Hook", func)
|
||||
else
|
||||
_rawset (self, hookType.."Hook", nil)
|
||||
end
|
||||
end
|
||||
|
||||
--> custom textures
|
||||
function ButtonMetaFunctions:InstallCustomTexture (texture, rect)
|
||||
|
||||
self.button:SetNormalTexture (nil)
|
||||
self.button:SetPushedTexture (nil)
|
||||
self.button:SetDisabledTexture (nil)
|
||||
self.button:SetHighlightTexture (nil)
|
||||
|
||||
texture = texture or "Interface\\AddOns\\Details\\images\\default_button"
|
||||
self.button.texture = self.button:CreateTexture (nil, "background")
|
||||
|
||||
if (not rect) then
|
||||
self.button.texture:SetAllPoints (self.button)
|
||||
else
|
||||
self.button.texture:SetPoint ("topleft", self.button, "topleft", rect.x1, rect.y1)
|
||||
self.button.texture:SetPoint ("bottomright", self.button, "bottomright", rect.x2, rect.y2)
|
||||
end
|
||||
|
||||
self.button.texture:SetTexCoord (0, 1, 0, 0.24609375)
|
||||
self.button.texture:SetTexture (texture)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> scripts
|
||||
|
||||
local OnEnter = function (button)
|
||||
|
||||
if (button.MyObject.OnEnterHook) then
|
||||
local interrupt = button.MyObject.OnEnterHook (button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (button.texture) then
|
||||
button.texture:SetTexCoord (0, 1, 0.25+(0.0078125/2), 0.5+(0.0078125/2))
|
||||
end
|
||||
|
||||
if (button.MyObject.have_tooltip) then
|
||||
GameCooltip:Reset()
|
||||
GameCooltip:AddLine (button.MyObject.have_tooltip)
|
||||
GameCooltip:ShowCooltip (button, "tooltip")
|
||||
end
|
||||
|
||||
local parent = button:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnLeave = function (button)
|
||||
if (button.MyObject.OnLeaveHook) then
|
||||
local interrupt = button.MyObject.OnLeaveHook (button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (button.texture) then
|
||||
button.texture:SetTexCoord (0, 1, 0, 0.24609375)
|
||||
end
|
||||
|
||||
if (button.MyObject.have_tooltip) then
|
||||
_detalhes.popup:ShowMe (false)
|
||||
end
|
||||
|
||||
local parent = button:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient (false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnHide = function (button)
|
||||
if (button.MyObject.OnHideHook) then
|
||||
local interrupt = button.MyObject.OnHideHook (button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnShow = function (button)
|
||||
if (button.MyObject.OnShowHook) then
|
||||
local interrupt = button.MyObject.OnShowHook (button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnMouseDown = function (button, buttontype)
|
||||
if (not button:IsEnabled()) then
|
||||
return
|
||||
end
|
||||
|
||||
if (button.MyObject.OnMouseDownHook) then
|
||||
local interrupt = button.MyObject.OnMouseDownHook (button, buttontype)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
button.text:SetPoint ("center", button,"center", 1, -1)
|
||||
|
||||
button.mouse_down = GetTime()
|
||||
local x, y = GetCursorPosition()
|
||||
button.x = _math_floor (x)
|
||||
button.y = _math_floor (y)
|
||||
|
||||
if (not button.MyObject.container.isLocked and button.MyObject.container:IsMovable()) then
|
||||
if (not button.isLocked and button:IsMovable()) then
|
||||
button.MyObject.container.isMoving = true
|
||||
button.MyObject.container:StartMoving()
|
||||
end
|
||||
end
|
||||
|
||||
if (button.MyObject.options.OnGrab) then
|
||||
if (_type (button.MyObject.options.OnGrab) == "string" and button.MyObject.options.OnGrab == "PassClick") then
|
||||
if (buttontype == "LeftButton") then
|
||||
button.MyObject.func (button.MyObject.param1, button.MyObject.param2)
|
||||
else
|
||||
button.MyObject.funcright (button.MyObject.param1, button.MyObject.param2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnMouseUp = function (button, buttontype)
|
||||
if (not button:IsEnabled()) then
|
||||
return
|
||||
end
|
||||
|
||||
if (button.MyObject.OnMouseUpHook) then
|
||||
local interrupt = button.MyObject.OnMouseUpHook (button, buttontype)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
button.text:SetPoint ("center", button,"center", 0, 0)
|
||||
|
||||
if (button.MyObject.container.isMoving) then
|
||||
button.MyObject.container:StopMovingOrSizing()
|
||||
button.MyObject.container.isMoving = false
|
||||
end
|
||||
|
||||
local x, y = GetCursorPosition()
|
||||
x = _math_floor (x)
|
||||
y = _math_floor (y)
|
||||
if ((button.mouse_down+0.4 > GetTime() and (x == button.x and y == button.y)) or (x == button.x and y == button.y)) then
|
||||
if (buttontype == "LeftButton") then
|
||||
button.MyObject.func (button.MyObject.param1, button.MyObject.param2, button)
|
||||
else
|
||||
button.MyObject.funcright (button.MyObject.param1, button.MyObject.param2, button)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
|
||||
function gump:NewButton (parent, container, name, member, w, h, func, param1, param2, texture, text)
|
||||
|
||||
if (not name) then
|
||||
return nil
|
||||
elseif (not parent) then
|
||||
return nil
|
||||
end
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
name = name:gsub ("$parent", parent:GetName())
|
||||
end
|
||||
|
||||
|
||||
local ButtonObject = {type = "button", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = ButtonObject
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
--> default members:
|
||||
--> hooks
|
||||
ButtonObject.OnEnterHook = nil
|
||||
ButtonObject.OnLeaveHook = nil
|
||||
ButtonObject.OnHideHook = nil
|
||||
ButtonObject.OnShowHook = nil
|
||||
ButtonObject.OnMouseDownHook = nil
|
||||
ButtonObject.OnMouseUpHook = nil
|
||||
--> misc
|
||||
ButtonObject.is_locked = true
|
||||
ButtonObject.container = container
|
||||
ButtonObject.have_tooltip = nil
|
||||
ButtonObject.options = {OnGrab = false}
|
||||
|
||||
|
||||
ButtonObject.button = CreateFrame ("button", name, parent, "DetailsButtonTemplate")
|
||||
ButtonObject.widget = ButtonObject.button
|
||||
|
||||
if (not APIButtonFunctions) then
|
||||
APIButtonFunctions = true
|
||||
local idx = getmetatable (ButtonObject.button).__index
|
||||
for funcName, funcAddress in pairs (idx) do
|
||||
if (not ButtonMetaFunctions [funcName]) then
|
||||
ButtonMetaFunctions [funcName] = function (object, ...)
|
||||
local x = loadstring ( "return _G."..object.button:GetName()..":"..funcName.."(...)")
|
||||
return x (...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ButtonObject.button:SetWidth (w or 100)
|
||||
ButtonObject.button:SetHeight (h or 20)
|
||||
ButtonObject.button.MyObject = ButtonObject
|
||||
|
||||
ButtonObject.text_overlay = _G [name .. "_Text"]
|
||||
ButtonObject.disabled_overlay = _G [name .. "_TextureDisabled"]
|
||||
|
||||
ButtonObject.button:SetNormalTexture (texture)
|
||||
ButtonObject.button:SetPushedTexture (texture)
|
||||
ButtonObject.button:SetDisabledTexture (texture)
|
||||
ButtonObject.button:SetHighlightTexture (texture, "ADD")
|
||||
|
||||
ButtonObject.button.text:SetText (text)
|
||||
|
||||
ButtonObject.func = func or cleanfunction
|
||||
ButtonObject.funcright = cleanfunction
|
||||
ButtonObject.param1 = param1
|
||||
ButtonObject.param2 = param2
|
||||
|
||||
--> hooks
|
||||
ButtonObject.button:SetScript ("OnEnter", OnEnter)
|
||||
ButtonObject.button:SetScript ("OnLeave", OnLeave)
|
||||
ButtonObject.button:SetScript ("OnHide", OnHide)
|
||||
ButtonObject.button:SetScript ("OnShow", OnShow)
|
||||
ButtonObject.button:SetScript ("OnMouseDown", OnMouseDown)
|
||||
ButtonObject.button:SetScript ("OnMouseUp", OnMouseUp)
|
||||
|
||||
_setmetatable (ButtonObject, ButtonMetaFunctions)
|
||||
|
||||
return ButtonObject
|
||||
|
||||
end
|
||||
@@ -0,0 +1,40 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ .. \FrameXML\UI.xsd">
|
||||
<Script file="button.lua"/>
|
||||
|
||||
<Button name="DetailsButtonTemplate" virtual="true">
|
||||
<Size x="100" y="20"/>
|
||||
|
||||
<Layers>
|
||||
|
||||
<Layer level="ARTWORK">
|
||||
|
||||
<!-- text -->
|
||||
<FontString name="$parent_Text" parentKey="text" inherits="GameFontNormal" justifyH="CENTER" nonspacewrap="false">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="CENTER" relativeTo="$parent" relativePoint="CENTER" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
|
||||
</Layer>
|
||||
|
||||
<Layer level="OVERLAY">
|
||||
<Texture name="$parent_TextureDisabled" setAllPoints="true" hidden="true" parentKey="texture_disabled" file = "Interface\AddOns\Details\images\button_disable_overlay"/>
|
||||
</Layer>
|
||||
|
||||
</Layers>
|
||||
|
||||
<Scripts>
|
||||
|
||||
<OnDisable>
|
||||
self.texture_disabled:Show()
|
||||
</OnDisable>
|
||||
|
||||
<OnEnable>
|
||||
self.texture_disabled:Hide()
|
||||
</OnEnable>
|
||||
|
||||
</Scripts>
|
||||
|
||||
</Button>
|
||||
</Ui>
|
||||
@@ -0,0 +1,150 @@
|
||||
do
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
gump.alias_text_colors = {
|
||||
["aliceblue"] = {0.941176, 0.972549, 1, 1},
|
||||
["antiquewhite"] = {0.980392, 0.921569, 0.843137, 1},
|
||||
["aqua"] = {0, 1, 1, 1},
|
||||
["aquamarine"] = {0.498039, 1, 0.831373, 1},
|
||||
["azure"] = {0.941176, 1, 1, 1},
|
||||
["beige"] = {0.960784, 0.960784, 0.862745, 1},
|
||||
["bisque"] = {1, 0.894118, 0.768627, 1},
|
||||
["black"] = {0, 0, 0, 1},
|
||||
["blanchedalmond"] = {1, 0.921569, 0.803922, 1},
|
||||
["blue"] = {0, 0, 1, 1},
|
||||
["blueviolet"] = {0.541176, 0.168627, 0.886275, 1},
|
||||
["brown"] = {0.647059, 0.164706, 0.164706, 1},
|
||||
["burlywood"] = {0.870588, 0.721569, 0.529412, 1},
|
||||
["cadetblue"] = {0.372549, 0.619608, 0.627451, 1},
|
||||
["chartreuse"] = {0.498039, 1, 0, 1},
|
||||
["chocolate"] = {0.823529, 0.411765, 0.117647, 1},
|
||||
["coral"] = {1, 0.498039, 0.313725, 1},
|
||||
["cornflowerblue"] = {0.392157, 0.584314, 0.929412, 1},
|
||||
["cornsilk"] = {1, 0.972549, 0.862745, 1},
|
||||
["crimson"] = {0.862745, 0.0784314, 0.235294, 1},
|
||||
["cyan"] = {0, 1, 1, 1},
|
||||
["darkblue"] = {0, 0, 0.545098, 1},
|
||||
["darkcyan"] = {0, 0.545098, 0.545098, 1},
|
||||
["darkgoldenrod"] = {0.721569, 0.52549, 0.0431373, 1},
|
||||
["darkgray"] = {0.662745, 0.662745, 0.662745, 1},
|
||||
["darkgreen"] = {0, 0.392157, 0, 1},
|
||||
["darkkhaki"] = {0.741176, 0.717647, 0.419608, 1},
|
||||
["darkmagenta"] = {0.545098, 0, 0.545098, 1},
|
||||
["darkolivegreen"] = {0.333333, 0.419608, 0.184314, 1},
|
||||
["darkorange"] = {1, 0.54902, 0, 1},
|
||||
["darkorchid"] = {0.6, 0.196078, 0.8, 1},
|
||||
["darkred"] = {0.545098, 0, 0, 1},
|
||||
["darksalmon"] = {0.913725, 0.588235, 0.478431, 1},
|
||||
["darkseagreen"] = {0.560784, 0.737255, 0.560784, 1},
|
||||
["darkslateblue"] = {0.282353, 0.239216, 0.545098, 1},
|
||||
["darkslategray"] = {0.184314, 0.309804, 0.309804, 1},
|
||||
["darkturquoise"] = {0, 0.807843, 0.819608, 1},
|
||||
["darkviolet"] = {0.580392, 0, 0.827451, 1},
|
||||
["deeppink"] = {1, 0.0784314, 0.576471, 1},
|
||||
["deepskyblue"] = {0, 0.74902, 1, 1},
|
||||
["dimgray"] = {0.411765, 0.411765, 0.411765, 1},
|
||||
["dimgrey"] = {0.411765, 0.411765, 0.411765, 1},
|
||||
["dodgerblue"] = {0.117647, 0.564706, 1, 1},
|
||||
["firebrick"] = {0.698039, 0.133333, 0.133333, 1},
|
||||
["floralwhite"] = {1, 0.980392, 0.941176, 1},
|
||||
["forestgreen"] = {0.133333, 0.545098, 0.133333, 1},
|
||||
["fuchsia"] = {1, 0, 1, 1},
|
||||
["gainsboro"] = {0.862745, 0.862745, 0.862745, 1},
|
||||
["ghostwhite"] = {0.972549, 0.972549, 1, 1},
|
||||
["gold"] = {1, 0.843137, 0, 1},
|
||||
["goldenrod"] = {0.854902, 0.647059, 0.12549, 1},
|
||||
["gray"] = {0.501961, 0.501961, 0.501961, 1},
|
||||
["green"] = {0, 0.501961, 0, 1},
|
||||
["greenyellow"] = {0.678431, 1, 0.184314, 1},
|
||||
["honeydew"] = {0.941176, 1, 0.941176, 1},
|
||||
["hotpink"] = {1, 0.411765, 0.705882, 1},
|
||||
["indianred"] = {0.803922, 0.360784, 0.360784, 1},
|
||||
["indigo"] = {0.294118, 0, 0.509804, 1},
|
||||
["ivory"] = {1, 1, 0.941176, 1},
|
||||
["khaki"] = {0.941176, 0.901961, 0.54902, 1},
|
||||
["lavender"] = {0.901961, 0.901961, 0.980392, 1},
|
||||
["lavenderblush"] = {1, 0.941176, 0.960784, 1},
|
||||
["lawngreen"] = {0.486275, 0.988235, 0, 1},
|
||||
["lemonchiffon"] = {1, 0.980392, 0.803922, 1},
|
||||
["lightblue"] = {0.678431, 0.847059, 0.901961, 1},
|
||||
["lightcoral"] = {0.941176, 0.501961, 0.501961, 1},
|
||||
["lightcyan"] = {0.878431, 1, 1, 1},
|
||||
["lightgoldenrodyellow"] = {0.980392, 0.980392, 0.823529, 1},
|
||||
["lightgray"] = {0.827451, 0.827451, 0.827451, 1},
|
||||
["lightgreen"] = {0.564706, 0.933333, 0.564706, 1},
|
||||
["lightpink"] = {1, 0.713725, 0.756863, 1},
|
||||
["lightsalmon"] = {1, 0.627451, 0.478431, 1},
|
||||
["lightseagreen"] = {0.12549, 0.698039, 0.666667, 1},
|
||||
["lightskyblue"] = {0.529412, 0.807843, 0.980392, 1},
|
||||
["lightslategray"] = {0.466667, 0.533333, 0.6, 1},
|
||||
["lightsteelblue"] = {0.690196, 0.768627, 0.870588, 1},
|
||||
["lightyellow"] = {1, 1, 0.878431, 1},
|
||||
["lime"] = {0, 1, 0, 1},
|
||||
["limegreen"] = {0.196078, 0.803922, 0.196078, 1},
|
||||
["linen"] = {0.980392, 0.941176, 0.901961, 1},
|
||||
["magenta"] = {1, 0, 1, 1},
|
||||
["maroon"] = {0.501961, 0, 0, 1},
|
||||
["mediumaquamarine"] = {0.4, 0.803922, 0.666667, 1},
|
||||
["mediumblue"] = {0, 0, 0.803922, 1},
|
||||
["mediumorchid"] = {0.729412, 0.333333, 0.827451, 1},
|
||||
["mediumpurple"] = {0.576471, 0.439216, 0.858824, 1},
|
||||
["mediumseagreen"] = {0.235294, 0.701961, 0.443137, 1},
|
||||
["mediumslateblue"] = {0.482353, 0.407843, 0.933333, 1},
|
||||
["mediumspringgreen"] = {0, 0.980392, 0.603922, 1},
|
||||
["mediumturquoise"] = {0.282353, 0.819608, 0.8, 1},
|
||||
["mediumvioletred"] = {0.780392, 0.0823529, 0.521569, 1},
|
||||
["midnightblue"] = {0.0980392, 0.0980392, 0.439216, 1},
|
||||
["mintcream"] = {0.960784, 1, 0.980392, 1},
|
||||
["mistyrose"] = {1, 0.894118, 0.882353, 1},
|
||||
["moccasin"] = {1, 0.894118, 0.709804, 1},
|
||||
["navajowhite"] = {1, 0.870588, 0.678431, 1},
|
||||
["navy"] = {0, 0, 0.501961, 1},
|
||||
["none"] ={0, 0, 0, 0},
|
||||
["oldlace"] = {0.992157, 0.960784, 0.901961, 1},
|
||||
["olive"] = {0.501961, 0.501961, 0, 1},
|
||||
["olivedrab"] = {0.419608, 0.556863, 0.137255, 1},
|
||||
["orange"] = {1, 0.647059, 0, 1},
|
||||
["orangered"] = {1, 0.270588, 0, 1},
|
||||
["orchid"] = {0.854902, 0.439216, 0.839216, 1},
|
||||
["palegoldenrod"] = {0.933333, 0.909804, 0.666667, 1},
|
||||
["palegreen"] = {0.596078, 0.984314, 0.596078, 1},
|
||||
["paleturquoise"] = {0.686275, 0.933333, 0.933333, 1},
|
||||
["palevioletred"] = {0.858824, 0.439216, 0.576471, 1},
|
||||
["papayawhip"] = {1, 0.937255, 0.835294, 1},
|
||||
["peachpuff"] = {1, 0.854902, 0.72549, 1},
|
||||
["peru"] = {0.803922, 0.521569, 0.247059, 1},
|
||||
["pink"] = {1, 0.752941, 0.796078, 1},
|
||||
["plum"] = {0.866667, 0.627451, 0.866667, 1},
|
||||
["powderblue"] = {0.690196, 0.878431, 0.901961, 1},
|
||||
["purple"] = {0.501961, 0, 0.501961, 1},
|
||||
["red"] = {1, 0, 0, 1},
|
||||
["rosybrown"] = {0.737255, 0.560784, 0.560784, 1},
|
||||
["royalblue"] = {0.254902, 0.411765, 0.882353, 1},
|
||||
["saddlebrown"] = {0.545098, 0.270588, 0.0745098, 1},
|
||||
["salmon"] = {0.980392, 0.501961, 0.447059, 1},
|
||||
["sandybrown"] = {0.956863, 0.643137, 0.376471, 1},
|
||||
["seagreen"] = {0.180392, 0.545098, 0.341176, 1},
|
||||
["seashell"] = {1, 0.960784, 0.933333, 1},
|
||||
["sienna"] = {0.627451, 0.321569, 0.176471, 1},
|
||||
["silver"] = {0.752941, 0.752941, 0.752941, 1},
|
||||
["skyblue"] = {0.529412, 0.807843, 0.921569, 1},
|
||||
["slateblue"] = {0.415686, 0.352941, 0.803922, 1},
|
||||
["slategray"] = {0.439216, 0.501961, 0.564706, 1},
|
||||
["snow"] = {1, 0.980392, 0.980392, 1},
|
||||
["springgreen"] = {0, 1, 0.498039, 1},
|
||||
["steelblue"] = {0.27451, 0.509804, 0.705882, 1},
|
||||
["tan"] = {0.823529, 0.705882, 0.54902, 1},
|
||||
["teal"] = {0, 0.501961, 0.501961, 1},
|
||||
["thistle"] = {0.847059, 0.74902, 0.847059, 1},
|
||||
["tomato"] = {1, 0.388235, 0.278431, 1},
|
||||
["transparent"] ={0, 0, 0, 0},
|
||||
["turquoise"] = {0.25098, 0.878431, 0.815686, 1},
|
||||
["violet"] = {0.933333, 0.509804, 0.933333, 1},
|
||||
["wheat"] = {0.960784, 0.870588, 0.701961, 1},
|
||||
["white"] = {1, 1, 1, 1},
|
||||
["whitesmoke"] = {0.960784, 0.960784, 0.960784, 1},
|
||||
["yellow"] = {1, 1, 0, 1},
|
||||
["yellowgreen"] = {0.603922, 0.803922, 0.196078, 1}
|
||||
}
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,194 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ .. \FrameXML\UI.xsd">
|
||||
<Script file="cooltip.lua"/>
|
||||
|
||||
<Frame name="CooltipMainFrameTemplate" virtual="true" frameStrata="TOOLTIP">
|
||||
<Size x="1" y="1"/>
|
||||
<Anchors>
|
||||
<Anchor point="CENTER" relativeTo="$parent" relativePoint="CENTER" x="0" y="0"/>
|
||||
</Anchors>
|
||||
|
||||
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background-Dark" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
|
||||
<EdgeSize>
|
||||
<AbsValue val="16"/>
|
||||
</EdgeSize>
|
||||
<TileSize>
|
||||
<AbsValue val="16"/>
|
||||
</TileSize>
|
||||
<BackgroundInsets>
|
||||
<AbsInset left="5" right="5" top="5" bottom="5"/>
|
||||
</BackgroundInsets>
|
||||
</Backdrop>
|
||||
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
self:SetBackdropColor (0.09019, 0.09019, 0.18823, 1)
|
||||
self:SetBackdropBorderColor (1, 1, 1, 1)
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
|
||||
<Layers>
|
||||
|
||||
<Layer level="BORDER">
|
||||
<!-- frame background -->
|
||||
<Texture name="$parent_FrameBackground" parentKey="framebackground" file = "Interface\AddOns\Details\images\cooltip_selected">
|
||||
<Color a = "1" r = "0" g = "1" b = "0" />
|
||||
<Anchors>
|
||||
<Anchor point="TOP" relativeTo="$parent" relativePoint="TOP" x="0" y="-5"/>
|
||||
<Anchor point="BOTTOM" relativeTo="$parent" relativePoint="BOTTOM" x="0" y="5"/>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="3" y="0"/>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="-3" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="ARTWORK">
|
||||
<!-- selected bar -->
|
||||
<Texture name="$parent_Selected" parentKey="selected" file = "Interface\AddOns\Details\images\cooltip_selected">
|
||||
<Size y="20"/>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="3" y="0"/>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="-3" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="OVERLAY">
|
||||
<!-- title icon -->
|
||||
<Texture name="$parent_TitleIcon" hidden="true" parentKey="titleIcon" file = "Interface\AddOns\Details\images\cooltip_selected">
|
||||
<Anchors>
|
||||
<Anchor point="TOP" relativeTo="$parent" relativePoint="TOP" x="0" y="0"/>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
<!-- title text -->
|
||||
<FontString name="$parent_TitleText" parentKey="titleText" inherits="GameFontHighlightSmall" justifyH="LEFT" nonspacewrap="true">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent_Selected" relativePoint="RIGHT" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
|
||||
</Layers>
|
||||
</Frame>
|
||||
|
||||
<Button name="CooltipButtonTemplate" virtual="true">
|
||||
<Size x="1" y="20"/>
|
||||
|
||||
<Frames>
|
||||
|
||||
<StatusBar name="$Parent_StatusBar" parentKey="statusbar">
|
||||
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="10" y="0"/>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="-10" y="0"/>
|
||||
<Anchor point="TOP" relativeTo="$parent" relativePoint="TOP" x="0" y="0"/>
|
||||
<Anchor point="BOTTOM" relativeTo="$parent" relativePoint="BOTTOM" x="0" y="0"/>
|
||||
</Anchors>
|
||||
|
||||
<Size y="20" />
|
||||
|
||||
<Layers>
|
||||
<Layer level="BACKGROUND">
|
||||
<!-- statusbar texture -->
|
||||
<Texture name="$parent_Texture" hidden="false" parentKey="texture" file = "Interface\PaperDollInfoFrame\UI-Character-Skills-Bar" horizTile="false" vertTile="false">
|
||||
<Size x="300" y="14" />
|
||||
<Color a = "1" r = "1" g = "1" b = "1" />
|
||||
</Texture>
|
||||
<!-- spark -->
|
||||
<Texture name="$parent_Spark" hidden="true" parentKey="spark" file = "Interface\AddOns\Details\images\bar_detalhes2_end">
|
||||
<Size>
|
||||
<AbsDimension x="8" y="18"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="RIGHT" x="-16" y="-1"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="ARTWORK">
|
||||
<!-- background texture -->
|
||||
<Texture name="$parent_Background" hidden="true" parentKey="background" file = "Interface\FriendsFrame\UI-FriendsFrame-HighlightBar" horizTile="false" vertTile="false">
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="-6" y="0"/>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="6" y="0"/>
|
||||
<Anchor point="TOP" relativeTo="$parent" relativePoint="TOP" x="0" y="0"/>
|
||||
<Anchor point="BOTTOM" relativeTo="$parent" relativePoint="BOTTOM" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="OVERLAY">
|
||||
<!-- left icon texture -->
|
||||
<Texture name="$parent_LeftIcon" parentKey="leftIcon">
|
||||
<Size x="16" y="16" />
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
<!-- right icon texture -->
|
||||
<Texture name="$parent_RightIcon" parentKey="rightIcon">
|
||||
<Size x="16" y="16" />
|
||||
<Anchors>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
|
||||
<!-- left text -->
|
||||
<FontString name="$parent_LeftText" parentKey="leftText" inherits="GameFontHighlight" justifyH="LEFT" nonspacewrap="false">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="CENTER" relativeTo="$parent_LeftIcon" relativePoint="CENTER" x="0" y="0"/>
|
||||
<Anchor point="LEFT" relativeTo="$parent_LeftIcon" relativePoint="RIGHT" x="3" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
|
||||
<!-- right text -->
|
||||
<FontString name="$parent_TextRight" parentKey="rightText" inherits="GameFontHighlight" justifyH="RIGHT" nonspacewrap="false">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="CENTER" relativeTo="$parent_RightIcon" relativePoint="CENTER" x="0" y="0"/>
|
||||
<Anchor point="RIGHT" relativeTo="$parent_RightIcon" relativePoint="LEFT" x="-3" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
|
||||
</Layer>
|
||||
|
||||
</Layers>
|
||||
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
self:SetStatusBarTexture (self.texture);
|
||||
<!-- note to my self, never forget statusbar MinMaxValues -->
|
||||
self:SetMinMaxValues (0, 100);
|
||||
self:GetParent().background = self.background
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
|
||||
</StatusBar>
|
||||
|
||||
</Frames>
|
||||
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
self:RegisterForClicks ("LeftButtonDown")
|
||||
self.leftIcon = self.statusbar.leftIcon
|
||||
self.rightIcon = self.statusbar.rightIcon
|
||||
self.texture = self.statusbar.texture
|
||||
self.spark = self.statusbar.spark
|
||||
self.leftText = self.statusbar.leftText
|
||||
self.rightText = self.statusbar.rightText
|
||||
</OnLoad>
|
||||
|
||||
<OnMouseDown>
|
||||
GameCooltipButtonMouseDown (self);
|
||||
</OnMouseDown>
|
||||
|
||||
<OnMouseUp>
|
||||
GameCooltipButtonMouseUp (self);
|
||||
</OnMouseUp>
|
||||
|
||||
</Scripts>
|
||||
</Button>
|
||||
|
||||
</Ui>
|
||||
@@ -0,0 +1,770 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
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
|
||||
local loadstring = loadstring --> lua local
|
||||
local _string_len = string.len --> lua local
|
||||
|
||||
local cleanfunction = function() end
|
||||
local APIDropDownFunctions = false
|
||||
local DropDownMetaFunctions = {}
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
|
||||
DropDownMetaFunctions.__call = function (_table, value)
|
||||
--> unknow
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--> selected value
|
||||
local gmember_value = function (_object)
|
||||
return _object:GetValue()
|
||||
end
|
||||
--> tooltip
|
||||
local gmember_tooltip = function (_object)
|
||||
return _object:GetTooltip()
|
||||
end
|
||||
--> shown
|
||||
local gmember_shown = function (_object)
|
||||
return _object:IsShown()
|
||||
end
|
||||
--> frame width
|
||||
local gmember_width = function (_object)
|
||||
return _object.button:GetWidth()
|
||||
end
|
||||
--> frame height
|
||||
local gmember_height = function (_object)
|
||||
return _object.button:GetHeight()
|
||||
end
|
||||
--> current text
|
||||
local gmember_text = function (_object)
|
||||
return _object.label:GetText()
|
||||
end
|
||||
--> menu creation function
|
||||
local gmember_function = function (_object)
|
||||
return _object:GetFunction()
|
||||
end
|
||||
--> menu width
|
||||
local gmember_menuwidth = function (_object)
|
||||
return _rawget (self, "realsizeW")
|
||||
end
|
||||
--> menu height
|
||||
local gmember_menuheight = function (_object)
|
||||
return _rawget (self, "realsizeH")
|
||||
end
|
||||
|
||||
local get_members_function_index = {
|
||||
["value"] = gmember_value,
|
||||
["text"] = gmember_text,
|
||||
["shown"] = gmember_shown,
|
||||
["width"] = gmember_width,
|
||||
["menuwidth"] = gmember_menuwidth,
|
||||
["height"] = gmember_height,
|
||||
["menuheight"] = gmember_menuheight,
|
||||
["tooltip"] = gmember_tooltip,
|
||||
["func"] = gmember_function,
|
||||
}
|
||||
|
||||
DropDownMetaFunctions.__index = function (_table, _member_requested)
|
||||
|
||||
local func = get_members_function_index [_member_requested]
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = _rawget (_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
return DropDownMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--> tooltip
|
||||
local smember_tooltip = function (_object, _value)
|
||||
return _object:SetTooltip (_value)
|
||||
end
|
||||
--> 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
|
||||
--> frame width
|
||||
local smember_width = function (_object, _value)
|
||||
return _object.dropdown:SetWidth (_value)
|
||||
end
|
||||
--> frame height
|
||||
local smember_height = function (_object, _value)
|
||||
return _object.dropdown:SetHeight (_value)
|
||||
end
|
||||
--> menu creation function
|
||||
local smember_function = function (_object, _value)
|
||||
return _object:SetFunction (_value)
|
||||
end
|
||||
--> menu width
|
||||
local smember_menuwidth = function (_object, _value)
|
||||
_object:SetMenuSize (_value, nil)
|
||||
end
|
||||
--> menu height
|
||||
local smember_menuheight = function (_object, _value)
|
||||
_object:SetMenuSize (nil, _value)
|
||||
end
|
||||
|
||||
local set_members_function_index = {
|
||||
["tooltip"] = smember_tooltip,
|
||||
["show"] = smember_show,
|
||||
["hide"] = smember_hide,
|
||||
["width"] = smember_width,
|
||||
["menuwidth"] = smember_menuwidth,
|
||||
["height"] = smember_height,
|
||||
["menuheight"] = smember_menuheight,
|
||||
["func"] = smember_function,
|
||||
}
|
||||
|
||||
DropDownMetaFunctions.__newindex = function (_table, _key, _value)
|
||||
local func = set_members_function_index [_key]
|
||||
if (func) then
|
||||
return func (_table, _value)
|
||||
else
|
||||
return _rawset (_table, _key, _value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> methods
|
||||
function DropDownMetaFunctions:IsShown()
|
||||
return self.dropdown:IsShown()
|
||||
end
|
||||
function DropDownMetaFunctions:Show()
|
||||
return self.dropdown:Show()
|
||||
end
|
||||
function DropDownMetaFunctions:Hide()
|
||||
return self.dropdown:Hide()
|
||||
end
|
||||
|
||||
--> menu width and height
|
||||
function DropDownMetaFunctions:SetMenuSize (w, h)
|
||||
if (w) then
|
||||
return _rawset (self, "realsizeW", w)
|
||||
end
|
||||
if (h) then
|
||||
return _rawset (self, "realsizeH", h)
|
||||
end
|
||||
end
|
||||
function DropDownMetaFunctions:GetMenuSize()
|
||||
return _rawget (self, "realsizeW"), _rawget (self, "realsizeH")
|
||||
end
|
||||
|
||||
--> function
|
||||
function DropDownMetaFunctions:SetFunction (func)
|
||||
return _rawset (self, "func", func)
|
||||
end
|
||||
function DropDownMetaFunctions:GetFunction()
|
||||
return _rawget (self, "func")
|
||||
end
|
||||
|
||||
--> value
|
||||
function DropDownMetaFunctions:GetValue()
|
||||
return _rawget (self, "myvalue")
|
||||
end
|
||||
function DropDownMetaFunctions:SetValue (value)
|
||||
return _rawset (self, "myvalue", value)
|
||||
end
|
||||
|
||||
--> setpoint
|
||||
function DropDownMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
||||
v1, v2, v3, v4, v5 = gump: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
|
||||
|
||||
--> sizes
|
||||
function DropDownMetaFunctions:SetSize (w, h)
|
||||
if (w) then
|
||||
self.dropdown:SetWidth (w)
|
||||
end
|
||||
if (h) then
|
||||
return self.dropdown:SetHeight (h)
|
||||
end
|
||||
end
|
||||
|
||||
--> tooltip
|
||||
function DropDownMetaFunctions:SetTooltip (tooltip)
|
||||
if (tooltip) then
|
||||
return _rawset (self, "have_tooltip", tooltip)
|
||||
else
|
||||
return _rawset (self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
function DropDownMetaFunctions:GetTooltip()
|
||||
return _rawget (self, "have_tooltip")
|
||||
end
|
||||
|
||||
--> frame levels
|
||||
function DropDownMetaFunctions:GetFrameLevel()
|
||||
return self.dropdown:GetFrameLevel()
|
||||
end
|
||||
function DropDownMetaFunctions:SetFrameLevel (level, frame)
|
||||
if (not frame) then
|
||||
return self.dropdown:SetFrameLevel (level)
|
||||
else
|
||||
local framelevel = frame:GetFrameLevel (frame) + level
|
||||
return self.dropdown:SetFrameLevel (framelevel)
|
||||
end
|
||||
end
|
||||
|
||||
--> frame stratas
|
||||
function DropDownMetaFunctions:SetFrameStrata()
|
||||
return self.dropdown:GetFrameStrata()
|
||||
end
|
||||
function DropDownMetaFunctions:SetFrameStrata (strata)
|
||||
if (_type (strata) == "table") then
|
||||
self.dropdown:SetFrameStrata (strata:GetFrameStrata())
|
||||
else
|
||||
self.dropdown:SetFrameStrata (strata)
|
||||
end
|
||||
end
|
||||
|
||||
--> enabled
|
||||
function DropDownMetaFunctions:IsEnabled()
|
||||
return self.dropdown:IsEnabled()
|
||||
end
|
||||
function DropDownMetaFunctions:Enable()
|
||||
return self.dropdown:Enable()
|
||||
end
|
||||
function DropDownMetaFunctions:Disable()
|
||||
return self.dropdown:Disable()
|
||||
end
|
||||
|
||||
--> fixed value
|
||||
function DropDownMetaFunctions:SetFixedParameter (value)
|
||||
_rawset (self, "FixedValue", value)
|
||||
end
|
||||
|
||||
--> hooks
|
||||
function DropDownMetaFunctions:SetHook (hookType, func)
|
||||
if (func) then
|
||||
_rawset (self, hookType.."Hook", func)
|
||||
else
|
||||
_rawset (self, hookType.."Hook", nil)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> scripts
|
||||
|
||||
local function isOptionVisible (thisOption)
|
||||
if (_type (thisOption.shown) == "boolean" or _type (thisOption.shown) == "function") then
|
||||
if (not thisOption.shown) then
|
||||
return false
|
||||
elseif (not thisOption.shown()) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function DropDownMetaFunctions:Select (optionName, byOptionNumber)
|
||||
local menu = self.func()
|
||||
|
||||
if (byOptionNumber and type (optionName) == "number") then
|
||||
return self:Selected (menu [optionName])
|
||||
end
|
||||
|
||||
for _, thisMenu in ipairs (menu) do
|
||||
if (thisMenu.label == optionName and isOptionVisible (thisMenu)) then
|
||||
return self:Selected (thisMenu)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DropDownMetaFunctions:Selected (_table)
|
||||
|
||||
self.label:SetText (_table.label)
|
||||
self.icon:SetTexture (_table.icon)
|
||||
|
||||
if (_table.icon) then
|
||||
self.label:SetPoint ("left", self.icon, "right", 2, 0)
|
||||
if (_table.texcoord) then
|
||||
self.icon:SetTexCoord (unpack (_table.texcoord))
|
||||
else
|
||||
self.icon:SetTexCoord (0, 1, 0, 1)
|
||||
end
|
||||
else
|
||||
self.label:SetPoint ("left", self.label:GetParent(), "left", 4, 0)
|
||||
end
|
||||
|
||||
self.statusbar:SetTexture (_table.statusbar)
|
||||
|
||||
if (_table.color) then
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (_table.color)
|
||||
self.label:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
else
|
||||
self.label:SetTextColor (1, 1, 1, 1)
|
||||
end
|
||||
|
||||
if (_table.font) then
|
||||
self.label:SetFont (_table.font, 10.5)
|
||||
else
|
||||
self.label:SetFont ("GameFontHighlightSmall", 10.5)
|
||||
end
|
||||
|
||||
self:SetValue (_table.value)
|
||||
|
||||
end
|
||||
|
||||
function DetailsDropDownOptionClick (button)
|
||||
|
||||
--> update name and icon on main frame
|
||||
button.object:Selected (button.table)
|
||||
|
||||
--> close menu frame
|
||||
button.object:Close()
|
||||
|
||||
--> exec function if any
|
||||
if (button.table.onclick) then
|
||||
button.table.onclick (button:GetParent():GetParent():GetParent().MyObject, button.object.FixedValue, button.table.value)
|
||||
end
|
||||
|
||||
--> set the value of selected option in main object
|
||||
button.object.myvalue = button.table.value
|
||||
end
|
||||
|
||||
function DropDownMetaFunctions:Open()
|
||||
self.dropdown.dropdownframe:Show()
|
||||
self.dropdown.dropdownborder:Show()
|
||||
self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Down")
|
||||
self.opened = true
|
||||
end
|
||||
|
||||
function DropDownMetaFunctions:Close()
|
||||
--> when menu is being close, just hide the border and the script will call back this again
|
||||
if (self.dropdown.dropdownborder:IsShown()) then
|
||||
self.dropdown.dropdownborder:Hide()
|
||||
return
|
||||
end
|
||||
self.dropdown.dropdownframe:Hide()
|
||||
self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Up")
|
||||
|
||||
local selectedTexture = _G [self:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
|
||||
selectedTexture:Hide()
|
||||
|
||||
self.opened = false
|
||||
end
|
||||
|
||||
--> close by escape key
|
||||
function DetailsDropDownOptionsFrameOnHide (frame)
|
||||
frame:GetParent().MyObject:Close()
|
||||
end
|
||||
|
||||
function DetailsDropDownOptionOnEnter (frame)
|
||||
if (frame.table.desc) then
|
||||
GameCooltip:Reset()
|
||||
GameCooltip:SetType ("tooltip")
|
||||
GameCooltip:SetColor ("main", "transparent")
|
||||
GameCooltip:AddLine (frame.table.desc)
|
||||
GameCooltip:SetOwner (frame:GetParent():GetParent():GetParent())
|
||||
GameCooltip:ShowCooltip()
|
||||
frame.tooltip = true
|
||||
end
|
||||
frame:GetParent().mouseover:SetPoint ("left", frame)
|
||||
frame:GetParent().mouseover:Show()
|
||||
end
|
||||
|
||||
function DetailsDropDownOptionOnLeave (frame)
|
||||
if (frame.table.desc) then
|
||||
_detalhes.popup:ShowMe (false)
|
||||
end
|
||||
frame:GetParent().mouseover:Hide()
|
||||
end
|
||||
|
||||
function DetailsDropDownOnMouseDown (button)
|
||||
|
||||
local object = button.MyObject
|
||||
|
||||
if (not object.opened) then --> click to open
|
||||
|
||||
local menu = object:func()
|
||||
local frame_witdh = object.realsizeW
|
||||
|
||||
if (menu [1]) then
|
||||
--> build menu
|
||||
|
||||
local scrollFrame = _G [button:GetName() .. "_ScrollFrame"]
|
||||
local scrollChild = _G [button:GetName() .. "_ScrollFrame_ScrollChild"]
|
||||
local scrollBorder = _G [button:GetName() .. "_Border"]
|
||||
local selectedTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
|
||||
local mouseOverTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_MouseOverTexture"]
|
||||
|
||||
local i = 1
|
||||
local showing = 0
|
||||
local currentText = button.text:GetText() or ""
|
||||
|
||||
if (object.OnMouseDownHook) then
|
||||
local interrupt = object.OnMouseDownHook (button, buttontype, menu, scrollFrame, scrollChild, selectedTexture)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
for _, _table in ipairs (menu) do
|
||||
|
||||
local show = isOptionVisible (_table)
|
||||
|
||||
if (show) then
|
||||
local _this_row = object.menus [i]
|
||||
showing = showing + 1
|
||||
|
||||
if (not _this_row) then
|
||||
|
||||
local name = button:GetName() .. "Row" .. i
|
||||
local parent = scrollChild
|
||||
|
||||
_this_row = CreateFrame ("Button", name, parent, "DetailsDropDownOptionTemplate")
|
||||
local anchor_i = i-1
|
||||
_this_row:SetPoint ("topleft", parent, "topleft", 5, (-anchor_i*20)-5)
|
||||
_this_row:SetPoint ("topright", parent, "topright", -5, (-anchor_i*20)-5)
|
||||
_this_row.object = object
|
||||
object.menus [i] = _this_row
|
||||
end
|
||||
|
||||
_this_row.icon:SetTexture (_table.icon)
|
||||
if (_table.icon) then
|
||||
_this_row.label:SetPoint ("left", _this_row.icon, "right", 5, 0)
|
||||
if (_table.texcoord) then
|
||||
_this_row.icon:SetTexCoord (unpack (_table.texcoord))
|
||||
else
|
||||
_this_row.icon:SetTexCoord (0, 1, 0, 1)
|
||||
end
|
||||
else
|
||||
_this_row.label:SetPoint ("left", _this_row.statusbar, "left", 2, 0)
|
||||
end
|
||||
|
||||
if (_table.font) then
|
||||
_this_row.label:SetFont (_table.font, 10.5)
|
||||
else
|
||||
_this_row.label:SetFont ("GameFontHighlightSmall", 10.5)
|
||||
end
|
||||
|
||||
_this_row.statusbar:SetTexture (_table.statusbar)
|
||||
_this_row.label:SetText (_table.label)
|
||||
|
||||
if (currentText and currentText == _table.label) then
|
||||
if (_table.icon) then
|
||||
selectedTexture:SetPoint ("left", _this_row.icon, "right", -5, -2)
|
||||
else
|
||||
selectedTexture:SetPoint ("left", _this_row.statusbar, "left", 0, 0)
|
||||
end
|
||||
|
||||
selectedTexture:Show()
|
||||
selectedTexture:SetVertexColor (1, 1, 1, .3);
|
||||
currentText = nil
|
||||
end
|
||||
|
||||
if (_table.color) then
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (_table.color)
|
||||
_this_row.label:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
else
|
||||
_this_row.label:SetTextColor (1, 1, 1, 1)
|
||||
end
|
||||
|
||||
_this_row.table = _table
|
||||
|
||||
local labelwitdh = _this_row.label:GetStringWidth()
|
||||
if (labelwitdh+40 > frame_witdh) then
|
||||
frame_witdh = labelwitdh+40
|
||||
end
|
||||
_this_row:Show()
|
||||
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if (currentText) then
|
||||
selectedTexture:Hide()
|
||||
else
|
||||
selectedTexture:SetWidth (frame_witdh-20)
|
||||
end
|
||||
|
||||
for i = showing+1, #object.menus do
|
||||
object.menus [i]:Hide()
|
||||
end
|
||||
|
||||
local size = object.realsizeH
|
||||
|
||||
if (showing*20 > size) then
|
||||
--show scrollbar and setup scroll
|
||||
object:ShowScroll()
|
||||
scrollFrame:EnableMouseWheel (true)
|
||||
object.scroll:Altura (size-35)
|
||||
object.scroll:SetMinMaxValues (0, (showing*20) - size + 20)
|
||||
--width
|
||||
scrollBorder:SetWidth (frame_witdh+20)
|
||||
scrollFrame:SetWidth (frame_witdh+20)
|
||||
scrollChild:SetWidth (frame_witdh+20)
|
||||
--height
|
||||
scrollBorder:SetHeight (size+20)
|
||||
scrollFrame:SetHeight (size)
|
||||
scrollChild:SetHeight ((showing*20)+20)
|
||||
--mouse over texture
|
||||
mouseOverTexture:SetWidth (frame_witdh-7)
|
||||
|
||||
for index, row in ipairs (object.menus) do
|
||||
row:SetPoint ("topright", scrollChild, "topright", -22, ((-index-1)*20)-5)
|
||||
end
|
||||
|
||||
else
|
||||
--hide scrollbar and disable wheel
|
||||
object:HideScroll()
|
||||
scrollFrame:EnableMouseWheel (false)
|
||||
--width
|
||||
scrollBorder:SetWidth (frame_witdh)
|
||||
scrollFrame:SetWidth (frame_witdh)
|
||||
scrollChild:SetWidth (frame_witdh)
|
||||
--height
|
||||
scrollBorder:SetHeight ((showing*20) + 25)
|
||||
scrollFrame:SetHeight ((showing*20) + 25)
|
||||
--mouse over texture
|
||||
mouseOverTexture:SetWidth (frame_witdh-10)
|
||||
|
||||
for index, row in ipairs (object.menus) do
|
||||
row:SetPoint ("topright", scrollChild, "topright", -5, ((-index-1)*20)-5)
|
||||
end
|
||||
end
|
||||
|
||||
object:Open()
|
||||
|
||||
else
|
||||
--> clear menu
|
||||
|
||||
end
|
||||
|
||||
else --> click to close
|
||||
|
||||
object:Close()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function DetailsDropDownOnEnter (self)
|
||||
|
||||
if (self.MyObject.OnEnterHook) then
|
||||
local interrupt = self.MyObject.OnEnterHook (self)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
self:SetBackdropColor (.2, .2, .2, .2)
|
||||
self.arrowTexture2:Show()
|
||||
|
||||
if (self.MyObject.have_tooltip) then
|
||||
GameCooltip:Reset()
|
||||
GameCooltip:SetType ("tooltip")
|
||||
GameCooltip:SetColor ("main", "transparent")
|
||||
GameCooltip:AddLine (self.MyObject.have_tooltip)
|
||||
GameCooltip:SetOwner (self)
|
||||
GameCooltip:ShowCooltip()
|
||||
end
|
||||
|
||||
local parent = self:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function DetailsDropDownOnLeave (self)
|
||||
self:SetBackdropColor (1, 1, 1, .5)
|
||||
self.arrowTexture2:Hide()
|
||||
|
||||
if (self.MyObject.OnLeaveHook) then
|
||||
local interrupt = self.MyObject.OnLeaveHook (self)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (self.MyObject.have_tooltip) then
|
||||
_detalhes.popup:ShowMe (false)
|
||||
end
|
||||
|
||||
local parent = self:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient (false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DetailsDropDownOnSizeChanged (self, w, h)
|
||||
self.MyObject.label:SetSize (self:GetWidth()-40, 10)
|
||||
end
|
||||
|
||||
function DetailsDropDownOnShow (self)
|
||||
if (self.MyObject and self.MyObject.OnShowHook) then
|
||||
local interrupt = self.MyObject.OnShowHook (self)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DetailsDropDownOnHide (self)
|
||||
if (self.MyObject and self.MyObject.OnHideHook) then
|
||||
local interrupt = self.MyObject.OnHideHook (self)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
self.MyObject:Close()
|
||||
end
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
|
||||
function gump:NewDropDown (parent, container, name, member, w, h, func, default)
|
||||
|
||||
if (not name) then
|
||||
return nil
|
||||
elseif (not parent) then
|
||||
return nil
|
||||
end
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
name = name:gsub ("$parent", parent:GetName())
|
||||
end
|
||||
|
||||
local DropDownObject = {type = "dropdown", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = DropDownObject
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
default = default or 1
|
||||
|
||||
--> default members:
|
||||
--> hooks
|
||||
DropDownObject.OnEnterHook = nil
|
||||
DropDownObject.OnLeaveHook = nil
|
||||
DropDownObject.OnHideHook = nil
|
||||
DropDownObject.OnShowHook = nil
|
||||
DropDownObject.OnMouseDownHook = nil
|
||||
--> misc
|
||||
DropDownObject.container = container
|
||||
DropDownObject.have_tooltip = nil
|
||||
|
||||
DropDownObject.dropdown = CreateFrame ("Button", name, parent, "DetailsDropDownTemplate")
|
||||
DropDownObject.widget = DropDownObject.dropdown
|
||||
--_G [name] = DropDownObject
|
||||
|
||||
if (not APIDropDownFunctions) then
|
||||
APIDropDownFunctions = true
|
||||
local idx = getmetatable (DropDownObject.dropdown).__index
|
||||
for funcName, funcAddress in pairs (idx) do
|
||||
if (not DropDownMetaFunctions [funcName]) then
|
||||
DropDownMetaFunctions [funcName] = function (object, ...)
|
||||
local x = loadstring ( "return _G."..object.dropdown:GetName()..":"..funcName.."(...)")
|
||||
return x (...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DropDownObject.dropdown.MyObject = DropDownObject
|
||||
|
||||
DropDownObject.dropdown:SetWidth (w)
|
||||
DropDownObject.dropdown:SetHeight (h)
|
||||
|
||||
DropDownObject.func = func
|
||||
DropDownObject.realsizeW = 150
|
||||
DropDownObject.realsizeH = 150
|
||||
DropDownObject.FixedValue = nil
|
||||
DropDownObject.opened = false
|
||||
DropDownObject.menus = {}
|
||||
DropDownObject.myvalue = nil
|
||||
|
||||
DropDownObject.label = _G [name .. "_Text"]
|
||||
|
||||
DropDownObject.icon = _G [name .. "_IconTexture"]
|
||||
DropDownObject.statusbar = _G [name .. "_StatusBarTexture"]
|
||||
DropDownObject.select = _G [name .. "_SelectedTexture"]
|
||||
|
||||
local scroll = _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame"]
|
||||
|
||||
DropDownObject.scroll = gump:NewScrollBar (scroll, _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame".."_ScrollChild"], -20, -18)
|
||||
|
||||
function DropDownObject:HideScroll()
|
||||
scroll.baixo:Hide()
|
||||
scroll.cima:Hide()
|
||||
scroll.slider:Hide()
|
||||
end
|
||||
function DropDownObject:ShowScroll()
|
||||
scroll.baixo:Show()
|
||||
scroll.cima:Show()
|
||||
scroll.slider:Show()
|
||||
end
|
||||
|
||||
DropDownObject:HideScroll()
|
||||
DropDownObject.label:SetSize (DropDownObject.dropdown:GetWidth()-40, 10)
|
||||
|
||||
--> setup class
|
||||
_setmetatable (DropDownObject, DropDownMetaFunctions)
|
||||
|
||||
--> initialize first menu selected
|
||||
local menu = func()
|
||||
for i = default, #menu do
|
||||
local _table = menu [i]
|
||||
if (not _table) then
|
||||
break
|
||||
end
|
||||
if (isOptionVisible (_table)) then
|
||||
DropDownObject:Selected (_table)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return DropDownObject
|
||||
|
||||
end
|
||||
@@ -0,0 +1,238 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ .. \FrameXML\UI.xsd">
|
||||
<Script file="dropdown.lua"/>
|
||||
|
||||
<Button name="DetailsDropDownTemplate" virtual="true">
|
||||
<Size x="150" y="20"/>
|
||||
|
||||
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
|
||||
<EdgeSize>
|
||||
<AbsValue val="10"/>
|
||||
</EdgeSize>
|
||||
<TileSize>
|
||||
<AbsValue val="16"/>
|
||||
</TileSize>
|
||||
<BackgroundInsets>
|
||||
<AbsInset left="1" right="1" top="0" bottom="1"/>
|
||||
</BackgroundInsets>
|
||||
</Backdrop>
|
||||
|
||||
<Layers>
|
||||
|
||||
<Layer level="BACKGROUND">
|
||||
<!-- statusbar texture -->
|
||||
<Texture name="$parent_StatusBarTexture" parentKey="statusbar">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT" x="3" y="-3"/>
|
||||
<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT" x="-3" y="3"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="ARTWORK">
|
||||
<!-- icon texture -->
|
||||
<Texture name="$parent_IconTexture" parentKey="icon" file = "Interface\ICONS\Spell_ChargePositive">
|
||||
<Size x="20" y="20" />
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="2" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
<!-- text -->
|
||||
<FontString name="$parent_Text" parentKey="text" inherits="GameFontHighlightSmall" justifyH="LEFT" nonspacewrap="true">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent_IconTexture" relativePoint="RIGHT" x="5" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
|
||||
<!-- <Texture name="$parent_ArrowTextureDisabled" parentKey="textureDisabled" file = "Interface\Buttons\UI-ScrollBar-UI-ScrollBar-ScrollDownButton-Disabled">
|
||||
<Size x="32" y="32" />
|
||||
</Texture> -->
|
||||
</Layer>
|
||||
|
||||
<Layer level="OVERLAY">
|
||||
<Texture name="$parent_ArrowTexture2" alphaMode="ADD" parentKey="arrowTexture2" file = "Interface\Buttons\UI-ScrollBar-ScrollDownButton-Highlight" hidden="true">
|
||||
<Size x="32" y="28"/>
|
||||
<Anchors>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="5" y="-1"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
<!-- button textures -->
|
||||
<Texture name="$parent_ArrowTexture" parentKey="arrowTexture" file = "Interface\Buttons\UI-ScrollBar-ScrollDownButton-Up">
|
||||
<Size x="32" y="28"/>
|
||||
<Anchors>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="5" y="-1"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
</Layers>
|
||||
|
||||
<Frames>
|
||||
|
||||
<Frame name="$Parent_Border" parentKey="dropdownborder" hidden="true">
|
||||
<Size x="150" y="170"/>
|
||||
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativeTo="$Parent" relativePoint="BOTTOMLEFT"/>
|
||||
</Anchors>
|
||||
|
||||
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background-Dark" edgeFile="Interface\Buttons\UI-SliderBar-Border" tile="true">
|
||||
<EdgeSize>
|
||||
<AbsValue val="10"/>
|
||||
</EdgeSize>
|
||||
<TileSize>
|
||||
<AbsValue val="256"/>
|
||||
</TileSize>
|
||||
<BackgroundInsets>
|
||||
<AbsInset left="0" right="0" top="5" bottom="5"/>
|
||||
</BackgroundInsets>
|
||||
</Backdrop>
|
||||
|
||||
<Scripts>
|
||||
<OnHide>
|
||||
DetailsDropDownOptionsFrameOnHide (self);
|
||||
</OnHide>
|
||||
<OnLoad>
|
||||
self:SetBackdropColor (1, 1, 1, 1);
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
|
||||
</Frame>
|
||||
|
||||
<ScrollFrame name="$Parent_ScrollFrame" parentKey="dropdownframe" hidden="true">
|
||||
<Size x="150" y="150"/>
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativeTo="$Parent" relativePoint="BOTTOMLEFT" x="0" y="-10" />
|
||||
</Anchors>
|
||||
|
||||
<ScrollChild>
|
||||
<Frame name="$Parent_ScrollChild">
|
||||
|
||||
<Size x="150" y="150"/>
|
||||
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativeTo="$Parent" relativePoint="TOPLEFT" x="0" y="0" />
|
||||
</Anchors>
|
||||
|
||||
<Layers>
|
||||
<Layer level="BACKGROUND">
|
||||
<!-- selected texture -->
|
||||
<Texture name="$parent_SelectedTexture" parentKey="selected" hidden="true" file="Interface\SPELLBOOK\Spellbook-Parts">
|
||||
<Size x="150" y="35" />
|
||||
<TexCoords left="0.31250000" right="0.78515625" top="0.00390625" bottom="0.36328125"/>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="2" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="ARTWORK">
|
||||
<!-- mouse over texture -->
|
||||
<Texture name="$parent_MouseOverTexture" alphaMode="ADD" parentKey="mouseover" hidden="true" file="Interface\Buttons\UI-Listbox-Highlight">
|
||||
<Size x="150" y="15" />
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="2" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
</Layers>
|
||||
|
||||
</Frame>
|
||||
|
||||
</ScrollChild>
|
||||
|
||||
</ScrollFrame>
|
||||
|
||||
</Frames>
|
||||
|
||||
<Scripts>
|
||||
|
||||
<OnLoad>
|
||||
self:SetBackdropColor (1, 1, 1, .5);
|
||||
self.arrowTexture:SetDrawLayer ("OVERLAY", 1);
|
||||
self.arrowTexture2:SetDrawLayer ("OVERLAY", 2);
|
||||
|
||||
tinsert (UISpecialFrames, self.dropdownborder:GetName());
|
||||
tinsert (UISpecialFrames, self.dropdownframe:GetName());
|
||||
</OnLoad>
|
||||
|
||||
<OnShow>
|
||||
DetailsDropDownOnShow (self);
|
||||
</OnShow>
|
||||
|
||||
<OnHide>
|
||||
DetailsDropDownOnHide (self);
|
||||
</OnHide>
|
||||
|
||||
<OnEnter>
|
||||
DetailsDropDownOnEnter (self);
|
||||
</OnEnter>
|
||||
|
||||
<OnLeave>
|
||||
DetailsDropDownOnLeave (self);
|
||||
</OnLeave>
|
||||
|
||||
<OnSizeChanged>
|
||||
DetailsDropDownOnSizeChanged (self);
|
||||
</OnSizeChanged>
|
||||
|
||||
<OnMouseDown>
|
||||
DetailsDropDownOnMouseDown (self);
|
||||
</OnMouseDown>
|
||||
</Scripts>
|
||||
|
||||
</Button>
|
||||
|
||||
<Button name="DetailsDropDownOptionTemplate" virtual="true">
|
||||
<Size x="150" y="20" />
|
||||
|
||||
<Layers>
|
||||
|
||||
<Layer level="ARTWORK">
|
||||
<!-- statusbar texture -->
|
||||
<Texture name="$parent_StatusBarTexture" parentKey="statusbar">
|
||||
<Size x="150" y="20" />
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="0" y="0"/>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="OVERLAY">
|
||||
<!-- icon texture -->
|
||||
<Texture name="$parent_IconTexture" parentKey="icon" file = "Interface\ICONS\Spell_ChargePositive">
|
||||
<Size x="20" y="20" />
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="2" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
<!-- text -->
|
||||
<FontString name="$parent_Text" parentKey="label" inherits="GameFontHighlightSmall" justifyH="LEFT" nonspacewrap="false">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent_IconTexture" relativePoint="RIGHT" x="5" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
</Layers>
|
||||
|
||||
<Scripts>
|
||||
<OnMouseDown>
|
||||
DetailsDropDownOptionClick (self);
|
||||
</OnMouseDown>
|
||||
|
||||
<OnEnter>
|
||||
DetailsDropDownOptionOnEnter (self);
|
||||
</OnEnter>
|
||||
|
||||
<OnLeave>
|
||||
DetailsDropDownOptionOnLeave (self);
|
||||
</OnLeave>
|
||||
|
||||
</Scripts>
|
||||
|
||||
</Button>
|
||||
|
||||
</Ui>
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
local _type = type
|
||||
local _unpack = unpack
|
||||
|
||||
gump.LabelNameCounter = 1
|
||||
gump.PictureNameCounter = 1
|
||||
|
||||
gump.debug = false
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--> points
|
||||
function gump:CheckPoints (v1, v2, v3, v4, v5, object)
|
||||
|
||||
--bg_esq:SetPoint ("topleft", DmgRankFrame, 10, -215)
|
||||
|
||||
if (not v1 and not v2) then
|
||||
return "topleft", object.widget:GetParent(), "topleft", 0, 0
|
||||
end
|
||||
|
||||
if (_type (v1) == "string") then
|
||||
local frameGlobal = _G [v1]
|
||||
if (frameGlobal and frameGlobal.GetObjectType) then
|
||||
return gump:CheckPoints (frameGlobal, v2, v3, v4, v5, object)
|
||||
end
|
||||
|
||||
elseif (_type (v2) == "string") then
|
||||
local frameGlobal = _G [v2]
|
||||
if (frameGlobal and frameGlobal.GetObjectType) then
|
||||
return gump:CheckPoints (v1, frameGlobal, v3, v4, v5, object)
|
||||
end
|
||||
end
|
||||
|
||||
if (_type (v1) == "string" and _type (v2) == "table") then --> :setpoint ("left", frame, _, _, _)
|
||||
if (not v3 or _type (v3) == "number") then --> :setpoint ("left", frame, 10, 10)
|
||||
v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4
|
||||
--else
|
||||
--> :setpoint ("left", frame, "left", 10, 10)
|
||||
end
|
||||
|
||||
elseif (_type (v1) == "string" and _type (v2) == "number") then --> :setpoint ("topleft", x, y)
|
||||
v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3
|
||||
|
||||
elseif (_type (v1) == "number") then --> :setpoint (x, y)
|
||||
v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2
|
||||
|
||||
elseif (_type (v1) == "table") then --> :setpoint (frame, x, y)
|
||||
v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3
|
||||
|
||||
end
|
||||
|
||||
if (not v2) then
|
||||
v2 = object.widget:GetParent()
|
||||
elseif (v2.dframework) then
|
||||
v2 = v2.widget
|
||||
end
|
||||
|
||||
return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--> color scheme
|
||||
|
||||
function gump:NewColor (_colorname, _colortable, _green, _blue, _alpha)
|
||||
|
||||
if (_type (_colorname) ~= "string") then
|
||||
return _detalhes:NewError ("color name must be a string.")
|
||||
end
|
||||
|
||||
if (gump.alias_text_colors [_colorname]) then
|
||||
return _detalhes:NewError (_colorname .. " already exists.")
|
||||
end
|
||||
|
||||
if (_type (_colortable) == "table") then
|
||||
if (_colortable[1] and _colortable[2] and _colortable[3]) then
|
||||
_colortable[4] = _colortable[4] or 1
|
||||
gump.alias_text_colors [_colorname] = _colortable
|
||||
else
|
||||
return _detalhes:NewError ("invalid color table.")
|
||||
end
|
||||
elseif (_colortable and _green and _blue) then
|
||||
_alpha = _alpha or 1
|
||||
gump.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha}
|
||||
else
|
||||
return _detalhes:NewError ("invalid parameter.")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function gump:ParseColors (_arg1, _arg2, _arg3, _arg4)
|
||||
if (_type (_arg1) == "table") then
|
||||
_arg1, _arg2, _arg3, _arg4 = _unpack (_arg1)
|
||||
elseif (_type (_arg1) == "string") then
|
||||
local color = gump.alias_text_colors [_arg1]
|
||||
if (color) then
|
||||
_arg1, _arg2, _arg3, _arg4 = _unpack (color)
|
||||
else
|
||||
_arg1, _arg2, _arg3, _arg4 = _unpack (gump.alias_text_colors.none)
|
||||
end
|
||||
end
|
||||
|
||||
if (not _arg4) then
|
||||
_arg4 = 1
|
||||
end
|
||||
|
||||
return _arg1, _arg2, _arg3, _arg4
|
||||
end
|
||||
@@ -0,0 +1,259 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
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
|
||||
local loadstring = loadstring --> lua local
|
||||
|
||||
local cleanfunction = function() end
|
||||
local APILabelFunctions = false
|
||||
local LabelMetaFunctions = {}
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
|
||||
LabelMetaFunctions.__call = function (_table, value)
|
||||
return self.label:SetText (value)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--> shown
|
||||
local gmember_shown = function (_object)
|
||||
return _object:IsShown()
|
||||
end
|
||||
--> frame width
|
||||
local gmember_width = function (_object)
|
||||
return _object.label:GetStringWidth()
|
||||
end
|
||||
--> frame height
|
||||
local gmember_height = function (_object)
|
||||
return _object.label:GetStringHeight()
|
||||
end
|
||||
--> text
|
||||
local gmember_text = function (_object)
|
||||
return _object.label:GetText()
|
||||
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()
|
||||
return fontsize
|
||||
end
|
||||
|
||||
|
||||
local get_members_function_index = {
|
||||
["shown"] = gmember_shown,
|
||||
["width"] = gmember_width,
|
||||
["height"] = gmember_height,
|
||||
["text"] = gmember_text,
|
||||
["fontcolor"] = gmember_textcolor,
|
||||
["fontface"] = gmember_textfont,
|
||||
["fontsize"] = gmember_textsize,
|
||||
["textcolor"] = gmember_textcolor, --alias
|
||||
["textfont"] = gmember_textfont, --alias
|
||||
["textsize"] = gmember_textsize --alias
|
||||
}
|
||||
|
||||
LabelMetaFunctions.__index = function (_table, _member_requested)
|
||||
|
||||
local func = get_members_function_index [_member_requested]
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = _rawget (_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
return LabelMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--> 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 = gump:ParseColors (_value)
|
||||
return _object.label:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
--> text font
|
||||
local smember_textfont = function (_object, _value)
|
||||
return _detalhes:SetFontFace (_object.label, _value)
|
||||
end
|
||||
--> text size
|
||||
local smember_textsize = function (_object, _value)
|
||||
return _detalhes:SetFontSize (_object.label, _value)
|
||||
end
|
||||
--> text align
|
||||
local smember_textalign = function (_object, _value)
|
||||
if (_value == "<") then
|
||||
_value = "left"
|
||||
elseif (_value == ">") then
|
||||
_value = "right"
|
||||
elseif (_value == "|") then
|
||||
_value = "center"
|
||||
end
|
||||
return _object.label:SetJustifyH (_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
|
||||
|
||||
local set_members_function_index = {
|
||||
["show"] = smember_show,
|
||||
["hide"] = smember_hide,
|
||||
["align"] = smember_textalign,
|
||||
["text"] = smember_text,
|
||||
["width"] = smember_width,
|
||||
["height"] = smember_height,
|
||||
["fontcolor"] = smember_textcolor,
|
||||
["color"] = smember_textcolor,
|
||||
["fontface"] = smember_textfont,
|
||||
["fontsize"] = smember_textsize,
|
||||
["textcolor"] = smember_textcolor,
|
||||
["textfont"] = smember_textfont,
|
||||
["textsize"] = smember_textsize
|
||||
}
|
||||
|
||||
LabelMetaFunctions.__newindex = function (_table, _key, _value)
|
||||
local func = set_members_function_index [_key]
|
||||
if (func) then
|
||||
return func (_table, _value)
|
||||
else
|
||||
return _rawset (_table, _key, _value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> 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
|
||||
|
||||
-- setpoint
|
||||
function LabelMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
||||
v1, v2, v3, v4, v5 = gump: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
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
|
||||
function gump:NewLabel (parent, container, name, member, text, font, size, color)
|
||||
|
||||
if (not parent) then
|
||||
return nil
|
||||
end
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (not name) then
|
||||
name = "DetailsLabelNumber" .. gump.LabelNameCounter
|
||||
gump.LabelNameCounter = gump.LabelNameCounter + 1
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
name = name:gsub ("$parent", parent:GetName())
|
||||
end
|
||||
|
||||
local LabelObject = {type = "label", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = LabelObject
|
||||
--container [member] = LabelObject.label
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
font = font or "GameFontHighlightSmall"
|
||||
|
||||
LabelObject.label = parent:CreateFontString (name, "OVERLAY", font)
|
||||
LabelObject.widget = LabelObject.label
|
||||
|
||||
if (not APILabelFunctions) then
|
||||
APILabelFunctions = true
|
||||
local idx = getmetatable (LabelObject.label).__index
|
||||
for funcName, funcAddress in pairs (idx) do
|
||||
if (not LabelMetaFunctions [funcName]) then
|
||||
LabelMetaFunctions [funcName] = function (object, ...)
|
||||
local x = loadstring ( "return _G."..object.label:GetName()..":"..funcName.."(...)")
|
||||
return x (...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
LabelObject.label:SetText (text)
|
||||
|
||||
if (size) then
|
||||
_detalhes:SetFontSize (LabelObject.label, size)
|
||||
end
|
||||
|
||||
if (color) then
|
||||
LabelObject.label:SetTextColor (unpack (color))
|
||||
end
|
||||
|
||||
LabelObject.label:SetJustifyH ("LEFT")
|
||||
|
||||
setmetatable (LabelObject, LabelMetaFunctions)
|
||||
|
||||
return LabelObject
|
||||
end
|
||||
@@ -0,0 +1,702 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
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 cleanfunction = function() end
|
||||
local BarMetaFunctions = {}
|
||||
local APIBarFunctions
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
|
||||
BarMetaFunctions.__call = function (_table, value)
|
||||
if (not value) then
|
||||
return _table.statusbar:GetValue()
|
||||
else
|
||||
return _table.statusbar:SetValue (value)
|
||||
end
|
||||
end
|
||||
|
||||
BarMetaFunctions.__add = function (v1, v2)
|
||||
if (_type (v1) == "table") then
|
||||
local v = v1.statusbar:GetValue()
|
||||
v = v + v2
|
||||
v1.statusbar:SetValue (v)
|
||||
else
|
||||
local v = v2.statusbar:GetValue()
|
||||
v = v + v1
|
||||
v2.statusbar:SetValue (v)
|
||||
end
|
||||
end
|
||||
|
||||
BarMetaFunctions.__sub = function (v1, v2)
|
||||
if (_type (v1) == "table") then
|
||||
local v = v1.statusbar:GetValue()
|
||||
v = v - v2
|
||||
v1.statusbar:SetValue (v)
|
||||
else
|
||||
local v = v2.statusbar:GetValue()
|
||||
v = v - v1
|
||||
v2.statusbar:SetValue (v)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--> tooltip
|
||||
local function gmember_tooltip (_object)
|
||||
return _object:GetTooltip()
|
||||
end
|
||||
--> shown
|
||||
local gmember_shown = function (_object)
|
||||
return _object.statusbar:IsShown()
|
||||
end
|
||||
--> frame width
|
||||
local gmember_width = function (_object)
|
||||
return _object.statusbar:GetWidth()
|
||||
end
|
||||
--> frame height
|
||||
local gmember_height = function (_object)
|
||||
return _object.statusbar:GetHeight()
|
||||
end
|
||||
--> value
|
||||
local gmember_value = function (_object)
|
||||
return _object.statusbar:GetValue()
|
||||
end
|
||||
--> right text
|
||||
local gmember_rtext = function (_object)
|
||||
return _object.textright:GetText()
|
||||
end
|
||||
--> left text
|
||||
local gmember_ltext = function (_object)
|
||||
return _object.textleft:GetText()
|
||||
end
|
||||
--> left color
|
||||
local gmember_color = function (_object)
|
||||
return _object.texture.original_colors
|
||||
end
|
||||
--> icon
|
||||
local gmember_icon = function (_object)
|
||||
return _object.icon:GetTexture()
|
||||
end
|
||||
--> texture
|
||||
local gmember_texture = function (_object)
|
||||
return _object.texture:GetTexture()
|
||||
end
|
||||
--> font size
|
||||
local gmember_textsize = function (_object)
|
||||
local _, fontsize = _object.textleft:GetFont()
|
||||
return fontsize
|
||||
end
|
||||
--> font face
|
||||
local gmember_textfont = function (_object)
|
||||
local fontface = _object.textleft:GetFont()
|
||||
return fontface
|
||||
end
|
||||
--> font color
|
||||
local gmember_textcolor = function (_object)
|
||||
return _object.textleft:GetTextColor()
|
||||
end
|
||||
|
||||
local get_members_function_index = {
|
||||
["tooltip"] = gmember_tooltip,
|
||||
["shown"] = gmember_shown,
|
||||
["width"] = gmember_width,
|
||||
["height"] = gmember_height,
|
||||
["value"] = gmember_value,
|
||||
["lefttext"] = gmember_ltext,
|
||||
["righttext"] = gmember_rtext,
|
||||
["color"] = gmember_color,
|
||||
["icon"] = gmember_icon,
|
||||
["texture"] = gmember_texture,
|
||||
["fontsize"] = gmember_textsize,
|
||||
["fontface"] = gmember_textfont,
|
||||
["fontcolor"] = gmember_textcolor,
|
||||
["textsize"] = gmember_textsize, --alias
|
||||
["textfont"] = gmember_textfont, --alias
|
||||
["textcolor"] = gmember_textcolor --alias
|
||||
}
|
||||
|
||||
BarMetaFunctions.__index = function (_table, _member_requested)
|
||||
|
||||
local func = get_members_function_index [_member_requested]
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = _rawget (_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
return BarMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
--> tooltip
|
||||
local smember_tooltip = function (_object, _value)
|
||||
return _object:SetTooltip (_value)
|
||||
end
|
||||
--> show
|
||||
local smember_shown = function (_object, _value)
|
||||
if (_value) then
|
||||
return _object:Show()
|
||||
else
|
||||
return _object:Hide()
|
||||
end
|
||||
end
|
||||
--> hide
|
||||
local smember_hide = function (_object, _value)
|
||||
if (_value) then
|
||||
return _object:Hide()
|
||||
else
|
||||
return _object:Show()
|
||||
end
|
||||
end
|
||||
--> width
|
||||
local smember_width = function (_object, _value)
|
||||
return _object.statusbar:SetWidth (_value)
|
||||
end
|
||||
--> height
|
||||
local smember_height = function (_object, _value)
|
||||
return _object.statusbar:SetHeight (_value)
|
||||
end
|
||||
--> statusbar value
|
||||
local smember_value = function (_object, _value)
|
||||
_object.statusbar:SetValue (_value)
|
||||
return _object.div:SetPoint ("left", _object.statusbar, "left", _value * (_object.statusbar:GetWidth()/100) - 16, 0)
|
||||
end
|
||||
--> right text
|
||||
local smember_rtext = function (_object, _value)
|
||||
return _object.textright:SetText (_value)
|
||||
end
|
||||
--> left text
|
||||
local smember_ltext = function (_object, _value)
|
||||
return _object.textleft:SetText (_value)
|
||||
end
|
||||
--> color
|
||||
local smember_color = function (_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (_value)
|
||||
|
||||
_object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
|
||||
_object.texture.original_colors = {_value1, _value2, _value3, _value4}
|
||||
return _object.texture:SetVertexColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
--> icon
|
||||
local smember_icon = function (_object, _value)
|
||||
if (type (_value) == "table") then
|
||||
local _value1, _value2 = _unpack (_value)
|
||||
_object.icon:SetTexture (_value1)
|
||||
if (_value2) then
|
||||
_object.icon:SetTexCoord (_unpack (_value2))
|
||||
end
|
||||
else
|
||||
_object.icon:SetTexture (_value)
|
||||
end
|
||||
return
|
||||
end
|
||||
--> texture
|
||||
local smember_texture = function (_object, _value)
|
||||
if (type (_value) == "table") then
|
||||
local _value1, _value2 = _unpack (_value)
|
||||
_object.texture:SetTexture (_value1)
|
||||
if (_value2) then
|
||||
_object.texture:SetTexCoord (_unpack (_value2))
|
||||
end
|
||||
else
|
||||
_object.texture:SetTexture (_value)
|
||||
end
|
||||
return
|
||||
end
|
||||
--> font face
|
||||
local smember_textfont = function (_object, _value)
|
||||
_detalhes:SetFontFace (_object.textleft, _value)
|
||||
return _detalhes:SetFontFace (_object.textright, _value)
|
||||
end
|
||||
--> font size
|
||||
local smember_textsize = function (_object, _value)
|
||||
_detalhes:SetFontSize (_object.textleft, _value)
|
||||
return _detalhes:SetFontSize (_object.textright, _value)
|
||||
end
|
||||
--> font color
|
||||
local smember_textcolor = function (_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (_value)
|
||||
_object.textleft:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
return _object.textright:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
|
||||
local set_members_function_index = {
|
||||
["tooltip"] = smember_tooltip,
|
||||
["shown"] = smember_shown,
|
||||
["width"] = smember_width,
|
||||
["height"] = smember_height,
|
||||
["value"] = smember_value,
|
||||
["righttext"] = smember_rtext,
|
||||
["lefttext"] = smember_ltext,
|
||||
["color"] = smember_color,
|
||||
["icon"] = smember_icon,
|
||||
["texture"] = smember_texture,
|
||||
["fontsize"] = smember_textsize,
|
||||
["fontface"] = smember_textfont,
|
||||
["fontcolor"] = smember_textcolor,
|
||||
["textsize"] = smember_textsize, --alias
|
||||
["textfont"] = smember_textfont, --alias
|
||||
["textcolor"] = smember_textcolor --alias
|
||||
}
|
||||
|
||||
BarMetaFunctions.__newindex = function (_table, _key, _value)
|
||||
local func = set_members_function_index [_key]
|
||||
if (func) then
|
||||
return func (_table, _value)
|
||||
else
|
||||
return _rawset (_table, _key, _value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> methods
|
||||
|
||||
--> show & hide
|
||||
function BarMetaFunctions:Show()
|
||||
self.statusbar:Show()
|
||||
end
|
||||
function BarMetaFunctions:Hide()
|
||||
self.statusbar:Hide()
|
||||
end
|
||||
|
||||
--> set value (status bar)
|
||||
function BarMetaFunctions:SetValue (value)
|
||||
if (not value) then
|
||||
value = 0
|
||||
end
|
||||
self.statusbar:SetValue (value)
|
||||
self.div:SetPoint ("left", self.statusbar, "left", value * (self.statusbar:GetWidth()/100) - 16, 0)
|
||||
end
|
||||
|
||||
--> set point
|
||||
function BarMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
||||
v1, v2, v3, v4, v5 = gump: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
|
||||
|
||||
--> set sizes
|
||||
function BarMetaFunctions:SetSize (w, h)
|
||||
if (w) then
|
||||
self.statusbar:SetWidth (w)
|
||||
end
|
||||
if (h) then
|
||||
self.statusbar:SetHeight (h)
|
||||
end
|
||||
end
|
||||
|
||||
--> set texture
|
||||
function BarMetaFunctions:SetTexture (texture)
|
||||
self.texture:SetTexture (texture)
|
||||
end
|
||||
|
||||
--> set texts
|
||||
function BarMetaFunctions:SetLeftText (text)
|
||||
self.textleft:SetText (text)
|
||||
end
|
||||
function BarMetaFunctions:SetRightText (text)
|
||||
self.textright:SetText (text)
|
||||
end
|
||||
|
||||
--> set color
|
||||
function BarMetaFunctions:SetColor (r, g, b, a)
|
||||
r, g, b, a = gump:ParseColors (r, g, b, a)
|
||||
|
||||
self.texture:SetVertexColor (r, g, b, a)
|
||||
self.statusbar:SetStatusBarColor (r, g, b, a)
|
||||
self.texture.original_colors = {r, g, b, a}
|
||||
end
|
||||
|
||||
--> set icons
|
||||
function BarMetaFunctions:SetIcon (texture, ...)
|
||||
self.icon:SetTexture (texture)
|
||||
if (...) then
|
||||
local L, R, U, D = _unpack (...)
|
||||
self.icon:SetTexCoord (L, R, U, D)
|
||||
end
|
||||
end
|
||||
|
||||
--> show div
|
||||
function BarMetaFunctions:ShowDiv (bool)
|
||||
if (bool) then
|
||||
self.div:Show()
|
||||
else
|
||||
self.div:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
-- tooltip
|
||||
function BarMetaFunctions:SetTooltip (tooltip)
|
||||
if (tooltip) then
|
||||
return _rawset (self, "have_tooltip", tooltip)
|
||||
else
|
||||
return _rawset (self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
function BarMetaFunctions:GetTooltip()
|
||||
return _rawget (self, "have_tooltip")
|
||||
end
|
||||
|
||||
-- frame levels
|
||||
function BarMetaFunctions:GetFrameLevel()
|
||||
return self.statusbar:GetFrameLevel()
|
||||
end
|
||||
function BarMetaFunctions:SetFrameLevel (level, frame)
|
||||
if (not frame) then
|
||||
return self.statusbar:SetFrameLevel (level)
|
||||
else
|
||||
local framelevel = frame:GetFrameLevel (frame) + level
|
||||
return self.statusbar:SetFrameLevel (framelevel)
|
||||
end
|
||||
end
|
||||
|
||||
-- frame stratas
|
||||
function BarMetaFunctions:SetFrameStrata()
|
||||
return self.statusbar:GetFrameStrata()
|
||||
end
|
||||
function BarMetaFunctions:SetFrameStrata (strata)
|
||||
if (_type (strata) == "table") then
|
||||
self.statusbar:SetFrameStrata (strata:GetFrameStrata())
|
||||
else
|
||||
self.statusbar:SetFrameStrata (strata)
|
||||
end
|
||||
end
|
||||
|
||||
--> container
|
||||
function BarMetaFunctions:SetContainer (container)
|
||||
self.container = container
|
||||
end
|
||||
|
||||
--> hooks
|
||||
function BarMetaFunctions:SetHook (hookType, func)
|
||||
if (func) then
|
||||
if (hookType == "OnEnterHook") then
|
||||
self.OnEnterHook = func
|
||||
return true
|
||||
elseif (hookType == "OnLeaveHook") then
|
||||
self.OnLeaveHook = func
|
||||
return true
|
||||
elseif (hookType == "OnHideHook") then
|
||||
self.OnHideHook = func
|
||||
return true
|
||||
elseif (hookType == "OnShowHook") then
|
||||
self.OnShowHook = func
|
||||
return true
|
||||
elseif (hookType == "OnMouseDownHook") then
|
||||
self.OnMouseDownHook = func
|
||||
return true
|
||||
elseif (hookType == "OnMouseUpHook") then
|
||||
self.OnMouseUpHook = func
|
||||
return true
|
||||
end
|
||||
else
|
||||
if (hookType == "OnEnterHook") then
|
||||
self.OnEnterHook = nil
|
||||
return true
|
||||
elseif (hookType == "OnLeaveHook") then
|
||||
self.OnLeaveHook = nil
|
||||
return true
|
||||
elseif (hookType == "OnHideHook") then
|
||||
self.OnHideHook = nil
|
||||
return true
|
||||
elseif (hookType == "OnShowHook") then
|
||||
self.OnShowHook = nil
|
||||
return true
|
||||
elseif (hookType == "OnMouseDownHook") then
|
||||
self.OnMouseDownHook = nil
|
||||
return true
|
||||
elseif (hookType == "OnMouseUpHook") then
|
||||
self.OnMouseUpHook = nil
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> scripts
|
||||
|
||||
local OnEnter = function (frame)
|
||||
if (frame.MyObject.OnEnterHook) then
|
||||
local interrupt = frame.MyObject.OnEnterHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (not frame.MyObject.timer) then
|
||||
local oc = frame.MyObject.texture.original_colors --original colors
|
||||
gump:GradientEffect ( frame.MyObject.texture, "texture", oc[1], oc[2], oc[3], oc[4], oc[1]+0.2, oc[2]+0.2, oc[3]+0.2, oc[4], .2)
|
||||
frame.MyObject.div:Show()
|
||||
frame.MyObject.div:SetPoint ("left", frame, "left", frame:GetValue() * (frame:GetWidth()/100) - 16, 0)
|
||||
else
|
||||
local oc = frame.MyObject.texture.original_colors --original colors
|
||||
gump:GradientEffect ( frame.MyObject.texture, "texture", oc[1], oc[2], oc[3], oc[4], oc[1]-0.2, oc[2]-0.2, oc[3]-0.2, oc[4]+.2, .2)
|
||||
end
|
||||
|
||||
frame.MyObject.background:Show()
|
||||
|
||||
if (frame.MyObject.have_tooltip) then
|
||||
GameCooltip:Reset()
|
||||
GameCooltip:AddLine (frame.MyObject.have_tooltip)
|
||||
GameCooltip:ShowCooltip (frame, "tooltip")
|
||||
end
|
||||
|
||||
local parent = frame:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local OnLeave = function (frame)
|
||||
if (frame.MyObject.OnLeaveHook) then
|
||||
local interrupt = frame.MyObject.OnLeaveHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (not frame.MyObject.timer) then
|
||||
local oc = frame.MyObject.texture.original_colors --original colors
|
||||
local r, g, b, a = frame.MyObject.texture:GetVertexColor()
|
||||
gump:GradientEffect ( frame.MyObject.texture, "texture", r, g, b, a, oc[1], oc[2], oc[3], oc[4], .2)
|
||||
frame.MyObject.div:Hide()
|
||||
frame.MyObject.background:Hide()
|
||||
else
|
||||
local oc = frame.MyObject.background.original_colors --original colors
|
||||
local r, g, b, a = frame.MyObject.background:GetVertexColor()
|
||||
gump:GradientEffect ( frame.MyObject.background, "texture", r, g, b, a, oc[1], oc[2], oc[3], oc[4], .2)
|
||||
end
|
||||
|
||||
if (frame.MyObject.have_tooltip) then
|
||||
_detalhes.popup:ShowMe (false)
|
||||
end
|
||||
|
||||
local parent = frame:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient (false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnHide = function (frame)
|
||||
if (frame.MyObject.OnHideHook) then
|
||||
local interrupt = frame.MyObject.OnHideHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnShow = function (frame)
|
||||
if (frame.MyObject.OnShowHook) then
|
||||
local interrupt = frame.MyObject.OnShowHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnMouseDown = function (frame, button)
|
||||
if (frame.MyObject.OnMouseDownHook) then
|
||||
local interrupt = frame.MyObject.OnMouseDownHook (frame, button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
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)
|
||||
if (frame.MyObject.OnMouseUpHook) then
|
||||
local interrupt = frame.MyObject.OnMouseUpHook (frame, button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (frame.MyObject.container.isMoving) then
|
||||
frame.MyObject.container:StopMovingOrSizing()
|
||||
frame.MyObject.container.isMoving = false
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> timer
|
||||
|
||||
function BarMetaFunctions:OnTimerEnd()
|
||||
if (self.OnTimerEndHook) then
|
||||
local interrupt = self.OnTimerEndHook()
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
self.timer_texture:Hide()
|
||||
self.div_timer:Hide()
|
||||
self:Hide()
|
||||
self.timer = false
|
||||
end
|
||||
|
||||
local OnUpdate = function (self, elapsed)
|
||||
local timepct = (elapsed / self.tempo) * 100
|
||||
self.c = self.c - (timepct*self.width/100)
|
||||
self.remaining = self.remaining - elapsed
|
||||
self.righttext:SetText (_math_floor (self.remaining))
|
||||
self.timertexture:SetWidth (self.c)
|
||||
if (self.c < 1) then
|
||||
self:SetScript ("OnUpdate", nil)
|
||||
self.MyObject:OnTimerEnd()
|
||||
end
|
||||
end
|
||||
|
||||
function BarMetaFunctions:SetTimer (tempo)
|
||||
|
||||
self.statusbar.width = self.statusbar:GetWidth()
|
||||
self.statusbar.tempo = tempo
|
||||
self.statusbar.remaining = tempo
|
||||
self.statusbar.c = self.statusbar.width
|
||||
|
||||
self.timer_texture:Show()
|
||||
self.timer_texture:SetWidth (self.statusbar.width)
|
||||
self.statusbar.t = self.timer_texture
|
||||
self (1)
|
||||
|
||||
self.div_timer:Show()
|
||||
self.background:Show()
|
||||
|
||||
self.timer = true
|
||||
|
||||
self.statusbar:SetScript ("OnUpdate", OnUpdate)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
|
||||
function DetailsNormalBar_OnCreate (self)
|
||||
self.texture.original_colors = {1, 1, 1, 1}
|
||||
self.background.original_colors = {.3, .3, .3, .3}
|
||||
self.timertexture.original_colors = {.3, .3, .3, .3}
|
||||
return true
|
||||
end
|
||||
|
||||
function gump:NewBar (parent, container, name, member, w, h, value)
|
||||
|
||||
if (not name) then
|
||||
return nil
|
||||
elseif (not parent) then
|
||||
return nil
|
||||
elseif (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
name = name:gsub ("$parent", parent:GetName())
|
||||
end
|
||||
|
||||
local BarObject = {type = "bar", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = BarObject
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
--> default members:
|
||||
--> hooks
|
||||
BarObject.OnEnterHook = nil
|
||||
BarObject.OnLeaveHook = nil
|
||||
BarObject.OnHideHook = nil
|
||||
BarObject.OnShowHook = nil
|
||||
BarObject.OnMouseDownHook = nil
|
||||
BarObject.OnMouseUpHook = nil
|
||||
BarObject.OnTimerEndHook = nil
|
||||
--> misc
|
||||
BarObject.tooltip = nil
|
||||
BarObject.locked = false
|
||||
BarObject.have_tooltip = nil
|
||||
|
||||
BarObject.container = container
|
||||
|
||||
--> create widgets
|
||||
BarObject.statusbar = CreateFrame ("statusbar", name, parent, "DetailsNormalBarTemplate")
|
||||
BarObject.widget = BarObject.statusbar
|
||||
|
||||
if (not APIBarFunctions) then
|
||||
APIBarFunctions = true
|
||||
local idx = getmetatable (BarObject.statusbar).__index
|
||||
for funcName, funcAddress in pairs (idx) do
|
||||
if (not BarMetaFunctions [funcName]) then
|
||||
BarMetaFunctions [funcName] = function (object, ...)
|
||||
local x = loadstring ( "return _G."..object.statusbar:GetName()..":"..funcName.."(...)")
|
||||
return x (...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
BarObject.statusbar:SetHeight (h)
|
||||
BarObject.statusbar:SetWidth (w)
|
||||
BarObject.statusbar:SetFrameLevel (parent:GetFrameLevel()+1)
|
||||
BarObject.statusbar:SetMinMaxValues (0, 100)
|
||||
BarObject.statusbar:SetValue (value or 50)
|
||||
BarObject.statusbar.MyObject = BarObject
|
||||
|
||||
BarObject.timer_texture = _G [name .. "_timerTexture"]
|
||||
BarObject.timer_texture:SetWidth (w)
|
||||
BarObject.timer_texture:SetHeight (h)
|
||||
|
||||
BarObject.texture = _G [name .. "_statusbarTexture"]
|
||||
BarObject.background = _G [name .. "_background"]
|
||||
BarObject.icon = _G [name .. "_icon"]
|
||||
BarObject.textleft = _G [name .. "_TextLeft"]
|
||||
BarObject.textright = _G [name .. "_TextRight"]
|
||||
BarObject.div = _G [name .. "_sparkMouseover"]
|
||||
BarObject.div_timer = _G [name .. "_sparkTimer"]
|
||||
|
||||
--> hooks
|
||||
BarObject.statusbar:SetScript ("OnEnter", OnEnter)
|
||||
BarObject.statusbar:SetScript ("OnLeave", OnLeave)
|
||||
BarObject.statusbar:SetScript ("OnHide", OnHide)
|
||||
BarObject.statusbar:SetScript ("OnShow", OnShow)
|
||||
BarObject.statusbar:SetScript ("OnMouseDown", OnMouseDown)
|
||||
BarObject.statusbar:SetScript ("OnMouseUp", OnMouseUp)
|
||||
|
||||
--> set class
|
||||
_setmetatable (BarObject, BarMetaFunctions)
|
||||
|
||||
return BarObject
|
||||
end
|
||||
@@ -0,0 +1,90 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ .. \FrameXML\UI.xsd">
|
||||
<Script file="normal_bar.lua"/>
|
||||
|
||||
<StatusBar name="DetailsNormalBarTemplate" virtual="true">
|
||||
<Size x="300" y="14"/>
|
||||
|
||||
<Layers>
|
||||
|
||||
<Layer level="BACKGROUND">
|
||||
<!-- background texture -->
|
||||
<Texture name="$parent_background" hidden="false" setAllPoints="true" parentKey="background" file = "Interface\PaperDollInfoFrame\UI-Character-Skills-Bar" horizTile="false" vertTile="false">
|
||||
<Size x="300" y="14" />
|
||||
<Color a = "0.3" r = "0.3" g = "0.3" b = "0.3" />
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="ARTWORK">
|
||||
<!-- timer texture -->
|
||||
<Texture name="$parent_timerTexture" hidden="true" parentKey="timertexture" file = "Interface\PaperDollInfoFrame\UI-Character-Skills-Bar" horizTile="false" vertTile="false">
|
||||
<Size x="300" y="14" />
|
||||
<Color a = "1" r = "1" g = "1" b = "1" />
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" />
|
||||
</Anchors>
|
||||
</Texture>
|
||||
|
||||
<!-- statusbar texture -->
|
||||
<Texture name="$parent_statusbarTexture" hidden="false" parentKey="texture" file = "Interface\PaperDollInfoFrame\UI-Character-Skills-Bar" horizTile="false" vertTile="false">
|
||||
<Size x="300" y="14" />
|
||||
<Color a = "1" r = "1" g = "1" b = "1" />
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="OVERLAY">
|
||||
<!-- icon texture -->
|
||||
<Texture name="$parent_icon" parentKey="icontexture">
|
||||
<Size x="14" y="14" />
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
|
||||
<!-- spark mouse over -->
|
||||
<Texture name="$parent_sparkMouseover" hidden="true" parentKey="sparkmouseover" file = "Interface\CastingBar\UI-CastingBar-Spark" alphaMode="ADD">
|
||||
<Size>
|
||||
<AbsDimension x="32" y="32"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="RIGHT" x="-16" y="-1"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
|
||||
<!-- timer spark -->
|
||||
<Texture name="$parent_sparkTimer" hidden="true" parentKey="sparktimer" file = "Interface\CastingBar\UI-CastingBar-Spark" alphaMode="ADD">
|
||||
<Size>
|
||||
<AbsDimension x="32" y="32"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent_timerTexture" relativePoint="RIGHT" x="-16" y="-1"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
|
||||
<!-- left text -->
|
||||
<FontString name="$parent_TextLeft" parentKey="lefttext" inherits="GameFontHighlight" justifyH="LEFT" nonspacewrap="false">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent_icon" relativePoint="RIGHT" x="3" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
|
||||
<!-- right text -->
|
||||
<FontString name="$parent_TextRight" parentKey="righttext" inherits="GameFontHighlight" justifyH="RIGHT" nonspacewrap="false">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="-3" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
|
||||
</Layer>
|
||||
|
||||
</Layers>
|
||||
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
self:SetStatusBarTexture (self.texture);
|
||||
DetailsNormalBar_OnCreate (self);
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</StatusBar>
|
||||
</Ui>
|
||||
@@ -0,0 +1,504 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
--> lua locals
|
||||
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
|
||||
local loadstring = loadstring --> lua local
|
||||
|
||||
local cleanfunction = function() end
|
||||
local PanelMetaFunctions = {}
|
||||
local APIFrameFunctions
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
|
||||
PanelMetaFunctions.__call = function (_table, value)
|
||||
--> nothing to do
|
||||
return true
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--> tooltip
|
||||
local gmember_tooltip = function (_object)
|
||||
return _object:GetTooltip()
|
||||
end
|
||||
--> shown
|
||||
local gmember_shown = function (_object)
|
||||
return _object:IsShown()
|
||||
end
|
||||
--> backdrop color
|
||||
local gmember_color = function (_object)
|
||||
return _object.frame:GetBackdropColor()
|
||||
end
|
||||
--> backdrop table
|
||||
local gmember_backdrop = function (_object)
|
||||
return _object.frame:GetBackdrop()
|
||||
end
|
||||
--> frame width
|
||||
local gmember_width = function (_object)
|
||||
return _object.frame:GetWidth()
|
||||
end
|
||||
--> frame height
|
||||
local gmember_height = function (_object)
|
||||
return _object.frame:GetHeight()
|
||||
end
|
||||
--> locked
|
||||
local gmember_locked = function (_object)
|
||||
return _rawget (_object, "is_locked")
|
||||
end
|
||||
|
||||
local get_members_function_index = {
|
||||
["tooltip"] = gmember_tooltip,
|
||||
["shown"] = gmember_shown,
|
||||
["color"] = gmember_color,
|
||||
["backdrop"] = gmember_backdrop,
|
||||
["width"] = gmember_width,
|
||||
["height"] = gmember_height,
|
||||
["locked"] = gmember_locked,
|
||||
}
|
||||
|
||||
PanelMetaFunctions.__index = function (_table, _member_requested)
|
||||
|
||||
local func = get_members_function_index [_member_requested]
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = _rawget (_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
return PanelMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
|
||||
--> tooltip
|
||||
local smember_tooltip = function (_object, _value)
|
||||
return _object:SetTooltip (_value)
|
||||
end
|
||||
--> 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
|
||||
--> backdrop color
|
||||
local smember_color = function (_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (_value)
|
||||
return _object:SetBackdropColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
--> frame width
|
||||
local smember_width = function (_object, _value)
|
||||
return _object.frame:SetWidth (_value)
|
||||
end
|
||||
--> frame height
|
||||
local smember_height = function (_object, _value)
|
||||
return _object.frame:SetHeight (_value)
|
||||
end
|
||||
|
||||
--> locked
|
||||
local smember_locked = function (_object, _value)
|
||||
if (_value) then
|
||||
_object.frame:SetMovable (false)
|
||||
return _rawset (_object, "is_locked", true)
|
||||
else
|
||||
_object.frame:SetMovable (true)
|
||||
_rawset (_object, "is_locked", false)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--> backdrop
|
||||
local smember_backdrop = function (_object, _value)
|
||||
return _object.frame:SetBackdrop (_value)
|
||||
end
|
||||
|
||||
--> close with right button
|
||||
local smember_right_close = function (_object, _value)
|
||||
return _rawset (_object, "rightButtonClose", _value)
|
||||
end
|
||||
|
||||
local set_members_function_index = {
|
||||
["tooltip"] = smember_tooltip,
|
||||
["show"] = smember_show,
|
||||
["hide"] = smember_hide,
|
||||
["color"] = smember_color,
|
||||
["backdrop"] = smember_backdrop,
|
||||
["width"] = smember_width,
|
||||
["height"] = smember_height,
|
||||
["locked"] = smember_locked,
|
||||
["close_with_right"] = smember_right_close,
|
||||
}
|
||||
|
||||
PanelMetaFunctions.__newindex = function (_table, _key, _value)
|
||||
local func = set_members_function_index [_key]
|
||||
if (func) then
|
||||
return func (_table, _value)
|
||||
else
|
||||
return _rawset (_table, _key, _value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> methods
|
||||
|
||||
--> show & hide
|
||||
function PanelMetaFunctions:Show()
|
||||
self.frame:Show()
|
||||
|
||||
end
|
||||
function PanelMetaFunctions:Hide()
|
||||
self.frame:Hide()
|
||||
|
||||
end
|
||||
|
||||
-- setpoint
|
||||
function PanelMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
||||
v1, v2, v3, v4, v5 = gump: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
|
||||
|
||||
-- sizes
|
||||
function PanelMetaFunctions:SetSize (w, h)
|
||||
if (w) then
|
||||
self.frame:SetWidth (w)
|
||||
end
|
||||
if (h) then
|
||||
self.frame:SetHeight (h)
|
||||
end
|
||||
end
|
||||
|
||||
-- clear
|
||||
function PanelMetaFunctions:HideWidgets()
|
||||
for widgetName, widgetSelf in pairs (self) do
|
||||
if (type (widgetSelf) == "table" and widgetSelf.dframework) then
|
||||
widgetSelf:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- backdrop
|
||||
function PanelMetaFunctions:SetBackdrop (background, edge, tilesize, edgesize, tile, left, right, top, bottom)
|
||||
|
||||
if (_type (background) == "boolean" and not background) then
|
||||
return self.frame:SetBackdrop (nil)
|
||||
|
||||
elseif (_type (background) == "table") then
|
||||
self.frame:SetBackdrop (background)
|
||||
|
||||
else
|
||||
local currentBackdrop = self.frame:GetBackdrop() or {edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", tile=true, tileSize=16, edgeSize=16, insets={left=1, right=0, top=0, bottom=0}}
|
||||
currentBackdrop.bgFile = background or currentBackdrop.bgFile
|
||||
currentBackdrop.edgeFile = edgeFile or currentBackdrop.edgeFile
|
||||
currentBackdrop.tileSize = tilesize or currentBackdrop.tileSize
|
||||
currentBackdrop.edgeSize = edgesize or currentBackdrop.edgeSize
|
||||
currentBackdrop.tile = tile or currentBackdrop.tile
|
||||
currentBackdrop.insets.left = left or currentBackdrop.insets.left
|
||||
currentBackdrop.insets.right = left or currentBackdrop.insets.right
|
||||
currentBackdrop.insets.top = left or currentBackdrop.insets.top
|
||||
currentBackdrop.insets.bottom = left or currentBackdrop.insets.bottom
|
||||
self.frame:SetBackdrop (currentBackdrop)
|
||||
end
|
||||
end
|
||||
|
||||
-- backdropcolor
|
||||
function PanelMetaFunctions:SetBackdropColor (color, arg2, arg3, arg4)
|
||||
if (arg2) then
|
||||
self.frame:SetBackdropColor (color, arg2, arg3, arg4 or 1)
|
||||
self.frame.Gradient.OnLeave = {color, arg2, arg3, arg4 or 1}
|
||||
else
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (color)
|
||||
self.frame:SetBackdropColor (_value1, _value2, _value3, _value4)
|
||||
self.frame.Gradient.OnLeave = {_value1, _value2, _value3, _value4}
|
||||
end
|
||||
end
|
||||
|
||||
-- border color
|
||||
function PanelMetaFunctions:SetBackdropBorderColor (color, arg2, arg3, arg4)
|
||||
if (arg2) then
|
||||
return self.frame:SetBackdropBorderColor (color, arg2, arg3, arg4)
|
||||
end
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (color)
|
||||
self.frame:SetBackdropBorderColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
|
||||
-- gradient colors
|
||||
function PanelMetaFunctions:SetGradient (FadeType, color)
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (color)
|
||||
if (FadeType == "OnEnter") then
|
||||
self.frame.Gradient.OnEnter = {_value1, _value2, _value3, _value4}
|
||||
elseif (FadeType == "OnLeave") then
|
||||
self.frame.Gradient.OnLeave = {_value1, _value2, _value3, _value4}
|
||||
end
|
||||
end
|
||||
|
||||
-- tooltip
|
||||
function PanelMetaFunctions:SetTooltip (tooltip)
|
||||
if (tooltip) then
|
||||
return _rawset (self, "have_tooltip", tooltip)
|
||||
else
|
||||
return _rawset (self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
function PanelMetaFunctions:GetTooltip()
|
||||
return _rawget (self, "have_tooltip")
|
||||
end
|
||||
|
||||
-- enable and disable gradients
|
||||
function PanelMetaFunctions:DisableGradient()
|
||||
self.GradientEnabled = false
|
||||
end
|
||||
function PanelMetaFunctions:EnableGradient()
|
||||
self.GradientEnabled = true
|
||||
end
|
||||
|
||||
--> hooks
|
||||
function PanelMetaFunctions:SetHook (hookType, func)
|
||||
if (func) then
|
||||
_rawset (self, hookType.."Hook", func)
|
||||
else
|
||||
_rawset (self, hookType.."Hook", nil)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> scripts
|
||||
|
||||
function PanelMetaFunctions:RunGradient (cancel)
|
||||
if (type (cancel) == "boolean" and not canceal) then
|
||||
local _r, _g, _b, _a = self.frame:GetBackdropColor()
|
||||
if (_r) then
|
||||
local OnLeaveColors = self.frame.Gradient.OnLeave
|
||||
gump:GradientEffect (self.frame, "frame", _r, _g, _b, _a, OnLeaveColors[1], OnLeaveColors[2], OnLeaveColors[3], OnLeaveColors[4], .3)
|
||||
end
|
||||
else
|
||||
local _r, _g, _b, _a = self.frame:GetBackdropColor()
|
||||
if (_r) then
|
||||
local OnEnterColors = self.frame.Gradient.OnEnter
|
||||
gump:GradientEffect (self.frame, "frame", _r, _g, _b, _a, OnEnterColors[1], OnEnterColors[2], OnEnterColors[3], OnEnterColors[4], .3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnEnter = function (frame)
|
||||
if (frame.MyObject.OnEnterHook) then
|
||||
local interrupt = frame.MyObject.OnEnterHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (frame.MyObject.GradientEnabled) then
|
||||
frame.MyObject:RunGradient()
|
||||
end
|
||||
|
||||
if (frame.MyObject.have_tooltip) then
|
||||
GameCooltip:Reset()
|
||||
GameCooltip:SetType ("tooltip")
|
||||
GameCooltip:SetColor ("main", "transparent")
|
||||
GameCooltip:AddLine (frame.MyObject.have_tooltip)
|
||||
GameCooltip:SetOwner (frame)
|
||||
GameCooltip:ShowCooltip()
|
||||
end
|
||||
end
|
||||
|
||||
local OnLeave = function (frame)
|
||||
if (frame.MyObject.OnLeaveHook) then
|
||||
local interrupt = frame.MyObject.OnLeaveHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (frame.MyObject.GradientEnabled) then
|
||||
frame.MyObject:RunGradient (false)
|
||||
end
|
||||
|
||||
if (frame.MyObject.have_tooltip) then
|
||||
_detalhes.popup:ShowMe (false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local OnHide = function (frame)
|
||||
if (frame.MyObject.OnHideHook) then
|
||||
local interrupt = frame.MyObject.OnHideHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnShow = function (frame)
|
||||
if (frame.MyObject.OnShowHook) then
|
||||
local interrupt = frame.MyObject.OnShowHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnMouseDown = function (frame, button)
|
||||
if (frame.MyObject.OnMouseDownHook) then
|
||||
local interrupt = frame.MyObject.OnMouseDownHook (frame, button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (frame.MyObject.container == UIParent) then
|
||||
if (not frame.isLocked and frame:IsMovable()) then
|
||||
frame.isMoving = true
|
||||
frame:StartMoving()
|
||||
end
|
||||
|
||||
elseif (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)
|
||||
if (frame.MyObject.OnMouseUpHook) then
|
||||
local interrupt = frame.MyObject.OnMouseUpHook (frame, button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (button == "RightButton" and frame.MyObject.rightButtonClose) then
|
||||
frame.MyObject:Hide()
|
||||
end
|
||||
|
||||
if (frame.MyObject.container == UIParent) then
|
||||
if (frame.isMoving) then
|
||||
frame:StopMovingOrSizing()
|
||||
frame.isMoving = false
|
||||
end
|
||||
else
|
||||
if (frame.MyObject.container.isMoving) then
|
||||
frame.MyObject.container:StopMovingOrSizing()
|
||||
frame.MyObject.container.isMoving = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
function gump:NewPanel (parent, container, name, member, w, h, backdrop, backdropcolor, bordercolor)
|
||||
|
||||
if (not name) then
|
||||
return nil
|
||||
elseif (not parent) then
|
||||
parent = UIParent
|
||||
end
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
name = name:gsub ("$parent", parent:GetName())
|
||||
end
|
||||
|
||||
local PanelObject = {type = "panel", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = PanelObject
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
|
||||
--> default members:
|
||||
--> hooks
|
||||
PanelObject.OnEnterHook = nil
|
||||
PanelObject.OnLeaveHook = nil
|
||||
PanelObject.OnHideHook = nil
|
||||
PanelObject.OnShowHook = nil
|
||||
PanelObject.OnMouseDownHook = nil
|
||||
PanelObject.OnMouseUpHook = nil
|
||||
--> misc
|
||||
PanelObject.is_locked = true
|
||||
PanelObject.GradientEnabled = true
|
||||
PanelObject.container = container
|
||||
PanelObject.rightButtonClose = false
|
||||
|
||||
PanelObject.frame = CreateFrame ("frame", name, parent, "DetailsPanelTemplate")
|
||||
PanelObject.widget = PanelObject.frame
|
||||
|
||||
if (not APIFrameFunctions) then
|
||||
APIFrameFunctions = {}
|
||||
local idx = getmetatable (PanelObject.frame).__index
|
||||
for funcName, funcAddress in pairs (idx) do
|
||||
if (not PanelMetaFunctions [funcName]) then
|
||||
PanelMetaFunctions [funcName] = function (object, ...)
|
||||
local x = loadstring ( "return _G."..object.frame:GetName()..":"..funcName.."(...)")
|
||||
return x (...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
PanelObject.frame:SetWidth (w or 100)
|
||||
PanelObject.frame:SetHeight (h or 100)
|
||||
|
||||
PanelObject.frame.MyObject = PanelObject
|
||||
|
||||
--> hooks
|
||||
PanelObject.frame:SetScript ("OnEnter", OnEnter)
|
||||
PanelObject.frame:SetScript ("OnLeave", OnLeave)
|
||||
PanelObject.frame:SetScript ("OnHide", OnHide)
|
||||
PanelObject.frame:SetScript ("OnShow", OnShow)
|
||||
PanelObject.frame:SetScript ("OnMouseDown", OnMouseDown)
|
||||
PanelObject.frame:SetScript ("OnMouseUp", OnMouseUp)
|
||||
|
||||
_setmetatable (PanelObject, PanelMetaFunctions)
|
||||
|
||||
if (backdrop) then
|
||||
PanelObject:SetBackdrop (backdrop)
|
||||
elseif (_type (backdrop) == "boolean") then
|
||||
PanelObject.frame:SetBackdrop (nil)
|
||||
end
|
||||
|
||||
if (backdropcolor) then
|
||||
PanelObject:SetBackdropColor (backdropcolor)
|
||||
end
|
||||
|
||||
if (bordercolor) then
|
||||
PanelObject:SetBackdropBorderColor (bordercolor)
|
||||
end
|
||||
|
||||
return PanelObject
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ .. \FrameXML\UI.xsd">
|
||||
|
||||
<Script file="panel.lua"/>
|
||||
|
||||
<Frame name="DetailsPanelTemplate" virtual="true">
|
||||
|
||||
<Size x="100" y="100"/>
|
||||
|
||||
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
|
||||
<EdgeSize>
|
||||
<AbsValue val="10"/>
|
||||
</EdgeSize>
|
||||
<TileSize>
|
||||
<AbsValue val="16"/>
|
||||
</TileSize>
|
||||
<BackgroundInsets>
|
||||
<AbsInset left="1" right="1" top="0" bottom="1"/>
|
||||
</BackgroundInsets>
|
||||
</Backdrop>
|
||||
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
self.Gradient = {
|
||||
["OnEnter"] = {0.3, 0.3, 0.3, 0.5},
|
||||
["OnLeave"] = {0.9, 0.7, 0.7, 1}
|
||||
}
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
|
||||
</Frame>
|
||||
|
||||
</Ui>
|
||||
@@ -0,0 +1,234 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
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
|
||||
local loadstring = loadstring --> lua local
|
||||
|
||||
local cleanfunction = function() end
|
||||
local APIImageFunctions = false
|
||||
local ImageMetaFunctions = {}
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
|
||||
ImageMetaFunctions.__call = function (_table, value)
|
||||
return self.image:SetTexture (value)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--> shown
|
||||
local gmember_shown = function (_object)
|
||||
return _object:IsShown()
|
||||
end
|
||||
--> frame width
|
||||
local gmember_width = function (_object)
|
||||
return _object.image:GetWidth()
|
||||
end
|
||||
--> frame height
|
||||
local gmember_height = function (_object)
|
||||
return _object.image:GetHeight()
|
||||
end
|
||||
--> texture
|
||||
local gmember_texture = function (_object)
|
||||
return _object.image:GetTexture()
|
||||
end
|
||||
--> alpha
|
||||
local gmember_alpha = function (_object)
|
||||
return _object.image:GetAlpha()
|
||||
end
|
||||
|
||||
local get_members_function_index = {
|
||||
["shown"] = gmember_shown,
|
||||
["alpha"] = gmember_alpha,
|
||||
["width"] = gmember_width,
|
||||
["height"] = gmember_height,
|
||||
["texture"] = gmember_texture,
|
||||
}
|
||||
|
||||
ImageMetaFunctions.__index = function (_table, _member_requested)
|
||||
|
||||
local func = get_members_function_index [_member_requested]
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = _rawget (_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
return ImageMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--> 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)
|
||||
return _object.image:SetTexture (_value)
|
||||
end
|
||||
--> width
|
||||
local smember_width = function (_object, _value)
|
||||
return _object.image:SetWidth (_value)
|
||||
end
|
||||
--> height
|
||||
local smember_height = function (_object, _value)
|
||||
return _object.image:SetHeight (_value)
|
||||
end
|
||||
--> alpha
|
||||
local smember_alpha = function (_object, _value)
|
||||
return _object.image:SetAlpha (_value)
|
||||
end
|
||||
--> color
|
||||
local smember_color = function (_object, _value)
|
||||
local _value1, _value2, _value3 = gump:ParseColors (_value)
|
||||
return _object.image:SetTexture (_value1, _value2, _value3)
|
||||
end
|
||||
|
||||
local set_members_function_index = {
|
||||
["show"] = smember_show,
|
||||
["hide"] = smember_hide,
|
||||
["alpha"] = smember_alpha,
|
||||
["width"] = smember_width,
|
||||
["height"] = smember_height,
|
||||
["texture"] = smember_texture,
|
||||
["color"] = smember_color,
|
||||
}
|
||||
|
||||
ImageMetaFunctions.__newindex = function (_table, _key, _value)
|
||||
local func = set_members_function_index [_key]
|
||||
if (func) then
|
||||
return func (_table, _value)
|
||||
else
|
||||
return _rawset (_table, _key, _value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> methods
|
||||
--> show & hide
|
||||
function ImageMetaFunctions:IsShown()
|
||||
return self.image:IsShown()
|
||||
end
|
||||
function ImageMetaFunctions:Show()
|
||||
return self.image:Show()
|
||||
end
|
||||
function ImageMetaFunctions:Hide()
|
||||
return self.image:Hide()
|
||||
end
|
||||
|
||||
-- setpoint
|
||||
function ImageMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
||||
v1, v2, v3, v4, v5 = gump: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
|
||||
|
||||
-- sizes
|
||||
function ImageMetaFunctions:SetSize (w, h)
|
||||
if (w) then
|
||||
self.image:SetWidth (w)
|
||||
end
|
||||
if (h) then
|
||||
return self.image:SetHeight (h)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> scripts
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
|
||||
function gump:NewImage (parent, container, name, member, w, h, texture, layer)
|
||||
|
||||
if (not parent) then
|
||||
return nil
|
||||
end
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (not name) then
|
||||
name = "DetailsPictureNumber" .. gump.PictureNameCounter
|
||||
gump.PictureNameCounter = gump.PictureNameCounter + 1
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
name = name:gsub ("$parent", parent:GetName())
|
||||
end
|
||||
|
||||
local ImageObject = {type = "image", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = ImageObject
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
texture = texture or ""
|
||||
|
||||
ImageObject.image = parent:CreateTexture (name, layer or "OVERLAY")
|
||||
ImageObject.widget = ImageObject.image
|
||||
|
||||
if (not APIImageFunctions) then
|
||||
APIImageFunctions = true
|
||||
local idx = getmetatable (ImageObject.image).__index
|
||||
for funcName, funcAddress in pairs (idx) do
|
||||
if (not ImageMetaFunctions [funcName]) then
|
||||
ImageMetaFunctions [funcName] = function (object, ...)
|
||||
local x = loadstring ( "return _G."..object.image:GetName()..":"..funcName.."(...)")
|
||||
return x (...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ImageObject.image.MyObject = ImageObject
|
||||
|
||||
if (w) then
|
||||
ImageObject.image:SetWidth (w)
|
||||
end
|
||||
if (h) then
|
||||
ImageObject.image:SetHeight (h)
|
||||
end
|
||||
if (texture) then
|
||||
ImageObject.image:SetTexture (texture)
|
||||
end
|
||||
|
||||
setmetatable (ImageObject, ImageMetaFunctions)
|
||||
|
||||
return ImageObject
|
||||
end
|
||||
@@ -0,0 +1,474 @@
|
||||
local _detalhes = _G._detalhes
|
||||
local g = _detalhes.gump
|
||||
|
||||
|
||||
local window = g:NewPanel (UIParent, _, "DetailsImageEdit", _, 100, 100, false)
|
||||
window:SetPoint ("center", UIParent, "center")
|
||||
window:SetResizable (true)
|
||||
window:SetMovable (true)
|
||||
tinsert (UISpecialFrames, "DetailsImageEdit")
|
||||
|
||||
local background = g:NewImage (window, _, "$parentBackground", _, _, _, nil, "background")
|
||||
background:SetAllPoints()
|
||||
background:SetTexture (0, 0, 0, .8)
|
||||
|
||||
local edit_texture = g:NewImage (window, _, "$parentImage", _, _, _, nil, "artwork")
|
||||
edit_texture:SetPoint ("center", window, "center")
|
||||
|
||||
local haveHFlip = false
|
||||
local haveVFlip = false
|
||||
|
||||
--> Top Slider
|
||||
|
||||
local topCoordTexture = g:NewImage (window, _, "$parentImageTopCoord", _, _, _, _, "overlay")
|
||||
topCoordTexture:SetPoint ("topleft", window, "topleft")
|
||||
topCoordTexture:SetPoint ("topright", window, "topright")
|
||||
topCoordTexture.color = "red"
|
||||
topCoordTexture.height = 1
|
||||
topCoordTexture.alpha = .2
|
||||
|
||||
local topSlider = g:NewSlider (window, _, "$parentTopSlider", "topSlider", 100, 100, 0.1, 100, 0.1, 0)
|
||||
topSlider:SetAllPoints (window.widget)
|
||||
topSlider:SetOrientation ("VERTICAL")
|
||||
topSlider.backdrop = nil
|
||||
topSlider.fractional = true
|
||||
topSlider:SetHook ("OnEnter", function() return true end)
|
||||
topSlider:SetHook ("OnLeave", function() return true end)
|
||||
|
||||
local topSliderThumpTexture = topSlider:CreateTexture (nil, "overlay")
|
||||
topSliderThumpTexture:SetTexture (1, 1, 1)
|
||||
topSliderThumpTexture:SetWidth (512)
|
||||
topSliderThumpTexture:SetHeight (3)
|
||||
topSlider:SetThumbTexture (topSliderThumpTexture)
|
||||
|
||||
topSlider:SetHook ("OnValueChange", function (_, _, value)
|
||||
topCoordTexture.image:SetHeight (window.frame:GetHeight()/100*value)
|
||||
end)
|
||||
|
||||
topSlider:Hide()
|
||||
|
||||
--> Bottom Slider
|
||||
|
||||
local bottomCoordTexture = g:NewImage (window, _, "$parentImageBottomCoord", _, _, _, _, "overlay")
|
||||
bottomCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
|
||||
bottomCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
|
||||
bottomCoordTexture.color = "red"
|
||||
bottomCoordTexture.height = 1
|
||||
bottomCoordTexture.alpha = .2
|
||||
|
||||
local bottomSlider= g:NewSlider (window, _, "$parentBottomSlider", "bottomSlider", 100, 100, 0.1, 100, 0.1, 100)
|
||||
bottomSlider:SetAllPoints (window.widget)
|
||||
bottomSlider:SetOrientation ("VERTICAL")
|
||||
bottomSlider.backdrop = nil
|
||||
bottomSlider.fractional = true
|
||||
bottomSlider:SetHook ("OnEnter", function() return true end)
|
||||
bottomSlider:SetHook ("OnLeave", function() return true end)
|
||||
|
||||
local bottomSliderThumpTexture = bottomSlider:CreateTexture (nil, "overlay")
|
||||
bottomSliderThumpTexture:SetTexture (1, 1, 1)
|
||||
bottomSliderThumpTexture:SetWidth (512)
|
||||
bottomSliderThumpTexture:SetHeight (3)
|
||||
bottomSlider:SetThumbTexture (bottomSliderThumpTexture)
|
||||
|
||||
bottomSlider:SetHook ("OnValueChange", function (_, _, value)
|
||||
value = math.abs (value-100)
|
||||
bottomCoordTexture.image:SetHeight (math.max (window.frame:GetHeight()/100*value, 1))
|
||||
end)
|
||||
|
||||
bottomSlider:Hide()
|
||||
|
||||
--> Left Slider
|
||||
|
||||
local leftCoordTexture = g:NewImage (window, _, "$parentImageLeftCoord", _, _, _, _, "overlay")
|
||||
leftCoordTexture:SetPoint ("topleft", window, "topleft", 0, 0)
|
||||
leftCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
|
||||
leftCoordTexture.color = "red"
|
||||
leftCoordTexture.width = 1
|
||||
leftCoordTexture.alpha = .2
|
||||
|
||||
local leftSlider = g:NewSlider (window, _, "$parentLeftSlider", "leftSlider", 100, 100, 0.1, 100, 0.1, 0.1)
|
||||
leftSlider:SetAllPoints (window.widget)
|
||||
leftSlider.backdrop = nil
|
||||
leftSlider.fractional = true
|
||||
leftSlider:SetHook ("OnEnter", function() return true end)
|
||||
leftSlider:SetHook ("OnLeave", function() return true end)
|
||||
|
||||
local leftSliderThumpTexture = leftSlider:CreateTexture (nil, "overlay")
|
||||
leftSliderThumpTexture:SetTexture (1, 1, 1)
|
||||
leftSliderThumpTexture:SetWidth (3)
|
||||
leftSliderThumpTexture:SetHeight (512)
|
||||
leftSlider:SetThumbTexture (leftSliderThumpTexture)
|
||||
|
||||
leftSlider:SetHook ("OnValueChange", function (_, _, value)
|
||||
leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*value)
|
||||
end)
|
||||
|
||||
leftSlider:Hide()
|
||||
|
||||
--> Right Slider
|
||||
|
||||
local rightCoordTexture = g:NewImage (window, _, "$parentImageRightCoord", _, _, _, _, "overlay")
|
||||
rightCoordTexture:SetPoint ("topright", window, "topright", 0, 0)
|
||||
rightCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
|
||||
rightCoordTexture.color = "red"
|
||||
rightCoordTexture.width = 1
|
||||
rightCoordTexture.alpha = .2
|
||||
|
||||
local rightSlider = g:NewSlider (window, _, "$parentRightSlider", "rightSlider", 100, 100, 0.1, 100, 0.1, 100)
|
||||
rightSlider:SetAllPoints (window.widget)
|
||||
rightSlider.backdrop = nil
|
||||
rightSlider.fractional = true
|
||||
rightSlider:SetHook ("OnEnter", function() return true end)
|
||||
rightSlider:SetHook ("OnLeave", function() return true end)
|
||||
--[
|
||||
local rightSliderThumpTexture = rightSlider:CreateTexture (nil, "overlay")
|
||||
rightSliderThumpTexture:SetTexture (1, 1, 1)
|
||||
rightSliderThumpTexture:SetWidth (3)
|
||||
rightSliderThumpTexture:SetHeight (512)
|
||||
rightSlider:SetThumbTexture (rightSliderThumpTexture)
|
||||
--]]
|
||||
rightSlider:SetHook ("OnValueChange", function (_, _, value)
|
||||
value = math.abs (value-100)
|
||||
rightCoordTexture.image:SetWidth (math.max (window.frame:GetWidth()/100*value, 1))
|
||||
end)
|
||||
|
||||
rightSlider:Hide()
|
||||
|
||||
--> Edit Buttons
|
||||
|
||||
local buttonsBackground = g:NewPanel (UIParent, _, "DetailsImageEditButtonsBg", _, 115, 225)
|
||||
buttonsBackground:SetPoint ("topleft", window, "topright", 2, 0)
|
||||
buttonsBackground:Hide()
|
||||
--buttonsBackground:SetMovable (true)
|
||||
tinsert (UISpecialFrames, "DetailsImageEditButtonsBg")
|
||||
|
||||
local alphaFrameShown = false
|
||||
|
||||
local editingSide = nil
|
||||
local lastButton = nil
|
||||
local alphaFrame
|
||||
local originalColor = {0.9999, 0.8196, 0}
|
||||
|
||||
local enableTexEdit = function (side, _, button)
|
||||
|
||||
if (alphaFrameShown) then
|
||||
alphaFrame:Hide()
|
||||
alphaFrameShown = false
|
||||
button.text:SetTextColor (unpack (originalColor))
|
||||
end
|
||||
|
||||
if (ColorPickerFrame:IsShown()) then
|
||||
ColorPickerFrame:Hide()
|
||||
end
|
||||
|
||||
if (lastButton) then
|
||||
lastButton.text:SetTextColor (unpack (originalColor))
|
||||
end
|
||||
|
||||
if (editingSide == side) then
|
||||
window [editingSide.."Slider"]:Hide()
|
||||
editingSide = nil
|
||||
return
|
||||
|
||||
elseif (editingSide) then
|
||||
window [editingSide.."Slider"]:Hide()
|
||||
end
|
||||
|
||||
editingSide = side
|
||||
button.text:SetTextColor (1, 1, 1)
|
||||
lastButton = button
|
||||
|
||||
window [side.."Slider"]:Show()
|
||||
end
|
||||
|
||||
local leftTexCoordButton = g:NewButton (buttonsBackground, _, "$parentLeftTexButton", _, 100, 20, enableTexEdit, "left", _, _, "Crop Left")
|
||||
leftTexCoordButton:SetPoint ("topleft", window, "topright", 10, -10)
|
||||
local rightTexCoordButton = g:NewButton (buttonsBackground, _, "$parentRightTexButton", _, 100, 20, enableTexEdit, "right", _, _, "Crop Right")
|
||||
rightTexCoordButton:SetPoint ("topleft", window, "topright", 10, -30)
|
||||
local topTexCoordButton = g:NewButton (buttonsBackground, _, "$parentTopTexButton", _, 100, 20, enableTexEdit, "top", _, _, "Crop Top")
|
||||
topTexCoordButton:SetPoint ("topleft", window, "topright", 10, -50)
|
||||
local bottomTexCoordButton = g:NewButton (buttonsBackground, _, "$parentBottomTexButton", _, 100, 20, enableTexEdit, "bottom", _, _, "Crop Bottom")
|
||||
bottomTexCoordButton:SetPoint ("topleft", window, "topright", 10, -70)
|
||||
leftTexCoordButton:InstallCustomTexture()
|
||||
rightTexCoordButton:InstallCustomTexture()
|
||||
topTexCoordButton:InstallCustomTexture()
|
||||
bottomTexCoordButton:InstallCustomTexture()
|
||||
|
||||
local Alpha = g:NewButton (buttonsBackground, _, "$parentBottomAlphaButton", _, 100, 20, alpha, _, _, _, "Transparency")
|
||||
Alpha:SetPoint ("topleft", window, "topright", 10, -110)
|
||||
Alpha:InstallCustomTexture()
|
||||
|
||||
--> overlay color
|
||||
local selectedColor = function (default)
|
||||
if (default) then
|
||||
edit_texture:SetVertexColor (unpack (default))
|
||||
else
|
||||
edit_texture:SetVertexColor (ColorPickerFrame:GetColorRGB())
|
||||
end
|
||||
end
|
||||
|
||||
local changeColor = function()
|
||||
|
||||
ColorPickerFrame.func = nil
|
||||
ColorPickerFrame.opacityFunc = nil
|
||||
ColorPickerFrame.cancelFunc = nil
|
||||
ColorPickerFrame.previousValues = nil
|
||||
|
||||
local r, g, b = edit_texture:GetVertexColor()
|
||||
ColorPickerFrame:SetColorRGB (r, g, b)
|
||||
ColorPickerFrame:SetParent (buttonsBackground.widget)
|
||||
ColorPickerFrame.hasOpacity = false
|
||||
ColorPickerFrame.previousValues = {r, g, b}
|
||||
ColorPickerFrame.func = selectedColor
|
||||
ColorPickerFrame.cancelFunc = selectedColor
|
||||
ColorPickerFrame:ClearAllPoints()
|
||||
ColorPickerFrame:SetPoint ("left", buttonsBackground.widget, "right")
|
||||
ColorPickerFrame:Show()
|
||||
|
||||
if (alphaFrameShown) then
|
||||
alphaFrame:Hide()
|
||||
alphaFrameShown = false
|
||||
Alpha.button.text:SetTextColor (unpack (originalColor))
|
||||
end
|
||||
|
||||
if (lastButton) then
|
||||
lastButton.text:SetTextColor (unpack (originalColor))
|
||||
if (editingSide) then
|
||||
window [editingSide.."Slider"]:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local changeColorButton = g:NewButton (buttonsBackground, _, "$parentOverlayColorButton", _, 100, 20, changeColor, _, _, _, "Overlay Color")
|
||||
changeColorButton:SetPoint ("topleft", window, "topright", 10, -90)
|
||||
changeColorButton:InstallCustomTexture()
|
||||
|
||||
alphaFrame = g:NewPanel (buttonsBackground, _, "DetailsImageEditAlphaBg", _, 40, 225)
|
||||
alphaFrame:SetPoint ("topleft", buttonsBackground, "topright", 2, 0)
|
||||
alphaFrame:Hide()
|
||||
local alphaSlider = g:NewSlider (alphaFrame, _, "$parentAlphaSlider", "alphaSlider", 30, 220, 1, 100, 1, edit_texture:GetAlpha()*100)
|
||||
alphaSlider:SetPoint ("top", alphaFrame, "top", 0, -5)
|
||||
alphaSlider:SetOrientation ("VERTICAL")
|
||||
alphaSlider.thumb:SetSize (40, 30)
|
||||
--leftSlider.backdrop = nil
|
||||
--leftSlider.fractional = true
|
||||
|
||||
local alpha = function(_, _, button)
|
||||
|
||||
if (ColorPickerFrame:IsShown()) then
|
||||
ColorPickerFrame:Hide()
|
||||
end
|
||||
|
||||
if (lastButton) then
|
||||
lastButton.text:SetTextColor (unpack (originalColor))
|
||||
if (editingSide) then
|
||||
window [editingSide.."Slider"]:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
if (not alphaFrameShown) then
|
||||
alphaFrame:Show()
|
||||
alphaSlider:SetValue (edit_texture:GetAlpha()*100)
|
||||
alphaFrameShown = true
|
||||
button.text:SetTextColor (1, 1, 1)
|
||||
else
|
||||
alphaFrame:Hide()
|
||||
alphaFrameShown = false
|
||||
button.text:SetTextColor (unpack (originalColor))
|
||||
end
|
||||
end
|
||||
|
||||
Alpha.clickfunction = alpha
|
||||
|
||||
alphaSlider:SetHook ("OnValueChange", function (_, _, value)
|
||||
edit_texture:SetAlpha (value/100)
|
||||
end)
|
||||
|
||||
local resizer = CreateFrame ("Button", nil, window.widget)
|
||||
resizer:SetNormalTexture ("Interface\\AddOns\\Details\\images\\ResizeGripD")
|
||||
resizer:SetHighlightTexture ("Interface\\AddOns\\Details\\images\\ResizeGripD")
|
||||
resizer:SetWidth (16)
|
||||
resizer:SetHeight (16)
|
||||
resizer:SetPoint ("BOTTOMRIGHT", window.widget, "BOTTOMRIGHT", 0, 0)
|
||||
resizer:EnableMouse (true)
|
||||
resizer:SetFrameLevel (window.widget:GetFrameLevel() + 2)
|
||||
|
||||
resizer:SetScript ("OnMouseDown", function (self, button)
|
||||
window.widget:StartSizing ("BOTTOMRIGHT")
|
||||
end)
|
||||
|
||||
resizer:SetScript ("OnMouseUp", function (self, button)
|
||||
window.widget:StopMovingOrSizing()
|
||||
end)
|
||||
|
||||
window.widget:SetScript ("OnMouseDown", function()
|
||||
window.widget:StartMoving()
|
||||
end)
|
||||
window.widget:SetScript ("OnMouseUp", function()
|
||||
window.widget:StopMovingOrSizing()
|
||||
end)
|
||||
|
||||
window.widget:SetScript ("OnSizeChanged", function()
|
||||
edit_texture.width = window.width
|
||||
edit_texture.height = window.height
|
||||
leftSliderThumpTexture:SetHeight (window.height)
|
||||
rightSliderThumpTexture:SetHeight (window.height)
|
||||
topSliderThumpTexture:SetWidth (window.width)
|
||||
bottomSliderThumpTexture:SetWidth (window.width)
|
||||
|
||||
rightCoordTexture.image:SetWidth (math.max ( (window.frame:GetWidth() / 100 * math.abs (rightSlider:GetValue()-100)), 1))
|
||||
leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*leftSlider:GetValue())
|
||||
bottomCoordTexture:SetHeight (math.max ( (window.frame:GetHeight() / 100 * math.abs (bottomSlider:GetValue()-100)), 1))
|
||||
topCoordTexture:SetHeight (window.frame:GetHeight()/100*topSlider:GetValue())
|
||||
end)
|
||||
|
||||
--> change size
|
||||
local resizeLabel = g:NewLabel (window, _, "$parentResizerIndicator", _, "RESIZE", _, 9)
|
||||
resizeLabel:SetPoint ("right", resizer, "left", -2, 0)
|
||||
|
||||
--> flip
|
||||
local flip = function (side)
|
||||
if (side == 1) then
|
||||
if (not haveHFlip) then
|
||||
if (not haveVFlip) then
|
||||
edit_texture:SetTexCoord (1, 0, 0, 1)
|
||||
else
|
||||
edit_texture:SetTexCoord (1, 0, 1, 0)
|
||||
end
|
||||
rightCoordTexture:Hide()
|
||||
leftCoordTexture:Hide()
|
||||
leftTexCoordButton:Disable()
|
||||
rightTexCoordButton:Disable()
|
||||
else
|
||||
if (not haveVFlip) then
|
||||
edit_texture:SetTexCoord (0, 1, 0, 1)
|
||||
else
|
||||
edit_texture:SetTexCoord (0, 1, 1, 0)
|
||||
end
|
||||
rightCoordTexture:Show()
|
||||
leftCoordTexture:Show()
|
||||
leftTexCoordButton:Enable()
|
||||
rightTexCoordButton:Enable()
|
||||
end
|
||||
haveHFlip = not haveHFlip
|
||||
|
||||
elseif (side == 2) then
|
||||
if (not haveVFlip) then
|
||||
if (not haveHFlip) then
|
||||
edit_texture:SetTexCoord (0, 1, 1, 0)
|
||||
else
|
||||
edit_texture:SetTexCoord (1, 0, 1, 0)
|
||||
end
|
||||
topCoordTexture:Hide()
|
||||
bottomCoordTexture:Hide()
|
||||
topTexCoordButton:Disable()
|
||||
bottomTexCoordButton:Disable()
|
||||
else
|
||||
if (not haveHFlip) then
|
||||
edit_texture:SetTexCoord (0, 1, 0, 1)
|
||||
else
|
||||
edit_texture:SetTexCoord (1, 0, 0, 1)
|
||||
end
|
||||
topCoordTexture:Show()
|
||||
bottomCoordTexture:Show()
|
||||
topTexCoordButton:Enable()
|
||||
bottomTexCoordButton:Enable()
|
||||
end
|
||||
haveVFlip = not haveVFlip
|
||||
end
|
||||
end
|
||||
|
||||
local flipButtonH = g:NewButton (buttonsBackground, _, "$parentFlipButton", _, 100, 20, flip, 1, _, _, "Flip Horizontal")
|
||||
flipButtonH:SetPoint ("topleft", window, "topright", 10, -140)
|
||||
flipButtonH:InstallCustomTexture()
|
||||
--
|
||||
local flipButtonV = g:NewButton (buttonsBackground, _, "$parentFlipButton2", _, 100, 20, flip, 2, _, _, "Flip Vertical")
|
||||
flipButtonV:SetPoint ("topleft", window, "topright", 10, -160)
|
||||
flipButtonV:InstallCustomTexture()
|
||||
|
||||
--> accept
|
||||
local accept = function()
|
||||
buttonsBackground:Hide()
|
||||
window:Hide()
|
||||
alphaFrame:Hide()
|
||||
ColorPickerFrame:Hide()
|
||||
|
||||
local coords = {}
|
||||
if (haveHFlip) then
|
||||
coords [1] = 1
|
||||
coords [2] = 0
|
||||
else
|
||||
coords [1] = leftSlider.value/100
|
||||
coords [2] = rightSlider.value /100
|
||||
end
|
||||
|
||||
if (haveVFlip) then
|
||||
coords [3] = 1
|
||||
coords [4] = 0
|
||||
else
|
||||
coords [3] = topSlider.value/100
|
||||
coords [4] = bottomSlider.value/100
|
||||
end
|
||||
|
||||
return window.callback_func (edit_texture.width, edit_texture.height, {edit_texture:GetVertexColor()}, edit_texture:GetAlpha(), coords)
|
||||
end
|
||||
|
||||
local acceptButton = g:NewButton (buttonsBackground, _, "$parentAcceptButton", _, 100, 20, accept, _, _, _, "DONE")
|
||||
acceptButton:SetPoint ("topleft", window, "topright", 10, -200)
|
||||
acceptButton:InstallCustomTexture()
|
||||
|
||||
-- fazer botao de editar a cor
|
||||
-- fazer botao de editar o tamanho
|
||||
-- fazer botao de okey e retornar os valores
|
||||
|
||||
|
||||
window:Hide()
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local ttexcoord
|
||||
function g:ImageEditor (callback, texture, texcoord, colors)
|
||||
|
||||
edit_texture:SetTexture (texture)
|
||||
|
||||
colors = colors or {1, 1, 1, 1}
|
||||
edit_texture:SetVertexColor (colors [1], colors [2], colors [3])
|
||||
|
||||
edit_texture:SetAlpha (colors [4] or 1)
|
||||
|
||||
texcoord = texcoord or {0, 1, 0, 1}
|
||||
ttexcoord = texcoord
|
||||
|
||||
_detalhes:ScheduleTimer ("RefreshImageEditor", 0.2)
|
||||
|
||||
window:Show()
|
||||
window.callback_func = callback
|
||||
buttonsBackground:Show()
|
||||
end
|
||||
|
||||
function _detalhes:RefreshImageEditor()
|
||||
|
||||
window.width = edit_texture.width
|
||||
window.height = edit_texture.height
|
||||
|
||||
if (ttexcoord[1] == 1 and ttexcoord[2] == 0) then
|
||||
haveHFlip = false
|
||||
flip (1)
|
||||
else
|
||||
haveHFlip = true
|
||||
flip (1)
|
||||
leftSlider:SetValue (ttexcoord[1]*100)
|
||||
rightSlider:SetValue (ttexcoord[2]*100)
|
||||
end
|
||||
|
||||
if (ttexcoord[3] == 1 and ttexcoord[4] == 0) then
|
||||
haveVFlip = false
|
||||
flip (2)
|
||||
else
|
||||
haveVFlip = true
|
||||
flip (2)
|
||||
topSlider:SetValue (ttexcoord[3]*100)
|
||||
bottomSlider:SetValue (ttexcoord[4]*100)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,526 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
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
|
||||
local loadstring = loadstring --> lua local
|
||||
|
||||
local cleanfunction = function() end
|
||||
local APISliderFunctions = false
|
||||
local SliderMetaFunctions = {}
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
|
||||
SliderMetaFunctions.__call = function (_table, value)
|
||||
if (not value) then
|
||||
return _table.slider:GetValue()
|
||||
else
|
||||
return _table.slider:SetValue (value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--> tooltip
|
||||
local gmember_tooltip = function (_object)
|
||||
return _object:GetTooltip()
|
||||
end
|
||||
--> shown
|
||||
local gmember_shown = function (_object)
|
||||
return _object:IsShown()
|
||||
end
|
||||
--> frame width
|
||||
local gmember_width = function (_object)
|
||||
return _object.slider:GetWidth()
|
||||
end
|
||||
--> frame height
|
||||
local gmember_height = function (_object)
|
||||
return _object.slider:GetHeight()
|
||||
end
|
||||
--> locked
|
||||
local gmember_locked = function (_object)
|
||||
return _rawget (_object, "lockdown")
|
||||
end
|
||||
--> fractional
|
||||
local gmember_fractional = function (_object, _value)
|
||||
return _rawget (_object, "useDecimals")
|
||||
end
|
||||
|
||||
local get_members_function_index = {
|
||||
["tooltip"] = gmember_tooltip,
|
||||
["shown"] = gmember_shown,
|
||||
["width"] = gmember_width,
|
||||
["height"] = gmember_height,
|
||||
["locked"] = gmember_locked,
|
||||
["fractional"] = gmember_fractional,
|
||||
}
|
||||
|
||||
SliderMetaFunctions.__index = function (_table, _member_requested)
|
||||
|
||||
local func = get_members_function_index [_member_requested]
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = _rawget (_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
return SliderMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--> tooltip
|
||||
local smember_tooltip = function (_object, _value)
|
||||
return _object:SetTooltip (_value)
|
||||
end
|
||||
--> 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
|
||||
--> frame width
|
||||
local smember_width = function (_object, _value)
|
||||
return _object.slider:SetWidth (_value)
|
||||
end
|
||||
--> frame height
|
||||
local smember_height = function (_object, _value)
|
||||
return _object.slider:SetHeight (_value)
|
||||
end
|
||||
--> locked
|
||||
local smember_locked = function (_object, _value)
|
||||
if (_value) then
|
||||
return self:Disable()
|
||||
else
|
||||
return self:Enable()
|
||||
end
|
||||
end
|
||||
--> backdrop
|
||||
local smember_backdrop = function (_object, _value)
|
||||
return _object.slider:SetBackdrop (_value)
|
||||
end
|
||||
--> fractional
|
||||
local smember_fractional = function (_object, _value)
|
||||
return _rawset (_object, "useDecimals", _value)
|
||||
end
|
||||
|
||||
local set_members_function_index = {
|
||||
["tooltip"] = smember_tooltip,
|
||||
["show"] = smember_show,
|
||||
["hide"] = smember_hide,
|
||||
["backdrop"] = smember_backdrop,
|
||||
["width"] = smember_width,
|
||||
["height"] = smember_height,
|
||||
["locked"] = smember_locked,
|
||||
["fractional"] = smember_fractional,
|
||||
}
|
||||
|
||||
SliderMetaFunctions.__newindex = function (_table, _key, _value)
|
||||
local func = set_members_function_index [_key]
|
||||
if (func) then
|
||||
return func (_table, _value)
|
||||
else
|
||||
return _rawset (_table, _key, _value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> methods
|
||||
|
||||
--> show & hide
|
||||
function SliderMetaFunctions:IsShown()
|
||||
return self.slider:IsShown()
|
||||
end
|
||||
function SliderMetaFunctions:Show()
|
||||
return self.slider:Show()
|
||||
end
|
||||
function SliderMetaFunctions:Hide()
|
||||
return self.slider:Hide()
|
||||
end
|
||||
|
||||
--> fixed value
|
||||
function SliderMetaFunctions:SetFixedParameter (value)
|
||||
_rawset (self, "FixedValue", value)
|
||||
end
|
||||
|
||||
-- thumb size
|
||||
function SliderMetaFunctions:SetThumbSize (w, h)
|
||||
if (not w) then
|
||||
w = self.thumb:GetWidth()
|
||||
end
|
||||
if (not h) then
|
||||
h = self.thumb:GetHeight()
|
||||
end
|
||||
return self.thumb:SetSize (w, h)
|
||||
end
|
||||
|
||||
|
||||
-- setpoint
|
||||
function SliderMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
||||
v1, v2, v3, v4, v5 = gump: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
|
||||
|
||||
-- sizes
|
||||
function SliderMetaFunctions:SetSize (w, h)
|
||||
if (w) then
|
||||
self.slider:SetWidth (w)
|
||||
end
|
||||
if (h) then
|
||||
return self.slider:SetHeight (h)
|
||||
end
|
||||
end
|
||||
|
||||
-- tooltip
|
||||
function SliderMetaFunctions:SetTooltip (tooltip)
|
||||
if (tooltip) then
|
||||
return _rawset (self, "have_tooltip", tooltip)
|
||||
else
|
||||
return _rawset (self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
function SliderMetaFunctions:GetTooltip()
|
||||
return _rawget (self, "have_tooltip")
|
||||
end
|
||||
|
||||
-- frame levels
|
||||
function SliderMetaFunctions:GetFrameLevel()
|
||||
return self.slider:GetFrameLevel()
|
||||
end
|
||||
function SliderMetaFunctions:SetFrameLevel (level, frame)
|
||||
if (not frame) then
|
||||
return self.slider:SetFrameLevel (level)
|
||||
else
|
||||
local framelevel = frame:GetFrameLevel (frame) + level
|
||||
return self.slider:SetFrameLevel (framelevel)
|
||||
end
|
||||
end
|
||||
|
||||
-- frame stratas
|
||||
function SliderMetaFunctions:SetFrameStrata()
|
||||
return self.slider:GetFrameStrata()
|
||||
end
|
||||
function SliderMetaFunctions:SetFrameStrata (strata)
|
||||
if (_type (strata) == "table") then
|
||||
self.slider:SetFrameStrata (strata:GetFrameStrata())
|
||||
else
|
||||
self.slider:SetFrameStrata (strata)
|
||||
end
|
||||
end
|
||||
|
||||
-- enabled
|
||||
function SliderMetaFunctions:IsEnabled()
|
||||
return not _rawget (self, "lockdown")
|
||||
end
|
||||
function SliderMetaFunctions:Enable()
|
||||
self.slider:Enable()
|
||||
self.slider.lock:Hide()
|
||||
self.slider.amt:Show()
|
||||
return _rawset (self, "lockdown", false)
|
||||
end
|
||||
function SliderMetaFunctions:Disable()
|
||||
self.slider:Disable()
|
||||
self.slider.lock:Show()
|
||||
self.slider.amt:Hide()
|
||||
return _rawset (self, "lockdown", true)
|
||||
end
|
||||
|
||||
--> hooks
|
||||
function SliderMetaFunctions:SetHook (hookType, func)
|
||||
if (func) then
|
||||
_rawset (self, hookType.."Hook", func)
|
||||
else
|
||||
_rawset (self, hookType.."Hook", nil)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> scripts
|
||||
|
||||
local OnEnter = function (slider)
|
||||
|
||||
if (slider.MyObject.OnEnterHook) then
|
||||
local interrupt = slider.MyObject.OnEnterHook (slider)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
slider.thumb:SetAlpha (1)
|
||||
|
||||
if (slider.MyObject.have_tooltip) then
|
||||
GameCooltip:Reset()
|
||||
GameCooltip:AddLine (slider.MyObject.have_tooltip)
|
||||
GameCooltip:ShowCooltip (slider, "tooltip")
|
||||
end
|
||||
|
||||
local parent = slider:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local OnLeave = function (slider)
|
||||
if (slider.MyObject.OnLeaveHook) then
|
||||
local interrupt = slider.MyObject.OnLeaveHook (slider)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
slider.thumb:SetAlpha (.7)
|
||||
|
||||
if (slider.MyObject.have_tooltip) then
|
||||
_detalhes.popup:ShowMe (false)
|
||||
end
|
||||
|
||||
local parent = slider:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient (false)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local OnHide = function (slider)
|
||||
if (slider.MyObject.OnHideHook) then
|
||||
local interrupt = slider.MyObject.OnHideHook (slider)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnShow = function (slider)
|
||||
if (slider.MyObject.OnShowHook) then
|
||||
local interrupt = slider.MyObject.OnShowHook (slider)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnValueChanged = function (slider)
|
||||
|
||||
local amt = slider:GetValue()
|
||||
|
||||
if (slider.MyObject.OnValueChangeHook) then
|
||||
local interrupt = slider.MyObject.OnValueChangeHook (slider, slider.MyObject.FixedValue, amt)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (amt < 10 and amt >= 1) then
|
||||
amt = "0"..amt
|
||||
end
|
||||
|
||||
if (slider.MyObject.useDecimals) then
|
||||
slider.amt:SetText (string.format ("%.1f", amt))
|
||||
else
|
||||
slider.amt:SetText (math.floor (amt))
|
||||
end
|
||||
slider.MyObject.value = amt
|
||||
end
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
|
||||
function gump:NewSwitch (parent, container, name, member, w, h, ltext, rtext, defaultv)
|
||||
|
||||
--> early checks
|
||||
if (not name) then
|
||||
return nil
|
||||
elseif (not parent) then
|
||||
return nil
|
||||
end
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
--> defaults
|
||||
ltext = ltext or "OFF"
|
||||
rtext = rtext or "ON"
|
||||
|
||||
if (type (defaultv) == "boolean" and not defaultv) then
|
||||
defaultv = 1
|
||||
elseif (type (defaultv) == "boolean" and defaultv) then
|
||||
defaultv = 2
|
||||
else
|
||||
defaultv = defaultv or 1
|
||||
end
|
||||
|
||||
--> build frames
|
||||
local slider = gump:NewSlider (parent, container, name, member, w, h, 1, 2, 1, defaultv)
|
||||
|
||||
slider:SetHook ("OnValueChange", function (self)
|
||||
if (slider:GetValue() == 1) then
|
||||
slider.amt:SetText (ltext)
|
||||
if (slider.OnSwitch) then
|
||||
slider.OnSwitch (slider, slider.FixedValue, false)
|
||||
end
|
||||
else
|
||||
slider.amt:SetText (rtext)
|
||||
if (slider.OnSwitch) then
|
||||
slider.OnSwitch (slider, slider.FixedValue, true)
|
||||
end
|
||||
end
|
||||
return true
|
||||
end)
|
||||
|
||||
slider:SetValue (1)
|
||||
slider:SetValue (2)
|
||||
slider:SetValue (defaultv)
|
||||
|
||||
return slider
|
||||
end
|
||||
|
||||
function gump:NewSlider (parent, container, name, member, w, h, min, max, step, defaultv, isDecemal)
|
||||
|
||||
--> early checks
|
||||
if (not name) then
|
||||
return nil
|
||||
elseif (not parent) then
|
||||
return nil
|
||||
end
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
name = name:gsub ("$parent", parent:GetName())
|
||||
end
|
||||
|
||||
local SliderObject = {type = "slider", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = SliderObject
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
--> defaults
|
||||
min = min or 1
|
||||
max = max or 2
|
||||
step = step or 1
|
||||
defaultv = defaultv or min
|
||||
|
||||
--> default members:
|
||||
--> hooks
|
||||
SliderObject.OnEnterHook = nil
|
||||
SliderObject.OnLeaveHook = nil
|
||||
SliderObject.OnHideHook = nil
|
||||
SliderObject.OnShowHook = nil
|
||||
SliderObject.OnValueChangeHook = nil
|
||||
--> misc
|
||||
SliderObject.lockdown = false
|
||||
SliderObject.container = container
|
||||
SliderObject.have_tooltip = nil
|
||||
SliderObject.FixedValue = nil
|
||||
SliderObject.useDecimals = isDecemal or false
|
||||
|
||||
--SliderObject.slider = CreateFrame ("slider", name, parent, "DetailsSliderTemplate")
|
||||
SliderObject.slider = CreateFrame ("slider", name, parent)
|
||||
SliderObject.widget = SliderObject.slider
|
||||
|
||||
if (not APISliderFunctions) then
|
||||
APISliderFunctions = true
|
||||
local idx = getmetatable (SliderObject.slider).__index
|
||||
for funcName, funcAddress in pairs (idx) do
|
||||
if (not SliderMetaFunctions [funcName]) then
|
||||
SliderMetaFunctions [funcName] = function (object, ...)
|
||||
local x = loadstring ( "return _G."..object.slider:GetName()..":"..funcName.."(...)")
|
||||
return x (...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SliderObject.slider.MyObject = SliderObject
|
||||
SliderObject.slider:SetWidth (w or 232)
|
||||
SliderObject.slider:SetHeight (h or 20)
|
||||
SliderObject.slider:SetOrientation ("horizontal")
|
||||
SliderObject.slider:SetMinMaxValues (min, max)
|
||||
SliderObject.slider:SetValueStep (step)
|
||||
SliderObject.slider:SetValue (defaultv)
|
||||
SliderObject.value = defaultv
|
||||
|
||||
--SliderObject.amt = _G [name .. "_Amt"]
|
||||
--SliderObject.lock = _G [name .. "_LockTexture"]
|
||||
--SliderObject.thumb = _G [name .. "_ThumbTexture"]
|
||||
|
||||
SliderObject.slider:SetBackdrop ({edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", edgeSize = 8})
|
||||
SliderObject.slider:SetBackdropColor (0.9, 0.7, 0.7, 1.0)
|
||||
|
||||
SliderObject.thumb = SliderObject.slider:CreateTexture (nil, "artwork")
|
||||
SliderObject.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
|
||||
--SliderObject.thumb:SetSize (30, 24)
|
||||
SliderObject.thumb:SetSize (30+(h*0.2), h*1.2)
|
||||
SliderObject.thumb:SetAlpha (0.7)
|
||||
SliderObject.slider:SetThumbTexture (SliderObject.thumb)
|
||||
SliderObject.slider.thumb = SliderObject.thumb
|
||||
|
||||
SliderObject.amt = SliderObject.slider:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
|
||||
|
||||
local amt = defaultv
|
||||
if (amt < 10 and amt >= 1) then
|
||||
amt = "0"..amt
|
||||
end
|
||||
|
||||
if (SliderObject.useDecimals) then
|
||||
SliderObject.amt:SetText (string.format ("%.1f", amt))
|
||||
else
|
||||
SliderObject.amt:SetText (math.floor (amt))
|
||||
end
|
||||
|
||||
SliderObject.amt:SetTextColor (.8, .8, .8, 1)
|
||||
SliderObject.amt:SetPoint ("center", SliderObject.thumb, "center")
|
||||
SliderObject.slider.amt = SliderObject.amt
|
||||
|
||||
--> hooks
|
||||
SliderObject.slider:SetScript ("OnEnter", OnEnter)
|
||||
SliderObject.slider:SetScript ("OnLeave", OnLeave)
|
||||
SliderObject.slider:SetScript ("OnHide", OnHide)
|
||||
SliderObject.slider:SetScript ("OnShow", OnShow)
|
||||
SliderObject.slider:SetScript ("OnValueChanged", OnValueChanged)
|
||||
|
||||
_setmetatable (SliderObject, SliderMetaFunctions)
|
||||
|
||||
return SliderObject
|
||||
|
||||
end
|
||||
@@ -0,0 +1,630 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
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
|
||||
|
||||
local cleanfunction = function() end
|
||||
local SplitBarMetaFunctions = {}
|
||||
local APISplitBarFunctions
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
|
||||
SplitBarMetaFunctions.__call = function (_table, value)
|
||||
if (not value) then
|
||||
return _table.statusbar:GetValue()
|
||||
else
|
||||
_table.div:SetPoint ("left", _table.statusbar, "left", value * (_table.statusbar:GetWidth()/100) - 18, 0)
|
||||
return _table.statusbar:SetValue (value)
|
||||
end
|
||||
end
|
||||
|
||||
SplitBarMetaFunctions.__add = function (v1, v2)
|
||||
if (_type (v1) == "table") then
|
||||
local v = v1.statusbar:GetValue()
|
||||
v = v + v2
|
||||
v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
|
||||
v1.statusbar:SetValue (v)
|
||||
else
|
||||
local v = v2.statusbar:GetValue()
|
||||
v = v + v1
|
||||
v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
|
||||
v2.statusbar:SetValue (v)
|
||||
end
|
||||
end
|
||||
|
||||
SplitBarMetaFunctions.__sub = function (v1, v2)
|
||||
if (_type (v1) == "table") then
|
||||
local v = v1.statusbar:GetValue()
|
||||
v = v - v2
|
||||
v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
|
||||
v1.statusbar:SetValue (v)
|
||||
else
|
||||
local v = v2.statusbar:GetValue()
|
||||
v = v - v1
|
||||
v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
|
||||
v2.statusbar:SetValue (v)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--> tooltip
|
||||
local function gmember_tooltip (_object)
|
||||
return _object:GetTooltip()
|
||||
end
|
||||
--> shown
|
||||
local gmember_shown = function (_object)
|
||||
return _object.statusbar:IsShown()
|
||||
end
|
||||
--> frame width
|
||||
local gmember_width = function (_object)
|
||||
return _object.statusbar:GetWidth()
|
||||
end
|
||||
--> frame height
|
||||
local gmember_height = function (_object)
|
||||
return _object.statusbar:GetHeight()
|
||||
end
|
||||
--> value
|
||||
local gmember_value = function (_object)
|
||||
return _object.statusbar:GetValue()
|
||||
end
|
||||
--> right text
|
||||
local gmember_rtext = function (_object)
|
||||
return _object.textright:GetText()
|
||||
end
|
||||
--> left text
|
||||
local gmember_ltext = function (_object)
|
||||
return _object.textleft:GetText()
|
||||
end
|
||||
--> right color
|
||||
local gmember_rcolor = function (_object)
|
||||
return _object.background.original_colors
|
||||
end
|
||||
--> left color
|
||||
local gmember_lcolor = function (_object)
|
||||
return _object.texture.original_colors
|
||||
end
|
||||
--> right icon
|
||||
local gmember_ricon = function (_object)
|
||||
return _object.iconright:GetTexture()
|
||||
end
|
||||
--> left icon
|
||||
local gmember_licon = function (_object)
|
||||
return _object.iconleft:GetTexture()
|
||||
end
|
||||
--> texture
|
||||
local gmember_texture = function (_object)
|
||||
return _object.texture:GetTexture()
|
||||
end
|
||||
--> font size
|
||||
local gmember_textsize = function (_object)
|
||||
local _, fontsize = _object.textleft:GetFont()
|
||||
return fontsize
|
||||
end
|
||||
--> font face
|
||||
local gmember_textfont = function (_object)
|
||||
local fontface = _object.textleft:GetFont()
|
||||
return fontface
|
||||
end
|
||||
--> font color
|
||||
local gmember_textcolor = function (_object)
|
||||
return _object.textleft:GetTextColor()
|
||||
end
|
||||
|
||||
local get_members_function_index = {
|
||||
["tooltip"] = gmember_tooltip,
|
||||
["shown"] = gmember_shown,
|
||||
["width"] = gmember_width,
|
||||
["height"] = gmember_height,
|
||||
["value"] = gmember_value,
|
||||
["righttext"] = gmember_rtext,
|
||||
["lefttext"] = gmember_ltext,
|
||||
["rightcolor"] = gmember_rcolor,
|
||||
["leftcolor"] = gmember_lcolor,
|
||||
["righticon"] = gmember_ricon,
|
||||
["lefticon"] = gmember_licon,
|
||||
["texture"] = gmember_texture,
|
||||
["fontsize"] = gmember_textsize,
|
||||
["fontface"] = gmember_textfont,
|
||||
["fontcolor"] = gmember_textcolor,
|
||||
["textsize"] = gmember_textsize, --alias
|
||||
["textfont"] = gmember_textfont, --alias
|
||||
["textcolor"] = gmember_textcolor --alias
|
||||
}
|
||||
|
||||
SplitBarMetaFunctions.__index = function (_table, _member_requested)
|
||||
|
||||
local func = get_members_function_index [_member_requested]
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = _rawget (_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
return SplitBarMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--> tooltip
|
||||
local smember_tooltip = function (_object, _value)
|
||||
return _object:SetTooltip (_value)
|
||||
end
|
||||
--> show
|
||||
local smember_shown = function (_object, _value)
|
||||
if (_value) then
|
||||
return _object:Show()
|
||||
else
|
||||
return _object:Hide()
|
||||
end
|
||||
end
|
||||
--> hide
|
||||
local smember_hide = function (_object, _value)
|
||||
if (_value) then
|
||||
return _object:Hide()
|
||||
else
|
||||
return _object:Show()
|
||||
end
|
||||
end
|
||||
--> width
|
||||
local smember_width = function (_object, _value)
|
||||
return _object.statusbar:SetWidth (_value)
|
||||
end
|
||||
--> height
|
||||
local smember_height = function (_object, _value)
|
||||
return _object.statusbar:SetHeight (_value)
|
||||
end
|
||||
--> statusbar value
|
||||
local smember_value = function (_object, _value)
|
||||
_object.statusbar:SetValue (_value)
|
||||
return _object.div:SetPoint ("left", _object.statusbar, "left", _value * (_object.statusbar:GetWidth()/100) - 18, 0)
|
||||
end
|
||||
--> right text
|
||||
local smember_rtext = function (_object, _value)
|
||||
return _object.textright:SetText (_value)
|
||||
end
|
||||
--> left text
|
||||
local smember_ltext = function (_object, _value)
|
||||
return _object.textleft:SetText (_value)
|
||||
end
|
||||
--> right color
|
||||
local smember_rcolor = function (_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (_value)
|
||||
_object.background.original_colors = {_value1, _value2, _value3, _value4}
|
||||
return _object.background:SetVertexColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
--> left color
|
||||
local smember_lcolor = function (_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (_value)
|
||||
|
||||
_object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
|
||||
_object.texture.original_colors = {_value1, _value2, _value3, _value4}
|
||||
return _object.texture:SetVertexColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
--> right icon
|
||||
local smember_ricon = function (_object, _value)
|
||||
if (type (_value) == "table") then
|
||||
local _value1, _value2 = _unpack (_value)
|
||||
_object.iconright:SetTexture (_value1)
|
||||
if (_value2) then
|
||||
_object.iconright:SetTexCoord (_unpack (_value2))
|
||||
end
|
||||
else
|
||||
_object.iconright:SetTexture (_value)
|
||||
end
|
||||
return
|
||||
end
|
||||
--> left icon
|
||||
local smember_licon = function (_object, _value)
|
||||
if (type (_value) == "table") then
|
||||
local _value1, _value2 = _unpack (_value)
|
||||
_object.iconleft:SetTexture (_value1)
|
||||
if (_value2) then
|
||||
_object.iconleft:SetTexCoord (_unpack (_value2))
|
||||
end
|
||||
else
|
||||
_object.iconleft:SetTexture (_value)
|
||||
end
|
||||
return
|
||||
end
|
||||
--> texture
|
||||
local smember_texture = function (_object, _value)
|
||||
if (type (_value) == "table") then
|
||||
local _value1, _value2 = _unpack (_value)
|
||||
_object.texture:SetTexture (_value1)
|
||||
_object.background:SetTexture (_value1)
|
||||
if (_value2) then
|
||||
_object.texture:SetTexCoord (_unpack (_value2))
|
||||
_object.background:SetTexCoord (_unpack (_value2))
|
||||
end
|
||||
else
|
||||
_object.texture:SetTexture (_value)
|
||||
_object.background:SetTexture (_value)
|
||||
end
|
||||
return
|
||||
end
|
||||
--> font face
|
||||
local smember_textfont = function (_object, _value)
|
||||
_detalhes:SetFontFace (_object.textleft, _value)
|
||||
return _detalhes:SetFontFace (_object.textright, _value)
|
||||
end
|
||||
--> font size
|
||||
local smember_textsize = function (_object, _value)
|
||||
_detalhes:SetFontSize (_object.textleft, _value)
|
||||
return _detalhes:SetFontSize (_object.textright, _value)
|
||||
end
|
||||
--> font color
|
||||
local smember_textcolor = function (_object, _value)
|
||||
local _value1, _value2, _value3, _value4 = gump:ParseColors (_value)
|
||||
_object.textleft:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
return _object.textright:SetTextColor (_value1, _value2, _value3, _value4)
|
||||
end
|
||||
|
||||
local set_members_function_index = {
|
||||
["tooltip"] = smember_tooltip,
|
||||
["shown"] = smember_shown,
|
||||
["width"] = smember_width,
|
||||
["height"] = smember_height,
|
||||
["value"] = smember_value,
|
||||
["righttext"] = smember_rtext,
|
||||
["lefttext"] = smember_ltext,
|
||||
["rightcolor"] = smember_rcolor,
|
||||
["leftcolor"] = smember_lcolor,
|
||||
["righticon"] = smember_ricon,
|
||||
["lefticon"] = smember_licon,
|
||||
["texture"] = smember_texture,
|
||||
["fontsize"] = smember_textsize,
|
||||
["fontface"] = smember_textfont,
|
||||
["fontcolor"] = smember_textcolor,
|
||||
["textsize"] = smember_textsize, --alias
|
||||
["textfont"] = smember_textfont, --alias
|
||||
["textcolor"] = smember_textcolor --alias
|
||||
}
|
||||
|
||||
SplitBarMetaFunctions.__newindex = function (_table, _key, _value)
|
||||
local func = set_members_function_index [_key]
|
||||
if (func) then
|
||||
return func (_table, _value)
|
||||
else
|
||||
return _rawset (_table, _key, _value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> methods
|
||||
|
||||
--> show & hide
|
||||
function SplitBarMetaFunctions:Show()
|
||||
return self.statusbar:Show()
|
||||
end
|
||||
function SplitBarMetaFunctions:Hide()
|
||||
return self.statusbar:Hide()
|
||||
end
|
||||
|
||||
-- set split
|
||||
function SplitBarMetaFunctions:SetSplit (value)
|
||||
if (not value) then
|
||||
value = self.statusbar:GetValue()
|
||||
elseif (value < 0 or value > 100) then
|
||||
return
|
||||
end
|
||||
self.statusbar:SetValue (value)
|
||||
self.div:SetPoint ("left", self.statusbar, "left", value * (self.statusbar:GetWidth()/100) - 18, 0)
|
||||
end
|
||||
|
||||
-- setpoint
|
||||
function SplitBarMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
||||
v1, v2, v3, v4, v5 = gump: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
|
||||
|
||||
-- sizes
|
||||
function SplitBarMetaFunctions:SetSize (w, h)
|
||||
if (w) then
|
||||
self.statusbar:SetWidth (w)
|
||||
end
|
||||
if (h) then
|
||||
self.statusbar:SetHeight (h)
|
||||
end
|
||||
end
|
||||
|
||||
-- texture
|
||||
function SplitBarMetaFunctions:SetTexture (texture)
|
||||
self.background:SetTexture (texture)
|
||||
self.texture:SetTexture (texture)
|
||||
end
|
||||
|
||||
-- texts
|
||||
function SplitBarMetaFunctions:SetLeftText (text)
|
||||
self.textleft:SetText (text)
|
||||
end
|
||||
function SplitBarMetaFunctions:SetRightText (text)
|
||||
self.textright:SetText (text)
|
||||
end
|
||||
|
||||
-- colors
|
||||
function SplitBarMetaFunctions:SetLeftColor (r, g, b, a)
|
||||
r, g, b, a = gump:ParseColors (r, g, b, a)
|
||||
self.texture:SetVertexColor (r, g, b, a)
|
||||
self.texture.original_colors = {r, g, b, a}
|
||||
end
|
||||
function SplitBarMetaFunctions:SetRightColor (r, g, b, a)
|
||||
r, g, b, a = gump:ParseColors (r, g, b, a)
|
||||
self.background:SetVertexColor (r, g, b, a)
|
||||
self.background.original_colors = {r, g, b, a}
|
||||
end
|
||||
|
||||
-- icons
|
||||
function SplitBarMetaFunctions:SetLeftIcon (texture, ...)
|
||||
self.iconleft:SetTexture (texture)
|
||||
if (...) then
|
||||
local L, R, U, D = unpack (...)
|
||||
self.iconleft:SetTexCoord (L, R, U, D)
|
||||
end
|
||||
end
|
||||
function SplitBarMetaFunctions:SetRightIcon (texture, ...)
|
||||
self.iconright:SetTexture (texture)
|
||||
if (...) then
|
||||
local L, R, U, D = unpack (...)
|
||||
self.iconright:SetTexCoord (L, R, U, D)
|
||||
end
|
||||
end
|
||||
|
||||
-- tooltip
|
||||
function SplitBarMetaFunctions:SetTooltip (tooltip)
|
||||
if (tooltip) then
|
||||
return _rawset (self, "have_tooltip", tooltip)
|
||||
else
|
||||
return _rawset (self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
function SplitBarMetaFunctions:GetTooltip()
|
||||
return _rawget (self, "have_tooltip")
|
||||
end
|
||||
|
||||
-- frame levels
|
||||
function SplitBarMetaFunctions:GetFrameLevel()
|
||||
return self.statusbar:GetFrameLevel()
|
||||
end
|
||||
function SplitBarMetaFunctions:SetFrameLevel (level, frame)
|
||||
if (not frame) then
|
||||
return self.statusbar:SetFrameLevel (level)
|
||||
else
|
||||
local framelevel = frame:GetFrameLevel (frame) + level
|
||||
return self.statusbar:SetFrameLevel (framelevel)
|
||||
end
|
||||
end
|
||||
|
||||
-- frame stratas
|
||||
function SplitBarMetaFunctions:SetFrameStrata()
|
||||
return self.statusbar:GetFrameStrata()
|
||||
end
|
||||
function SplitBarMetaFunctions:SetFrameStrata (strata)
|
||||
if (_type (strata) == "table") then
|
||||
self.statusbar:SetFrameStrata (strata:GetFrameStrata())
|
||||
else
|
||||
self.statusbar:SetFrameStrata (strata)
|
||||
end
|
||||
end
|
||||
|
||||
--> hooks
|
||||
function SplitBarMetaFunctions:SetHook (hookType, func)
|
||||
if (func) then
|
||||
_rawset (self, hookType.."Hook", func)
|
||||
else
|
||||
_rawset (self, hookType.."Hook", nil)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> scripts
|
||||
local OnEnter = function (frame)
|
||||
if (frame.MyObject.OnEnterHook) then
|
||||
local interrupt = frame.MyObject.OnEnterHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local oc = frame.MyObject.texture.original_colors --original colors
|
||||
gump:GradientEffect ( frame.MyObject.texture, "texture", oc[1], oc[2], oc[3], oc[4], oc[1]+0.2, oc[2]+0.2, oc[3]+0.2, oc[4], .2)
|
||||
frame.MyObject.div:SetPoint ("left", frame, "left", frame:GetValue() * (frame:GetWidth()/100) - 18, 0)
|
||||
|
||||
if (frame.MyObject.have_tooltip) then
|
||||
GameCooltip:Reset()
|
||||
GameCooltip:AddLine (frame.MyObject.have_tooltip)
|
||||
GameCooltip:ShowCooltip (frame, "tooltip")
|
||||
end
|
||||
|
||||
local parent = frame:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnLeave = function (frame)
|
||||
if (frame.MyObject.OnLeaveHook) then
|
||||
local interrupt = frame.MyObject.OnLeaveHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local oc = frame.MyObject.texture.original_colors --original colors
|
||||
local r, g, b, a = frame.MyObject.texture:GetVertexColor()
|
||||
gump:GradientEffect ( frame.MyObject.texture, "texture", r, g, b, a, oc[1], oc[2], oc[3], oc[4], .2)
|
||||
|
||||
if (frame.MyObject.have_tooltip) then
|
||||
_detalhes.popup:ShowMe (false)
|
||||
end
|
||||
|
||||
local parent = frame:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient (false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnHide = function (frame)
|
||||
if (frame.MyObject.OnHideHook) then
|
||||
local interrupt = frame.MyObject.OnHideHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnShow = function (frame)
|
||||
if (frame.MyObject.OnShowHook) then
|
||||
local interrupt = frame.MyObject.OnShowHook (frame)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnMouseDown = function (frame, button)
|
||||
if (frame.MyObject.OnMouseDownHook) then
|
||||
local interrupt = frame.MyObject.OnMouseDownHook (frame, button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
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)
|
||||
if (frame.MyObject.OnMouseUpHook) then
|
||||
local interrupt = frame.MyObject.OnMouseUpHook (frame, button)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (frame.MyObject.container.isMoving) then
|
||||
frame.MyObject.container:StopMovingOrSizing()
|
||||
frame.MyObject.container.isMoving = false
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
|
||||
function DetailsSplitlBar_OnCreate (self)
|
||||
self.texture.original_colors = {1, 1, 1, 1}
|
||||
self.background.original_colors = {.5, .5, .5, 1}
|
||||
self.spark:SetPoint ("left", self, "left", self:GetValue() * (self:GetWidth()/100) - 18, 0)
|
||||
return true
|
||||
end
|
||||
|
||||
function gump:NewSplitBar (parent, container, name, member, w, h)
|
||||
|
||||
if (not name) then
|
||||
return nil
|
||||
elseif (not parent) then
|
||||
return nil
|
||||
elseif (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
name = name:gsub ("$parent", parent:GetName())
|
||||
end
|
||||
|
||||
local SplitBarObject = {type = "barsplit", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = SplitBarObject
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
--> default members:
|
||||
--> hooks
|
||||
SplitBarObject.OnEnterHook = nil
|
||||
SplitBarObject.OnLeaveHook = nil
|
||||
SplitBarObject.OnHideHook = nil
|
||||
SplitBarObject.OnShowHook = nil
|
||||
SplitBarObject.OnMouseDownHook = nil
|
||||
SplitBarObject.OnMouseUpHook = nil
|
||||
--> misc
|
||||
SplitBarObject.tooltip = nil
|
||||
SplitBarObject.locked = false
|
||||
SplitBarObject.have_tooltip = nil
|
||||
SplitBarObject.container = container
|
||||
|
||||
--> create widgets
|
||||
SplitBarObject.statusbar = CreateFrame ("statusbar", name, parent, "DetailsSplitBarTemplate")
|
||||
SplitBarObject.widget = SplitBarObject.statusbar
|
||||
|
||||
if (not APISplitBarFunctions) then
|
||||
APISplitBarFunctions = true
|
||||
local idx = getmetatable (SplitBarObject.statusbar).__index
|
||||
for funcName, funcAddress in pairs (idx) do
|
||||
if (not SplitBarMetaFunctions [funcName]) then
|
||||
SplitBarMetaFunctions [funcName] = function (object, ...)
|
||||
local x = loadstring ( "return _G."..object.statusbar:GetName()..":"..funcName.."(...)")
|
||||
return x (...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SplitBarObject.statusbar:SetHeight (h or 200)
|
||||
SplitBarObject.statusbar:SetWidth (w or 14)
|
||||
|
||||
SplitBarObject.statusbar.MyObject = SplitBarObject
|
||||
|
||||
SplitBarObject.textleft = _G [name .. "_TextLeft"]
|
||||
SplitBarObject.textright = _G [name .. "_TextRight"]
|
||||
|
||||
SplitBarObject.iconleft = _G [name .. "_IconLeft"]
|
||||
SplitBarObject.iconright = _G [name .. "_IconRight"]
|
||||
|
||||
SplitBarObject.background = _G [name .. "_StatusBarBackground"]
|
||||
SplitBarObject.texture = _G [name .. "_StatusBarTexture"]
|
||||
|
||||
SplitBarObject.div = _G [name .. "_Spark"]
|
||||
|
||||
|
||||
--> hooks
|
||||
SplitBarObject.statusbar:SetScript ("OnEnter", OnEnter)
|
||||
SplitBarObject.statusbar:SetScript ("OnLeave", OnLeave)
|
||||
SplitBarObject.statusbar:SetScript ("OnHide", OnHide)
|
||||
SplitBarObject.statusbar:SetScript ("OnShow", OnShow)
|
||||
SplitBarObject.statusbar:SetScript ("OnMouseDown", OnMouseDown)
|
||||
SplitBarObject.statusbar:SetScript ("OnMouseUp", OnMouseUp)
|
||||
|
||||
_setmetatable (SplitBarObject, SplitBarMetaFunctions)
|
||||
|
||||
return SplitBarObject
|
||||
end
|
||||
@@ -0,0 +1,82 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ .. \FrameXML\UI.xsd">
|
||||
|
||||
<Script file="split_bar.lua"/>
|
||||
|
||||
<StatusBar name="DetailsSplitBarTemplate" virtual="true">
|
||||
<Size x="300" y="14"/>
|
||||
|
||||
<Layers>
|
||||
|
||||
<Layer level="BACKGROUND">
|
||||
<!-- background texture -->
|
||||
<Texture name="$parent_StatusBarBackground" setAllPoints="true" parentKey="background" file = "Interface\PaperDollInfoFrame\UI-Character-Skills-Bar" horizTile="false" vertTile="false">
|
||||
<Color a = "1" r = ".5" g = ".5" b = ".5" />
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="ARTWORK">
|
||||
<!-- statusbar texture -->
|
||||
<Texture name="$parent_StatusBarTexture" hidden="true" parentKey="texture" file = "Interface\PaperDollInfoFrame\UI-Character-Skills-Bar" horizTile="false" vertTile="false">
|
||||
<Size x="300" y="14" />
|
||||
<Color a = "1" r = "1" g = "1" b = "1" />
|
||||
</Texture>
|
||||
</Layer>
|
||||
|
||||
<Layer level="OVERLAY">
|
||||
<!-- left icon -->
|
||||
<Texture name="$parent_IconLeft" parentKey="lefticon">
|
||||
<Size x="14" y="14" />
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
|
||||
<!-- right icon -->
|
||||
<Texture name="$parent_IconRight" parentKey="righticon">
|
||||
<Size x="14" y="14" />
|
||||
<Anchors>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT" x="0" y="0"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
|
||||
<!-- left text -->
|
||||
<FontString name="$parent_TextLeft" parentKey="lefttext" inherits="GameFontHighlight" justifyH="LEFT" nonspacewrap="false">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent_IconLeft" relativePoint="RIGHT" x="3" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
|
||||
<!-- right text -->
|
||||
<FontString name="$parent_TextRight" parentKey="righttext" inherits="GameFontHighlight" justifyH="RIGHT" nonspacewrap="false">
|
||||
<FontHeight val="10.5"/>
|
||||
<Anchors>
|
||||
<Anchor point="RIGHT" relativeTo="$parent_IconRight" relativePoint="LEFT" x="-3" y="0"/>
|
||||
</Anchors>
|
||||
</FontString>
|
||||
|
||||
<!-- div spark -->
|
||||
<Texture name="$parent_Spark" parentKey="spark" file = "Interface\CastingBar\UI-CastingBar-Spark" alphaMode="ADD">
|
||||
<Size>
|
||||
<AbsDimension x="32" y="32"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="$parent" relativePoint="RIGHT" x="-17" y="-1"/>
|
||||
</Anchors>
|
||||
</Texture>
|
||||
|
||||
</Layer>
|
||||
|
||||
</Layers>
|
||||
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
self:SetStatusBarTexture (self.texture);
|
||||
self:SetMinMaxValues (1, 100);
|
||||
self:SetValue (50);
|
||||
DetailsSplitlBar_OnCreate (self);
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
|
||||
</StatusBar>
|
||||
</Ui>
|
||||
@@ -0,0 +1,560 @@
|
||||
--> details main objects
|
||||
local _detalhes = _G._detalhes
|
||||
local gump = _detalhes.gump
|
||||
|
||||
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
|
||||
local loadstring = loadstring --> lua local
|
||||
local _string_len = string.len --> lua local
|
||||
|
||||
local cleanfunction = function() end
|
||||
local APITextEntryFunctions = false
|
||||
local TextEntryMetaFunctions = {}
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> metatables
|
||||
|
||||
TextEntryMetaFunctions.__call = function (_table, value)
|
||||
--> unknow
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> members
|
||||
|
||||
--> tooltip
|
||||
local gmember_tooltip = function (_object)
|
||||
return _object:GetTooltip()
|
||||
end
|
||||
--> shown
|
||||
local gmember_shown = function (_object)
|
||||
return _object:IsShown()
|
||||
end
|
||||
--> frame width
|
||||
local gmember_width = function (_object)
|
||||
return _object.editbox:GetWidth()
|
||||
end
|
||||
--> frame height
|
||||
local gmember_height = function (_object)
|
||||
return _object.editbox:GetHeight()
|
||||
end
|
||||
--> get text
|
||||
local gmember_text = function (_object)
|
||||
return _object.editbox:GetText()
|
||||
end
|
||||
|
||||
local get_members_function_index = {
|
||||
["tooltip"] = gmember_tooltip,
|
||||
["shown"] = gmember_shown,
|
||||
["width"] = gmember_width,
|
||||
["height"] = gmember_height,
|
||||
["text"] = gmember_text,
|
||||
}
|
||||
|
||||
TextEntryMetaFunctions.__index = function (_table, _member_requested)
|
||||
|
||||
local func = get_members_function_index [_member_requested]
|
||||
if (func) then
|
||||
return func (_table, _member_requested)
|
||||
end
|
||||
|
||||
local fromMe = _rawget (_table, _member_requested)
|
||||
if (fromMe) then
|
||||
return fromMe
|
||||
end
|
||||
|
||||
return TextEntryMetaFunctions [_member_requested]
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--> tooltip
|
||||
local smember_tooltip = function (_object, _value)
|
||||
return _object:SetTooltip (_value)
|
||||
end
|
||||
--> 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
|
||||
--> frame width
|
||||
local smember_width = function (_object, _value)
|
||||
return _object.editbox:SetWidth (_value)
|
||||
end
|
||||
--> frame height
|
||||
local smember_height = function (_object, _value)
|
||||
return _object.editbox:SetHeight (_value)
|
||||
end
|
||||
--> set text
|
||||
local smember_text = function (_object, _value)
|
||||
return _object.editbox:SetText (_value)
|
||||
end
|
||||
--> set multiline
|
||||
local smember_multiline = function (_object, _value)
|
||||
if (_value) then
|
||||
return _object.editbox:SetMultiLine (true)
|
||||
else
|
||||
return _object.editbox:SetMultiLine (false)
|
||||
end
|
||||
end
|
||||
--> text horizontal pos
|
||||
local smember_horizontalpos = function (_object, _value)
|
||||
return _object.editbox:SetJustifyH (string.lower (_value))
|
||||
end
|
||||
|
||||
local set_members_function_index = {
|
||||
["tooltip"] = smember_tooltip,
|
||||
["show"] = smember_show,
|
||||
["hide"] = smember_hide,
|
||||
["width"] = smember_width,
|
||||
["height"] = smember_height,
|
||||
["text"] = smember_text,
|
||||
["multiline"] = smember_multiline,
|
||||
["align"] = smember_horizontalpos,
|
||||
}
|
||||
|
||||
TextEntryMetaFunctions.__newindex = function (_table, _key, _value)
|
||||
local func = set_members_function_index [_key]
|
||||
if (func) then
|
||||
return func (_table, _value)
|
||||
else
|
||||
return _rawset (_table, _key, _value)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> methods
|
||||
|
||||
--> set point
|
||||
function TextEntryMetaFunctions:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y, Width)
|
||||
|
||||
if (type (MyAnchor) == "boolean" and MyAnchor and self.space) then
|
||||
local textWidth = self.label:GetStringWidth()+2
|
||||
self.editbox:SetWidth (self.space - textWidth - 15)
|
||||
return
|
||||
|
||||
elseif (type (MyAnchor) == "boolean" and MyAnchor and not self.space) then
|
||||
self.space = self.label:GetStringWidth()+2 + self.editbox:GetWidth()
|
||||
end
|
||||
|
||||
if (Width) then
|
||||
self.space = Width
|
||||
end
|
||||
|
||||
MyAnchor, SnapTo, HisAnchor, x, y = gump:CheckPoints (MyAnchor, SnapTo, HisAnchor, x, y, self)
|
||||
if (not MyAnchor) then
|
||||
print ("Invalid parameter for SetPoint")
|
||||
return
|
||||
end
|
||||
|
||||
if (self.space) then
|
||||
self.label:ClearAllPoints()
|
||||
self.editbox:ClearAllPoints()
|
||||
|
||||
self.label:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y)
|
||||
self.editbox:SetPoint ("left", self.label, "right", 2, 0)
|
||||
|
||||
local textWidth = self.label:GetStringWidth()+2
|
||||
self.editbox:SetWidth (self.space - textWidth - 15)
|
||||
else
|
||||
self.label:ClearAllPoints()
|
||||
self.editbox:ClearAllPoints()
|
||||
self.editbox:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--> frame levels
|
||||
function TextEntryMetaFunctions:GetFrameLevel()
|
||||
return self.editbox:GetFrameLevel()
|
||||
end
|
||||
function TextEntryMetaFunctions:SetFrameLevel (level, frame)
|
||||
if (not frame) then
|
||||
return self.editbox:SetFrameLevel (level)
|
||||
else
|
||||
local framelevel = frame:GetFrameLevel (frame) + level
|
||||
return self.editbox:SetFrameLevel (framelevel)
|
||||
end
|
||||
end
|
||||
|
||||
--> set labal description
|
||||
function TextEntryMetaFunctions:SetLabelText (text)
|
||||
if (text) then
|
||||
self.label:SetText (text)
|
||||
else
|
||||
self.label:SetText ("")
|
||||
end
|
||||
self:SetPoint (true) --> refresh
|
||||
end
|
||||
|
||||
--> set tab order
|
||||
function TextEntryMetaFunctions:SetNext (nextbox)
|
||||
self.next = nextbox
|
||||
end
|
||||
|
||||
--> blink
|
||||
function TextEntryMetaFunctions:Blink()
|
||||
self.label:SetTextColor (1, .2, .2, 1)
|
||||
end
|
||||
|
||||
--> show & hide
|
||||
function TextEntryMetaFunctions:IsShown()
|
||||
return self.editbox:IsShown()
|
||||
end
|
||||
function TextEntryMetaFunctions:Show()
|
||||
return self.editbox:Show()
|
||||
end
|
||||
function TextEntryMetaFunctions:Hide()
|
||||
return self.editbox:Hide()
|
||||
end
|
||||
|
||||
-- tooltip
|
||||
function TextEntryMetaFunctions:SetTooltip (tooltip)
|
||||
if (tooltip) then
|
||||
return _rawset (self, "have_tooltip", tooltip)
|
||||
else
|
||||
return _rawset (self, "have_tooltip", nil)
|
||||
end
|
||||
end
|
||||
function TextEntryMetaFunctions:GetTooltip()
|
||||
return _rawget (self, "have_tooltip")
|
||||
end
|
||||
|
||||
--> hooks
|
||||
function TextEntryMetaFunctions:SetHook (hookType, func)
|
||||
if (func) then
|
||||
_rawset (self, hookType.."Hook", func)
|
||||
else
|
||||
_rawset (self, hookType.."Hook", nil)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> scripts
|
||||
local OnEnter = function (textentry)
|
||||
|
||||
if (textentry.MyObject.OnEnterHook) then
|
||||
local interrupt = textentry.MyObject.OnEnterHook (textentry)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (textentry.MyObject.have_tooltip) then
|
||||
GameCooltip:Reset()
|
||||
GameCooltip:SetType ("tooltip")
|
||||
GameCooltip:SetColor ("main", "transparent")
|
||||
GameCooltip:AddLine (textentry.MyObject.have_tooltip)
|
||||
GameCooltip:SetOwner (textentry)
|
||||
GameCooltip:ShowCooltip()
|
||||
end
|
||||
|
||||
textentry.mouse_over = true
|
||||
|
||||
if (textentry:IsEnabled()) then
|
||||
textentry:SetBackdropBorderColor (0.5, 0.5, 0.5, 1)
|
||||
end
|
||||
|
||||
local parent = textentry:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local OnLeave = function (textentry)
|
||||
if (textentry.MyObject.OnLeaveHook) then
|
||||
local interrupt = textentry.MyObject.OnLeaveHook (textentry)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (textentry.MyObject.have_tooltip) then
|
||||
_detalhes.popup:ShowMe (false)
|
||||
end
|
||||
|
||||
textentry.mouse_over = false
|
||||
|
||||
if (textentry:IsEnabled()) then
|
||||
textentry:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
|
||||
end
|
||||
|
||||
local parent = textentry:GetParent().MyObject
|
||||
if (parent and parent.type == "panel") then
|
||||
if (parent.GradientEnabled) then
|
||||
parent:RunGradient (false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnHide = function (textentry)
|
||||
if (textentry.MyObject.OnHideHook) then
|
||||
local interrupt = textentry.MyObject.OnHideHook (textentry)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnShow = function (textentry)
|
||||
if (textentry.MyObject.OnShowHook) then
|
||||
local interrupt = textentry.MyObject.OnShowHook (textentry)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnEnterPressed = function (textentry, byScript)
|
||||
|
||||
if (textentry.MyObject.OnEnterPressedHook) then
|
||||
local interrupt = textentry.MyObject.OnEnterPressedHook (textentry)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local texto = _detalhes:trim (textentry:GetText())
|
||||
if (_string_len (texto) > 0) then
|
||||
textentry.text = texto
|
||||
if (textentry.MyObject.func) then
|
||||
textentry.MyObject.func (textentry.MyObject.param1, textentry.MyObject.param2, texto, textentry, byScript or textentry)
|
||||
end
|
||||
else
|
||||
textentry:SetText ("")
|
||||
textentry.MyObject.currenttext = ""
|
||||
end
|
||||
textentry.focuslost = true --> perdeu_focus isso aqui pra quando estiver editando e clicar em outra caixa
|
||||
textentry:ClearFocus()
|
||||
|
||||
if (textentry.MyObject.tab_on_enter and textentry.MyObject.next) then
|
||||
textentry.MyObject.next:SetFocus()
|
||||
end
|
||||
end
|
||||
|
||||
local OnEscapePressed = function (textentry)
|
||||
|
||||
if (textentry.MyObject.OnEscapePressedHook) then
|
||||
local interrupt = textentry.MyObject.OnEscapePressedHook (textentry)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
textentry:SetText("")
|
||||
textentry.MyObject.currenttext = ""
|
||||
textentry.focuslost = true
|
||||
textentry:ClearFocus()
|
||||
end
|
||||
|
||||
local OnEditFocusLost = function (textentry)
|
||||
|
||||
if (textentry:IsShown()) then
|
||||
|
||||
if (textentry.MyObject.OnEditFocusLostHook) then
|
||||
local interrupt = textentry.MyObject.OnEditFocusLostHook (textentry)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (not textentry.focuslost) then
|
||||
local texto = _detalhes:trim (textentry:GetText())
|
||||
if (_string_len (texto) > 0) then
|
||||
textentry.MyObject.currenttext = texto
|
||||
if (textentry.MyObject.func) then
|
||||
textentry.MyObject.func (textentry.MyObject.param1, textentry.MyObject.param2, texto, textentry, nil)
|
||||
end
|
||||
else
|
||||
textentry:SetText ("")
|
||||
textentry.MyObject.currenttext = ""
|
||||
end
|
||||
else
|
||||
textentry.focuslost = false
|
||||
end
|
||||
|
||||
textentry.MyObject.label:SetTextColor (.8, .8, .8, 1)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
local OnEditFocusGained = function (textentry)
|
||||
if (textentry.MyObject.OnEditFocusGainedHook) then
|
||||
local interrupt = textentry.MyObject.OnEditFocusGainedHook (textentry)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
textentry.MyObject.label:SetTextColor (1, 1, 1, 1)
|
||||
end
|
||||
|
||||
local OnChar = function (textentry, text)
|
||||
if (textentry.MyObject.OnCharHook) then
|
||||
local interrupt = textentry.MyObject.OnCharHook (textentry, text)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnTextChanged = function (textentry, byUser)
|
||||
if (textentry.MyObject.OnTextChangedHook) then
|
||||
local interrupt = textentry.MyObject.OnTextChangedHook (textentry, byUser)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local OnTabPressed = function (textentry)
|
||||
if (textentry.MyObject.OnTabPressedHook) then
|
||||
local interrupt = textentry.MyObject.OnTabPressedHook (textentry, byUser)
|
||||
if (interrupt) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if (textentry.MyObject.next) then
|
||||
OnEnterPressed (textentry, false)
|
||||
textentry.MyObject.next:SetFocus()
|
||||
end
|
||||
end
|
||||
|
||||
function TextEntryMetaFunctions:PressEnter (byScript)
|
||||
OnEnterPressed (self.editbox, byScript)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--> object constructor
|
||||
|
||||
function gump:NewTextEntry (parent, container, name, member, w, h, func, param1, param2, space)
|
||||
|
||||
if (not name) then
|
||||
return nil
|
||||
elseif (not parent) then
|
||||
return nil
|
||||
end
|
||||
if (not container) then
|
||||
container = parent
|
||||
end
|
||||
|
||||
if (name:find ("$parent")) then
|
||||
name = name:gsub ("$parent", parent:GetName())
|
||||
end
|
||||
|
||||
local TextEntryObject = {type = "textentry", dframework = true}
|
||||
|
||||
if (member) then
|
||||
parent [member] = TextEntryObject
|
||||
end
|
||||
|
||||
if (parent.dframework) then
|
||||
parent = parent.widget
|
||||
end
|
||||
if (container.dframework) then
|
||||
container = container.widget
|
||||
end
|
||||
|
||||
--> default members:
|
||||
--> hooks
|
||||
TextEntryObject.OnEnterHook = nil
|
||||
TextEntryObject.OnLeaveHook = nil
|
||||
TextEntryObject.OnHideHook = nil
|
||||
TextEntryObject.OnShowHook = nil
|
||||
TextEntryObject.OnEnterPressedHook = nil
|
||||
TextEntryObject.OnEscapePressedHook = nil
|
||||
TextEntryObject.OnEditFocusGainedHook = nil
|
||||
TextEntryObject.OnEditFocusLostHook = nil
|
||||
TextEntryObject.OnCharHook = nil
|
||||
TextEntryObject.OnTextChangedHook = nil
|
||||
TextEntryObject.OnTabPressedHook = nil
|
||||
|
||||
--> misc
|
||||
TextEntryObject.container = container
|
||||
TextEntryObject.have_tooltip = nil
|
||||
|
||||
TextEntryObject.editbox = CreateFrame ("EditBox", name, parent, "DetailsEditBoxTemplate2")
|
||||
TextEntryObject.widget = TextEntryObject.editbox
|
||||
|
||||
if (not APITextEntryFunctions) then
|
||||
APITextEntryFunctions = true
|
||||
local idx = getmetatable (TextEntryObject.editbox).__index
|
||||
for funcName, funcAddress in pairs (idx) do
|
||||
if (not TextEntryMetaFunctions [funcName]) then
|
||||
TextEntryMetaFunctions [funcName] = function (object, ...)
|
||||
local x = loadstring ( "return _G."..object.editbox:GetName()..":"..funcName.."(...)")
|
||||
return x (...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
TextEntryObject.editbox.MyObject = TextEntryObject
|
||||
|
||||
if (not w and space) then
|
||||
w = space
|
||||
elseif (w and space) then
|
||||
if (gump.debug) then
|
||||
print ("warning: you are using width and space, try use only space for better results.")
|
||||
end
|
||||
end
|
||||
|
||||
TextEntryObject.editbox:SetWidth (w)
|
||||
TextEntryObject.editbox:SetHeight (h)
|
||||
|
||||
TextEntryObject.editbox:SetJustifyH ("center")
|
||||
TextEntryObject.editbox:EnableMouse (true)
|
||||
TextEntryObject.editbox:SetText ("")
|
||||
TextEntryObject.editbox:SetBackdrop ({bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
||||
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
||||
tile = true, edgeSize = 1, tileSize = 5})
|
||||
TextEntryObject.editbox:SetBackdropColor (0, 0, 0, 0.5)
|
||||
TextEntryObject.editbox:SetBackdropBorderColor (0.3, 0.3, 0.30, 0.80)
|
||||
TextEntryObject.editbox:SetAutoFocus (false)
|
||||
TextEntryObject.editbox:SetFontObject ("GameFontHighlightSmall")
|
||||
|
||||
TextEntryObject.func = func
|
||||
TextEntryObject.param1 = param1
|
||||
TextEntryObject.param2 = param2
|
||||
TextEntryObject.next = nil
|
||||
TextEntryObject.space = space
|
||||
TextEntryObject.tab_on_enter = false
|
||||
|
||||
TextEntryObject.label = _G [name .. "_Desc"]
|
||||
|
||||
--> hooks
|
||||
TextEntryObject.editbox:SetScript ("OnEnter", OnEnter)
|
||||
TextEntryObject.editbox:SetScript ("OnLeave", OnLeave)
|
||||
TextEntryObject.editbox:SetScript ("OnHide", OnHide)
|
||||
TextEntryObject.editbox:SetScript ("OnShow", OnShow)
|
||||
|
||||
TextEntryObject.editbox:SetScript ("OnEnterPressed", OnEnterPressed)
|
||||
TextEntryObject.editbox:SetScript ("OnEscapePressed", OnEscapePressed)
|
||||
TextEntryObject.editbox:SetScript ("OnEditFocusLost", OnEditFocusLost)
|
||||
TextEntryObject.editbox:SetScript ("OnEditFocusGained", OnEditFocusGained)
|
||||
TextEntryObject.editbox:SetScript ("OnChar", OnChar)
|
||||
TextEntryObject.editbox:SetScript ("OnTextChanged", OnTextChanged)
|
||||
TextEntryObject.editbox:SetScript ("OnTabPressed", OnTabPressed)
|
||||
|
||||
_setmetatable (TextEntryObject, TextEntryMetaFunctions)
|
||||
|
||||
return TextEntryObject
|
||||
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
|
||||
|
||||
<Script file="textentry.lua"/>
|
||||
|
||||
<EditBox name="DetailsEditBoxTemplate2" virtual="true">
|
||||
<Size x="232" y="20"/>
|
||||
|
||||
<Backdrop bgFile="Interface\\ChatFrame\\ChatFrameBackground" edgeFile="Interface\\ChatFrame\\ChatFrameBackground" tile="true">
|
||||
<EdgeSize>
|
||||
<AbsValue val="1"/>
|
||||
</EdgeSize>
|
||||
<TileSize>
|
||||
<AbsValue val="16"/>
|
||||
</TileSize>
|
||||
<BackgroundInsets>
|
||||
<AbsInset left="0" right="0" top="0" bottom="0"/>
|
||||
</BackgroundInsets>
|
||||
</Backdrop>
|
||||
|
||||
<Layers>
|
||||
|
||||
<Layer level="OVERLAY">
|
||||
<!-- box description -->
|
||||
<FontString name="$parent_Desc" text="" parentKey="label" inherits="GameFontHighlightSmall" justifyH="LEFT" nonspacewrap="false">
|
||||
<Color r = "0.8" g = "0.8" b = "0.8" a = "1"/>
|
||||
<Anchors>
|
||||
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="LEFT" x="-2" y="0" />
|
||||
</Anchors>
|
||||
</FontString>
|
||||
|
||||
</Layer>
|
||||
|
||||
</Layers>
|
||||
|
||||
</EditBox>
|
||||
</Ui>
|
||||
Reference in New Issue
Block a user