From 4cf5fddb47084ab7c0e752c46f9152e2d3bf346b Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 6 Jan 2017 19:56:38 +0100 Subject: [PATCH] unitframes: option to use fallback 2d portrait --- modules/config.lua | 1 + modules/gui.lua | 1 + modules/unitframes.lua | 35 +++++++++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/modules/config.lua b/modules/config.lua index f009e07c..2966e974 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -44,6 +44,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", nil, "customcolor", ".2,.2,.2,1") pfUI:UpdateConfig("unitframes", nil, "animation_speed", "5") pfUI:UpdateConfig("unitframes", nil, "portraitalpha", "0.1") + pfUI:UpdateConfig("unitframes", nil, "portraittexture", "1") pfUI:UpdateConfig("unitframes", nil, "buff_size", "20") pfUI:UpdateConfig("unitframes", nil, "debuff_size", "20") diff --git a/modules/gui.lua b/modules/gui.lua index 88d2adb8..f88dd9ff 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -863,6 +863,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Custom healthbar color", pfUI_config.unitframes, "customcolor", "color") pfUI.gui:CreateConfig(pfUI.gui.uf, "Animation speed", pfUI_config.unitframes, "animation_speed") pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Alpha on Bars", pfUI_config.unitframes, "portraitalpha") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Use 2D Portraits as fallback", pfUI_config.unitframes, "portraittexture", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff size", pfUI_config.unitframes, "buff_size") pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff size", pfUI_config.unitframes, "debuff_size") diff --git a/modules/unitframes.lua b/modules/unitframes.lua index 5d6ca8e3..981c9e35 100644 --- a/modules/unitframes.lua +++ b/modules/unitframes.lua @@ -314,13 +314,21 @@ function pfUI.uf:CreatePortrait(frame, pos, spacing) local id = frame.id or "" local unitstr = unit .. id - frame.portrait = CreateFrame("PlayerModel", "pfPortrait" .. unitstr, frame) + frame.portrait = CreateFrame("Frame", "pfPortrait" .. unitstr, frame) frame.portrait:RegisterEvent("UNIT_PORTRAIT_UPDATE") frame.portrait:RegisterEvent("UNIT_MODEL_CHANGED") frame.portrait:RegisterEvent("PLAYER_ENTERING_WORLD") frame.portrait:RegisterEvent("PLAYER_TARGET_CHANGED") frame.portrait.base = frame + frame.portrait.pos = pos + + frame.portrait.tex = frame.portrait:CreateTexture("pfPortraitTexture" .. unitstr, "OVERLAY") + frame.portrait.tex:SetAllPoints(frame.portrait) + frame.portrait.tex:SetTexCoord(.1, .9, .1, .9) + + frame.portrait.model = CreateFrame("PlayerModel", "pfPortraitModel" .. unitstr, frame.portrait) + frame.portrait.model:SetAllPoints(frame.portrait) frame.portrait:SetScript("OnEvent", function() local unit = this.base.label @@ -380,18 +388,29 @@ function pfUI.uf:UpdatePortrait() local unitstr = unit .. id local name = UnitName(unitstr) or "" - if this.name then this:SetCamera(0) end - if this.name == name then return end if not UnitIsVisible(unitstr) or not UnitIsConnected(unitstr) then - this:SetModelScale(4.25) - this:SetPosition(0, 0, -1.0) - this:SetModel("Interface\\Buttons\\talktomequestionmark.mdx") + if this.pos == "bar" then + this.tex:Hide() + this.model:Hide() + elseif pfUI_config.unitframes.portraittexture == "1" then + this.tex:Show() + this.model:Hide() + SetPortraitTexture(this.tex, unitstr) + else + this.tex:Hide() + this.model:Show() + this.model:SetModelScale(4.25) + this.model:SetPosition(0, 0, -1) + this.model:SetModel("Interface\\Buttons\\talktomequestionmark.mdx") + end this.name = nil else - this:SetUnit(unitstr) - this:SetCamera(0) + this.tex:Hide() + this.model:Show() + this.model:SetUnit(unitstr) + this.model:SetCamera(0) this.name = name end end