View Single Post
01-30-12, 02:45 AM   #3
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Hm, I don't quite understand, could you explain in a bit more detail if possible?

Edit: Nevermind! What you said worked out great! Thanks Sigg!

lua Code:
  1. RDX.RegisterFeature({
  2.     name = "BM Priority Icon";
  3.     title = VFLI.i18n("Icon BM Priority");
  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.         local flg = true;
  15.         flg = flg and RDXUI.UFFrameCheck_Proto("Frame_", desc, state, errs);
  16.         flg = flg and RDXUI.UFAnchorCheck(desc.anchor, state, errs);
  17.         flg = flg and RDXUI.UFOwnerCheck(desc.owner, state, errs);
  18.         if flg then state:AddSlot("Frame_" .. desc.name); end
  19.         return flg;
  20.     end;
  21.     ApplyFeature = function(desc, state)
  22.         local objname = "Frame_" .. desc.name;
  23.         local ebsflag, ebs, ebsos = "false", "bs_default", 0;
  24.         if desc.externalButtonSkin then
  25.             ebsflag = "true";
  26.             ebs = desc.externalButtonSkin;
  27.             if desc.ButtonSkinOffset then ebsos = desc.ButtonSkinOffset; end
  28.         end
  29.       ------------------ On frame creation
  30.         local createCode = [[      
  31. local btn, owner = nil, ]] .. RDXUI.ResolveFrameReference(desc.owner) .. [[;
  32. if ]] .. ebsflag .. [[ then
  33.     btn = VFLUI.SkinButton:new();
  34.     btn:SetButtonSkin("]] .. ebs ..[[", true, true, false, true, true, true, false, true, true, true);
  35. else
  36.     btn = VFLUI.AcquireFrame("Frame");
  37. end
  38. btn:SetParent(owner);
  39. btn:SetFrameLevel(owner:GetFrameLevel());
  40. btn:SetPoint(]] .. RDXUI.AnchorCodeFromDescriptor(desc.anchor) .. [[);
  41. btn:SetWidth(]] .. desc.w .. [[); btn:SetHeight(]] .. desc.h .. [[);
  42. btn._t = VFLUI.CreateTexture(btn);
  43. btn._t:SetDrawLayer("]] .. (desc.drawLayer or "ARTWORK") .. [[", 2);
  44. btn._t:SetPoint("CENTER", btn, "CENTER");
  45. btn._t:SetWidth(]] .. desc.w .. [[ - ]] .. ebsos .. [[); btn._t:SetHeight(]] .. desc.h .. [[ - ]] .. ebsos .. [[);
  46. btn._t:SetVertexColor(1,1,1,1);
  47. btn._t:SetTexture("Interface\\InventoryItems\\WoWUnknownItem01.blp");
  48. btn._t:Show();
  49. btn:Hide();
  50. frame.]] .. objname .. [[ = btn;
  51. ]];
  52.         state:Attach(state:Slot("EmitCreate"), true, function(code) code:AppendCode(createCode); end);
  53.  
  54.         ------------------ On frame destruction.
  55.         state:Attach(state:Slot("EmitDestroy"), true, function(code) code:AppendCode([[
  56. VFLUI.ReleaseRegion(frame.]] .. objname .. [[._t); frame.]] .. objname .. [[._t = nil;
  57. frame.]] .. objname .. [[:Destroy(); frame.]] .. objname .. [[ = nil;
  58. ]]); end);
  59.         state:Attach(state:Slot("EmitCleanup"), true, function(code) code:AppendCode([[
  60. frame.]] .. objname .. [[:Hide();
  61. ]]); end);
  62.  
  63.         ------------------ On paint.
  64.         state:Attach(state:Slot("EmitPaint"), true, function(code)
  65.         if desc.test then
  66.             code:AppendCode([[
  67. frame.]] .. objname .. [[._t:SetTexture(GetSpellTexture("Kill Command"));
  68. frame.]] .. objname .. [[:Show();
  69. ]]);
  70.         else
  71.             code:AppendCode([[
  72. function IconBMPriority()
  73.     local gcd = 1.5
  74.     local level = UnitLevel("player")
  75.     local focus = UnitPower("player")
  76.     local duration, _
  77.     local inRange = 0
  78.     if UnitExists("target") and UnitIsVisible("target") then
  79.         inRange = IsSpellInRange(16827, pet, "target")
  80.     end
  81.  
  82.     if not UnitCanAttack("player", "target") then
  83.         return
  84.     end
  85.  
  86.     -- 1. If your pet is on the target, Kill Command
  87.     if inRange == 1 and focus > 50 then
  88.         _, duration = GetSpellCooldown("Kill Command")
  89.         if duration <= gcd then
  90.             return GetSpellTexture("Kill Command")
  91.         end
  92.     end
  93.  
  94.     -- 2. If the mob is going to live long enough, apply Serpent Sting.
  95.     if focus > 35 then
  96.         _, duration = GetSpellCooldown("Serpent Sting")
  97.         if duration <= gcd then
  98.             return GetSpellTexture("Serpent Sting")
  99.         end
  100.     end
  101.  
  102.     -- 3. If mob is below 20% health, Kill Shot
  103.     _, duration = GetSpellCooldown("Kill Shot")
  104.     if duration <= gcd and ( UnitHealth("target") / UnitHealthMax("target") < 0.2 ) then
  105.         return GetSpellTexture("Kill Shot")
  106.     end
  107.  
  108.     -- 4. If you will have enough focus to use Explosive Shot and Black Arrow, use Arcane Shot
  109.     if focus > 85 then
  110.         return GetSpellTexture("Arcane Shot")
  111.     end
  112.  
  113.     -- 5. Cobra Shot (or Steady Shot)
  114.     if level < 81 then
  115.         return GetSpellTexture("Steady Shot")
  116.     else
  117.         return GetSpellTexture("Cobra Shot")
  118.     end
  119. end
  120.  
  121. frame.]] .. objname .. [[._t:SetTexture(IconBMPriority());
  122. frame.]] .. objname .. [[:Show();
  123. ]]);
  124.         end
  125.         end);
  126.         return true;
  127.     end;
  128.     UIFromDescriptor = function(desc, parent, state)
  129.         local ui = VFLUI.CompoundFrame:new(parent);
  130.        
  131.         -- Name/width/height
  132.         local ed_name, ed_width, ed_height = RDXUI.GenNameWidthHeightPortion(ui, desc, state);
  133.        
  134.         -- Owner
  135.         local owner = RDXUI.MakeSlotSelectorDropdown(ui, VFLI.i18n("Owner"), state, "Subframe_");
  136.         if desc and desc.owner then owner:SetSelection(desc.owner); end
  137.        
  138.         -- Drawlayer
  139.         local er = VFLUI.EmbedRight(ui, VFLI.i18n("Draw layer"));
  140.         local drawLayer = VFLUI.Dropdown:new(er, RDXUI.DrawLayerDropdownFunction);
  141.         drawLayer:SetWidth(100); drawLayer:Show();
  142.         if desc and desc.drawLayer then drawLayer:SetSelection(desc.drawLayer); else drawLayer:SetSelection("ARTWORK"); end
  143.         er:EmbedChild(drawLayer); er:Show();
  144.         ui:InsertFrame(er);
  145.        
  146.         -- Anchor
  147.         local anchor = RDXUI.UnitFrameAnchorSelector:new(ui); anchor:Show();
  148.         anchor:SetAFArray(RDXUI.ComposeAnchorList(state));
  149.         if desc and desc.anchor then anchor:SetAnchorInfo(desc.anchor); end
  150.         ui:InsertFrame(anchor);
  151.        
  152.         local chk_bs = VFLUI.CheckEmbedRight(ui, VFLI.i18n("Use Button Skin"));
  153.         local dd_buttonSkin = VFLUI.Dropdown:new(chk_bs, VFLUI.GetButtonSkinList);
  154.         dd_buttonSkin:SetWidth(150); dd_buttonSkin:Show();
  155.         if desc and desc.externalButtonSkin then
  156.             chk_bs:SetChecked(true);
  157.             dd_buttonSkin:SetSelection(desc.externalButtonSkin);
  158.         else
  159.             chk_bs:SetChecked();
  160.             dd_buttonSkin:SetSelection("bs_default");
  161.         end
  162.         chk_bs:EmbedChild(dd_buttonSkin); chk_bs:Show();
  163.         ui:InsertFrame(chk_bs);
  164.        
  165.         local ed_bs = VFLUI.LabeledEdit:new(ui, 50); ed_bs:Show();
  166.         ed_bs:SetText(VFLI.i18n("Button Skin Size Offset"));
  167.         if desc and desc.ButtonSkinOffset then ed_bs.editBox:SetText(desc.ButtonSkinOffset); end
  168.         ui:InsertFrame(ed_bs);
  169.        
  170.         function ui:GetDescriptor()
  171.         local name = ed_name.editBox:GetText();
  172.         local ebs = nil;
  173.         if chk_bs:GetChecked() then ebs = dd_buttonSkin:GetSelection(); end
  174.         return {
  175.             feature = "BM Priority Icon", name = name, owner = owner:GetSelection();
  176.             drawLayer = drawLayer:GetSelection();
  177.             w = ed_width:GetSelection();
  178.             h = ed_height:GetSelection();
  179.             anchor = anchor:GetAnchorInfo();
  180.             externalButtonSkin = ebs;
  181.             ButtonSkinOffset = VFL.clamp(ed_bs.editBox:GetNumber(), 0, 50);
  182.         };
  183.         end
  184.        
  185.         return ui;
  186.     end;
  187.     CreateDescriptor = function()
  188.         return {
  189.             feature = "BM Priority Icon", name = "bmpi", owner = "decor", drawLayer = "ARTWORK";
  190.             w = 14; h = 14;
  191.             anchor = { lp = "TOPLEFT", af = "Base", rp = "TOPLEFT", dx = 0, dy = 0};
  192.             ButtonSkinOffset = 5;
  193.         };
  194.     end;
  195. });
__________________


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

Last edited by unlimit : 01-30-12 at 05:34 AM.
  Reply With Quote