Using portrait for enemy faces

This commit is contained in:
Tercio Jose
2022-12-02 19:32:51 -03:00
parent f17f8642b7
commit 5571749ef6
12 changed files with 328 additions and 224 deletions
+112 -15
View File
@@ -15,7 +15,7 @@ local max = math.max
--api locals
local PixelUtil = PixelUtil or DFPixelUtil
local version = 7
local version = 8
local CONST_MENU_TYPE_MAINMENU = "main"
local CONST_MENU_TYPE_SUBMENU = "sub"
@@ -1069,30 +1069,91 @@ function DF:CreateCoolTip()
--left icon
if (leftIconSettings and leftIconSettings[1]) then
menuButton.leftIcon:SetTexture(leftIconSettings[1])
menuButton.leftIcon:SetWidth(leftIconSettings[2])
menuButton.leftIcon:SetHeight(leftIconSettings[3])
menuButton.leftIcon:SetTexCoord(leftIconSettings[4], leftIconSettings[5], leftIconSettings[6], leftIconSettings[7])
local textureObject = menuButton.leftIcon
local colorRed, colorGreen, colorBlue, colorAlpha = DF:ParseColors(leftIconSettings[8])
menuButton.leftIcon:SetVertexColor(colorRed, colorGreen, colorBlue, colorAlpha)
--check if the texture passed is a texture object
if (type(leftIconSettings[1]) == "table" and leftIconSettings[1].GetObjectType and leftIconSettings[1]:GetObjectType() == "Texture") then
menuButton.leftIcon:SetSize(leftIconSettings[2], leftIconSettings[3])
menuButton.leftIcon:SetColorTexture(0.0156, 0.047, 0.1215, 1)
textureObject = leftIconSettings[1]
textureObject:SetParent(menuButton.leftIcon:GetParent())
textureObject:ClearAllPoints()
textureObject:SetDrawLayer("overlay", 7)
textureObject:Show()
if (gameCooltip.OptionsTable.IconBlendMode) then
menuButton.leftIcon:SetBlendMode(gameCooltip.OptionsTable.IconBlendMode)
for i = 1, menuButton.leftIcon:GetNumPoints() do
local anchor1, anchorFrame, anchor2, x, y = menuButton.leftIcon:GetPoint(i)
textureObject:SetPoint(anchor1, anchorFrame, anchor2, x, y)
end
menuButton.customLeftTexture = textureObject
else
menuButton.leftIcon:SetBlendMode("BLEND")
if (menuButton.customLeftTexture) then
menuButton.customLeftTexture:Hide()
menuButton.customLeftTexture = nil
end
menuButton.leftIcon:Show()
menuButton.leftIcon:SetTexture(leftIconSettings[1])
end
menuButton.leftIcon:SetDesaturated(leftIconSettings[9])
textureObject:SetWidth(leftIconSettings[2])
textureObject:SetHeight(leftIconSettings[3])
textureObject:SetTexCoord(leftIconSettings[4], leftIconSettings[5], leftIconSettings[6], leftIconSettings[7])
local colorRed, colorGreen, colorBlue, colorAlpha = DF:ParseColors(leftIconSettings[8])
textureObject:SetVertexColor(colorRed, colorGreen, colorBlue, colorAlpha)
if (gameCooltip.OptionsTable.IconBlendMode) then
textureObject:SetBlendMode(gameCooltip.OptionsTable.IconBlendMode)
else
textureObject:SetBlendMode("BLEND")
end
textureObject:SetDesaturated(leftIconSettings[9])
else
menuButton.leftIcon:SetTexture("")
menuButton.leftIcon:SetWidth(1)
menuButton.leftIcon:SetHeight(1)
local textureObject = menuButton.leftIcon
textureObject:SetTexture("")
textureObject:SetWidth(1)
textureObject:SetHeight(1)
if (menuButton.customLeftTexture) then
menuButton.customLeftTexture:Hide()
menuButton.customLeftTexture = nil
end
end
--right icon
if (rightIconSettings and rightIconSettings[1]) then
menuButton.rightIcon:SetTexture(rightIconSettings[1])
local textureObject = menuButton.rightIcon
--check if the texture passed is a texture object
if (type(rightIconSettings[1]) == "table" and rightIconSettings[1].GetObjectType and rightIconSettings[1]:GetObjectType() == "Texture") then
menuButton.rightIcon:SetSize(leftIconSettings[2], leftIconSettings[3])
menuButton.rightIcon:SetColorTexture(0.0156, 0.047, 0.1215, 1)
textureObject = rightIconSettings[1]
textureObject:SetParent(menuButton)
textureObject:ClearAllPoints()
textureObject:SetDrawLayer("overlay", 7)
textureObject:Show()
for i = 1, menuButton.rightIcon:GetNumPoints() do
local anchor1, anchorFrame, anchor2, x, y = menuButton.rightIcon:GetPoint(i)
textureObject:SetPoint(anchor1, anchorFrame, anchor2, x, y)
end
menuButton.customRightTexture = textureObject
else
if (menuButton.customRightTexture) then
menuButton.customRightTexture:Hide()
menuButton.customRightTexture = nil
end
menuButton.rightIcon:Show()
menuButton.rightIcon:SetTexture(rightIconSettings[1])
end
menuButton.rightIcon:SetWidth(rightIconSettings[2])
menuButton.rightIcon:SetHeight(rightIconSettings[3])
menuButton.rightIcon:SetTexCoord(rightIconSettings[4], rightIconSettings[5], rightIconSettings[6], rightIconSettings[7])
@@ -1111,6 +1172,11 @@ function DF:CreateCoolTip()
menuButton.rightIcon:SetTexture("")
menuButton.rightIcon:SetWidth(1)
menuButton.rightIcon:SetHeight(1)
if (menuButton.customRightTexture) then
menuButton.customRightTexture:Hide()
menuButton.customRightTexture = nil
end
end
--overwrite icon size
@@ -3048,6 +3114,37 @@ function DF:CreateCoolTip()
gameCooltip.Host = nil
DF:FadeFrame(frame1, 1)
DF:FadeFrame(frame2, 1)
--release custom icon texture objects, these are TextureObject passed with AddIcon() instead of a texture path or textureId
for i = 1, #frame1.Lines do
local menuButton = frame1.Lines[i]
--relase custom icon texture if any
if (menuButton.customLeftTexture) then
menuButton.customLeftTexture:ClearAllPoints()
menuButton.customLeftTexture = nil
end
if (menuButton.customRightTexture) then
menuButton.customRightTexture:ClearAllPoints()
menuButton.customRightTexture = nil
end
end
for i = 1, #frame2.Lines do
local menuButton = frame2.Lines[i]
--relase custom icon texture if any
if (menuButton.customLeftTexture) then
menuButton.customLeftTexture:ClearAllPoints()
menuButton.customLeftTexture = nil
end
if (menuButton.customRightTexture) then
menuButton.customRightTexture:ClearAllPoints()
menuButton.customRightTexture = nil
end
end
end
--old function call