Thread Tools Display Modes
Unread 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
Rhamses is offline  
Unread 06-28-09, 01:04 PM   #2
spiel2001
nUI's Author
 
spiel2001's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 7,724
Why would you want to use a table instead of the spell book? Using the spell book means it always works with the player's spells. Tables always end up broken as soon as Bliz changes anything at all and don't work across multiple languages.
__________________

What people don't get is that I am, ultimately, an artist at heart.
My brush has two colors, 1 and 0, and my canvas is made of silicon.



Official nUI Web Site: http://www.nUIaddon.com
Official nUI Support Forum: http://forums.nUIaddon.com
My day job: http://www.presidio.com/
spiel2001 is offline  
Unread 06-28-09, 02:04 PM   #3
Rhamses
A Theradrim Guardian
Join Date: Jun 2009
Posts: 61
well, it does not pull up Inferno or Doomguard. My knowledge of the syntax is not strongh enough to parse the logic that looks at the spellbook. I can not emmulate what was done to create other buttons like it. I lke the "child" buttons, but Necrosis, Lunar and other mod put them out in a long line.
Rhamses is offline  
Unread 06-30-09, 05:32 PM   #4
Rhamses
A Theradrim Guardian
Join Date: Jun 2009
Posts: 61
I spent a few more hours trying to figure this out. I now think that is impossible to figure out without more of the "guts" of the game. This Addon seems to look in the warlock spell book and identifies textures rather than the names of the spells. As the button textures are recycled what they represent is context dependent.

Does anyone know of a list where the texture is shown along with its root location/name?

to wit

Demonomicon.SummonTab = [[Interface\Icons\Spell_Shadow_Metamorphosis]]

this does not mean the warlock spell metamorphosis, it must mean the icon, which is used on the warlocks "demon" tab.


rhamses
Rhamses is offline  
Unread 06-30-09, 05:43 PM   #5
Xrystal
nUI User and Supporter
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,030
There is a function called ( if I remember rightly ) GetSpellInfo. One of the items returned is the path to the spells texture icon. There is also I think GetSpellIcon or something similarly named just to get the texture. One I think is taken from the book and another is from the spellID or spellName itself.

Edit: Ah nope it was GetSpellTexture. Here are the two links to those functions on the wowwiki interface pages.

http://www.wowwiki.com/API_GetSpellTexture
http://www.wowwiki.com/API_GetSpellInfo

I use GetSpellInfo in my addons and can validate the existence in the spellbook by testing it against the SpellLink instead of the SpellID. The former will fail if you don't know the spell yet and the latter will give you the information. It is how I got the portal/teleport spells to display even if you had never learnt them yet.

This page has an example of reading through the spellbook to grab the spell information available there :

http://www.wowwiki.com/API_GetSpellName

But, as to a list nope, you would probably have to trawl through the wowhead database for that information and even then it may not tell you the texture path.
__________________

Last edited by Xrystal : 06-30-09 at 05:49 PM.
Xrystal is offline  
Unread 06-30-09, 05:53 PM   #6
Rhamses
A Theradrim Guardian
Join Date: Jun 2009
Posts: 61
thanks for the tip. I will look into it. If I was really motivated, I would make a relationship database that would allow the user to view the icons as if presented in the macro design

rhamses
Rhamses is offline  
Unread 07-01-09, 06:37 AM   #7
spiel2001
nUI's Author
 
spiel2001's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 7,724
Yeah -- there's no built in table for such information... you would have to create one and maintain it every time there's a new patch -- something I have been aggressively avoiding because that's exactly the kind of stuff that causes mods to break and get abandoned over time.

The best solution is a programmatic one such as what Xrystal has provided you.
__________________

What people don't get is that I am, ultimately, an artist at heart.
My brush has two colors, 1 and 0, and my canvas is made of silicon.



Official nUI Web Site: http://www.nUIaddon.com
Official nUI Support Forum: http://forums.nUIaddon.com
My day job: http://www.presidio.com/
spiel2001 is offline  
Unread 07-01-09, 08:58 AM   #8
Rhamses
A Theradrim Guardian
Join Date: Jun 2009
Posts: 61
Good Point. I will do my best to implement it. I am a "tinker". I know what an item is supposed to do (in this case the addon) and take it apart to figure out how it was done. Now with your help, I sorta understand it. I will probably go back and try and parse some of the more complicated aspects of the addon.

Rhamses
Rhamses is offline  
 

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

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