From f1fa3f5cfe908320454afb376ab0d1fadb1ba7b6 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Fri, 7 Oct 2022 11:16:31 -0300 Subject: [PATCH] framework update --- Libs/DF/dropdown.lua | 110 +++++++++++++++++++++---------------------- Libs/DF/fw.lua | 9 ++++ Libs/DF/mixins.lua | 102 ++++++++++++++++++++++----------------- Libs/DF/slider.lua | 2 +- core/network.lua | 6 +-- 5 files changed, 127 insertions(+), 102 deletions(-) diff --git a/Libs/DF/dropdown.lua b/Libs/DF/dropdown.lua index aae4ec8a..3395fc0c 100644 --- a/Libs/DF/dropdown.lua +++ b/Libs/DF/dropdown.lua @@ -750,7 +750,7 @@ function DetailsFrameworkDropDownOnMouseDown(button, buttontype) if (currentText) then selectedTexture:Hide() else - selectedTexture:SetWidth(frameWitdh-20) + selectedTexture:SetWidth(frameWitdh - 20) end for o = showing + 1, #object.menus do @@ -764,7 +764,7 @@ function DetailsFrameworkDropDownOnMouseDown(button, buttontype) object:ShowScroll() scrollFrame:EnableMouseWheel(true) object.scroll:Altura(size-35) --height - object.scroll:SetMinMaxValues(0, (showing*20) - size + 2) + object.scroll:SetMinMaxValues(0, (showing * 20) - size + 2) --width scrollBorder:SetWidth(frameWitdh+20) @@ -774,16 +774,16 @@ function DetailsFrameworkDropDownOnMouseDown(button, buttontype) --height scrollBorder:SetHeight(size+2) scrollFrame:SetHeight(size+2) - scrollChild:SetHeight((showing*20)+20) + scrollChild:SetHeight((showing * 20) + 20) --mouse over texture - mouseOverTexture:SetWidth(frameWitdh-7) + mouseOverTexture:SetWidth(frameWitdh - 7) --selected selectedTexture:SetWidth(frameWitdh - 9) for index, row in ipairs(object.menus) do - row:SetPoint("topright", scrollChild, "topright", -22, ((-index-1)*20)-5) + row:SetPoint("topright", scrollChild, "topright", -22, ((-index-1) * 20) - 5) end else --hide scrollbar and disable wheel @@ -794,20 +794,20 @@ function DetailsFrameworkDropDownOnMouseDown(button, buttontype) scrollFrame:SetWidth(frameWitdh) scrollChild:SetWidth(frameWitdh) --height - scrollBorder:SetHeight((showing*20) + 1) - scrollFrame:SetHeight((showing*20) + 1) + scrollBorder:SetHeight((showing * 20) + 1) + scrollFrame:SetHeight((showing * 20) + 1) --mouse over texture mouseOverTexture:SetWidth(frameWitdh - 1) --selected selectedTexture:SetWidth(frameWitdh - 1) for index, row in ipairs(object.menus) do - row:SetPoint("topright", scrollChild, "topright", -5, ((-index-1)*20)-5) + row:SetPoint("topright", scrollChild, "topright", -5, ((-index-1) * 20) -5) end end if (object.myvaluelabel and currentIndex and scrollFrame.slider:IsShown()) then - object.scroll:SetValue(max((currentIndex*20) - 80, 0)) + object.scroll:SetValue(max((currentIndex * 20) - 80, 0)) else object.scroll:SetValue(0) end @@ -1123,68 +1123,68 @@ local borderBackdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, local childBackdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 256, insets = {left = 0, right = 0, top = 0, bottom = 0}} function DF:CreateNewDropdownFrame(parent, name) - local f = CreateFrame("button", name, parent, "BackdropTemplate") - f:SetBackdrop(defaultBackdrop) - f:SetBackdropColor(1, 1, 1, .5) - f:SetSize(150, 20) + local newDropdownFrame = CreateFrame("button", name, parent, "BackdropTemplate") + newDropdownFrame:SetBackdrop(defaultBackdrop) + newDropdownFrame:SetBackdropColor(1, 1, 1, .5) + newDropdownFrame:SetSize(150, 20) - local statusbar = f:CreateTexture("$parent_StatusBarTexture", "BACKGROUND") - statusbar:SetPoint("topleft", f, "topleft", 0, 0) - statusbar:SetPoint("bottomright", f, "bottomright", 0, 0) - f.statusbar = statusbar + local statusbar = newDropdownFrame:CreateTexture("$parent_StatusBarTexture", "BACKGROUND") + statusbar:SetPoint("topleft", newDropdownFrame, "topleft", 0, 0) + statusbar:SetPoint("bottomright", newDropdownFrame, "bottomright", 0, 0) + newDropdownFrame.statusbar = statusbar - local icon = f:CreateTexture("$parent_IconTexture", "ARTWORK") - icon:SetPoint("left", f, "left", 2, 0) + local icon = newDropdownFrame:CreateTexture("$parent_IconTexture", "ARTWORK") + icon:SetPoint("left", newDropdownFrame, "left", 2, 0) icon:SetSize(20, 20) icon:SetTexture([[Interface\COMMON\UI-ModelControlPanel]]) icon:SetTexCoord(0.625, 0.78125, 0.328125, 0.390625) icon:SetVertexColor(1, 1, 1, 0.4) - f.icon = icon + newDropdownFrame.icon = icon - local text = f:CreateFontString("$parent_Text", "ARTWORK", "GameFontHighlightSmall") + local text = newDropdownFrame:CreateFontString("$parent_Text", "ARTWORK", "GameFontHighlightSmall") text:SetPoint("left", icon, "right", 5, 0) text:SetJustifyH("left") text:SetText("no option selected") text:SetTextColor(1, 1, 1, 0.4) DF:SetFontSize(text, 10) - f.text = text + newDropdownFrame.text = text - local arrowHightlight = f:CreateTexture ("$parent_ArrowTexture2", "OVERLAY", nil, 2) - arrowHightlight:SetPoint ("right", f, "right", 5, -1) + local arrowHightlight = newDropdownFrame:CreateTexture("$parent_ArrowTexture2", "OVERLAY", nil, 2) + arrowHightlight:SetPoint ("right", newDropdownFrame, "right", 5, -1) arrowHightlight:SetBlendMode ("ADD") arrowHightlight:SetTexture ([[Interface\Buttons\UI-ScrollBar-ScrollDownButton-Highlight]]) arrowHightlight:Hide() arrowHightlight:SetSize (32, 28) - f.arrowTexture2 = arrowHightlight + newDropdownFrame.arrowTexture2 = arrowHightlight - local arrowTexture = f:CreateTexture("$parent_ArrowTexture", "OVERLAY", nil, 1) - arrowTexture:SetPoint("right", f, "right", 5, -1) + local arrowTexture = newDropdownFrame:CreateTexture("$parent_ArrowTexture", "OVERLAY", nil, 1) + arrowTexture:SetPoint("right", newDropdownFrame, "right", 5, -1) arrowTexture:SetTexture([[Interface\Buttons\UI-ScrollBar-ScrollDownButton-Up]]) arrowTexture:SetSize(32, 28) - f.arrowTexture = arrowTexture + newDropdownFrame.arrowTexture = arrowTexture --scripts - f:SetScript ("OnSizeChanged", DetailsFrameworkDropDownOnSizeChanged) - f:SetScript ("OnMouseDown", DetailsFrameworkDropDownOnMouseDown) + newDropdownFrame:SetScript("OnSizeChanged", DetailsFrameworkDropDownOnSizeChanged) + newDropdownFrame:SetScript("OnMouseDown", DetailsFrameworkDropDownOnMouseDown) --dropdown - local border = CreateFrame("frame", "$Parent_Border", f, "BackdropTemplate") + local border = CreateFrame("frame", "$Parent_Border", newDropdownFrame, "BackdropTemplate") border:Hide() border:SetFrameStrata("FULLSCREEN") border:SetSize(150, 150) - border:SetPoint("topleft", f, "bottomleft", 0, 0) + border:SetPoint("topleft", newDropdownFrame, "bottomleft", 0, 0) border:SetBackdrop(borderBackdrop) border:SetScript("OnHide", DetailsFrameworkDropDownOptionsFrameOnHide) border:SetBackdropColor(0, 0, 0, 0.92) border:SetBackdropBorderColor(0, 0, 0, 1) - f.dropdownborder = border + newDropdownFrame.dropdownborder = border - local scroll = CreateFrame("ScrollFrame", "$Parent_ScrollFrame", f, "BackdropTemplate") + local scroll = CreateFrame("ScrollFrame", "$Parent_ScrollFrame", newDropdownFrame, "BackdropTemplate") scroll:SetFrameStrata("FULLSCREEN") scroll:SetSize(150, 150) - scroll:SetPoint("topleft", f, "bottomleft", 0, 0) + scroll:SetPoint("topleft", newDropdownFrame, "bottomleft", 0, 0) scroll:Hide() - f.dropdownframe = scroll + newDropdownFrame.dropdownframe = scroll local child = CreateFrame("frame", "$Parent_ScrollChild", scroll, "BackdropTemplate") child:SetSize(150, 150) @@ -1214,41 +1214,41 @@ function DF:CreateNewDropdownFrame(parent, name) child.mouseover = mouseover scroll:SetScrollChild(child) - tinsert(UISpecialFrames, f.dropdownborder:GetName()) + tinsert(UISpecialFrames, newDropdownFrame.dropdownborder:GetName()) --tinsert(UISpecialFrames, f.dropdownframe:GetName()) --not adding this solves an issue with ConsolePort addon and stackoverflows on Hide... - return f + return newDropdownFrame end function DF:CreateDropdownButton(parent, name) - local f = CreateFrame("button", name, parent, "BackdropTemplate") - f:SetSize(150, 20) + local newButton = CreateFrame("button", name, parent, "BackdropTemplate") + newButton:SetSize(150, 20) - local statusbar = f:CreateTexture("$parent_StatusBarTexture", "ARTWORK") - statusbar:SetPoint("topleft", f, "topleft", 0, 0) - statusbar:SetPoint("bottomright", f, "bottomright", 0, 0) + local statusbar = newButton:CreateTexture("$parent_StatusBarTexture", "ARTWORK") + statusbar:SetPoint("topleft", newButton, "topleft", 0, 0) + statusbar:SetPoint("bottomright", newButton, "bottomright", 0, 0) statusbar:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]]) - f.statusbar = statusbar + newButton.statusbar = statusbar - local icon = f:CreateTexture("$parent_IconTexture", "OVERLAY") - icon:SetPoint("left", f, "left", 2, 0) + local icon = newButton:CreateTexture("$parent_IconTexture", "OVERLAY") + icon:SetPoint("left", newButton, "left", 2, 0) icon:SetSize(20, 20) icon:SetTexture([[Interface\ICONS\Spell_ChargePositive]]) - f.icon = icon + newButton.icon = icon - local text = f:CreateFontString("$parent_Text", "OVERLAY", "GameFontHighlightSmall") + local text = newButton:CreateFontString("$parent_Text", "OVERLAY", "GameFontHighlightSmall") text:SetPoint("left", icon, "right", 5, 0) text:SetJustifyH("left") DF:SetFontSize(text, 10) - f.label = text + newButton.label = text - local rightButton = DF:CreateButton(f, function()end, 16, 16, "", 0, 0, "", "rightButton", "$parentRightButton", nil, DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) - rightButton:SetPoint("right", f, "right", -2, 0) + local rightButton = DF:CreateButton(newButton, function()end, 16, 16, "", 0, 0, "", "rightButton", "$parentRightButton", nil, DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + rightButton:SetPoint("right", newButton, "right", -2, 0) rightButton:Hide() - f:SetScript("OnMouseDown", DetailsFrameworkDropDownOptionClick) - f:SetScript("OnEnter", DetailsFrameworkDropDownOptionOnEnter) - f:SetScript("OnLeave", DetailsFrameworkDropDownOptionOnLeave) + newButton:SetScript("OnMouseDown", DetailsFrameworkDropDownOptionClick) + newButton:SetScript("OnEnter", DetailsFrameworkDropDownOptionOnEnter) + newButton:SetScript("OnLeave", DetailsFrameworkDropDownOptionOnLeave) - return f + return newButton end diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 95031502..48502d9d 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -107,6 +107,15 @@ function DF.IsShadowlandsWow() end end +function DF.GetContainerItemInfo(containerIndex, slotIndex) + if (DF.IsDragonflightAndBeyond()) then + local itemInfo = C_Container.GetContainerItemInfo(containerIndex, slotIndex) + return itemInfo.iconFileID, itemInfo.stackCount, itemInfo.isLocked, itemInfo.quality, itemInfo.isReadable, itemInfo.hasLoot, itemInfo.hyperlink, itemInfo.isFiltered, itemInfo.hasNoValue, itemInfo.itemID, itemInfo.isBound + else + return GetContainerItemInfo(containerIndex, slotIndex) + end +end + local roleBySpecTextureName = { DruidBalance = "DAMAGER", DruidFeralCombat = "DAMAGER", diff --git a/Libs/DF/mixins.lua b/Libs/DF/mixins.lua index 9d2c69db..4395d5b4 100644 --- a/Libs/DF/mixins.lua +++ b/Libs/DF/mixins.lua @@ -72,6 +72,57 @@ detailsFramework.LayeredRegionMetaFunctionsGet = { end, } +local getFrame = function(frame) + return rawget(frame, "widget") or frame +end + +detailsFramework.FrameMixin = { + SetFrameStrata = function(self, strata) + self = getFrame(self) + if (type(strata) == "table" and strata.GetObjectType) then + local UIObject = strata + self:SetFrameStrata(UIObject:GetFrameStrata()) + else + self:SetFrameStrata(strata) + end + end, + + SetFrameLevel = function(self, level, UIObject) + self = getFrame(self) + if (not UIObject) then + self:SetFrameLevel(level) + else + local framelevel = UIObject:GetFrameLevel(UIObject) + level + self:SetFrameLevel(framelevel) + end + end, + + SetSize = function(self, width, height) + self = getFrame(self) + if (width) then + self:SetWidth(width) + end + if (height) then + self:SetHeight(height) + end + end, + + SetBackdrop = function(self, ...) + self = getFrame(self) + self:SetBackdrop(...) + end, + + SetBackdropColor = function(self, ...) + self = getFrame(self) + self:SetBackdropColor(...) + end, + + SetBackdropBorderColor = function(self, ...) + self = getFrame(self) + getFrame(self):SetBackdropBorderColor(...) + end, +} + local doublePoint = { ["lefts"] = true, ["rights"] = true, @@ -89,47 +140,6 @@ 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 @@ -137,7 +147,7 @@ detailsFramework.SetPointMixin = { local anchorTo if (anchorObject and type(anchorObject) == "table") then xOffset, yOffset = anchorName2 or 0, xOffset or 0 - anchorTo = anchorObject.widget or anchorObject + anchorTo = getFrame(anchorObject) else xOffset, yOffset = anchorObject or 0, anchorName2 or 0 anchorTo = object:GetParent() @@ -200,7 +210,13 @@ detailsFramework.SetPointMixin = { error("SetPoint: Invalid parameter.") return end - return object.widget:SetPoint(anchorName1, anchorObject, anchorName2, xOffset, yOffset) + + if (not object.widget) then + local SetPoint = getmetatable(object).__index.SetPoint + return SetPoint(object, anchorName1, anchorObject, anchorName2, xOffset, yOffset) + else + return object.widget:SetPoint(anchorName1, anchorObject, anchorName2, xOffset, yOffset) + end end, } diff --git a/Libs/DF/slider.lua b/Libs/DF/slider.lua index 69cd4159..2a922bc7 100644 --- a/Libs/DF/slider.lua +++ b/Libs/DF/slider.lua @@ -1374,7 +1374,7 @@ local createAdjustmentSliderFrames = function(parent, options, name) DF:Mixin(adjustmentSlider, DF.AdjustmentSliderFunctions) DF:Mixin(adjustmentSlider, DF.PayloadMixin) DF:Mixin(adjustmentSlider, DF.SetPointMixin) - DF:Mixin(adjustmentSlider, DF.FrameMixin) + --DF:Mixin(adjustmentSlider, DF.FrameMixin) adjustmentSlider:BuildOptionsTable(DF.AdjustmentSliderOptions, options) adjustmentSlider:SetSize(adjustmentSlider.options.width, adjustmentSlider.options.height) diff --git a/core/network.lua b/core/network.lua index 7c635dfe..8223c2ee 100644 --- a/core/network.lua +++ b/core/network.lua @@ -71,7 +71,6 @@ } local registredPlugins = {} - local temp = {} ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> comm functions @@ -444,11 +443,12 @@ return end - local prefix, player, realm, coreVersion, arg6, arg7, arg8, arg9 = select(2, deserializedTable) + tremove(deserializedTable, 1) + local prefix, player, realm, coreVersion, arg6, arg7, arg8, arg9 = unpack(deserializedTable) player = source if (Details.debugnet) then - Details:Msg("(debug) network received:", prefix, "length:", string.len(data)) + Details:Msg("(debug) network received prefix:", prefix, "length:", string.len(data)) end if (type(prefix) ~= "string") then