# HG changeset patch # User Tercio # Date 1468945420 10800 # Node ID 7944c081e5b4c37f9c09874eae73365a9aee017a # Parent 219f04e5ba555fdf793ecbd2fda33dfa171e24be - framework update. - ToC Update. diff -r 219f04e5ba55 -r 7944c081e5b4 Hansgar_And_Franzok_Assist.toc --- a/Hansgar_And_Franzok_Assist.toc Mon Jul 04 23:06:23 2016 -0300 +++ b/Hansgar_And_Franzok_Assist.toc Tue Jul 19 13:23:40 2016 -0300 @@ -1,4 +1,4 @@ -## Interface: 60200 +## Interface: 70000 ## Title: Hansgar And Franzok Assist ## Notes: Helps with Smart Stampers on Mythic during this encounter. ## SavedVariables: Hansgar_And_Franzok_DB diff -r 219f04e5ba55 -r 7944c081e5b4 Libs/DF/button.lua --- a/Libs/DF/button.lua Mon Jul 04 23:06:23 2016 -0300 +++ b/Libs/DF/button.lua Tue Jul 19 13:23:40 2016 -0300 @@ -16,7 +16,18 @@ local cleanfunction = function() end local APIButtonFunctions = false -local ButtonMetaFunctions = {} + +do + local metaPrototype = { + WidgetType = "button", + SetHook = DF.SetHook, + RunHooksForWidget = DF.RunHooksForWidget, + } + + _G [DF.GlobalWidgetControlNames ["button"]] = _G [DF.GlobalWidgetControlNames ["button"]] or metaPrototype +end + +local ButtonMetaFunctions = _G [DF.GlobalWidgetControlNames ["button"]] ------------------------------------------------------------------------------------------------------------ --> metatables @@ -75,26 +86,25 @@ return _rawget (_object, "is_locked") end - local get_members_function_index = { - ["tooltip"] = gmember_tooltip, - ["shown"] = gmember_shown, - ["width"] = gmember_width, - ["height"] = gmember_height, - ["text"] = gmember_text, - ["clickfunction"] = gmember_function, - ["texture"] = gmember_texture, - ["locked"] = gmember_locked, - ["fontcolor"] = gmember_textcolor, - ["fontface"] = gmember_textfont, - ["fontsize"] = gmember_textsize, - ["textcolor"] = gmember_textcolor, --alias - ["textfont"] = gmember_textfont, --alias - ["textsize"] = gmember_textsize --alias - } + ButtonMetaFunctions.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.__index = function (_table, _member_requested) - local func = get_members_function_index [_member_requested] + local func = ButtonMetaFunctions.GetMembers [_member_requested] if (func) then return func (_table, _member_requested) end @@ -206,25 +216,24 @@ _object.capsule_textalign = "right" end end - - local set_members_function_index = { - ["tooltip"] = smember_tooltip, - ["show"] = smember_show, - ["hide"] = smember_hide, - ["width"] = smember_width, - ["height"] = smember_height, - ["text"] = smember_text, - ["clickfunction"] = smember_function, - ["textcolor"] = smember_textcolor, - ["textfont"] = smember_textfont, - ["textsize"] = smember_textsize, - ["texture"] = smember_texture, - ["locked"] = smember_locked, - ["textalign"] = smember_textalign, - } + + ButtonMetaFunctions.SetMembers = ButtonMetaFunctions.SetMembers or {} + ButtonMetaFunctions.SetMembers ["tooltip"] = smember_tooltip + ButtonMetaFunctions.SetMembers ["show"] = smember_show + ButtonMetaFunctions.SetMembers ["hide"] = smember_hide + ButtonMetaFunctions.SetMembers ["width"] = smember_width + ButtonMetaFunctions.SetMembers ["height"] = smember_height + ButtonMetaFunctions.SetMembers ["text"] = smember_text + ButtonMetaFunctions.SetMembers ["clickfunction"] = smember_function + ButtonMetaFunctions.SetMembers ["textcolor"] = smember_textcolor + ButtonMetaFunctions.SetMembers ["textfont"] = smember_textfont + ButtonMetaFunctions.SetMembers ["textsize"] = smember_textsize + ButtonMetaFunctions.SetMembers ["texture"] = smember_texture + ButtonMetaFunctions.SetMembers ["locked"] = smember_locked + ButtonMetaFunctions.SetMembers ["textalign"] = smember_textalign ButtonMetaFunctions.__newindex = function (_table, _key, _value) - local func = set_members_function_index [_key] + local func = ButtonMetaFunctions.SetMembers [_key] if (func) then return func (_table, _value) else @@ -473,15 +482,6 @@ return self.funcright() end ---> hooks - function ButtonMetaFunctions:SetHook (hookType, func) - if (func) then - _rawset (self, hookType.."Hook", func) - else - _rawset (self, hookType.."Hook", nil) - end - end - --> custom textures function ButtonMetaFunctions:InstallCustomTexture (texture, rect, coords, use_split, side_textures, side_textures2) @@ -587,6 +587,8 @@ local OnEnter = function (button) + 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) @@ -598,12 +600,10 @@ button.textureBottomLeft:SetTexCoord (0, 8/128, 56/128, 64/128) button.textureBottomRight:SetTexCoord (120/128, 1, 56/128, 64/128) end - - if (button.MyObject.OnEnterHook) then - local interrupt = button.MyObject.OnEnterHook (button, button.MyObject) - if (interrupt) then - return - end + + local kill = capsule:RunHooksForWidget ("OnEnter", button, capsule) + if (kill) then + return end button.MyObject.is_mouse_over = true @@ -637,6 +637,8 @@ 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) @@ -648,12 +650,10 @@ button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128) button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128) end - - if (button.MyObject.OnLeaveHook) then - local interrupt = button.MyObject.OnLeaveHook (button, button.MyObject) - if (interrupt) then - return - end + + local kill = capsule:RunHooksForWidget ("OnLeave", button, capsule) + if (kill) then + return end button.MyObject.is_mouse_over = false @@ -682,27 +682,27 @@ end local OnHide = function (button) - if (button.MyObject.OnHideHook) then - local interrupt = button.MyObject.OnHideHook (button, button.MyObject) - if (interrupt) then - return - end + local capsule = button.MyObject + local kill = capsule:RunHooksForWidget ("OnHide", button, capsule) + if (kill) then + return end end local OnShow = function (button) - if (button.MyObject.OnShowHook) then - local interrupt = button.MyObject.OnShowHook (button, button.MyObject) - if (interrupt) then - return - end + local capsule = button.MyObject + local kill = capsule:RunHooksForWidget ("OnShow", button, capsule) + if (kill) then + return end end local OnMouseDown = function (button, buttontype) + local capsule = button.MyObject + if (not button:IsEnabled()) then return - end + end if (button.textureTopLeft) then button.textureLeft:SetTexCoord (0, 4/128, 72/128, 88/128) @@ -715,12 +715,10 @@ button.textureBottomLeft:SetTexCoord (0, 8/128, 88/128, 96/128) button.textureBottomRight:SetTexCoord (120/128, 1, 88/128, 96/128) end - - if (button.MyObject.OnMouseDownHook) then - local interrupt = button.MyObject.OnMouseDownHook (button, buttontype, button.MyObject) - if (interrupt) then - return - end + + local kill = capsule:RunHooksForWidget ("OnMouseDown", button, capsule) + if (kill) then + return end button.MyObject.is_mouse_down = true @@ -803,11 +801,10 @@ end end - if (button.MyObject.OnMouseUpHook) then - local interrupt = button.MyObject.OnMouseUpHook (button, buttontype, button.MyObject) - if (interrupt) then - return - end + local capsule = button.MyObject + local kill = capsule:RunHooksForWidget ("OnMouseUp", button, capsule) + if (kill) then + return end button.MyObject.is_mouse_down = false @@ -957,20 +954,10 @@ end --> default members: - --> hooks - ButtonObject.OnEnterHook = nil - ButtonObject.OnLeaveHook = nil - ButtonObject.OnHideHook = nil - ButtonObject.OnShowHook = nil - ButtonObject.OnMouseDownHook = nil - ButtonObject.OnMouseUpHook = nil - --> misc ButtonObject.is_locked = true ButtonObject.container = container - ButtonObject.have_tooltip = nil ButtonObject.options = {OnGrab = false} - ButtonObject.button = CreateFrame ("button", name, parent, "DetailsFrameworkButtonTemplate") ButtonObject.widget = ButtonObject.button @@ -1006,12 +993,15 @@ ButtonObject.button.text:SetText (text) ButtonObject.button.text:SetPoint ("center", ButtonObject.button, "center") - + local text_width = ButtonObject.button.text:GetStringWidth() if (text_width > w-15 and ButtonObject.button.text:GetText() ~= "") then - if (not short_method) then + if (short_method == false) then --> if is false, do not use auto resize + --do nothing + elseif (not short_method) then --> if the value is omitted, use the default resize local new_width = text_width+15 ButtonObject.button:SetWidth (new_width) + elseif (short_method == 1) then local loop = true local textsize = 11 @@ -1051,6 +1041,15 @@ 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) @@ -1119,7 +1118,7 @@ --textura da cor local img = DF:NewImage (button, nil, color_button_width, color_button_height, nil, nil, "color_texture", "$parentTex") - img:SetTexture (1, 1, 1) + img:SetColorTexture (1, 1, 1) img:SetPoint ("topleft", button.widget, "topleft", 1, -2) img:SetPoint ("bottomright", button.widget, "bottomright", -1, 1) img:SetDrawLayer ("background", 2) diff -r 219f04e5ba55 -r 7944c081e5b4 Libs/DF/button.xml --- a/Libs/DF/button.xml Mon Jul 04 23:06:23 2016 -0300 +++ b/Libs/DF/button.xml Tue Jul 19 13:23:40 2016 -0300 @@ -19,7 +19,7 @@ - @@ -28,6 +28,8 @@ self.texture_disabled:Show() + self.texture_disabled:SetVertexColor (0, 0, 0) + self.texture_disabled:SetAlpha (.5) diff -r 219f04e5ba55 -r 7944c081e5b4 Libs/DF/cooltip.lua --- a/Libs/DF/cooltip.lua Mon Jul 04 23:06:23 2016 -0300 +++ b/Libs/DF/cooltip.lua Tue Jul 19 13:23:40 2016 -0300 @@ -2493,7 +2493,7 @@ end --> check data integrity - if (type (iconTexture) ~= "string" and (type (iconTexture) ~= "table" or not iconTexture.GetObjectType or iconTexture:GetObjectType() ~= "Texture") ) then + if ( (type (iconTexture) ~= "string" and type (iconTexture) ~= "number") and (type (iconTexture) ~= "table" or not iconTexture.GetObjectType or iconTexture:GetObjectType() ~= "Texture") ) then return --> return error end @@ -3033,10 +3033,17 @@ --> all done CoolTip:ClearAllOptions() - local preset2_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = DF.folder .. "border_3", tile=true, - edgeSize = 16, tileSize = 64, insets = {left = 3, right = 3, top = 4, bottom = 4}} +-- local preset2_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = DF.folder .. "border_3", tile=true, +-- edgeSize = 16, tileSize = 64, insets = {left = 3, right = 3, top = 4, bottom = 4}} + local preset2_backdrop = {bgFile = DF.folder .. "background", edgeFile = [[Interface\Buttons\WHITE8X8]], tile = true, + edgeSize = 1, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}} + local default_backdrop_color = {0.09019, 0.09019, 0.18823, 0.8} + local default_backdropborder_color = {1, 1, 1, 1} + + local gray_table = {0.37, 0.37, 0.37, 0.95} local white_table = {1, 1, 1, 1} + local black_table = {0.2, 0.2, 0.2, 1} function CoolTip:Preset (number) self:Reset() @@ -3058,9 +3065,11 @@ self:SetOption ("ButtonsYMod", -4) self:SetOption ("YSpacingMod", -4) self:SetOption ("IgnoreButtonAutoHeight", true) - self:SetColor (1, 0.5, 0.5, 0.5, 0.5) - self:SetBackdrop (1, preset2_backdrop, nil, white_table) + --self:SetColor (1, 0.5, 0.5, 0.5, 0.5) + self:SetColor (1, 0.5, 0.5, 0.5, 0) + + self:SetBackdrop (1, preset2_backdrop, gray_table, black_table) end end diff -r 219f04e5ba55 -r 7944c081e5b4 Libs/DF/dropdown.lua --- a/Libs/DF/dropdown.lua Mon Jul 04 23:06:23 2016 -0300 +++ b/Libs/DF/dropdown.lua Tue Jul 19 13:23:40 2016 -0300 @@ -16,7 +16,18 @@ local cleanfunction = function() end local APIDropDownFunctions = false -local DropDownMetaFunctions = {} + +do + local metaPrototype = { + WidgetType = "dropdown", + SetHook = DF.SetHook, + RunHooksForWidget = DF.RunHooksForWidget, + } + + _G [DF.GlobalWidgetControlNames ["dropdown"]] = _G [DF.GlobalWidgetControlNames ["dropdown"]] or metaPrototype +end + +local DropDownMetaFunctions = _G [DF.GlobalWidgetControlNames ["dropdown"]] ------------------------------------------------------------------------------------------------------------ --> metatables @@ -65,21 +76,20 @@ return _rawget (self, "realsizeH") end - local get_members_function_index = { - ["value"] = gmember_value, - ["text"] = gmember_text, - ["shown"] = gmember_shown, - ["width"] = gmember_width, - ["menuwidth"] = gmember_menuwidth, - ["height"] = gmember_height, - ["menuheight"] = gmember_menuheight, - ["tooltip"] = gmember_tooltip, - ["func"] = gmember_function, - } + DropDownMetaFunctions.GetMembers = DropDownMetaFunctions.GetMembers or {} + DropDownMetaFunctions.GetMembers ["value"] = gmember_value + DropDownMetaFunctions.GetMembers ["text"] = gmember_text + DropDownMetaFunctions.GetMembers ["shown"] = gmember_shown + DropDownMetaFunctions.GetMembers ["width"] = gmember_width + DropDownMetaFunctions.GetMembers ["menuwidth"] = gmember_menuwidth + DropDownMetaFunctions.GetMembers ["height"] = gmember_height + DropDownMetaFunctions.GetMembers ["menuheight"] = gmember_menuheight + DropDownMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip + DropDownMetaFunctions.GetMembers ["func"] = gmember_function DropDownMetaFunctions.__index = function (_table, _member_requested) - local func = get_members_function_index [_member_requested] + local func = DropDownMetaFunctions.GetMembers [_member_requested] if (func) then return func (_table, _member_requested) end @@ -135,19 +145,18 @@ _object:SetMenuSize (nil, _value) end - local set_members_function_index = { - ["tooltip"] = smember_tooltip, - ["show"] = smember_show, - ["hide"] = smember_hide, - ["width"] = smember_width, - ["menuwidth"] = smember_menuwidth, - ["height"] = smember_height, - ["menuheight"] = smember_menuheight, - ["func"] = smember_function, - } + DropDownMetaFunctions.SetMembers = DropDownMetaFunctions.SetMembers or {} + DropDownMetaFunctions.SetMembers ["tooltip"] = smember_tooltip + DropDownMetaFunctions.SetMembers ["show"] = smember_show + DropDownMetaFunctions.SetMembers ["hide"] = smember_hide + DropDownMetaFunctions.SetMembers ["width"] = smember_width + DropDownMetaFunctions.SetMembers ["menuwidth"] = smember_menuwidth + DropDownMetaFunctions.SetMembers ["height"] = smember_height + DropDownMetaFunctions.SetMembers ["menuheight"] = smember_menuheight + DropDownMetaFunctions.SetMembers ["func"] = smember_function DropDownMetaFunctions.__newindex = function (_table, _key, _value) - local func = set_members_function_index [_key] + local func = DropDownMetaFunctions.SetMembers [_key] if (func) then return func (_table, _value) else @@ -285,15 +294,6 @@ _rawset (self, "FixedValue", value) end ---> hooks - function DropDownMetaFunctions:SetHook (hookType, func) - if (func) then - _rawset (self, hookType.."Hook", func) - else - _rawset (self, hookType.."Hook", nil) - end - end - ------------------------------------------------------------------------------------------------------------ --> scripts @@ -752,11 +752,10 @@ function DetailsFrameworkDropDownOnEnter (self) - if (self.MyObject.OnEnterHook) then - local interrupt = self.MyObject.OnEnterHook (self) - if (interrupt) then - return - end + local capsule = self.MyObject + local kill = capsule:RunHooksForWidget ("OnEnter", self, capsule) + if (kill) then + return end if (self.MyObject.onenter_backdrop) then @@ -787,11 +786,10 @@ end function DetailsFrameworkDropDownOnLeave (self) - if (self.MyObject.OnLeaveHook) then - local interrupt = self.MyObject.OnLeaveHook (self) - if (interrupt) then - return - end + local capsule = self.MyObject + local kill = capsule:RunHooksForWidget ("OnLeave", self, capsule) + if (kill) then + return end if (self.MyObject.onleave_backdrop) then @@ -816,20 +814,18 @@ end function DetailsFrameworkDropDownOnShow (self) - if (self.MyObject and self.MyObject.OnShowHook) then - local interrupt = self.MyObject.OnShowHook (self) - if (interrupt) then - return - end + local capsule = self.MyObject + local kill = capsule:RunHooksForWidget ("OnShow", self, capsule) + if (kill) then + return end end function DetailsFrameworkDropDownOnHide (self) - if (self.MyObject and self.MyObject.OnHideHook) then - local interrupt = self.MyObject.OnHideHook (self) - if (interrupt) then - return - end + local capsule = self.MyObject + local kill = capsule:RunHooksForWidget ("OnHide", self, capsule) + if (kill) then + return end self.MyObject:Close() @@ -934,15 +930,8 @@ end --> default members: - --> hooks - DropDownObject.OnEnterHook = nil - DropDownObject.OnLeaveHook = nil - DropDownObject.OnHideHook = nil - DropDownObject.OnShowHook = nil - DropDownObject.OnMouseDownHook = nil --> misc DropDownObject.container = container - DropDownObject.have_tooltip = nil DropDownObject.dropdown = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownTemplate") DropDownObject.widget = DropDownObject.dropdown @@ -1002,11 +991,22 @@ DropDownObject:HideScroll() DropDownObject.label:SetSize (DropDownObject.dropdown:GetWidth()-40, 10) + DropDownObject.HookList = { + OnEnter = {}, + OnLeave = {}, + OnHide = {}, + OnShow = {}, + } + + DropDownObject.dropdown:SetScript ("OnShow", DetailsFrameworkDropDownOnShow) + DropDownObject.dropdown:SetScript ("OnHide", DetailsFrameworkDropDownOnHide) + DropDownObject.dropdown:SetScript ("OnEnter", DetailsFrameworkDropDownOnEnter) + DropDownObject.dropdown:SetScript ("OnLeave", DetailsFrameworkDropDownOnLeave) + --> setup class _setmetatable (DropDownObject, DropDownMetaFunctions) - + --> initialize first menu selected - if (type (default) == "string") then DropDownObject:Select (default) @@ -1020,6 +1020,6 @@ DropDownObject:SetTemplate (template) end - return DropDownObject + return DropDownObject end \ No newline at end of file diff -r 219f04e5ba55 -r 7944c081e5b4 Libs/DF/dropdown.xml --- a/Libs/DF/dropdown.xml Mon Jul 04 23:06:23 2016 -0300 +++ b/Libs/DF/dropdown.xml Tue Jul 19 13:23:40 2016 -0300 @@ -79,15 +79,15 @@ - + - + - + @@ -96,7 +96,8 @@ DetailsFrameworkDropDownOptionsFrameOnHide (self); - self:SetBackdropColor (0, 0, 0, 0.95); + self:SetBackdropColor (0, 0, 0, 0.92); + self:SetBackdropBorderColor (0, 0, 0, 1); @@ -109,7 +110,7 @@ - + @@ -160,19 +161,19 @@ - DetailsFrameworkDropDownOnShow (self); + - DetailsFrameworkDropDownOnHide (self); + - DetailsFrameworkDropDownOnEnter (self); + - DetailsFrameworkDropDownOnLeave (self); + diff -r 219f04e5ba55 -r 7944c081e5b4 Libs/DF/fw.lua --- a/Libs/DF/fw.lua Mon Jul 04 23:06:23 2016 -0300 +++ b/Libs/DF/fw.lua Tue Jul 19 13:23:40 2016 -0300 @@ -1,5 +1,5 @@ -local dversion = 16 +local dversion = 22 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary (major, minor) @@ -30,6 +30,9 @@ DF.SwitchCounter = DF.SwitchCounter or init_counter DF.SplitBarCounter = DF.SplitBarCounter or init_counter +DF.FRAMELEVEL_OVERLAY = 750 +DF.FRAMELEVEL_BACKGROUND = 150 + DF.FrameWorkVersion = tostring (dversion) function DF:PrintVersion() print ("Details! Framework Version:", DF.FrameWorkVersion) @@ -104,6 +107,9 @@ "InstallTemplate", "GetFrameworkFolder", "ShowPanicWarning", + "SetFrameworkDebugState", + "FindHighestParent", + "OpenInterfaceProfile", } DF.table = {} @@ -112,6 +118,10 @@ return DF.folder end +function DF:SetFrameworkDebugState (state) + DF.debug = state +end + function DF:FadeFrame (frame, t) if (t == 0) then frame.hidden = false @@ -332,11 +342,13 @@ FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime FlashAnimation.fadeOut:SetOrder (1) - FlashAnimation.fadeOut:SetChange (1) + FlashAnimation.fadeOut:SetFromAlpha (0) + FlashAnimation.fadeOut:SetToAlpha (1) FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime FlashAnimation.fadeIn:SetOrder (2) - FlashAnimation.fadeIn:SetChange (-1) + FlashAnimation.fadeIn:SetFromAlpha (1) + FlashAnimation.fadeIn:SetToAlpha (0) frame.FlashAnimation = FlashAnimation FlashAnimation.frame = frame @@ -473,6 +485,8 @@ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> menus + local disable_on_combat = {} + function DF:BuildMenu (parent, menu, x_offset, y_offset, height, use_two_points, text_template, dropdown_template, switch_template, switch_is_box, slider_template, button_template) if (not parent.widget_list) then @@ -488,6 +502,8 @@ for index, widget_table in ipairs (menu) do + local widget_created + if (widget_table.type == "blank" or widget_table.type == "space") then -- do nothing @@ -513,6 +529,7 @@ end tinsert (parent.widget_list, dropdown) + widget_created = dropdown elseif (widget_table.type == "toggle" or widget_table.type == "switch") then local switch = DF:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get(), nil, nil, nil, nil, switch_template) @@ -535,6 +552,7 @@ end tinsert (parent.widget_list, switch) + widget_created = switch elseif (widget_table.type == "range" or widget_table.type == "slider") then local is_decimanls = widget_table.usedecimals @@ -554,6 +572,7 @@ end tinsert (parent.widget_list, slider) + widget_created = slider elseif (widget_table.type == "color" or widget_table.type == "color") then local colorpick = DF:NewColorPickButton (parent, "$parentWidget" .. index, nil, widget_table.set, nil, button_template) @@ -578,6 +597,7 @@ end tinsert (parent.widget_list, colorpick) + widget_created = colorpick elseif (widget_table.type == "execute" or widget_table.type == "button") then @@ -596,8 +616,13 @@ end tinsert (parent.widget_list, button) + widget_created = button end + + if (widget_table.nocombat) then + tinsert (disable_on_combat, widget_created) + end if (widget_table.spacement) then cur_y = cur_y - 30 @@ -605,16 +630,59 @@ cur_y = cur_y - 20 end - if (cur_y < height) then + if (widget_table.type == "breakline" or cur_y < height) then cur_y = y_offset cur_x = cur_x + max_x + 30 - max_x = 0 end end + DF.RefreshUnsafeOptionsWidgets() + end + + local lock_notsafe_widgets = function() + for _, widget in ipairs (disable_on_combat) do + widget:Disable() + end + end + local unlock_notsafe_widgets = function() + for _, widget in ipairs (disable_on_combat) do + widget:Enable() + end + end + function DF.RefreshUnsafeOptionsWidgets() + if (DF.PlayerHasCombatFlag) then + lock_notsafe_widgets() + else + unlock_notsafe_widgets() + end + end + DF.PlayerHasCombatFlag = false + local ProtectCombatFrame = CreateFrame ("frame") + ProtectCombatFrame:RegisterEvent ("PLAYER_REGEN_ENABLED") + ProtectCombatFrame:RegisterEvent ("PLAYER_REGEN_DISABLED") + ProtectCombatFrame:RegisterEvent ("PLAYER_ENTERING_WORLD") + ProtectCombatFrame:SetScript ("OnEvent", function (self, event) + if (event == "PLAYER_ENTERING_WORLD") then + if (InCombatLockdown()) then + DF.PlayerHasCombatFlag = true + else + DF.PlayerHasCombatFlag = false + end + DF.RefreshUnsafeOptionsWidgets() + + elseif (event == "PLAYER_REGEN_ENABLED") then + DF.PlayerHasCombatFlag = false + DF.RefreshUnsafeOptionsWidgets() + + elseif (event == "PLAYER_REGEN_DISABLED") then + DF.PlayerHasCombatFlag = true + DF.RefreshUnsafeOptionsWidgets() + + end + end) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> tutorials @@ -922,3 +990,139 @@ end return parentName end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +--> widget scripts and hooks + +function DF:RunHooksForWidget (event, ...) + local hooks = self.HookList [event] + + if (not hooks) then + print (self.widget:GetName(), "sem hook para", event) + return + end + + for i, func in ipairs (hooks) do + local success, canInterrupt = pcall (func, ...) + if (not success) then + error ("Details! Framework: " .. event .. " hook for " .. self:GetName() .. ": " .. canInterrupt) + elseif (canInterrupt) then + return true + end + end +end + +function DF:SetHook (hookType, func) + if (self.HookList [hookType]) then + if (type (func) == "function") then + local isRemoval = false + for i = #self.HookList [hookType], 1, -1 do + if (self.HookList [hookType] [i] == func) then + tremove (self.HookList [hookType], i) + isRemoval = true + break + end + end + if (not isRemoval) then + tinsert (self.HookList [hookType], func) + end + else + if (DF.debug) then + error ("Details! Framework: invalid function for widget " .. self.WidgetType .. ".") + end + end + else + if (DF.debug) then + error ("Details! Framework: unknown hook type for widget " .. self.WidgetType .. ": '" .. hookType .. "'.") + end + end +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +--> members + +DF.GlobalWidgetControlNames = { + textentry = "DF_TextEntryMetaFunctions", + button = "DF_ButtonMetaFunctions", + panel = "DF_PanelMetaFunctions", + dropdown = "DF_DropdownMetaFunctions", + label = "DF_LabelMetaFunctions", + normal_bar = "DF_NormalBarMetaFunctions", + image = "DF_ImageMetaFunctions", + slider = "DF_SliderMetaFunctions", + split_bar = "DF_SplitBarMetaFunctions", +} + +function DF:AddMemberForWidget (widgetName, memberType, memberName, func) + if (DF.GlobalWidgetControlNames [widgetName]) then + if (type (memberName) == "string" and (memberType == "SET" or memberType == "GET")) then + if (func) then + local widgetControlObject = _G [DF.GlobalWidgetControlNames [widgetName]] + + if (memberType == "SET") then + widgetControlObject ["SetMembers"] [memberName] = func + elseif (memberType == "GET") then + widgetControlObject ["GetMembers"] [memberName] = func + end + else + if (DF.debug) then + error ("Details! Framework: AddMemberForWidget invalid function.") + end + end + else + if (DF.debug) then + error ("Details! Framework: AddMemberForWidget unknown memberName or memberType.") + end + end + else + if (DF.debug) then + error ("Details! Framework: AddMemberForWidget unknown widget type: " .. (widgetName or "") .. ".") + end + end +end + +----------------------------- + +function DF:OpenInterfaceProfile() + InterfaceOptionsFrame_OpenToCategory (self.__name) + InterfaceOptionsFrame_OpenToCategory (self.__name) + for i = 1, 100 do + local button = _G ["InterfaceOptionsFrameAddOnsButton" .. i] + if (button) then + local text = _G ["InterfaceOptionsFrameAddOnsButton" .. i .. "Text"] + if (text) then + text = text:GetText() + if (text == self.__name) then + local toggle = _G ["InterfaceOptionsFrameAddOnsButton" .. i .. "Toggle"] + if (toggle) then + if (toggle:GetNormalTexture():GetTexture():find ("PlusButton")) then + --is minimized, need expand + toggle:Click() + _G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click() + elseif (toggle:GetNormalTexture():GetTexture():find ("MinusButton")) then + --isn't minimized + _G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click() + end + end + break + end + end + else + self:Msg ("Couldn't not find the profile panel.") + break + end + end +end + +----------------------------- +--safe copy from blizz api +function DF:Mixin (object, ...) + for i = 1, select("#", ...) do + local mixin = select(i, ...); + for k, v in pairs(mixin) do + object[k] = v; + end + end + + return object; +end diff -r 219f04e5ba55 -r 7944c081e5b4 Libs/DF/label.lua --- a/Libs/DF/label.lua Mon Jul 04 23:06:23 2016 -0300 +++ b/Libs/DF/label.lua Tue Jul 19 13:23:40 2016 -0300 @@ -15,7 +15,18 @@ local cleanfunction = function() end local APILabelFunctions = false -local LabelMetaFunctions = {} + +do + local metaPrototype = { + WidgetType = "label", + SetHook = DF.SetHook, + RunHooksForWidget = DF.RunHooksForWidget, + } + + _G [DF.GlobalWidgetControlNames ["label"]] = _G [DF.GlobalWidgetControlNames ["label"]] or metaPrototype +end + +local LabelMetaFunctions = _G [DF.GlobalWidgetControlNames ["label"]] ------------------------------------------------------------------------------------------------------------ --> metatables @@ -58,23 +69,21 @@ return fontsize end - - local get_members_function_index = { - ["shown"] = gmember_shown, - ["width"] = gmember_width, - ["height"] = gmember_height, - ["text"] = gmember_text, - ["fontcolor"] = gmember_textcolor, - ["fontface"] = gmember_textfont, - ["fontsize"] = gmember_textsize, - ["textcolor"] = gmember_textcolor, --alias - ["textfont"] = gmember_textfont, --alias - ["textsize"] = gmember_textsize --alias - } + LabelMetaFunctions.GetMembers = LabelMetaFunctions.GetMembers or {} + LabelMetaFunctions.GetMembers ["shown"] = gmember_shown + LabelMetaFunctions.GetMembers ["width"] = gmember_width + LabelMetaFunctions.GetMembers ["height"] = gmember_height + LabelMetaFunctions.GetMembers ["text"] = gmember_text + LabelMetaFunctions.GetMembers ["fontcolor"] = gmember_textcolor + LabelMetaFunctions.GetMembers ["fontface"] = gmember_textfont + LabelMetaFunctions.GetMembers ["fontsize"] = gmember_textsize + LabelMetaFunctions.GetMembers ["textcolor"] = gmember_textcolor --alias + LabelMetaFunctions.GetMembers ["textfont"] = gmember_textfont --alias + LabelMetaFunctions.GetMembers ["textsize"] = gmember_textsize --alias LabelMetaFunctions.__index = function (_table, _member_requested) - local func = get_members_function_index [_member_requested] + local func = LabelMetaFunctions.GetMembers [_member_requested] if (func) then return func (_table, _member_requested) end @@ -157,27 +166,26 @@ DF:SetFontOutline (_object.label, _value) end - local set_members_function_index = { - ["show"] = smember_show, - ["hide"] = smember_hide, - ["align"] = smember_textalign, - ["valign"] = smember_textvalign, - ["text"] = smember_text, - ["width"] = smember_width, - ["height"] = smember_height, - ["fontcolor"] = smember_textcolor, - ["color"] = smember_textcolor,--alias - ["fontface"] = smember_textfont, - ["fontsize"] = smember_textsize, - ["textcolor"] = smember_textcolor,--alias - ["textfont"] = smember_textfont,--alias - ["textsize"] = smember_textsize,--alias - ["shadow"] = smember_outline, - ["outline"] = smember_outline,--alias - } + LabelMetaFunctions.SetMembers = LabelMetaFunctions.SetMembers or {} + LabelMetaFunctions.SetMembers["show"] = smember_show + LabelMetaFunctions.SetMembers["hide"] = smember_hide + LabelMetaFunctions.SetMembers["align"] = smember_textalign + LabelMetaFunctions.SetMembers["valign"] = smember_textvalign + LabelMetaFunctions.SetMembers["text"] = smember_text + LabelMetaFunctions.SetMembers["width"] = smember_width + LabelMetaFunctions.SetMembers["height"] = smember_height + LabelMetaFunctions.SetMembers["fontcolor"] = smember_textcolor + LabelMetaFunctions.SetMembers["color"] = smember_textcolor--alias + LabelMetaFunctions.SetMembers["fontface"] = smember_textfont + LabelMetaFunctions.SetMembers["fontsize"] = smember_textsize + LabelMetaFunctions.SetMembers["textcolor"] = smember_textcolor--alias + LabelMetaFunctions.SetMembers["textfont"] = smember_textfont--alias + LabelMetaFunctions.SetMembers["textsize"] = smember_textsize--alias + LabelMetaFunctions.SetMembers["shadow"] = smember_outline + LabelMetaFunctions.SetMembers["outline"] = smember_outline--alias LabelMetaFunctions.__newindex = function (_table, _key, _value) - local func = set_members_function_index [_key] + local func = LabelMetaFunctions.SetMembers [_key] if (func) then return func (_table, _value) else @@ -305,7 +313,8 @@ DF:SetFontSize (LabelObject.label, size) end - + LabelObject.HookList = { + } LabelObject.label:SetJustifyH ("LEFT") diff -r 219f04e5ba55 -r 7944c081e5b4 Libs/DF/load.xml --- a/Libs/DF/load.xml Mon Jul 04 23:06:23 2016 -0300 +++ b/Libs/DF/load.xml Tue Jul 19 13:23:40 2016 -0300 @@ -8,6 +8,7 @@