View Single Post
01-31-12, 04:53 AM   #4
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Alrighty, so I got it ALL working except for a few tiny things.

I plan on GREATLY expanding the functionality of my rotation priority feature later on for all of the classes I play, so I wanted to be able to really customize the button skin and such on my feature. I pretty much copied the IconsCustom button system into my feature, except, it doesn't actually work like it should... everything shows up in the descriptor, but - for example - I'm not able to actually set the color of my buttonskin in the options even though it looks like I am, it just remains white on the unitframe.

Also, I am using "Hide Empty Button", just, whenever my icon isn't up (which is whenever I'm not targeting a hostile unit), it still displays the button skin.

Here are my two features, so you get the idea:

lua Code:
  1. function TRUESYS.PriorityHunterBeastMastery()
  2.     local gcd = 1.5
  3.     local level = UnitLevel("player")
  4.     local focus = UnitPower("player")
  5.     local duration, _
  6.  
  7.     if not UnitCanAttack("player", "target") then
  8.         return
  9.     end
  10.  
  11.     -- 1. If your pet is on the target, Kill Command.
  12.     if UnitExists("pet") and UnitHealth("pet") > 1 and IsSpellInRange(RDXSS.GetSpellBookId("Growl", BOOKTYPE_PET),"pet","pettarget") == 1 and focus > 50 then
  13.         _, duration = GetSpellCooldown("Kill Command")
  14.         if duration <= gcd then
  15.             return GetSpellTexture("Kill Command")
  16.         end
  17.     end
  18.  
  19.     -- 2. If the mob is going to live long enough, apply Serpent Sting.
  20.     if focus > 25 then
  21.         if not UnitDebuff("target", "Serpent Sting") then
  22.             _, duration = GetSpellCooldown("Serpent Sting")
  23.             if duration <= gcd then
  24.                 return GetSpellTexture("Serpent Sting")
  25.             end
  26.         end
  27.     end
  28.  
  29.     -- 3. If mob is below 20% health, Kill Shot.
  30.     _, duration = GetSpellCooldown("Kill Shot")
  31.     if duration <= gcd and ( UnitHealth("target") / UnitHealthMax("target") < 0.2 ) then
  32.         return GetSpellTexture("Kill Shot")
  33.     end
  34.  
  35.     -- 4. If you will have enough focus to use Kill Command on cooldown, use Arcane Shot
  36.     if focus > 85 then
  37.         return GetSpellTexture("Arcane Shot")
  38.     end
  39.  
  40.     -- 5. Cobra Shot or Steady Shot.
  41.     if level < 81 then
  42.         return GetSpellTexture("Steady Shot")
  43.     else
  44.         return GetSpellTexture("Cobra Shot")
  45.     end
  46. end
  47.  
  48. -- Hunter 4.3 Priorities for CLCinfo (modified for OpenRDX) by Phanx @ [url]http://www.wowinterface.com/forums/showpost.php?p=251728&postcount=2[/url]
  49. function TRUESYS.PriorityHunterSurvival()
  50.     local gcd = 1.5
  51.     local level = UnitLevel("player")
  52.     local focus = UnitPower("player")
  53.     local duration, _
  54.  
  55.     if not UnitCanAttack("player", "target") then
  56.         return
  57.     end
  58.  
  59.     -- 1. If the mob is going to live long enough, apply Serpent Sting.
  60.     if focus > 25 then
  61.         if not UnitDebuff("target", "Serpent Sting") then
  62.             _, duration = GetSpellCooldown("Serpent Sting")
  63.             if duration <= gcd then
  64.                 return GetSpellTexture("Serpent Sting")
  65.             end
  66.         end
  67.     end
  68.    
  69.     -- 2. Explosive Shot
  70.     if focus > 50 then
  71.         _, duration = GetSpellCooldown("Explosive Shot")
  72.         if duration <= gcd then
  73.             return GetSpellTexture("Explosive Shot")
  74.         end
  75.     end
  76.  
  77.     -- 3. If mob is below 20% health, Kill Shot.
  78.     _, duration = GetSpellCooldown("Kill Shot")
  79.     if duration <= gcd and ( UnitHealth("target") / UnitHealthMax("target") < 0.2 ) then
  80.         return GetSpellTexture("Kill Shot")
  81.     end
  82.  
  83.     -- 4. If mob will be alive long enough, Black Arrow.
  84.     if level < 61 and focus > 35 then
  85.         _, duration = GetSpellCooldown("Black Arrow")
  86.         if duration <= gcd and ( UnitHealth("target") / dps > 15 ) then
  87.             return GetSpellTexture("Black Arrow")
  88.         end
  89.     end
  90.  
  91.     -- 5. If you will have enough focus to use Explosive Shot and Black Arrow, use Arcane Shot.
  92.     if focus > 85 then
  93.         return GetSpellTexture("Arcane Shot")
  94.     end
  95.  
  96.     -- 6. Cobra Shot or Steady Shot.
  97.     if level < 81 then
  98.         return GetSpellTexture("Steady Shot")
  99.     else
  100.         return GetSpellTexture("Cobra Shot")
  101.     end
  102. end

