Thread Tools Display Modes
08-30-09, 10:22 AM   #1
Rhamses
A Theradrim Guardian
Join Date: Jun 2009
Posts: 61
Some warlock buttons

I am at best a noob coder. I wrote these two buttons in lua. But, I access them through an xml because that was what I was learning.

The first button is a pretty simple warlock life drain button.

If there is no target, it will show the current number of shards and the max number of shards to keep. If a 29th (my baf holds 28) is collected it is deleted. If soemone is targeted it shows the current health percentage in the soul stone circle until the percentage drops to 25% or below. Then it displays the drain soul spell icon. A click will cast drain soul at any time.

the second button dispalys my pets current mana and health percentage. If health drops below 25% it reminds to health funle. If mana drops low it asks about life tap. One button controls both spells by accessing the left vs right mouse button. If this is helpful to anyone, here is what I wrote in the lua. But, I guess you would have to initialize the buttons in lua on your own.

-- Customizable Stuff

-- MAX SHARDS VARIABLE SET HERE.

local maxShards = 28

-- Change the number above to increase or decrease number of shards
-- MAX SHARDS VARIABLE SET END

local ITEM_TO_DELETE = "Soul Shard";
local health = 0;
local maxhealth = 0;
local numShards = 0


-- ****************************************************
-- * ON_LOAD COMMANDS *
-- ****************************************************
function ExecuteWarning_OnLoad()
ExecuteWarning_BuffFrame:Show();
ExecuteWarning_BuffFrame:SetAttribute('type', 'spell')
ExecuteWarning_BuffFrame:SetAttribute('spell', "Drain Soul")
ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\INV_Misc_Gem_Amethyst_02")


ExecuteWarning_Pet_BuffFrame:Show();
ExecuteWarning_Pet_BuffFrame:SetAttribute('type', 'spell')
ExecuteWarning_Pet_BuffFrame:SetAttribute('spell1', "Health Funnel")
ExecuteWarning_Pet_BuffFrame:SetAttribute('type2', 'spell')
ExecuteWarning_Pet_BuffFrame:SetAttribute('spell2', 'Life Tap')
ExecuteWarning_Pet_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_DemonicPact");
end
-- ****************************************************
-- * FUNCTIONS *
-- ****************************************************
-- * Add your own functions in the section below. I've also included several basic but
-- * useful functions below to get you started.

function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end


function ExecuteWarning_Update(name, health, maxhealth)
numShards = GetItemCount(ITEM_TO_DELETE);
if numShards > maxShards then
DeleteShard()
end

if (UnitName("target") == nil) then
ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\INV_Misc_Gem_Amethyst_02")
getglobal(ExecuteWarning_BuffFrame:GetName().."_Text"):SetText( " "..numShards .."\n\n\n".. maxShards.." " );
end

if (UnitIsDead("target") == 1) then
ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\INV_Misc_Orb_04");
getglobal(ExecuteWarning_BuffFrame:GetName().."_Text"):SetText( "Dead" );
else
local name = UnitName("target");
local maxhealth = UnitHealthMax("target");
local health = UnitHealth("target");
local status = health.."/"..maxhealth;
local percent = round( (health/maxhealth)*100);

if (percent > 25) then
ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\INV_Misc_Orb_04");
getglobal(ExecuteWarning_BuffFrame:GetName().."_Text"):SetText(percent .. "%" );

elseif (percent <= 25) then
getglobal(ExecuteWarning_BuffFrame:GetName().."_Text"):SetText(" ");
ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_Haunting");
ExecuteWarning_Pet_BuffFrame:SetBackdropColor( 1, 0, 0, 1 );
end
end

if (UnitName("pet") == nil) then
ExecuteWarning_Pet_BuffFrame:Hide();
else
ExecuteWarning_Pet_BuffFrame:Show();

local name = UnitName("pet");
local maxhealth = UnitHealthMax("pet");
local health = UnitHealth("pet");
local status = health.."/"..maxhealth;
local percent = round( (health/maxhealth)*100);

