diff --git a/Libs/DF/frames.lua b/Libs/DF/frames.lua new file mode 100644 index 00000000..9494b82f --- /dev/null +++ b/Libs/DF/frames.lua @@ -0,0 +1,106 @@ + +local detailsFramework = _G.DetailsFramework +if (not detailsFramework or not DetailsFrameworkCanLoad) then + return +end + +local CreateFrame = CreateFrame + +---@class df_roundedpanel : frame, blz_backdrop, df_optionsmixin, df_titlebar +---@field cornerTextures texture[] +---@field edgeTextures texture[] +---@field Constructor fun(self:df_roundedpanel) + +---@class blz_backdrop : table +---@field TopLeftCorner texture +---@field TopRightCorner texture +---@field BottomLeftCorner texture +---@field BottomRightCorner texture +---@field TopEdge texture +---@field BottomEdge texture +---@field LeftEdge texture +---@field RightEdge texture +---@field Center texture + +detailsFramework.RoundedCornerPanelMixin = { + Constructor = function(self) + self.cornerTextures = {} + self.edgeTextures = {} + + local red, green, blue, alpha = detailsFramework:GetDefaultBackdropColor() + + self:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) + self:SetBackdropColor(red, green, blue, alpha * 0.95) + self:SetBackdropBorderColor(0, 0, 0, 0.95) + + self.__background = self:CreateTexture(nil, "border", nil, -6) + self.__background:SetColorTexture(red, green, blue) + self.__background:SetAllPoints() + + self:SetSize(self.options.width, self.options.height) + + if (self.options.use_titlebar) then + detailsFramework:CreateTitleBar(self) + self:SetTitle(self.options.title) + end + + if (self.options.use_scalebar) then + detailsFramework:CreateScaleBar(self, self.options) + self:SetScale(self.options.scale) + end + + --fill the corner and edge textures table + for index, cornerName in ipairs({"TopLeftCorner", "TopRightCorner", "BottomLeftCorner", "BottomRightCorner"}) do + local thisTexture = self[cornerName] + self.cornerTextures[cornerName] = thisTexture + thisTexture:SetTexture([[Interface\CHARACTERFRAME\TempPortraitAlphaMaskSmall]]) + + --local bIsOdd = index % 2 == 1 + --thisTexture:SetTexCoord(bIsOdd and 0 or 0.5, index < 3 and 0 or 0.5, bIsOdd and 0.5 or 1, index < 3 and 0.5 or 1) + + if (cornerName == "TopLeftCorner") then + thisTexture:SetTexCoord(0, 0.5, 0, 0.5) + elseif (cornerName == "TopRightCorner") then + thisTexture:SetTexCoord(0.5, 1, 0, 0.5) + elseif (cornerName == "BottomLeftCorner") then + thisTexture:SetTexCoord(0, 0.5, 0.5, 1) + elseif (cornerName == "BottomRightCorner") then + thisTexture:SetTexCoord(0.5, 1, 0.5, 1) + end + end + + for _, edgeName in ipairs({"TopEdge", "BottomEdge", "LeftEdge", "RightEdge"}) do + self.edgeTextures[edgeName] = self[edgeName] + end + end, +} + +local defaultOptions = { + width = 200, + height = 200, + use_titlebar = true, + use_scalebar = true, + title = "", + scale = 1, +} + +---create a regular panel with rounded corner +---@param parent frame +---@param name string|nil +---@param optionsTable table|nil +---@return df_roundedpanel +function detailsFramework:CreateRoundedPanel(parent, name, optionsTable) + ---@type df_roundedpanel + local newRoundedPanel = CreateFrame("frame", name, parent, "BackdropTemplate") + newRoundedPanel:EnableMouse(true) + newRoundedPanel.__dftype = "df_roundedpanel" + + detailsFramework:Mixin(newRoundedPanel, detailsFramework.RoundedCornerPanelMixin) + detailsFramework:Mixin(newRoundedPanel, detailsFramework.OptionsFunctions) + + newRoundedPanel:BuildOptionsTable(defaultOptions, optionsTable or {}) + + newRoundedPanel:Constructor() + + return newRoundedPanel +end \ No newline at end of file diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 1ca5e160..e74a840d 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 444 +local dversion = 445 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary(major, minor) @@ -124,9 +124,9 @@ end ---return true if the player is playing in the WotLK version of wow with the retail api ---@return boolean -function DF.IsWotLKWowWithRetailAPI() +function DF.IsNonRetailWowWithRetailAPI() local _, _, _, buildInfo = GetBuildInfo() - if (buildInfo < 40000 and buildInfo >= 30401) then + if (buildInfo < 40000 and buildInfo >= 30401) or (buildInfo < 20000 and buildInfo >= 11404) then return true end return false @@ -263,7 +263,7 @@ function DF.UnitGroupRolesAssigned(unitId) end end ----return the specialization of the player it self +---return the specializationid of the player it self ---@return number|nil function DF.GetSpecialization() if (GetSpecialization) then @@ -272,7 +272,7 @@ function DF.GetSpecialization() return nil end ----return the specialization using the specId +---return the specializationid using the specId ---@param specId unknown function DF.GetSpecializationInfoByID(specId) if (GetSpecializationInfoByID) then @@ -3394,7 +3394,7 @@ function DF:CreateAnimation(animation, animationType, order, duration, arg1, arg anim:SetToAlpha(arg2) elseif (animationType == "SCALE") then - if (DF.IsDragonflight() or DF.IsWotLKWowWithRetailAPI()) then + if (DF.IsDragonflight() or DF.IsNonRetailWowWithRetailAPI()) then anim:SetScaleFrom(arg1, arg2) anim:SetScaleTo(arg3, arg4) else diff --git a/Libs/DF/load.xml b/Libs/DF/load.xml index 9e5dcd29..e065eaf4 100644 --- a/Libs/DF/load.xml +++ b/Libs/DF/load.xml @@ -23,6 +23,7 @@