From 3cd63cff5304c76bf0506ac8e6547a0e90f858f6 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 18 Jun 2017 23:18:07 +0200 Subject: [PATCH] unitframes: option to always use 2d portraits --- api/config.lua | 1 + api/unitframes.lua | 65 +++++++++++++++++++++++++--------------------- modules/gui.lua | 3 ++- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/api/config.lua b/api/config.lua index 6dc2788d..e98bb9dd 100644 --- a/api/config.lua +++ b/api/config.lua @@ -76,6 +76,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", nil, "custombgcolor", ".5,.2,.2,1") pfUI:UpdateConfig("unitframes", nil, "animation_speed", "5") pfUI:UpdateConfig("unitframes", nil, "portraitalpha", "0.1") + pfUI:UpdateConfig("unitframes", nil, "always2dportrait", "0") pfUI:UpdateConfig("unitframes", nil, "portraittexture", "1") pfUI:UpdateConfig("unitframes", nil, "layout", "default") pfUI:UpdateConfig("unitframes", nil, "rangecheck", "0") diff --git a/api/unitframes.lua b/api/unitframes.lua index 62d83e5f..06451c07 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -717,40 +717,45 @@ function pfUI.uf:RefreshUnit(unit, component) -- portrait if unit.portrait and ( component == "all" or component == "portrait" ) then - if not UnitIsVisible(unit.label .. unit.id) or not UnitIsConnected(unit.label .. unit.id) then - if unit.config.portrait == "bar" then - unit.portrait.tex:Hide() - unit.portrait.model:Hide() - elseif pfUI_config.unitframes.portraittexture == "1" then - unit.portrait.tex:Show() - unit.portrait.model:Hide() - SetPortraitTexture(unit.portrait.tex, unit.label .. unit.id) - else - unit.portrait.tex:Hide() - unit.portrait.model:Show() - unit.portrait.model:SetModelScale(4.25) - unit.portrait.model:SetPosition(0, 0, -1) - unit.portrait.model:SetModel("Interface\\Buttons\\talktomequestionmark.mdx") - end + if pfUI_config.unitframes.always2dportrait == "1" then + unit.portrait.tex:Show() + unit.portrait.model:Hide() + SetPortraitTexture(unit.portrait.tex, unit.label .. unit.id) else - if unit.config.portrait == "bar" then - unit.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) - end - unit.portrait.tex:Hide() - unit.portrait.model:Show() - - if unit.tick then - unit.portrait.model.next:SetUnit(unit.label .. unit.id) - if unit.portrait.model.lastUnit ~= UnitName(unit.label .. unit.id) or unit.portrait.model:GetModel() ~= unit.portrait.model.next:GetModel() then - unit.portrait.model:SetUnit(unit.label .. unit.id) - unit.portrait.model.lastUnit = UnitName(unit.label .. unit.id) - unit.portrait.model:SetCamera(0) + if not UnitIsVisible(unit.label .. unit.id) or not UnitIsConnected(unit.label .. unit.id) then + if unit.config.portrait == "bar" then + unit.portrait.tex:Hide() + unit.portrait.model:Hide() + elseif pfUI_config.unitframes.portraittexture == "1" then + unit.portrait.tex:Show() + unit.portrait.model:Hide() + SetPortraitTexture(unit.portrait.tex, unit.label .. unit.id) + else + unit.portrait.tex:Hide() + unit.portrait.model:Show() + unit.portrait.model:SetModelScale(4.25) + unit.portrait.model:SetPosition(0, 0, -1) + unit.portrait.model:SetModel("Interface\\Buttons\\talktomequestionmark.mdx") end else - unit.portrait.model:SetUnit(unit.label .. unit.id) - unit.portrait.model:SetCamera(0) - end + if unit.config.portrait == "bar" then + unit.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + end + unit.portrait.tex:Hide() + unit.portrait.model:Show() + if unit.tick then + unit.portrait.model.next:SetUnit(unit.label .. unit.id) + if unit.portrait.model.lastUnit ~= UnitName(unit.label .. unit.id) or unit.portrait.model:GetModel() ~= unit.portrait.model.next:GetModel() then + unit.portrait.model:SetUnit(unit.label .. unit.id) + unit.portrait.model.lastUnit = UnitName(unit.label .. unit.id) + unit.portrait.model:SetCamera(0) + end + else + unit.portrait.model:SetUnit(unit.label .. unit.id) + unit.portrait.model:SetCamera(0) + end + end end end diff --git a/modules/gui.lua b/modules/gui.lua index d0d1dbb3..3b93328c 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -765,6 +765,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, "Custom Health Bar Background Color", C.unitframes, "custombgcolor", "color") CreateConfig(this, "Healthbar Animation Speed", C.unitframes, "animation_speed") CreateConfig(this, "Portrait Alpha", C.unitframes, "portraitalpha") + CreateConfig(this, "Always Use 2D Portraits", C.unitframes, "always2dportrait", "checkbox") CreateConfig(this, "Enable 2D Portraits As Fallback", C.unitframes, "portraittexture", "checkbox") CreateConfig(this, "Unit Frame Layout", C.unitframes, "layout", "dropdown", { "default", "tukui" }) CreateConfig(this, "Aggressive 40y-Range Check (Will break stuff)", C.unitframes, "rangecheck", "checkbox") @@ -1411,4 +1412,4 @@ pfUI:RegisterModule("gui", function () end) -end) \ No newline at end of file +end)