local maxMana = UnitManaMax("pet");
local Mana = UnitMana("pet");
local status2 = Mana.."/"..maxMana;
local percent2 = round( (Mana/maxMana)*100);

if (percent > 25) then
ExecuteWarning_Pet_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_DemonicPact");
getglobal(ExecuteWarning_Pet_BuffFrame:GetName().."_Text"):SetText( percent .."%\n\n\n".. percent2.."%" );
end

if (percent2 <= 25) then
ExecuteWarning_Pet_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_Metamorphosis");
getglobal(ExecuteWarning_Pet_BuffFrame:GetName().."_Text"):SetText( "LifeTap?\n\n\n(Right B)" );
end
if (percent <= 25) then
ExecuteWarning_Pet_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_LifeDrain");
getglobal(ExecuteWarning_Pet_BuffFrame:GetName().."_Text"):SetText( "Funnel!\n\n\n(Left B)" );
end
end
end

function DeleteShard()
for i=0,4 do
for j=1, GetContainerNumSlots(i) do
local item = GetContainerItemLink(i,j)
if item and item:find(ITEM_TO_DELETE) then
PickupContainerItem(i,j)
DeleteCursorItem()
return
end
end
end
end
 
08-30-09, 10:28 AM   #2
Rhamses
A Theradrim Guardian
Join Date: Jun 2009
Posts: 61
This creaes three buttons at present. The first one searches the spellbook and identifies teh demon spells known by the player. It then collects them and puts them in "children buttons" similar to luna. But, the children are wrapped around the parent.

There are two other parents one contians the four lock channeling - drain and funnel. the other contains the targeted direct damage, shadow bolt, incinerate etc. Not quite done yet. i should do one for curses. I also have to better credit the original author that showed how to do the circles and how to check the spell book

BINDING_HEADER_DEMONOMICON_PETHEADER = 'Demonomicon'

---------------------------------------------------------------------------------------------
-- Warlock Check
---------------------------------------------------------------------------------------------
if select(2, UnitClass('player')) ~= 'WARLOCK' then return; end


----------------------------------------------------------------------------------------------
-- Demon Button #1 Creation
----------------------------------------------------------------------------------------------
local Demonomicon = Servitas:StyleButton(CreateFrame("Button", "Demonomicon", UIParent, "SecureHandlerClickTemplate"))
Servitas.Demonomicon = Demonomicon
SecureHandler_OnLoad(Demonomicon)

Demonomicon:SetPoint("TOPLEFT", PlayerFrame, "BOTTOMLEFT", 52, 12)
Demonomicon:SetHeight(24);
Demonomicon:SetWidth(24)
Demonomicon:SetMovable()
Demonomicon:SetScript("OnDragStart", Demonomicon.StartMoving)
Demonomicon:SetScript("OnDragStop", Demonomicon.StopMovingOrSizing)
Demonomicon:RegisterForDrag("LeftButton")
Demonomicon.Icon:SetTexture[[Interface\Icons\Spell_Shadow_DeathsEmbrace]];
-------------------------------------------------------------------------------------------------------------
-- Toggles the visibility of the children buttons
-------------------------------------------------------------------------------------------------------------

Demonomicon:SetAttribute("_onclick",
[[
if menu:IsShown() then
menu:Hide()
else
menu:SetAttribute("open", button)
menu:Show()
end]])

-------------------------------------------------------------------------------------------------------------
-- Prepare the spells that will be sought from the player's spell book
-------------------------------------------------------------------------------------------------------------

Demonomicon.Buttons = {}
Demonomicon.SummonTab = [[Interface\Icons\Spell_Shadow_Metamorphosis]]
Demonomicon.Textures =
{
Imp = [[Interface\Icons\Spell_Shadow_Haunting]],
Infernal = [[Interface\Icons\Spell_Shadow_SiphonMana]],
Succubus = [[Interface\Icons\Spell_Shadow_LifeDrain]],
Felhunter = [[Interface\Icons\Spell_Shadow_LifeDrain02]],
}