lua Code:
  1. RDX.RegisterFeature({
  2.     name = "(True) Hunter Priority Icon";
  3.     title = VFLI.i18n("(True) Priority Icon");
  4.     category = VFLI.i18n("Textures");
  5.     test = true;
  6.     IsPossible = function(state)
  7.         if not state:Slot("DesignFrame") then return nil; end
  8.         if not state:Slot("Base") then return nil; end
  9.         return true;
  10.     end;
  11.     ExposeFeature = function(desc, state, errs)
  12.         if not RDXUI.DescriptorCheck(desc, state, errs) then return nil; end
  13.         if desc.owner == "Base" then desc.owner = "decor"; end
  14.         if not desc.usebkd then desc.usebs = true; end
  15.         local flg = true;
  16.         flg = flg and RDXUI.UFFrameCheck_Proto("Frame_", desc, state, errs);
  17.         flg = flg and RDXUI.UFAnchorCheck(desc.anchor, state, errs);
  18.         flg = flg and RDXUI.UFOwnerCheck(desc.owner, state, errs);
  19.         if flg then state:AddSlot("Frame_" .. desc.name); end
  20.         return flg;
  21.     end;
  22.     ApplyFeature = function(desc, state)
  23.         local objname = "Frame_" .. desc.name;
  24.         local usebs = "false"; if desc.usebs then usebs = "true"; end
  25.         local ebs = desc.externalButtonSkin or "bs_default";
  26.         local usebkd = "false"; if desc.usebkd then usebkd = "true"; end
  27.         local bkd = desc.bkd or VFLUI.defaultBackdrop; 
  28.         local os = 0;
  29.         if desc.usebs then
  30.             os = desc.ButtonSkinOffset or 0;
  31.         elseif desc.usebkd then
  32.             if desc.bkd and desc.bkd.insets and desc.bkd.insets.left then os = desc.bkd.insets.left or 0; end
  33.         end
  34.         local showgloss = "nil"; if desc.showgloss then showgloss = "true"; end
  35.         local bsdefault = desc.bsdefault or _white;
  36.         local hidebs = "nil"; if desc.hidebs then hidebs = "true"; end
  37.       ------------------ On frame creation
  38.         local createCode = [[      
  39. local btn, owner = nil, ]] .. RDXUI.ResolveFrameReference(desc.owner) .. [[;
  40. if ]] .. usebs .. [[ then
  41.     btn = VFLUI.SkinButton:new();
  42.     btn:SetButtonSkin("]] .. ebs ..[[", true, true, false, true, true, true, false, true, true, ]] .. showgloss ..[[);
  43. elseif ]] .. usebkd .. [[ then
  44.     btn = VFLUI.AcquireFrame("Button");
  45.     VFLUI.SetBackdrop(btn, ]] .. Serialize(bkd) .. [[);
  46. else
  47.     btn = VFLUI.AcquireFrame("Frame");
  48. end
  49. btn:SetParent(owner);
  50. btn:SetFrameLevel(owner:GetFrameLevel());
  51. btn:SetPoint(]] .. RDXUI.AnchorCodeFromDescriptor(desc.anchor) .. [[);
  52. btn:SetWidth(]] .. desc.w .. [[); btn:SetHeight(]] .. desc.h .. [[);
  53. btn._t = VFLUI.CreateTexture(btn);
  54. btn._t:SetDrawLayer("]] .. (desc.drawLayer or "ARTWORK") .. [[", 2);
  55. btn._t:SetPoint("CENTER", btn, "CENTER");
  56. btn._t:SetWidth(]] .. desc.w .. [[ - ]] .. os .. [[); btn._t:SetHeight(]] .. desc.h .. [[ - ]] .. os .. [[);
  57. btn._t:Show();
  58. btn:Hide();
  59. frame.]] .. objname .. [[ = btn;
  60. ]];
  61.         state:Attach(state:Slot("EmitCreate"), true, function(code) code:AppendCode(createCode); end);
  62.  
  63.         ------------------ On frame destruction.
  64.         state:Attach(state:Slot("EmitDestroy"), true, function(code) code:AppendCode([[
  65. VFLUI.ReleaseRegion(frame.]] .. objname .. [[._t); frame.]] .. objname .. [[._t = nil;
  66. frame.]] .. objname .. [[:Destroy(); frame.]] .. objname .. [[ = nil;
  67. ]]); end);
  68.         state:Attach(state:Slot("EmitCleanup"), true, function(code) code:AppendCode([[
  69. frame.]] .. objname .. [[:Hide();
  70. ]]); end);
  71.  
  72.         ------------------ On paint.
  73.         state:Attach(state:Slot("EmitPaint"), true, function(code)
  74.         if desc.test then
  75.             code:AppendCode([[
  76. frame.]] .. objname .. [[._t:SetTexture(GetSpellTexture("Kill Command"));
  77. frame.]] .. objname .. [[:Show();
  78. ]]);
  79.         else
  80.             code:AppendCode([[
  81. frame.]] .. objname .. [[._t:SetTexture(TRUESYS.PriorityHunterBeastMastery());
  82. frame.]] .. objname .. [[:Show();
  83. ]]);
  84.         end
  85.         end);
  86.         return true;
  87.     end;
  88.     UIFromDescriptor = function(desc, parent, state)
  89.         local ui = VFLUI.CompoundFrame:new(parent);
  90.        
  91.         -- Name/width/height
  92.         local ed_name, ed_width, ed_height = RDXUI.GenNameWidthHeightPortion(ui, desc, state);
  93.        
  94.         -- Owner
  95.         local owner = RDXUI.MakeSlotSelectorDropdown(ui, VFLI.i18n("Owner"), state, "Subframe_");
  96.         if desc and desc.owner then owner:SetSelection(desc.owner); end
  97.        
  98.         -- Drawlayer
  99.         local er = VFLUI.EmbedRight(ui, VFLI.i18n("Draw layer"));
  100.         local drawLayer = VFLUI.Dropdown:new(er, RDXUI.DrawLayerDropdownFunction);
  101.         drawLayer:SetWidth(100); drawLayer:Show();
  102.         if desc and desc.drawLayer then drawLayer:SetSelection(desc.drawLayer); else drawLayer:SetSelection("ARTWORK"); end
  103.         er:EmbedChild(drawLayer); er:Show();
  104.         ui:InsertFrame(er);
  105.        
  106.         -- Anchor
  107.         local anchor = RDXUI.UnitFrameAnchorSelector:new(ui); anchor:Show();
  108.         anchor:SetAFArray(RDXUI.ComposeAnchorList(state));
  109.         if desc and desc.anchor then anchor:SetAnchorInfo(desc.anchor); end
  110.         ui:InsertFrame(anchor);
  111.        
  112.         -------------- Display
  113.         ui:InsertFrame(VFLUI.Separator:new(ui, VFLI.i18n("Button Skin parameters")));
  114.        
  115.         local chk_bs = VFLUI.CheckEmbedRight(ui, VFLI.i18n("Use Button Skin"));
  116.         local dd_buttonSkin = VFLUI.Dropdown:new(chk_bs, VFLUI.GetButtonSkinList);
  117.         dd_buttonSkin:SetWidth(150); dd_buttonSkin:Show();
  118.         dd_buttonSkin:SetSelection(desc.externalButtonSkin);
  119.         if desc and desc.usebs then
  120.             chk_bs:SetChecked(true);
  121.         else
  122.             chk_bs:SetChecked();
  123.         end
  124.         chk_bs:EmbedChild(dd_buttonSkin); chk_bs:Show();
  125.         ui:InsertFrame(chk_bs);
  126.        
  127.         local ed_bs = VFLUI.LabeledEdit:new(ui, 50); ed_bs:Show();
  128.         ed_bs:SetText(VFLI.i18n("Button Skin Size Offset"));
  129.         if desc and desc.ButtonSkinOffset then ed_bs.editBox:SetText(desc.ButtonSkinOffset); end
  130.         ui:InsertFrame(ed_bs);
  131.        
  132.         local chk_showgloss = VFLUI.Checkbox:new(ui); chk_showgloss:Show();
  133.         chk_showgloss:SetText(VFLI.i18n("Button Skin Show Gloss"));
  134.         if desc and desc.showgloss then chk_showgloss:SetChecked(true); else chk_showgloss:SetChecked(); end
  135.         ui:InsertFrame(chk_showgloss);
  136.        
  137.         local color_bsdefault = RDXUI.GenerateColorSwatch(ui, VFLI.i18n("Button Skin default color"));
  138.         if desc and desc.bsdefault then color_bsdefault:SetColor(VFL.explodeRGBA(desc.bsdefault)); end
  139.        
  140.         local chk_bkd = VFLUI.CheckEmbedRight(ui, VFLI.i18n("Use Backdrop"));
  141.         local dd_backdrop = VFLUI.MakeBackdropSelectButton(chk_bkd, desc.bkd);
  142.         dd_backdrop:Show();
  143.         if desc and desc.usebkd then
  144.             chk_bkd:SetChecked(true);
  145.         else
  146.             chk_bkd:SetChecked();
  147.         end
  148.         chk_bkd:EmbedChild(dd_backdrop); chk_bkd:Show();
  149.         ui:InsertFrame(chk_bkd);
  150.        
  151.         local chk_hidebs = VFLUI.Checkbox:new(ui); chk_hidebs:Show();
  152.         chk_hidebs:SetText(VFLI.i18n("Hide empty button"));
  153.         if desc and desc.hidebs then chk_hidebs:SetChecked(true); else chk_hidebs:SetChecked(); end
  154.         ui:InsertFrame(chk_hidebs);
  155.        
  156.         function ui:GetDescriptor()
  157.         local name = ed_name.editBox:GetText();
  158.         local ebs = nil;
  159.         if chk_bs:GetChecked() then ebs = dd_buttonSkin:GetSelection(); end
  160.         return {
  161.             feature = "(True) Hunter Priority Icon", name = name, owner = owner:GetSelection();
  162.             drawLayer = drawLayer:GetSelection();
  163.             w = ed_width:GetSelection();
  164.             h = ed_height:GetSelection();
  165.             anchor = anchor:GetAnchorInfo();
  166.             -- display
  167.             usebs = chk_bs:GetChecked();
  168.             externalButtonSkin = dd_buttonSkin:GetSelection();
  169.             ButtonSkinOffset = VFL.clamp(ed_bs.editBox:GetNumber(), 0, 50);
  170.             showgloss = chk_showgloss:GetChecked();
  171.             bsdefault = color_bsdefault:GetColor();
  172.             usebkd = chk_bkd:GetChecked();
  173.             bkd = dd_backdrop:GetSelectedBackdrop();
  174.             hidebs = chk_hidebs:GetChecked();
  175.         };
  176.         end
  177.        
  178.         return ui;
  179.     end;
  180.     CreateDescriptor = function()
  181.         return {
  182.             feature = "(True) Hunter Priority Icon", name = "bmpi", owner = "decor", drawLayer = "ARTWORK";
  183.             w = 14; h = 14;
  184.             anchor = { lp = "TOPLEFT", af = "Base", rp = "TOPLEFT", dx = 0, dy = 0};
  185.             externalButtonSkin = "bs_default";
  186.             ButtonSkinOffset = 0;
  187.             bkd = VFL.copy(VFLUI.defaultBackdrop);
  188.         };
  189.     end;
  190. });

Honestly, except for the button skin, I'm 100% happy with the outcome of my work on these. They're exactly what I wanted. c.c
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **

Last edited by unlimit : 01-31-12 at 05:18 AM.
  Reply With Quote