RDX.RegisterFeature({
name = "(True) Hunter Priority Icon";
title = VFLI.i18n("(True) Priority Icon");
category = VFLI.i18n("Textures");
test = true;
IsPossible = function(state)
if not state:Slot("DesignFrame") then return nil; end
if not state:Slot("Base") then return nil; end
return true;
end;
ExposeFeature = function(desc, state, errs)
if not RDXUI.DescriptorCheck(desc, state, errs) then return nil; end
if desc.owner == "Base" then desc.owner = "decor"; end
if not desc.usebkd then desc.usebs = true; end
local flg = true;
flg = flg and RDXUI.UFFrameCheck_Proto("Frame_", desc, state, errs);
flg = flg and RDXUI.UFAnchorCheck(desc.anchor, state, errs);
flg = flg and RDXUI.UFOwnerCheck(desc.owner, state, errs);
if flg then state:AddSlot("Frame_" .. desc.name); end
return flg;
end;
ApplyFeature = function(desc, state)
local objname = "Frame_" .. desc.name;
local usebs = "false"; if desc.usebs then usebs = "true"; end
local ebs = desc.externalButtonSkin or "bs_default";
local usebkd = "false"; if desc.usebkd then usebkd = "true"; end
local bkd = desc.bkd or VFLUI.defaultBackdrop;
local os = 0;
if desc.usebs then
os = desc.ButtonSkinOffset or 0;
elseif desc.usebkd then
if desc.bkd and desc.bkd.insets and desc.bkd.insets.left then os = desc.bkd.insets.left or 0; end
end
local showgloss = "nil"; if desc.showgloss then showgloss = "true"; end
local bsdefault = desc.bsdefault or _white;
local hidebs = "nil"; if desc.hidebs then hidebs = "true"; end
------------------ On frame creation
local createCode = [[
local btn, owner = nil, ]] .. RDXUI.ResolveFrameReference(desc.owner) .. [[;
if ]] .. usebs .. [[ then
btn = VFLUI.SkinButton:new();
btn:SetButtonSkin("]] .. ebs ..[[", true, true, false, true, true, true, false, true, true, ]] .. showgloss ..[[);
elseif ]] .. usebkd .. [[ then
btn = VFLUI.AcquireFrame("Button");
VFLUI.SetBackdrop(btn, ]] .. Serialize(bkd) .. [[);
else
btn = VFLUI.AcquireFrame("Frame");
end
btn:SetParent(owner);
btn:SetFrameLevel(owner:GetFrameLevel());
btn:SetPoint(]] .. RDXUI.AnchorCodeFromDescriptor(desc.anchor) .. [[);
btn:SetWidth(]] .. desc.w .. [[); btn:SetHeight(]] .. desc.h .. [[);
btn._t = VFLUI.CreateTexture(btn);
btn._t:SetDrawLayer("]] .. (desc.drawLayer or "ARTWORK") .. [[", 2);
btn._t:SetPoint("CENTER", btn, "CENTER");
btn._t:SetWidth(]] .. desc.w .. [[ - ]] .. os .. [[); btn._t:SetHeight(]] .. desc.h .. [[ - ]] .. os .. [[);
btn._t:Show();
btn:Hide();
frame.]] .. objname .. [[ = btn;
]];
state:Attach(state:Slot("EmitCreate"), true, function(code) code:AppendCode(createCode); end);
------------------ On frame destruction.
state:Attach(state:Slot("EmitDestroy"), true, function(code) code:AppendCode([[
VFLUI.ReleaseRegion(frame.]] .. objname .. [[._t); frame.]] .. objname .. [[._t = nil;
frame.]] .. objname .. [[:Destroy(); frame.]] .. objname .. [[ = nil;
]]); end);
state:Attach(state:Slot("EmitCleanup"), true, function(code) code:AppendCode([[
frame.]] .. objname .. [[:Hide();
]]); end);
------------------ On paint.
state:Attach(state:Slot("EmitPaint"), true, function(code)
if desc.test then
code:AppendCode([[
frame.]] .. objname .. [[._t:SetTexture(GetSpellTexture("Kill Command"));
frame.]] .. objname .. [[:Show();
]]);
else
code:AppendCode([[
frame.]] .. objname .. [[._t:SetTexture(TRUESYS.PriorityHunterBeastMastery());
frame.]] .. objname .. [[:Show();
]]);
end
end);
return true;
end;
UIFromDescriptor = function(desc, parent, state)
local ui = VFLUI.CompoundFrame:new(parent);
-- Name/width/height
local ed_name, ed_width, ed_height = RDXUI.GenNameWidthHeightPortion(ui, desc, state);
-- Owner
local owner = RDXUI.MakeSlotSelectorDropdown(ui, VFLI.i18n("Owner"), state, "Subframe_");
if desc and desc.owner then owner:SetSelection(desc.owner); end
-- Drawlayer
local er = VFLUI.EmbedRight(ui, VFLI.i18n("Draw layer"));
local drawLayer = VFLUI.Dropdown:new(er, RDXUI.DrawLayerDropdownFunction);
drawLayer:SetWidth(100); drawLayer:Show();
if desc and desc.drawLayer then drawLayer:SetSelection(desc.drawLayer); else drawLayer:SetSelection("ARTWORK"); end
er:EmbedChild(drawLayer); er:Show();
ui:InsertFrame(er);
-- Anchor
local anchor = RDXUI.UnitFrameAnchorSelector:new(ui); anchor:Show();
anchor:SetAFArray(RDXUI.ComposeAnchorList(state));
if desc and desc.anchor then anchor:SetAnchorInfo(desc.anchor); end
ui:InsertFrame(anchor);
-------------- Display
ui:InsertFrame(VFLUI.Separator:new(ui, VFLI.i18n("Button Skin parameters")));
local chk_bs = VFLUI.CheckEmbedRight(ui, VFLI.i18n("Use Button Skin"));
local dd_buttonSkin = VFLUI.Dropdown:new(chk_bs, VFLUI.GetButtonSkinList);
dd_buttonSkin:SetWidth(150); dd_buttonSkin:Show();
dd_buttonSkin:SetSelection(desc.externalButtonSkin);
if desc and desc.usebs then
chk_bs:SetChecked(true);
else
chk_bs:SetChecked();
end
chk_bs:EmbedChild(dd_buttonSkin); chk_bs:Show();
ui:InsertFrame(chk_bs);
local ed_bs = VFLUI.LabeledEdit:new(ui, 50); ed_bs:Show();
ed_bs:SetText(VFLI.i18n("Button Skin Size Offset"));
if desc and desc.ButtonSkinOffset then ed_bs.editBox:SetText(desc.ButtonSkinOffset); end
ui:InsertFrame(ed_bs);
local chk_showgloss = VFLUI.Checkbox:new(ui); chk_showgloss:Show();
chk_showgloss:SetText(VFLI.i18n("Button Skin Show Gloss"));
if desc and desc.showgloss then chk_showgloss:SetChecked(true); else chk_showgloss:SetChecked(); end
ui:InsertFrame(chk_showgloss);
local color_bsdefault = RDXUI.GenerateColorSwatch(ui, VFLI.i18n("Button Skin default color"));
if desc and desc.bsdefault then color_bsdefault:SetColor(VFL.explodeRGBA(desc.bsdefault)); end
local chk_bkd = VFLUI.CheckEmbedRight(ui, VFLI.i18n("Use Backdrop"));
local dd_backdrop = VFLUI.MakeBackdropSelectButton(chk_bkd, desc.bkd);
dd_backdrop:Show();
if desc and desc.usebkd then
chk_bkd:SetChecked(true);
else
chk_bkd:SetChecked();
end
chk_bkd:EmbedChild(dd_backdrop); chk_bkd:Show();
ui:InsertFrame(chk_bkd);
local chk_hidebs = VFLUI.Checkbox:new(ui); chk_hidebs:Show();
chk_hidebs:SetText(VFLI.i18n("Hide empty button"));
if desc and desc.hidebs then chk_hidebs:SetChecked(true); else chk_hidebs:SetChecked(); end
ui:InsertFrame(chk_hidebs);
function ui:GetDescriptor()
local name = ed_name.editBox:GetText();
local ebs = nil;
if chk_bs:GetChecked() then ebs = dd_buttonSkin:GetSelection(); end
return {
feature = "(True) Hunter Priority Icon", name = name, owner = owner:GetSelection();
drawLayer = drawLayer:GetSelection();
w = ed_width:GetSelection();
h = ed_height:GetSelection();
anchor = anchor:GetAnchorInfo();
-- display
usebs = chk_bs:GetChecked();
externalButtonSkin = dd_buttonSkin:GetSelection();
ButtonSkinOffset = VFL.clamp(ed_bs.editBox:GetNumber(), 0, 50);
showgloss = chk_showgloss:GetChecked();
bsdefault = color_bsdefault:GetColor();
usebkd = chk_bkd:GetChecked();
bkd = dd_backdrop:GetSelectedBackdrop();
hidebs = chk_hidebs:GetChecked();
};
end
return ui;
end;
CreateDescriptor = function()
return {
feature = "(True) Hunter Priority Icon", name = "bmpi", owner = "decor", drawLayer = "ARTWORK";
w = 14; h = 14;
anchor = { lp = "TOPLEFT", af = "Base", rp = "TOPLEFT", dx = 0, dy = 0};
externalButtonSkin = "bs_default";
ButtonSkinOffset = 0;
bkd = VFL.copy(VFLUI.defaultBackdrop);
};
end;
});