Demonomicon[ Demonomicon.Textures.Imp ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Infernal ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Succubus ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Felhunter ] = 'Summon'

-------------------------------------------------------------------------------------------------------------
-- Creating Frame
-------------------------------------------------------------------------------------------------------------

Demonomicon.Menu = CreateFrame("Frame", Demonomicon:GetName().."Menu", Demonomicon, "SecureHandlerShowHideTemplate")

Demonomicon:SetFrameRef("menu", Demonomicon.Menu)
Demonomicon.Menu:Hide()
Demonomicon.Menu:SetPoint("CENTER", Demonomicon)
Demonomicon.Menu:SetAttribute("_onhide", [[open = nil]])
Demonomicon.Menu:SetAttribute("_onshow", [[
if buttons then
for i, b in ipairs(buttons) do
if self:GetAttribute("open") then
b:SetAttribute('type', 'macro');
end
self:SetBindingClick(true, tostring(b:GetID()), b:GetName(), "LeftButton")
end
end ]])

-------------------------------------------------------------------------------------------------------------
-- Matching desired spells with spells know in spell book
-------------------------------------------------------------------------------------------------------------

Demonomicon:Execute[[menu = self:GetFrameRef("menu")]]

function Demonomicon:SetUpButtons(event, ...)

local Locale, Placement, Buttons = self.Locale, self.Placement, self.Buttons
Locale.Spells = { Summons = {} }
local Spells = Locale.Spells
for tabIndex = 1,MAX_SKILLLINE_TABS do
local tabName, texture, startSpell, numSpells = GetSpellTabInfo(tabIndex)
if not tabName then break end
-- if texture == self.SummonTab then
for spellIndex = startSpell + 1, startSpell + numSpells do
local spellIcon = GetSpellTexture(spellIndex,BOOKTYPE_SPELL)
local spellSought = self[spellIcon]
if spellSought and type(spellSought) == 'string' then
if spellSought == 'Summon' then
Spells.Summons[spellIcon] = GetSpellName(spellIndex, BOOKTYPE_SPELL)
else
Spells[spellSought] = GetSpellName(spellIndex, BOOKTYPE_SPELL)
end
end
-- end
end
end
if next(Spells.Summons) then self:Show() else self:Hide(); return end

