From ea9caa1f4002b7cc969aab18658dffc2d6dc1c0c Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Thu, 6 Oct 2022 16:24:29 -0300 Subject: [PATCH] Fixed: report window send button, tooltip showing the player's death --- Libs/DF/button.lua | 1207 ++++++++++++---------------- Libs/DF/cooltip.lua | 75 +- Libs/DF/dropdown.lua | 78 +- Libs/DF/fw.lua | 514 ++++++------ Libs/DF/label.lua | 127 ++- Libs/DF/mixins.lua | 41 + Libs/DF/picture.lua | 24 +- Libs/DF/scrollbar.lua | 316 ++++---- Libs/DF/slider.lua | 431 +++++----- Libs/DF/textentry.lua | 150 +--- classes/class_utility.lua | 725 +++++++++-------- frames/window_report.lua | 1591 ++++++++++++++++--------------------- 12 files changed, 2376 insertions(+), 2903 deletions(-) diff --git a/Libs/DF/button.lua b/Libs/DF/button.lua index 9e00552c..11b4fe89 100644 --- a/Libs/DF/button.lua +++ b/Libs/DF/button.lua @@ -1,19 +1,11 @@ -local DF = _G ["DetailsFramework"] +local DF = _G["DetailsFramework"] if (not DF or not DetailsFrameworkCanLoad) then - return + return end local _ -local _rawset = rawset --> lua local -local _rawget = rawget --> lua local -local _setmetatable = setmetatable --> lua local -local _unpack = unpack --> lua local -local _type = type --> lua local -local _math_floor = math.floor --> lua local -local loadstring = loadstring --> lua local - local cleanfunction = function() end local APIButtonFunctions = false @@ -24,14 +16,13 @@ do HasHook = DF.HasHook, ClearHooks = DF.ClearHooks, RunHooksForWidget = DF.RunHooksForWidget, - dversion = DF.dversion } --check if there's a metaPrototype already existing if (_G[DF.GlobalWidgetControlNames["button"]]) then --get the already existing metaPrototype - local oldMetaPrototype = _G[DF.GlobalWidgetControlNames ["button"]] + local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["button"]] --check if is older if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then --the version is older them the currently loading one @@ -42,85 +33,97 @@ do end else --first time loading the framework - _G[DF.GlobalWidgetControlNames ["button"]] = metaPrototype + _G[DF.GlobalWidgetControlNames["button"]] = metaPrototype end end -local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames ["button"]] +local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames["button"]] + +DF:Mixin(ButtonMetaFunctions, DF.SetPointMixin) +DF:Mixin(ButtonMetaFunctions, DF.FrameMixin) ------------------------------------------------------------------------------------------------------------ ---> metatables +--metatables - ButtonMetaFunctions.__call = function (self) + ButtonMetaFunctions.__call = function(self) local frameWidget = self.widget - DF:CoreDispatch ((frameWidget:GetName() or "Button") .. ":__call()", self.func, frameWidget, "LeftButton", self.param1, self.param2) + DF:CoreDispatch((frameWidget:GetName() or "Button") .. ":__call()", self.func, frameWidget, "LeftButton", self.param1, self.param2) end ------------------------------------------------------------------------------------------------------------ ---> members +--members - --> tooltip - local gmember_tooltip = function (_object) - return _object:GetTooltip() + --tooltip + local gmember_tooltip = function(object) + return object:GetTooltip() end - --> shown - local gmember_shown = function (_object) - return _object:IsShown() + + --shown + local gmember_shown = function(object) + return object:IsShown() end - --> frame width - local gmember_width = function (_object) - return _object.button:GetWidth() + --frame width + local gmember_width = function(object) + return object.button:GetWidth() end - --> frame height - local gmember_height = function (_object) - return _object.button:GetHeight() + + --frame height + local gmember_height = function(object) + return object.button:GetHeight() end - --> text - local gmember_text = function (_object) - return _object.button.text:GetText() + + --text + local gmember_text = function(object) + return object.button.text:GetText() end - --> function - local gmember_function = function (_object) - return _rawget (_object, "func") + + --function + local gmember_function = function(object) + return rawget(object, "func") end - --> text color - local gmember_textcolor = function (_object) - return _object.button.text:GetTextColor() + + --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() + + --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() + + --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()} + + --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") + + --locked + local gmember_locked = function(object) + return rawget(object, "is_locked") end ButtonMetaFunctions.GetMembers = ButtonMetaFunctions.GetMembers or {} - ButtonMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip - ButtonMetaFunctions.GetMembers ["shown"] = gmember_shown - ButtonMetaFunctions.GetMembers ["width"] = gmember_width - ButtonMetaFunctions.GetMembers ["height"] = gmember_height - ButtonMetaFunctions.GetMembers ["text"] = gmember_text - ButtonMetaFunctions.GetMembers ["clickfunction"] = gmember_function - ButtonMetaFunctions.GetMembers ["texture"] = gmember_texture - ButtonMetaFunctions.GetMembers ["locked"] = gmember_locked - ButtonMetaFunctions.GetMembers ["fontcolor"] = gmember_textcolor - ButtonMetaFunctions.GetMembers ["fontface"] = gmember_textfont - ButtonMetaFunctions.GetMembers ["fontsize"] = gmember_textsize - ButtonMetaFunctions.GetMembers ["textcolor"] = gmember_textcolor --alias - ButtonMetaFunctions.GetMembers ["textfont"] = gmember_textfont --alias - ButtonMetaFunctions.GetMembers ["textsize"] = gmember_textsize --alias + ButtonMetaFunctions.GetMembers["tooltip"] = gmember_tooltip + ButtonMetaFunctions.GetMembers["shown"] = gmember_shown + ButtonMetaFunctions.GetMembers["width"] = gmember_width + ButtonMetaFunctions.GetMembers["height"] = gmember_height + ButtonMetaFunctions.GetMembers["text"] = gmember_text + ButtonMetaFunctions.GetMembers["clickfunction"] = gmember_function + ButtonMetaFunctions.GetMembers["texture"] = gmember_texture + ButtonMetaFunctions.GetMembers["locked"] = gmember_locked + ButtonMetaFunctions.GetMembers["fontcolor"] = gmember_textcolor + ButtonMetaFunctions.GetMembers["fontface"] = gmember_textfont + ButtonMetaFunctions.GetMembers["fontsize"] = gmember_textsize + ButtonMetaFunctions.GetMembers["textcolor"] = gmember_textcolor --alias + ButtonMetaFunctions.GetMembers["textfont"] = gmember_textfont --alias + ButtonMetaFunctions.GetMembers["textsize"] = gmember_textsize --alias ButtonMetaFunctions.__index = function (_table, _member_requested) @@ -129,7 +132,7 @@ local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames ["button"]] return func (_table, _member_requested) end - local fromMe = _rawget (_table, _member_requested) + local fromMe = rawget (_table, _member_requested) if (fromMe) then return fromMe end @@ -139,11 +142,12 @@ local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames ["button"]] ------------------------------------------------------------------------------------------------------------------------------------------------------------------- - --> tooltip + --tooltip local smember_tooltip = function (_object, _value) return _object:SetTooltip (_value) end - --> show + + --show local smember_show = function (_object, _value) if (_value) then return _object:Show() @@ -151,7 +155,8 @@ local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames ["button"]] return _object:Hide() end end - --> hide + + --hide local smember_hide = function (_object, _value) if (not _value) then return _object:Show() @@ -159,46 +164,56 @@ local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames ["button"]] return _object:Hide() end end - --> frame width + + --frame width local smember_width = function (_object, _value) return _object.button:SetWidth (_value) end - --> frame height + + --frame height local smember_height = function (_object, _value) return _object.button:SetHeight (_value) end - --> text + + --text local smember_text = function (_object, _value) return _object.button.text:SetText (_value) end - --> function + + --function local smember_function = function (_object, _value) - return _rawset (_object, "func", _value) + return rawset(_object, "func", _value) end - --> param1 + + --param1 local smember_param1 = function (_object, _value) - return _rawset (_object, "param1", _value) + return rawset(_object, "param1", _value) end - --> param2 + + --param2 local smember_param2 = function (_object, _value) - return _rawset (_object, "param2", _value) + return rawset(_object, "param2", _value) end - --> text color + + --text color local smember_textcolor = function (_object, _value) local _value1, _value2, _value3, _value4 = DF:ParseColors (_value) return _object.button.text:SetTextColor (_value1, _value2, _value3, _value4) end - --> text font + + --text font local smember_textfont = function (_object, _value) return DF:SetFontFace (_object.button.text, _value) end - --> text size + + --text size local smember_textsize = function (_object, _value) return DF:SetFontSize (_object.button.text, _value) end - --> texture + + --texture local smember_texture = function (_object, _value) - if (_type (_value) == "table") then + if (type (_value) == "table") then local _value1, _value2, _value3, _value4 = unpack (_value) if (_value1) then _object.button:SetNormalTexture (_value1) @@ -220,18 +235,20 @@ local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames ["button"]] end return end - --> locked + + --locked local smember_locked = function (_object, _value) if (_value) then _object.button:SetMovable (false) - return _rawset (_object, "is_locked", true) + return rawset(_object, "is_locked", true) else _object.button:SetMovable (true) - _rawset (_object, "is_locked", false) + rawset(_object, "is_locked", false) return end - end - --> text align + end + + --text align local smember_textalign = function (_object, _value) if (_value == "left" or _value == "<") then _object.button.text:SetPoint ("left", _object.button, "left", 2, 0) @@ -270,181 +287,119 @@ local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames ["button"]] if (func) then return func (_table, _value) else - return _rawset (_table, _key, _value) + return rawset(_table, _key, _value) end end - + ------------------------------------------------------------------------------------------------------------ ---> methods +--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 = DF:CheckPoints (v1, v2, v3, v4, v5, self) - if (not v1) then - error ("SetPoint: Invalid parameter.") - 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) +--tooltip + function ButtonMetaFunctions:SetTooltip(tooltip) if (tooltip) then - return _rawset (self, "have_tooltip", tooltip) + return rawset(self, "have_tooltip", tooltip) else - return _rawset (self, "have_tooltip", nil) + return rawset(self, "have_tooltip", nil) end end + function ButtonMetaFunctions:GetTooltip() - return _rawget (self, "have_tooltip") + 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 + +--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) + rawset(self, "func", func) else - _rawset (self, "func", cleanfunction) + rawset(self, "func", cleanfunction) end - + if (param1 ~= nil) then - _rawset (self, "param1", param1) + rawset(self, "param1", param1) end if (param2 ~= nil) then - _rawset (self, "param2", param2) + rawset(self, "param2", param2) end - - elseif (clicktype or string.find (string.lower (clicktype), "right")) then + + elseif (clickType or string.find (string.lower (clickType), "right")) then if (func) then - _rawset (self, "funcright", func) + rawset(self, "funcright", func) else - _rawset (self, "funcright", cleanfunction) + 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, arg2, arg3, arg4) - if (arg2) then - return self.button.text:SetTextColor (color, arg2, arg3, arg4 or 1) - end - local _value1, _value2, _value3, _value4 = DF:ParseColors (color) - return self.button.text:SetTextColor (_value1, _value2, _value3, _value4) - end - --- textsize - function ButtonMetaFunctions:SetTextSize (size) - return DF:SetFontSize (self.button.text, _value) - end - --- textfont - function ButtonMetaFunctions:SetTextFont (font) - return DF: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 ("") - 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 ("") - 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 ("") - 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 ("") - 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 --- icon +--text + function ButtonMetaFunctions:SetText(text) + self.button.text:SetText(text) + end + +--text color + function ButtonMetaFunctions:SetTextColor(...) + local red, green, blue, alpha = DF:ParseColors(...) + self.button.text:SetTextColor(red, green, blue, alpha) + end + ButtonMetaFunctions.SetFontColor = ButtonMetaFunctions.SetTextColor --alias + +--text size + function ButtonMetaFunctions:SetFontSize(...) + DF:SetFontSize(self.button.text, ...) + end + +--text font + function ButtonMetaFunctions:SetFontFace(font) + DF:SetFontFace(self.button.text, font) + end + +--textures + function ButtonMetaFunctions:SetTexture(normalTexture, highlightTexture, pressedTexture, disabledTexture) + if (normalTexture) then + self.button:SetNormalTexture(normalTexture) + elseif (type(normalTexture) ~= "boolean") then + self.button:SetNormalTexture("") + end + + if (type(highlightTexture) == "boolean") then + if (highlightTexture and normalTexture and type(normalTexture) ~= "boolean") then + self.button:SetHighlightTexture(normalTexture, "ADD") + end + elseif (highlightTexture == nil) then + self.button:SetHighlightTexture("") + else + self.button:SetHighlightTexture(highlightTexture, "ADD") + end + + if (type(pressedTexture) == "boolean") then + if (pressedTexture and normalTexture and type(normalTexture) ~= "boolean") then + self.button:SetPushedTexture(normalTexture) + end + elseif (pressedTexture == nil) then + self.button:SetPushedTexture("") + else + self.button:SetPushedTexture(pressedTexture, "ADD") + end + + if (type(disabledTexture) == "boolean") then + if (disabledTexture and normalTexture and type(normalTexture) ~= "boolean") then + self.button:SetDisabledTexture(normalTexture) + end + elseif (disabledTexture == nil) then + self.button:SetDisabledTexture("") + else + self.button:SetDisabledTexture(disabledTexture, "ADD") + end + end + +--icon function ButtonMetaFunctions:GetIconTexture() if (self.icon) then return self.icon:GetTexture() end end - function ButtonMetaFunctions:SetBackdrop(...) - return self.button:SetBackdrop(...) - end - - function ButtonMetaFunctions:SetBackdropColor(...) - return self.button:SetBackdropColor(...) - end - - function ButtonMetaFunctions:SetBackdropBorderColor(...) - return self.button:SetBackdropBorderColor(...) - end - function ButtonMetaFunctions:SetIcon(texture, width, height, layout, texcoord, overlay, textDistance, leftPadding, textHeight, shortMethod) if (not self.icon) then self.icon = self:CreateTexture(nil, "artwork") @@ -519,424 +474,263 @@ local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames ["button"]] end 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 + +--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 + +--exec function ButtonMetaFunctions:Exec() local frameWidget = self.widget - DF:CoreDispatch ((frameWidget:GetName() or "Button") .. ":Exec()", self.func, frameWidget, "LeftButton", self.param1, self.param2) + DF:CoreDispatch((frameWidget:GetName() or "Button") .. ":Exec()", self.func, frameWidget, "LeftButton", self.param1, self.param2) end + function ButtonMetaFunctions:Click() local frameWidget = self.widget - DF:CoreDispatch ((frameWidget:GetName() or "Button") .. ":Click()", self.func, frameWidget, "LeftButton", self.param1, self.param2) + DF:CoreDispatch((frameWidget:GetName() or "Button") .. ":Click()", self.func, frameWidget, "LeftButton", self.param1, self.param2) end + function ButtonMetaFunctions:RightClick() local frameWidget = self.widget - DF:CoreDispatch ((frameWidget:GetName() or "Button") .. ":RightClick()", self.funcright, frameWidget, "RightButton", self.param1, self.param2) + DF:CoreDispatch((frameWidget:GetName() or "Button") .. ":RightClick()", self.funcright, frameWidget, "RightButton", self.param1, self.param2) end ---> custom textures - function ButtonMetaFunctions:InstallCustomTexture (texture, rect, coords, use_split, side_textures, side_textures2) - - self.button:SetNormalTexture ("") - self.button:SetPushedTexture ("") - self.button:SetDisabledTexture ("") - self.button:SetHighlightTexture ("") - - local button = self.button - - if (use_split) then - - --> 4 corners - button.textureTopLeft = button:CreateTexture (nil, "artwork"); button.textureTopLeft:SetSize (8, 8); button.textureTopLeft:SetPoint ("topleft", button) - button.textureTopRight = button:CreateTexture (nil, "artwork"); button.textureTopRight:SetSize (8, 8); button.textureTopRight:SetPoint ("topright", button) - button.textureBottomLeft = button:CreateTexture (nil, "artwork"); button.textureBottomLeft:SetSize (8, 8); button.textureBottomLeft:SetPoint ("bottomleft", button) - button.textureBottomRight = button:CreateTexture (nil, "artwork"); button.textureBottomRight:SetSize (8, 8); button.textureBottomRight:SetPoint ("bottomright", button) - - button.textureLeft = button:CreateTexture (nil, "artwork"); button.textureLeft:SetWidth (4); button.textureLeft:SetPoint ("topleft", button.textureTopLeft, "bottomleft"); button.textureLeft:SetPoint ("bottomleft", button.textureBottomLeft, "topleft") - button.textureRight = button:CreateTexture (nil, "artwork"); button.textureRight:SetWidth (4); button.textureRight:SetPoint ("topright", button.textureTopRight, "bottomright"); button.textureRight:SetPoint ("bottomright", button.textureBottomRight, "topright") - button.textureTop = button:CreateTexture (nil, "artwork"); button.textureTop:SetHeight (4); button.textureTop:SetPoint ("topleft", button.textureTopLeft, "topright"); button.textureTop:SetPoint ("topright", button.textureTopRight, "topleft"); - button.textureBottom = button:CreateTexture (nil, "artwork"); button.textureBottom:SetHeight (4); button.textureBottom:SetPoint ("bottomleft", button.textureBottomLeft, "bottomright"); button.textureBottom:SetPoint ("bottomright", button.textureBottomRight, "bottomleft"); - - button.textureLeft:SetTexCoord (0, 4/128, 9/128, 24/128) - button.textureRight:SetTexCoord (124/128, 1, 9/128, 24/128) - button.textureTop:SetTexCoord (9/128, 120/128, 0, 4/128) - button.textureBottom:SetTexCoord (9/128, 119/128, 28/128, 32/128) - - button.textureTopLeft:SetTexCoord (0, 8/128, 0, 8/128) - button.textureTopRight:SetTexCoord (121/128, 1, 0, 8/128) - button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128) - button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128) - - button.textureTopLeft:SetTexture ([[Interface\AddOns\Details\images\default_button]]) - button.textureTopRight:SetTexture ([[Interface\AddOns\Details\images\default_button]]) - button.textureBottomLeft:SetTexture ([[Interface\AddOns\Details\images\default_button]]) - button.textureBottomRight:SetTexture ([[Interface\AddOns\Details\images\default_button]]) - button.textureLeft:SetTexture ([[Interface\AddOns\Details\images\default_button]]) - button.textureRight:SetTexture ([[Interface\AddOns\Details\images\default_button]]) - button.textureTop:SetTexture ([[Interface\AddOns\Details\images\default_button]]) - button.textureBottom:SetTexture ([[Interface\AddOns\Details\images\default_button]]) - - else - texture = texture or "Interface\\AddOns\\Details\\images\\default_button" - self.button.texture = self.button:CreateTexture (nil, "artwork") - - 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 - - if (coords) then - self.button.texture.coords = coords - self.button.texture:SetTexCoord (_unpack (coords.Normal)) - else - self.button.texture:SetTexCoord (0, 1, 0, 0.24609375) - end - - self.button.texture:SetTexture (texture) - end - - if (side_textures) then - local left = self.button:CreateTexture (nil, "overlay") - left:SetTexture ([[Interface\TALENTFRAME\talent-main]]) - left:SetTexCoord (0.13671875, 0.25, 0.486328125, 0.576171875) - left:SetPoint ("left", self.button, 0, 0) - left:SetWidth (10) - left:SetHeight (self.button:GetHeight()+2) - self.button.left_border = left - - local right = self.button:CreateTexture (nil, "overlay") - right:SetTexture ([[Interface\TALENTFRAME\talent-main]]) - right:SetTexCoord (0.01953125, 0.13671875, 0.486328125, 0.576171875) - right:SetPoint ("right", self.button, 0, 0) - right:SetWidth (10) - right:SetHeight (self.button:GetHeight()+2) - self.button.right_border = right - - elseif (side_textures2) then - - local left = self.button:CreateTexture (nil, "overlay") - left:SetTexture ([[Interface\AddOns\Details\images\icons]]) - left:SetTexCoord (94/512, 123/512, 42/512, 87/512) - left:SetPoint ("left", self.button, 0, 0) - left:SetWidth (10) - left:SetHeight (self.button:GetHeight()+2) - self.button.left_border = left - - local right = self.button:CreateTexture (nil, "overlay") - right:SetTexture ([[Interface\AddOns\Details\images\icons]]) - right:SetTexCoord (65/512, 94/512, 42/512, 87/512) - right:SetPoint ("right", self.button, 0, 0) - right:SetWidth (10) - right:SetHeight (self.button:GetHeight()+2) - self.button.right_border = right - end +--custom textures + function ButtonMetaFunctions:InstallCustomTexture() + --function deprecated, now just set a the standard template + self:SetTemplate(DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")) end ------------------------------------------------------------------------------------------------------------ ---> scripts +--scripts - local OnEnter = function (button) + local OnEnter = function(button) + local object = button.MyObject - local capsule = button.MyObject - - if (button.textureTopLeft) then - button.textureLeft:SetTexCoord (0, 4/128, 40/128, 56/128) - button.textureRight:SetTexCoord (124/128, 1, 40/128, 56/128) - button.textureTop:SetTexCoord (9/128, 120/128, 33/128, 37/128) - button.textureBottom:SetTexCoord (9/128, 119/128, 60/128, 64/128) - - button.textureTopLeft:SetTexCoord (0, 8/128, 33/128, 40/128) - button.textureTopRight:SetTexCoord (121/128, 1, 33/128, 40/128) - button.textureBottomLeft:SetTexCoord (0, 8/128, 56/128, 64/128) - button.textureBottomRight:SetTexCoord (120/128, 1, 56/128, 64/128) - end - - local kill = capsule:RunHooksForWidget ("OnEnter", button, capsule) + local kill = object:RunHooksForWidget("OnEnter", button, object) if (kill) then return end button.MyObject.is_mouse_over = true - + if (button.texture) then if (button.texture.coords) then - button.texture:SetTexCoord (_unpack (button.texture.coords.Highlight)) + button.texture:SetTexCoord(unpack(button.texture.coords.Highlight)) else - button.texture:SetTexCoord (0, 1, 0.24609375, 0.49609375) + button.texture:SetTexCoord(0, 1, 0.24609375, 0.49609375) end end if (button.MyObject.onenter_backdrop_border_color) then - button:SetBackdropBorderColor (unpack (button.MyObject.onenter_backdrop_border_color)) + button:SetBackdropBorderColor(unpack(button.MyObject.onenter_backdrop_border_color)) end - + if (button.MyObject.onenter_backdrop) then - button:SetBackdropColor (unpack (button.MyObject.onenter_backdrop)) + button:SetBackdropColor(unpack(button.MyObject.onenter_backdrop)) end - - if (button.MyObject.have_tooltip) then - GameCooltip2:Preset (2) - if (type (button.MyObject.have_tooltip) == "function") then - GameCooltip2:AddLine (button.MyObject.have_tooltip() or "") + + if (button.MyObject.have_tooltip) then + GameCooltip2:Preset(2) + if (type(button.MyObject.have_tooltip) == "function") then + GameCooltip2:AddLine(button.MyObject.have_tooltip() or "") else - GameCooltip2:AddLine (button.MyObject.have_tooltip) + GameCooltip2:AddLine(button.MyObject.have_tooltip) end - GameCooltip2:ShowCooltip (button, "tooltip") + GameCooltip2:ShowCooltip(button, "tooltip") end end - - local OnLeave = function (button) - - local capsule = button.MyObject - - if (button.textureLeft and not button.MyObject.is_mouse_down) then - button.textureLeft:SetTexCoord (0, 4/128, 9/128, 24/128) - button.textureRight:SetTexCoord (124/128, 1, 9/128, 24/128) - button.textureTop:SetTexCoord (9/128, 120/128, 0, 4/128) - button.textureBottom:SetTexCoord (9/128, 119/128, 28/128, 32/128) - - button.textureTopLeft:SetTexCoord (0, 8/128, 0, 8/128) - button.textureTopRight:SetTexCoord (121/128, 1, 0, 8/128) - button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128) - button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128) - end - - local kill = capsule:RunHooksForWidget ("OnLeave", button, capsule) + + local OnLeave = function(button) + local object = button.MyObject + + local kill = object:RunHooksForWidget("OnLeave", button, object) if (kill) then return end - + button.MyObject.is_mouse_over = false - + if (button.texture and not button.MyObject.is_mouse_down) then if (button.texture.coords) then - button.texture:SetTexCoord (_unpack (button.texture.coords.Normal)) - else - button.texture:SetTexCoord (0, 1, 0, 0.24609375) + button.texture:SetTexCoord(unpack(button.texture.coords.Normal)) + else + button.texture:SetTexCoord(0, 1, 0, 0.24609375) end end if (button.MyObject.onleave_backdrop_border_color) then - button:SetBackdropBorderColor (unpack (button.MyObject.onleave_backdrop_border_color)) + button:SetBackdropBorderColor(unpack(button.MyObject.onleave_backdrop_border_color)) end - + if (button.MyObject.onleave_backdrop) then - button:SetBackdropColor (unpack (button.MyObject.onleave_backdrop)) + button:SetBackdropColor(unpack(button.MyObject.onleave_backdrop)) end - + if (button.MyObject.have_tooltip) then - if (GameCooltip2:GetText (1) == button.MyObject.have_tooltip or type (button.MyObject.have_tooltip) == "function") then + if (GameCooltip2:GetText(1) == button.MyObject.have_tooltip or type(button.MyObject.have_tooltip) == "function") then GameCooltip2:Hide() end end end - - local OnHide = function (button) - local capsule = button.MyObject - local kill = capsule:RunHooksForWidget ("OnHide", button, capsule) + + local OnHide = function(button) + local object = button.MyObject + local kill = object:RunHooksForWidget("OnHide", button, object) if (kill) then return end end - - local OnShow = function (button) - local capsule = button.MyObject - local kill = capsule:RunHooksForWidget ("OnShow", button, capsule) + + local OnShow = function(button) + local object = button.MyObject + local kill = object:RunHooksForWidget("OnShow", button, object) if (kill) then return end end - - local OnMouseDown = function (button, buttontype) - local capsule = button.MyObject - + + local OnMouseDown = function(button, buttontype) + local object = button.MyObject + if (not button:IsEnabled()) then return - end - - if (button.textureTopLeft) then - button.textureLeft:SetTexCoord (0, 4/128, 72/128, 88/128) - button.textureRight:SetTexCoord (124/128, 1, 72/128, 88/128) - button.textureTop:SetTexCoord (9/128, 120/128, 65/128, 68/128) - button.textureBottom:SetTexCoord (9/128, 119/128, 92/128, 96/128) - - button.textureTopLeft:SetTexCoord (0, 8/128, 65/128, 71/128) - button.textureTopRight:SetTexCoord (121/128, 1, 65/128, 71/128) - button.textureBottomLeft:SetTexCoord (0, 8/128, 88/128, 96/128) - button.textureBottomRight:SetTexCoord (120/128, 1, 88/128, 96/128) end - local kill = capsule:RunHooksForWidget ("OnMouseDown", button, capsule) + local kill = object:RunHooksForWidget("OnMouseDown", button, object) if (kill) then return end - + button.MyObject.is_mouse_down = true - + if (button.texture) then if (button.texture.coords) then - button.texture:SetTexCoord (_unpack (button.texture.coords.Pushed)) - else - button.texture:SetTexCoord (0, 1, 0.5078125, 0.75) + button.texture:SetTexCoord(unpack(button.texture.coords.Pushed)) + else + button.texture:SetTexCoord(0, 1, 0.5078125, 0.75) end end - + if (button.MyObject.capsule_textalign) then if (button.MyObject.icon) then - button.MyObject.icon:SetPoint ("left", button, "left", 5 + (button.MyObject.icon.leftpadding or 0), -1) + button.MyObject.icon:SetPoint("left", button, "left", 5 + (button.MyObject.icon.leftpadding or 0), -1) + elseif (button.MyObject.capsule_textalign == "left") then - button.text:SetPoint ("left", button, "left", 3, -1) + button.text:SetPoint("left", button, "left", 3, -1) + elseif (button.MyObject.capsule_textalign == "center") then - button.text:SetPoint ("center", button, "center", 1, -1) + button.text:SetPoint("center", button, "center", 1, -1) + elseif (button.MyObject.capsule_textalign == "right") then - button.text:SetPoint ("right", button, "right", -1, -1) + button.text:SetPoint("right", button, "right", -1, -1) end else if (button.MyObject.icon) then - button.MyObject.icon:SetPoint ("left", button, "left", 5 + (button.MyObject.icon.leftpadding or 0), -1) + button.MyObject.icon:SetPoint("left", button, "left", 5 + (button.MyObject.icon.leftpadding or 0), -1) else - button.text:SetPoint ("center", button,"center", 1, -1) + button.text:SetPoint("center", button,"center", 1, -1) end end button.mouse_down = GetTime() local x, y = GetCursorPosition() - button.x = _math_floor (x) - button.y = _math_floor (y) - + button.x = floor(x) + button.y = 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 (type(button.MyObject.options.OnGrab) == "string" and button.MyObject.options.OnGrab == "PassClick") then if (buttontype == "LeftButton") then - DF:CoreDispatch ((button:GetName() or "Button") .. ":OnMouseDown()", button.MyObject.func, button, buttontype, button.MyObject.param1, button.MyObject.param2) + DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", button.MyObject.func, button, buttontype, button.MyObject.param1, button.MyObject.param2) else - DF:CoreDispatch ((button:GetName() or "Button") .. ":OnMouseDown()", button.MyObject.funcright, button, buttontype, button.MyObject.param1, button.MyObject.param2) + DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", button.MyObject.funcright, button, buttontype, button.MyObject.param1, button.MyObject.param2) end end end end - local OnMouseUp = function (button, buttontype) + local OnMouseUp = function(button, buttonType) if (not button:IsEnabled()) then return end - - if (button.textureLeft) then - if (button.MyObject.is_mouse_over) then - button.textureLeft:SetTexCoord (0, 4/128, 40/128, 56/128) - button.textureRight:SetTexCoord (124/128, 1, 40/128, 56/128) - button.textureTop:SetTexCoord (9/128, 120/128, 33/128, 37/128) - button.textureBottom:SetTexCoord (9/128, 119/128, 60/128, 64/128) - - button.textureTopLeft:SetTexCoord (0, 8/128, 33/128, 40/128) - button.textureTopRight:SetTexCoord (121/128, 1, 33/128, 40/128) - button.textureBottomLeft:SetTexCoord (0, 8/128, 56/128, 64/128) - button.textureBottomRight:SetTexCoord (120/128, 1, 56/128, 64/128) - else - button.textureLeft:SetTexCoord (0, 4/128, 9/128, 24/128) - button.textureRight:SetTexCoord (124/128, 1, 9/128, 24/128) - button.textureTop:SetTexCoord (9/128, 120/128, 0, 4/128) - button.textureBottom:SetTexCoord (9/128, 119/128, 28/128, 32/128) - - button.textureTopLeft:SetTexCoord (0, 8/128, 0, 8/128) - button.textureTopRight:SetTexCoord (121/128, 1, 0, 8/128) - button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128) - button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128) - end - end - - local capsule = button.MyObject - local kill = capsule:RunHooksForWidget ("OnMouseUp", button, capsule) + + local object = button.MyObject + local kill = object:RunHooksForWidget("OnMouseUp", button, object) if (kill) then return end - + button.MyObject.is_mouse_down = false - + if (button.texture) then if (button.texture.coords) then if (button.MyObject.is_mouse_over) then - button.texture:SetTexCoord (_unpack (button.texture.coords.Highlight)) + button.texture:SetTexCoord(unpack(button.texture.coords.Highlight)) else - button.texture:SetTexCoord (_unpack (coords.Normal)) + button.texture:SetTexCoord(unpack(coords.Normal)) end - else + else if (button.MyObject.is_mouse_over) then - button.texture:SetTexCoord (0, 1, 0.24609375, 0.49609375) + button.texture:SetTexCoord(0, 1, 0.24609375, 0.49609375) else - button.texture:SetTexCoord (0, 1, 0, 0.24609375) + button.texture:SetTexCoord(0, 1, 0, 0.24609375) end end end if (button.MyObject.capsule_textalign) then if (button.MyObject.icon) then - button.MyObject.icon:SetPoint ("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0) + button.MyObject.icon:SetPoint("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0) + elseif (button.MyObject.capsule_textalign == "left") then - button.text:SetPoint ("left", button, "left", 2, 0) + button.text:SetPoint("left", button, "left", 2, 0) + elseif (button.MyObject.capsule_textalign == "center") then - button.text:SetPoint ("center", button, "center", 0, 0) + button.text:SetPoint("center", button, "center", 0, 0) + elseif (button.MyObject.capsule_textalign == "right") then - button.text:SetPoint ("right", button, "right", -2, 0) + button.text:SetPoint("right", button, "right", -2, 0) end else if (button.MyObject.icon) then - button.MyObject.icon:SetPoint ("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0) + button.MyObject.icon:SetPoint("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0) else - button.text:SetPoint ("center", button,"center", 0, 0) + button.text:SetPoint("center", button,"center", 0, 0) end end - + 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) - + x = floor(x) + y = floor(y) + button.mouse_down = button.mouse_down or 0 --avoid issues when the button was pressed while disabled and release when enabled - - if ( - (x == button.x and y == button.y) or - (button.mouse_down+0.5 > GetTime() and button:IsMouseOver()) - ) then - if (buttontype == "LeftButton") then - DF:CoreDispatch ((button:GetName() or "Button") .. ":OnMouseUp()", button.MyObject.func, button, buttontype, button.MyObject.param1, button.MyObject.param2) + + if ((x == button.x and y == button.y) or (button.mouse_down + 0.5 > GetTime() and button:IsMouseOver())) then + if (buttonType == "LeftButton") then + DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", button.MyObject.func, button, buttonType, button.MyObject.param1, button.MyObject.param2) else - DF:CoreDispatch ((button:GetName() or "Button") .. ":OnMouseUp()", button.MyObject.funcright, button, buttontype, button.MyObject.param1, button.MyObject.param2) + DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", button.MyObject.funcright, button, buttonType, button.MyObject.param1, button.MyObject.param2) end end end @@ -1020,247 +814,244 @@ function ButtonMetaFunctions:SetTemplate(template) end ------------------------------------------------------------------------------------------------------------ ---> object constructor +--object constructor -local createButtonWidgets = function(self) - self:SetSize(100, 20) - - self.text = self:CreateFontString("$parent_Text", "ARTWORK", "GameFontNormal") - self.text:SetJustifyH("CENTER") - DF:SetFontSize(self.text, 10) - self.text:SetPoint("CENTER", self, "CENTER", 0, 0) - - self.texture_disabled = self:CreateTexture("$parent_TextureDisabled", "OVERLAY") - self.texture_disabled:SetAllPoints() - self.texture_disabled:Hide() - self.texture_disabled:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background") - - self:SetScript("OnDisable", function(self) + local onDisableFunc = function(self) self.texture_disabled:Show() self.texture_disabled:SetVertexColor(0, 0, 0) self.texture_disabled:SetAlpha(.5) - end) + end - self:SetScript("OnEnable", function(self) + local onEnableFunc = function(self) self.texture_disabled:Hide() - end) -end - -function DF:CreateButton(parent, func, width, height, text, param1, param2, texture, member, name, shortMethod, buttonTemplate, textTemplate) - return DF:NewButton(parent, parent, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate) -end - -function DF:NewButton(parent, container, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate) - if (not name) then - name = "DetailsFrameworkButtonNumber" .. DF.ButtonCounter - DF.ButtonCounter = DF.ButtonCounter + 1 - - elseif (not parent) then - return error("Details! FrameWork: parent not found.", 2) end - if (not container) then - container = parent + local createButtonWidgets = function(self) + self:SetSize(100, 20) + + self.text = self:CreateFontString("$parent_Text", "ARTWORK", "GameFontNormal") + self:SetFontString(self.text) + self.text:SetJustifyH("CENTER") + DF:SetFontSize(self.text, 10) + self.text:SetPoint("CENTER", self, "CENTER", 0, 0) + + self.texture_disabled = self:CreateTexture("$parent_TextureDisabled", "OVERLAY") + self.texture_disabled:SetAllPoints() + self.texture_disabled:Hide() + self.texture_disabled:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background") + + self:SetScript("OnDisable", onDisableFunc) + self:SetScript("OnEnable", onEnableFunc) end - if (name:find("$parent")) then - local parentName = DF.GetParentName(parent) - name = name:gsub("$parent", parentName) + function DF:CreateButton(parent, func, width, height, text, param1, param2, texture, member, name, shortMethod, buttonTemplate, textTemplate) + return DF:NewButton(parent, parent, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate) end - local buttonObject = {type = "button", dframework = true} + function DF:NewButton(parent, container, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate) + if (not name) then + name = "DetailsFrameworkButtonNumber" .. DF.ButtonCounter + DF.ButtonCounter = DF.ButtonCounter + 1 - if (member) then - parent[member] = buttonObject - end + elseif (not parent) then + return error("Details! FrameWork: parent not found.", 2) + end - if (parent.dframework) then - parent = parent.widget - end - if (container.dframework) then - container = container.widget - end + if (name:find("$parent")) then + local parentName = DF.GetParentName(parent) + name = name:gsub("$parent", parentName) + end - --default members - buttonObject.is_locked = true - buttonObject.container = container - buttonObject.options = {OnGrab = false} + local buttonObject = {type = "button", dframework = true} - buttonObject.button = CreateFrame("button", name, parent, "BackdropTemplate") - DF:Mixin(buttonObject.button, DF.WidgetFunctions) + if (member) then + parent[member] = buttonObject + end - createButtonWidgets(buttonObject.button) + if (parent.dframework) then + parent = parent.widget + end - buttonObject.widget = buttonObject.button - buttonObject.button:SetBackdropColor(0, 0, 0, 0.4) - buttonObject.button:SetBackdropBorderColor(1, 1, 1, 1) + --container is used to move the 'container' frame when attempt to move the button + buttonObject.container = container or parent - 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(...) + --default members + buttonObject.is_locked = true + buttonObject.options = {OnGrab = false} + + buttonObject.button = CreateFrame("button", name, parent, "BackdropTemplate") + DF:Mixin(buttonObject.button, DF.WidgetFunctions) + + createButtonWidgets(buttonObject.button) + + buttonObject.widget = buttonObject.button + buttonObject.button:SetBackdropColor(0, 0, 0, 0.4) + buttonObject.button:SetBackdropBorderColor(1, 1, 1, 1) + + 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 - end - buttonObject.button:SetWidth(width or 100) - buttonObject.button:SetHeight(height or 20) - buttonObject.button.MyObject = buttonObject + buttonObject.button:SetWidth(width or 100) + buttonObject.button:SetHeight(height or 20) + buttonObject.button.MyObject = buttonObject - buttonObject.text_overlay = _G[name .. "_Text"] - buttonObject.disabled_overlay = _G[name .. "_TextureDisabled"] + buttonObject.text_overlay = _G[name .. "_Text"] + buttonObject.disabled_overlay = _G[name .. "_TextureDisabled"] - texture = texture or "" - buttonObject.button:SetNormalTexture(texture) - buttonObject.button:SetPushedTexture(texture) - buttonObject.button:SetDisabledTexture(texture) - buttonObject.button:SetHighlightTexture(texture, "ADD") + texture = texture or "" + buttonObject.button:SetNormalTexture(texture) + buttonObject.button:SetPushedTexture(texture) + buttonObject.button:SetDisabledTexture(texture) + buttonObject.button:SetHighlightTexture(texture, "ADD") - buttonObject.button.text:SetText(text or "") - buttonObject.button.text:SetPoint("center", buttonObject.button, "center") + buttonObject.button.text:SetText(text or "") + buttonObject.button.text:SetPoint("center", buttonObject.button, "center") - local textWidth = buttonObject.button.text:GetStringWidth() - if (textWidth > width - 15 and buttonObject.button.text:GetText() ~= "") then - if (shortMethod == false) then --> if is false, do not use auto resize - --do nothing - elseif (not shortMethod) then --> if the value is omitted, use the default resize - local new_width = textWidth + 15 - buttonObject.button:SetWidth(new_width) + local textWidth = buttonObject.button.text:GetStringWidth() + if (textWidth > width - 15 and buttonObject.button.text:GetText() ~= "") then + if (shortMethod == false) then --> if is false, do not use auto resize + --do nothing + elseif (not shortMethod) then --> if the value is omitted, use the default resize + local new_width = textWidth + 15 + buttonObject.button:SetWidth(new_width) - elseif (shortMethod == 1) then - local loop = true - local textsize = 11 - while (loop) do - if (textWidth + 15 < width or textsize < 8) then - loop = false - break - else - DF:SetFontSize(buttonObject.button.text, textsize) - textWidth = buttonObject.button.text:GetStringWidth() - textsize = textsize - 1 + elseif (shortMethod == 1) then + local loop = true + local textsize = 11 + while (loop) do + if (textWidth + 15 < width or textsize < 8) then + loop = false + break + else + DF:SetFontSize(buttonObject.button.text, textsize) + textWidth = buttonObject.button.text:GetStringWidth() + textsize = textsize - 1 + end end + elseif (shortMethod == 2) then + end - elseif (shortMethod == 2) then - end + + buttonObject.func = func or cleanfunction + buttonObject.funcright = cleanfunction + buttonObject.param1 = param1 + buttonObject.param2 = param2 + buttonObject.short_method = shortMethod + + if (textTemplate) then + if (textTemplate.size) then + DF:SetFontSize(buttonObject.button.text, textTemplate.size) + end + if (textTemplate.color) then + local r, g, b, a = DF:ParseColors(textTemplate.color) + buttonObject.button.text:SetTextColor(r, g, b, a) + end + if (textTemplate.font) then + local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") + local font = SharedMedia:Fetch("font", textTemplate.font) + DF:SetFontFace(buttonObject.button.text, font) + end + end + + --hooks + buttonObject.HookList = { + OnEnter = {}, + OnLeave = {}, + OnHide = {}, + OnShow = {}, + OnMouseDown = {}, + OnMouseUp = {}, + } + + 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) + + if (buttonTemplate) then + buttonObject:SetTemplate(buttonTemplate) + end + + return buttonObject end - buttonObject.func = func or cleanfunction - buttonObject.funcright = cleanfunction - buttonObject.param1 = param1 - buttonObject.param2 = param2 - buttonObject.short_method = shortMethod +------------------------------------------------------------------------------------------------------------ +--color picker button - if (textTemplate) then - if (textTemplate.size) then - DF:SetFontSize(buttonObject.button.text, textTemplate.size) - end - if (textTemplate.color) then - local r, g, b, a = DF:ParseColors(textTemplate.color) - buttonObject.button.text:SetTextColor(r, g, b, a) - end - if (textTemplate.font) then - local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") - local font = SharedMedia:Fetch("font", textTemplate.font) - DF:SetFontFace(buttonObject.button.text, font) - end + local pickcolorCallback = function(self, red, green, blue, alpha, button) + alpha = abs(alpha - 1) + button.MyObject.color_texture:SetVertexColor(red, green, blue, alpha) + + --safecall + DF:CoreDispatch((self:GetName() or "ColorPicker") .. ".pickcolor_callback()", button.MyObject.color_callback, button.MyObject, red, green, blue, alpha) + button.MyObject:RunHooksForWidget("OnColorChanged", button.MyObject, red, green, blue, alpha) end - --hooks - buttonObject.HookList = { - OnEnter = {}, - OnLeave = {}, - OnHide = {}, - OnShow = {}, - OnMouseDown = {}, - OnMouseUp = {}, - } - - 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) - - if (buttonTemplate) then - buttonObject:SetTemplate(buttonTemplate) + local pickcolor = function(self) + local red, green, blue, alpha = self.MyObject.color_texture:GetVertexColor() + alpha = abs(alpha - 1) + DF:ColorPick(self, red, green, blue, alpha, pickcolorCallback) end - return buttonObject -end - -local pickcolor_callback = function (self, r, g, b, a, button) - a = abs (a-1) - button.MyObject.color_texture:SetVertexColor (r, g, b, a) - - --> safecall - DF:CoreDispatch ((self:GetName() or "ColorPicker") .. ".pickcolor_callback()", button.MyObject.color_callback, button.MyObject, r, g, b, a) - button.MyObject:RunHooksForWidget ("OnColorChanged", button.MyObject, r, g, b, a) -end - -local pickcolor = function (self, alpha, param2) - local r, g, b, a = self.MyObject.color_texture:GetVertexColor() - a = abs (a-1) - DF:ColorPick (self, r, g, b, a, pickcolor_callback) -end - -local color_button_height = 16 -local color_button_width = 16 - -local setColorPickColor = function (button, r, g, b, a) - r, g, b, a = DF:ParseColors(r, g, b, a) - button.color_texture:SetVertexColor (r, g, b, a) -end - -local colorpick_cancel = function (self) - ColorPickerFrame:Hide() -end - -local getColorPickColor = function(self) - return self.color_texture:GetVertexColor() -end - -function DF:CreateColorPickButton (parent, name, member, callback, alpha, button_template) - return DF:NewColorPickButton (parent, name, member, callback, alpha, button_template) -end - -function DF:NewColorPickButton (parent, name, member, callback, alpha, button_template) - --button - local button = DF:NewButton (parent, _, name, member, color_button_width, color_button_height, pickcolor, alpha, "param2", nil, nil, nil, button_template) - button.color_callback = callback - button.Cancel = colorpick_cancel - button.SetColor = setColorPickColor - button.GetColor = getColorPickColor - - button.HookList.OnColorChanged = {} - - if (not button_template) then - button:InstallCustomTexture() - button:SetBackdrop ({edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 6, - bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], insets = {left = 0, right = 0, top = 0, bottom = 0}}) + local setColorPickColor = function(button, ...) + local red, green, blue, alpha = DF:ParseColors(...) + button.color_texture:SetVertexColor (red, green, blue, alpha) end - local background = button:CreateTexture(nil, "background", nil, 2) - background:SetPoint("topleft", button.widget, "topleft", 0, 0) - background:SetPoint("bottomright", button.widget, "bottomright", 0, 0) - background:SetTexture([[Interface\ITEMSOCKETINGFRAME\UI-EMPTYSOCKET]]) - background:SetTexCoord(3/16, 13/16, 3/16, 13/16) - background:SetAlpha(0.3) + local colorpickCancel = function(self) + ColorPickerFrame:Hide() + end - --textura da cor - local img = DF:NewImage (button, nil, color_button_width, color_button_height, nil, nil, "color_texture", "$parentTex") - img:SetColorTexture (1, 1, 1) - img:SetPoint ("topleft", button.widget, "topleft", 0, 0) - img:SetPoint ("bottomright", button.widget, "bottomright", 0, 0) - img:SetDrawLayer ("background", 3) + local getColorPickColor = function(self) + return self.color_texture:GetVertexColor() + end - return button -end + function DF:CreateColorPickButton(parent, name, member, callback, alpha, buttonTemplate) + return DF:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate) + end + + function DF:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate) + --button + local button = DF:NewButton(parent, _, name, member, 16, 16, pickcolor, alpha, "param2", nil, nil, nil, buttonTemplate) + button.color_callback = callback + button.Cancel = colorpickCancel + button.SetColor = setColorPickColor + button.GetColor = getColorPickColor + + button.HookList.OnColorChanged = {} + + if (not buttonTemplate) then + button:InstallCustomTexture() + end + + local background = button:CreateTexture(nil, "background", nil, 2) + background:SetPoint("topleft", button.widget, "topleft", 0, 0) + background:SetPoint("bottomright", button.widget, "bottomright", 0, 0) + background:SetTexture([[Interface\ITEMSOCKETINGFRAME\UI-EMPTYSOCKET]]) + background:SetTexCoord(3/16, 13/16, 3/16, 13/16) + background:SetAlpha(0.3) + + --color texture + local img = DF:NewImage(button, nil, 16, 16, nil, nil, "color_texture", "$parentTex") + img:SetColorTexture(1, 1, 1) + img:SetPoint("topleft", button.widget, "topleft", 0, 0) + img:SetPoint("bottomright", button.widget, "bottomright", 0, 0) + img:SetDrawLayer("background", 3) + + return button + end diff --git a/Libs/DF/cooltip.lua b/Libs/DF/cooltip.lua index f6bec583..ddd84325 100644 --- a/Libs/DF/cooltip.lua +++ b/Libs/DF/cooltip.lua @@ -15,7 +15,7 @@ local max = math.max --api locals local PixelUtil = PixelUtil or DFPixelUtil -local version = 3 +local version = 4 local CONST_MENU_TYPE_MAINMENU = "main" local CONST_MENU_TYPE_SUBMENU = "sub" @@ -145,10 +145,30 @@ function DF:CreateCoolTip() } gameCooltip.AliasList = { - ["VerticalOffset"] = "ButtonsYMod", - ["VerticalPadding"] = "YSpacingMod", + --set the height of each line, options 'IgnoreButtonAutoHeight' and 'AlignAsBlizzTooltip' must be false ["LineHeightSizeOffset"] = "ButtonHeightMod", + ["LineHeightSizeOffsetSub"] = "ButtonHeightModSub", + ["FrameHeightSizeOffset"] = "HeighMod", + ["FrameHeightSizeOffsetSub"] = "HeighModSub", + + --space between the tooltip's left side and the start of the line + ["LeftPadding"] = "LeftBorderSize", + + --space between the tooltip's right side and the end of the line + ["RightPadding"] = "RightBorderSize", + + --space between each line, positive values make the lines be closer + ["LinePadding"] = "YSpacingMod", + ["VerticalPadding"] = "YSpacingMod", + ["LinePaddingSub"] = "YSpacingModSub", + ["VerticalPaddingSub"] = "YSpacingModSub", + + --move each line in the Y axis (vertical offsett) + ["LineYOffset"] = "ButtonsYMod", + ["VerticalOffset"] = "ButtonsYMod", + ["LineYOffsetSub"] = "ButtonsYModSub", + ["VerticalOffsetSub"] = "ButtonsYModSub", } gameCooltip.OptionsTable = {} @@ -1475,8 +1495,8 @@ function DF:CreateCoolTip() frame1.w = gameCooltip.OptionsTable.FixedWidth or 0 frame1.hHeight = 0 frame2.hHeight = 0 - gameCooltip.active = true + for i = 1, gameCooltip.Indexes do local button = frame1.Lines[i] if (not button) then @@ -1485,10 +1505,11 @@ function DF:CreateCoolTip() button.index = i - --basic stuff button:Show() button.background:Hide() button:SetHeight(gameCooltip.OptionsTable.ButtonHeightMod or gameCooltip.default_height) + + --clear registered click buttons button:RegisterForClicks() --setup texts and icons @@ -1510,7 +1531,7 @@ function DF:CreateCoolTip() --normalize height of all rows local heightValue = -6 + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0) - for i = 1, gameCooltip.Indexes do + for i = 1, gameCooltip.Indexes do local menuButton = frame1.Lines[i] menuButton:ClearAllPoints() @@ -1528,19 +1549,17 @@ function DF:CreateCoolTip() local height = max(2, menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight(), gameCooltip.OptionsTable.AlignAsBlizzTooltipForceHeight or 2) menuButton:SetHeight(height) menuButton:SetPoint("top", frame1, "top", 0, heightValue) - heightValue = heightValue + ( height * -1) + heightValue = heightValue + (height * -1) elseif (gameCooltip.OptionsTable.IgnoreButtonAutoHeight) then - local height = max(menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight()) menuButton:SetHeight(height) menuButton:SetPoint("top", frame1, "top", 0, heightValue) - - heightValue = heightValue + ( height * -1) + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0) + heightValue = heightValue + (height * -1) + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0) else menuButton:SetHeight(frame1.hHeight + (gameCooltip.OptionsTable.ButtonHeightMod or 0)) - menuButton:SetPoint("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 6 + (gameCooltip.OptionsTable.ButtonsYMod or 0) + spacing) + menuButton:SetPoint("top", frame1, "top", 0, (((i-1) * frame1.hHeight) * -1) - 6 + (gameCooltip.OptionsTable.ButtonsYMod or 0) + spacing) end if (gameCooltip.OptionsTable.YSpacingMod and not gameCooltip.OptionsTable.IgnoreButtonAutoHeight) then @@ -1553,8 +1572,8 @@ function DF:CreateCoolTip() if (not gameCooltip.OptionsTable.FixedWidth) then if (gameCooltip.Type == 2) then --with bars if (gameCooltip.OptionsTable.MinWidth) then - local w = frame1.w + 34 - PixelUtil.SetWidth(frame1, math.max(w, gameCooltip.OptionsTable.MinWidth)) + local width = frame1.w + 34 + PixelUtil.SetWidth(frame1, math.max(width, gameCooltip.OptionsTable.MinWidth)) else PixelUtil.SetWidth(frame1, frame1.w + 34) end @@ -1585,7 +1604,7 @@ function DF:CreateCoolTip() PixelUtil.SetHeight(frame1, (heightValue + spacing) * -1) else - PixelUtil.SetHeight(frame1, max( (frame1.hHeight * gameCooltip.Indexes) + 8 + ((gameCooltip.OptionsTable.ButtonsYMod or 0)*-1), 22 )) + PixelUtil.SetHeight(frame1, max((frame1.hHeight * gameCooltip.Indexes) + 8 + ((gameCooltip.OptionsTable.ButtonsYMod or 0) * -1), 22)) end end @@ -3136,39 +3155,27 @@ function DF:CreateCoolTip() self:Reset(true) end + gameCooltip:SetOption("StatusBarTexture", [[Interface\WorldStateFrame\WORLDSTATEFINALSCORE-HIGHLIGHT]]) + self:SetOption("TextFont", DF:GetBestFontForLanguage()) + self:SetOption("TextColor", "orange") + self:SetOption("TextSize", 11) + self:SetOption("ButtonsYMod", -4) + self:SetOption("YSpacingMod", -4) + self:SetOption("IgnoreButtonAutoHeight", true) + if (presetId == 1) then - self:SetOption("TextFont", DF:GetBestFontForLanguage()) - self:SetOption("TextColor", "orange") - self:SetOption("TextSize", 12) - self:SetOption("ButtonsYMod", -4) - self:SetOption("YSpacingMod", -4) - self:SetOption("IgnoreButtonAutoHeight", true) self:SetColor(1, 0.5, 0.5, 0.5, 0.5) elseif (presetId == 2) then --used by most of the widgets - self:SetOption("TextFont", DF:GetBestFontForLanguage()) - self:SetOption("TextColor", "orange") - self:SetOption("TextSize", 12) self:SetOption("FixedWidth", 220) - self:SetOption("ButtonsYMod", -4) - self:SetOption("YSpacingMod", -4) - self:SetOption("IgnoreButtonAutoHeight", true) self:SetColor(1, defaultBackdropColor) self:SetColor(2, defaultBackdropColor) - self:SetBackdrop(1, defaultBackdrop, defaultBackdropColor, defaultBackdropBorderColor) self:SetBackdrop(2, defaultBackdrop, defaultBackdropColor, defaultBackdropBorderColor) elseif (presetId == 3) then --default used when Cooltip:Reset() is called - self:SetOption("TextFont", DF:GetBestFontForLanguage()) - self:SetOption("TextColor", "orange") - self:SetOption("TextSize", 12) - self:SetOption("ButtonsYMod", -4) - self:SetOption("YSpacingMod", -4) - self:SetOption("IgnoreButtonAutoHeight", true) self:SetColor(1, defaultBackdropColor) self:SetColor(2, defaultBackdropColor) - self:SetBackdrop(1, defaultBackdrop, defaultBackdropColor, defaultBackdropBorderColor) self:SetBackdrop(2, defaultBackdrop, defaultBackdropColor, defaultBackdropBorderColor) end diff --git a/Libs/DF/dropdown.lua b/Libs/DF/dropdown.lua index 81238c98..aae4ec8a 100644 --- a/Libs/DF/dropdown.lua +++ b/Libs/DF/dropdown.lua @@ -37,6 +37,9 @@ end local DropDownMetaFunctions = _G[DF.GlobalWidgetControlNames["dropdown"]] +DF:Mixin(DropDownMetaFunctions, DF.SetPointMixin) +DF:Mixin(DropDownMetaFunctions, DF.FrameMixin) + ------------------------------------------------------------------------------------------------------------ --metatables @@ -173,30 +176,7 @@ local DropDownMetaFunctions = _G[DF.GlobalWidgetControlNames["dropdown"]] ------------------------------------------------------------------------------------------------------------ -function DropDownMetaFunctions:SetBackdrop(...) - return self.dropdown:SetBackdrop(...) -end - -function DropDownMetaFunctions:SetBackdropColor(...) - return self.dropdown:SetBackdropColor(...) -end - -function DropDownMetaFunctions:SetBackdropBorderColor(...) - return self.dropdown:SetBackdropBorderColor(...) -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 +--menu width and height function DropDownMetaFunctions:SetMenuSize(width, height) if (width) then return rawset(self, "realsizeW", width) @@ -209,7 +189,7 @@ end return rawget(self, "realsizeW"), rawget(self, "realsizeH") end ---> function +--function function DropDownMetaFunctions:SetFunction(func) return rawset(self, "func", func) end @@ -217,7 +197,7 @@ end return rawget(self, "func") end ---> value +--value function DropDownMetaFunctions:GetValue() return rawget(self, "myvalue") end @@ -225,27 +205,7 @@ end return rawset(self, "myvalue", value) end ---> setpoint - function DropDownMetaFunctions:SetPoint(v1, v2, v3, v4, v5) - v1, v2, v3, v4, v5 = DF:CheckPoints(v1, v2, v3, v4, v5, self) - if (not v1) then - print("Invalid parameter for SetPoint") - return - end - return self.widget:SetPoint(v1, v2, v3, v4, v5) - end - ---> sizes - function DropDownMetaFunctions:SetSize(width, height) - if (width) then - self.dropdown:SetWidth(width) - end - if (height) then - return self.dropdown:SetHeight(height) - end - end - ---> tooltip +--tooltip function DropDownMetaFunctions:SetTooltip(tooltip) if (tooltip) then return rawset(self, "have_tooltip", tooltip) @@ -257,10 +217,7 @@ end return rawget(self, "have_tooltip") end ---> frame levels - function DropDownMetaFunctions:GetFrameLevel() - return self.dropdown:GetFrameLevel() - end +--frame levels function DropDownMetaFunctions:SetFrameLevel(level, frame) if (not frame) then return self.dropdown:SetFrameLevel(level) @@ -270,25 +227,12 @@ end end end ---> frame stratas - function DropDownMetaFunctions:GetFrameStrata() - 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 +--enabled function DropDownMetaFunctions:IsEnabled() return self.dropdown:IsEnabled() end function DropDownMetaFunctions:Enable() - self:SetAlpha(1) rawset(self, "lockdown", false) @@ -306,13 +250,13 @@ end end end ---> fixed value +--fixed value function DropDownMetaFunctions:SetFixedParameter(value) rawset(self, "FixedValue", value) end ------------------------------------------------------------------------------------------------------------ ---> scripts +--scripts local lastOpened = false diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 9e9a9968..95031502 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 375 +local dversion = 376 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary(major, minor) @@ -9,6 +9,8 @@ if (not DF) then return end +_G["DetailsFramework"] = DF + DetailsFrameworkCanLoad = true local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") @@ -37,6 +39,10 @@ DF.AuthorInfo = { Discord = "https://discord.gg/AGSzAZX", } +function DF:Msg(msg, ...) + print("|cFFFFFFAA" .. (self.__name or "FW Msg:") .. "|r ", msg, ...) +end + local PixelUtil = PixelUtil or DFPixelUtil if (not PixelUtil) then --check if is in classic, TBC, or WotLK wow, if it is, build a replacement for PixelUtil @@ -226,23 +232,23 @@ function DF.GetSpecialization() return nil end -function DF.GetSpecializationInfoByID (...) +function DF.GetSpecializationInfoByID(...) if (GetSpecializationInfoByID) then - return GetSpecializationInfoByID (...) + return GetSpecializationInfoByID(...) end return nil end -function DF.GetSpecializationInfo (...) +function DF.GetSpecializationInfo(...) if (GetSpecializationInfo) then - return GetSpecializationInfo (...) + return GetSpecializationInfo(...) end return nil end -function DF.GetSpecializationRole (...) +function DF.GetSpecializationRole(...) if (GetSpecializationRole) then - return GetSpecializationRole (...) + return GetSpecializationRole(...) end return nil end @@ -283,11 +289,9 @@ DF.SplitBarCounter = DF.SplitBarCounter or init_counter DF.FRAMELEVEL_OVERLAY = 750 DF.FRAMELEVEL_BACKGROUND = 150 ---/dump DetailsFramework:PrintVersion() - DF.FrameWorkVersion = tostring(dversion) function DF:PrintVersion() - print ("Details! Framework Version:", DF.FrameWorkVersion) + print("Details! Framework Version:", DF.FrameWorkVersion) end --get the working folder @@ -303,10 +307,17 @@ end DF.debug = false -_G["DetailsFramework"] = DF +function DF:GetFrameworkFolder() + return DF.folder +end + +function DF:SetFrameworkDebugState(state) + DF.debug = state +end + DF.embeds = DF.embeds or {} -local embed_functions = { +local embedFunctions = { "RemoveRealName", "table", "BuildDropDownFontList", @@ -331,7 +342,7 @@ local embed_functions = { "GetPlayerRole", "GetCharacterTalents", "GetCharacterPvPTalents", - + "CreateDropDown", "CreateButton", "CreateColorPickButton", @@ -382,14 +393,12 @@ local embed_functions = { "SendScriptComm", } -DF.table = {} - -function DF:GetFrameworkFolder() - return DF.folder -end - -function DF:SetFrameworkDebugState(state) - DF.debug = state +function DF:Embed(target) + for k, v in pairs(embedFunctions) do + target[v] = self[v] + end + self.embeds[target] = true + return target end function DF:FadeFrame(frame, t) @@ -411,6 +420,11 @@ function DF:FadeFrame(frame, t) end end +------------------------------------------------------------------------------------------------------------ +--table + +DF.table = {} + function DF.table.find(t, value) for i = 1, #t do if (t[i] == value) then @@ -686,34 +700,27 @@ function DF:IntegerToTimer(value) return "" .. floor(value/60) .. ":" .. format("%02.f", value%60) end -function DF:Embed (target) - for k, v in pairs (embed_functions) do - target[v] = self[v] - end - self.embeds [target] = true - return target +function DF:RemoveRealmName(name) + return name:gsub(("%-.*"), "") end -function DF:RemoveRealmName (name) - return name:gsub (("%-.*"), "") +function DF:RemoveRealName(name) + return name:gsub(("%-.*"), "") end -function DF:RemoveRealName (name) - return name:gsub (("%-.*"), "") +function DF:SetFontSize(fontString, ...) + local font, _, flags = fontString:GetFont() + fontString:SetFont(font, max(...), flags) end -function DF:SetFontSize (fontString, ...) - local fonte, _, flags = fontString:GetFont() - fontString:SetFont (fonte, max (...), flags) -end -function DF:SetFontFace (fontString, fontface) - local font = SharedMedia:Fetch ("font", fontface, true) +function DF:SetFontFace(fontString, fontface) + local font = SharedMedia:Fetch("font", fontface, true) if (font) then fontface = font end local _, size, flags = fontString:GetFont() - fontString:SetFont (fontface, size, flags) + fontString:SetFont(fontface, size, flags) end function DF:SetFontColor (fontString, r, g, b, a) r, g, b, a = DF:ParseColors (r, g, b, a) @@ -745,39 +752,38 @@ function DF:SetFontRotation(fontString, degrees) end end -function DF:AddClassColorToText (text, class) - if (type (class) ~= "string") then - return DF:RemoveRealName (text) - - elseif (class == "UNKNOW" or class == "PET") then - return DF:RemoveRealName (text) +function DF:AddClassColorToText(text, className) + if (type(className) ~= "string") then + return DF:RemoveRealName(text) + + elseif (className == "UNKNOW" or className == "PET") then + return DF:RemoveRealName(text) end - - local color = RAID_CLASS_COLORS [class] + + local color = RAID_CLASS_COLORS[className] if (color) then - text = "|c" .. color.colorStr .. DF:RemoveRealName (text) .. "|r" + text = "|c" .. color.colorStr .. DF:RemoveRealName(text) .. "|r" else - return DF:RemoveRealName (text) + return DF:RemoveRealName(text) end - + return text end function DF:GetClassTCoordsAndTexture(class) local l, r, t, b = unpack(CLASS_ICON_TCOORDS[class]) return l, r, t, b, [[Interface\WORLDSTATEFRAME\Icons-Classes]] - --return l, r, t, b, "Interface\\TargetingFrame\\UI-Classes-Circles" end function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize) local size = iconSize or 16 - - local iconToUse, spec + + local spec if (useSpec) then if (Details) then - local guid = UnitGUID(playerName) - if (guid) then - local spec = Details.cached_specs[guid] + local GUID = UnitGUID(playerName) + if (GUID) then + spec = Details.cached_specs[GUID] if (spec) then spec = spec end @@ -787,7 +793,7 @@ function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize) if (spec) then --if spec is valid, the user has Details! installed local specString = "" - local L, R, T, B = unpack (Details.class_specs_coords[spec]) + local L, R, T, B = unpack(Details.class_specs_coords[spec]) if (L) then specString = "|TInterface\\AddOns\\Details\\images\\spec_icons_normal:" .. size .. ":" .. size .. ":0:0:512:512:" .. (L * 512) .. ":" .. (R * 512) .. ":" .. (T * 512) .. ":" .. (B * 512) .. "|t" return specString .. " " .. text @@ -796,7 +802,7 @@ function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize) if (class) then local classString = "" - local L, R, T, B = unpack (Details.class_coords[class]) + local L, R, T, B = unpack(Details.class_coords[class]) if (L) then local imageSize = 128 classString = "|TInterface\\AddOns\\Details\\images\\classes_small:" .. size .. ":" .. size .. ":0:0:" .. imageSize .. ":" .. imageSize .. ":" .. (L * imageSize) .. ":" .. (R * imageSize) .. ":" .. (T * imageSize) .. ":" .. (B * imageSize) .. "|t" @@ -807,11 +813,11 @@ function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize) return text end -function DF:GetFontSize (fontString) +function DF:GetFontSize(fontString) local _, size = fontString:GetFont() return size end -function DF:GetFontFace (fontString) +function DF:GetFontFace(fontString) local fontface = fontString:GetFont() return fontface end @@ -822,8 +828,9 @@ local ValidOutlines = { ["OUTLINE"] = true, ["THICKOUTLINE"] = true, } -function DF:SetFontOutline (fontString, outline) - local fonte, size = fontString:GetFont() + +function DF:SetFontOutline(fontString, outline) + local font, fontSize = fontString:GetFont() if (outline) then if (type(outline) == "string") then outline = outline:upper() @@ -831,27 +838,30 @@ function DF:SetFontOutline (fontString, outline) if (ValidOutlines[outline]) then outline = outline + elseif (type(outline) == "boolean" and outline) then outline = "OUTLINE" + elseif (type(outline) == "boolean" and not outline) then outline = "NONE" + elseif (outline == 1) then outline = "OUTLINE" + elseif (outline == 2) then outline = "THICKOUTLINE" end end - fontString:SetFont (fonte, size, outline) + fontString:SetFont(font, fontSize, outline) end -function DF:Trim (s) --hello name conventions! - return DF:trim (s) +function DF:Trim(string) + return DF:trim(string) end - -function DF:trim (s) - local from = s:match"^%s*()" - return from > #s and "" or s:match(".*%S", from) +function DF:trim(string) + local from = string:match"^%s*()" + return from > #string and "" or string:match(".*%S", from) end --truncated revoming at a maximum of 10 character from the string @@ -876,17 +886,17 @@ function DF:TruncateTextSafe(fontString, maxWidth) fontString:SetText(text) end -function DF:TruncateText (fontString, maxWidth) +function DF:TruncateText(fontString, maxWidth) local text = fontString:GetText() - + while (fontString:GetStringWidth() > maxWidth) do - text = strsub (text, 1, #text - 1) - fontString:SetText (text) - if (string.len (text) <= 1) then + text = strsub(text, 1, #text - 1) + fontString:SetText(text) + if (string.len(text) <= 1) then break end end - + text = DF:CleanTruncateUTF8String(text) fontString:SetText (text) end @@ -896,20 +906,26 @@ function DF:CleanTruncateUTF8String(text) local b1 = (#text > 0) and strbyte(strsub(text, #text, #text)) or nil local b2 = (#text > 1) and strbyte(strsub(text, #text-1, #text)) or nil local b3 = (#text > 2) and strbyte(strsub(text, #text-2, #text)) or nil + if b1 and b1 >= 194 and b1 <= 244 then text = strsub (text, 1, #text - 1) + elseif b2 and b2 >= 224 and b2 <= 244 then text = strsub (text, 1, #text - 2) + elseif b3 and b3 >= 240 and b3 <= 244 then text = strsub (text, 1, #text - 3) end end + return text end --DF:TruncateNumber(number, fractionDigits): truncate the amount of numbers used to show fraction. function DF:TruncateNumber(number, fractionDigits) fractionDigits = fractionDigits or 2 + local truncatedNumber = number + --local truncatedNumber = format("%." .. fractionDigits .. "f", number) --4x slower than: --http://lua-users.org/wiki/SimpleRound local mult = 10 ^ fractionDigits @@ -922,34 +938,30 @@ function DF:TruncateNumber(number, fractionDigits) return truncatedNumber end -function DF:Msg (msg, ...) - print ("|cFFFFFFAA" .. (self.__name or "FW Msg:") .. "|r ", msg, ...) -end - -function DF:GetNpcIdFromGuid (guid) - local NpcId = select ( 6, strsplit ( "-", guid ) ) - if (NpcId) then - return tonumber ( NpcId ) +function DF:GetNpcIdFromGuid(GUID) + local npcId = select(6, strsplit("-", GUID )) + if (npcId) then + return tonumber(npcId) end return 0 end -function DF.SortOrder1 (t1, t2) +function DF.SortOrder1(t1, t2) return t1[1] > t2[1] end -function DF.SortOrder2 (t1, t2) +function DF.SortOrder2(t1, t2) return t1[2] > t2[2] end -function DF.SortOrder3 (t1, t2) +function DF.SortOrder3(t1, t2) return t1[3] > t2[3] end -function DF.SortOrder1R (t1, t2) +function DF.SortOrder1R(t1, t2) return t1[1] < t2[1] end -function DF.SortOrder2R (t1, t2) +function DF.SortOrder2R(t1, t2) return t1[2] < t2[2] end -function DF.SortOrder3R (t1, t2) +function DF.SortOrder3R(t1, t2) return t1[3] < t2[3] end @@ -996,232 +1008,226 @@ function DF:GetSpellBookSpells() return spellNamesInSpellBook, spellIdsInSpellBook end ------------------------------- + +------------------------------------------------------------------------------------------------------------------------ --flash animation -local onFinish = function (self) +local onFinishFlashAnimation = function(self) if (self.showWhenDone) then - self.frame:SetAlpha (1) + self.frame:SetAlpha(1) else - self.frame:SetAlpha (0) + self.frame:SetAlpha(0) self.frame:Hide() end - + if (self.onFinishFunc) then - self:onFinishFunc (self.frame) + self:onFinishFunc(self.frame) end end -local stop = function (self) +local stopAnimation_Method = function(self) local FlashAnimation = self.FlashAnimation FlashAnimation:Stop() end -local flash = function (self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType) - - local FlashAnimation = self.FlashAnimation - - local fadeIn = FlashAnimation.fadeIn - local fadeOut = FlashAnimation.fadeOut - +local startFlash_Method = function(self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType) + local flashAnimation = self.FlashAnimation + + local fadeIn = flashAnimation.fadeIn + local fadeOut = flashAnimation.fadeOut + fadeIn:Stop() fadeOut:Stop() - fadeIn:SetDuration (fadeInTime or 1) - fadeIn:SetEndDelay (flashInHoldTime or 0) - - fadeOut:SetDuration (fadeOutTime or 1) - fadeOut:SetEndDelay (flashOutHoldTime or 0) + fadeIn:SetDuration(fadeInTime or 1) + fadeIn:SetEndDelay(flashInHoldTime or 0) + + fadeOut:SetDuration(fadeOutTime or 1) + fadeOut:SetEndDelay(flashOutHoldTime or 0) + + flashAnimation.duration = flashDuration + flashAnimation.loopTime = flashAnimation:GetDuration() + flashAnimation.finishAt = GetTime() + flashDuration + flashAnimation.showWhenDone = showWhenDone + + flashAnimation:SetLooping(loopType or "REPEAT") - FlashAnimation.duration = flashDuration - FlashAnimation.loopTime = FlashAnimation:GetDuration() - FlashAnimation.finishAt = GetTime() + flashDuration - FlashAnimation.showWhenDone = showWhenDone - - FlashAnimation:SetLooping (loopType or "REPEAT") - self:Show() - self:SetAlpha (0) - FlashAnimation:Play() + self:SetAlpha(0) + flashAnimation:Play() end -function DF:CreateFlashAnimation (frame, onFinishFunc, onLoopFunc) - local FlashAnimation = frame:CreateAnimationGroup() - - FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime - FlashAnimation.fadeOut:SetOrder (1) - FlashAnimation.fadeOut:SetFromAlpha (0) - FlashAnimation.fadeOut:SetToAlpha (1) - - FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime - FlashAnimation.fadeIn:SetOrder (2) - FlashAnimation.fadeIn:SetFromAlpha (1) - FlashAnimation.fadeIn:SetToAlpha (0) - - frame.FlashAnimation = FlashAnimation - FlashAnimation.frame = frame - FlashAnimation.onFinishFunc = onFinishFunc - - FlashAnimation:SetScript ("OnLoop", onLoopFunc) - FlashAnimation:SetScript ("OnFinished", onFinish) - - frame.Flash = flash - frame.Stop = stop +function DF:CreateFlashAnimation(frame, onFinishFunc, onLoopFunc) + local flashAnimation = frame:CreateAnimationGroup() + + flashAnimation.fadeOut = flashAnimation:CreateAnimation("Alpha") + flashAnimation.fadeOut:SetOrder(1) + flashAnimation.fadeOut:SetFromAlpha(0) + flashAnimation.fadeOut:SetToAlpha(1) + + flashAnimation.fadeIn = flashAnimation:CreateAnimation("Alpha") + flashAnimation.fadeIn:SetOrder(2) + flashAnimation.fadeIn:SetFromAlpha(1) + flashAnimation.fadeIn:SetToAlpha(0) + + frame.FlashAnimation = flashAnimation + flashAnimation.frame = frame + flashAnimation.onFinishFunc = onFinishFunc + + flashAnimation:SetScript("OnLoop", onLoopFunc) + flashAnimation:SetScript("OnFinished", onFinishFlashAnimation) + + frame.Flash = startFlash_Method + frame.Stop = stopAnimation_Method + + return flashAnimation end ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---> points +--anchoring - function DF:CheckPoints(v1, v2, v3, v4, v5, object) - if (not v1 and not v2) then + function DF:CheckPoints(point1, point2, point3, point4, point5, object) + if (not point1 and not point2) then return "topleft", object.widget:GetParent(), "topleft", 0, 0 end - if (type(v1) == "string") then - local frameGlobal = _G[v1] + if (type(point1) == "string") then + local frameGlobal = _G[point1] if (frameGlobal and type(frameGlobal) == "table" and frameGlobal.GetObjectType) then - return DF:CheckPoints(frameGlobal, v2, v3, v4, v5, object) + return DF:CheckPoints(frameGlobal, point2, point3, point4, point5, object) end - elseif (type(v2) == "string") then - local frameGlobal = _G[v2] + elseif (type(point2) == "string") then + local frameGlobal = _G[point2] if (frameGlobal and type(frameGlobal) == "table" and frameGlobal.GetObjectType) then - return DF:CheckPoints(v1, frameGlobal, v3, v4, v5, object) + return DF:CheckPoints(point1, frameGlobal, point3, point4, point5, 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 + if (type(point1) == "string" and type(point2) == "table") then --setpoint("left", frame, _, _, _) + if (not point3 or type(point3) == "number") then --setpoint("left", frame, 10, 10) + point1, point2, point3, point4, point5 = point1, point2, point1, point3, point4 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(point1) == "string" and type(point2) == "number") then --setpoint("topleft", x, y) + point1, point2, point3, point4, point5 = point1, object.widget:GetParent(), point1, point2, point3 - elseif (type(v1) == "number") then --setpoint(x, y) - v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2 + elseif (type(point1) == "number") then --setpoint(x, y) + point1, point2, point3, point4, point5 = "topleft", object.widget:GetParent(), "topleft", point1, point2 - elseif (type(v1) == "table") then --setpoint(frame, x, y) - v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3 + elseif (type(point1) == "table") then --setpoint(frame, x, y) + point1, point2, point3, point4, point5 = "topleft", point1, "topleft", point2, point3 end - if (not v2) then - v2 = object.widget:GetParent() - elseif (v2.dframework) then - v2 = v2.widget + if (not point2) then + point2 = object.widget:GetParent() + elseif (point2.dframework) then + point2 = point2.widget end - return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0 + return point1 or "topleft", point2, point3 or "topleft", point4 or 0, point5 or 0 end - - local anchoring_functions = { - function (frame, anchorTo, offSetX, offSetY) --> 1 TOP LEFT + + local anchoringFunctions = { + function(frame, anchorTo, offSetX, offSetY) --1 TOP LEFT frame:ClearAllPoints() - frame:SetPoint ("bottomleft", anchorTo, "topleft", offSetX, offSetY) + frame:SetPoint("bottomleft", anchorTo, "topleft", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 2 LEFT + + function(frame, anchorTo, offSetX, offSetY) --2 LEFT frame:ClearAllPoints() - frame:SetPoint ("right", anchorTo, "left", offSetX, offSetY) + frame:SetPoint("right", anchorTo, "left", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 3 BOTTOM LEFT + + function(frame, anchorTo, offSetX, offSetY) --3 BOTTOM LEFT frame:ClearAllPoints() - frame:SetPoint ("topleft", anchorTo, "bottomleft", offSetX, offSetY) + frame:SetPoint("topleft", anchorTo, "bottomleft", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 4 BOTTOM + + function(frame, anchorTo, offSetX, offSetY) --4 BOTTOM frame:ClearAllPoints() - frame:SetPoint ("top", anchorTo, "bottom", offSetX, offSetY) + frame:SetPoint("top", anchorTo, "bottom", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 5 BOTTOM RIGHT + + function(frame, anchorTo, offSetX, offSetY) --5 BOTTOM RIGHT frame:ClearAllPoints() - frame:SetPoint ("topright", anchorTo, "bottomright", offSetX, offSetY) + frame:SetPoint("topright", anchorTo, "bottomright", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 6 RIGHT + + function(frame, anchorTo, offSetX, offSetY) --6 RIGHT frame:ClearAllPoints() - frame:SetPoint ("left", anchorTo, "right", offSetX, offSetY) + frame:SetPoint("left", anchorTo, "right", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 7 TOP RIGHT + + function(frame, anchorTo, offSetX, offSetY) --7 TOP RIGHT frame:ClearAllPoints() - frame:SetPoint ("bottomright", anchorTo, "topright", offSetX, offSetY) + frame:SetPoint("bottomright", anchorTo, "topright", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 8 TOP + + function(frame, anchorTo, offSetX, offSetY) --8 TOP frame:ClearAllPoints() - frame:SetPoint ("bottom", anchorTo, "top", offSetX, offSetY) + frame:SetPoint("bottom", anchorTo, "top", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 9 CENTER + + function(frame, anchorTo, offSetX, offSetY) --9 CENTER frame:ClearAllPoints() - frame:SetPoint ("center", anchorTo, "center", offSetX, offSetY) + frame:SetPoint("center", anchorTo, "center", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 10 + + function(frame, anchorTo, offSetX, offSetY) --10 frame:ClearAllPoints() - frame:SetPoint ("left", anchorTo, "left", offSetX, offSetY) + frame:SetPoint("left", anchorTo, "left", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 11 + + function(frame, anchorTo, offSetX, offSetY) --11 frame:ClearAllPoints() - frame:SetPoint ("right", anchorTo, "right", offSetX, offSetY) + frame:SetPoint("right", anchorTo, "right", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 12 + + function(frame, anchorTo, offSetX, offSetY) --12 frame:ClearAllPoints() - frame:SetPoint ("top", anchorTo, "top", offSetX, offSetY) + frame:SetPoint("top", anchorTo, "top", offSetX, offSetY) end, - - function (frame, anchorTo, offSetX, offSetY) --> 13 + + function(frame, anchorTo, offSetX, offSetY) --13 frame:ClearAllPoints() - frame:SetPoint ("bottom", anchorTo, "bottom", offSetX, offSetY) + frame:SetPoint("bottom", anchorTo, "bottom", offSetX, offSetY) end } - function DF:SetAnchor (widget, config, anchorTo) + function DF:SetAnchor(widget, config, anchorTo) anchorTo = anchorTo or widget:GetParent() - anchoring_functions [config.side] (widget, anchorTo, config.x, config.y) - end + anchoringFunctions[config.side](widget, anchorTo, config.x, config.y) + end ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---> colors +--colors - function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha) - assert (type (_colorname) == "string", "NewColor: colorname must be a string.") - assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.") + --add a new color name, the color can be query using DetailsFramework:ParseColors(colorName) + function DF:NewColor(colorName, red, green, blue, alpha) + assert(type(colorName) == "string", "DetailsFramework:NewColor(): colorName must be a string.") + assert(not DF.alias_text_colors[colorName], "DetailsFramework:NewColor(): colorName already exists.") - if (type (_colortable) == "table") then - if (_colortable[1] and _colortable[2] and _colortable[3]) then - _colortable[4] = _colortable[4] or 1 - DF.alias_text_colors [_colorname] = _colortable - else - error ("invalid color table.") - end - elseif (_colortable and _green and _blue) then - _alpha = _alpha or 1 - DF.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha} - else - error ("invalid parameter.") - end - - return true + red, green, blue, alpha = DetailsFramework:ParseColors(red, green, blue, alpha) + local colorTable = DetailsFramework:FormatColor("table", red, green, blue, alpha) + + DF.alias_text_colors[colorName] = colorTable + + return colorTable end - + local colorTableMixin = { - GetColor = function (self) + GetColor = function(self) return self.r, self.g, self.b, self.a end, - - SetColor = function (self, r, g, b, a) - r, g, b, a = DF:ParseColors (r, g, b, a) + + SetColor = function(self, r, g, b, a) + r, g, b, a = DF:ParseColors(r, g, b, a) self.r = r or self.r self.g = g or self.g self.b = b or self.b self.a = a or self.a end, - + IsColorTable = true, } @@ -1255,22 +1261,22 @@ end end end - function DF:CreateColorTable (r, g, b, a) + function DF:CreateColorTable(r, g, b, a) local t = { - r = r or 1, - g = g or 1, - b = b or 1, + r = r or 1, + g = g or 1, + b = b or 1, a = a or 1, } - DF:Mixin (t, colorTableMixin) + DF:Mixin(t, colorTableMixin) return t end - function DF:IsHtmlColor (color) - return DF.alias_text_colors [color] + function DF:IsHtmlColor(color) + return DF.alias_text_colors[color] end - function DF:ParseColors (red, green, blue, alpha) + function DF:ParseColors(red, green, blue, alpha) local firstParameter = red --the first value passed is a table? @@ -1569,6 +1575,7 @@ end --dropdowns elseif (widgetTable.type == "select" or widgetTable.type == "dropdown") then + assert(widgetTable.get, "DetailsFramework:BuildMenu(): .get not found in the widget table for 'select'") local dropdown = getMenuWidgetVolative(parent, "dropdown", widgetIndexes) widgetCreated = dropdown @@ -1577,7 +1584,7 @@ end dropdown:Select(widgetTable.get()) dropdown:SetTemplate(dropdownTemplate) - dropdown.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId) + dropdown:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)) dropdown._get = widgetTable.get dropdown.widget_type = "select" @@ -1619,7 +1626,7 @@ end switch:SetTemplate(switchTemplate) switch:SetAsCheckBox() --it's always a checkbox on volatile menu - switch.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId) + switch:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)) switch._get = widgetTable.get switch.widget_type = "toggle" switch.OnSwitch = widgetTable.set @@ -1683,7 +1690,7 @@ end slider:SetTemplate(sliderTemplate) - slider.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId) + slider:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)) slider._get = widgetTable.get slider.widget_type = "range" slider:SetHook("OnValueChange", widgetTable.set) @@ -1729,7 +1736,7 @@ end colorpick:SetTemplate(buttonTemplate) colorpick:SetSize(18, 18) - colorpick.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId) + colorpick:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)) colorpick._get = widgetTable.get colorpick.widget_type = "color" @@ -1800,7 +1807,7 @@ end button:SetPoint(currentXOffset, currentYOffset) end - button.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId) + button:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)) button.widget_type = "execute" --hook list @@ -1835,7 +1842,7 @@ end textentry:SetTemplate(widgetTable.template or widgetTable.button_template or buttonTemplate) textentry:SetSize(widgetTable.width or 120, widgetTable.height or 18) - textentry.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId) + textentry:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)) textentry.text = widgetTable.get() textentry._get = widgetTable.get textentry.widget_type = "textentry" @@ -1962,7 +1969,7 @@ end if (widgetTable.namePhraseId) then DetailsFramework.Language.RegisterFontString(languageAddonId, label.widget, widgetTable.namePhraseId) else - local textToSet = widgetTable.get() or widgetTable.text or "" + local textToSet = (widgetTable.get and widgetTable.get()) or widgetTable.text or "" label:SetText(textToSet) end @@ -1977,14 +1984,17 @@ end end elseif (widgetTable.type == "select") then + assert(widgetTable.get, "DetailsFramework:BuildMenu(): .get not found in the widget table for 'select'") local dropdown = DF:NewDropDown(parent, nil, "$parentWidget" .. index, nil, 140, 18, widgetTable.values, widgetTable.get(), dropdownTemplate) - DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, dropdown, "tooltip", widgetTable.descPhraseId, widgetTable.desc) + DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, dropdown, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc) dropdown._get = widgetTable.get dropdown.widget_type = "select" - local label = DF:NewLabel(parent, nil, "$parentLabel" .. index, nil, widgetTable.name .. (useColon and ": " or ""), "GameFontNormal", widgetTable.text_template or textTemplate or 12) + local label = DF:NewLabel(parent, nil, "$parentLabel" .. index, nil, "", "GameFontNormal", widgetTable.text_template or textTemplate or 12) + DetailsFramework.Language.RegisterObjectWithDefault(languageAddonId, label.widget, widgetTable.namePhraseId, formatOptionNameWithColon(widgetTable.name, useColon)) + dropdown:SetPoint("left", label, "right", 2) label:SetPoint(currentXOffset, currentYOffset) dropdown.hasLabel = label @@ -2020,7 +2030,7 @@ end elseif (widgetTable.type == "toggle") then local switch = DF:NewSwitch(parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widgetTable.get(), nil, nil, nil, nil, switchTemplate) - DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, switch, "tooltip", widgetTable.descPhraseId, widgetTable.desc) + DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, switch, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc) switch._get = widgetTable.get switch.widget_type = "toggle" @@ -2084,10 +2094,11 @@ end amountLineWidgetCreated = amountLineWidgetCreated + 1 elseif (widgetTable.type == "range") then + assert(widgetTable.get, "DetailsFramework:BuildMenu(): .get not found in the widget table for 'range'") local isDecimanls = widgetTable.usedecimals local slider = DF:NewSlider(parent, nil, "$parentWidget" .. index, nil, 140, 20, widgetTable.min, widgetTable.max, widgetTable.step, widgetTable.get(), isDecimanls, nil, nil, sliderTemplate) - DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, slider, "tooltip", widgetTable.descPhraseId, widgetTable.desc) + DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, slider, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc) slider._get = widgetTable.get slider.widget_type = "range" @@ -2134,9 +2145,10 @@ end amountLineWidgetCreated = amountLineWidgetCreated + 1 elseif (widgetTable.type == "color") then + assert(widgetTable.get, "DetailsFramework:BuildMenu(): .get not found in the widget table for 'color'") local colorpick = DF:NewColorPickButton(parent, "$parentWidget" .. index, nil, widgetTable.set, nil, buttonTemplate) - DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, colorpick, "tooltip", widgetTable.descPhraseId, widgetTable.desc) + DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, colorpick, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc) colorpick._get = widgetTable.get colorpick.widget_type = "color" @@ -2206,7 +2218,7 @@ end button:SetPoint(currentXOffset, currentYOffset) end - DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, button, "tooltip", widgetTable.descPhraseId, widgetTable.desc) + DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, button, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc) button.widget_type = "execute" @@ -2248,7 +2260,7 @@ end elseif (widgetTable.type == "textentry") then local textentry = DF:CreateTextEntry(parent, widgetTable.func or widgetTable.set, 120, 18, nil, "$parentWidget" .. index, nil, buttonTemplate) - DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, textentry, "tooltip", widgetTable.descPhraseId, widgetTable.desc) + DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, textentry, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc) textentry.text = widgetTable.get() textentry._get = widgetTable.get diff --git a/Libs/DF/label.lua b/Libs/DF/label.lua index 40b94685..36e94fa4 100644 --- a/Libs/DF/label.lua +++ b/Libs/DF/label.lua @@ -12,7 +12,6 @@ do WidgetType = "label", SetHook = detailsFramework.SetHook, RunHooksForWidget = detailsFramework.RunHooksForWidget, - dversion = detailsFramework.dversion, } @@ -215,21 +214,22 @@ detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.SetPointMixin) end ------------------------------------------------------------------------------------------------------------ ---> methods +--methods ---text text + --text text function LabelMetaFunctions:SetTextTruncated(text, maxWidth) self.widget:SetText(text) detailsFramework:TruncateText(self.widget, maxWidth) end ---textcolor + --textcolor function LabelMetaFunctions:SetTextColor(r, g, b, a) r, g, b, a = detailsFramework:ParseColors(r, g, b, a) return self.label:SetTextColor(r, g, b, a) end ------------------------------------------------------------------------------------------------------------ +--template function LabelMetaFunctions:SetTemplate(template) if (template.size) then @@ -247,84 +247,83 @@ detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.SetPointMixin) end ------------------------------------------------------------------------------------------------------------ ---> object constructor -function detailsFramework:CreateLabel(parent, text, size, color, font, member, name, layer) - return detailsFramework:NewLabel(parent, nil, name, member, text, font, size, color, layer) -end +--object constructor -function detailsFramework:NewLabel(parent, container, name, member, text, font, size, color, layer) - if (not parent) then - return error("Details! Framework: parent not found.", 2) - end - if (not container) then - container = parent + function detailsFramework:CreateLabel(parent, text, size, color, font, member, name, layer) + return detailsFramework:NewLabel(parent, nil, name, member, text, font, size, color, layer) end - if (not name) then - name = "DetailsFrameworkLabelNumber" .. detailsFramework.LabelNameCounter - detailsFramework.LabelNameCounter = detailsFramework.LabelNameCounter + 1 - end + function detailsFramework:NewLabel(parent, container, name, member, text, font, size, color, layer) + if (not parent) then + return error("Details! Framework: parent not found.", 2) + end + if (not container) then + container = parent + end - if (name:find("$parent")) then - local parentName = detailsFramework.GetParentName(parent) - name = name:gsub("$parent", parentName) - end + if (not name) then + name = "DetailsFrameworkLabelNumber" .. detailsFramework.LabelNameCounter + detailsFramework.LabelNameCounter = detailsFramework.LabelNameCounter + 1 + end - local LabelObject = {type = "label", dframework = true} + if (name:find("$parent")) then + local parentName = detailsFramework.GetParentName(parent) + name = name:gsub("$parent", parentName) + end - if (member) then - parent[member] = LabelObject - end + local labelObject = {type = "label", dframework = true} - if (parent.dframework) then - parent = parent.widget - end + if (member) then + parent[member] = labelObject + end - if (container.dframework) then - container = container.widget - end + if (parent.dframework) then + parent = parent.widget + end - font = font == "" and "GameFontHighlightSmall" or font or "GameFontHighlightSmall" + if (container.dframework) then + container = container.widget + end - LabelObject.label = parent:CreateFontString(name, layer or "OVERLAY", font) - LabelObject.widget = LabelObject.label - LabelObject.label.MyObject = LabelObject + font = font == "" and "GameFontHighlightSmall" or font or "GameFontHighlightSmall" - if (not loadedAPILabelFunctions) then - loadedAPILabelFunctions = 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(...) + labelObject.label = parent:CreateFontString(name, layer or "OVERLAY", font) + labelObject.widget = labelObject.label + labelObject.label.MyObject = labelObject + + if (not loadedAPILabelFunctions) then + loadedAPILabelFunctions = 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 - end - LabelObject.label:SetText(text) + labelObject.label:SetText(text) + labelObject.label:SetJustifyH("left") - if (color) then - local r, g, b, a = detailsFramework:ParseColors(color) - LabelObject.label:SetTextColor(r, g, b, a) - end + if (color) then + local r, g, b, a = detailsFramework:ParseColors(color) + labelObject.label:SetTextColor(r, g, b, a) + end - if (size and type(size) == "number") then - detailsFramework:SetFontSize(LabelObject.label, size) - end + if (size and type(size) == "number") then + detailsFramework:SetFontSize(labelObject.label, size) + end - LabelObject.HookList = { - } + labelObject.HookList = {} - LabelObject.label:SetJustifyH("LEFT") + setmetatable(labelObject, LabelMetaFunctions) - setmetatable(LabelObject, LabelMetaFunctions) + --if template has been passed as the third parameter + if (size and type(size) == "table") then + labelObject:SetTemplate(size) + end - --if template has been passed as the third parameter - if (size and type(size) == "table") then - LabelObject:SetTemplate(size) - end - - return LabelObject -end + return labelObject + end \ No newline at end of file diff --git a/Libs/DF/mixins.lua b/Libs/DF/mixins.lua index c7362c85..9d2c69db 100644 --- a/Libs/DF/mixins.lua +++ b/Libs/DF/mixins.lua @@ -89,6 +89,47 @@ local doublePoint = { ["left-right"] = true, } +detailsFramework.FrameMixin = { + SetFrameStrata = function(self, strata) + if (type(strata) == "table" and strata.GetObjectType) then + local UIObject = strata + self.widget:SetFrameStrata(UIObject:GetFrameStrata()) + else + self.widget:SetFrameStrata(strata) + end + end, + + SetFrameLevel = function(self, level, UIObject) + if (not UIObject) then + return self.widget:SetFrameLevel(level) + else + local framelevel = UIObject:GetFrameLevel(UIObject) + level + return self.widget:SetFrameLevel(framelevel) + end + end, + + SetBackdrop = function(self, ...) + return self.widget:SetBackdrop(...) + end, + + SetBackdropColor = function(self, ...) + return self.widget:SetBackdropColor(...) + end, + + SetBackdropBorderColor = function(self, ...) + return self.widget:SetBackdropBorderColor(...) + end, + + SetSize = function(self, width, height) + if (width) then + self.widget:SetWidth(width) + end + if (height) then + return self.widget:SetHeight(height) + end + end +} + detailsFramework.SetPointMixin = { SetPoint = function(object, anchorName1, anchorObject, anchorName2, xOffset, yOffset) if (doublePoint[anchorName1]) then diff --git a/Libs/DF/picture.lua b/Libs/DF/picture.lua index 8980dda6..87e0906e 100644 --- a/Libs/DF/picture.lua +++ b/Libs/DF/picture.lua @@ -5,7 +5,6 @@ if (not detailsFramework or not DetailsFrameworkCanLoad) then end local _ -local loadstring = loadstring local APIImageFunctions = false do @@ -13,7 +12,6 @@ do WidgetType = "image", SetHook = detailsFramework.SetHook, RunHooksForWidget = detailsFramework.RunHooksForWidget, - dversion = detailsFramework.dversion, } @@ -116,12 +114,12 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin) --texture local smember_texture = function(object, value) if (type(value) == "table") then - local r, g, b, a = detailsFramework:ParseColors(value) - object.image:SetTexture(r, g, b, a or 1) + local red, green, blue, alpha = detailsFramework:ParseColors(value) + object.image:SetTexture(red, green, blue, alpha) else if (detailsFramework:IsHtmlColor(value)) then - local r, g, b, a = detailsFramework:ParseColors(value) - object.image:SetTexture(r, g, b, a or 1) + local red, green, blue, alpha = detailsFramework:ParseColors(value) + object.image:SetTexture(red, green, blue, alpha) else object.image:SetTexture(value) end @@ -145,14 +143,14 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin) --color local smember_color = function(object, value) - local r, g, b, a = detailsFramework:ParseColors(value) - object.image:SetColorTexture(r, g, b, a or 1) + local red, green, blue, alpha = detailsFramework:ParseColors(value) + object.image:SetColorTexture(red, green, blue, alpha) end --vertex color local smember_vertexcolor = function(object, value) - local r, g, b, a = detailsFramework:ParseColors(value) - object.image:SetVertexColor(r, g, b, a or 1) + local red, green, blue, alpha = detailsFramework:ParseColors(value) + object.image:SetVertexColor(red, green, blue, alpha) end --desaturated @@ -248,7 +246,7 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin) function detailsFramework:NewImage(parent, texture, width, height, layer, texCoord, member, name) if (not parent) then - return error("Details! FrameWork: parent not found.", 2) + return error("DetailsFrameWork: NewImage() parent not found.", 2) end if (not name) then @@ -273,7 +271,7 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin) texture = texture or "" - ImageObject.image = parent:CreateTexture(name, layer or "OVERLAY") + ImageObject.image = parent:CreateTexture(name, layer or "overlay") ImageObject.widget = ImageObject.image detailsFramework:Mixin(ImageObject.image, detailsFramework.WidgetFunctions) @@ -346,4 +344,4 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin) setmetatable(ImageObject, ImageMetaFunctions) return ImageObject - end + end \ No newline at end of file diff --git a/Libs/DF/scrollbar.lua b/Libs/DF/scrollbar.lua index 48477ecf..060d4b2d 100644 --- a/Libs/DF/scrollbar.lua +++ b/Libs/DF/scrollbar.lua @@ -1,235 +1,233 @@ -local DF = _G ["DetailsFramework"] +--note: this scroll bar is using legacy code and shouldn't be used on creating new stuff + +local DF = _G["DetailsFramework"] if (not DF or not DetailsFrameworkCanLoad) then - return + return end -function DF:CreateScrollBar (master, slave, x, y) - return DF:NewScrollBar (master, slave, x, y) +function DF:CreateScrollBar(master, scrollContainer, x, y) + return DF:NewScrollBar(master, scrollContainer, x, y) end -function DF:NewScrollBar (master, slave, x, y) +function DF:NewScrollBar(parent, scrollContainer, x, y) + local newSlider = CreateFrame("Slider", nil, parent, "BackdropTemplate") + newSlider.scrollMax = 560 - local new_slider = CreateFrame ("Slider", nil, master,"BackdropTemplate") - new_slider.scrollMax = 560 --default - tamanho da janela de fundo + newSlider:SetPoint("TOPLEFT", parent, "TOPRIGHT", x, y) + newSlider.ativo = true - -- ///// SLIDER ///// - new_slider:SetPoint ("TOPLEFT", master, "TOPRIGHT", x, y) - new_slider.ativo = true - - new_slider.bg = new_slider:CreateTexture (nil, "BACKGROUND") - new_slider.bg:SetAllPoints (true) - new_slider.bg:SetTexture (0, 0, 0, 0) - --coisinha do meio - new_slider.thumb = new_slider:CreateTexture (nil, "OVERLAY") - new_slider.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob") - new_slider.thumb:SetSize (29, 30) - new_slider:SetThumbTexture (new_slider.thumb) - - new_slider:SetOrientation ("VERTICAL") - new_slider:SetSize(16, 100) - new_slider:SetMinMaxValues(0, new_slider.scrollMax) - new_slider:SetValue(0) - new_slider.ultimo = 0 + newSlider.bg = newSlider:CreateTexture(nil, "BACKGROUND") + newSlider.bg:SetAllPoints(true) + newSlider.bg:SetTexture(0, 0, 0, 0) - local botao_cima = CreateFrame ("Button", nil, master,"BackdropTemplate") - - botao_cima:SetPoint ("BOTTOM", new_slider, "TOP", 0, -12) - botao_cima.x = 0 - botao_cima.y = -12 - - botao_cima:SetWidth (29) - botao_cima:SetHeight (32) - botao_cima:SetNormalTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Up") - botao_cima:SetPushedTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Down") - botao_cima:SetDisabledTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Disabled") - botao_cima:Show() - botao_cima:Disable() - - local botao_baixo = CreateFrame ("Button", nil, master,"BackdropTemplate") - botao_baixo:SetPoint ("TOP", new_slider, "BOTTOM", 0, 12) - botao_baixo.x = 0 - botao_baixo.y = 12 - - botao_baixo:SetWidth (29) - botao_baixo:SetHeight (32) - botao_baixo:SetNormalTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Up") - botao_baixo:SetPushedTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Down") - botao_baixo:SetDisabledTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Disabled") - botao_baixo:Show() - botao_baixo:Disable() + newSlider.thumb = newSlider:CreateTexture(nil, "OVERLAY") + newSlider.thumb:SetTexture("Interface\\Buttons\\UI-ScrollBar-Knob") + newSlider.thumb:SetSize(29, 30) + newSlider:SetThumbTexture(newSlider.thumb) + newSlider:SetOrientation("VERTICAL") + newSlider:SetSize(16, 100) + newSlider:SetMinMaxValues(0, newSlider.scrollMax) + newSlider:SetValue(0) + newSlider.ultimo = 0 - master.baixo = botao_baixo - master.cima = botao_cima - master.slider = new_slider - - botao_baixo:SetScript ("OnMouseDown", function(self) - if (not new_slider:IsEnabled()) then + local upButton = CreateFrame("Button", nil, parent,"BackdropTemplate") + + upButton:SetPoint("BOTTOM", newSlider, "TOP", 0, -12) + upButton.x = 0 + upButton.y = -12 + + upButton:SetWidth(29) + upButton:SetHeight(32) + upButton:SetNormalTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Up") + upButton:SetPushedTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Down") + upButton:SetDisabledTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Disabled") + upButton:Show() + upButton:Disable() + + local downDutton = CreateFrame("Button", nil, parent,"BackdropTemplate") + downDutton:SetPoint("TOP", newSlider, "BOTTOM", 0, 12) + downDutton.x = 0 + downDutton.y = 12 + + downDutton:SetWidth(29) + downDutton:SetHeight(32) + downDutton:SetNormalTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Up") + downDutton:SetPushedTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Down") + downDutton:SetDisabledTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Disabled") + downDutton:Show() + downDutton:Disable() + + parent.baixo = downDutton + parent.cima = upButton + parent.slider = newSlider + + downDutton:SetScript("OnMouseDown", function(self) + if (not newSlider:IsEnabled()) then return end - - local current = new_slider:GetValue() - local minValue, maxValue = new_slider:GetMinMaxValues() - if (current+5 < maxValue) then - new_slider:SetValue (current+5) + + local current = newSlider:GetValue() + local minValue, maxValue = newSlider:GetMinMaxValues() + if (current + 5 < maxValue) then + newSlider:SetValue(current + 5) else - new_slider:SetValue (maxValue) + newSlider:SetValue(maxValue) end self.precionado = true self.last_up = -0.3 - self:SetScript ("OnUpdate", function(self, elapsed) + self:SetScript("OnUpdate", function(self, elapsed) self.last_up = self.last_up + elapsed if (self.last_up > 0.03) then self.last_up = 0 - local current = new_slider:GetValue() - local minValue, maxValue = new_slider:GetMinMaxValues() - if (current+2 < maxValue) then - new_slider:SetValue (current+2) + local current = newSlider:GetValue() + local minValue, maxValue = newSlider:GetMinMaxValues() + if (current + 2 < maxValue) then + newSlider:SetValue(current + 2) else - new_slider:SetValue (maxValue) + newSlider:SetValue(maxValue) end end end) end) - botao_baixo:SetScript ("OnMouseUp", function(self) + + downDutton:SetScript("OnMouseUp", function(self) self.precionado = false - self:SetScript ("OnUpdate", nil) - end) - - botao_cima:SetScript ("OnMouseDown", function(self) - if (not new_slider:IsEnabled()) then + self:SetScript("OnUpdate", nil) + end) + + upButton:SetScript("OnMouseDown", function(self) + if (not newSlider:IsEnabled()) then return end - - local current = new_slider:GetValue() - if (current-5 > 0) then - new_slider:SetValue (current-5) + + local current = newSlider:GetValue() + if (current - 5 > 0) then + newSlider:SetValue(current - 5) else - new_slider:SetValue (0) - end + newSlider:SetValue(0) + end + self.precionado = true self.last_up = -0.3 - self:SetScript ("OnUpdate", function(self, elapsed) + self:SetScript("OnUpdate", function(self, elapsed) self.last_up = self.last_up + elapsed if (self.last_up > 0.03) then self.last_up = 0 - local current = new_slider:GetValue() - if (current-2 > 0) then - new_slider:SetValue (current-2) + local current = newSlider:GetValue() + if (current - 2 > 0) then + newSlider:SetValue(current - 2) else - new_slider:SetValue (0) + newSlider:SetValue(0) end end end) end) - botao_cima:SetScript ("OnMouseUp", function(self) + + upButton:SetScript("OnMouseUp", function(self) self.precionado = false - self:SetScript ("OnUpdate", nil) + self:SetScript("OnUpdate", nil) end) - --> isso aqui pra quando o slider ativar, o scroll fica na posi��o zero - botao_cima:SetScript ("OnEnable", function (self) - local current = new_slider:GetValue() + + upButton:SetScript("OnEnable", function(self) + local current = newSlider:GetValue() if (current == 0) then - botao_cima:Disable() + upButton:Disable() end end) - new_slider:SetScript ("OnValueChanged", function (self) + newSlider:SetScript("OnValueChanged", function(self) local current = self:GetValue() - master:SetVerticalScroll (current) - - local minValue, maxValue = new_slider:GetMinMaxValues() - + parent:SetVerticalScroll(current) + + local minValue, maxValue = newSlider:GetMinMaxValues() + if (current == minValue) then - botao_cima:Disable() - elseif (not botao_cima:IsEnabled()) then - botao_cima:Enable() + upButton:Disable() + elseif (not upButton:IsEnabled()) then + upButton:Enable() end - + if (current == maxValue) then - botao_baixo:Disable() - elseif (not botao_baixo:IsEnabled()) then - botao_baixo:Enable() + downDutton:Disable() + elseif (not downDutton:IsEnabled()) then + downDutton:Enable() end - end) - new_slider:SetScript ("OnShow", function (self) - botao_cima:Show() - botao_baixo:Show() + newSlider:SetScript("OnShow", function(self) + upButton:Show() + downDutton:Show() end) - - new_slider:SetScript ("OnDisable", function (self) - botao_cima:Disable() - botao_baixo:Disable() + + newSlider:SetScript("OnDisable", function(self) + upButton:Disable() + downDutton:Disable() end) - - new_slider:SetScript ("OnEnable", function (self) - botao_cima:Enable() - botao_baixo:Enable() + + newSlider:SetScript("OnEnable", function(self) + upButton:Enable() + downDutton:Enable() end) - - master:SetScript ("OnMouseWheel", function (self, delta) - if (not new_slider:IsEnabled()) then + + parent:SetScript("OnMouseWheel", function(self, delta) + if (not newSlider:IsEnabled()) then return end - local current = new_slider:GetValue() - if (delta < 0) then - --baixo - local minValue, maxValue = new_slider:GetMinMaxValues() - if (current + (master.wheel_jump or 20) < maxValue) then - new_slider:SetValue (current + (master.wheel_jump or 20)) + local current = newSlider:GetValue() + if (delta < 0) then + local minValue, maxValue = newSlider:GetMinMaxValues() + if (current + (parent.wheel_jump or 20) < maxValue) then + newSlider:SetValue(current + (parent.wheel_jump or 20)) else - new_slider:SetValue (maxValue) + newSlider:SetValue(maxValue) end elseif (delta > 0) then - --cima - if (current + (master.wheel_jump or 20) > 0) then - new_slider:SetValue (current - (master.wheel_jump or 20)) + if (current + (parent.wheel_jump or 20) > 0) then + newSlider:SetValue(current - (parent.wheel_jump or 20)) else - new_slider:SetValue (0) + newSlider:SetValue(0) end end end) - - function new_slider:Altura (h) - self:SetHeight (h) + + function newSlider:Altura(height) + self:SetHeight(height) end - - function new_slider:Update (desativar) - + + function newSlider:Update(desativar) if (desativar) then - new_slider:Disable() - new_slider:SetValue(0) - new_slider.ativo = false - master:EnableMouseWheel (false) + newSlider:Disable() + newSlider:SetValue(0) + newSlider.ativo = false + parent:EnableMouseWheel(false) return end - - self.scrollMax = slave:GetHeight()-master:GetHeight() + + self.scrollMax = scrollContainer:GetHeight() - parent:GetHeight() if (self.scrollMax > 0) then - new_slider:SetMinMaxValues (0, self.scrollMax) - if (not new_slider.ativo) then - new_slider:Enable() - new_slider.ativo = true - master:EnableMouseWheel (true) + newSlider:SetMinMaxValues(0, self.scrollMax) + if (not newSlider.ativo) then + newSlider:Enable() + newSlider.ativo = true + parent:EnableMouseWheel(true) end else - new_slider:Disable() - new_slider:SetValue(0) - new_slider.ativo = false - master:EnableMouseWheel (false) + newSlider:Disable() + newSlider:SetValue(0) + newSlider.ativo = false + parent:EnableMouseWheel(false) end end - - function new_slider:cimaPoint (x, y) - botao_cima:SetPoint ("BOTTOM", new_slider, "TOP", x, (y)-12) + + function newSlider:cimaPoint(x, y) + upButton:SetPoint("BOTTOM", newSlider, "TOP", x, y - 12) end - - function new_slider:baixoPoint (x, y) - botao_baixo:SetPoint ("TOP", new_slider, "BOTTOM", x, (y)+12) + + function newSlider:baixoPoint(x, y) + downDutton:SetPoint("TOP", newSlider, "BOTTOM", x, y + 12) end - - return new_slider + + return newSlider end diff --git a/Libs/DF/slider.lua b/Libs/DF/slider.lua index cdb1ec26..69cd4159 100644 --- a/Libs/DF/slider.lua +++ b/Libs/DF/slider.lua @@ -1,21 +1,10 @@ -local DF = _G ["DetailsFramework"] +local DF = _G["DetailsFramework"] if (not DF or not DetailsFrameworkCanLoad) then - return + return end local _ -local _rawset = rawset --> lua local -local _rawget = rawget --> lua local -local _setmetatable = setmetatable --> lua local -local _unpack = unpack --> lua local -local _type = type --> lua local -local _math_floor = math.floor --> lua local -local loadstring = loadstring --> lua local - -local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") - -local cleanfunction = function() end local APISliderFunctions = false do @@ -25,14 +14,13 @@ do HasHook = DF.HasHook, ClearHooks = DF.ClearHooks, RunHooksForWidget = DF.RunHooksForWidget, - dversion = DF.dversion } --check if there's a metaPrototype already existing if (_G[DF.GlobalWidgetControlNames["slider"]]) then --get the already existing metaPrototype - local oldMetaPrototype = _G[DF.GlobalWidgetControlNames ["slider"]] + local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["slider"]] --check if is older if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then --the version is older them the currently loading one @@ -43,281 +31,229 @@ do end else --first time loading the framework - _G[DF.GlobalWidgetControlNames ["slider"]] = metaPrototype + _G[DF.GlobalWidgetControlNames["slider"]] = metaPrototype end end -local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames ["slider"]] +local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames["slider"]] + +DF:Mixin(DFSliderMetaFunctions, DF.SetPointMixin) +DF:Mixin(DFSliderMetaFunctions, DF.FrameMixin) ------------------------------------------------------------------------------------------------------------ ---> metatables +--metatables - DFSliderMetaFunctions.__call = function (_table, value) + DFSliderMetaFunctions.__call = function(object, value) if (not value) then - if (_table.isSwitch) then - - if (type (value) == "boolean") then --> false - return _table.slider:SetValue (1) + if (object.isSwitch) then + if (type(value) == "boolean") then + object.slider:SetValue(1) + return end - - if (_table.slider:GetValue() == 1) then + + if (object.slider:GetValue() == 1) then return false else return true end end - return _table.slider:GetValue() + + return object.slider:GetValue() else - if (_table.isSwitch) then - if (type (value) == "boolean") then + if (object.isSwitch) then + if (type(value) == "boolean") then if (value) then - _table.slider:SetValue (2) + object.slider:SetValue(2) else - _table.slider:SetValue (1) + object.slider:SetValue(1) end else - _table.slider:SetValue (value) + object.slider:SetValue(value) end return end - - return _table.slider:SetValue (value) + + return object.slider:SetValue(value) end end ------------------------------------------------------------------------------------------------------------ ---> members +--members - --> tooltip - local gmember_tooltip = function (_object) - return _object:GetTooltip() + --tooltip + local gmember_tooltip = function(object) + return object:GetTooltip() end - --> shown - local gmember_shown = function (_object) - return _object:IsShown() + + --shown + local gmember_shown = function(object) + return object:IsShown() end - --> frame width - local gmember_width = function (_object) - return _object.slider:GetWidth() + + --frame width + local gmember_width = function(object) + return object.slider:GetWidth() end - --> frame height - local gmember_height = function (_object) - return _object.slider:GetHeight() + + --frame height + local gmember_height = function(object) + return object.slider:GetHeight() end - --> locked - local gmember_locked = function (_object) - return _rawget (_object, "lockdown") + + --locked + local gmember_locked = function(object) + return rawget(object, "lockdown") + end + + --fractional + local gmember_fractional = function(object) + return rawget(object, "useDecimals") + end + + --value + local gmember_value = function(object) + return object() end - --> fractional - local gmember_fractional = function (_object) - return _rawget (_object, "useDecimals") - end - --> value - local gmember_value = function (_object) - return _object() - end DFSliderMetaFunctions.GetMembers = DFSliderMetaFunctions.GetMembers or {} - DFSliderMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip - DFSliderMetaFunctions.GetMembers ["shown"] = gmember_shown - DFSliderMetaFunctions.GetMembers ["width"] = gmember_width - DFSliderMetaFunctions.GetMembers ["height"] = gmember_height - DFSliderMetaFunctions.GetMembers ["locked"] = gmember_locked - DFSliderMetaFunctions.GetMembers ["fractional"] = gmember_fractional - DFSliderMetaFunctions.GetMembers ["value"] = gmember_value + DFSliderMetaFunctions.GetMembers["tooltip"] = gmember_tooltip + DFSliderMetaFunctions.GetMembers["shown"] = gmember_shown + DFSliderMetaFunctions.GetMembers["width"] = gmember_width + DFSliderMetaFunctions.GetMembers["height"] = gmember_height + DFSliderMetaFunctions.GetMembers["locked"] = gmember_locked + DFSliderMetaFunctions.GetMembers["fractional"] = gmember_fractional + DFSliderMetaFunctions.GetMembers["value"] = gmember_value - DFSliderMetaFunctions.__index = function (_table, _member_requested) - - local func = DFSliderMetaFunctions.GetMembers [_member_requested] + DFSliderMetaFunctions.__index = function(object, key) + local func = DFSliderMetaFunctions.GetMembers[key] if (func) then - return func (_table, _member_requested) + return func(object, key) end - - local fromMe = _rawget (_table, _member_requested) + + local fromMe = rawget(object, key) if (fromMe) then return fromMe end - - return DFSliderMetaFunctions [_member_requested] + + return DFSliderMetaFunctions[key] end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - - --> tooltip - local smember_tooltip = function (_object, _value) - return _object:SetTooltip (_value) + + --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() + + --show + local smember_show = function(object, value) + if (value) then + return object:Show() else - return _object:Hide() + return object:Hide() end end - --> hide - local smember_hide = function (_object, _value) - if (not _value) then - return _object:Show() + + --hide + local smember_hide = function(object, value) + if (not value) then + return object:Show() else - return _object:Hide() + return object:Hide() end end - --> frame width - local smember_width = function (_object, _value) - return _object.slider:SetWidth (_value) + + --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) + + --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() + + --locked + local smember_locked = function(object, value) + if (value) then + return object:Disable() else - return self:Enable() + return object: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) + + --backdrop + local smember_backdrop = function(object, value) + return object.slider:SetBackdrop(value) end - --> value - local smember_value = function (_object, _value) - _object (_value) + + --fractional + local smember_fractional = function(object, value) + return rawset(object, "useDecimals", value) end - + + --value + local smember_value = function(object, value) + object(value) + end + DFSliderMetaFunctions.SetMembers = DFSliderMetaFunctions.SetMembers or {} - DFSliderMetaFunctions.SetMembers ["tooltip"] = smember_tooltip - DFSliderMetaFunctions.SetMembers ["show"] = smember_show - DFSliderMetaFunctions.SetMembers ["hide"] = smember_hide - DFSliderMetaFunctions.SetMembers ["backdrop"] = smember_backdrop - DFSliderMetaFunctions.SetMembers ["width"] = smember_width - DFSliderMetaFunctions.SetMembers ["height"] = smember_height - DFSliderMetaFunctions.SetMembers ["locked"] = smember_locked - DFSliderMetaFunctions.SetMembers ["fractional"] = smember_fractional - DFSliderMetaFunctions.SetMembers ["value"] = smember_value - - DFSliderMetaFunctions.__newindex = function (_table, _key, _value) - local func = DFSliderMetaFunctions.SetMembers [_key] + DFSliderMetaFunctions.SetMembers["tooltip"] = smember_tooltip + DFSliderMetaFunctions.SetMembers["show"] = smember_show + DFSliderMetaFunctions.SetMembers["hide"] = smember_hide + DFSliderMetaFunctions.SetMembers["backdrop"] = smember_backdrop + DFSliderMetaFunctions.SetMembers["width"] = smember_width + DFSliderMetaFunctions.SetMembers["height"] = smember_height + DFSliderMetaFunctions.SetMembers["locked"] = smember_locked + DFSliderMetaFunctions.SetMembers["fractional"] = smember_fractional + DFSliderMetaFunctions.SetMembers["value"] = smember_value + + DFSliderMetaFunctions.__newindex = function (object, key, value) + local func = DFSliderMetaFunctions.SetMembers[key] if (func) then - return func (_table, _value) + return func(object, value) else - return _rawset (_table, _key, _value) + return rawset(object, key, value) end - end - + end + ------------------------------------------------------------------------------------------------------------ ---> methods +--methods ---> show & hide - function DFSliderMetaFunctions:IsShown() - return self.slider:IsShown() - end - function DFSliderMetaFunctions:Show() - return self.slider:Show() - end - function DFSliderMetaFunctions:Hide() - return self.slider:Hide() - end - ---> fixed value - function DFSliderMetaFunctions:SetFixedParameter (value) - _rawset (self, "FixedValue", value) - end - ---> set value - function DFSliderMetaFunctions:SetValue (value) - return self (value) - end - --- thumb size - function DFSliderMetaFunctions: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 - - function DFSliderMetaFunctions:SetBackdrop(...) - return self.slider:SetBackdrop(...) + --fixed value + function DFSliderMetaFunctions:SetFixedParameter(value) + rawset(self, "FixedValue", value) end - function DFSliderMetaFunctions:SetBackdropColor(...) - return self.slider:SetBackdropColor(...) + --set value + function DFSliderMetaFunctions:SetValue(value) + return self(value) end - function DFSliderMetaFunctions:SetBackdropBorderColor(...) - return self.slider:SetBackdropBorderColor(...) + -- thumb size + function DFSliderMetaFunctions:SetThumbSize(width, height) + if (not width) then + width = self.thumb:GetWidth() + end + if (not height) then + height = self.thumb:GetHeight() + end + return self.thumb:SetSize(width, height) end - --- setpoint - function DFSliderMetaFunctions:SetPoint (v1, v2, v3, v4, v5) - v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self) - if (not v1) then - print ("Invalid parameter for SetPoint") - return - end - return self.widget:SetPoint (v1, v2, v3, v4, v5) - end - --- sizes - function DFSliderMetaFunctions:SetSize (w, h) - if (w) then - self.slider:SetWidth (w) - end - if (h) then - return self.slider:SetHeight (h) - end - end - --- tooltip - function DFSliderMetaFunctions:SetTooltip (tooltip) + --tooltip + function DFSliderMetaFunctions:SetTooltip(tooltip) if (tooltip) then - return _rawset (self, "have_tooltip", tooltip) + return rawset(self, "have_tooltip", tooltip) else - return _rawset (self, "have_tooltip", nil) + return rawset(self, "have_tooltip", nil) end end function DFSliderMetaFunctions:GetTooltip() - return _rawget (self, "have_tooltip") - end - --- frame levels - function DFSliderMetaFunctions:GetFrameLevel() - return self.slider:GetFrameLevel() - end - function DFSliderMetaFunctions: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 + return rawget(self, "have_tooltip") end --- frame stratas - function DFSliderMetaFunctions:SetFrameStrata() - return self.slider:GetFrameStrata() - end - function DFSliderMetaFunctions:SetFrameStrata (strata) - if (_type (strata) == "table") then - self.slider:SetFrameStrata (strata:GetFrameStrata()) - else - self.slider:SetFrameStrata (strata) - end - end - --- clear focus + --clear focus function DFSliderMetaFunctions:ClearFocus() local editbox = DFSliderMetaFunctions.editbox_typevalue if editbox and self.typing_value then @@ -327,33 +263,32 @@ local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames ["slider"]] editbox:GetParent().MyObject.value = self.typing_value_started end end - --- enabled + + --enabled function DFSliderMetaFunctions:IsEnabled() - return not _rawget (self, "lockdown") + return not rawget(self, "lockdown") end - + function DFSliderMetaFunctions:Enable() self.slider:Enable() if (not self.is_checkbox) then if (not self.lock_texture) then - DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture") - self.lock_texture:SetDesaturated (true) - self.lock_texture:SetPoint ("center", self.amt, "center") + DF:NewImage(self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture") + self.lock_texture:SetDesaturated(true) + self.lock_texture:SetPoint("center", self.amt, "center") end self.lock_texture:Hide() end self.slider.amt:Show() - self:SetAlpha (1) - + self:SetAlpha(1) + if (self.is_checkbox) then self.checked_texture:Show() end - return _rawset (self, "lockdown", false) + return rawset(self, "lockdown", false) end - + function DFSliderMetaFunctions:Disable() - self:ClearFocus() self.slider:Disable() self.slider.amt:Hide() @@ -362,26 +297,24 @@ local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames ["slider"]] if (not self.is_checkbox) then if (not self.lock_texture) then DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture") - self.lock_texture:SetDesaturated (true) - self.lock_texture:SetPoint ("center", self.amt, "center") + self.lock_texture:SetDesaturated(true) + self.lock_texture:SetPoint("center", self.amt, "center") end self.lock_texture:Show() end - + if (self.is_checkbox) then self.checked_texture:Show() end - - --print ("result 2:", self.checked_texture:IsShown(), self.checked_texture:GetAlpha(), self.checked_texture:GetSize()) - - return _rawset (self, "lockdown", true) + + return rawset(self, "lockdown", true) end ------------------------------------------------------------------------------------------------------------ --> scripts local OnEnter = function (slider) - if (_rawget (slider.MyObject, "lockdown")) then + if (rawget (slider.MyObject, "lockdown")) then return end @@ -413,7 +346,7 @@ local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames ["slider"]] local OnLeave = function (slider) - if (_rawget (slider.MyObject, "lockdown")) then + if (rawget (slider.MyObject, "lockdown")) then return end @@ -814,16 +747,16 @@ local SwitchOnClick = function (self, button, forced_value, value) local slider = self.MyObject - if (_rawget (slider, "lockdown")) then + if (rawget (slider, "lockdown")) then return end if (forced_value) then - _rawset (slider, "value", not value) + rawset (slider, "value", not value) end - if (_rawget (slider, "value")) then --actived - _rawset (slider, "value", false) + if (rawget (slider, "value")) then --actived + rawset (slider, "value", false) if (slider.backdrop_disabledcolor) then slider:SetBackdropColor (unpack (slider.backdrop_disabledcolor)) @@ -839,7 +772,7 @@ local SwitchOnClick = function (self, button, forced_value, value) slider._thumb:SetPoint ("left", slider.widget, "left") end else - _rawset (slider, "value", true) + rawset (slider, "value", true) if (slider.backdrop_enabledcolor) then slider:SetBackdropColor (unpack (slider.backdrop_enabledcolor)) else @@ -855,7 +788,7 @@ local SwitchOnClick = function (self, button, forced_value, value) end if (slider.OnSwitch and not forced_value) then - local value = _rawget (slider, "value") + local value = rawget (slider, "value") if (slider.return_func) then value = slider:return_func (value) end @@ -892,7 +825,7 @@ local switch_set_value = function (self, value) end local switch_set_fixparameter = function (self, value) - _rawset (self, "FixedValue", value) + rawset (self, "FixedValue", value) end local switch_disable = function (self) @@ -910,11 +843,11 @@ local switch_disable = function (self) end self:SetAlpha (.4) - _rawset (self, "lockdown", true) + rawset (self, "lockdown", true) end local switch_enable = function (self) if (self.is_checkbox) then - if (_rawget (self, "value")) then + if (rawget (self, "value")) then self.checked_texture:Show() else self.checked_texture:Hide() @@ -930,7 +863,7 @@ local switch_enable = function (self) end self:SetAlpha (1) - return _rawset (self, "lockdown", false) + return rawset (self, "lockdown", false) end local set_switch_func = function (self, newFunction) @@ -951,7 +884,7 @@ local set_as_checkbok = function (self) self.is_checkbox = true - if (_rawget (self, "value")) then + if (rawget (self, "value")) then self.checked_texture:Show() if (self.backdrop_enabledcolor) then self:SetBackdropColor (unpack (self.backdrop_enabledcolor)) @@ -1265,7 +1198,7 @@ function DF:NewSlider (parent, container, name, member, w, h, min, max, step, de SliderObject.slider:SetScript ("OnMouseDown", OnMouseDown) SliderObject.slider:SetScript ("OnMouseUp", OnMouseUp) - _setmetatable (SliderObject, DFSliderMetaFunctions) + setmetatable (SliderObject, DFSliderMetaFunctions) if (with_label) then local label = DF:CreateLabel (SliderObject.slider, with_label, nil, nil, nil, "label", nil, "overlay") @@ -1440,6 +1373,8 @@ local createAdjustmentSliderFrames = function(parent, options, name) DF:Mixin(adjustmentSlider, DF.OptionsFunctions) DF:Mixin(adjustmentSlider, DF.AdjustmentSliderFunctions) DF:Mixin(adjustmentSlider, DF.PayloadMixin) + DF:Mixin(adjustmentSlider, DF.SetPointMixin) + DF:Mixin(adjustmentSlider, DF.FrameMixin) adjustmentSlider:BuildOptionsTable(DF.AdjustmentSliderOptions, options) adjustmentSlider:SetSize(adjustmentSlider.options.width, adjustmentSlider.options.height) diff --git a/Libs/DF/textentry.lua b/Libs/DF/textentry.lua index 9b4ae9fa..1e1f4a88 100644 --- a/Libs/DF/textentry.lua +++ b/Libs/DF/textentry.lua @@ -37,12 +37,17 @@ do end local TextEntryMetaFunctions = _G[DF.GlobalWidgetControlNames["textentry"]] + +DF:Mixin(TextEntryMetaFunctions, DF.SetPointMixin) +DF:Mixin(TextEntryMetaFunctions, DF.FrameMixin) + + DF.TextEntryCounter = DF.TextEntryCounter or 1 ------------------------------------------------------------------------------------------------------------ --metatables - TextEntryMetaFunctions.__call = function(object, value) + TextEntryMetaFunctions.__call = function(object, value) end ------------------------------------------------------------------------------------------------------------ @@ -173,94 +178,32 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1 ------------------------------------------------------------------------------------------------------------ --methods + local cleanfunction = function()end function TextEntryMetaFunctions:SetEnterFunction(func, param1, param2) if (func) then - rawset (self, "func", func) + rawset(self, "func", func) else - rawset (self, "func", cleanfunction) + rawset(self, "func", cleanfunction) end if (param1 ~= nil) then - rawset (self, "param1", param1) + rawset(self, "param1", param1) end if (param2 ~= nil) then - rawset (self, "param2", param2) + rawset(self, "param2", param2) end end ---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 = DF: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 - + function TextEntryMetaFunctions:SetText(text) + self.editbox:SetText(text) end - - function TextEntryMetaFunctions:SetText (text) - self.editbox:SetText (text) - end + function TextEntryMetaFunctions:GetText() return self.editbox:GetText() 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 - function TextEntryMetaFunctions:SetBackdrop(...) - return self.editbox:SetBackdrop(...) - end - - function TextEntryMetaFunctions:SetBackdropColor(...) - return self.editbox:SetBackdropColor(...) - end - - function TextEntryMetaFunctions:SetBackdropBorderColor(...) - return self.editbox:SetBackdropBorderColor(...) - end - ---select all text + --select all text function TextEntryMetaFunctions:SelectAll() self.editbox:HighlightText() end @@ -268,51 +211,36 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1 function TextEntryMetaFunctions:SetAutoSelectTextOnFocus(value) self.autoSelectAllText = value end - ---set labal description - function TextEntryMetaFunctions:SetLabelText (text) - if (text) then - self.label:SetText (text) - else - self.label:SetText ("") - end - self:SetPoint (true) --> refresh + + --set label description + function TextEntryMetaFunctions:SetLabelText(text) + self.label:SetText(text) end ---> set tab order - function TextEntryMetaFunctions:SetNext (nextbox) + --set tab order + function TextEntryMetaFunctions:SetNext(nextbox) self.next = nextbox end - ---> blink + + --blink function TextEntryMetaFunctions:Blink() - self.label:SetTextColor (1, .2, .2, 1) - end - ---> show & hide - function TextEntryMetaFunctions:IsShown() - return self.editbox:IsShown() + self.label:SetTextColor(1, .2, .2, 1) end - function TextEntryMetaFunctions:Show() - return self.editbox:Show() - end - function TextEntryMetaFunctions:Hide() - return self.editbox:Hide() - end - --- tooltip - function TextEntryMetaFunctions:SetTooltip (tooltip) + + --tooltip + function TextEntryMetaFunctions:SetTooltip(tooltip) if (tooltip) then - return rawset (self, "have_tooltip", tooltip) + return rawset(self, "have_tooltip", tooltip) else - return rawset (self, "have_tooltip", nil) + return rawset(self, "have_tooltip", nil) end end + function TextEntryMetaFunctions:GetTooltip() - return rawget (self, "have_tooltip") + return rawget(self, "have_tooltip") end - ---> hooks + + --hooks function TextEntryMetaFunctions:Enable() if (not self.editbox:IsEnabled()) then self.editbox:Enable() @@ -325,7 +253,7 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1 end end end - + function TextEntryMetaFunctions:Disable() if (self.editbox:IsEnabled()) then self.enabled_border_color = {self.editbox:GetBackdropBorderColor()} @@ -334,12 +262,12 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1 self.editbox:Disable() - self.editbox:SetBackdropBorderColor (.5, .5, .5, .5) - self.editbox:SetBackdropColor (.5, .5, .5, .5) - self.editbox:SetTextColor (.5, .5, .5, .5) - + self.editbox:SetBackdropBorderColor(.5, .5, .5, .5) + self.editbox:SetBackdropColor(.5, .5, .5, .5) + self.editbox:SetTextColor(.5, .5, .5, .5) + if (self.editbox.borderframe) then - self.editbox.borderframe:SetBackdropColor (.5, .5, .5, .5) + self.editbox.borderframe:SetBackdropColor(.5, .5, .5, .5) end end end diff --git a/classes/class_utility.lua b/classes/class_utility.lua index a4c8c8f6..a4e60ff1 100644 --- a/classes/class_utility.lua +++ b/classes/class_utility.lua @@ -1,19 +1,16 @@ --lua locals local _cstr = string.format local _math_floor = math.floor -local _table_sort = table.sort local _table_insert = table.insert local _table_size = table.getn -local _setmetatable = setmetatable -local _getmetatable = getmetatable -local _ipairs = ipairs -local _pairs = pairs +local ipairs = ipairs +local pairs = pairs local _rawget= rawget -local _math_min = math.min +local min = math.min local _math_max = math.max local _math_abs = math.abs local _bit_band = bit.band -local _unpack = unpack +local unpack = unpack local _type = type --api locals local _GetSpellInfo = _detalhes.getspellinfo @@ -49,9 +46,7 @@ local container_damage_target = _detalhes.container_type.CONTAINER_DAMAGETARGET_ local container_playernpc = _detalhes.container_type.CONTAINER_PLAYERNPC local container_misc = _detalhes.container_type.CONTAINER_MISC_CLASS local container_misc_target = _detalhes.container_type.CONTAINER_ENERGYTARGET_CLASS ---local container_friendlyfire = _detalhes.container_type.CONTAINER_FRIENDLYFIRE ---local modo_ALONE = _detalhes.modos.alone local modo_GROUP = _detalhes.modos.group local modo_ALL = _detalhes.modos.all @@ -65,11 +60,11 @@ local div_fecha = _detalhes.divisores.fecha local div_lugar = _detalhes.divisores.colocacao local ToKFunctions = _detalhes.ToKFunctions -local SelectedToKFunction = ToKFunctions [1] +local SelectedToKFunction = ToKFunctions[1] local UsingCustomLeftText = false local UsingCustomRightText = false -local FormatTooltipNumber = ToKFunctions [8] +local FormatTooltipNumber = ToKFunctions[8] local TooltipMaximizedMethod = 1 local info = _detalhes.playerDetailWindow @@ -77,9 +72,10 @@ local keyName local headerColor = "yellow" -function _detalhes.SortIfHaveKey (table1, table2) +function _detalhes.SortIfHaveKey(table1, table2) if (table1[keyName] and table2[keyName]) then - return table1[keyName] > table2[keyName] + return table1[keyName] > table2[keyName] + elseif (table1[keyName] and not table2[keyName]) then return true else @@ -87,22 +83,27 @@ function _detalhes.SortIfHaveKey (table1, table2) end end -function _detalhes.SortGroupIfHaveKey (table1, table2) +function _detalhes.SortGroupIfHaveKey(table1, table2) if (table1.grupo and table2.grupo) then if (table1[keyName] and table2[keyName]) then - return table1[keyName] > table2[keyName] + return table1[keyName] > table2[keyName] + elseif (table1[keyName] and not table2[keyName]) then return true else return false end + elseif (table1.grupo and not table2.grupo) then return true + elseif (not table1.grupo and table2.grupo) then return false + else if (table1[keyName] and table2[keyName]) then - return table1[keyName] > table2[keyName] + return table1[keyName] > table2[keyName] + elseif (table1[keyName] and not table2[keyName]) then return true else @@ -111,40 +112,42 @@ function _detalhes.SortGroupIfHaveKey (table1, table2) end end -function _detalhes.SortGroupMisc (container, keyName2) +function _detalhes.SortGroupMisc(container, keyName2) keyName = keyName2 - return _table_sort (container, _detalhes.SortKeyGroupMisc) + return table.sort(container, _detalhes.SortKeyGroupMisc) end -function _detalhes.SortKeyGroupMisc (table1, table2) +function _detalhes.SortKeyGroupMisc(table1, table2) if (table1.grupo and table2.grupo) then - return table1 [keyName] > table2 [keyName] + return table1[keyName] > table2[keyName] + elseif (table1.grupo and not table2.grupo) then return true elseif (not table1.grupo and table2.grupo) then return false + else - return table1 [keyName] > table2 [keyName] + return table1[keyName] > table2[keyName] end end -function _detalhes.SortKeySimpleMisc (table1, table2) - return table1 [keyName] > table2 [keyName] +function _detalhes.SortKeySimpleMisc(table1, table2) + return table1[keyName] > table2[keyName] end -function _detalhes:ContainerSortMisc (container, amount, keyName2) +function _detalhes:ContainerSortMisc(container, amount, keyName2) keyName = keyName2 - _table_sort (container, _detalhes.SortKeySimpleMisc) - - if (amount) then - for i = amount, 1, -1 do --> de tr�s pra frente + table.sort(container, _detalhes.SortKeySimpleMisc) + + if (amount) then + for i = amount, 1, -1 do if (container[i][keyName] < 1) then amount = amount-1 else break end end - + return amount end end @@ -157,7 +160,7 @@ end --try to find a spell with the same name and get the amount of casts of that spell object if (not spell_cast and misc_actor.spell_cast) then local spellname = GetSpellInfo (spellId) - for casted_spellid, amount in _pairs (misc_actor.spell_cast) do + for casted_spellid, amount in pairs (misc_actor.spell_cast) do local casted_spellname = GetSpellInfo (casted_spellid) if (casted_spellname == spellname) then return amount, true @@ -173,16 +176,16 @@ end end end -function atributo_misc:NovaTabela (serial, nome, link) +function atributo_misc:NovaTabela(serial, nome, link) - local _new_miscActor = { + local newActor = { last_event = 0, - tipo = class_type, --> atributo 4 = misc - pets = {} --> pets? okey pets + tipo = class_type, + pets = {} } - _setmetatable (_new_miscActor, atributo_misc) - - return _new_miscActor + setmetatable(newActor, atributo_misc) + + return newActor end function atributo_misc:CreateBuffTargetObject() @@ -196,43 +199,42 @@ function atributo_misc:CreateBuffTargetObject() end local backgroundColor = {0, 0, 0, 1} -local backgroud_bar_damage = {value = 100, texture = [[Interface\AddOns\Details\images\bar_serenity]], color = {1, 0, 0, 0.1}} +local statusBarDamageBackgroundTable = {value = 100, texture = [[Interface\AddOns\Details\images\bar_serenity]], color = {1, 0, 0, 0.1}} function Details:ShowDeathTooltip(combatObject, deathTable) local events = deathTable[1] local timeOfDeath = deathTable[2] - local maxHP = deathTable[5] + local maxHP = max(deathTable[5], 0.001) local battleress = false local lastcooldown = false - local GameCooltip = GameCooltip + local gameCooltip = GameCooltip - GameCooltip:Reset() - GameCooltip:SetType ("tooltipbar") - GameCooltip:AddLine (Loc ["STRING_REPORT_LEFTCLICK"], nil, 1, _unpack (self.click_to_report_color)) - GameCooltip:AddIcon ([[Interface\TUTORIALFRAME\UI-TUTORIAL-FRAME]], 1, 1, 12, 16, 0.015625, 0.13671875, 0.4375, 0.59765625) - GameCooltip:AddStatusBar (0, 1, 1, 1, 1, 1, false, {value = 100, color = {.3, .3, .3, 1}, specialSpark = false, texture = [[Interface\AddOns\Details\images\bar_serenity]]}) + gameCooltip:Reset() + gameCooltip:SetType("tooltipbar") + + gameCooltip:AddLine(Loc ["STRING_REPORT_LEFTCLICK"], nil, 1, unpack(self.click_to_report_color)) + gameCooltip:AddIcon([[Interface\TUTORIALFRAME\UI-TUTORIAL-FRAME]], 1, 1, 12, 16, 0.015625, 0.13671875, 0.4375, 0.59765625) local barTypeColors = Details.death_log_colors --death parser - for i, event in _ipairs (events) do - + for i, event in ipairs(events) do local currentHP = event[5] - local hp = floor(currentHP / maxHP * 100) - if (hp > 100) then - hp = 100 + local healthPercent = floor(currentHP / maxHP * 100) + if (healthPercent > 100) then + healthPercent = 100 end - local evtype = event[1] + local evType = event[1] local spellName, _, spellIcon = _GetSpellInfo(event[2]) local amount = event[3] local time = event[4] local source = event[6] if (time + 12 > timeOfDeath) then - if (type (evtype) == "boolean") then + if (type (evType) == "boolean") then --is damage or heal? - if (evtype) then --bool true + if (evType) then --bool true --damage local overkill = event[10] or 0 local critical = event[11] and (" " .. TEXT_MODE_A_STRING_RESULT_CRITICAL) or "" -- (Critical) @@ -240,132 +242,132 @@ function Details:ShowDeathTooltip(combatObject, deathTable) local critOrCrush = critical .. crushing if (overkill > 0) then - --> deprecated as the parser now removes the overkill damage from total damage - --> this should now sum the overkill from [10] with the damage from [3] + --deprecated as the parser now removes the overkill damage from total damage + --this should now sum the overkill from [10] with the damage from [3] --check the type of overkill that should be shown --if show_totalhitdamage_on_overkill is true it'll show the total damage of the hit --if false it shows the total damage of the hit minus the overkill - --if (not _detalhes.show_totalhitdamage_on_overkill) then + --if (not Details.show_totalhitdamage_on_overkill) then -- amount = amount - overkill --end - overkill = " (" .. _detalhes:ToK(overkill) .. " |cFFFF8800overkill|r)" - GameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s |cFFFFFF00" .. spellName .. "|r (|cFFC6B0D9" .. source .. "|r)", "-" .. _detalhes:ToK(amount) .. critOrCrush .. overkill .. " (" .. hp .. "%)", 1, "white", "white") + overkill = " (" .. Details:ToK(overkill) .. " |cFFFF8800overkill|r)" + gameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s |cFFFFFF00" .. spellName .. "|r (|cFFC6B0D9" .. source .. "|r)", "-" .. Details:ToK(amount) .. critOrCrush .. overkill .. " (" .. healthPercent .. "%)", 1, "white", "white") else overkill = "" - GameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s " .. spellName .. " (|cFFC6B0D9" .. source .. "|r)", "-" .. _detalhes:ToK(amount) .. critOrCrush .. overkill .. " (" .. hp .. "%)", 1, "white", "white") + gameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s " .. spellName .. " (|cFFC6B0D9" .. source .. "|r)", "-" .. Details:ToK(amount) .. critOrCrush .. overkill .. " (" .. healthPercent .. "%)", 1, "white", "white") end - --iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B - - GameCooltip:AddIcon(spellIcon, nil, nil, nil, nil, .1, .9, .1, .9) + gameCooltip:AddIcon(spellIcon, nil, nil, nil, nil, .1, .9, .1, .9) if (event[9]) then --friendly fire - GameCooltip:AddStatusBar(hp, 1, barTypeColors.friendlyfire, true, backgroud_bar_damage) + gameCooltip:AddStatusBar(healthPercent, 1, barTypeColors.friendlyfire, true, statusBarDamageBackgroundTable) else --from a enemy - GameCooltip:AddStatusBar(hp, 1, barTypeColors.damage, true, backgroud_bar_damage) + gameCooltip:AddStatusBar(healthPercent, 1, barTypeColors.damage, true, statusBarDamageBackgroundTable) end else --heal - if (amount > _detalhes.deathlog_healingdone_min) then + if (amount > Details.deathlog_healingdone_min) then if (combatObject.is_arena) then - if (amount > _detalhes.deathlog_healingdone_min_arena) then - GameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s " .. spellName .. " (|cFFC6B0D9" .. source .. "|r)", "+" .. _detalhes:ToK(amount) .. " (" .. hp .. "%)", 1, "white", "white") - GameCooltip:AddIcon(spellIcon, nil, nil, nil, nil, .1, .9, .1, .9) - GameCooltip:AddStatusBar(hp, 1, barTypeColors.heal, true) + if (amount > Details.deathlog_healingdone_min_arena) then + gameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s " .. spellName .. " (|cFFC6B0D9" .. source .. "|r)", "+" .. Details:ToK(amount) .. " (" .. healthPercent .. "%)", 1, "white", "white") + gameCooltip:AddIcon(spellIcon, nil, nil, nil, nil, .1, .9, .1, .9) + gameCooltip:AddStatusBar(healthPercent, 1, barTypeColors.heal, true) end else - GameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s " .. spellName .. " (|cFFC6B0D9" .. source .. "|r)", "+" .. _detalhes:ToK(amount) .. " (" .. hp .. "%)", 1, "white", "white") - GameCooltip:AddIcon(spellIcon, nil, nil, nil, nil, .1, .9, .1, .9) - GameCooltip:AddStatusBar(hp, 1, barTypeColors.heal, true) + gameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s " .. spellName .. " (|cFFC6B0D9" .. source .. "|r)", "+" .. Details:ToK(amount) .. " (" .. healthPercent .. "%)", 1, "white", "white") + gameCooltip:AddIcon(spellIcon, nil, nil, nil, nil, .1, .9, .1, .9) + gameCooltip:AddStatusBar(healthPercent, 1, barTypeColors.heal, true) end end end - elseif (type (evtype) == "number") then - if (evtype == 1) then + elseif (type (evType) == "number") then + if (evType == 1) then --cooldown - GameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s " .. spellName .. " (" .. source .. ")", "cooldown (" .. hp .. "%)", 1, "white", "white") - GameCooltip:AddIcon(spellIcon, nil, nil, nil, nil, .1, .9, .1, .9) - GameCooltip:AddStatusBar(100, 1, barTypeColors.cooldown, true) + gameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s " .. spellName .. " (" .. source .. ")", "cooldown (" .. healthPercent .. "%)", 1, "white", "white") + gameCooltip:AddIcon(spellIcon, nil, nil, nil, nil, .1, .9, .1, .9) + gameCooltip:AddStatusBar(100, 1, barTypeColors.cooldown, true) - elseif (evtype == 2 and not battleress) then + elseif (evType == 2 and not battleress) then --battle ress battleress = event - elseif (evtype == 3) then + elseif (evType == 3) then --last cooldown used lastcooldown = event - elseif (evtype == 4) then + elseif (evType == 4) then --debuff - GameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s [x" .. amount .. "] " .. spellName .. " (" .. source .. ")", "debuff (" .. hp .. "%)", 1, "white", "white") - GameCooltip:AddIcon(spellIcon) - GameCooltip:AddStatusBar(100, 1, barTypeColors.debuff, true) + gameCooltip:AddLine("" .. format("%.1f", time - timeOfDeath) .. "s [x" .. amount .. "] " .. spellName .. " (" .. source .. ")", "debuff (" .. healthPercent .. "%)", 1, "white", "white") + gameCooltip:AddIcon(spellIcon) + gameCooltip:AddStatusBar(100, 1, barTypeColors.debuff, true) end end end end - GameCooltip:AddLine(deathTable[6] .. " " .. Loc["STRING_TIME_OF_DEATH"] , "-- -- -- ", 1, "white") - GameCooltip:AddIcon("Interface\\AddOns\\Details\\images\\small_icons", 1, 1, nil, nil, .75, 1, 0, 1) - GameCooltip:AddStatusBar(0, 1, .5, .5, .5, .5, false, {value = 100, color = {.5, .5, .5, 1}, specialSpark = false, texture = [[Interface\AddOns\Details\images\bar4_vidro]]}) + gameCooltip:AddLine(deathTable[6] .. " " .. Loc["STRING_TIME_OF_DEATH"] , "-- -- -- ", 1, "white") + gameCooltip:AddIcon("Interface\\AddOns\\Details\\images\\small_icons", 1, 1, nil, nil, .75, 1, 0, 1) + gameCooltip:AddStatusBar(0, 1, .5, .5, .5, .5, false, {value = 100, color = {.5, .5, .5, 1}, specialSpark = false, texture = [[Interface\AddOns\Details\images\bar4_vidro]]}) if (battleress) then - local spellName, _, spellIcon = _GetSpellInfo (battleress[2]) - GameCooltip:AddLine("+" .. format("%.1f", battleress[4] - timeOfDeath) .. "s " .. spellName .. " (" .. battleress[6] .. ")", "", 1, "white") - GameCooltip:AddIcon("Interface\\Glues\\CharacterSelect\\Glues-AddOn-Icons", 1, 1, nil, nil, .75, 1, 0, 1) - GameCooltip:AddStatusBar(0, 1, .5, .5, .5, .5, false, {value = 100, color = {.5, .5, .5, 1}, specialSpark = false, texture = [[Interface\AddOns\Details\images\bar4_vidro]]}) + local spellName, _, spellIcon = _GetSpellInfo(battleress[2]) + gameCooltip:AddLine("+" .. format("%.1f", battleress[4] - timeOfDeath) .. "s " .. spellName .. " (" .. battleress[6] .. ")", "", 1, "white") + gameCooltip:AddIcon("Interface\\Glues\\CharacterSelect\\Glues-AddOn-Icons", 1, 1, nil, nil, .75, 1, 0, 1) + gameCooltip:AddStatusBar(0, 1, .5, .5, .5, .5, false, {value = 100, color = {.5, .5, .5, 1}, specialSpark = false, texture = [[Interface\AddOns\Details\images\bar4_vidro]]}) end if (lastcooldown) then if (lastcooldown[3] == 1) then - local spellName, _, spellIcon = _GetSpellInfo (lastcooldown[2]) - GameCooltip:AddLine(format("%.1f", lastcooldown[4] - timeOfDeath) .. "s " .. spellName .. " (" .. Loc ["STRING_LAST_COOLDOWN"] .. ")") - GameCooltip:AddIcon(spellIcon) + local spellName, _, spellIcon = _GetSpellInfo(lastcooldown[2]) + gameCooltip:AddLine(format("%.1f", lastcooldown[4] - timeOfDeath) .. "s " .. spellName .. " (" .. Loc ["STRING_LAST_COOLDOWN"] .. ")") + gameCooltip:AddIcon(spellIcon) else - GameCooltip:AddLine(Loc ["STRING_NOLAST_COOLDOWN"]) - GameCooltip:AddIcon([[Interface\CHARACTERFRAME\UI-Player-PlayTimeUnhealthy]], 1, 1, 18, 18) + gameCooltip:AddLine(Loc ["STRING_NOLAST_COOLDOWN"]) + gameCooltip:AddIcon([[Interface\CHARACTERFRAME\UI-Player-PlayTimeUnhealthy]], 1, 1, 18, 18) end - GameCooltip:AddStatusBar(0, 1, 1, 1, 1, 1, false, {value = 100, color = {.3, .3, .3, 1}, specialSpark = false, texture = [[Interface\AddOns\Details\images\bar_serenity]]}) + gameCooltip:AddStatusBar(0, 1, 1, 1, 1, 1, false, {value = 100, color = {.3, .3, .3, 1}, specialSpark = false, texture = [[Interface\AddOns\Details\images\bar_serenity]]}) end - GameCooltip:SetOption("StatusBarHeightMod", -6) - GameCooltip:SetOption("FixedWidth", (type(_detalhes.death_tooltip_width) == "number" and _detalhes.death_tooltip_width) or 300) + --set the font and size of the text as defined in the options panel + gameCooltip:SetOption("TextSize", Details.tooltip.fontsize) + gameCooltip:SetOption("TextFont", Details.tooltip.fontface) - GameCooltip:SetOption("TextSize", _detalhes.tooltip.fontsize) - GameCooltip:SetOption("TextFont", _detalhes.tooltip.fontface) + --move the left and right texts more close to the tooltip border + gameCooltip:SetOption("LeftPadding", -4) + gameCooltip:SetOption("RightPadding", 7) - GameCooltip:SetOption("LeftBorderSize", -4) - GameCooltip:SetOption("RightBorderSize", 5) - GameCooltip:SetOption("StatusBarTexture", [[Interface\AddOns\Details\images\bar4_reverse]]) - GameCooltip:SetOption("StatusBarTexture", [[Interface\AddOns\Details\images\BantoBar]]) - GameCooltip:SetWallpaper(1, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0.64453125, 0}, {.8, .8, .8, 0.2}, true) + --space between each line, positive values make the lines be closer + gameCooltip:SetOption("LinePadding", -2) - GameCooltip:SetBackdrop(1, _detalhes.tooltip_backdrop, backgroundColor, _detalhes.tooltip_border_color) + --move each line in the Y axis (vertical offsett) + gameCooltip:SetOption("LineYOffset", 0) + + gameCooltip:SetOption("FixedWidth", (type(_detalhes.death_tooltip_width) == "number" and _detalhes.death_tooltip_width) or 300) end -function _detalhes:ToolTipDead (instancia, morte, esta_barra) - local GameCooltip = GameCooltip +function Details:ToolTipDead(instance, deathTable, barFrame) + local gameCooltip = GameCooltip - Details:ShowDeathTooltip(instancia:GetShowingCombat(), morte) + Details:ShowDeathTooltip(instance:GetShowingCombat(), deathTable) - local myPoint = _detalhes.tooltip.anchor_point - local anchorPoint = _detalhes.tooltip.anchor_relative - local x_Offset = _detalhes.tooltip.anchor_offset[1] - local y_Offset = _detalhes.tooltip.anchor_offset[2] + local myPoint = Details.tooltip.anchor_point + local anchorPoint = Details.tooltip.anchor_relative + local xOffset = Details.tooltip.anchor_offset[1] + local yOffset = Details.tooltip.anchor_offset[2] - if (_detalhes.tooltip.anchored_to == 1) then - GameCooltip:SetHost (esta_barra, myPoint, anchorPoint, x_Offset, y_Offset) + if (Details.tooltip.anchored_to == 1) then + gameCooltip:SetHost(barFrame, myPoint, anchorPoint, xOffset, yOffset) else - GameCooltip:SetHost (DetailsTooltipAnchor, myPoint, anchorPoint, x_Offset, y_Offset) + gameCooltip:SetHost(DetailsTooltipAnchor, myPoint, anchorPoint, xOffset, yOffset) end - GameCooltip:ShowCooltip() + gameCooltip:ShowCooltip() end local function RefreshBarraMorte (morte, barra, instancia) @@ -382,7 +384,7 @@ local ReportSingleDeathFunc = function (IsCurrent, IsReverse, AmtLines) AmtLines = AmtLines + 1 local t = {} - for i = 1, _math_min (#report_table, AmtLines) do + for i = 1, min (#report_table, AmtLines) do local table = report_table [i] t [#t+1] = table [1] .. table [4] .. table [2] .. table [3] end @@ -420,7 +422,7 @@ function atributo_misc:ReportSingleDeadLine (morte, instancia) local report_array = report_table report_array[1] = {"Details! " .. Loc ["STRING_REPORT_SINGLE_DEATH"] .. " " .. morte [3] .. " " .. Loc ["STRING_ACTORFRAME_REPORTAT"] .. " " .. morte [6], "", "", ""} - for index, evento in _ipairs (_detalhes.table.reverse (morte [1])) do + for index, evento in ipairs (_detalhes.table.reverse (morte [1])) do if (evento [1] and type (evento [1]) == "boolean") then --> damage if (evento [3]) then local elapsed = _cstr ("%.1f", evento [4] - time_of_death) .."s" @@ -500,17 +502,17 @@ function atributo_misc:ReportSingleCooldownLine (misc_actor, instancia) local cooldowns = misc_actor.cooldowns_defensive_spells._ActorTable local cooldowns_used = {} - for spellid, spell in _pairs (cooldowns) do + for spellid, spell in pairs (cooldowns) do cooldowns_used [#cooldowns_used+1] = {spellid, spell.counter, spell} end - _table_sort (cooldowns_used, _detalhes.Sort2) + table.sort (cooldowns_used, _detalhes.Sort2) - for i, spell in _ipairs (cooldowns_used) do + for i, spell in ipairs (cooldowns_used) do local spelllink = GetSpellLink (spell [1]) reportar [#reportar+1] = spelllink .. ": " .. spell [2] - for target_name, amount in _pairs (spell[3].targets) do + for target_name, amount in pairs (spell[3].targets) do if (target_name ~= misc_actor.nome and target_name ~= Loc ["STRING_RAID_WIDE"] and amount > 0) then reportar [#reportar+1] = " -" .. target_name .. ": " .. amount end @@ -542,14 +544,14 @@ function atributo_misc:ReportSingleBuffUptimeLine (misc_actor, instance) local buffs = {} local combat_time = instance.showing:GetCombatTime() - for spellid, spell in _pairs (misc_actor.buff_uptime_spells._ActorTable) do + for spellid, spell in pairs (misc_actor.buff_uptime_spells._ActorTable) do local percent = spell.uptime / combat_time * 100 if (percent < 99.5) then buffs [#buffs+1] = {spellid, {spell.uptime, percent}} end end - _table_sort (buffs, sort_buff_report) + table.sort (buffs, sort_buff_report) _detalhes:FormatReportLines (report_table, buffs, buff_format_name, buff_format_amount) return _detalhes:Reportar (report_table, {_no_current = true, _no_inverse = true, _custom = true}) end @@ -560,12 +562,12 @@ function atributo_misc:ReportSingleDebuffUptimeLine (misc_actor, instance) local debuffs = {} local combat_time = instance.showing:GetCombatTime() - for spellid, spell in _pairs (misc_actor.debuff_uptime_spells._ActorTable) do + for spellid, spell in pairs (misc_actor.debuff_uptime_spells._ActorTable) do local percent = spell.uptime / combat_time * 100 debuffs [#debuffs+1] = {spellid, {spell.uptime, percent}} end - _table_sort (debuffs, sort_buff_report) + table.sort (debuffs, sort_buff_report) _detalhes:FormatReportLines (report_table, debuffs, buff_format_name, buff_format_amount) return _detalhes:Reportar (report_table, {_no_current = true, _no_inverse = true, _custom = true}) @@ -589,8 +591,8 @@ function atributo_misc:DeadAtualizarBarra (morte, whichRowLine, colocacao, insta morte.minha_barra = whichRowLine esta_barra.colocacao = colocacao - if (not _getmetatable (morte)) then - _setmetatable (morte, {__call = RefreshBarraMorte}) + if (not getmetatable (morte)) then + setmetatable (morte, {__call = RefreshBarraMorte}) morte._custom = true end @@ -605,7 +607,7 @@ function atributo_misc:DeadAtualizarBarra (morte, whichRowLine, colocacao, insta end --> seta a cor da barra e a cor do texto caso eles esteja mostrando com a cor da classe - local r, g, b, a = _unpack (_detalhes.class_colors [morte[4]]) + local r, g, b, a = unpack (_detalhes.class_colors [morte[4]]) _detalhes:SetBarColors (esta_barra, instancia, r, g, b, a) if (instancia.row_info.use_spec_icons) then @@ -613,11 +615,11 @@ function atributo_misc:DeadAtualizarBarra (morte, whichRowLine, colocacao, insta local spec = instancia.showing (1, nome) and instancia.showing (1, nome).spec or (instancia.showing (2, nome) and instancia.showing (2, nome).spec) if (spec and spec ~= 0) then esta_barra.icone_classe:SetTexture (instancia.row_info.spec_file) - esta_barra.icone_classe:SetTexCoord (_unpack (_detalhes.class_specs_coords[spec])) + esta_barra.icone_classe:SetTexCoord (unpack (_detalhes.class_specs_coords[spec])) else if (CLASS_ICON_TCOORDS [morte[4]]) then esta_barra.icone_classe:SetTexture (instancia.row_info.icon_file) - esta_barra.icone_classe:SetTexCoord (_unpack (CLASS_ICON_TCOORDS [morte[4]])) + esta_barra.icone_classe:SetTexCoord (unpack (CLASS_ICON_TCOORDS [morte[4]])) else local texture, l, r, t, b = Details:GetUnknownClassIcon() esta_barra.icone_classe:SetTexture(texture) @@ -627,7 +629,7 @@ function atributo_misc:DeadAtualizarBarra (morte, whichRowLine, colocacao, insta else if (CLASS_ICON_TCOORDS [morte[4]]) then esta_barra.icone_classe:SetTexture (instancia.row_info.icon_file) - esta_barra.icone_classe:SetTexCoord (_unpack (CLASS_ICON_TCOORDS [morte[4]])) + esta_barra.icone_classe:SetTexCoord (unpack (CLASS_ICON_TCOORDS [morte[4]])) else local texture, l, r, t, b = Details:GetUnknownClassIcon() esta_barra.icone_classe:SetTexture(texture) @@ -714,8 +716,6 @@ function atributo_misc:RefreshWindow (instancia, tabela_do_combate, forcar, expo if (keyName == "dead") then local mortes = tabela_do_combate.last_events_tables - --> n�o precisa reordenar, uma vez que sempre vai da na ordem do �ltimo a morrer at� o primeiro - -- _table_sort (mortes, function (m1, m2) return m1[2] < m2[2] end) -- [1] = tabela com a morte [2] = tempo [3] = nome do jogador instancia.top = 1 total = #mortes @@ -749,7 +749,7 @@ function atributo_misc:RefreshWindow (instancia, tabela_do_combate, forcar, expo if (instancia.atributo == 5) then --> custom --> faz o sort da categoria e retorna o amount corrigido - _table_sort (conteudo, _detalhes.SortIfHaveKey) + table.sort (conteudo, _detalhes.SortIfHaveKey) --> n�o mostrar resultados com zero for i = amount, 1, -1 do --> de tr�s pra frente @@ -768,7 +768,7 @@ function atributo_misc:RefreshWindow (instancia, tabela_do_combate, forcar, expo elseif (modo == modo_ALL) then --> mostrando ALL - _table_sort (conteudo, _detalhes.SortIfHaveKey) + table.sort (conteudo, _detalhes.SortIfHaveKey) --> n�o mostrar resultados com zero for i = amount, 1, -1 do --> de tr�s pra frente @@ -788,9 +788,9 @@ function atributo_misc:RefreshWindow (instancia, tabela_do_combate, forcar, expo elseif (modo == modo_GROUP) then --> mostrando GROUP --if (refresh_needed) then - _table_sort (conteudo, _detalhes.SortGroupIfHaveKey) + table.sort (conteudo, _detalhes.SortGroupIfHaveKey) --end - for index, player in _ipairs (conteudo) do + for index, player in ipairs (conteudo) do if (player.grupo) then --> � um player e esta em grupo if (not player[keyName] or player[keyName] < 1) then --> dano menor que 1, interromper o loop amount = index - 1 @@ -862,7 +862,7 @@ function atributo_misc:RefreshWindow (instancia, tabela_do_combate, forcar, expo if (instancia.atributo == 5) then --> custom --> zerar o .custom dos_ Actors - for index, player in _ipairs (conteudo) do + for index, player in ipairs (conteudo) do if (player.custom > 0) then player.custom = 0 else @@ -1034,29 +1034,34 @@ end --------------------------------------------- // TOOLTIPS // --------------------------------------------- - ----------> TOOLTIPS BIFURCA��O ~tooltip -function atributo_misc:ToolTip (instancia, numero, barra, keydown) - --> seria possivel aqui colocar o icone da classe dele? +--~tooltips +function atributo_misc:ToolTip(instance, numero, barFrame, keydown) GameTooltip:ClearLines() - GameTooltip:AddLine (barra.colocacao..". "..self.nome) - - if (instancia.sub_atributo == 3) then --> interrupt - return self:ToolTipInterrupt (instancia, numero, barra, keydown) - elseif (instancia.sub_atributo == 1) then --> cc_break - return self:ToolTipCC (instancia, numero, barra, keydown) - elseif (instancia.sub_atributo == 2) then --> ress - return self:ToolTipRess (instancia, numero, barra, keydown) - elseif (instancia.sub_atributo == 4) then --> dispell - return self:ToolTipDispell (instancia, numero, barra, keydown) - elseif (instancia.sub_atributo == 5) then --> mortes - return self:ToolTipDead (instancia, numero, barra, keydown) - elseif (instancia.sub_atributo == 6) then --> defensive cooldowns - return self:ToolTipDefensiveCooldowns (instancia, numero, barra, keydown) - elseif (instancia.sub_atributo == 7) then --> buff uptime - return self:ToolTipBuffUptime (instancia, numero, barra, keydown) - elseif (instancia.sub_atributo == 8) then --> debuff uptime - return self:ToolTipDebuffUptime (instancia, numero, barra, keydown) + GameTooltip:AddLine(barFrame.colocacao .. ". " .. self.nome) + + if (instance.sub_atributo == 3) then --interrupt + return self:ToolTipInterrupt(instance, numero, barFrame, keydown) + + elseif (instance.sub_atributo == 1) then --cc_break + return self:ToolTipCC(instance, numero, barFrame, keydown) + + elseif (instance.sub_atributo == 2) then --ress + return self:ToolTipRess(instance, numero, barFrame, keydown) + + elseif (instance.sub_atributo == 4) then --dispell + return self:ToolTipDispell(instance, numero, barFrame, keydown) + + elseif (instance.sub_atributo == 5) then --mortes + return self:ToolTipDead(instance, numero, barFrame, keydown) + + elseif (instance.sub_atributo == 6) then --defensive cooldowns + return self:ToolTipDefensiveCooldowns(instance, numero, barFrame, keydown) + + elseif (instance.sub_atributo == 7) then --buff uptime + return self:ToolTipBuffUptime(instance, barFrame) + + elseif (instance.sub_atributo == 8) then --debuff uptime + return self:ToolTipDebuffUptime(instance, numero, barFrame, keydown) end end @@ -1064,10 +1069,10 @@ end local r, g, b local barAlha = .6 -function atributo_misc:ToolTipDead (instancia, numero, barra) - +function atributo_misc:ToolTipDead(instancia, numero, barra) + --is this even called? local last_dead = self.dead_log [#self.dead_log] - + Details:Msg("utility class called ToolTipDead, a deprecated function.") end function atributo_misc:ToolTipCC (instancia, numero, barra) @@ -1088,7 +1093,7 @@ function atributo_misc:ToolTipCC (instancia, numero, barra) local lineHeight = _detalhes.tooltip.line_height local icon_border = _detalhes.tooltip.icon_border_texcoord - for _spellid, _tabela in _pairs (habilidades) do + for _spellid, _tabela in pairs (habilidades) do --> quantidade local nome_magia, _, icone_magia = _GetSpellInfo (_spellid) @@ -1098,7 +1103,7 @@ function atributo_misc:ToolTipCC (instancia, numero, barra) --> o que quebrou local quebrou_oque = _tabela.cc_break_oque - for spellid_quebrada, amt_quebrada in _pairs (_tabela.cc_break_oque) do + for spellid_quebrada, amt_quebrada in pairs (_tabela.cc_break_oque) do local nome_magia, _, icone_magia = _GetSpellInfo (spellid_quebrada) GameCooltip:AddLine (nome_magia, amt_quebrada .. " ") GameCooltip:AddIcon ([[Interface\Buttons\UI-GroupLoot-Pass-Down]], nil, 1, 14, 14) @@ -1107,7 +1112,7 @@ function atributo_misc:ToolTipCC (instancia, numero, barra) end --> em quem quebrou - for target_name, amount in _pairs (_tabela.targets) do + for target_name, amount in pairs (_tabela.targets) do GameCooltip:AddLine (target_name .. ": ", amount .. " ") local classe = _detalhes:GetClass (target_name) @@ -1140,14 +1145,14 @@ function atributo_misc:ToolTipDispell (instancia, numero, barra) --> habilidade usada para dispelar local meus_dispells = {} - for _spellid, _tabela in _pairs (habilidades) do + for _spellid, _tabela in pairs (habilidades) do if (_tabela.dispell) then meus_dispells [#meus_dispells+1] = {_spellid, _math_floor (_tabela.dispell)} --_math_floor valor é nil, uma magia na tabela de dispel, sem dispel? else Details:Msg("D! table.dispell is invalid. spellId:", _spellid) end end - _table_sort (meus_dispells, _detalhes.Sort2) + table.sort (meus_dispells, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_SPELLS"], headerColor, #meus_dispells, [[Interface\ICONS\Spell_Arcane_ArcaneTorrent]], 0.078125, 0.9375, 0.078125, 0.953125) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) @@ -1156,7 +1161,7 @@ function atributo_misc:ToolTipDispell (instancia, numero, barra) local icon_border = _detalhes.tooltip.icon_border_texcoord if (#meus_dispells > 0) then - for i = 1, _math_min (25, #meus_dispells) do + for i = 1, min (25, #meus_dispells) do local esta_habilidade = meus_dispells[i] local nome_magia, _, icone_magia = _GetSpellInfo (esta_habilidade[1]) GameCooltip:AddLine (nome_magia, esta_habilidade[2].." (".._cstr("%.1f", esta_habilidade[2]/meu_total*100).."%)") @@ -1169,16 +1174,16 @@ function atributo_misc:ToolTipDispell (instancia, numero, barra) --> quais habilidades foram dispaladas local buffs_dispelados = {} - for _spellid, amt in _pairs (self.dispell_oque) do + for _spellid, amt in pairs (self.dispell_oque) do buffs_dispelados [#buffs_dispelados+1] = {_spellid, amt} end - _table_sort (buffs_dispelados, _detalhes.Sort2) + table.sort (buffs_dispelados, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_DISPELLED"], headerColor, #buffs_dispelados, [[Interface\ICONS\Spell_Arcane_ManaTap]], 0.078125, 0.9375, 0.078125, 0.953125) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) if (#buffs_dispelados > 0) then - for i = 1, _math_min (25, #buffs_dispelados) do + for i = 1, min (25, #buffs_dispelados) do local esta_habilidade = buffs_dispelados[i] local nome_magia, _, icone_magia = _GetSpellInfo (esta_habilidade[1]) GameCooltip:AddLine (nome_magia, esta_habilidade[2].." (".._cstr("%.1f", esta_habilidade[2]/meu_total*100).."%)") @@ -1190,15 +1195,15 @@ function atributo_misc:ToolTipDispell (instancia, numero, barra) --> alvos dispelados local alvos_dispelados = {} - for target_name, amount in _pairs (self.dispell_targets) do + for target_name, amount in pairs (self.dispell_targets) do alvos_dispelados [#alvos_dispelados + 1] = {target_name, _math_floor (amount), amount / meu_total * 100} end - _table_sort (alvos_dispelados, _detalhes.Sort2) + table.sort (alvos_dispelados, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_TARGETS"], headerColor, #alvos_dispelados, [[Interface\ICONS\ACHIEVEMENT_GUILDPERK_EVERYONES A HERO_RANK2]], 0.078125, 0.9375, 0.078125, 0.953125) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) - for i = 1, _math_min (25, #alvos_dispelados) do + for i = 1, min (25, #alvos_dispelados) do if (alvos_dispelados[i][2] < 1) then break end @@ -1216,7 +1221,7 @@ function atributo_misc:ToolTipDispell (instancia, numero, barra) if (classe == "UNKNOW") then GameCooltip:AddIcon ("Interface\\LFGFRAME\\LFGROLE_BW", nil, nil, 14, 14, .25, .5, 0, 1) else - GameCooltip:AddIcon ("Interface\\AddOns\\Details\\images\\classes_small", nil, nil, 14, 14, _unpack (_detalhes.class_coords [classe])) + GameCooltip:AddIcon ("Interface\\AddOns\\Details\\images\\classes_small", nil, nil, 14, 14, unpack (_detalhes.class_coords [classe])) end end end @@ -1230,7 +1235,7 @@ function atributo_misc:ToolTipDispell (instancia, numero, barra) local alvos = {} --> armazena os alvos local totais = {} --> armazena o dano total de cada objeto - for index, nome in _ipairs (meus_pets) do + for index, nome in ipairs (meus_pets) do if (not quantidade [nome]) then quantidade [nome] = 1 @@ -1246,14 +1251,14 @@ function atributo_misc:ToolTipDispell (instancia, numero, barra) local _quantidade = 0 local added_logo = false - _table_sort (totais, _detalhes.Sort2) + table.sort (totais, _detalhes.Sort2) local ismaximized = false if (keydown == "alt" or TooltipMaximizedMethod == 2 or TooltipMaximizedMethod == 5) then ismaximized = true end - for index, _table in _ipairs (totais) do + for index, _table in ipairs (totais) do if (_table [2] > 0 and (index < 3 or ismaximized)) then @@ -1283,9 +1288,9 @@ function _detalhes:CloseEnemyDebuffsUptime() local combat = _detalhes.tabela_vigente local misc_container = combat [4]._ActorTable - for _, actor in _ipairs (misc_container) do + for _, actor in ipairs (misc_container) do if (actor.boss_debuff) then - for target_name, target in _ipairs (actor.debuff_uptime_targets) do + for target_name, target in ipairs (actor.debuff_uptime_targets) do if (target.actived and target.actived_at) then target.uptime = target.uptime + _detalhes._tempo - target.actived_at actor.debuff_uptime = actor.debuff_uptime + _detalhes._tempo - target.actived_at @@ -1305,9 +1310,9 @@ function _detalhes:CatchRaidDebuffUptime (in_or_out) -- "DEBUFF_UPTIME_IN" local combat = _detalhes.tabela_vigente local misc_container = combat [4]._ActorTable - for _, actor in _ipairs (misc_container) do + for _, actor in ipairs (misc_container) do if (actor.debuff_uptime) then - for spellid, spell in _pairs (actor.debuff_uptime_spells._ActorTable) do + for spellid, spell in pairs (actor.debuff_uptime_spells._ActorTable) do if (spell.actived and spell.actived_at) then spell.uptime = spell.uptime + _detalhes._tempo - spell.actived_at actor.debuff_uptime = actor.debuff_uptime + _detalhes._tempo - spell.actived_at @@ -1476,7 +1481,7 @@ function _detalhes:CatchRaidBuffUptime (in_or_out) if (in_or_out == "BUFF_UPTIME_IN") then local string_output = "pre-potion: " --> localize-me - for playername, potspellid in _pairs (pot_usage) do + for playername, potspellid in pairs (pot_usage) do local name, _, icon = _GetSpellInfo (potspellid) local _, class = UnitClass (playername) local class_color = "" @@ -1548,7 +1553,7 @@ function _detalhes:CatchRaidBuffUptime (in_or_out) if (in_or_out == "BUFF_UPTIME_IN") then local string_output = "pre-potion: " - for playername, potspellid in _pairs (pot_usage) do + for playername, potspellid in pairs (pot_usage) do local name, _, icon = _GetSpellInfo (potspellid) local _, class = UnitClass (playername) local class_color = "" @@ -1589,7 +1594,7 @@ function _detalhes:CatchRaidBuffUptime (in_or_out) --[ if (in_or_out == "BUFF_UPTIME_IN") then local string_output = "pre-potion: " - for playername, potspellid in _pairs (pot_usage) do + for playername, potspellid in pairs (pot_usage) do local name, _, icon = _GetSpellInfo (potspellid) local _, class = UnitClass (playername) local class_color = "" @@ -1630,11 +1635,10 @@ function atributo_misc:ToolTipDebuffUptime (instancia, numero, barra) local _combat_time = instancia.showing:GetCombatTime() - for _spellid, _tabela in _pairs (minha_tabela) do + for _spellid, _tabela in pairs (minha_tabela) do debuffs_usados [#debuffs_usados+1] = {_spellid, _tabela.uptime} end - --_table_sort (debuffs_usados, Sort2Reverse) - _table_sort (debuffs_usados, _detalhes.Sort2) + table.sort (debuffs_usados, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_SPELLS"], headerColor, #debuffs_usados, _detalhes.tooltip_spell_icon.file, unpack (_detalhes.tooltip_spell_icon.coords)) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) @@ -1643,7 +1647,7 @@ function atributo_misc:ToolTipDebuffUptime (instancia, numero, barra) local icon_border = _detalhes.tooltip.icon_border_texcoord if (#debuffs_usados > 0) then - for i = 1, _math_min (30, #debuffs_usados) do + for i = 1, min (30, #debuffs_usados) do local esta_habilidade = debuffs_usados[i] if (esta_habilidade[2] > 0) then @@ -1667,70 +1671,65 @@ function atributo_misc:ToolTipDebuffUptime (instancia, numero, barra) else GameCooltip:AddLine (Loc ["STRING_NO_SPELL"]) end - + return true - end -function atributo_misc:ToolTipBuffUptime (instancia, numero, barra) - +function atributo_misc:ToolTipBuffUptime(instance, barFrame) local owner = self.owner if (owner and owner.classe) then - r, g, b = unpack (_detalhes.class_colors [owner.classe]) + r, g, b = unpack(_detalhes.class_colors[owner.classe]) else - r, g, b = unpack (_detalhes.class_colors [self.classe]) - end - - local meu_total = self ["buff_uptime"] - local minha_tabela = self.buff_uptime_spells._ActorTable - ---> habilidade usada para interromper - local buffs_usados = {} - - local _combat_time = instancia.showing:GetCombatTime() - - for _spellid, _tabela in _pairs (minha_tabela) do - buffs_usados [#buffs_usados+1] = {_spellid, _tabela.uptime or 0} + r, g, b = unpack(_detalhes.class_colors[self.classe]) end - --_table_sort (buffs_usados, Sort2Reverse) - _table_sort (buffs_usados, _detalhes.Sort2) - - _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_SPELLS"], headerColor, #buffs_usados, _detalhes.tooltip_spell_icon.file, unpack (_detalhes.tooltip_spell_icon.coords)) - _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) - local icon_size = _detalhes.tooltip.icon_size - local icon_border = _detalhes.tooltip.icon_border_texcoord - - if (#buffs_usados > 0) then - for i = 1, _math_min (30, #buffs_usados) do - local esta_habilidade = buffs_usados[i] - - local percent = esta_habilidade[2] / _combat_time * 100 - - if (esta_habilidade[2] > 0 and percent < 99.5) then - local nome_magia, _, icone_magia = _GetSpellInfo (esta_habilidade[1]) - - local minutos, segundos = _math_floor (esta_habilidade[2]/60), _math_floor (esta_habilidade[2]%60) - if (esta_habilidade[2] >= _combat_time) then + local actorTotal = self["buff_uptime"] + local actorTable = self.buff_uptime_spells._ActorTable + + local buffsUsed = {} + local combatTime = instance.showing:GetCombatTime() + + for spellId, actor in pairs(actorTable) do + buffsUsed[#buffsUsed+1] = {spellId, actor.uptime or 0} + end + table.sort(buffsUsed, _detalhes.Sort2) + + _detalhes:AddTooltipSpellHeaderText(Loc ["STRING_SPELLS"], headerColor, #buffsUsed, _detalhes.tooltip_spell_icon.file, unpack(_detalhes.tooltip_spell_icon.coords)) + _detalhes:AddTooltipHeaderStatusbar(r, g, b, barAlha) + + local iconSizeInfo = _detalhes.tooltip.icon_size + local iconBorderInfo = _detalhes.tooltip.icon_border_texcoord + + if (#buffsUsed > 0) then + for i = 1, min(30, #buffsUsed) do + local spellTable = buffsUsed[i] + local percent = spellTable[2] / combatTime * 100 + + if (spellTable[2] > 0 and percent < 99.5) then + local spellName, _, spellIcon = _GetSpellInfo(spellTable[1]) + + local minutes, seconds = floor(spellTable[2] / 60), floor(spellTable[2] % 60) + if (spellTable[2] >= combatTime) then --GameCooltip:AddLine (nome_magia, minutos .. "m " .. segundos .. "s" .. " (" .. _cstr ("%.1f", esta_habilidade[2] / _combat_time * 100) .. "%)", nil, "gray", "gray") --GameCooltip:AddStatusBar (100, nil, 1, 0, 1, .3, false) - elseif (minutos > 0) then - GameCooltip:AddLine (nome_magia, minutos .. "m " .. segundos .. "s" .. " (" .. _cstr ("%.1f", percent) .. "%)") - _detalhes:AddTooltipBackgroundStatusbar (false, percent) + + elseif (minutes > 0) then + GameCooltip:AddLine(spellName, minutes .. "m " .. seconds .. "s" .. " (" .. _cstr("%.1f", percent) .. "%)") + _detalhes:AddTooltipBackgroundStatusbar(false, percent) + else - GameCooltip:AddLine (nome_magia, segundos .. "s" .. " (" .. _cstr ("%.1f", percent) .. "%)") - _detalhes:AddTooltipBackgroundStatusbar (false, percent) + GameCooltip:AddLine(spellName, seconds .. "s" .. " (" .. _cstr("%.1f", percent) .. "%)") + _detalhes:AddTooltipBackgroundStatusbar(false, percent) end - - GameCooltip:AddIcon (icone_magia, nil, nil, icon_size.W, icon_size.H, icon_border.L, icon_border.R, icon_border.T, icon_border.B) + + GameCooltip:AddIcon(spellIcon, nil, nil, iconSizeInfo.W, iconSizeInfo.H, iconBorderInfo.L, iconBorderInfo.R, iconBorderInfo.T, iconBorderInfo.B) end end else - GameCooltip:AddLine (Loc ["STRING_NO_SPELL"]) + GameCooltip:AddLine(Loc ["STRING_NO_SPELL"]) end - + return true - end function atributo_misc:ToolTipDefensiveCooldowns (instancia, numero, barra) @@ -1748,10 +1747,10 @@ function atributo_misc:ToolTipDefensiveCooldowns (instancia, numero, barra) --> spells local cooldowns_usados = {} - for _spellid, _tabela in _pairs (minha_tabela) do + for _spellid, _tabela in pairs (minha_tabela) do cooldowns_usados [#cooldowns_usados+1] = {_spellid, _tabela.counter} end - _table_sort (cooldowns_usados, _detalhes.Sort2) + table.sort (cooldowns_usados, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_SPELLS"], headerColor, #cooldowns_usados, _detalhes.tooltip_spell_icon.file, unpack (_detalhes.tooltip_spell_icon.coords)) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) @@ -1761,7 +1760,7 @@ function atributo_misc:ToolTipDefensiveCooldowns (instancia, numero, barra) local lineHeight = _detalhes.tooltip.line_height if (#cooldowns_usados > 0) then - for i = 1, _math_min (25, #cooldowns_usados) do + for i = 1, min (25, #cooldowns_usados) do local esta_habilidade = cooldowns_usados[i] local nome_magia, _, icone_magia = _GetSpellInfo (esta_habilidade[1]) GameCooltip:AddLine (nome_magia, esta_habilidade[2].." (".._cstr("%.1f", esta_habilidade[2]/meu_total*100).."%)") @@ -1776,16 +1775,16 @@ function atributo_misc:ToolTipDefensiveCooldowns (instancia, numero, barra) local meus_alvos = self.cooldowns_defensive_targets local alvos = {} - for target_name, amount in _pairs (meus_alvos) do + for target_name, amount in pairs (meus_alvos) do alvos [#alvos+1] = {target_name, amount} end - _table_sort (alvos, _detalhes.Sort2) + table.sort (alvos, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_TARGETS"], headerColor, #alvos, _detalhes.tooltip_target_icon.file, unpack (_detalhes.tooltip_target_icon.coords)) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) if (#alvos > 0) then - for i = 1, _math_min (25, #alvos) do + for i = 1, min (25, #alvos) do GameCooltip:AddLine (_detalhes:GetOnlyName (alvos[i][1]) .. ": ", alvos[i][2], 1, "white", "white") _detalhes:AddTooltipBackgroundStatusbar() @@ -1805,7 +1804,7 @@ function atributo_misc:ToolTipDefensiveCooldowns (instancia, numero, barra) local texture, l, r, t, b = _detalhes:GetSpecIcon (specID, false) GameCooltip:AddIcon (texture, 1, 1, lineHeight, lineHeight, l, r, t, b) else - GameCooltip:AddIcon ("Interface\\AddOns\\Details\\images\\classes_small", nil, nil, 14, 14, _unpack (_detalhes.class_coords [classe])) + GameCooltip:AddIcon ("Interface\\AddOns\\Details\\images\\classes_small", nil, nil, 14, 14, unpack (_detalhes.class_coords [classe])) end end end @@ -1834,16 +1833,16 @@ function atributo_misc:ToolTipRess (instancia, numero, barra) --> habilidade usada para interromper local meus_ress = {} - for _spellid, _tabela in _pairs (minha_tabela) do + for _spellid, _tabela in pairs (minha_tabela) do meus_ress [#meus_ress+1] = {_spellid, _tabela.ress} end - _table_sort (meus_ress, _detalhes.Sort2) + table.sort (meus_ress, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_SPELLS"], headerColor, #meus_ress, _detalhes.tooltip_spell_icon.file, unpack (_detalhes.tooltip_spell_icon.coords)) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) if (#meus_ress > 0) then - for i = 1, _math_min (3, #meus_ress) do + for i = 1, min (3, #meus_ress) do local esta_habilidade = meus_ress[i] local nome_magia, _, icone_magia = _GetSpellInfo (esta_habilidade[1]) GameCooltip:AddLine (nome_magia, esta_habilidade[2] .. " (" .. _cstr ("%.1f", floor (esta_habilidade[2]) / floor (meu_total) * 100).."%)") @@ -1858,16 +1857,16 @@ function atributo_misc:ToolTipRess (instancia, numero, barra) local meus_alvos = self.ress_targets local alvos = {} - for target_name, amount in _pairs (meus_alvos) do + for target_name, amount in pairs (meus_alvos) do alvos [#alvos+1] = {target_name, amount} end - _table_sort (alvos, _detalhes.Sort2) + table.sort (alvos, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_TARGETS"], headerColor, #alvos, _detalhes.tooltip_target_icon.file, unpack (_detalhes.tooltip_target_icon.coords)) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) if (#alvos > 0) then - for i = 1, _math_min (3, #alvos) do + for i = 1, min (3, #alvos) do GameCooltip:AddLine (alvos[i][1], alvos[i][2]) _detalhes:AddTooltipBackgroundStatusbar() @@ -1885,7 +1884,7 @@ function atributo_misc:ToolTipRess (instancia, numero, barra) local texture, l, r, t, b = _detalhes:GetSpecIcon (specID, false) GameCooltip:AddIcon (texture, 1, 1, lineHeight, lineHeight, l, r, t, b) else - GameCooltip:AddIcon ("Interface\\AddOns\\Details\\images\\classes_small", nil, nil, lineHeight, lineHeight, _unpack (_detalhes.class_coords [classe])) + GameCooltip:AddIcon ("Interface\\AddOns\\Details\\images\\classes_small", nil, nil, lineHeight, lineHeight, unpack (_detalhes.class_coords [classe])) end end end @@ -1916,16 +1915,16 @@ function atributo_misc:ToolTipInterrupt (instancia, numero, barra) --> habilidade usada para interromper local meus_interrupts = {} - for _spellid, _tabela in _pairs (minha_tabela) do + for _spellid, _tabela in pairs (minha_tabela) do meus_interrupts [#meus_interrupts+1] = {_spellid, _tabela.counter} end - _table_sort (meus_interrupts, _detalhes.Sort2) + table.sort (meus_interrupts, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_SPELLS"], headerColor, #meus_interrupts, _detalhes.tooltip_spell_icon.file, unpack (_detalhes.tooltip_spell_icon.coords)) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) if (#meus_interrupts > 0) then - for i = 1, _math_min (25, #meus_interrupts) do + for i = 1, min (25, #meus_interrupts) do local esta_habilidade = meus_interrupts[i] local nome_magia, _, icone_magia = _GetSpellInfo (esta_habilidade[1]) GameCooltip:AddLine (nome_magia, esta_habilidade[2].." (".._cstr("%.1f", floor (esta_habilidade[2])/floor (meu_total)*100).."%)") @@ -1939,16 +1938,16 @@ function atributo_misc:ToolTipInterrupt (instancia, numero, barra) --> quais habilidades foram interrompidas local habilidades_interrompidas = {} - for _spellid, amt in _pairs (self.interrompeu_oque) do + for _spellid, amt in pairs (self.interrompeu_oque) do habilidades_interrompidas [#habilidades_interrompidas+1] = {_spellid, amt} end - _table_sort (habilidades_interrompidas, _detalhes.Sort2) + table.sort (habilidades_interrompidas, _detalhes.Sort2) _detalhes:AddTooltipSpellHeaderText (Loc ["STRING_SPELL_INTERRUPTED"] .. ":", headerColor, #habilidades_interrompidas, _detalhes.tooltip_target_icon.file, unpack (_detalhes.tooltip_target_icon.coords)) _detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha) if (#habilidades_interrompidas > 0) then - for i = 1, _math_min (25, #habilidades_interrompidas) do + for i = 1, min (25, #habilidades_interrompidas) do local esta_habilidade = habilidades_interrompidas[i] local nome_magia, _, icone_magia = _GetSpellInfo (esta_habilidade[1]) GameCooltip:AddLine (nome_magia, esta_habilidade[2].." (".._cstr("%.1f", floor (esta_habilidade[2])/floor (meu_total)*100).."%)") @@ -1966,7 +1965,7 @@ function atributo_misc:ToolTipInterrupt (instancia, numero, barra) local alvos = {} --> armazena os alvos local totais = {} --> armazena o dano total de cada objeto - for index, nome in _ipairs (meus_pets) do + for index, nome in ipairs (meus_pets) do if (not quantidade [nome]) then quantidade [nome] = 1 @@ -1982,14 +1981,14 @@ function atributo_misc:ToolTipInterrupt (instancia, numero, barra) local _quantidade = 0 local added_logo = false - _table_sort (totais, _detalhes.Sort2) + table.sort (totais, _detalhes.Sort2) local ismaximized = false if (keydown == "alt" or TooltipMaximizedMethod == 2 or TooltipMaximizedMethod == 5) then ismaximized = true end - for index, _table in _ipairs (totais) do + for index, _table in ipairs (totais) do if (_table [2] > 0 and (index < 3 or ismaximized)) then @@ -2047,25 +2046,25 @@ function atributo_misc:MontaInfoInterrupt() local meus_interrupts = {} --player - for _spellid, _tabela in _pairs (minha_tabela) do --> da foreach em cada spellid do container + for _spellid, _tabela in pairs (minha_tabela) do --> da foreach em cada spellid do container local nome, _, icone = _GetSpellInfo (_spellid) _table_insert (meus_interrupts, {_spellid, _tabela.counter, _tabela.counter/meu_total*100, nome, icone}) end --pet local ActorPets = self.pets local class_color = "FFDDDDDD" - for _, PetName in _ipairs (ActorPets) do + for _, PetName in ipairs (ActorPets) do local PetActor = instancia.showing (class_type, PetName) if (PetActor and PetActor.interrupt and PetActor.interrupt > 0) then local PetSkillsContainer = PetActor.interrupt_spells._ActorTable - for _spellid, _skill in _pairs (PetSkillsContainer) do --> da foreach em cada spellid do container + for _spellid, _skill in pairs (PetSkillsContainer) do --> da foreach em cada spellid do container local nome, _, icone = _GetSpellInfo (_spellid) _table_insert (meus_interrupts, {_spellid, _skill.counter, _skill.counter/meu_total*100, nome .. " (|c" .. class_color .. PetName:gsub ((" <.*"), "") .. "|r)", icone, PetActor}) end end end - _table_sort (meus_interrupts, _detalhes.Sort2) + table.sort (meus_interrupts, _detalhes.Sort2) local amt = #meus_interrupts gump:JI_AtualizaContainerBarras (amt) @@ -2073,7 +2072,7 @@ function atributo_misc:MontaInfoInterrupt() local max_ = meus_interrupts [1][2] --> dano que a primeiro magia vez local barra - for index, tabela in _ipairs (meus_interrupts) do + for index, tabela in ipairs (meus_interrupts) do barra = barras [index] @@ -2126,10 +2125,10 @@ function atributo_misc:MontaInfoInterrupt() --> Alvos do interrupt local meus_alvos = {} - for target_name, amount in _pairs (self.interrupt_targets) do + for target_name, amount in pairs (self.interrupt_targets) do meus_alvos [#meus_alvos+1] = {target_name, amount} end - _table_sort (meus_alvos, _detalhes.Sort2) + table.sort (meus_alvos, _detalhes.Sort2) local amt_alvos = #meus_alvos if (amt_alvos < 1) then @@ -2140,7 +2139,7 @@ function atributo_misc:MontaInfoInterrupt() local max_alvos = meus_alvos[1][2] local barra - for index, tabela in _ipairs (meus_alvos) do + for index, tabela in ipairs (meus_alvos) do barra = info.barras2 [index] @@ -2181,7 +2180,7 @@ end ------ Detalhe Info Interrupt function atributo_misc:MontaDetalhesInterrupt (spellid, barra) - for _, barra in _ipairs (info.barras3) do + for _, barra in ipairs (info.barras3) do barra:Hide() end @@ -2210,11 +2209,11 @@ function atributo_misc:MontaDetalhesInterrupt (spellid, barra) for spellid, amt in pairs (esta_magia.interrompeu_oque) do habilidades_alvos [#habilidades_alvos+1] = {spellid, amt} end - _table_sort (habilidades_alvos, _detalhes.Sort2) + table.sort (habilidades_alvos, _detalhes.Sort2) local max_ = habilidades_alvos[1][2] local barra - for index, tabela in _ipairs (habilidades_alvos) do + for index, tabela in ipairs (habilidades_alvos) do barra = barras [index] if (not barra) then --> se a barra n�o existir, criar ela ent�o @@ -2257,10 +2256,10 @@ function atributo_misc:MontaTooltipAlvos (esta_barra, index) local habilidades = {} local total = self.interrupt - for spellid, tabela in _pairs (container) do + for spellid, tabela in pairs (container) do --> tabela = classe_damage_habilidade local alvos = tabela.targets - for target_name, amount in _ipairs (alvos) do + for target_name, amount in ipairs (alvos) do --> tabela = classe_target if (target_name == inimigo) then habilidades [#habilidades+1] = {spellid, amount} @@ -2274,7 +2273,7 @@ function atributo_misc:MontaTooltipAlvos (esta_barra, index) GameTooltip:AddLine (Loc ["STRING_SPELL_INTERRUPTED"] .. ":") GameTooltip:AddLine (" ") - for index, tabela in _ipairs (habilidades) do + for index, tabela in ipairs (habilidades) do local nome, rank, icone = _GetSpellInfo (tabela[1]) if (index < 8) then GameTooltip:AddDoubleLine (index..". |T"..icone..":0|t "..nome, tabela[2].." (".._cstr("%.1f", tabela[2]/total*100).."%)", 1, 1, 1, 1, 1, 1) @@ -2308,7 +2307,7 @@ end --> subtract total from a combat table function atributo_misc:subtract_total (combat_table) - for _, sub_attribute in _ipairs (sub_list) do + for _, sub_attribute in ipairs (sub_list) do if (self [sub_attribute]) then combat_table.totals [class_type][sub_attribute] = combat_table.totals [class_type][sub_attribute] - self [sub_attribute] if (self.grupo) then @@ -2318,7 +2317,7 @@ end end end function atributo_misc:add_total (combat_table) - for _, sub_attribute in _ipairs (sub_list) do + for _, sub_attribute in ipairs (sub_list) do if (self [sub_attribute]) then combat_table.totals [class_type][sub_attribute] = combat_table.totals [class_type][sub_attribute] + self [sub_attribute] if (self.grupo) then @@ -2329,12 +2328,12 @@ end end local refresh_alvos = function (container1, container2) - for target_name, amount in _pairs (container2) do + for target_name, amount in pairs (container2) do container1 [target_name] = container1 [target_name] or 0 end end local refresh_habilidades = function (container1, container2) - for spellid, habilidade in _pairs (container2._ActorTable) do + for spellid, habilidade in pairs (container2._ActorTable) do local habilidade_shadow = container1:PegaHabilidade (spellid, true, nil, true) refresh_alvos (habilidade_shadow.targets , habilidade.targets) end @@ -2370,7 +2369,7 @@ function atributo_misc:r_onlyrefresh_shadow (actor) if (not shadow.spell_cast) then shadow.spell_cast = {} end - for spellid, _ in _pairs (actor.spell_cast) do + for spellid, _ in pairs (actor.spell_cast) do shadow.spell_cast [spellid] = shadow.spell_cast [spellid] or 0 end end @@ -2408,7 +2407,7 @@ function atributo_misc:r_onlyrefresh_shadow (actor) if (actor.interrupt) then refresh_alvos (shadow.interrupt_targets, actor.interrupt_targets) refresh_habilidades (shadow.interrupt_spells, actor.interrupt_spells) - for spellid, habilidade in _pairs (actor.interrupt_spells._ActorTable) do + for spellid, habilidade in pairs (actor.interrupt_spells._ActorTable) do local habilidade_shadow = shadow.interrupt_spells:PegaHabilidade (spellid, true, nil, true) habilidade_shadow.interrompeu_oque = habilidade_shadow.interrompeu_oque or {} end @@ -2424,7 +2423,7 @@ function atributo_misc:r_onlyrefresh_shadow (actor) if (actor.dispell) then refresh_alvos (shadow.dispell_targets, actor.dispell_targets) refresh_habilidades (shadow.dispell_spells, actor.dispell_spells) - for spellid, habilidade in _pairs (actor.dispell_spells._ActorTable) do + for spellid, habilidade in pairs (actor.dispell_spells._ActorTable) do local habilidade_shadow = shadow.dispell_spells:PegaHabilidade (spellid, true, nil, true) habilidade_shadow.dispell_oque = habilidade_shadow.dispell_oque or {} end @@ -2434,7 +2433,7 @@ function atributo_misc:r_onlyrefresh_shadow (actor) if (actor.cc_break) then refresh_alvos (shadow.cc_break_targets, actor.cc_break_targets) refresh_habilidades (shadow.cc_break_spells, actor.cc_break_spells) - for spellid, habilidade in _pairs (actor.cc_break_spells._ActorTable) do + for spellid, habilidade in pairs (actor.cc_break_spells._ActorTable) do local habilidade_shadow = shadow.cc_break_spells:PegaHabilidade (spellid, true, nil, true) habilidade_shadow.cc_break_oque = habilidade_shadow.cc_break_oque or {} end @@ -2445,7 +2444,7 @@ function atributo_misc:r_onlyrefresh_shadow (actor) end local somar_keys = function (habilidade, habilidade_tabela1) - for key, value in _pairs (habilidade) do + for key, value in pairs (habilidade) do if (_type (value) == "number") then if (key ~= "id" and key ~= "spellschool") then habilidade_tabela1 [key] = (habilidade_tabela1 [key] or 0) + value @@ -2454,12 +2453,12 @@ local somar_keys = function (habilidade, habilidade_tabela1) end end local somar_alvos = function (container1, container2) - for target_name, amount in _pairs (container2) do + for target_name, amount in pairs (container2) do container1 [target_name] = (container1 [target_name] or 0) + amount end end local somar_habilidades = function (container1, container2) - for spellid, habilidade in _pairs (container2._ActorTable) do + for spellid, habilidade in pairs (container2._ActorTable) do local habilidade_tabela1 = container1:PegaHabilidade (spellid, true, nil, false) somar_alvos (habilidade_tabela1.targets, habilidade.targets) somar_keys (habilidade, habilidade_tabela1) @@ -2498,7 +2497,7 @@ function atributo_misc:r_connect_shadow (actor, no_refresh, combat_object) end --> pets (add unique pet names) - for _, petName in _ipairs (actor.pets) do + for _, petName in ipairs (actor.pets) do DetailsFramework.table.addunique (shadow.pets, petName) end @@ -2507,7 +2506,7 @@ function atributo_misc:r_connect_shadow (actor, no_refresh, combat_object) shadow.spell_cast = {} end - for spellid, amount in _pairs (actor.spell_cast) do + for spellid, amount in pairs (actor.spell_cast) do shadow.spell_cast [spellid] = (shadow.spell_cast [spellid] or 0) + amount end end @@ -2573,7 +2572,7 @@ function atributo_misc:r_connect_shadow (actor, no_refresh, combat_object) shadow.debuff_uptime = shadow.debuff_uptime + actor.debuff_uptime - for target_name, amount in _pairs (actor.debuff_uptime_targets) do + for target_name, amount in pairs (actor.debuff_uptime_targets) do if (_type (amount) == "table") then --> boss debuff local t = shadow.debuff_uptime_targets [target_name] if (not t) then @@ -2610,16 +2609,16 @@ function atributo_misc:r_connect_shadow (actor, no_refresh, combat_object) somar_alvos (shadow.interrupt_targets, actor.interrupt_targets) somar_habilidades (shadow.interrupt_spells, actor.interrupt_spells) - for spellid, habilidade in _pairs (actor.interrupt_spells._ActorTable) do + for spellid, habilidade in pairs (actor.interrupt_spells._ActorTable) do local habilidade_shadow = shadow.interrupt_spells:PegaHabilidade (spellid, true, nil, true) habilidade_shadow.interrompeu_oque = habilidade_shadow.interrompeu_oque or {} - for _spellid, amount in _pairs (habilidade.interrompeu_oque) do + for _spellid, amount in pairs (habilidade.interrompeu_oque) do habilidade_shadow.interrompeu_oque [_spellid] = (habilidade_shadow.interrompeu_oque [_spellid] or 0) + amount end end - for spellid, amount in _pairs (actor.interrompeu_oque) do + for spellid, amount in pairs (actor.interrompeu_oque) do shadow.interrompeu_oque [spellid] = (shadow.interrompeu_oque [spellid] or 0) + amount end end @@ -2660,15 +2659,15 @@ function atributo_misc:r_connect_shadow (actor, no_refresh, combat_object) somar_alvos (shadow.dispell_targets, actor.dispell_targets) somar_habilidades (shadow.dispell_spells, actor.dispell_spells) - for spellid, habilidade in _pairs (actor.dispell_spells._ActorTable) do + for spellid, habilidade in pairs (actor.dispell_spells._ActorTable) do local habilidade_shadow = shadow.dispell_spells:PegaHabilidade (spellid, true, nil, true) habilidade_shadow.dispell_oque = habilidade_shadow.dispell_oque or {} - for _spellid, amount in _pairs (habilidade.dispell_oque) do + for _spellid, amount in pairs (habilidade.dispell_oque) do habilidade_shadow.dispell_oque [_spellid] = (habilidade_shadow.dispell_oque [_spellid] or 0) + amount end end - for spellid, amount in _pairs (actor.dispell_oque) do + for spellid, amount in pairs (actor.dispell_oque) do shadow.dispell_oque [spellid] = (shadow.dispell_oque [spellid] or 0) + amount end end @@ -2690,14 +2689,14 @@ function atributo_misc:r_connect_shadow (actor, no_refresh, combat_object) somar_alvos (shadow.cc_break_targets, actor.cc_break_targets) somar_habilidades (shadow.cc_break_spells, actor.cc_break_spells) - for spellid, habilidade in _pairs (actor.cc_break_spells._ActorTable) do + for spellid, habilidade in pairs (actor.cc_break_spells._ActorTable) do local habilidade_shadow = shadow.cc_break_spells:PegaHabilidade (spellid, true, nil, true) habilidade_shadow.cc_break_oque = habilidade_shadow.cc_break_oque or {} - for _spellid, amount in _pairs (habilidade.cc_break_oque) do + for _spellid, amount in pairs (habilidade.cc_break_oque) do habilidade_shadow.cc_break_oque [_spellid] = (habilidade_shadow.cc_break_oque [_spellid] or 0) + amount end end - for spellid, amount in _pairs (actor.cc_break_oque) do + for spellid, amount in pairs (actor.cc_break_oque) do shadow.cc_break_oque [spellid] = (shadow.cc_break_oque [spellid] or 0) + amount end end @@ -2711,7 +2710,7 @@ function atributo_misc:ColetarLixo (lastevent) end function _detalhes.refresh:r_atributo_misc (este_jogador, shadow) - _setmetatable (este_jogador, _detalhes.atributo_misc) + setmetatable (este_jogador, _detalhes.atributo_misc) este_jogador.__index = _detalhes.atributo_misc --> refresh spell cast @@ -2858,7 +2857,7 @@ end atributo_misc.__add = function (tabela1, tabela2) if (tabela2.spell_cast) then - for spellid, amount in _pairs (tabela2.spell_cast) do + for spellid, amount in pairs (tabela2.spell_cast) do tabela1.spell_cast [spellid] = (tabela1.spell_cast [spellid] or 0) + amount end end @@ -2866,14 +2865,14 @@ atributo_misc.__add = function (tabela1, tabela2) if (tabela2.cc_done) then tabela1.cc_done = tabela1.cc_done + tabela2.cc_done - for target_name, amount in _pairs (tabela2.cc_done_targets) do + for target_name, amount in pairs (tabela2.cc_done_targets) do tabela1.cc_done_targets [target_name] = (tabela1.cc_done_targets [target_name] or 0) + amount end - for spellid, habilidade in _pairs (tabela2.cc_done_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.cc_done_spells._ActorTable) do local habilidade_tabela1 = tabela1.cc_done_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) + amount end @@ -2893,24 +2892,24 @@ atributo_misc.__add = function (tabela1, tabela2) --> total de interrupts tabela1.interrupt = tabela1.interrupt + tabela2.interrupt --> soma o interrompeu o que - for spellid, amount in _pairs (tabela2.interrompeu_oque) do + for spellid, amount in pairs (tabela2.interrompeu_oque) do tabela1.interrompeu_oque [spellid] = (tabela1.interrompeu_oque [spellid] or 0) + amount end --> soma os containers de alvos - for target_name, amount in _pairs (tabela2.interrupt_targets) do + for target_name, amount in pairs (tabela2.interrupt_targets) do tabela1.interrupt_targets [target_name] = (tabela1.interrupt_targets [target_name] or 0) + amount end --> soma o container de habilidades - for spellid, habilidade in _pairs (tabela2.interrupt_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.interrupt_spells._ActorTable) do local habilidade_tabela1 = tabela1.interrupt_spells:PegaHabilidade (spellid, true, nil, false) habilidade_tabela1.interrompeu_oque = habilidade_tabela1.interrompeu_oque or {} - for _spellid, amount in _pairs (habilidade.interrompeu_oque) do + for _spellid, amount in pairs (habilidade.interrompeu_oque) do habilidade_tabela1.interrompeu_oque [_spellid] = (habilidade_tabela1.interrompeu_oque [_spellid] or 0) + amount end - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) + amount end @@ -2928,14 +2927,14 @@ atributo_misc.__add = function (tabela1, tabela2) tabela1.buff_uptime = tabela1.buff_uptime + tabela2.buff_uptime - for target_name, amount in _pairs (tabela2.buff_uptime_targets) do + for target_name, amount in pairs (tabela2.buff_uptime_targets) do tabela1.buff_uptime_targets [target_name] = (tabela1.buff_uptime_targets [target_name] or 0) + amount end - for spellid, habilidade in _pairs (tabela2.buff_uptime_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.buff_uptime_spells._ActorTable) do local habilidade_tabela1 = tabela1.buff_uptime_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) + amount end @@ -2961,7 +2960,7 @@ atributo_misc.__add = function (tabela1, tabela2) tabela1.debuff_uptime = tabela1.debuff_uptime + tabela2.debuff_uptime - for target_name, amount in _pairs (tabela2.debuff_uptime_targets) do + for target_name, amount in pairs (tabela2.debuff_uptime_targets) do if (_type (amount) == "table") then --> boss debuff local t = tabela1.debuff_uptime_targets [target_name] if (not t) then @@ -2977,10 +2976,10 @@ atributo_misc.__add = function (tabela1, tabela2) end end - for spellid, habilidade in _pairs (tabela2.debuff_uptime_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.debuff_uptime_spells._ActorTable) do local habilidade_tabela1 = tabela1.debuff_uptime_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) + amount end @@ -2997,14 +2996,14 @@ atributo_misc.__add = function (tabela1, tabela2) tabela1.cooldowns_defensive = tabela1.cooldowns_defensive + tabela2.cooldowns_defensive - for target_name, amount in _pairs (tabela2.cooldowns_defensive_targets) do + for target_name, amount in pairs (tabela2.cooldowns_defensive_targets) do tabela1.cooldowns_defensive_targets [target_name] = (tabela1.cooldowns_defensive_targets [target_name] or 0) + amount end - for spellid, habilidade in _pairs (tabela2.cooldowns_defensive_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.cooldowns_defensive_spells._ActorTable) do local habilidade_tabela1 = tabela1.cooldowns_defensive_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) + amount end @@ -3021,14 +3020,14 @@ atributo_misc.__add = function (tabela1, tabela2) tabela1.ress = tabela1.ress + tabela2.ress - for target_name, amount in _pairs (tabela2.ress_targets) do + for target_name, amount in pairs (tabela2.ress_targets) do tabela1.ress_targets [target_name] = (tabela1.ress_targets [target_name] or 0) + amount end - for spellid, habilidade in _pairs (tabela2.ress_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.ress_spells._ActorTable) do local habilidade_tabela1 = tabela1.ress_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) + amount end @@ -3047,27 +3046,27 @@ atributo_misc.__add = function (tabela1, tabela2) tabela1.dispell = tabela1.dispell + tabela2.dispell - for target_name, amount in _pairs (tabela2.dispell_targets) do + for target_name, amount in pairs (tabela2.dispell_targets) do tabela1.dispell_targets [target_name] = (tabela1.dispell_targets [target_name] or 0) + amount end - for spellid, habilidade in _pairs (tabela2.dispell_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.dispell_spells._ActorTable) do local habilidade_tabela1 = tabela1.dispell_spells:PegaHabilidade (spellid, true, nil, false) habilidade_tabela1.dispell_oque = habilidade_tabela1.dispell_oque or {} - for _spellid, amount in _pairs (habilidade.dispell_oque) do + for _spellid, amount in pairs (habilidade.dispell_oque) do habilidade_tabela1.dispell_oque [_spellid] = (habilidade_tabela1.dispell_oque [_spellid] or 0) + amount end - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) + amount end somar_keys (habilidade, habilidade_tabela1) end - for spellid, amount in _pairs (tabela2.dispell_oque) do + for spellid, amount in pairs (tabela2.dispell_oque) do tabela1.dispell_oque [spellid] = (tabela1.dispell_oque [spellid] or 0) + amount end @@ -3084,26 +3083,26 @@ atributo_misc.__add = function (tabela1, tabela2) tabela1.cc_break = tabela1.cc_break + tabela2.cc_break - for target_name, amount in _pairs (tabela2.cc_break_targets) do + for target_name, amount in pairs (tabela2.cc_break_targets) do tabela1.cc_break_targets [target_name] = (tabela1.cc_break_targets [target_name] or 0) + amount end - for spellid, habilidade in _pairs (tabela2.cc_break_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.cc_break_spells._ActorTable) do local habilidade_tabela1 = tabela1.cc_break_spells:PegaHabilidade (spellid, true, nil, false) habilidade_tabela1.cc_break_oque = habilidade_tabela1.cc_break_oque or {} - for _spellid, amount in _pairs (habilidade.cc_break_oque) do + for _spellid, amount in pairs (habilidade.cc_break_oque) do habilidade_tabela1.cc_break_oque [_spellid] = (habilidade_tabela1.cc_break_oque [_spellid] or 0) + amount end - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) + amount end somar_keys (habilidade, habilidade_tabela1) end - for spellid, amount in _pairs (tabela2.cc_break_oque) do + for spellid, amount in pairs (tabela2.cc_break_oque) do tabela1.cc_break_oque [spellid] = (tabela1.cc_break_oque [spellid] or 0) + amount end end @@ -3112,7 +3111,7 @@ atributo_misc.__add = function (tabela1, tabela2) end local subtrair_keys = function (habilidade, habilidade_tabela1) - for key, value in _pairs (habilidade) do + for key, value in pairs (habilidade) do if (_type (value) == "number") then if (key ~= "id" and key ~= "spellschool") then habilidade_tabela1 [key] = (habilidade_tabela1 [key] or 0) - value @@ -3124,7 +3123,7 @@ end atributo_misc.__sub = function (tabela1, tabela2) if (tabela2.spell_cast) then - for spellid, amount in _pairs (tabela2.spell_cast) do + for spellid, amount in pairs (tabela2.spell_cast) do tabela1.spell_cast [spellid] = (tabela1.spell_cast [spellid] or 0) - amount end end @@ -3132,14 +3131,14 @@ atributo_misc.__sub = function (tabela1, tabela2) if (tabela2.cc_done) then tabela1.cc_done = tabela1.cc_done - tabela2.cc_done - for target_name, amount in _pairs (tabela2.cc_done_targets) do + for target_name, amount in pairs (tabela2.cc_done_targets) do tabela1.cc_done_targets [target_name] = (tabela1.cc_done_targets [target_name] or 0) - amount end - for spellid, habilidade in _pairs (tabela2.cc_done_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.cc_done_spells._ActorTable) do local habilidade_tabela1 = tabela1.cc_done_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) - amount end @@ -3151,24 +3150,24 @@ atributo_misc.__sub = function (tabela1, tabela2) --> total de interrupts tabela1.interrupt = tabela1.interrupt - tabela2.interrupt --> soma o interrompeu o que - for spellid, amount in _pairs (tabela2.interrompeu_oque) do + for spellid, amount in pairs (tabela2.interrompeu_oque) do tabela1.interrompeu_oque [spellid] = (tabela1.interrompeu_oque [spellid] or 0) - amount end --> soma os containers de alvos - for target_name, amount in _pairs (tabela2.interrupt_targets) do + for target_name, amount in pairs (tabela2.interrupt_targets) do tabela1.interrupt_targets [target_name] = (tabela1.interrupt_targets [target_name] or 0) - amount end --> soma o container de habilidades - for spellid, habilidade in _pairs (tabela2.interrupt_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.interrupt_spells._ActorTable) do local habilidade_tabela1 = tabela1.interrupt_spells:PegaHabilidade (spellid, true, nil, false) habilidade_tabela1.interrompeu_oque = habilidade_tabela1.interrompeu_oque or {} - for _spellid, amount in _pairs (habilidade.interrompeu_oque) do + for _spellid, amount in pairs (habilidade.interrompeu_oque) do habilidade_tabela1.interrompeu_oque [_spellid] = (habilidade_tabela1.interrompeu_oque [_spellid] or 0) - amount end - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) - amount end @@ -3179,14 +3178,14 @@ atributo_misc.__sub = function (tabela1, tabela2) if (tabela2.buff_uptime) then tabela1.buff_uptime = tabela1.buff_uptime - tabela2.buff_uptime - for target_name, amount in _pairs (tabela2.buff_uptime_targets) do + for target_name, amount in pairs (tabela2.buff_uptime_targets) do tabela1.buff_uptime_targets [target_name] = (tabela1.buff_uptime_targets [target_name] or 0) - amount end - for spellid, habilidade in _pairs (tabela2.buff_uptime_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.buff_uptime_spells._ActorTable) do local habilidade_tabela1 = tabela1.buff_uptime_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) - amount end @@ -3197,7 +3196,7 @@ atributo_misc.__sub = function (tabela1, tabela2) if (tabela2.debuff_uptime) then tabela1.debuff_uptime = tabela1.debuff_uptime - tabela2.debuff_uptime - for target_name, amount in _pairs (tabela2.debuff_uptime_targets) do + for target_name, amount in pairs (tabela2.debuff_uptime_targets) do if (_type (amount) == "table") then --> boss debuff local t = tabela1.debuff_uptime_targets [target_name] if (not t) then @@ -3213,10 +3212,10 @@ atributo_misc.__sub = function (tabela1, tabela2) end end - for spellid, habilidade in _pairs (tabela2.debuff_uptime_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.debuff_uptime_spells._ActorTable) do local habilidade_tabela1 = tabela1.debuff_uptime_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) - amount end @@ -3227,14 +3226,14 @@ atributo_misc.__sub = function (tabela1, tabela2) if (tabela2.cooldowns_defensive) then tabela1.cooldowns_defensive = tabela1.cooldowns_defensive - tabela2.cooldowns_defensive - for target_name, amount in _pairs (tabela2.cooldowns_defensive_targets) do + for target_name, amount in pairs (tabela2.cooldowns_defensive_targets) do tabela1.cooldowns_defensive_targets [target_name] = (tabela1.cooldowns_defensive_targets [target_name] or 0) - amount end - for spellid, habilidade in _pairs (tabela2.cooldowns_defensive_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.cooldowns_defensive_spells._ActorTable) do local habilidade_tabela1 = tabela1.cooldowns_defensive_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) - amount end @@ -3245,14 +3244,14 @@ atributo_misc.__sub = function (tabela1, tabela2) if (tabela2.ress) then tabela1.ress = tabela1.ress - tabela2.ress - for target_name, amount in _pairs (tabela2.ress_targets) do + for target_name, amount in pairs (tabela2.ress_targets) do tabela1.ress_targets [target_name] = (tabela1.ress_targets [target_name] or 0) - amount end - for spellid, habilidade in _pairs (tabela2.ress_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.ress_spells._ActorTable) do local habilidade_tabela1 = tabela1.ress_spells:PegaHabilidade (spellid, true, nil, false) - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) - amount end @@ -3263,27 +3262,27 @@ atributo_misc.__sub = function (tabela1, tabela2) if (tabela2.dispell) then tabela1.dispell = tabela1.dispell - tabela2.dispell - for target_name, amount in _pairs (tabela2.dispell_targets) do + for target_name, amount in pairs (tabela2.dispell_targets) do tabela1.dispell_targets [target_name] = (tabela1.dispell_targets [target_name] or 0) - amount end - for spellid, habilidade in _pairs (tabela2.dispell_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.dispell_spells._ActorTable) do local habilidade_tabela1 = tabela1.dispell_spells:PegaHabilidade (spellid, true, nil, false) habilidade_tabela1.dispell_oque = habilidade_tabela1.dispell_oque or {} - for _spellid, amount in _pairs (habilidade.dispell_oque) do + for _spellid, amount in pairs (habilidade.dispell_oque) do habilidade_tabela1.dispell_oque [_spellid] = (habilidade_tabela1.dispell_oque [_spellid] or 0) - amount end - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) - amount end subtrair_keys (habilidade, habilidade_tabela1) end - for spellid, amount in _pairs (tabela2.dispell_oque) do + for spellid, amount in pairs (tabela2.dispell_oque) do tabela1.dispell_oque [spellid] = (tabela1.dispell_oque [spellid] or 0) - amount end end @@ -3292,26 +3291,26 @@ atributo_misc.__sub = function (tabela1, tabela2) tabela1.cc_break = tabela1.cc_break - tabela2.cc_break - for target_name, amount in _pairs (tabela2.cc_break_targets) do + for target_name, amount in pairs (tabela2.cc_break_targets) do tabela1.cc_break_targets [target_name] = (tabela1.cc_break_targets [target_name] or 0) - amount end - for spellid, habilidade in _pairs (tabela2.cc_break_spells._ActorTable) do + for spellid, habilidade in pairs (tabela2.cc_break_spells._ActorTable) do local habilidade_tabela1 = tabela1.cc_break_spells:PegaHabilidade (spellid, true, nil, false) habilidade_tabela1.cc_break_oque = habilidade_tabela1.cc_break_oque or {} - for _spellid, amount in _pairs (habilidade.cc_break_oque) do + for _spellid, amount in pairs (habilidade.cc_break_oque) do habilidade_tabela1.cc_break_oque [_spellid] = (habilidade_tabela1.cc_break_oque [_spellid] or 0) - amount end - for target_name, amount in _pairs (habilidade.targets) do + for target_name, amount in pairs (habilidade.targets) do habilidade_tabela1.targets [target_name] = (habilidade_tabela1.targets [target_name] or 0) - amount end subtrair_keys (habilidade, habilidade_tabela1) end - for spellid, amount in _pairs (tabela2.cc_break_oque) do + for spellid, amount in pairs (tabela2.cc_break_oque) do tabela1.cc_break_oque [spellid] = (tabela1.cc_break_oque [spellid] or 0) - amount end end diff --git a/frames/window_report.lua b/frames/window_report.lua index 857569d0..9fd846b4 100644 --- a/frames/window_report.lua +++ b/frames/window_report.lua @@ -1,312 +1,270 @@ -local Loc = LibStub ("AceLocale-3.0"):GetLocale ( "Details" ) -local _detalhes = _G._detalhes -local gump = _detalhes.gump +local Loc = LibStub("AceLocale-3.0"):GetLocale("Details") + +local Details = _G._detalhes +local gump = Details.gump local _ ---lua locals -local _cstr = tostring --> lua local -local _math_ceil = math.ceil --> lua local -local _math_floor = math.floor --> lua local -local _string_len = string.len --> lua local -local _pairs = pairs --> lua local -local _tinsert = tinsert --> lua local -local _IsInRaid = IsInRaid --> lua local - -local _CreateFrame = CreateFrame --> wow api locals -local _IsInGuild = IsInGuild --> wow api locals -local _GetChannelList = GetChannelList --> wow api locals -local _UIParent = UIParent --> wow api locals - --> details API functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - function _detalhes:FastReportWindow (window) - + function Details:FastReportWindow(window) if (not DetailsReportWindow) then gump:CriaJanelaReport() DetailsReportWindow:Hide() end - - local instance = _detalhes:GetInstance (window) + + local instance = Details:GetInstance(window) if (instance) then - if (instance.atributo == 1) then - _detalhes.report_lines = 14 + Details.report_lines = 14 + elseif (instance.atributo == 2) then - _detalhes.report_lines = 6 + Details.report_lines = 6 + else - _detalhes.report_lines = max (10, instance.rows_fit_in_window) + Details.report_lines = max(10, instance.rows_fit_in_window) end - + if (IsInRaid()) then - _detalhes.report_where = "RAID" + Details.report_where = "RAID" + elseif (GetNumSubgroupMembers() > 0) then - _detalhes.report_where = "PARTY" + Details.report_where = "PARTY" + else - _detalhes.report_where = "SAY" + Details.report_where = "SAY" end - + instance:monta_relatorio() - else - _detalhes:Msg (Loc ["STRING_WINDOW_NOTFOUND"]) + Details:Msg(Loc ["STRING_WINDOW_NOTFOUND"]) end end - function _detalhes.ReportFromLatest (_, _, index) - local t = _detalhes.latest_report_table [index] - - if (t) then + function Details.ReportFromLatest(_, _, index) + local reportTable = Details.latest_report_table[index] + if (reportTable) then if (not DetailsReportWindow) then gump:CriaJanelaReport() DetailsReportWindow:Hide() end - - local id, attribute, subattribute, amt, report_where = unpack (t) - local instance = _detalhes:GetInstance (id) - _detalhes.report_lines = amt - _detalhes.report_where = report_where - + + local id, attribute, subattribute, amt, report_where = unpack(reportTable) + local instance = Details:GetInstance(id) + Details.report_lines = amt + Details.report_where = report_where + local cattribute, csubattribute = instance:GetDisplay() - instance:SetDisplay (nil, attribute, subattribute) + instance:SetDisplay(nil, attribute, subattribute) instance:monta_relatorio() - - instance:SetDisplay (nil, cattribute, csubattribute) - + instance:SetDisplay(nil, cattribute, csubattribute) GameCooltip:Hide() end end - function _detalhes:SendReportLines (lines) - if (type (lines) == "string") then + function Details:SendReportLines(lines) + if (type(lines) == "string") then lines = {lines} - elseif (type (lines) ~= "table") then - return _detalhes:NewError ("SendReportLines parameter 1 must be a table or string.") end - return _detalhes:envia_relatorio (lines, true) + return Details:envia_relatorio(lines, true) end - function _detalhes:SendReportWindow (func, _current, _inverse, _slider) - - if (type (func) ~= "function") then - return _detalhes:NewError ("SendReportWindow parameter 1 must be a function.") + function Details:SendReportWindow(func, current, inverse, slider) + if (type(func) ~= "function") then + return end - if (not _detalhes.janela_report) then - _detalhes.janela_report = gump:CriaJanelaReport() + if (not Details.janela_report) then + Details.janela_report = gump:CriaJanelaReport() end - if (_current) then - _G ["Details_Report_CB_1"]:Enable() - _G ["Details_Report_CB_1Text"]:SetTextColor (1, 1, 1, 1) + if (current) then + _G["Details_Report_CB_1"]:Enable() + _G["Details_Report_CB_1Text"]:SetTextColor(1, 1, 1, 1) else - _G ["Details_Report_CB_1"]:Disable() - _G ["Details_Report_CB_1Text"]:SetTextColor (.5, .5, .5, 1) + _G["Details_Report_CB_1"]:Disable() + _G["Details_Report_CB_1Text"]:SetTextColor(.5, .5, .5, 1) end - - if (_inverse) then - _G ["Details_Report_CB_2"]:Enable() - _G ["Details_Report_CB_2Text"]:SetTextColor (1, 1, 1, 1) + + if (inverse) then + _G["Details_Report_CB_2"]:Enable() + _G["Details_Report_CB_2Text"]:SetTextColor(1, 1, 1, 1) else - _G ["Details_Report_CB_2"]:Disable() - _G ["Details_Report_CB_2Text"]:SetTextColor (.5, .5, .5, 1) + _G["Details_Report_CB_2"]:Disable() + _G["Details_Report_CB_2Text"]:SetTextColor(.5, .5, .5, 1) end - - if (_slider) then - _detalhes.janela_report.slider:Enable() - _detalhes.janela_report.slider.lockTexture:Hide() - _detalhes.janela_report.slider.amt:Show() + + if (slider) then + Details.janela_report.slider:Enable() + Details.janela_report.slider.lockTexture:Hide() + Details.janela_report.slider.amt:Show() else - _detalhes.janela_report.slider:Disable() - _detalhes.janela_report.slider.lockTexture:Show() - _detalhes.janela_report.slider.amt:Hide() + Details.janela_report.slider:Disable() + Details.janela_report.slider.lockTexture:Show() + Details.janela_report.slider.amt:Hide() end - - if (_detalhes.janela_report.ativa) then - _detalhes.janela_report:Flash (0.2, 0.2, 0.4, true, 0, 0, "NONE") + + if (Details.janela_report.ativa) then + Details.janela_report:Flash (0.2, 0.2, 0.4, true, 0, 0, "NONE") end - - _detalhes.janela_report.ativa = true - _detalhes.janela_report.enviar:SetScript ("OnClick", function() func (_G ["Details_Report_CB_1"]:GetChecked(), _G ["Details_Report_CB_2"]:GetChecked(), _detalhes.report_lines) end) - - Details.FadeHandler.Fader (_detalhes.janela_report, 0) - + + Details.janela_report.ativa = true + Details.janela_report.enviar:SetScript("OnClick", function() func(_G["Details_Report_CB_1"]:GetChecked(), _G["Details_Report_CB_2"]:GetChecked(), Details.report_lines) end) + + Details.FadeHandler.Fader(Details.janela_report, 0) return true end - - function _detalhes:SendReportTextWindow (lines) - - if (not _detalhes.copypasteframe) then - _detalhes.copypasteframe = CreateFrame ("frame", "DetailsCopyPasteFrame2", UIParent,"BackdropTemplate") - _detalhes.copypasteframe:SetFrameStrata ("TOOLTIP") - _detalhes.copypasteframe:SetPoint ("CENTER", UIParent, "CENTER", 0, 50) - tinsert (UISpecialFrames, "DetailsCopyPasteFrame2") - _detalhes.copypasteframe:SetSize (400, 400) - _detalhes.copypasteframe:Hide() - - DetailsFramework:ApplyStandardBackdrop (_detalhes.copypasteframe) - DetailsFramework:CreateTitleBar (_detalhes.copypasteframe, "Export Text") - - local editBox = CreateFrame ("editbox", nil, _detalhes.copypasteframe) - editBox:SetPoint ("topleft", _detalhes.copypasteframe, "topleft", 2, -26) - editBox:SetPoint ("bottomright", _detalhes.copypasteframe, "bottomright", -2, 2) - editBox:SetAutoFocus (false) - editBox:SetMultiLine (true) - editBox:SetFontObject ("GameFontHighlightSmall") - - editBox:SetScript ("OnEditFocusGained", function() editBox:HighlightText() end) - editBox:SetScript ("OnEditFocusLost", function() _detalhes.copypasteframe:Hide() end) - editBox:SetScript ("OnEscapePressed", function() editBox:SetFocus (false); _detalhes.copypasteframe:Hide() end) - editBox:SetScript ("OnChar", function() editBox:SetFocus (false); _detalhes.copypasteframe:Hide() end) - - _detalhes.copypasteframe.EditBox = editBox + + function Details:SendReportTextWindow(lines) + if (not Details.copypasteframe) then + Details.copypasteframe = CreateFrame("frame", "DetailsCopyPasteFrame2", UIParent, "BackdropTemplate") + Details.copypasteframe:SetFrameStrata("TOOLTIP") + Details.copypasteframe:SetPoint("CENTER", UIParent, "CENTER", 0, 50) + tinsert(UISpecialFrames, "DetailsCopyPasteFrame2") + Details.copypasteframe:SetSize(400, 400) + Details.copypasteframe:Hide() + + DetailsFramework:ApplyStandardBackdrop(Details.copypasteframe) + DetailsFramework:CreateTitleBar(Details.copypasteframe, "Export Text") + + local editBox = CreateFrame("editbox", nil, Details.copypasteframe) + editBox:SetPoint("topleft", Details.copypasteframe, "topleft", 2, -26) + editBox:SetPoint("bottomright", Details.copypasteframe, "bottomright", -2, 2) + editBox:SetAutoFocus(false) + editBox:SetMultiLine(true) + editBox:SetFontObject("GameFontHighlightSmall") + + editBox:SetScript("OnEditFocusGained", function() editBox:HighlightText() end) + editBox:SetScript("OnEditFocusLost", function() Details.copypasteframe:Hide() end) + editBox:SetScript("OnEscapePressed", function() editBox:SetFocus(false); Details.copypasteframe:Hide() end) + editBox:SetScript("OnChar", function() editBox:SetFocus(false); Details.copypasteframe:Hide() end) + + Details.copypasteframe.EditBox = editBox end - - local s = "" - for _, line in ipairs (lines) do - s = s .. line .. "\n" + + local reportString = "" + for _, line in ipairs(lines) do + reportString = reportString .. line .. "\n" end - - _detalhes.copypasteframe:Show() - _detalhes.copypasteframe.EditBox:SetText (s) - _detalhes.copypasteframe.EditBox:HighlightText() - _detalhes.copypasteframe.EditBox:SetFocus (true) + + Details.copypasteframe:Show() + Details.copypasteframe.EditBox:SetText(reportString) + Details.copypasteframe.EditBox:HighlightText() + Details.copypasteframe.EditBox:SetFocus(true) end - --> internal details report functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - - function _detalhes:Reportar (param2, options, arg3, id) - + function Details:Reportar(param2, options, arg3, id) GameCooltip2:Hide() - - if (not _detalhes.janela_report) then - _detalhes.janela_report = gump:CriaJanelaReport() + + if (not Details.janela_report) then + Details.janela_report = gump:CriaJanelaReport() end - + if (options and options.meu_id) then self = options end - - if (type (param2) == "string") then + + if (type(param2) == "string") then id = param2 end - if (_detalhes.last_report_id and id and _detalhes.last_report_id == id) then - _detalhes.last_report_id = nil - _detalhes.janela_report.fechar:Click() + if (Details.last_report_id and id and Details.last_report_id == id) then + Details.last_report_id = nil + Details.janela_report.fechar:Click() return end - - _detalhes.last_report_id = id - - --> trabalha com as op��es: + + Details.last_report_id = id + if (options and options._no_current) then - _G ["Details_Report_CB_1"]:Disable() - _G ["Details_Report_CB_1Text"]:SetTextColor (.5, .5, .5, 1) + _G["Details_Report_CB_1"]:Disable() + _G["Details_Report_CB_1Text"]:SetTextColor(.5, .5, .5, 1) + else - _G ["Details_Report_CB_1"]:Enable() - _G ["Details_Report_CB_1Text"]:SetTextColor (1, 1, 1, 1) + _G["Details_Report_CB_1"]:Enable() + _G["Details_Report_CB_1Text"]:SetTextColor(1, 1, 1, 1) end - + if (options and options._no_inverse) then - _G ["Details_Report_CB_2"]:Disable() - _G ["Details_Report_CB_2Text"]:SetTextColor (.5, .5, .5, 1) + _G["Details_Report_CB_2"]:Disable() + _G["Details_Report_CB_2Text"]:SetTextColor(.5, .5, .5, 1) else - _G ["Details_Report_CB_2"]:Enable() - _G ["Details_Report_CB_2Text"]:SetTextColor (1, 1, 1, 1) + _G["Details_Report_CB_2"]:Enable() + _G["Details_Report_CB_2Text"]:SetTextColor(1, 1, 1, 1) end - - _detalhes.janela_report.slider:Enable() - _detalhes.janela_report.slider.lockTexture:Hide() - _detalhes.janela_report.slider.amt:Show() - + + Details.janela_report.slider:Enable() + Details.janela_report.slider.lockTexture:Hide() + Details.janela_report.slider.amt:Show() + if (options) then - _detalhes.janela_report.enviar:SetScript ("OnClick", function() self:monta_relatorio (param2, options._custom) end) + Details.janela_report.enviar:SetScript("OnClick", function() self:monta_relatorio(param2, options._custom) end) else - _detalhes.janela_report.enviar:SetScript ("OnClick", function() self:monta_relatorio (param2) end) + Details.janela_report.enviar:SetScript("OnClick", function() self:monta_relatorio(param2) end) end - if (_detalhes.janela_report.ativa) then - _detalhes.janela_report:Flash (0.2, 0.2, 0.4, true, 0, 0, "NONE") + if (Details.janela_report.ativa) then + Details.janela_report:Flash (0.2, 0.2, 0.4, true, 0, 0, "NONE") end - - _detalhes.janela_report.ativa = true - Details.FadeHandler.Fader (_detalhes.janela_report, 0) + + Details.janela_report.ativa = true + Details.FadeHandler.Fader(Details.janela_report, 0) end - ---> build report frame gump ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---> script - local savepos = function (self) - local xofs, yofs = self:GetCenter() +--build report frame gump ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--script + local savepos = function(self) + local xofs, yofs = self:GetCenter() local scale = self:GetEffectiveScale() local UIscale = UIParent:GetScale() xofs = xofs * scale - GetScreenWidth() * UIscale / 2 yofs = yofs * scale - GetScreenHeight() * UIscale / 2 local x = xofs / UIscale local y = yofs / UIscale - _detalhes.report_pos [1] = x - _detalhes.report_pos [2] = y + Details.report_pos[1] = x + Details.report_pos[2] = y end - local restorepos = function (self) - local x, y = _detalhes.report_pos [1], _detalhes.report_pos [2] - local scale = self:GetEffectiveScale() + + local restorepos = function(self) + local x, y = Details.report_pos[1], Details.report_pos[2] + local scale = self:GetEffectiveScale() local UIscale = UIParent:GetScale() x = x * UIscale / scale y = y * UIscale / scale self:ClearAllPoints() - self:SetPoint ("center", UIParent, "center", x, y) - end - local function seta_scripts (este_gump) - --> Janela - este_gump:SetScript ("OnMouseDown", - function (self, botao) - if (botao == "LeftButton") then - self:StartMoving() - self.isMoving = true - elseif (botao == "RightButton") then - if (self.isMoving) then - self:StopMovingOrSizing() - savepos (self) - self.isMoving = false - end - self:Hide() - end - end) - - este_gump:SetScript ("OnMouseUp", - function (self) - if (self.isMoving) then - self:StopMovingOrSizing() - savepos (self) - self.isMoving = false - end - end) + self:SetPoint("center", UIParent, "center", x, y) end ---> dropdown menus + local function setScripts(este_gump) + --Janela + este_gump:SetScript("OnMouseDown", function(self, botao) + if (botao == "LeftButton") then + self:StartMoving() + self.isMoving = true ---[[ -Emote: 255 251 255 -Yell: 255 63 64 -Guild Chat: 64 251 64 -Officer Chat: 64 189 64 -Achievement: 255 251 0 -Whisper: 255 126 255 -RealID: 0 251 246 -Party: 170 167 255 -Party Lead: 118 197 255 -Raid: 255 125 0 -Raid Warning: 255 71 0 -Raid Lead: 255 71 9 -BG Leader: 255 216 183 -General/Trade: 255 189 192 ---]] + elseif (botao == "RightButton") then + if (self.isMoving) then + self:StopMovingOrSizing() + savepos(self) + self.isMoving = false + end + self:Hide() + end + end) + este_gump:SetScript("OnMouseUp", function(self) + if (self.isMoving) then + self:StopMovingOrSizing() + savepos (self) + self.isMoving = false + end + end) + end -local icons_and_colors = { +local iconsAndColors = { ["PARTY"] = {icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.53125, 0.7265625, 0.078125, 0.40625}, color = {0.66, 0.65, 1}}, ["RAID"] = {icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.53125, 0.7265625, 0.078125, 0.40625}, color = {1, 0.49, 0}}, ["GUILD"] = {icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.8046875, 0.96875, 0.125, 0.390625}, color = {0.25, 0.98, 0.25}}, @@ -315,837 +273,700 @@ local icons_and_colors = { ["SAY"] = {icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0390625, 0.203125, 0.09375, 0.375}, color = {1, 1, 1}}, ["COPY"] = {icon = [[Interface\Buttons\UI-GuildButton-PublicNote-Disabled]], coords = {0, 1, 0, 1}, color = {1, 1, 1}}, } -function _detalhes.GetReportIconAndColor (report_where) - local key = report_where:gsub ((".*|"), "") - return icons_and_colors [key] + +function Details.GetReportIconAndColor(reportWhere) + local key = reportWhere:gsub((".*|"), "") + return iconsAndColors[key] end -local function cria_drop_down (este_gump) - +local createDropdown = function(thisFrame) local iconsize = {16, 16} local baseChannels = { {Loc ["STRING_REPORTFRAME_PARTY"], "PARTY", function() return GetNumSubgroupMembers() > 0 end, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.53125, 0.7265625, 0.078125, 0.40625}, color = {0.66, 0.65, 1}}}, - {Loc ["STRING_REPORTFRAME_RAID"], "RAID", _IsInRaid, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.53125, 0.7265625, 0.078125, 0.40625}, color = {1, 0.49, 0}}}, - {Loc ["STRING_REPORTFRAME_GUILD"], "GUILD", _IsInGuild, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.8046875, 0.96875, 0.125, 0.390625}, color = {0.25, 0.98, 0.25}}}, - {Loc ["STRING_REPORTFRAME_OFFICERS"], "OFFICER", _IsInGuild, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.8046875, 0.96875, 0.125, 0.390625}, color = {0.25, 0.74, 0.25}}}, + {Loc ["STRING_REPORTFRAME_RAID"], "RAID", IsInRaid, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.53125, 0.7265625, 0.078125, 0.40625}, color = {1, 0.49, 0}}}, + {Loc ["STRING_REPORTFRAME_GUILD"], "GUILD", IsInGuild, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.8046875, 0.96875, 0.125, 0.390625}, color = {0.25, 0.98, 0.25}}}, + {Loc ["STRING_REPORTFRAME_OFFICERS"], "OFFICER", IsInGuild, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.8046875, 0.96875, 0.125, 0.390625}, color = {0.25, 0.74, 0.25}}}, {Loc ["STRING_REPORTFRAME_WHISPER"], "WHISPER", nil, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0546875, 0.1953125, 0.625, 0.890625}, color = {1, 0.49, 1}}}, - {Loc ["STRING_REPORTFRAME_WHISPERTARGET"], "WHISPER2", nil, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0546875, 0.1953125, 0.625, 0.890625}, color = {1, 0.49, 1}}}, + {Loc ["STRING_REPORTFRAME_WHISPERTARGET"], "WHISPER2", nil, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0546875, 0.1953125, 0.625, 0.890625}, color = {1, 0.49, 1}}}, {Loc ["STRING_REPORTFRAME_SAY"], "SAY", IsInInstance, {iconsize = iconsize, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], coords = {0.0390625, 0.203125, 0.09375, 0.375}, color = {1, 1, 1}}}, {Loc ["STRING_REPORTFRAME_COPY"], "COPY", nil, {iconsize = iconsize, icon = [[Interface\Buttons\UI-GuildButton-PublicNote-Disabled]], coords = {0, 1, 0, 1}, color = {1, 1, 1}}}, } - - local on_click = function (self, fixedParam, selectedOutput) - _detalhes.report_where = selectedOutput - end - - local build_list = function() - local reportChannelsTable = {} - - for index, channelInfo in ipairs (baseChannels) do - if (not channelInfo [3] or channelInfo[3]()) then - reportChannelsTable[#reportChannelsTable + 1] = {iconsize = channelInfo [4].iconsize, value = channelInfo [2], label = channelInfo [1], onclick = on_click, icon = channelInfo [4].icon, texcoord = channelInfo [4].coords, iconcolor = channelInfo [4].color} - end - end - - local channels = {_GetChannelList()} --> coloca o resultado em uma tabela .. {id1, canal1, id2, canal2} - --09/august/2018: GetChannelList passed to return 3 values for each channel instead of 2 - for i = 1, #channels, 3 do --> total de canais - reportChannelsTable [#reportChannelsTable + 1] = {iconsize = iconsize, value = "CHANNEL|"..channels [i+1], label = channels [i]..". "..channels [i+1], onclick = on_click, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], texcoord = {0.3046875, 0.4453125, 0.109375, 0.390625}, iconcolor = {149/255, 112/255, 112/255}} - end - - if (not DetailsFramework.IsTimewalkWoW()) then - local _, numBNetOnline = BNGetNumFriends() - for i = 1, numBNetOnline do - local accountInfo = C_BattleNet.GetFriendAccountInfo(i) - local gameAccountInfo = accountInfo and accountInfo.gameAccountInfo - - if (gameAccountInfo) then - local isOnline = gameAccountInfo.isOnline - if (isOnline) then - local bTag = accountInfo.battleTag - local bTagNoNumber = bTag:gsub("#.*", "") - reportChannelsTable[#reportChannelsTable + 1] = {iconsize = iconsize, value = "REALID|" .. accountInfo.bnetAccountID, label = bTagNoNumber, onclick = on_click, icon = [[Interface\FriendsFrame\Battlenet-Battleneticon]], texcoord = {0.125, 0.875, 0.125, 0.875}, iconcolor = {1, 1, 1}} - end - end - end - end - - return reportChannelsTable - end - este_gump.dropdown_func = build_list - - local select_output = gump:NewDropDown (este_gump, _, "$parentOutputDropdown", "select", 185, 20, build_list, 1) - select_output:SetPoint ("topleft", este_gump, "topleft", 107, -55) - este_gump.select = select_output.widget - este_gump.dropdown = select_output - - function select_output:CheckValid() - - local last_selected = _detalhes.report_where - local check_func - for i, t in ipairs (baseChannels) do - if (t[2] == last_selected) then - check_func = t[3] - break - end - end - - if (check_func) then - local is_shown = check_func() - if (is_shown) then - select_output:Select (last_selected) - else - if (IsInRaid()) then - select_output:Select ("RAID") - elseif (GetNumSubgroupMembers() > 0) then - select_output:Select ("PARTY") - elseif (IsInGuild()) then - select_output:Select ("GUILD") - else - select_output:Select ("SAY") - end - end - else - select_output:Select (last_selected) - end - end - - select_output:CheckValid() + local onClick = function(self, fixedParam, selectedOutput) + Details.report_where = selectedOutput end ---> slider + local buildList = function() + local reportChannelsTable = {} - local function cria_slider (este_gump) + for index, channelInfo in ipairs(baseChannels) do + if (not channelInfo[3] or channelInfo[3]()) then + reportChannelsTable[#reportChannelsTable + 1] = {iconsize = channelInfo[4].iconsize, value = channelInfo[2], label = channelInfo[1], onclick = onClick, icon = channelInfo[4].icon, texcoord = channelInfo[4].coords, iconcolor = channelInfo[4].color} + end + end - este_gump.linhas_amt = este_gump:CreateFontString (nil, "OVERLAY", "GameFontHighlight") - este_gump.linhas_amt:SetText (Loc ["STRING_REPORTFRAME_LINES"]) - este_gump.linhas_amt:SetTextColor (.9, .9, .9, 1) - este_gump.linhas_amt:SetPoint ("bottomleft", este_gump, "bottomleft", 58, 12) - _detalhes:SetFontSize (este_gump.linhas_amt, 10) - - local slider = _CreateFrame ("Slider", "Details_Report_Slider", este_gump,"BackdropTemplate") - este_gump.slider = slider - slider:SetPoint ("bottomleft", este_gump, "bottomleft", 58, -7) - - slider.thumb = slider:CreateTexture (nil, "artwork") - slider.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob") - slider.thumb:SetSize (30, 24) - slider.thumb:SetAlpha (0.7) - - local lockTexture = slider:CreateTexture (nil, "overlay") - lockTexture:SetPoint ("center", slider.thumb, "center", -1, -1) - lockTexture:SetTexture ("Interface\\Buttons\\CancelButton-Up") - lockTexture:SetWidth (29) - lockTexture:SetHeight (24) + local channels = {GetChannelList()} --> coloca o resultado em uma tabela .. {id1, canal1, id2, canal2} + --09/august/2018: GetChannelList passed to return 3 values for each channel instead of 2 + + for i = 1, #channels, 3 do --> total de canais + reportChannelsTable[#reportChannelsTable + 1] = {iconsize = iconsize, value = "CHANNEL|" .. channels[i+1], label = channels[i] .. ". " .. channels[i+1], onclick = onClick, icon = [[Interface\FriendsFrame\UI-Toast-ToastIcons]], texcoord = {0.3046875, 0.4453125, 0.109375, 0.390625}, iconcolor = {149/255, 112/255, 112/255}} + end + + if (not DetailsFramework.IsTimewalkWoW()) then + local _, numBNetOnline = BNGetNumFriends() + for i = 1, numBNetOnline do + local accountInfo = C_BattleNet.GetFriendAccountInfo(i) + local gameAccountInfo = accountInfo and accountInfo.gameAccountInfo + + if (gameAccountInfo) then + local isOnline = gameAccountInfo.isOnline + if (isOnline) then + local bTag = accountInfo.battleTag + local bTagNoNumber = bTag:gsub("#.*", "") + reportChannelsTable[#reportChannelsTable + 1] = {iconsize = iconsize, value = "REALID|" .. accountInfo.bnetAccountID, label = bTagNoNumber, onclick = onClick, icon = [[Interface\FriendsFrame\Battlenet-Battleneticon]], texcoord = {0.125, 0.875, 0.125, 0.875}, iconcolor = {1, 1, 1}} + end + end + end + end + + return reportChannelsTable + end + + thisFrame.dropdown_func = buildList + + local selectOutputChannel = gump:NewDropDown(thisFrame, _, "$parentOutputDropdown", "select", 185, 20, buildList, 1) + selectOutputChannel:SetPoint("topleft", thisFrame, "topleft", 107, -55) + thisFrame.select = selectOutputChannel.widget + thisFrame.dropdown = selectOutputChannel + + function selectOutputChannel:CheckValid() + local lastSelected = Details.report_where + local checkFunc + + for i, channelTable in ipairs(baseChannels) do + if (channelTable[2] == lastSelected) then + checkFunc = channelTable[3] + break + end + end + + if (checkFunc) then + local isShown = checkFunc() + if (isShown) then + selectOutputChannel:Select(lastSelected) + else + if (IsInRaid()) then + selectOutputChannel:Select("RAID") + + elseif (GetNumSubgroupMembers() > 0) then + selectOutputChannel:Select("PARTY") + + elseif (IsInGuild()) then + selectOutputChannel:Select("GUILD") + + else + selectOutputChannel:Select("SAY") + end + end + else + selectOutputChannel:Select(lastSelected) + end + end + selectOutputChannel:CheckValid() + end + +--slider + local createSlider = function(thisFrame) + thisFrame.linhas_amt = thisFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") + thisFrame.linhas_amt:SetText(Loc ["STRING_REPORTFRAME_LINES"]) + thisFrame.linhas_amt:SetTextColor(.9, .9, .9, 1) + thisFrame.linhas_amt:SetPoint("bottomleft", thisFrame, "bottomleft", 58, 12) + Details:SetFontSize(thisFrame.linhas_amt, 10) + + local slider = CreateFrame("Slider", "Details_Report_Slider", thisFrame, "BackdropTemplate") + thisFrame.slider = slider + slider:SetPoint("bottomleft", thisFrame, "bottomleft", 58, -7) + + slider.thumb = slider:CreateTexture(nil, "artwork") + slider.thumb:SetTexture("Interface\\Buttons\\UI-ScrollBar-Knob") + slider.thumb:SetSize(30, 24) + slider.thumb:SetAlpha(0.7) + + local lockTexture = slider:CreateTexture(nil, "overlay") + lockTexture:SetPoint("center", slider.thumb, "center", -1, -1) + lockTexture:SetTexture("Interface\\Buttons\\CancelButton-Up") + lockTexture:SetWidth(29) + lockTexture:SetHeight(24) lockTexture:Hide() slider.lockTexture = lockTexture - slider:SetThumbTexture (slider.thumb) --depois - slider:SetOrientation ("HORIZONTAL") - slider:SetMinMaxValues (1.0, 25.0) - slider:SetValueStep (1.0) - slider:SetWidth (232) - slider:SetHeight (20) + slider:SetThumbTexture(slider.thumb) + slider:SetOrientation("HORIZONTAL") + slider:SetMinMaxValues(1.0, 25.0) + slider:SetValueStep(1.0) + slider:SetWidth(232) + slider:SetHeight(20) - local last_value = _detalhes.report_lines or 5 - slider:SetValue (math.floor (last_value)) - - slider.amt = slider:CreateFontString (nil, "OVERLAY", "GameFontHighlightSmall") + local lastValue = Details.report_lines or 5 + slider:SetValue(floor(lastValue)) + + slider.amt = slider:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") local amt = slider:GetValue() if (amt < 10) then - amt = "0"..amt + amt = "0" .. amt end - slider.amt:SetText (amt) - slider.amt:SetTextColor (.8, .8, .8, 1) - - slider.amt:SetPoint ("center", slider.thumb, "center") - - slider:SetScript ("OnValueChanged", function (self) - local amt = math.floor (self:GetValue()) - _detalhes.report_lines = amt + + slider.amt:SetText(amt) + slider.amt:SetTextColor(.8, .8, .8, 1) + slider.amt:SetPoint("center", slider.thumb, "center") + + slider:SetScript("OnValueChanged", function(self) + local amt = math.floor(self:GetValue()) + Details.report_lines = amt if (amt < 10) then - amt = "0"..amt + amt = "0" .. amt end - self.amt:SetText (amt) - end) - - slider:SetScript ("OnEnter", function (self) - slider.thumb:SetAlpha (1) + self.amt:SetText(amt) end) - - slider:SetScript ("OnLeave", function (self) - slider.thumb:SetAlpha (0.7) + + slider:SetScript("OnEnter", function(self) + slider.thumb:SetAlpha(1) + end) + + slider:SetScript("OnLeave", function(self) + slider.thumb:SetAlpha(0.7) end) - end ---> whisper taget field +--whisper taget field + local createWisperField = function(thisFrame) + thisFrame.wisp_who = thisFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") + thisFrame.wisp_who:SetText(Loc ["STRING_REPORTFRAME_WHISPER"] .. ":") + thisFrame.wisp_who:SetTextColor(1, 1, 1, 1) + thisFrame.wisp_who:SetPoint("topleft", thisFrame.select, "topleft", 14, -30) - local function cria_wisper_field (este_gump) - - este_gump.wisp_who = este_gump:CreateFontString (nil, "OVERLAY", "GameFontHighlight") - este_gump.wisp_who:SetText (Loc ["STRING_REPORTFRAME_WHISPER"] .. ":") - este_gump.wisp_who:SetTextColor (1, 1, 1, 1) - - este_gump.wisp_who:SetPoint ("topleft", este_gump.select, "topleft", 14, -30) - - _detalhes:SetFontSize (este_gump.wisp_who, 10) + Details:SetFontSize(thisFrame.wisp_who, 10) --editbox - local editbox = _CreateFrame ("EditBox", nil, este_gump,"BackdropTemplate") - este_gump.editbox = editbox - - editbox:SetAutoFocus (false) - editbox:SetFontObject ("GameFontHighlightSmall") - - editbox:SetPoint ("TOPLEFT", este_gump.select, "TOPLEFT", 64, -28) - - editbox:SetHeight (14) - editbox:SetWidth (120) - editbox:SetJustifyH ("center") + local editbox = CreateFrame("EditBox", nil, thisFrame, "BackdropTemplate") + thisFrame.editbox = editbox + + editbox:SetAutoFocus(false) + editbox:SetFontObject("GameFontHighlightSmall") + + editbox:SetPoint("TOPLEFT", thisFrame.select, "TOPLEFT", 64, -28) + + editbox:SetHeight(14) + editbox:SetWidth(120) + editbox:SetJustifyH("center") editbox:EnableMouse(true) - editbox:SetBackdrop ({ + editbox:SetBackdrop({ bgFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, edgeSize = 1, tileSize = 5, }) editbox:SetBackdropColor(0, 0, 0, 0.0) editbox:SetBackdropBorderColor(0.0, 0.0, 0.0, 0.0) - - local last_value = _detalhes.report_to_who or "" - editbox:SetText (last_value) + + local lastValue = Details.report_to_who or "" + editbox:SetText(lastValue) editbox.perdeu_foco = nil editbox.focus = false - - editbox:SetScript ("OnEnterPressed", function () - local texto = _detalhes:trim (editbox:GetText()) - if (_string_len (texto) > 0) then - _detalhes.report_to_who = texto - editbox:AddHistoryLine (texto) - editbox:SetText (texto) - else - _detalhes.report_to_who = "" - editbox:SetText ("") - end + + editbox:SetScript("OnEnterPressed", function() + local texto = Details:trim(editbox:GetText()) + if (string.len(texto) > 0) then + Details.report_to_who = texto + editbox:AddHistoryLine(texto) + editbox:SetText(texto) + else + Details.report_to_who = "" + editbox:SetText("") + end + editbox.perdeu_foco = true --> isso aqui pra quando estiver editando e clicar em outra caixa editbox:ClearFocus() end) - - editbox:SetScript ("OnEscapePressed", function() - editbox:SetText("") - _detalhes.report_to_who = "" + + editbox:SetScript("OnEscapePressed", function() + editbox:SetText("") + Details.report_to_who = "" editbox.perdeu_foco = true - editbox:ClearFocus() - end) - - editbox:SetScript ("OnEnter", function() - editbox.mouse_over = true - --editbox:SetBackdropColor(0.1, 0.1, 0.1, 0.7) - if (editbox:GetText() == "" and not editbox.focus) then - editbox:SetText (Loc ["STRING_REPORTFRAME_INSERTNAME"]) - end - end) - - editbox:SetScript ("OnLeave", function() - editbox.mouse_over = false - --editbox:SetBackdropColor(0.0, 0.0, 0.0, 0.0) - if (not editbox:HasFocus()) then - if (editbox:GetText() == Loc ["STRING_REPORTFRAME_INSERTNAME"]) then - editbox:SetText("") - end - end + editbox:ClearFocus() end) - editbox:SetScript ("OnEditFocusGained", function() + editbox:SetScript("OnEnter", function() + editbox.mouse_over = true + if (editbox:GetText() == "" and not editbox.focus) then + editbox:SetText(Loc ["STRING_REPORTFRAME_INSERTNAME"]) + end + end) + + editbox:SetScript("OnLeave", function() + editbox.mouse_over = false + if (not editbox:HasFocus()) then + if (editbox:GetText() == Loc ["STRING_REPORTFRAME_INSERTNAME"]) then + editbox:SetText("") + end + end + end) + + editbox:SetScript("OnEditFocusGained", function() if (editbox:GetText() == Loc ["STRING_REPORTFRAME_INSERTNAME"]) then - editbox:SetText("") + editbox:SetText("") end - + if (editbox:GetText() ~= "") then - --> selecionar todo o texto - editbox:HighlightText (0, editbox:GetNumLetters()) + editbox:HighlightText(0, editbox:GetNumLetters()) end - + editbox.focus = true end) - - editbox:SetScript ("OnEditFocusLost", function() + + editbox:SetScript("OnEditFocusLost", function() if (editbox.perdeu_foco == nil) then - local texto = _detalhes:trim (editbox:GetText()) - if (_string_len (texto) > 0) then - _detalhes.report_to_who = texto + local text = Details:trim(editbox:GetText()) + + if (string.len(text) > 0) then + Details.report_to_who = text else - _detalhes.report_to_who = "" - editbox:SetText ("") - end + Details.report_to_who = "" + editbox:SetText("") + end else editbox.perdeu_foco = nil end - + editbox.focus = false end) end ---> both check buttons - - function cria_check_buttons (este_gump) - local checkbox = _CreateFrame ("CheckButton", "Details_Report_CB_1", este_gump, "ChatConfigCheckButtonTemplate,BackdropTemplate") - checkbox:SetPoint ("topleft", este_gump.wisp_who, "bottomleft", -25, -4) - _G [checkbox:GetName().."Text"]:SetText (Loc ["STRING_REPORTFRAME_CURRENT"]) - _detalhes:SetFontSize (_G [checkbox:GetName().."Text"], 10) +--both check buttons + local createCheckButtons = function(thisFrame) + local checkbox = CreateFrame("CheckButton", "Details_Report_CB_1", thisFrame, "ChatConfigCheckButtonTemplate,BackdropTemplate") + checkbox:SetPoint("topleft", thisFrame.wisp_who, "bottomleft", -25, -4) + _G[checkbox:GetName().."Text"]:SetText(Loc ["STRING_REPORTFRAME_CURRENT"]) + Details:SetFontSize(_G[checkbox:GetName().."Text"], 10) checkbox.tooltip = Loc ["STRING_REPORTFRAME_CURRENTINFO"] - checkbox:SetHitRectInsets (0, -35, 0, 0) - - local checkbox2 = _CreateFrame ("CheckButton", "Details_Report_CB_2", este_gump, "ChatConfigCheckButtonTemplate,BackdropTemplate") - checkbox2:SetPoint ("topleft", este_gump.wisp_who, "bottomleft", 35, -4) - _G [checkbox2:GetName().."Text"]:SetText (Loc ["STRING_REPORTFRAME_REVERT"]) - _detalhes:SetFontSize (_G [checkbox2:GetName().."Text"], 10) + checkbox:SetHitRectInsets(0, -35, 0, 0) + + local checkbox2 = CreateFrame("CheckButton", "Details_Report_CB_2", thisFrame, "ChatConfigCheckButtonTemplate,BackdropTemplate") + checkbox2:SetPoint("topleft", thisFrame.wisp_who, "bottomleft", 35, -4) + _G[checkbox2:GetName().."Text"]:SetText(Loc ["STRING_REPORTFRAME_REVERT"]) + Details:SetFontSize(_G[checkbox2:GetName().."Text"], 10) checkbox2.tooltip = Loc ["STRING_REPORTFRAME_REVERTINFO"] - checkbox2:SetHitRectInsets (0, -35, 0, 0) + checkbox2:SetHitRectInsets(0, -35, 0, 0) end ---> frame creation function - - - local elvui_skin = function() - +--frame creation function + local defaultSkin = function() local window = DetailsReportWindow - local anchorX = 10 - - local b_onenter = function (self) - self:SetBackdropColor (0.4, 0.4, 0.4, 0.6) - self.icon:SetBlendMode ("ADD") - _detalhes:SetFontColor (self.text, "yellow") - end - local b_onleave = function (self) - self:SetBackdropColor (0, 0, 0, 0.3) - self.icon:SetBlendMode ("BLEND") - _detalhes:SetFontColor (self.text, "white") - end - - window.last_reported_label:SetPoint ("topleft", window, "topleft", 5, -28) - gump:SetFontSize (window.last_reported_label, 10) - - for i = 1, 9 do --window.max_last_buttons - local b = window.recently_report_buttons [i] - - b:SetSize (150, 16) - b:SetPoint ("topleft", window, "topleft", 5, -28 + (i*17*-1)) - b:Show() - b:SetBackdrop ({bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16, - insets = {left = 0, right = 0, top = 0, bottom = 0}}) - b:SetBackdropColor (0, 0, 0, 0.3) - b.text:SetTextColor (1, 1, 1, 1) - _detalhes:SetFontSize (b.text, 9) - - b:SetScript ("OnEnter", b_onenter) - b:SetScript ("OnLeave", b_onleave) + + local recentReportButtonOnEnter = function(self) + self:SetBackdropColor(0.4, 0.4, 0.4, 0.6) + self.icon:SetBlendMode("ADD") + Details:SetFontColor(self.text, "yellow") end - window.fechar:SetWidth (20) - window.fechar:SetHeight (20) - window.fechar:SetPoint ("TOPRIGHT", window, "TOPRIGHT", 0, -3) + local recentReportButtonOnLeave = function(self) + self:SetBackdropColor(0, 0, 0, 0.3) + self.icon:SetBlendMode("BLEND") + Details:SetFontColor(self.text, "white") + end + + window.last_reported_label:SetPoint("topleft", window, "topleft", 5, -28) + gump:SetFontSize(window.last_reported_label, 10) + + for i = 1, 9 do --window.max_last_buttons + local recentReportButton = window.recently_report_buttons[i] + + recentReportButton:SetSize(150, 16) + recentReportButton:SetPoint("topleft", window, "topleft", 5, -28 + (i * 17 * -1)) + recentReportButton:Show() + recentReportButton:SetBackdrop({bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16, + insets = {left = 0, right = 0, top = 0, bottom = 0}}) + recentReportButton:SetBackdropColor(0, 0, 0, 0.3) + recentReportButton.text:SetTextColor(1, 1, 1, 1) + Details:SetFontSize(recentReportButton.text, 9) + + recentReportButton:SetScript("OnEnter", recentReportButtonOnEnter) + recentReportButton:SetScript("OnLeave", recentReportButtonOnLeave) + end + + window.fechar:SetWidth(20) + window.fechar:SetHeight(20) + window.fechar:SetPoint("TOPRIGHT", window, "TOPRIGHT", 0, -3) window.fechar:Show() window.fechar:GetNormalTexture():SetDesaturated (true) - local b = window.recently_report_buttons [10] - b:Hide() - + local recentReportButton = window.recently_report_buttons[10] + recentReportButton:Hide() + window.dropdown:ClearAllPoints() - window.dropdown:SetWidth (155) - window.dropdown:SetPoint ("topleft", window, "topleft", anchorX, -30) - window.dropdown:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, + window.dropdown:SetWidth(155) + window.dropdown:SetPoint("topleft", window, "topleft", anchorX, -30) + window.dropdown:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}}) window.dropdown:SetBackdropBorderColor (0, 0, 0, 0.5) - window.dropdown:SetBackdropColor (0, 0, 0, 0.1) - + window.dropdown:SetBackdropColor(0, 0, 0, 0.1) + window.wisp_who:ClearAllPoints() window.editbox:ClearAllPoints() - window.wisp_who:SetPoint ("topleft", window.dropdown.widget, "bottomleft", 0, -10) - window.editbox:SetPoint ("topleft", window.wisp_who, "bottomleft", 0, -3) - window.editbox:SetWidth (155) - window.editbox:SetHeight (20) - window.editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, + window.wisp_who:SetPoint("topleft", window.dropdown.widget, "bottomleft", 0, -10) + window.editbox:SetPoint("topleft", window.wisp_who, "bottomleft", 0, -3) + window.editbox:SetWidth(155) + window.editbox:SetHeight(20) + window.editbox:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}}) window.editbox:SetBackdropBorderColor (0, 0, 0, 0.5) - window.editbox:SetBackdropColor (0, 0, 0, 0.3) - + window.editbox:SetBackdropColor(0, 0, 0, 0.3) + window.linhas_amt:ClearAllPoints() - window.linhas_amt:SetPoint ("topleft", window.editbox, "bottomleft", 0, -10) + window.linhas_amt:SetPoint("topleft", window.editbox, "bottomleft", 0, -10) window.slider:ClearAllPoints() - window.slider:SetWidth (155) - window.slider:SetPoint ("topleft", window.linhas_amt, "bottomleft", 0, -3) - window.slider:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, + window.slider:SetWidth(155) + window.slider:SetPoint("topleft", window.linhas_amt, "bottomleft", 0, -3) + window.slider:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}}) window.slider:SetBackdropBorderColor (0, 0, 0, 0.5) - window.slider:SetBackdropColor (0, 0, 0, 0.3) - - window.slider.thumb:SetTexture ([[Interface\AddOns\Details\images\icons2]]) - window.slider.thumb:SetTexCoord (482/512, 492/512, 104/512, 120/512) - window.slider.thumb:SetSize (16, 16) - window.slider.thumb:SetVertexColor (0.6, 0.6, 0.6, 0.95) - + window.slider:SetBackdropColor(0, 0, 0, 0.3) + + window.slider.thumb:SetTexture([[Interface\AddOns\Details\images\icons2]]) + window.slider.thumb:SetTexCoord(482/512, 492/512, 104/512, 120/512) + window.slider.thumb:SetSize(16, 16) + window.slider.thumb:SetVertexColor(0.6, 0.6, 0.6, 0.95) + Details_Report_CB_1:Hide() local reverse_checkbox = Details_Report_CB_2 reverse_checkbox:Show() reverse_checkbox:ClearAllPoints() - reverse_checkbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, + reverse_checkbox:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}}) reverse_checkbox:SetBackdropBorderColor (0, 0, 0, 0.5) - reverse_checkbox:SetBackdropColor (0, 0, 0, 0.3) - reverse_checkbox:SetPoint ("topleft", window.slider, "bottomleft", 0, -8) - reverse_checkbox:SetSize (14, 14) - reverse_checkbox:SetNormalTexture ("") - reverse_checkbox:SetPushedTexture ("") - reverse_checkbox:SetHighlightTexture ("") - _G [reverse_checkbox:GetName().."Text"]:ClearAllPoints() - _G [reverse_checkbox:GetName().."Text"]:SetPoint ("left", reverse_checkbox, "right", 2, 0) - + reverse_checkbox:SetBackdropColor(0, 0, 0, 0.3) + reverse_checkbox:SetPoint("topleft", window.slider, "bottomleft", 0, -8) + reverse_checkbox:SetSize(14, 14) + reverse_checkbox:SetNormalTexture("") + reverse_checkbox:SetPushedTexture("") + reverse_checkbox:SetHighlightTexture("") + _G[reverse_checkbox:GetName().."Text"]:ClearAllPoints() + _G[reverse_checkbox:GetName().."Text"]:SetPoint("left", reverse_checkbox, "right", 2, 0) + window.enviar:ClearAllPoints() - window.enviar:SetPoint ("bottom", window, "bottom", 0, 10) - window.enviar:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, + window.enviar:SetPoint("bottom", window, "bottom", 0, 10) + window.enviar:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile=true, tileSize = 64, insets = {left = 0, right = 0, top = 0, bottom = 0}}) - window.enviar:SetBackdropBorderColor (0, 0, 0, 0.5) - window.enviar:SetBackdropColor (0, 0, 0, 0.3) --- window.enviar.Left:Hide() --- window.enviar.Middle:Hide() --- window.enviar.Right:Hide() - - window.enviar:SetSize (342/2 - 15, 20) - - window:SetWidth (342/2 + 5) - window:SetHeight (195) - window:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1}) - window:SetBackdropColor (1, 1, 1, 1) + window.enviar:SetBackdropBorderColor(0, 0, 0, 0.5) + window.enviar:SetBackdropColor(0, 0, 0, 0.3) + window.enviar:SetSize(342/2 - 15, 20) + + window:SetWidth(342/2 + 5) + window:SetHeight(195) + window:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1}) + window:SetBackdropColor(1, 1, 1, 1) window:SetBackdropBorderColor (0, 0, 0, 1) - - if (not window.elvui_widgets) then - window.elvui_widgets = {} - - local titlebar = CreateFrame ("frame", window:GetName() .. "ElvUITitleBar", window,"BackdropTemplate") - titlebar:SetPoint ("topleft", window, "topleft", 2, -3) - titlebar:SetPoint ("topright", window, "topright", -2, -3) - titlebar:SetHeight (20) - titlebar:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true}) - titlebar:SetBackdropColor (.5, .5, .5, 1) + + if (not window.widgets) then + window.widgets = {} + + local titlebar = CreateFrame("frame", window:GetName() .. "TitleBar", window, "BackdropTemplate") + titlebar:SetPoint("topleft", window, "topleft", 2, -3) + titlebar:SetPoint("topright", window, "topright", -2, -3) + titlebar:SetHeight(20) + titlebar:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true}) + titlebar:SetBackdropColor(.5, .5, .5, 1) titlebar:SetBackdropBorderColor (0, 0, 0, 1) - - local bg1 = window:CreateTexture (nil, "background") - bg1:SetTexture ([[Interface\AddOns\Details\images\background]], true) - bg1:SetAlpha (0.7) - bg1:SetVertexColor (0.27, 0.27, 0.27) + + local bg1 = window:CreateTexture(nil, "background") + bg1:SetTexture([[Interface\AddOns\Details\images\background]], true) + bg1:SetAlpha(0.7) + bg1:SetVertexColor(0.27, 0.27, 0.27) bg1:SetVertTile (true) bg1:SetHorizTile (true) bg1:SetAllPoints() - - tinsert (window.all_widgets, bg1) - tinsert (window.elvui_widgets, bg1) - tinsert (window.all_widgets, titlebar) - tinsert (window.elvui_widgets, titlebar) + + tinsert(window.all_widgets, bg1) + tinsert(window.widgets, bg1) + tinsert(window.all_widgets, titlebar) + tinsert(window.widgets, titlebar) end window.title:ClearAllPoints() - window.title:SetPoint ("center", window, "center") - window.title:SetPoint ("top", window, "top", 0, -7) - window.title:SetParent (_G [window:GetName() .. "ElvUITitleBar"]) - window.title:SetTextColor (.8, .8, .8, 1) + window.title:SetPoint("center", window, "center") + window.title:SetPoint("top", window, "top", 0, -7) + window.title:SetParent(_G[window:GetName() .. "TitleBar"]) + window.title:SetTextColor(.8, .8, .8, 1) window.title:Show() - - - window:SetClampedToScreen (true) - - for _, widget in ipairs (window.elvui_widgets) do - widget:Show() - end - - end - - local classic_skin = function() - - local window = DetailsReportWindow - - local b_onenter = function (self) - self:SetBackdropColor (0.4, 0.4, 0.4, 0.6) - self.icon:SetBlendMode ("ADD") - _detalhes:SetFontColor (self.text, "yellow") - end - local b_onleave = function (self) - self:SetBackdropColor (0, 0, 0, 0.3) - self.icon:SetBlendMode ("BLEND") - _detalhes:SetFontColor (self.text, "white") - end - - window.last_reported_label:SetPoint ("topleft", window, "topleft", 10, -69) - _detalhes:SetFontSize (window.last_reported_label, 10) - - for i = 1, 8 do --window.max_last_buttons - local b = window.recently_report_buttons [i] - - b:SetSize (150, 16) - b:SetPoint ("topleft", window, "topleft", 10, -67 + (i*17*-1)) - b:Show() - b:SetBackdrop ({bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16, - insets = {left = 0, right = 0, top = 0, bottom = 0}}) - b:SetBackdropColor (0, 0, 0, 0.3) - b.text:SetTextColor (1, 1, 1, 1) - _detalhes:SetFontSize (b.text, 9) - - b:SetScript ("OnEnter", b_onenter) - b:SetScript ("OnLeave", b_onleave) - end - - local b = window.recently_report_buttons [10] - b:Hide() - b = window.recently_report_buttons [9] - b:Hide() - - Details_Report_CB_1:Hide() - Details_Report_CB_2:Hide() - - window.dropdown:ClearAllPoints() - window.dropdown:SetWidth (145) - window.dropdown:SetPoint ("topleft", window, "topleft", 175, -68) - - window.wisp_who:ClearAllPoints() - window.editbox:ClearAllPoints() - window.wisp_who:SetPoint ("topleft", window.dropdown.widget, "bottomleft", 0, -10) - window.editbox:SetPoint ("topleft", window.wisp_who, "bottomleft", 0, -3) - window.editbox:SetWidth (145) - window.editbox:SetHeight (20) - window.editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\AddOns\Details\images\border_3]], tile=true, - edgeSize = 15, tileSize = 64, insets = {left = 3, right = 3, top = 4, bottom = 4}}) - - window.linhas_amt:ClearAllPoints() - window.linhas_amt:SetPoint ("topleft", window.editbox, "bottomleft", 0, -7) - window.slider:ClearAllPoints() - window.slider :SetWidth (145) - window.slider:SetPoint ("topleft", window.linhas_amt, "bottomleft", 0, -3) - window.slider:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = [[Interface\AddOns\Details\images\border_3]], tile=true, - edgeSize = 15, tileSize = 64, insets = {left = 3, right = 3, top = 4, bottom = 4}}) - - window.slider.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob") - window.slider.thumb:SetSize (30, 24) - window.slider.thumb:SetAlpha (0.7) - - Details_Report_CB_1:Hide() - local reverse_checkbox = Details_Report_CB_2 - reverse_checkbox:Show() - reverse_checkbox:ClearAllPoints() - reverse_checkbox:SetBackdrop (nil) - reverse_checkbox:SetPoint ("topleft", window.slider, "bottomleft", -1, -4) - reverse_checkbox:SetSize (26, 26) - reverse_checkbox:SetNormalTexture ([[Interface\Buttons\UI-CheckBox-Up]]) - reverse_checkbox:SetPushedTexture ([[Interface\Buttons\UI-CheckBox-Down]]) - reverse_checkbox:SetHighlightTexture ([[Interface\Buttons\UI-CheckBox-Highlight]]) - _G [reverse_checkbox:GetName().."Text"]:ClearAllPoints() - _G [reverse_checkbox:GetName().."Text"]:SetPoint ("left", reverse_checkbox, "right", 2, 0) - - window.enviar:ClearAllPoints() - window.enviar:SetPoint ("topleft", reverse_checkbox, "bottomleft", 0, -4) --- window.enviar.Left:Show() --- window.enviar.Middle:Show() --- window.enviar.Right:Show() - - window:SetWidth (342) - window:SetHeight (255) - window:SetBackdrop (nil) - - window.fechar:Hide() - window.title:Hide() - - if (not window.classic_widgets) then - window.classic_widgets = {} - - local f = CreateFrame ("frame", window:GetName() .. "F", window, "ButtonFrameTemplate") - f:SetAllPoints() - - --f.portrait:SetTexture ("Interface\\AddOns\\Details\\images\\report_frame_icons") - --f.portrait:SetTexCoord (1/256, 64/256, 1/256, 64/256) - - --f.TitleText:SetText (Loc ["STRING_REPORTFRAME_WINDOW_TITLE"]) --10.0 fuck - f:SetFrameLevel (window:GetFrameLevel()-1) - - _G [window:GetName() .. "FCloseButton"]:SetFrameLevel (window:GetFrameLevel()+1) - _G [window:GetName() .. "FCloseButton"]:SetScript ("OnClick", function() - window:Hide() - end) - tinsert (window.classic_widgets, f) - tinsert (window.all_widgets, f) - end + window:SetClampedToScreen(true) - for _, widget in ipairs (window.classic_widgets) do + for _, widget in ipairs(window.widgets) do widget:Show() end end - - function _detalhes:UpdateRecentlyReported() + function Details:UpdateRecentlyReported() DetailsReportWindow:RefreshRecentlyReported() end - function _detalhes:DelayUpdateReportWindowRecentlyReported() + + function Details:DelayUpdateReportWindowRecentlyReported() if (DetailsReportWindow) then - _detalhes:ScheduleTimer ("UpdateRecentlyReported", 0.5) + Details:ScheduleTimer ("UpdateRecentlyReported", 0.5) end end - - function _detalhes:CheckLastReportsIntegrity() - local last_reports = _detalhes.latest_report_table or {} - if (#last_reports > 0) then + + function Details:CheckLastReportsIntegrity() + local lastReports = Details.latest_report_table or {} + if (#lastReports > 0) then local i = 1 - for index = #last_reports, 1, -1 do - local report = last_reports [index] - local instance_id, atributo, sub_atributo, amt, where, custom_name = unpack (report) + for index = #lastReports, 1, -1 do + local report = lastReports[index] + local instance_id, atributo, sub_atributo, amt, where, custom_name = unpack(report) if (atributo == 5) then if (not custom_name) then - tremove (last_reports, index) + tremove(lastReports, index) else local found - for _, custom in ipairs (_detalhes.custom) do + for _, custom in ipairs(Details.custom) do if (custom.name == custom_name) then found = true break end end if (not found) then - tremove (last_reports, index) + tremove(lastReports, index) end end end end end end - + function gump:CriaJanelaReport() + --window + local window = CreateFrame("Frame", "DetailsReportWindow", UIParent, "BackdropTemplate") + tinsert(UISpecialFrames, "DetailsReportWindow") + window:SetPoint("CENTER", UIParent, "CENTER") + window:SetFrameStrata("DIALOG") + window.skins = {} + window.all_widgets = {} + window.max_last_buttons = 10 - --> window - local window = _CreateFrame ("Frame", "DetailsReportWindow", _UIParent,"BackdropTemplate") - tinsert (UISpecialFrames, "DetailsReportWindow") - window:SetPoint ("CENTER", UIParent, "CENTER") - window:SetFrameStrata ("DIALOG") - window.skins = {} - window.all_widgets = {} - window.max_last_buttons = 10 - - window:EnableMouse (true) - window:SetResizable (false) - window:SetMovable (true) - restorepos (window) + window:EnableMouse(true) + window:SetResizable(false) + window:SetMovable(true) + restorepos(window) - _detalhes.janela_report = window - - _detalhes:InstallRPSkin ("WoWClassic", classic_skin) - _detalhes:InstallRPSkin ("ElvUI", elvui_skin) - - --> all new widgets: - - --recently reported: - window.recently_report_buttons = {} - - local history_Background = window:CreateTexture (nil, "background") - history_Background:SetColorTexture (0, 0, 0, .3) - history_Background:SetSize (160, 158) - history_Background:SetPoint ("topleft", window, "topleft", 3, -25) - - local separador = window:CreateTexture (nil, "border") - separador:SetColorTexture (0, 0, 0, .6) - separador:SetSize (2, 158) - separador:SetPoint ("topleft", history_Background, "topright", 0, 0) - - function window:RefreshRecentlyReported() - for i = 1, window.max_last_buttons do - local b = window.recently_report_buttons [i] - b.icon:SetTexture ("") - b:Hide() - end - - _detalhes:CheckLastReportsIntegrity() - - local last_reports = _detalhes.latest_report_table - if (#last_reports > 0) then - local i = 1 - for index = 1, min (#last_reports, 8) do - local b = window.recently_report_buttons [i] - local report = last_reports [index] - local instance_number, attribute, subattribute, amt, report_where = unpack (report) - local name = _detalhes:GetSubAttributeName (attribute, subattribute) - local artwork = _detalhes.GetReportIconAndColor (report_where) - - b.text:SetText (name .. " (#" .. amt .. ")") - b.index = index - if (artwork) then - b.icon:SetTexture (artwork.icon) - b.icon:SetTexCoord (artwork.coords[1], artwork.coords[2], artwork.coords[3], artwork.coords[4]) - b.icon:SetVertexColor (unpack (artwork.color or {})) - end - - --b:Show() - b:Hide() - i = i + 1 - end - end - end - - local recently_on_click = function (self) - if (self.index) then - return _detalhes.ReportFromLatest (_, _, self.index) - end - end - - local last_reported_label = window:CreateFontString (nil, "overlay", "GameFontNormal") - window.last_reported_label = last_reported_label - window.last_reported_label:SetText (Loc ["STRING_REPORTHISTORY"] .. ":") --this string could be removed from localization - + Details.janela_report = window + Details:InstallRPSkin("defaultSkin", defaultSkin) + + --recently reported: + window.recently_report_buttons = {} + + local historyBlockBackground = window:CreateTexture(nil, "background") + historyBlockBackground:SetColorTexture (0, 0, 0, .3) + historyBlockBackground:SetSize(160, 158) + historyBlockBackground:SetPoint("topleft", window, "topleft", 3, -25) + + local separator = window:CreateTexture(nil, "border") + separator:SetColorTexture (0, 0, 0, .6) + separator:SetSize(2, 158) + separator:SetPoint("topleft", historyBlockBackground, "topright", 0, 0) + + function window:RefreshRecentlyReported() for i = 1, window.max_last_buttons do - local b = CreateFrame ("button", "DetailsReportWindowRRB" .. i, window,"BackdropTemplate") - local icon = b:CreateTexture (nil, "overlay") - icon:SetPoint ("left", b, "left") - icon:SetSize (16, 16) - local text = b:CreateFontString (nil, "overlay", "GameFontNormal") - text:SetPoint ("left", icon, "right", 2, 0) - b.icon = icon - b.text = text - b:SetScript ("OnClick", recently_on_click) - tinsert (window.recently_report_buttons, b) + local b = window.recently_report_buttons[i] + b.icon:SetTexture("") + b:Hide() end - - history_Background:Hide() - separador:Hide() - window.last_reported_label:Hide() - --> scritps - - local flashTexture = window:CreateTexture (nil, "background") - flashTexture:SetColorTexture (1, 1, 1) - flashTexture:SetAllPoints() - - local onShowAnimation = DetailsFramework:CreateAnimationHub (flashTexture, function() flashTexture:Show() end, function() flashTexture:Hide() end) - DetailsFramework:CreateAnimation (onShowAnimation, "ALPHA", 1, .2, 0, .10) - DetailsFramework:CreateAnimation (onShowAnimation, "ALPHA", 2, .2, .10, 0) - - window:SetScript ("OnShow", function (self) - local dropdown = window.select.MyObject - local where = _detalhes.report_where - - local list = window.dropdown_func() - local found - - onShowAnimation:Play() - - for index, option in ipairs (list) do - if (option.value == where) then - dropdown:Select (where) - found = true - break - end - end - - if (not found) then - if (_IsInRaid()) then - dropdown:Select ("RAID") - _detalhes.report_where = "RAID" - - elseif (GetNumSubgroupMembers() > 0) then - dropdown:Select ("PARTY") - _detalhes.report_where = "PARTY" - - elseif (_IsInGuild()) then - dropdown:Select ("GUILD") - _detalhes.report_where = "GUILD" - - else - dropdown:Select ("SAY") - _detalhes.report_where = "SAY" - end - end - - window:RefreshRecentlyReported() - - end) + Details:CheckLastReportsIntegrity() - window:SetScript ("OnHide", function (self) - _detalhes.janela_report.ativa = false - _detalhes.last_report_id = nil - end) - - --> close button - window.fechar = CreateFrame ("Button", nil, window, "UIPanelCloseButton") - window.fechar:SetScript ("OnClick", function() + local lastReports = Details.latest_report_table + if (#lastReports > 0) then + local i = 1 + for index = 1, min(#lastReports, 8) do + local recentReportButton = window.recently_report_buttons[i] + local report = lastReports[index] + local instanceId, attribute, subAttribute, amt, reportWhere = unpack(report) + local name = Details:GetSubAttributeName(attribute, subAttribute) + local artwork = Details.GetReportIconAndColor(reportWhere) + + recentReportButton.text:SetText(name .. " (#" .. amt .. ")") + recentReportButton.index = index + + if (artwork) then + recentReportButton.icon:SetTexture(artwork.icon) + recentReportButton.icon:SetTexCoord(artwork.coords[1], artwork.coords[2], artwork.coords[3], artwork.coords[4]) + recentReportButton.icon:SetVertexColor(unpack(artwork.color or {})) + end + + recentReportButton:Hide() + i = i + 1 + end + end + end + + local recentlyButtonOnClick = function(self) + if (self.index) then + return Details.ReportFromLatest(_, _, self.index) + end + end + + local lastReportedLabel = window:CreateFontString(nil, "overlay", "GameFontNormal") + window.last_reported_label = lastReportedLabel + window.last_reported_label:SetText(Loc ["STRING_REPORTHISTORY"] .. ":") --this string could be removed from localization + + for i = 1, window.max_last_buttons do + local button = CreateFrame("button", "DetailsReportWindowRRB" .. i, window, "BackdropTemplate") + local icon = button:CreateTexture(nil, "overlay") + icon:SetPoint("left", button, "left") + icon:SetSize(16, 16) + + local text = button:CreateFontString(nil, "overlay", "GameFontNormal") + text:SetPoint("left", icon, "right", 2, 0) + + button.icon = icon + button.text = text + button:SetScript("OnClick", recentlyButtonOnClick) + tinsert(window.recently_report_buttons, button) + end + + historyBlockBackground:Hide() + separator:Hide() + window.last_reported_label:Hide() + + --scritps + + local flashTexture = window:CreateTexture(nil, "background") + flashTexture:SetColorTexture(1, 1, 1) + flashTexture:SetAllPoints() + + local onShowAnimation = DetailsFramework:CreateAnimationHub(flashTexture, function() flashTexture:Show() end, function() flashTexture:Hide() end) + DetailsFramework:CreateAnimation(onShowAnimation, "ALPHA", 1, .2, 0, .10) + DetailsFramework:CreateAnimation(onShowAnimation, "ALPHA", 2, .2, .10, 0) + + window:SetScript("OnShow", function(self) + local dropdown = window.select.MyObject + local where = Details.report_where + + local list = window.dropdown_func() + local found + + onShowAnimation:Play() + + for index, option in ipairs(list) do + if (option.value == where) then + dropdown:Select(where) + found = true + break + end + end + + if (not found) then + if (IsInRaid()) then + dropdown:Select("RAID") + Details.report_where = "RAID" + + elseif (GetNumSubgroupMembers() > 0) then + dropdown:Select("PARTY") + Details.report_where = "PARTY" + + elseif (IsInGuild()) then + dropdown:Select("GUILD") + Details.report_where = "GUILD" + + else + dropdown:Select("SAY") + Details.report_where = "SAY" + end + end + + window:RefreshRecentlyReported() + end) + + window:SetScript("OnHide", function(self) + Details.janela_report.ativa = false + Details.last_report_id = nil + end) + + --close button + window.fechar = CreateFrame("Button", nil, window, "UIPanelCloseButton") + window.fechar:SetScript("OnClick", function() Details.FadeHandler.Fader (window, 1) - _detalhes.janela_report.ativa = false - end) + Details.janela_report.ativa = false + end) - --> title - window.title = window:CreateFontString (nil, "OVERLAY", "GameFontHighlightLeft") - window.title:SetText (Loc ["STRING_REPORTFRAME_WINDOW_TITLE"]) + --title + window.title = window:CreateFontString(nil, "OVERLAY", "GameFontHighlightLeft") + window.title:SetText(Loc ["STRING_REPORTFRAME_WINDOW_TITLE"]) - seta_scripts (window) - cria_drop_down (window) - cria_slider (window) - cria_wisper_field (window) - cria_check_buttons (window) + setScripts(window) + createDropdown(window) + createSlider(window) + createWisperField(window) + createCheckButtons(window) - window.enviar = _CreateFrame ("Button", nil, window, "BackdropTemplate") - window.enviar:SetPoint ("topleft", window.editbox, "topleft", 61, -19) - window.enviar:SetWidth (60) - window.enviar:SetHeight (15) - window.enviar:SetText (Loc ["STRING_REPORTFRAME_SEND"]) + window.enviar = CreateFrame("Button", nil, window, "BackdropTemplate") + window.enviar:SetPoint("topleft", window.editbox, "topleft", 61, -19) + window.enviar:SetWidth(60) + window.enviar:SetHeight(15) DetailsFramework:ApplyStandardBackdrop(window.enviar) - Details.FadeHandler.Fader (window, 1) - gump:CreateFlashAnimation (window) - + local sendButtonLabel = window.enviar:CreateFontString(nil, "overlay", "GameFontNormal") + sendButtonLabel:SetPoint("center", 0, 0) + sendButtonLabel:SetText(Loc ["STRING_REPORTFRAME_SEND"]) + + Details.FadeHandler.Fader(window, 1) + gump:CreateFlashAnimation(window) + --apply the current skin - _detalhes:ApplyRPSkin() - + Details:ApplyRPSkin() + return window - end - - function _detalhes:InstallRPSkin (skin_name, func) + + function Details:InstallRPSkin(skinName, func) if (not DetailsReportWindow) then gump:CriaJanelaReport() DetailsReportWindow:Hide() end - - if (not skin_name) then - return false -- sem nome - elseif (DetailsReportWindow.skins [skin_name]) then - return false -- ja existe + + if (not skinName) then + return false + elseif (DetailsReportWindow.skins[skinName]) then + return false end - - DetailsReportWindow.skins [skin_name] = func + + DetailsReportWindow.skins[skinName] = func return true end - - function _detalhes:ApplyRPSkin (skin_name) - + + function Details:ApplyRPSkin(skinName) if (not DetailsReportWindow) then gump:CriaJanelaReport() DetailsReportWindow:Hide() end - - if (not skin_name) then - skin_name = _detalhes.player_details_window.skin - if (not DetailsReportWindow.skins [skin_name]) then - skin_name = "ElvUI" + + if (not skinName) then + skinName = Details.player_details_window.skin + if (not DetailsReportWindow.skins[skinName]) then + skinName = "defaultSkin" end end - - local skin = DetailsReportWindow.skins [skin_name] + + local skin = DetailsReportWindow.skins[skinName] if (skin) then - - for _, widget in ipairs (DetailsReportWindow.all_widgets) do + for _, widget in ipairs(DetailsReportWindow.all_widgets) do widget:Hide() end - - local successful, errortext = pcall (skin) + + local successful, errortext = pcall(skin) if (not successful) then - _detalhes:Msg ("error occurred on report window skin call():", errortext) - pcall (DetailsReportWindow.skins["ElvUI"]) + Details:Msg("error occurred on report window skin call():", errortext) + pcall(DetailsReportWindow.skins["defaultSkin"]) end end - end + end \ No newline at end of file