Better options for Real Time DPS

- Removed 'Real Time DPS' from the time measure dropdown.
- Added "Show 'Real Time' DPS" toggle to show real time dps while in combat.
- Added "Order Bars By Real Time DPS" toggle to order bars by the amount of real time dps.
- Added "Always Use Real Time in Arenas" toggle to always use real time dps in Arenas.
- Added .last_dps_realtime to player actors, caches the latest real time dps calculated.
This commit is contained in:
Tercio Jose
2023-07-24 16:43:34 -03:00
parent ae490f434d
commit 762c80669d
51 changed files with 2300 additions and 887 deletions
@@ -127,7 +127,7 @@ do
tooltip = CreateFrame ("frame", nil, UIParent, "BackdropTemplate")
tooltip:SetFrameStrata ("tooltip")
tooltip:SetSize (1, 1)
Details.gump:CreateBorder (tooltip)
_detalhes.gump:CreateBorder (tooltip)
tooltip:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true})
tooltip:SetBackdropColor (.2, .2, .2, .99)
tooltip:SetBackdropBorderColor (unpack (comparisonFrameSettings.tooltipBorderColor))
@@ -218,7 +218,7 @@ do
tooltip = CreateFrame ("frame", nil, UIParent, "BackdropTemplate")
tooltip:SetFrameStrata ("tooltip")
tooltip:SetSize (1, 1)
Details.gump:CreateBorder (tooltip)
_detalhes.gump:CreateBorder (tooltip)
tooltip:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true})
tooltip:SetBackdropColor (0, 0, 0, 1)
tooltip:SetBackdropBorderColor (unpack (comparisonFrameSettings.tooltipBorderColor))
@@ -1,7 +1,7 @@
DETAILS_STORAGE_VERSION = 5
function Details:CreateStorageDB()
function _detalhes:CreateStorageDB()
DetailsDataStorage = {
VERSION = DETAILS_STORAGE_VERSION,
[14] = {}, --normal mode (raid)
@@ -19,18 +19,18 @@ f:RegisterEvent ("ADDON_LOADED")
f:SetScript ("OnEvent", function (self, event, addonName)
if (addonName == "Details_DataStorage") then
DetailsDataStorage = DetailsDataStorage or Details:CreateStorageDB()
DetailsDataStorage = DetailsDataStorage or _detalhes:CreateStorageDB()
DetailsDataStorage.Data = {}
if (DetailsDataStorage.VERSION < DETAILS_STORAGE_VERSION) then
--> do revisions
if (DetailsDataStorage.VERSION < 5) then
table.wipe (DetailsDataStorage)
DetailsDataStorage = Details:CreateStorageDB()
DetailsDataStorage = _detalhes:CreateStorageDB()
end
end
if (Details and Details.debug) then
if (_detalhes and _detalhes.debug) then
print ("|cFFFFFF00Details! Storage|r: loaded!")
end
DETAILS_STORAGE_LOADED = true
@@ -259,9 +259,12 @@ local function CreatePluginFrames(data)
return encounterDetails:CloseWindow()
end
DetailsPluginContainerWindow.OpenPlugin(encounterDetails)
--build all window data
encounterDetails.db.opened = encounterDetails.db.opened + 1
encounterDetails:OpenAndRefresh()
--show
edFrame:Show()
encounterDetails.open = true
@@ -282,14 +285,13 @@ local function CreatePluginFrames(data)
end
end
DetailsPluginContainerWindow.OpenPlugin(encounterDetails)
return true
end
function encounterDetails:CloseWindow()
encounterDetails.open = false
edFrame:Hide()
Details:CloseBreakdownWindow()
return true
end
@@ -1,137 +0,0 @@
--- **AceLocale-3.0** manages localization in addons, allowing for multiple locale to be registered with fallback to the base locale for untranslated strings.
-- @class file
-- @name AceLocale-3.0
-- @release $Id: AceLocale-3.0.lua 1035 2011-07-09 03:20:13Z kaelten $
local MAJOR,MINOR = "AceLocale-3.0", 6
local AceLocale, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
if not AceLocale then return end -- no upgrade needed
-- Lua APIs
local assert, tostring, error = assert, tostring, error
local getmetatable, setmetatable, rawset, rawget = getmetatable, setmetatable, rawset, rawget
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: GAME_LOCALE, geterrorhandler
local gameLocale = GetLocale()
if gameLocale == "enGB" then
gameLocale = "enUS"
end
AceLocale.apps = AceLocale.apps or {} -- array of ["AppName"]=localetableref
AceLocale.appnames = AceLocale.appnames or {} -- array of [localetableref]="AppName"
-- This metatable is used on all tables returned from GetLocale
local readmeta = {
__index = function(self, key) -- requesting totally unknown entries: fire off a nonbreaking error and return key
rawset(self, key, key) -- only need to see the warning once, really
geterrorhandler()(MAJOR..": "..tostring(AceLocale.appnames[self])..": Missing entry for '"..tostring(key).."'")
return key
end
}
-- This metatable is used on all tables returned from GetLocale if the silent flag is true, it does not issue a warning on unknown keys
local readmetasilent = {
__index = function(self, key) -- requesting totally unknown entries: return key
rawset(self, key, key) -- only need to invoke this function once
return key
end
}
-- Remember the locale table being registered right now (it gets set by :NewLocale())
-- NOTE: Do never try to register 2 locale tables at once and mix their definition.
local registering
-- local assert false function
local assertfalse = function() assert(false) end
-- This metatable proxy is used when registering nondefault locales
local writeproxy = setmetatable({}, {
__newindex = function(self, key, value)
rawset(registering, key, value == true and key or value) -- assigning values: replace 'true' with key string
end,
__index = assertfalse
})
-- This metatable proxy is used when registering the default locale.
-- It refuses to overwrite existing values
-- Reason 1: Allows loading locales in any order
-- Reason 2: If 2 modules have the same string, but only the first one to be
-- loaded has a translation for the current locale, the translation
-- doesn't get overwritten.
--
local writedefaultproxy = setmetatable({}, {
__newindex = function(self, key, value)
if not rawget(registering, key) then
rawset(registering, key, value == true and key or value)
end
end,
__index = assertfalse
})
--- Register a new locale (or extend an existing one) for the specified application.
-- :NewLocale will return a table you can fill your locale into, or nil if the locale isn't needed for the players
-- game locale.
-- @paramsig application, locale[, isDefault[, silent]]
-- @param application Unique name of addon / module
-- @param locale Name of the locale to register, e.g. "enUS", "deDE", etc.
-- @param isDefault If this is the default locale being registered (your addon is written in this language, generally enUS)
-- @param silent If true, the locale will not issue warnings for missing keys. Must be set on the first locale registered. If set to "raw", nils will be returned for unknown keys (no metatable used).
-- @usage
-- -- enUS.lua
-- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "enUS", true)
-- L["string1"] = true
--
-- -- deDE.lua
-- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "deDE")
-- if not L then return end
-- L["string1"] = "Zeichenkette1"
-- @return Locale Table to add localizations to, or nil if the current locale is not required.
function AceLocale:NewLocale(application, locale, isDefault, silent)
-- GAME_LOCALE allows translators to test translations of addons without having that wow client installed
local gameLocale = GAME_LOCALE or gameLocale
local app = AceLocale.apps[application]
if silent and app and getmetatable(app) ~= readmetasilent then
geterrorhandler()("Usage: NewLocale(application, locale[, isDefault[, silent]]): 'silent' must be specified for the first locale registered")
end
if not app then
if silent=="raw" then
app = {}
else
app = setmetatable({}, silent and readmetasilent or readmeta)
end
AceLocale.apps[application] = app
AceLocale.appnames[app] = application
end
if locale ~= gameLocale and not isDefault then
return -- nop, we don't need these translations
end
registering = app -- remember globally for writeproxy and writedefaultproxy
if isDefault then
return writedefaultproxy
end
return writeproxy
end
--- Returns localizations for the current locale (or default locale if translations are missing).
-- Errors if nothing is registered (spank developer, not just a missing translation)
-- @param application Unique name of addon / module
-- @param silent If true, the locale is optional, silently return nil if it's not found (defaults to false, optional)
-- @return The locale table for the current language.
function AceLocale:GetLocale(application, silent)
if not silent and not AceLocale.apps[application] then
error("Usage: GetLocale(application[, silent]): 'application' - No locales registered for '"..tostring(application).."'", 2)
end
return AceLocale.apps[application]
end
@@ -1,4 +0,0 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="AceLocale-3.0.lua"/>
</Ui>
@@ -855,6 +855,7 @@ end
end
---@class df_button : button
---@field widget button
---@field tooltip string
---@field shown boolean
---@field width number
@@ -17,6 +17,17 @@ local _
---@field Texture texture
---@field Label fontstring
---@class chart_backdropindicator : frame a frame which is used to indicate a specific time frame in the chart with a colored texture
---@field fieldTexture texture the texture which indicates the amount of time the effect was active, it is painted over the background texture
---@field fieldLabel fontstring the label showing the name of the indicator, example: bloodlust, heroism, etc
---@field indicatorTexture texture a small squere texture located in the top right of the chart frame, it is used to indicate the color of the indicator
---@field indicatorLabel fontstring the label showing the name of the indicator within the indicatorTexture
---@field bInUse boolean if the indicator is in use or not
---@field startTime number
---@field endTime number
---@field labelText string
---@field color color
---@alias x_axisdatatype
---| "time" when setting the text into the labels, it will be converted into a time format
---| "number" same as timer, but the number is not comverted to time
@@ -36,6 +47,11 @@ local _
---@field chartBottomOffset number the offset of the bottom side of the chart frame to the plot frame
---@field xAxisLabelsYOffset number default: -6, the offset of the horizontal axis labels to the horizontal axis line (y coordinate)
---@field smoothnessLevel number default: 0, the smoothness level of the chart lines, 0 is no smoothness
---@field backdropIndicators chart_backdropindicator[]
---@field nextBackdropIndicator number tell which is the next backdrop indicator to be used
---@field CreateBackdropIndicator fun(self: df_chartmulti|df_chart, index: number) : chart_backdropindicator create a new backdrop indicator
---@field GetBackdropIndicator fun(self: df_chartmulti|df_chart) : chart_backdropindicator get a backdrop indicator by index
---@field ResetBackdropIndicators fun(self: df_chartmulti|df_chart) reset all backdrop indicators
---@field SetAxesColor fun(self: df_chartmulti, red: number|string|table|nil, green: number|nil, blue: number|nil, alpha: number|nil) : boolean set the color of both axis lines
---@field SetAxesThickness fun(self: df_chartmulti, thickness: number) : boolean set the thickness of both axis lines
---@field CreateAxesLines fun(self: df_chartmulti|df_chart, xOffset: number, yOffset: number, whichSide: "left"|"right", thickness: number, amountYLabels: number, amountXLabels: number, red: any, green: number|nil, blue: number|nil, alpha: number|nil)
@@ -56,6 +72,8 @@ local chartFrameSharedConstructor = function(self)
self.chartBottomOffset = 0
self.xAxisLabelsYOffset = -6
self.smoothnessLevel = 0
self.backdropIndicators = {}
self.nextBackdropIndicator = 1
end
---@class df_chart: frame, df_data, df_value, df_chartshared
@@ -389,6 +407,138 @@ detailsFramework.ChartFrameSharedMixin = {
SetXAxisDataType = function(self, dataType)
setXAxisDataType(self, dataType)
end,
---create a new backdrop indicator, this is called from the function GetBackdropIndicator
---@param self df_chartmulti|df_chart
---@return chart_backdropindicator
CreateBackdropIndicator = function(self, nextIndicatorIndex)
---@type chart_backdropindicator
local newBackdropIndicator = CreateFrame("frame", "$parentBackdropIndicator" .. nextIndicatorIndex, self.plotFrame)
--make the backdrop indicators bebelow the plot frame
newBackdropIndicator:SetFrameLevel(self.plotFrame:GetFrameLevel() - 1)
newBackdropIndicator.fieldTexture = newBackdropIndicator:CreateTexture(nil, "overlay")
newBackdropIndicator.fieldTexture:SetAllPoints()
newBackdropIndicator.fieldLabel = newBackdropIndicator:CreateFontString(nil, "overlay", "GameFontNormal")
newBackdropIndicator.fieldLabel:SetTextColor(1, 1, 1, 0.3)
newBackdropIndicator.fieldLabel:SetJustifyH("left")
newBackdropIndicator.fieldLabel:SetJustifyV("top")
detailsFramework:SetFontSize(newBackdropIndicator.fieldLabel, 10)
newBackdropIndicator.fieldLabel:SetPoint("topleft", newBackdropIndicator.fieldTexture, "topleft", 2, -2)
newBackdropIndicator.indicatorTexture = newBackdropIndicator:CreateTexture(nil, "overlay")
newBackdropIndicator.indicatorTexture:SetSize(10, 10)
newBackdropIndicator.indicatorLabel = newBackdropIndicator:CreateFontString(nil, "overlay", "GameFontNormal")
newBackdropIndicator.indicatorLabel:SetTextColor(1, 1, 1, 0.837)
newBackdropIndicator.indicatorLabel:SetJustifyH("left")
newBackdropIndicator.indicatorLabel:SetPoint("left", newBackdropIndicator.indicatorTexture, "right", 2, 0)
return newBackdropIndicator
end,
---reset the backdrop indicators by hidding all of them
---@param self df_chartmulti|df_chart
ResetBackdropIndicators = function(self)
for i = 1, #self.backdropIndicators do
local thisBackdropIndicator = self.backdropIndicators[i]
thisBackdropIndicator:Hide()
thisBackdropIndicator.bInUse = false
end
self.nextBackdropIndicator = 1
end,
---get a backdrop indicator, if it doesn't exist, create a new one
---@param self df_chartmulti|df_chart
---@return chart_backdropindicator
GetBackdropIndicator = function(self)
local nextIndicator = self.nextBackdropIndicator
if (not self.backdropIndicators[nextIndicator]) then
self.backdropIndicators[nextIndicator] = self:CreateBackdropIndicator(nextIndicator)
end
self.nextBackdropIndicator = nextIndicator + 1
return self.backdropIndicators[nextIndicator]
end,
---add a backdrop indicator to the chart
---@param self df_chartmulti|df_chart
---@param label string this is a text to be displayed on the left side of the indicator and on the top right corner of the chart panel
---@param timeStart number the start time of the indicator
---@param timeEnd number the end time of the indicator
---@param red number|nil
---@param green number|nil
---@param blue number|nil
---@param alpha number|nil
AddBackdropIndicator = function(self, label, timeStart, timeEnd, red, green, blue, alpha)
assert(type(label) == "string", "AddBackdropIndicator: label must be a string.")
assert(type(timeStart) == "number", "AddBackdropIndicator: timeStart must be a number.")
assert(type(timeEnd) == "number", "AddBackdropIndicator: timeEnd must be a number.")
red, green, blue, alpha = detailsFramework:ParseColors(red, green, blue, alpha)
local backdropIndicator = self:GetBackdropIndicator()
backdropIndicator.bInUse = true
backdropIndicator.startTime = timeStart
backdropIndicator.endTime = timeEnd
backdropIndicator.labelText = label
backdropIndicator.color = {red, green, blue, alpha}
return true
end,
---when Plot() is called, this function will be called to show the backdrop indicators
---it gets the x_axisdatatype or if not existant defaults to "time", calculate the area in pixels using the plot area width and the plot area 'time'
---then set the texture color, label texts and show the small squere indicators in the top right of the plot area
---@param self df_chartmulti|df_chart
ShowBackdropIndicators = function(self)
--get the x axis data type
local xDataType = self.xAxisDataType or "time"
--get the max value of the data type
local dataSize = self.xAxisDataNumber or self.GetDataSize and self:GetDataSize() or 0
--frame width in pixels
local frameWidth = self.plotFrame:GetWidth()
for i = 1, self.nextBackdropIndicator-1 do
local thisIndicator = self.backdropIndicators[i]
if (not thisIndicator.bInUse) then
break
end
local startTime = thisIndicator.startTime
local endTime = thisIndicator.endTime
local labelText = thisIndicator.labelText
local color = thisIndicator.color
--set the point where the indicator will be placed
local startX = startTime / dataSize * frameWidth
local endX = endTime / dataSize * frameWidth
thisIndicator:SetPoint("topleft", self.plotFrame, "topleft", startX, 0)
thisIndicator:SetPoint("bottomright", self.plotFrame, "bottomleft", endX, 0)
thisIndicator.fieldLabel:SetText(labelText)
thisIndicator.fieldTexture:SetColorTexture(unpack(color))
thisIndicator.indicatorLabel:SetText(labelText)
thisIndicator.indicatorTexture:SetColorTexture(unpack(color))
local stringWidth = thisIndicator.indicatorLabel:GetStringWidth()
local squareWidth = thisIndicator.indicatorTexture:GetWidth()
if (i == 1) then
local space = stringWidth + squareWidth
thisIndicator.indicatorTexture:SetPoint("topright", self.plotFrame, "topright", -space + 2, -30)
else
local space = stringWidth + squareWidth + 10
thisIndicator.indicatorTexture:SetPoint("left", self.backdropIndicators[i-1].indicatorTexture, "left", -space, 0)
end
thisIndicator:Show()
end
end,
}
detailsFramework.ChartFrameMixin = {
@@ -481,7 +631,10 @@ detailsFramework.ChartFrameMixin = {
---@param self df_chart
Reset = function(self)
self:HideLines()
self:ResetMinMaxValues()
self.nextLine = 1
self.xAxisDataNumber = 0
self:ResetBackdropIndicators()
end,
---@param self df_chart
@@ -578,6 +731,8 @@ detailsFramework.ChartFrameMixin = {
line:SetEndPoint("bottomleft", currentXPoint, currentYPoint)
end
self:ShowBackdropIndicators()
if (bUpdateLabels or bUpdateLabels == nil) then
updateLabelValues(self)
end
@@ -735,7 +890,11 @@ detailsFramework.MultiChartFrameMixin = {
---@param self df_chartmulti
Reset = function(self)
self:HideCharts()
self:ResetMinMaxValues()
self:ResetBackdropIndicators()
self.nextChartFrame = 1
self.biggestDataValue = 0
self.xAxisDataNumber = 0
end,
---set the min and max values of all charts
@@ -835,7 +994,7 @@ detailsFramework.MultiChartFrameMixin = {
Plot = function(multiChartFrame)
local minValue, multiChartMaxValue = multiChartFrame:GetMinMaxValues()
local plotAreaWidth = multiChartFrame.plotFrame:GetWidth() --if there's no axis, the plotFrame has no width
local maxDataSize = multiChartFrame:GetMaxDataSize()
local maxDataSize = multiChartFrame:GetMaxDataSize() --it's not clearing when a new boss is selected
local eachLineWidth = plotAreaWidth / maxDataSize
local allCharts = multiChartFrame:GetCharts()
@@ -857,6 +1016,7 @@ detailsFramework.MultiChartFrameMixin = {
chartFrame:Plot(yPointScale, bUpdateLabels)
end
multiChartFrame:ShowBackdropIndicators()
updateLabelValues(multiChartFrame)
multiChartFrame:UpdateChartNamesIndicator()
end,
@@ -1841,7 +1841,7 @@ function DF:CreateCoolTip()
end
--~inicio ~start ~tooltip
function gameCooltip:BuildTooltip()
function gameCooltip:BuildTooltip() --~refresh
--hide select bar
gameCooltip:HideSelectedTexture(frame1)
@@ -0,0 +1,14 @@
---@class detailsframework
---@field OptionsFunctions df_optionsmixin
---@field RoundedCornerPanelMixin df_roundedcornermixin
---@field GetDefaultBackdropColor fun(self:table) : red, green, blue, alpha return a standard backdrop color
---@field Msg fun(self:table, message:string, ...) show a message in the chat frame
---@field MsgWarning fun(self:table, message:string, ...) show a warning message in the chat frame
---@field CreateCloseButton fun(self:table, parent:frame, frameName:string|nil) : df_closebutton
---@field CreateTabButton fun(self:table, parent:frame, frameName:string|nil) : df_tabbutton
---@field CreateRoundedPanel fun(self:table, parent:frame, frameName:string|nil, optionsTable:df_roundedpanel_options|nil) : df_roundedpanel
---@field CreateScaleBar fun(self:table, parent:frame, config:table<scale,number>) : df_scalebar
---@field AddRoundedCornersToFrame fun(self:table, frame:frame, optionsTable:df_roundedpanel_preset|nil)
---@field ParseColors fun(self:table, red:any, green:number|nil, blue:number|nil, alpha:number|nil) : red, green, blue, alpha
---@field Mixin fun(self:table, target:table, ...) : table
@@ -533,7 +533,11 @@ function DropDownMetaFunctions:Selected(thisOption)
self.icon:SetVertexColor(1, 1, 1, 1)
end
self.icon:SetSize(self:GetHeight()-4, self:GetHeight()-4)
if (thisOption.iconsize) then
self.icon:SetSize(thisOption.iconsize[1], thisOption.iconsize[2])
else
self.icon:SetSize(self:GetHeight()-4, self:GetHeight()-4)
end
else
self.label:SetPoint("left", self.label:GetParent(), "left", 4, 0)
end
@@ -0,0 +1,600 @@
---@class detailsframework
local detailsFramework = _G.DetailsFramework
if (not detailsFramework or not DetailsFrameworkCanLoad) then
return
end
local CreateFrame = CreateFrame
local defaultRed, defaultGreen, defaultBlue = detailsFramework:GetDefaultBackdropColor()
--local defaultColorTable = {defaultRed, defaultGreen, defaultBlue, 1}
local defaultColorTable = {0.98, 0.98, 0.98, 1}
local defaultBorderColorTable = {0.1, 0.1, 0.1, 1}
---@type edgenames[]
local cornerNames = {"TopLeft", "TopRight", "BottomLeft", "BottomRight"}
---@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
---@class cornertextures : table
---@field TopLeft texture
---@field TopRight texture
---@field BottomLeft texture
---@field BottomRight texture
---@class edgetextures : table
---@field Top texture
---@field Bottom texture
---@field Left texture
---@field Right texture
---@class df_roundedpanel_preset : table
---@field border_color any
---@field color any
---@field roundness number
---@class df_roundedpanel_options : table
---@field width number
---@field height number
---@field use_titlebar boolean
---@field use_scalebar boolean
---@field title string
---@field scale number
---@field roundness number
---@field color any
---@field border_color any
---@field corner_texture texturepath|textureid
---@class df_roundedcornermixin : table
---@field RoundedCornerConstructor fun(self:df_roundedpanel) --called from CreateRoundedPanel
---@field SetColor fun(self:df_roundedpanel, red: any, green: number|nil, blue: number|nil, alpha: number|nil)
---@field SetBorderCornerColor fun(self:df_roundedpanel, red: any, green: number|nil, blue: number|nil, alpha: number|nil)
---@field SetRoundness fun(self:df_roundedpanel, slope: number)
---@field GetCornerSize fun(self:df_roundedpanel) : width, height
---@field OnSizeChanged fun(self:df_roundedpanel) --called when the frame size changes
---@field CreateBorder fun(self:df_roundedpanel) --called from SetBorderCornerColor if the border is not created yet
---@field CalculateBorderEdgeSize fun(self:df_roundedpanel, alignment: "vertical"|"horizontal"): number --calculate the size of the border edge texture
---@field SetTitleBarColor fun(self:df_roundedpanel, red: any, green: number|nil, blue: number|nil, alpha: number|nil)
---@class df_roundedpanel : frame, df_roundedcornermixin, df_optionsmixin, df_titlebar
---@field bHasBorder boolean
---@field bHasTitleBar boolean
---@field options df_roundedpanel_options
---@field cornerRoundness number
---@field CornerTextures cornertextures
---@field CenterTextures texture[]
---@field BorderCornerTextures cornertextures
---@field BorderEdgeTextures edgetextures
---@field TitleBar df_roundedpanel
---@field TopLeft texture corner texture
---@field TopRight texture corner texture
---@field BottomLeft texture corner texture
---@field BottomRight texture corner texture
---@field TopEdgeBorder texture border edge
---@field BottomEdgeBorder texture border edge
---@field LeftEdgeBorder texture border edge
---@field RightEdgeBorder texture border edge
---@field TopLeftBorder texture border corner
---@field TopRightBorder texture border corner
---@field BottomLeftBorder texture border corner
---@field BottomRightBorder texture border corner
---@field TopHorizontalEdge texture texture connecting the top corners
---@field BottomHorizontalEdge texture texture connecting the bottom corners
---@field CenterBlock texture texture connecting the bottom left of the topleft corner with the top right of the bottom right corner
---@param self df_roundedpanel
---@param textures cornertextures
---@param width number|nil
---@param height number|nil
---@param xOffset number|nil
---@param yOffset number|nil
---@param bIsBorder boolean|nil
local setCornerPoints = function(self, textures, width, height, xOffset, yOffset, bIsBorder)
for cornerName, thisTexture in pairs(textures) do
thisTexture:SetSize(width or 16, height or 16)
thisTexture:SetTexture(self.options.corner_texture)
--set the mask
if (not thisTexture.MaskTexture and bIsBorder) then
thisTexture.MaskTexture = self:CreateMaskTexture(nil, "background")
thisTexture.MaskTexture:SetSize(74, 64)
thisTexture:AddMaskTexture(thisTexture.MaskTexture)
thisTexture.MaskTexture:SetTexture([[Interface\Azerite\AzeriteGoldRingRank2]]) --1940690
--thisTexture.MaskTexture:Hide()
end
xOffset = xOffset or 0
yOffset = yOffset or 0
--todo: adjust the other corners setpoint offset
--todo (done): use mask when the alpha is below 0.98, disable the mask when the alpha is above 0.98
if (cornerName == "TopLeft") then
thisTexture:SetTexCoord(0, 0.5, 0, 0.5)
thisTexture:SetPoint(cornerName, self, cornerName, -xOffset, yOffset)
if (thisTexture.MaskTexture) then
thisTexture.MaskTexture:SetPoint(cornerName, self, cornerName, -18-xOffset, 16+yOffset)
end
elseif (cornerName == "TopRight") then
thisTexture:SetTexCoord(0.5, 1, 0, 0.5)
thisTexture:SetPoint(cornerName, self, cornerName, xOffset, yOffset)
if (thisTexture.MaskTexture) then
thisTexture.MaskTexture:SetPoint(cornerName, self, cornerName, -18+xOffset, 16+yOffset)
end
elseif (cornerName == "BottomLeft") then
thisTexture:SetTexCoord(0, 0.5, 0.5, 1)
thisTexture:SetPoint(cornerName, self, cornerName, -xOffset, -yOffset)
if (thisTexture.MaskTexture) then
thisTexture.MaskTexture:SetPoint(cornerName, self, cornerName, -18-xOffset, 16-yOffset)
end
elseif (cornerName == "BottomRight") then
thisTexture:SetTexCoord(0.5, 1, 0.5, 1)
thisTexture:SetPoint(cornerName, self, cornerName, xOffset, -yOffset)
if (thisTexture.MaskTexture) then
thisTexture.MaskTexture:SetPoint(cornerName, self, cornerName, -18+xOffset, 16-yOffset)
end
end
end
end
detailsFramework.RoundedCornerPanelMixin = {
RoundedCornerConstructor = function(self)
self.CornerTextures = {}
self.CenterTextures = {}
self.BorderCornerTextures = {}
self.BorderEdgeTextures = {}
self.cornerRoundness = 0
for i = 1, #cornerNames do
---@type texture
local newCornerTexture = self:CreateTexture(nil, "border", nil, 0)
self.CornerTextures[cornerNames[i]] = newCornerTexture
self[cornerNames[i]] = newCornerTexture
end
--create the top texture which connects the top corners with a horizontal line
---@type texture
local topHorizontalEdge = self:CreateTexture(nil, "border", nil, 0)
topHorizontalEdge:SetPoint("topleft", self.CornerTextures["TopLeft"], "topright", 0, 0)
topHorizontalEdge:SetPoint("bottomleft", self.CornerTextures["TopLeft"], "bottomright", 0, 0)
topHorizontalEdge:SetPoint("topright", self.CornerTextures["TopRight"], "topleft", 0, 0)
topHorizontalEdge:SetPoint("bottomright", self.CornerTextures["TopRight"], "bottomleft", 0, 0)
topHorizontalEdge:SetColorTexture(unpack(defaultColorTable))
--create the bottom texture which connects the bottom corners with a horizontal line
---@type texture
local bottomHorizontalEdge = self:CreateTexture(nil, "border", nil, 0)
bottomHorizontalEdge:SetPoint("topleft", self.CornerTextures["BottomLeft"], "topright", 0, 0)
bottomHorizontalEdge:SetPoint("bottomleft", self.CornerTextures["BottomLeft"], "bottomright", 0, 0)
bottomHorizontalEdge:SetPoint("topright", self.CornerTextures["BottomRight"], "topleft", 0, 0)
bottomHorizontalEdge:SetPoint("bottomright", self.CornerTextures["BottomRight"], "bottomleft", 0, 0)
bottomHorizontalEdge:SetColorTexture(unpack(defaultColorTable))
--create the center block which connects the bottom left of the topleft corner with the top right of the bottom right corner
---@type texture
local centerBlock = self:CreateTexture(nil, "border", nil, 0)
centerBlock:SetPoint("topleft", self.CornerTextures["TopLeft"], "bottomleft", 0, 0)
centerBlock:SetPoint("bottomleft", self.CornerTextures["BottomLeft"], "topleft", 0, 0)
centerBlock:SetPoint("topright", self.CornerTextures["BottomRight"], "topright", 0, 0)
centerBlock:SetPoint("bottomright", self.CornerTextures["BottomRight"], "topright", 0, 0)
centerBlock:SetColorTexture(unpack(defaultColorTable))
self.CenterTextures[#self.CenterTextures+1] = topHorizontalEdge
self.CenterTextures[#self.CenterTextures+1] = bottomHorizontalEdge
self.CenterTextures[#self.CenterTextures+1] = centerBlock
self.TopHorizontalEdge = topHorizontalEdge
self.BottomHorizontalEdge = bottomHorizontalEdge
self.CenterBlock = centerBlock
---@type width
local width = self.options.width
---@type height
local height = self.options.height
self:SetSize(width, height)
--fill the corner and edge textures table
setCornerPoints(self, self.CornerTextures)
end,
---return the width and height of the corner textures
---@param self df_roundedpanel
---@return number, number
GetCornerSize = function(self)
return self.CornerTextures["TopLeft"]:GetSize()
end,
---set how rounded the corners should be
---@param self df_roundedpanel
---@param roundness number
SetRoundness = function(self, roundness)
self.cornerRoundness = roundness
self:OnSizeChanged()
end,
---adjust the size of the corner textures and the border edge textures
---@param self df_roundedpanel
OnSizeChanged = function(self)
--if the frame has a titlebar, need to adjust the size of the titlebar
if (self.bHasTitleBar) then
self.TitleBar:SetWidth(self:GetWidth() - 14)
end
--if the frame height is below 32, need to recalculate the size of the corners
---@type height
local frameHeight = self:GetHeight()
if (frameHeight < 32) then
local newCornerSize = frameHeight / 2
--set the new size of the corners on all corner textures
for _, thisTexture in pairs(self.CornerTextures) do
thisTexture:SetSize(newCornerSize-self.cornerRoundness, newCornerSize)
end
--check if the frame has border and set the size of the border corners as well
if (self.bHasBorder) then
for _, thisTexture in pairs(self.BorderCornerTextures) do
thisTexture:SetSize(newCornerSize, newCornerSize)
end
--hide the left and right edges as the corner textures already is enough to fill the frame
self.BorderEdgeTextures["Left"]:Hide()
self.BorderEdgeTextures["Right"]:Hide()
local horizontalEdgesNewSize = self:CalculateBorderEdgeSize("horizontal")
self.BorderEdgeTextures["Top"]:SetSize(horizontalEdgesNewSize, 1)
self.BorderEdgeTextures["Bottom"]:SetSize(horizontalEdgesNewSize, 1)
end
self.CenterBlock:Hide()
else
if (self.bHasBorder) then
self.BorderEdgeTextures["Left"]:Show()
self.BorderEdgeTextures["Right"]:Show()
end
---@type width, height
local cornerWidth, cornerHeight = 16, 16
self.CenterBlock:Show()
for _, thisTexture in pairs(self.CornerTextures) do
thisTexture:SetSize(cornerWidth-self.cornerRoundness, cornerHeight-self.cornerRoundness)
end
if (self.bHasBorder) then
for _, thisTexture in pairs(self.BorderCornerTextures) do
thisTexture:SetSize(cornerWidth-self.cornerRoundness, cornerHeight-self.cornerRoundness)
thisTexture.MaskTexture:SetSize(74-(self.cornerRoundness*0.75), 64-self.cornerRoundness)
end
local horizontalEdgesNewSize = self:CalculateBorderEdgeSize("horizontal")
self.BorderEdgeTextures["Top"]:SetSize(horizontalEdgesNewSize, 1)
self.BorderEdgeTextures["Bottom"]:SetSize(horizontalEdgesNewSize, 1)
local verticalEdgesNewSize = self:CalculateBorderEdgeSize("vertical")
self.BorderEdgeTextures["Left"]:SetSize(1, verticalEdgesNewSize)
self.BorderEdgeTextures["Right"]:SetSize(1, verticalEdgesNewSize)
end
end
end,
---get the size of the edge texture
---@param self df_roundedpanel
---@param alignment "vertical"|"horizontal"
---@return number edgeSize
CalculateBorderEdgeSize = function(self, alignment)
---@type string
local borderCornerName = next(self.BorderCornerTextures)
if (not borderCornerName) then
return 0
end
---@type texture
local borderTexture = self.BorderCornerTextures[borderCornerName]
alignment = alignment:lower()
if (alignment == "vertical") then
return self:GetHeight() - (borderTexture:GetHeight() * 2) + 2
elseif (alignment == "horizontal") then
return self:GetWidth() - (borderTexture:GetHeight() * 2) + 2
end
error("df_roundedpanel:CalculateBorderEdgeSize(self, alignment) alignment must be 'vertical' or 'horizontal'")
end,
---@param self df_roundedpanel
CreateBorder = function(self)
local r, g, b, a = 0, 0, 0, 0.8
--create the corner edges
for i = 1, #cornerNames do
---@type texture
local newBorderTexture = self:CreateTexture(nil, "background", nil, 0)
self.BorderCornerTextures[cornerNames[i]] = newBorderTexture
newBorderTexture:SetColorTexture(unpack(defaultColorTable))
newBorderTexture:SetVertexColor(r, g, b, a)
self[cornerNames[i] .. "Border"] = newBorderTexture
end
setCornerPoints(self, self.BorderCornerTextures, 16, 16, 1, 1, true)
--create the top, left, bottom and right edges, the edge has 1pixel width and connects the corners
---@type texture
local topEdge = self:CreateTexture(nil, "background", nil, 0)
topEdge:SetPoint("bottom", self, "top", 0, 0)
self.BorderEdgeTextures["Top"] = topEdge
---@type texture
local leftEdge = self:CreateTexture(nil, "background", nil, 0)
leftEdge:SetPoint("right", self, "left", 0, 0)
self.BorderEdgeTextures["Left"] = leftEdge
---@type texture
local bottomEdge = self:CreateTexture(nil, "background", nil, 0)
bottomEdge:SetPoint("top", self, "bottom", 0, 0)
self.BorderEdgeTextures["Bottom"] = bottomEdge
---@type texture
local rightEdge = self:CreateTexture(nil, "background", nil, 0)
rightEdge:SetPoint("left", self, "right", 0, 0)
self.BorderEdgeTextures["Right"] = rightEdge
---@type width
local horizontalEdgeSize = self:CalculateBorderEdgeSize("horizontal")
---@type height
local verticalEdgeSize = self:CalculateBorderEdgeSize("vertical")
--set the edges size
topEdge:SetSize(horizontalEdgeSize, 1)
leftEdge:SetSize(1, verticalEdgeSize)
bottomEdge:SetSize(horizontalEdgeSize, 1)
rightEdge:SetSize(1, verticalEdgeSize)
for edgeName, thisTexture in pairs(self.BorderEdgeTextures) do
---@cast thisTexture texture
thisTexture:SetColorTexture(unpack(defaultColorTable))
thisTexture:SetVertexColor(r, g, b, a)
end
self.TopEdgeBorder = topEdge
self.BottomEdgeBorder = bottomEdge
self.LeftEdgeBorder = leftEdge
self.RightEdgeBorder = rightEdge
self.bHasBorder = true
end,
---@param self df_roundedpanel
---@param red any
---@param green number|nil
---@param blue number|nil
---@param alpha number|nil
SetTitleBarColor = function(self, red, green, blue, alpha)
if (self.bHasTitleBar) then
red, green, blue, alpha = detailsFramework:ParseColors(red, green, blue, alpha)
self.TitleBar:SetColor(red, green, blue, alpha)
end
end,
---@param self df_roundedpanel
---@param red any
---@param green number|nil
---@param blue number|nil
---@param alpha number|nil
SetBorderCornerColor = function(self, red, green, blue, alpha)
if (not self.bHasBorder) then
self:CreateBorder()
end
red, green, blue, alpha = detailsFramework:ParseColors(red, green, blue, alpha)
for _, thisTexture in pairs(self.BorderCornerTextures) do
thisTexture:SetVertexColor(red, green, blue, alpha)
end
for _, thisTexture in pairs(self.BorderEdgeTextures) do
thisTexture:SetVertexColor(red, green, blue, alpha)
end
end,
---@param self df_roundedpanel
---@param red any
---@param green number|nil
---@param blue number|nil
---@param alpha number|nil
SetColor = function(self, red, green, blue, alpha)
red, green, blue, alpha = detailsFramework:ParseColors(red, green, blue, alpha)
for _, thisTexture in pairs(self.CornerTextures) do
thisTexture:SetVertexColor(red, green, blue, alpha)
end
for _, thisTexture in pairs(self.CenterTextures) do
thisTexture:SetVertexColor(red, green, blue, alpha)
end
if (self.bHasBorder) then
if (alpha < 0.98) then
--if using borders, the two border textures overlaps making the alpha be darker than it should
for _, thisTexture in pairs(self.BorderCornerTextures) do
thisTexture.MaskTexture:Show()
end
else
for _, thisTexture in pairs(self.BorderCornerTextures) do
thisTexture.MaskTexture:Hide()
end
end
end
end,
}
local defaultOptions = {
width = 200,
height = 200,
use_titlebar = false,
use_scalebar = false,
title = "",
scale = 1,
roundness = 0,
color = defaultColorTable,
border_color = defaultColorTable,
corner_texture = [[Interface\CHARACTERFRAME\TempPortraitAlphaMaskSmall]],
}
local defaultPreset = {
border_color = {.1, .1, .1, 0.834},
color = {defaultRed, defaultGreen, defaultBlue},
roundness = 3,
}
---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"
newRoundedPanel.__rcorners = true
detailsFramework:Mixin(newRoundedPanel, detailsFramework.RoundedCornerPanelMixin)
detailsFramework:Mixin(newRoundedPanel, detailsFramework.OptionsFunctions)
newRoundedPanel:BuildOptionsTable(defaultOptions, optionsTable or {})
newRoundedPanel:RoundedCornerConstructor()
newRoundedPanel:SetScript("OnSizeChanged", newRoundedPanel.OnSizeChanged)
if (newRoundedPanel.options.use_titlebar) then
---@type df_roundedpanel
local titleBar = detailsFramework:CreateRoundedPanel(newRoundedPanel, "$parentTitleBar", {height = 26})
titleBar:SetPoint("top", newRoundedPanel, "top", 0, -7)
newRoundedPanel.TitleBar = titleBar
titleBar:SetRoundness(5)
newRoundedPanel.bHasTitleBar = true
end
if (newRoundedPanel.options.use_scalebar) then
detailsFramework:CreateScaleBar(newRoundedPanel.TitleBar or newRoundedPanel, newRoundedPanel.options)
newRoundedPanel:SetScale(newRoundedPanel.options.scale)
end
newRoundedPanel:SetRoundness(newRoundedPanel.options.roundness)
newRoundedPanel:SetColor(newRoundedPanel.options.color)
newRoundedPanel:SetBorderCornerColor(newRoundedPanel.options.border_color)
return newRoundedPanel
end
local applyPreset = function(frame, preset)
if (preset.border_color) then
frame:SetBorderCornerColor(preset.border_color)
end
if (preset.color) then
frame:SetColor(preset.color)
end
if (preset.roundness) then
frame:SetRoundness(preset.roundness)
else
frame:SetRoundness(1)
end
end
---set a frame to have rounded corners following the settings passed by the preset table
---@param frame frame
---@param preset df_roundedpanel_preset|nil
function detailsFramework:AddRoundedCornersToFrame(frame, preset)
frame = frame and frame.widget or frame
assert(frame and frame.GetObjectType and frame.SetPoint, "AddRoundedCornersToFrame(frame): frame must be a frame object.")
if (frame.GetBackdropBorderColor) then
local red, green, blue, alpha = frame:GetBackdropBorderColor()
if (alpha and alpha > 0) then
detailsFramework:MsgWarning("AddRoundedCornersToFrame() applyed to a frame with a backdrop border.")
detailsFramework:Msg(debugstack(2, 1, 0))
end
end
---@cast frame +df_roundedcornermixin
detailsFramework:Mixin(frame, detailsFramework.RoundedCornerPanelMixin)
if (not frame["BuildOptionsTable"]) then
---@cast frame +df_optionsmixin
detailsFramework:Mixin(frame, detailsFramework.OptionsFunctions)
end
frame:BuildOptionsTable(defaultOptions, {})
frame.options.width = frame:GetWidth()
frame.options.height = frame:GetHeight()
frame:RoundedCornerConstructor()
frame:HookScript("OnSizeChanged", frame.OnSizeChanged)
frame.__rcorners = true
--handle preset
if (preset and type(preset) == "table") then
applyPreset(frame, preset)
else
applyPreset(frame, defaultPreset)
end
end
---test case:
C_Timer.After(1, function() if true then return end
local DF = DetailsFramework
local parent = UIParent
local name = "NewRoundedCornerFrame"
local optionsTable = {
use_titlebar = true,
use_scalebar = true,
title = "Test",
scale = 1.0,
}
---@type df_roundedpanel
local frame = _G[name] or DF:CreateRoundedPanel(parent, name, optionsTable)
frame:SetSize(800, 600)
frame:SetPoint("center", parent, "center", 0, 0)
frame:SetColor(.1, .1, .1, 1)
frame:SetTitleBarColor(.2, .2, .2, .5)
frame:SetBorderCornerColor(.2, .2, .2, .5)
frame:SetRoundness(0)
local radiusSlider = DF:CreateSlider(frame, 120, 14, 0, 15, 1, frame.cornerRoundness, false, "RadiusBar", nil, nil, DF:GetTemplate("slider", "OPTIONS_SLIDER_TEMPLATE"))
radiusSlider:SetHook("OnValueChange", function(self, fixedValue, value)
value = floor(value)
if (frame.cornerRoundness == value) then
return
end
frame:SetRoundness(value)
end)
local radiusText = frame:CreateFontString(nil, "overlay", "GameFontNormal")
radiusText:SetText("Radius:")
radiusText:SetPoint("bottomleft", radiusSlider.widget, "topleft", 0, 0)
radiusSlider:SetPoint(10, -100)
end)
+85 -37
View File
@@ -1,6 +1,6 @@
local dversion = 440
local dversion = 450
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
@@ -40,7 +40,11 @@ DF.AuthorInfo = {
}
function DF:Msg(msg, ...)
print("|cFFFFFFAA" .. (self.__name or "FW Msg:") .. "|r ", msg, ...)
print("|cFFFFFFAA" .. (self.__name or "Details!Framework:") .. "|r ", msg, ...)
end
function DF:MsgWarning(msg, ...)
print("|cFFFFFFAA" .. (self.__name or "Details!Framework") .. "|r |cFFFFAA00[Warning]|r", msg, ...)
end
local PixelUtil = PixelUtil or DFPixelUtil
@@ -124,13 +128,14 @@ 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
end
DF.IsWotLKWowWithRetailAPI = DF.IsNonRetailWowWithRetailAPI -- this is still in use
---return true if the version of wow the player is playing is the shadowlands
function DF.IsShadowlandsWow()
@@ -263,7 +268,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 +277,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
@@ -837,6 +842,23 @@ function DF:RemoveRealmName(name)
return name:gsub(("%-.*"), "")
end
---remove the owner name of the pet or guardian
---@param name string
---@return string, number
function DF:RemoveOwnerName(name)
return name:gsub((" <.*"), "")
end
---remove realm and owner names also remove brackets from spell actors
---@param name string
---@return string
function DF:CleanUpName(name)
name = DF:RemoveRealmName(name)
name = DF:RemoveOwnerName(name)
name = name:gsub("%[%*%]%s", "")
return name
end
---remove the realm name from a name
---@param name string
---@return string, number
@@ -3377,7 +3399,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
@@ -3703,21 +3725,36 @@ local glow_overlay_play = function(self)
if (not self:IsShown()) then
self:Show()
end
if (self.animOut:IsPlaying()) then
self.animOut:Stop()
end
if (not self.animIn:IsPlaying()) then
self.animIn:Stop()
self.animIn:Play()
if (self.animOut) then
if (self.animOut:IsPlaying()) then
self.animOut:Stop()
end
if (not self.animIn:IsPlaying()) then
self.animIn:Stop()
self.animIn:Play()
end
elseif (self.ProcStartAnim) then
if (not self.ProcStartAnim:IsPlaying()) then
self.ProcStartAnim:Play()
end
if (not self.ProcLoop:IsPlaying()) then
--self.ProcLoop:Play()
end
end
end
local glow_overlay_stop = function(self)
if (self.animOut:IsPlaying()) then
self.animOut:Stop()
end
if (self.animIn:IsPlaying()) then
self.animIn:Stop()
if (self.animOut) then
if (self.animOut:IsPlaying()) then
self.animOut:Stop()
end
if (self.animIn:IsPlaying()) then
self.animIn:Stop()
end
elseif (self.ProcStartAnim) then
if (self.ProcStartAnim:IsPlaying()) then
self.ProcStartAnim:Stop()
end
end
if (self:IsShown()) then
self:Hide()
@@ -3727,20 +3764,27 @@ end
local glow_overlay_setcolor = function(self, antsColor, glowColor)
if (antsColor) then
local r, g, b, a = DF:ParseColors(antsColor)
self.ants:SetVertexColor(r, g, b, a)
self.AntsColor.r = r
self.AntsColor.g = g
self.AntsColor.b = b
self.AntsColor.a = a
self.AntsColor = {r, g, b, a}
if (self.ants) then
self.ants:SetVertexColor(r, g, b, a)
elseif (self.ProcLoopFlipbook) then
self.ProcLoopFlipbook:SetVertexColor(r, g, b) --no alpha because of animation
local anim1 = self.ProcLoop:GetAnimations()
anim1:SetToAlpha(a)
end
end
if (glowColor) then
local r, g, b, a = DF:ParseColors(glowColor)
self.outerGlow:SetVertexColor(r, g, b, a)
self.GlowColor.r = r
self.GlowColor.g = g
self.GlowColor.b = b
self.GlowColor.a = a
self.GlowColor = {r, g, b, a}
if (self.outerGlow) then
self.outerGlow:SetVertexColor(r, g, b, a)
elseif (self.ProcStartFlipbook) then
self.ProcStartFlipbook:SetVertexColor(r, g, b) --no alpha because of animation
local anim1, anim2, anim3 = self.ProcStartAnim:GetAnimations()
anim1:SetToAlpha(a)
anim3:SetFromAlpha(a)
end
end
end
@@ -3767,6 +3811,8 @@ function DF:CreateGlowOverlay (parent, antsColor, glowColor)
glowFrame.Stop = glow_overlay_stop
glowFrame.SetColor = glow_overlay_setcolor
glowFrame:SetColor(antsColor, glowColor)
glowFrame:Hide()
parent.overlay = glowFrame
@@ -3779,15 +3825,17 @@ function DF:CreateGlowOverlay (parent, antsColor, glowColor)
parent.overlay:SetPoint("TOPLEFT", parent, "TOPLEFT", -frameWidth * 0.32, frameHeight * 0.36)
parent.overlay:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", frameWidth * 0.32, -frameHeight * 0.36)
local r, g, b, a = DF:ParseColors(antsColor)
glowFrame.ants:SetVertexColor(r, g, b, a)
glowFrame.AntsColor = {r, g, b, a}
local r, g, b, a = DF:ParseColors(glowColor)
glowFrame.outerGlow:SetVertexColor(r, g, b, a)
glowFrame.GlowColor = {r, g, b, a}
glowFrame.outerGlow:SetScale(1.2)
if (glowFrame.outerGlow) then
glowFrame.outerGlow:SetScale(1.2)
end
if (glowFrame.ProcStartFlipbook) then
glowFrame.ProcStartAnim:Stop()
glowFrame.ProcStartFlipbook:ClearAllPoints()
--glowFrame.ProcStartFlipbook:SetAllPoints()
--glowFrame.ProcStartFlipbook:SetSize(frameWidth * scale, frameHeight * scale)
glowFrame.ProcStartFlipbook:SetPoint("TOPLEFT", glowFrame, "TOPLEFT", -frameWidth * scale, frameHeight * scale)
glowFrame.ProcStartFlipbook:SetPoint("BOTTOMRIGHT", glowFrame, "BOTTOMRIGHT", frameWidth * scale, -frameHeight * scale)
end
glowFrame:EnableMouse(false)
return glowFrame
end
@@ -215,16 +215,24 @@ detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.ScriptHookMixin)
------------------------------------------------------------------------------------------------------------
--methods
--text text
---set the text of the label and truncate it is its width passes 'maxWidth' threshold
---@param self df_label
---@param text string
---@param maxWidth width
function LabelMetaFunctions:SetTextTruncated(text, maxWidth)
self.widget:SetText(text)
detailsFramework:TruncateText(self.widget, maxWidth)
end
--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)
---set the text color
---@param self df_label
---@param red any
---@param green number|nil
---@param blue number|nil
---@param alpha number|nil
function LabelMetaFunctions:SetTextColor(red, green, blue, alpha)
red, green, blue, alpha = detailsFramework:ParseColors(red, green, blue, alpha)
return self.label:SetTextColor(red, green, blue, alpha)
end
------------------------------------------------------------------------------------------------------------
@@ -248,94 +256,127 @@ detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.ScriptHookMixin)
------------------------------------------------------------------------------------------------------------
--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)
---@class df_label
---@field widget fontstring widget and label points to the same fontstring
---@field label fontstring widget and label points to the same fontstring
---@field align justifyh
---@field valign justifyv
---@field text string
---@field width width
---@field height height
---@field fontcolor any
---@field color any
---@field fontface string
---@field fontsize number
---@field textcolor any
---@field textfont string
---@field textsize number
---@field shadow fontflags
---@field outline fontflags
---@field rotation number
---@field SetTemplate fun(self: df_label, template: table) set the fontstring visual by a template
---@field SetTextColor fun(self: df_label, red: any, green: number|nil, blue: number|nil, alpha: number|nil) set the button text color
---@field SetTextTruncated fun(self: df_label, text: string, maxWidth: width)
---create a new label object
---@param parent frame
---@param text string
---@param size number|nil
---@param color any|nil
---@param font string|nil
---@param member string|nil
---@param name string|nil
---@param layer drawlayer|nil
---@return df_label|nil
function detailsFramework:CreateLabel(parent, text, size, color, font, member, name, layer)
return detailsFramework:NewLabel(parent, nil, name, member, text, font, size, color, layer)
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
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 (not name) then
name = "DetailsFrameworkLabelNumber" .. detailsFramework.LabelNameCounter
detailsFramework.LabelNameCounter = detailsFramework.LabelNameCounter + 1
end
if (not name) then
name = "DetailsFrameworkLabelNumber" .. detailsFramework.LabelNameCounter
detailsFramework.LabelNameCounter = detailsFramework.LabelNameCounter + 1
end
if (name:find("$parent")) then
local parentName = detailsFramework.GetParentName(parent)
name = name:gsub("$parent", parentName)
end
if (name:find("$parent")) then
local parentName = detailsFramework.GetParentName(parent)
name = name:gsub("$parent", parentName)
end
---@type df_label
local labelObject = {type = "label", dframework = true}
local labelObject = {type = "label", dframework = true}
if (member) then
parent[member] = labelObject
end
if (member) then
parent[member] = labelObject
end
if (parent.dframework) then
parent = parent.widget
end
if (parent.dframework) then
parent = parent.widget
end
if (container.dframework) then
container = container.widget
end
if (container.dframework) then
container = container.widget
end
if (not font or font == "") then
font = "GameFontNormal"
end
if (not font or font == "") then
font = "GameFontNormal"
end
labelObject.label = parent:CreateFontString(name, layer or "OVERLAY", font)
labelObject.widget = labelObject.label
labelObject.label.MyObject = labelObject
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
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
--if the text is a table, it means a language table has been passed
if (type(text) == "table") then
local locTable = text
if (detailsFramework.Language.IsLocTable(locTable)) then
detailsFramework.Language.SetTextWithLocTable(labelObject.widget, locTable)
else
labelObject.label:SetText(text)
end
--if the text is a table, it means a language table has been passed
if (type(text) == "table") then
local locTable = text
if (detailsFramework.Language.IsLocTable(locTable)) then
detailsFramework.Language.SetTextWithLocTable(labelObject.widget, locTable)
else
labelObject.label:SetText(text)
end
else
labelObject.label:SetText(text)
end
labelObject.label:SetJustifyH("left")
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 = {}
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
@@ -23,6 +23,7 @@
<Script file="charts.lua"/>
<Script file="scripting.lua"/>
<Script file="externals.lua"/>
<Script file="frames.lua"/>
<Include file="tutorial_alert.xml"/>
<Include file="split_bar.xml"/>
@@ -166,7 +166,7 @@ detailsFramework.FrameMixin = {
SetBackdropBorderColor = function(self, ...)
self = getFrame(self)
getFrame(self):SetBackdropBorderColor(...)
self:SetBackdropBorderColor(...)
end,
}
@@ -269,6 +269,11 @@ detailsFramework.SetPointMixin = {
---mixin for options
---@class df_optionsmixin
---@field options table
---@field SetOption fun(self, optionName: string, optionValue: any)
---@field GetOption fun(self, optionName: string):any
---@field GetAllOptions fun(self):table
---@field BuildOptionsTable fun(self, defaultOptions: table, userOptions: table)
detailsFramework.OptionsFunctions = {
SetOption = function(self, optionName, optionValue)
if (self.options) then
@@ -887,6 +892,7 @@ detailsFramework.DataMixin = {
---@field ValueConstructor fun(self: df_value)
---@field SetMinMaxValues fun(self: df_value, minValue: number, maxValue: number)
---@field GetMinMaxValues fun(self: df_value) : number, number
---@field ResetMinMaxValues fun(self: df_value)
---@field GetMinValue fun(self: df_value) : number
---@field GetMaxValue fun(self: df_value) : number
---@field SetMinValue fun(self: df_value, minValue: number)
@@ -901,8 +907,7 @@ detailsFramework.ValueMixin = {
---initialize the value table
---@param self table
ValueConstructor = function(self)
self.minValue = 0
self.maxValue = 1
self:ResetMinMaxValues()
end,
---set the min and max values
@@ -921,6 +926,13 @@ detailsFramework.ValueMixin = {
return self.minValue, self.maxValue
end,
---reset the min and max values
---@param self table
ResetMinMaxValues = function(self)
self.minValue = 0
self.maxValue = 1
end,
---get the min value
---@param self table
---@return number
@@ -1880,7 +1880,10 @@ local SimplePanel_frame_backdrop_border_color = {0, 0, 0, 1}
--with_label was making the frame stay in place while its parent moves
--the slider was anchoring to with_label and here here were anchoring the slider again
---@class df_scalebar : slider
---@field thumb texture
function detailsFramework:CreateScaleBar(frame, config) --~scale
---@type df_scalebar
local scaleBar, text = detailsFramework:CreateSlider(frame, 120, 14, 0.6, 1.6, 0.1, config.scale, true, "ScaleBar", nil, "Scale:", detailsFramework:GetTemplate("slider", "OPTIONS_SLIDER_TEMPLATE"), detailsFramework:GetTemplate("font", "ORANGE_FONT_TEMPLATE"))
scaleBar.thumb:SetWidth(24)
scaleBar:SetValueStep(0.1)
@@ -2059,6 +2062,7 @@ function detailsFramework:CreateSimplePanel(parent, width, height, title, frameN
close:SetAlpha(0.7)
close:SetScript("OnClick", simple_panel_close_click)
simplePanel.Close = close
simplePanel.closeButton = close
local titleText = titleBar:CreateFontString(frameName and frameName .. "Title", "overlay", "GameFontNormal")
titleText:SetTextColor(.8, .8, .8, 1)
@@ -4359,7 +4363,7 @@ function detailsFramework:ApplyStandardBackdrop(frame, bUseSolidColor, alphaScal
end
if (not frame.__background) then
frame.__background = frame:CreateTexture(nil, "background")
frame.__background = frame:CreateTexture(nil, "border", nil, -6)
frame.__background:SetColorTexture(red, green, blue)
frame.__background:SetAllPoints()
end
@@ -4371,30 +4375,31 @@ end
-- ~title bar
detailsFramework.TitleFunctions = {
SetTitle = function(self, titleText, titleColor, font, size)
self.TitleLabel:SetText(titleText or self.TitleLabel:GetText())
local titleLabel = self.TitleLabel or self.Text
titleLabel:SetText(titleText or titleLabel:GetText())
if (titleColor) then
local r, g, b, a = detailsFramework:ParseColors(titleColor)
self.TitleLabel:SetTextColor(r, g, b, a)
titleLabel:SetTextColor(r, g, b, a)
end
if (font) then
detailsFramework:SetFontFace (self.TitleLabel, font)
detailsFramework:SetFontFace (titleLabel, font)
end
if (size) then
detailsFramework:SetFontSize(self.TitleLabel, size)
detailsFramework:SetFontSize(titleLabel, size)
end
end
}
---@class df_titlebar : frame
---@field TitleBar frame
---@field TitleLabel fontstring
---@field CloseButton button
---@field SetTitle fun(self:df_titlebar, titleText:string, titleColor:any, font:string, size:number)
---create a title bar with a font string in the center and a close button in the right side
---@param parent frame
@@ -4434,7 +4439,9 @@ function detailsFramework:CreateTitleBar(parent, titleText)
parent.TitleBar = titleBar
parent.CloseButton = closeButton
parent.TitleLabel = titleLabel
parent.SetTitle = titleBar.SetTitle
titleBar.TitleBar = titleBar --to fit documentation
titleBar.CloseButton = closeButton
titleBar.Text = titleLabel
@@ -5323,7 +5330,7 @@ function detailsFramework:OpenLoadConditionsPanel(optionsTable, callback, frameO
function loadConditionsFrame.Refresh (self)
if IS_WOW_PROJECT_MAINLINE then
--update the talents (might have changed if the player changed its specialization)
--update the talents (might have changed if the player changed its specializationid)
local talentList = {}
for _, talentTable in ipairs(detailsFramework:GetCharacterTalents()) do
if talentTable.ID then
@@ -235,10 +235,33 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin)
------------------------------------------------------------------------------------------------------------
--object constructor
---@class df_image : texture
---@field SetGradient fun(gradientType: "vertical"|"horizontal", fromColor: table, toColor: table)
---create an object that encapsulates a texture and add additional methods to it
---@param parent frame
---@param texture texturepath|textureid
---@param width number
---@param height number
---@param layer drawlayer
---@param coords {key1: number, key2: number, key3: number, key4: number}
---@param member string
---@param name string
---@return table|nil
function detailsFramework:CreateTexture(parent, texture, width, height, layer, coords, member, name)
return detailsFramework:NewImage(parent, texture, width, height, layer, coords, member, name)
end
---create an object that encapsulates a texture and add additional methods to it
---@param parent frame
---@param texture texturepath|textureid
---@param width number
---@param height number
---@param layer drawlayer
---@param coords {key1: number, key2: number, key3: number, key4: number}
---@param member string
---@param name string
---@return table|nil
function detailsFramework:CreateImage(parent, texture, width, height, layer, coords, member, name)
return detailsFramework:NewImage(parent, texture, width, height, layer, coords, member, name)
end
@@ -300,7 +323,7 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin)
if (texture) then
if (type(texture) == "table") then
if (texture.gradient) then
if (detailsFramework.IsDragonflight() or detailsFramework.IsWotLKWowWithRetailAPI()) then
if (detailsFramework.IsDragonflight() or detailsFramework.IsNonRetailWowWithRetailAPI()) then
ImageObject.image:SetColorTexture(1, 1, 1, 1)
local fromColor = detailsFramework:FormatColor("tablemembers", texture.fromColor)
local toColor = detailsFramework:FormatColor("tablemembers", texture.toColor)
@@ -1178,6 +1178,8 @@ function DF:NewSlider (parent, container, name, member, width, height, minValue,
if (label_template) then
label:SetTemplate(label_template)
end
SliderObject.label = label
end
if (slider_template) then
@@ -942,10 +942,14 @@ local set_speciallua_editor_font_size = function(borderFrame, newSize)
borderFrame.editboxlines:SetFont(file, newSize, flags)
end
function detailsFramework:NewSpecialLuaEditorEntry(parent, width, height, member, name, nointent, showLineNumbers)
if (name:find("$parent")) then
local parentName = detailsFramework.GetParentName(parent)
name = name:gsub("$parent", parentName)
function detailsFramework:NewSpecialLuaEditorEntry(parent, width, height, member, name, nointent, showLineNumbers, bNoName)
if (not bNoName) then
if (name:find("$parent")) then
local parentName = detailsFramework.GetParentName(parent)
name = name:gsub("$parent", parentName)
end
else
name = nil
end
local borderframe = CreateFrame("Frame", name, parent,"BackdropTemplate")
@@ -956,9 +960,9 @@ function detailsFramework:NewSpecialLuaEditorEntry(parent, width, height, member
end
local scrollframe = CreateFrame("ScrollFrame", name, borderframe, "UIPanelScrollFrameTemplate, BackdropTemplate")
local scrollframeNumberLines = CreateFrame("ScrollFrame", name .. "NumberLines", borderframe, "UIPanelScrollFrameTemplate, BackdropTemplate")
local scrollframeNumberLines = CreateFrame("ScrollFrame", name and (name .. "NumberLines"), borderframe, "UIPanelScrollFrameTemplate, BackdropTemplate")
scrollframe.editbox = CreateFrame("editbox", "$parentEditBox", scrollframe,"BackdropTemplate")
scrollframe.editbox = CreateFrame("editbox", name and "$parentEditBox", scrollframe,"BackdropTemplate")
scrollframe.editbox:SetMultiLine (true)
scrollframe.editbox:SetAutoFocus(false)
scrollframe.editbox:SetScript("OnCursorChanged", _G.ScrollingEdit_OnCursorChanged)
@@ -968,7 +972,7 @@ function detailsFramework:NewSpecialLuaEditorEntry(parent, width, height, member
--line number
if (showLineNumbers) then
scrollframeNumberLines.editbox = CreateFrame("editbox", "$parentLineNumbers", scrollframeNumberLines, "BackdropTemplate")
scrollframeNumberLines.editbox = CreateFrame("editbox", name and "$parentLineNumbers", scrollframeNumberLines, "BackdropTemplate")
scrollframeNumberLines.editbox:SetMultiLine (true)
scrollframeNumberLines.editbox:SetAutoFocus(false)
scrollframeNumberLines.editbox:SetEnabled (false)
@@ -1,51 +0,0 @@
-- $Id: LibStub.lua 76 2007-09-03 01:50:17Z mikk $
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
-- LibStub is hereby placed in the Public Domain
-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR]
-- Check to see is this version of the stub is obsolete
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
-- LibStub:NewLibrary(major, minor)
-- major (string) - the major version of the library
-- minor (string or number ) - the minor version of the library
--
-- returns nil if a newer or same version of the lib is already present
-- returns empty library object or old library object if upgrade is needed
function LibStub:NewLibrary(major, minor)
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
local oldminor = self.minors[major]
if oldminor and oldminor >= minor then return nil end
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
return self.libs[major], oldminor
end
-- LibStub:GetLibrary(major, [silent])
-- major (string) - the major version of the library
-- silent (boolean) - if true, library is optional, silently return nil if its not found
--
-- throws an error if the library can not be found (except silent is set)
-- returns the library object if found
function LibStub:GetLibrary(major, silent)
if not self.libs[major] and not silent then
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
end
return self.libs[major], self.minors[major]
end
-- LibStub:IterateLibraries()
--
-- Returns an iterator for the currently registered libraries
function LibStub:IterateLibraries()
return pairs(self.libs)
end
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
@@ -1,13 +0,0 @@
## Interface: 40200
## Title: Lib: LibStub
## Notes: Universal Library Stub
## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
## X-Website: http://www.wowace.com/addons/libstub/
## X-Category: Library
## X-License: Public Domain
## X-Curse-Packaged-Version: r95
## X-Curse-Project-Name: LibStub
## X-Curse-Project-ID: libstub
## X-Curse-Repository-ID: wow/libstub/mainline
LibStub.lua
@@ -1,41 +0,0 @@
debugstack = debug.traceback
strmatch = string.match
loadfile("../LibStub.lua")()
local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
assert(lib) -- should return the library table
assert(not oldMinor) -- should not return the old minor, since it didn't exist
-- the following is to create data and then be able to check if the same data exists after the fact
function lib:MyMethod()
end
local MyMethod = lib.MyMethod
lib.MyTable = {}
local MyTable = lib.MyTable
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
assert(not newLib) -- should not return since out of date
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
assert(not newLib) -- should not return since out of date
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
assert(newLib) -- library table
assert(rawequal(newLib, lib)) -- should be the same reference as the previous
assert(newOldMinor == 1) -- should return the minor version of the previous version
assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
assert(newLib) -- library table
assert(newOldMinor == 2) -- previous version was 2
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
assert(newLib)
assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
assert(newLib)
assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
@@ -1,27 +0,0 @@
debugstack = debug.traceback
strmatch = string.match
loadfile("../LibStub.lua")()
for major, library in LibStub:IterateLibraries() do
-- check that MyLib doesn't exist yet, by iterating through all the libraries
assert(major ~= "MyLib")
end
assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
assert(lib) -- check it exists
assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
local count=0
for major, library in LibStub:IterateLibraries() do
-- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
if major == "MyLib" then -- we found it!
count = count +1
assert(rawequal(library, lib)) -- verify that the references are equal
end
end
assert(count == 1) -- verify that we actually found it, and only once
@@ -1,14 +0,0 @@
debugstack = debug.traceback
strmatch = string.match
loadfile("../LibStub.lua")()
local proxy = newproxy() -- non-string
assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
local success, ret = pcall(LibStub.GetLibrary, proxy, true)
assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
@@ -1,41 +0,0 @@
debugstack = debug.traceback
strmatch = string.match
loadfile("../LibStub.lua")()
-- Pretend like loaded libstub is old and doesn't have :IterateLibraries
assert(LibStub.minor)
LibStub.minor = LibStub.minor - 0.0001
LibStub.IterateLibraries = nil
loadfile("../LibStub.lua")()
assert(type(LibStub.IterateLibraries)=="function")
-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
LibStub.IterateLibraries = 123
loadfile("../LibStub.lua")()
assert(LibStub.IterateLibraries == 123)
-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
LibStub.minor = LibStub.minor + 0.0001
loadfile("../LibStub.lua")()
assert(LibStub.IterateLibraries == 123)
-- Again with a huge number
LibStub.minor = LibStub.minor + 1234567890
loadfile("../LibStub.lua")()
assert(LibStub.IterateLibraries == 123)
print("OK")
+1 -1
View File
@@ -43,7 +43,7 @@ do
end
local buildOptionsPanel = function()
local optionsFrame = encounterDetails:CreatePluginOptionsFrame("EncounterDetailsOptionsWindow", "Encounter Breakdown Options", 2)
local optionsFrame = encounterDetails:CreatePluginOptionsFrame("EncounterDetailsOptionsWindow", "Encounter Breakdown Options")
-- 1 = only when inside a raid map
-- 2 = only when in raid group
-- 3 = only after a boss encounter
@@ -250,7 +250,19 @@ local buildEmoteSementsList = function()
end
for index, segment in ipairs(encounterDetails.charsaved.emotes) do
local bossIcon, iconWidth, iconHeight, iconL, iconR, iconT, iconB = Details:GetBossEncounterTexture(segment.boss or "unknown")
table.insert(resultTable, {label = "#" .. index .. " " ..(segment.boss or "unknown"), value = index, icon = bossIcon, iconsize = {iconWidth, iconHeight}, texcoord = {iconL, iconR, iconT, iconB}, onclick = onEmoteSegmentSelected, iconcolor = segmentIconColor})
bossIcon = bossIcon or ""
iconWidth, iconHeight = iconWidth or 16, iconHeight or 16
iconL, iconR, iconT, iconB = iconL or 0, iconR or 1, iconT or 0, iconB or 1
table.insert(resultTable, {
label = "#" .. index .. " " ..(segment.boss or "unknown"),
value = index,
icon = bossIcon,
iconsize = {iconWidth, iconHeight},
texcoord = {iconL, iconR, iconT, iconB},
onclick = onEmoteSegmentSelected,
iconcolor = segmentIconColor
})
end
return resultTable
end