-------------------------------------------------------------------------------------------------------------
-- Setting button abilities
-------------------------------------------------------------------------------------------------------------
local numButtons = 0
for _,summonKey in pairs(Placement.order) do
local summon = Spells.Summons[summonKey]
if summon then
numButtons = numButtons + 1
local summonButton = Buttons[numButtons]
if not summonButton then
local newName = self:GetName().."Summon"..numButtons
summonButton = Servitas:StyleButton(CreateFrame('BUTTON', newName, self.Menu, "SecureActionButtonTemplate"))
self.Menu:WrapScript(summonButton, "OnClick", [[if #buttons > 1 then owner:Hide() end]])
Buttons[numButtons] = summonButton
end
summonButton:SetID(numButtons)
summonButton.Icon:SetTexture(summonKey)
summonButton:SetAttribute('macrotext', '/cast '..summon)
end
end
self.Menu:Execute
[[buttons = self:GetChildList(buttons or table.new());
for i, b in ipairs(buttons) do
if b:GetID() == 0 then
table.remove(buttons, i);
end
end]]

-------------------------------------------------------------------------------------------------------------
-- Slice the pie locations
-------------------------------------------------------------------------------------------------------------
if numButtons > 0 then
local angle = Placement.startAngle
local slice = (Placement.endAngle - angle) / numButtons
local radius = 18 / math.sin(slice / 2)
for index=1,numButtons do
Buttons[index]:SetPoint("CENTER", self, "CENTER", radius * math.cos(angle),
radius * math.sin(angle))
angle = angle + slice
end
self.Menu:SetWidth(radius * 2 + 36)
self.Menu:SetHeight(radius * 2 + 36)
end
end
-------------------------------------------------------------------------------------------------------------
-- Load pie slices with Textures
-------------------------------------------------------------------------------------------------------------
Demonomicon:SetScript("OnEvent", function (self, event, ...)
Demonomicon_Locale = {}
Demonomicon_Locale[GetLocale()] = Demonomicon_Locale[GetLocale()] or
({})[GetLocale()] or {}

self.Locale = Demonomicon_Locale[GetLocale()]
Demonomicon_Placement =
{
startAngle = math.pi,
endAngle = 3 * math.pi,
order =
{
self.Textures.Imp,
self.Textures.Infernal,
self.Textures.Voidwalker,
self.Textures.Succubus,
self.Textures.Felhunter,
self.Textures.Felguard
}
}
self.Placement = Demonomicon_Placement
self:SetScript('OnEvent', function (self, event, ...)
self:SetUpButtons(event, ...)end)
end)

--------------------------------------------------------------------------------------------------------------
--
--------------------------------------------------------------------------------------------------------------
Demonomicon:RegisterEvent('PLAYER_ENTERING_WORLD')
Demonomicon:RegisterForClicks("AnyUp")
Demonomicon:RegisterEvent('ADDON_LOADED')


----------------------------------------------------------------------------------------------
-- Demon Button#2 Creation
----------------------------------------------------------------------------------------------
local Demonomicon = Servitas:StyleButton(CreateFrame("Button", "Demonomicon", UIParent, "SecureHandlerClickTemplate"))
Servitas.Demonomicon = Demonomicon
SecureHandler_OnLoad(Demonomicon)

Demonomicon:SetPoint("TOPLEFT", PlayerFrame, "BOTTOMLEFT", 52, 12)
Demonomicon:SetHeight(24);
Demonomicon:SetWidth(24)
Demonomicon:SetMovable()
Demonomicon:SetScript("OnDragStart", Demonomicon.StartMoving)
Demonomicon:SetScript("OnDragStop", Demonomicon.StopMovingOrSizing)
Demonomicon:RegisterForDrag("LeftButton")
Demonomicon.Icon:SetTexture[[Interface\Icons\INV_Misc_Book_06]];

-------------------------------------------------------------------------------------------------------------
-- Toggles the visibility of the children buttons
-------------------------------------------------------------------------------------------------------------

Demonomicon:SetAttribute("_onclick",
[[
if menu:IsShown() then
menu:Hide()
else
menu:SetAttribute("open", button)
menu:Show()
menu:RegisterAutoHide(1.5)
end]])

-------------------------------------------------------------------------------------------------------------
-- Prepare the spells that will be sought from the player's spell book
-------------------------------------------------------------------------------------------------------------

Demonomicon.Buttons = {}
Demonomicon.SummonTab = [[Interface\Icons\Spell_Shadow_Metamorphosis]]
Demonomicon.Textures =
{
Imp = [[Interface\Icons\Spell_Shadow_SummonImp]],
Infernal = [[Interface\Icons\Spell_Shadow_SummonInfernal]],
Voidwalker = [[Interface\Icons\Spell_Shadow_SummonVoidWalker]],
Succubus = [[Interface\Icons\Spell_Shadow_SummonSuccubus]],
Felhunter = [[Interface\Icons\Spell_Shadow_SummonFelHunter]],
Felguard = [[Interface\Icons\Spell_Shadow_SummonFelGuard]]
}

Demonomicon[ Demonomicon.Textures.Imp ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Infernal ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Voidwalker ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Succubus ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Felhunter ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Felguard ] = 'Summon'

Demonomicon[ [[Interface\Icons\Spell_Nature_RemoveCurse]] ] = "FastCast"
-------------------------------------------------------------------------------------------------------------
-- Creating Frame
-------------------------------------------------------------------------------------------------------------

Demonomicon.Menu = CreateFrame("Frame", Demonomicon:GetName().."Menu", Demonomicon, "SecureHandlerShowHideTemplate")

Demonomicon:SetFrameRef("menu", Demonomicon.Menu)
Demonomicon.Menu:Hide()
Demonomicon.Menu:SetPoint("CENTER", Demonomicon)
Demonomicon.Menu:SetAttribute("_onhide", [[open = nil]])
Demonomicon.Menu:SetAttribute("_onshow", [[
if buttons then
for i, b in ipairs(buttons) do
if self:GetAttribute("open") then
b:SetAttribute('type', 'macro');
end
self:SetBindingClick(true, tostring(b:GetID()), b:GetName(), "LeftButton")
end
end ]])

-------------------------------------------------------------------------------------------------------------
-- Matching desired spells with spells know in spell book
-------------------------------------------------------------------------------------------------------------

Demonomicon:Execute[[menu = self:GetFrameRef("menu")]]

function Demonomicon:SetUpButtons(event, ...)

local Locale, Placement, Buttons = self.Locale, self.Placement, self.Buttons
Locale.Spells = { Summons = {} }
local Spells = Locale.Spells
for tabIndex = 1,MAX_SKILLLINE_TABS do
local tabName, texture, startSpell, numSpells = GetSpellTabInfo(tabIndex)
if not tabName then break end
if texture == self.SummonTab then
for spellIndex = startSpell + 1, startSpell + numSpells do
local spellIcon = GetSpellTexture(spellIndex,BOOKTYPE_SPELL)
local spellSought = self[spellIcon]
if spellSought and type(spellSought) == 'string' then
if spellSought == 'Summon' then
Spells.Summons[spellIcon] = GetSpellName(spellIndex, BOOKTYPE_SPELL)
else
Spells[spellSought] = GetSpellName(spellIndex, BOOKTYPE_SPELL)
end
end
end
end
end
if next(Spells.Summons) then self:Show() else self:Hide(); return end

-------------------------------------------------------------------------------------------------------------
-- Setting button abilities
-------------------------------------------------------------------------------------------------------------
local numButtons = 0
for _,summonKey in pairs(Placement.order) do
local summon = Spells.Summons[summonKey]
if summon then
numButtons = numButtons + 1
local summonButton = Buttons[numButtons]
if not summonButton then
local newName = self:GetName().."Summon"..numButtons
summonButton = Servitas:StyleButton(CreateFrame('BUTTON', newName, self.Menu, "SecureActionButtonTemplate"))
self.Menu:WrapScript(summonButton, "OnClick", [[if #buttons > 1 then owner:Hide() end]])
Buttons[numButtons] = summonButton
end
summonButton:SetID(numButtons)
summonButton.Icon:SetTexture(summonKey)
summonButton:SetAttribute('macrotext', '/cast '..(Locale.Spells.FastCast or "").."\n/cast "..summon)
end
end
self.Menu:Execute
[[buttons = self:GetChildList(buttons or table.new());
for i, b in ipairs(buttons) do
if b:GetID() == 0 then
table.remove(buttons, i);
end
end]]

-------------------------------------------------------------------------------------------------------------
-- Slice the pie locations
-------------------------------------------------------------------------------------------------------------
if numButtons > 0 then
local angle = Placement.startAngle
local slice = (Placement.endAngle - angle) / numButtons
local radius = 18 / math.sin(slice / 2)
for index=1,numButtons do
Buttons[index]:SetPoint("CENTER", self, "CENTER", radius * math.cos(angle),
radius * math.sin(angle))
angle = angle + slice
end
self.Menu:SetWidth(radius * 2 + 36)
self.Menu:SetHeight(radius * 2 + 36)
end
end
-------------------------------------------------------------------------------------------------------------
-- Load pie slices with Textures
-------------------------------------------------------------------------------------------------------------
Demonomicon:SetScript("OnEvent", function (self, event, ...)
Demonomicon_Locale = {}
Demonomicon_Locale[GetLocale()] = Demonomicon_Locale[GetLocale()] or
({})[GetLocale()] or {}

self.Locale = Demonomicon_Locale[GetLocale()]
Demonomicon_Placement =
{
startAngle = math.pi,
endAngle = 3 * math.pi,
order =
{
self.Textures.Imp,
self.Textures.Infernal,
self.Textures.Voidwalker,
self.Textures.Succubus,
self.Textures.Felhunter,
self.Textures.Felguard
}
}
self.Placement = Demonomicon_Placement
self:SetScript('OnEvent', function (self, event, ...)
self:SetUpButtons(event, ...)end)
end)

Demonomicon:RegisterEvent('PLAYER_ENTERING_WORLD')
Demonomicon:RegisterForClicks("AnyUp")
Demonomicon:RegisterEvent('ADDON_LOADED')


----------------------------------------------------------------------------------------------
-- Demon Button #3 Creation
----------------------------------------------------------------------------------------------
local Demonomicon = Servitas:StyleButton(CreateFrame("Button", "Demonomicon", UIParent, "SecureHandlerClickTemplate"))
Servitas.Demonomicon = Demonomicon
SecureHandler_OnLoad(Demonomicon)

Demonomicon:SetPoint("TOPLEFT", PlayerFrame, "BOTTOMLEFT", 52, 12)
Demonomicon:SetHeight(24);
Demonomicon:SetWidth(24)
Demonomicon:SetMovable()
Demonomicon:SetScript("OnDragStart", Demonomicon.StartMoving)
Demonomicon:SetScript("OnDragStop", Demonomicon.StopMovingOrSizing)
Demonomicon:RegisterForDrag("LeftButton")
Demonomicon.Icon:SetTexture[[Interface\Icons\Spell_Fire_BlueFire]];
-------------------------------------------------------------------------------------------------------------
-- Toggles the visibility of the children buttons
-------------------------------------------------------------------------------------------------------------

Demonomicon:SetAttribute("_onclick",
[[
if menu:IsShown() then
menu:Hide()
else
menu:SetAttribute("open", button)
menu:Show()
end]])

-------------------------------------------------------------------------------------------------------------
-- Prepare the spells that will be sought from the player's spell book
-------------------------------------------------------------------------------------------------------------

Demonomicon.Buttons = {}
Demonomicon.SummonTab = [[Interface\Icons\Spell_Shadow_Metamorphosis]]
Demonomicon.Textures =
{
Imp = [[Interface\Icons\Icons\Spell_Fire_Immolation]],
Infernal = [[Interface\Icons\Spell_Fire_SoulBurn]],
Succubus = [[Interface\Icons\Spell_Fire_Burnout]],
Felhunter = [[Interface\Icons\Spell_Fire_Fireball02]],
Felguard = [[Interface\Icons\Spell_Shadow_ShadowBolt]],
}
Demonomicon[ Demonomicon.Textures.Imp ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Infernal ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Succubus ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Felhunter ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Felguard ] = 'Summon'

-------------------------------------------------------------------------------------------------------------
-- Creating Frame
-------------------------------------------------------------------------------------------------------------

Demonomicon.Menu = CreateFrame("Frame", Demonomicon:GetName().."Menu", Demonomicon, "SecureHandlerShowHideTemplate")

Demonomicon:SetFrameRef("menu", Demonomicon.Menu)
Demonomicon.Menu:Hide()
Demonomicon.Menu:SetPoint("CENTER", Demonomicon)
Demonomicon.Menu:SetAttribute("_onhide", [[open = nil]])
Demonomicon.Menu:SetAttribute("_onshow", [[
if buttons then
for i, b in ipairs(buttons) do
if self:GetAttribute("open") then
b:SetAttribute('type', 'macro');
end
self:SetBindingClick(true, tostring(b:GetID()), b:GetName(), "LeftButton")
end
end ]])

-------------------------------------------------------------------------------------------------------------
-- Matching desired spells with spells know in spell book
-------------------------------------------------------------------------------------------------------------

Demonomicon:Execute[[menu = self:GetFrameRef("menu")]]

function Demonomicon:SetUpButtons(event, ...)

local Locale, Placement, Buttons = self.Locale, self.Placement, self.Buttons
Locale.Spells = { Summons = {} }
local Spells = Locale.Spells
for tabIndex = 1,MAX_SKILLLINE_TABS do
local tabName, texture, startSpell, numSpells = GetSpellTabInfo(tabIndex)
if not tabName then break end
-- if texture == self.SummonTab then
for spellIndex = startSpell + 1, startSpell + numSpells do
local spellIcon = GetSpellTexture(spellIndex,BOOKTYPE_SPELL)
local spellSought = self[spellIcon]
if spellSought and type(spellSought) == 'string' then
if spellSought == 'Summon' then
Spells.Summons[spellIcon] = GetSpellName(spellIndex, BOOKTYPE_SPELL)
else
Spells[spellSought] = GetSpellName(spellIndex, BOOKTYPE_SPELL)
end
end
-- end
end
end
if next(Spells.Summons) then self:Show() else self:Hide(); return end

-------------------------------------------------------------------------------------------------------------
-- Setting button abilities
-------------------------------------------------------------------------------------------------------------
local numButtons = 0
for _,summonKey in pairs(Placement.order) do
local summon = Spells.Summons[summonKey]
if summon then
numButtons = numButtons + 1
local summonButton = Buttons[numButtons]
if not summonButton then
local newName = self:GetName().."Summon"..numButtons
summonButton = Servitas:StyleButton(CreateFrame('BUTTON', newName, self.Menu, "SecureActionButtonTemplate"))
self.Menu:WrapScript(summonButton, "OnClick", [[if #buttons > 1 then owner:Hide() end]])
Buttons[numButtons] = summonButton
end
summonButton:SetID(numButtons)
summonButton.Icon:SetTexture(summonKey)
summonButton:SetAttribute('macrotext', '/cast '..summon)
end
end
self.Menu:Execute
[[buttons = self:GetChildList(buttons or table.new());
for i, b in ipairs(buttons) do
if b:GetID() == 0 then
table.remove(buttons, i);
end
end]]

-------------------------------------------------------------------------------------------------------------
-- Slice the pie locations
-------------------------------------------------------------------------------------------------------------
if numButtons > 0 then
local angle = Placement.startAngle
local slice = (Placement.endAngle - angle) / numButtons
local radius = 18 / math.sin(slice / 2)
for index=1,numButtons do
Buttons[index]:SetPoint("CENTER", self, "CENTER", radius * math.cos(angle),
radius * math.sin(angle))
angle = angle + slice
end
self.Menu:SetWidth(radius * 2 + 36)
self.Menu:SetHeight(radius * 2 + 36)
end
end
-------------------------------------------------------------------------------------------------------------
-- Load pie slices with Textures
-------------------------------------------------------------------------------------------------------------
Demonomicon:SetScript("OnEvent", function (self, event, ...)
Demonomicon_Locale = {}
Demonomicon_Locale[GetLocale()] = Demonomicon_Locale[GetLocale()] or
({})[GetLocale()] or {}

self.Locale = Demonomicon_Locale[GetLocale()]
Demonomicon_Placement =
{
startAngle = math.pi,
endAngle = 3 * math.pi,
order =
{
self.Textures.Imp,
self.Textures.Infernal,
self.Textures.Succubus,
self.Textures.Felhunter,
self.Textures.Felguard
}
}


self.Placement = Demonomicon_Placement
self:SetScript('OnEvent', function (self, event, ...)
self:SetUpButtons(event, ...)end)
end)

--------------------------------------------------------------------------------------------------------------
--
--------------------------------------------------------------------------------------------------------------

Demonomicon:RegisterEvent('PLAYER_ENTERING_WORLD')
Demonomicon:RegisterForClicks("AnyUp")
Demonomicon:RegisterEvent('ADDON_LOADED')

----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
 
 

WoWInterface » Featured Projects » nUI, MozzFullWorldMap and PartySpotter » Customization » nUI: Developer Chat » Some warlock buttons

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off