Thread Tools Display Modes
Prev Previous Post   Next Post Next
06-28-09, 11:55 AM   #1
Rhamses
A Theradrim Guardian
Join Date: Jun 2009
Posts: 61
Help the Noob 8 )

On Curse there is an addon that I like very much. Demonicon.

http://wow.curse.com/downloads/wow-a...ject-4469.aspx

What I like the best is that when the inital button is clicked, it "flowers" several new buttons around the original. I have pulled most of the junk away from it, leaving the core. But, the author was smart enough to have it look to the spell books. Trying to parse that out has left me pulling my hair out over the last several days. I was wondering if someone could look at the code and maybe change it so the spells are in a table (I have them all so there is no reason to lookup). I could then use the back bone to build others.

There are two files for Luna. One Servitas that has some of the button management and Demonicon that seems to load the button. If they could be combined into one lua that would be cool.

If you got a lot of time to kill, I would love the help. I do not know why everyone use the long single bar for "child" buttons. I think the circular array is much more convenient. Maybe this will initiate a rebirth of its use.

Trimed down Demonicon:
BINDING_HEADER_DEMONOMICON_PETHEADER = 'Demonomicon'


if select(2, UnitClass('player')) ~= 'WARLOCK' then return; end
if not Servitas then
local oldHandler = geterrorhandler()
seterrorhandler(
function (...)
print(...)
seterrorhandler(oldHandler)
end
)
error("Servitas did not load. Demonomicon will not be available")
end

local Demonomicon = Servitas:StyleButton(CreateFrame("Button", "Demonomicon", UIParent, "SecureHandlerClickTemplate"))
Servitas.Demonomicon = Demonomicon
SecureHandler_OnLoad(Demonomicon)
Demonomicon:SetPoint("TOPLEFT", PlayerFrame, "BOTTOMLEFT", 52, 12)
Demonomicon.Icon:SetTexture[[Interface\Icons\INV_Misc_Book_06]]
Demonomicon:SetHeight(24); Demonomicon:SetWidth(24)
Demonomicon:SetMovable()

Demonomicon.Buttons = {}
Demonomicon.SummonTab = [[Interface\Icons\Spell_Shadow_Metamorphosis]]
Demonomicon.Textures = {
Imp = [[Interface\Icons\Spell_Shadow_SummonImp]],
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.Voidwalker ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Succubus ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Felhunter ] = 'Summon'
Demonomicon[ Demonomicon.Textures.Felguard ] = 'Summon'

Demonomicon.Menu = CreateFrame("Frame", Demonomicon:GetName().."Menu", Demonomicon, "SecureHandlerShowHideTemplate")
Demonomicon.Menu:Hide()
Demonomicon:SetFrameRef("menu", Demonomicon.Menu)
Demonomicon.Menu:SetPoint("CENTER", Demonomicon)
Demonomicon.Menu:SetAttribute("_onshow", [[
if buttons then
for i, b in ipairs(buttons) do
if self:GetAttribute("open"):match("^Right.*") and b:GetAttribute('*type2') then
b:SetAttribute('type', 'macro');
else
b:SetAttribute('type', 'spell');
end
self:SetBindingClick(true, tostring(b:GetID()), b:GetName(), "LeftButton")
local localeBinding = b:GetAttribute('binding')
if localeBinding then
self:SetBindingClick(true, tostring(localeBinding), b:GetName(), "LeftButton")
end
end
end ]]
)
Demonomicon.Menu:SetAttribute("_onhide", [[
open = nil;
self:UnregisterAutoHide();
self:ClearBindings(); ]]
)
Demonomicon:Execute[[menu = self:GetFrameRef("menu")]]

function Demonomicon:SetUpButtons(event, ...)
if InCombatLockdown() then
self:RegisterEvent("PLAYER_REGEN_ENABLED"); return
end

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



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('spell', summon)
end
end
for index=numButtons+1,5 do
local extraButton = Buttons[index]
if extraButton then
extraButton:SetID(0)
extraButton:Hide()
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
]]
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)

self:UnregisterEvent("PLAYER_REGEN_ENABLED")
self:UnregisterEvent('PLAYER_ENTERING_WORLD')
end


Demonomicon:SetAttribute("_onclick", [[
if menu:IsShown() then
menu:Hide()
else
menu:SetAttribute("open", button)
menu:Show()
menu:SetBindingClick(true, "ESCAPE", "Demonomicon", "LeftButton")
if button:match("Button$") then
menu:RegisterAutoHide(1.5)
end
end]]
)
Demonomicon:RegisterForClicks("AnyUp")

Demonomicon:SetScript("OnEvent",
function (self, event, ...)
local Textures = self.Textures
if event ~= "ADDON_LOADED" or (...) ~= "Demonomicon" then return; end
local currentLocale = GetLocale()
Demonomicon_Locale = Demonomicon_Locale or {}
Demonomicon_Locale[currentLocale] = Demonomicon_Locale[currentLocale] or ({})[currentLocale] or {}
self.Locale = Demonomicon_Locale[currentLocale]
Demonomicon_Placement = Demonomicon_Placement or {
startAngle = math.pi,
endAngle = 3 * math.pi,
order = {
Textures.Imp,
Textures.Voidwalker,
Textures.Succubus,
Textures.Felhunter,
Textures.Felguard
}
}
self.Placement = Demonomicon_Placement
self:SetScript('OnEvent',
function (self, event, ...)
self:SetUpButtons(event, ...) end )
self:UnregisterAllEvents()
self:RegisterEvent('SPELLS_CHANGED')
self:RegisterEvent('PLAYER_ENTERING_WORLD')
end
)


Demonomicon:RegisterEvent('ADDON_LOADED')
Demonomicon:SetScript("OnShow", function (self) end)
Demonomicon:SetScript("OnHide", function (self) end)
Demonomicon:SetScript("OnDragStart", Demonomicon.StartMoving)
Demonomicon:SetScript("OnDragStop", Demonomicon.StopMovingOrSizing)
Demonomicon:RegisterForDrag("LeftButton")
--------------------------------------------


Serivas

local CurrentVersion = 0.8

if select(2, UnitClass('player')) ~= 'WARLOCK' or (Servitas and Servitas.version >= CurrentVersion) then return; end

Servitas = Servitas or {version = CurrentVersion}

function Servitas.PreClick(self, button, down)
PlaySound("igMainMenuOptionCheckBoxOn")
end

function Servitas:StyleButton(button)
button:SetHeight(24); button:SetWidth(24)

local border = button:CreateTexture(nil, "OVERLAY"); button.Border = border
border:SetHeight(40); border:SetWidth(40)
border:ClearAllPoints(); border:SetPoint("CENTER", button, 2, -2)
border:SetTexture[[Interface\Minimap\MiniMap-TrackingBorder]]
border:SetTexCoord(0.0, 0.625, 0.0, 0.625)

local icon = button:CreateTexture(nil, "BACKGROUND"); button.Icon = icon
icon:SetAllPoints(button)
icon:SetTexture[[Interface\Icons\Spell_Shadow_Metamorphosis]]

button:SetScript("PreClick", self.PreClick)

return button
end
 
 

WoWInterface » Featured Projects » nUI, MozzFullWorldMap and PartySpotter » Customization » nUI: Developer Chat » Help the Noob 8 )


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