Skip to content

Commit

Permalink
Fixed an issue with icons not showing on classic versions of the game.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Mar 16, 2024
1 parent 2421b29 commit 0b7f4d2
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 9 deletions.
5 changes: 2 additions & 3 deletions Libs/DF/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,13 @@
---@field CleanTruncateUTF8String fun(self:table, text:string) : string
---@field GetSpellBookSpells fun(self:table) : table<string, boolean>, spellid[] return a list of spells from the player spellbook
---@field PreviewTexture fun(self:table, texture:atlasname|texturepath|textureid, left:number?, right:number?, top:number?, bottom:number?) : nil
---@field TableIsAtlas fun(self:table, atlasTale:table) : boolean
---@field SetAtlas fun(self:table, textureObject:texture, atlas:atlasinfo|atlasname, useAtlasSize:boolean?, filterMode:texturefilter?, resetTexCoords:boolean?) : nil
---@field CreateAtlas fun(self:table, file:texturepath|textureid, width:number?, height:number?, leftTexCoord:number?, rightTexCoord:number?, topTexCoord:number?, bottomTexCoord:number?, tilesHorizontally:boolean?, tilesVertically:boolean?, vertexRed:any, vertexGreen:number?, vertexBlue:number?, vertexAlpha:number?, desaturated:boolean?, desaturation:number?, alpha:number) : atlasinfo
---@field ParseTexture fun(self:table, texture:texturepath|textureid|atlasname|atlasinfo, width: number?, height: number?, leftTexCoord: number?, rightTexCoord: number?, topTexCoord: number?, bottomTexCoord: number?, vertexRed:number|string?, vertexGreenvertexRed:number?, vertexBluevertexRed:number?, vertexAlphavertexRed:number?) : any, number?, number?, number?, number?, number?, number?, number?, number?, number?, number?, number?, number?
---@field IsTexture fun(self:table, texture:any, bCheckTextureObject: boolean?) : boolean
---@field CreateAtlasString fun(self:table, atlas:atlasinfo|atlasname, textureHeight:number?, textureWidth:number?) : string
---@field SetMask fun(self:table, texture:texture, maskTexture:atlasname|texturepath|textureid) : nil
---@field SetMask fun(self:table, texture:texture, maskTexture:atlasname|texturepath|textureid|table) : nil
---@field GetClientRegion fun(self:table) : string
---@field GetBestFontPathForLanguage fun(self:table, languageId:string) : string
---@field SetTemplate fun(self:table, frame:uiobject, template:string)
Expand All @@ -312,8 +313,6 @@
---@field CreateBorder fun(self:table, parent:frame, alpha1:number?, alpha2:number?, alpha3:number?) : frame
---@field
---@field
---@field




Expand Down
4 changes: 2 additions & 2 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 525
local dversion = 526
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)

Expand Down Expand Up @@ -181,7 +181,7 @@ end
---@return boolean
function DF.IsNonRetailWowWithRetailAPI()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 40000 and buildInfo >= 30401) or (buildInfo < 20000 and buildInfo >= 11404) then
if (buildInfo < 50000 and buildInfo >= 30401) or (buildInfo < 20000 and buildInfo >= 11404) then
return true
end
return false
Expand Down
32 changes: 31 additions & 1 deletion Libs/DF/picture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,24 @@ function detailsFramework:IsTexture(texture, bCheckTextureObject)
return false
end

---Return if the table passed has the structure of an atlasinfo
---@param self table
---@param atlasTale table
---@return boolean
function detailsFramework:TableIsAtlas(atlasTale)
if (type(atlasTale) == "table") then
if (atlasTale.file or atlasTale.filename) then
return true
end
end
return false
end

---Receives a texture object and a texture to use as mask
---If the mask texture is not created, it will be created and added to a key named MaskTexture
---@param self table
---@param texture texture
---@param maskTexture string|number
---@param maskTexture string|number|table
function detailsFramework:SetMask(texture, maskTexture)
if (not texture.MaskTexture) then
local parent = texture:GetParent()
Expand All @@ -707,6 +720,23 @@ function detailsFramework:SetMask(texture, maskTexture)
texture:AddMaskTexture(maskTextureObject)
texture.MaskTexture = maskTextureObject
end

--is this a game texture atlas?
if (type(maskTexture) == "string") then
local isAtlas = C_Texture.GetAtlasInfo(maskTexture)
if (isAtlas) then
texture.MaskTexture:SetAtlas(maskTexture)
return
end

elseif (type(maskTexture) == "table") then
local bIsAtlas = detailsFramework:TableIsAtlas(maskTexture)
if (bIsAtlas) then
detailsFramework:SetAtlas(texture.MaskTexture, maskTexture)
return
end
end

texture.MaskTexture:SetTexture(maskTexture)
end

2 changes: 1 addition & 1 deletion frames/window_breakdown/breakdown_spells_spellframes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ function spellsTab.CreateSpellBar(self, index) --~spellbar ~spellline ~spell ~cr
local spellIcon = spellIconFrame:CreateTexture("$parentTexture", "overlay")
spellIcon:SetAllPoints()
spellIcon:SetTexCoord(.1, .9, .1, .9)
detailsFramework:SetMask(spellIcon, [[Interface\COMMON\common-iconmask]])
detailsFramework:SetMask(spellIcon, Details:GetTextureAtlas("iconmask"))
spellBar.spellIcon = spellIcon

--create a square frame which is placed at the right side of the line to show which targets for damaged by the spell
Expand Down
2 changes: 1 addition & 1 deletion frames/window_breakdown/window_playerbreakdown_auras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ local createAuraTabOnBreakdownWindow = function(tab, frame)
local iconTexture = line:CreateTexture("$parentIcon", "overlay")
iconTexture:SetSize(scroll_line_height -2 , scroll_line_height - 2)
iconTexture:SetAlpha(0.924)
detailsFramework:SetMask(iconTexture, [[Interface\COMMON\common-iconmask]])
detailsFramework:SetMask(iconTexture, Details:GetTextureAtlas("iconmask"))

local nameLabel = line:CreateFontString("$parentName", "overlay", "GameFontNormal")
local uptimeLabel = line:CreateFontString("$parentUptime", "overlay", "GameFontNormal")
Expand Down
2 changes: 1 addition & 1 deletion frames/window_breakdown/window_playerbreakdown_list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ local createPlayerScrollBox = function(breakdownWindowFrame, breakdownSideMenu,
local specIcon = OTTFrame:CreateTexture("$parentSpecIcon", "artwork")
specIcon:SetSize(headerTable[1].width - 1, headerTable[1].width - 1)
specIcon:SetAlpha(0.834)
detailsFramework:SetMask(specIcon, [[Interface\COMMON\common-iconmask]])
detailsFramework:SetMask(specIcon, Details:GetTextureAtlas("iconmask"))

local roleIcon = OTTFrame:CreateTexture("$parentRoleIcon", "overlay")
roleIcon:SetSize((player_line_height-2) / 2, (player_line_height-2) / 2)
Expand Down
Binary file added images/common-iconmask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions textures.lua
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,21 @@ Details.TextureAtlas = {
nativeWidth = 512,
nativeHeight = 512,
},

["iconmask"] = {
file = [[Interface\AddOns\Details\images\common-iconmask.png]],
width = 64,
height = 64,
leftTexCoord = 0,
rightTexCoord = 1,
topTexCoord = 0,
bottomTexCoord = 1,
tilesHorizontally = false,
tilesVertically = false,
nativeWidth = 64,
nativeHeight = 64,
},

}

C_Timer.After(1, function()
Expand Down

0 comments on commit 0b7f4d2

Please sign in to comment.