-- local function print(msg) ChatFrame1:AddMessage(msg); end |
|
BINDING_HEADER_DEMONOMICON_PETHEADER = 'Demonomicon' |
_G["BINDING_NAME_CLICK PetFrame:LeftButton"] = '"Click" Pet Button' |
_G["BINDING_NAME_CLICK PetFrame:RightButton"] = '"Right-Click" Pet Button' |
_G["BINDING_NAME_CLICK DemonomiconMenuButton:LeftButton"] = 'Open Demon Menu' |
_G["BINDING_NAME_CLICK DemonomiconMenuButton:RightButton"] = 'Open Demon Menu for Fast Summon' |
|
local Demonomicon = CreateFrame("Button", "Demonomicon", UIParent, "DemonomiconStyleTemplate SecureHandlerClickTemplate") |
Demonomicon:SetPoint("TOPLEFT", PlayerFrame, "BOTTOMLEFT", 52, 12) |
Demonomicon.Icon = DemonomiconIcon |
Demonomicon.Icon:SetTexture( [[Interface\Icons\INV_Misc_Book_06]] ) |
Demonomicon:SetHeight(24); Demonomicon:SetWidth(24) |
|
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[ [[Interface\Icons\Spell_Nature_RemoveCurse]] ] = |
"FastCast" |
Demonomicon[ [[Interface\Icons\Spell_Shadow_LifeDrain]] ] = |
"HealPet" |
Demonomicon[ [[Interface\Icons\Spell_Shadow_AntiShadow]] ] = |
{pet="Blueberry", spell="HealTank" } |
Demonomicon[ [[Interface\Icons\Spell_Shadow_SacrificialShield]] ] = |
{pet="Blueberry", spell="PopBlueberry" } |
Demonomicon[ [[Interface\Icons\Spell_Nature_Purge]] ] = |
{pet="Puppy", spell="EatMagic" } |
Demonomicon[ [[Interface\Icons\Ability_Rogue_Sprint]] ] = |
{pet="Bruiser", spell="ChaseDown"} |
Demonomicon[ [[Interface\Icons\Spell_Shadow_MindSteal]] ] = |
{pet="Temptress", spell="Charm"} |
Demonomicon[ [[Interface\Icons\Spell_Shadow_MindRot]] ] = |
{pet="Puppy", spell="Silence"} |
|
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["_childupdate-Close"] = [[ |
--self:ClearBindings() |
self:Hide() |
]] |
Demonomicon["_childupdate-LeftButton"] = [[ |
--self:SetBindingClick(true, tostring(self:GetID()), self:GetName(), "LeftButton") |
local localeBinding = tostring(self:GetAttribute('binding')) |
if localeBinding then |
--self:SetBindingClick(true, localeBinding, self:GetName(), "LeftButton") |
end |
self:SetAttribute('type', 'spell') |
self:Show() |
]] |
Demonomicon["_childupdate-RightButton"] = [[ |
--self:SetBindingClick(true, tostring(self:GetID()), self:GetName(), "LeftButton") |
local localeBinding = tostring(self:GetAttribute('binding')) |
if localeBinding then |
--self:SetBindingClick(true, localeBinding, self:GetName(), "LeftButton") |
end |
if self:GetAttribute('*type2') then |
self:SetAttribute('type', 'macro') |
end |
self:Show() |
]] |
Demonomicon["_childclick"] = [[open = nil; return nil, true]] |
|
function Demonomicon:SetUpButtons(event, ...) |
if InCombatLockdown() then |
self:RegisterEvent("PLAYER_REGEN_ENABLED") |
else |
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 |
|
if Spells.HealPet then |
PetFrame:SetAttribute('alt-type1', 'spell') |
PetFrame:SetAttribute('spell', Spells.HealPet) |
end |
|
local state2, type2 |
if Spells.FastCast then |
state2, type2 = "^rightclick", 'macro' |
end |
|
local numButtons = 0 |
for _,summonKey in pairs(Placement.order) do |
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 = _G.CreateFrame('BUTTON', newName, self, "DemonomiconStyleTemplate SecureActionButtonTemplate") |
summonButton.Icon = _G[newName.."Icon"] |
summonButton:SetAttribute("_childupdate-Close", self["_childupdate-Close"]) |
summonButton:SetAttribute("_childupdate-LeftButton", self["_childupdate-LeftButton"]) |
summonButton:SetAttribute("_childupdate-RightButton", self["_childupdate-RightButton"]) |
summonButton:SetAttribute("_childclick", self["_childclick"]) |
Buttons[numButtons] = summonButton |
self:SetAttribute("_adopt", summonButton) |
end |
summonButton:SetID(numButtons) |
summonButton.Icon:SetTexture(summonKey) |
summonButton:SetAttribute("binding", Locale.Bindings) |
summonButton:SetAttribute('spell', summon) |
summonButton:SetAttribute('macrotext', '/cast '..(Locale.Spells.FastCast or "").."\n/stopcasting\n/cast "..summon) |
summonButton:SetAttribute('*type2', type2) |
end |
end |
for index=numButtons+1,5 do |
local extraButton = Buttons[index] |
if extraButton then |
extraButton:SetID(0) |
extraButton:SetAttribute('*type2', type2) |
extraButton:SetAttribute('binding', nil) |
extraButton:Hide() |
end |
end |
|
if numButtons > 1 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 |
elseif numButtons == 1 then |
local oneButton = Buttons[1] |
oneButton:SetPoint("CENTER", self, "CENTER") |
oneButton:SetAttribute('hidestates', nil) |
oneButton:Show() |
end |
self:UnregisterEvent("PLAYER_REGEN_ENABLED") |
end |
end |
|
function Demonomicon:SetUpPetFrame(event, ...) |
local Locale = self.Locale |
Locale.Pets = Locale.Pets or {} |
local spellCount = HasPetSpells() |
if spellCount and spellCount > 0 then |
for index=1,spellCount do |
soughtSpell = self[GetSpellTexture(index, BOOKTYPE_PET)] |
if soughtSpell and type(soughtSpell) == 'table' then |
Locale.Pets[soughtSpell.pet] = (UnitCreatureFamily("pet") or ""):lower() |
Locale[soughtSpell.spell] = GetSpellName(index, BOOKTYPE_PET) |
end |
end |
if InCombatLockdown() then |
self:RegisterEvent("PLAYER_REGEN_ENABLED") |
else |
Locale.Macros = Locale.Macros or {} |
local shiftMacro = {Populate = table.insert} |
if Locale.PopBlueberry then |
shiftMacro:Populate("[pet:"..Locale.Pets.Blueberry..",button:2] "..Locale.PopBlueberry) |
end |
if Locale.HealTank then |
shiftMacro:Populate("[pet:"..Locale.Pets.Blueberry.."] "..Locale.HealTank) |
end |
if Locale.EatMagic then |
shiftMacro:Populate("[pet:"..Locale.Pets.Puppy..",button:2,target=mouseover][pet:"..Locale.Pets.Puppy.."] "..locale.EatMagic) |
end |
if Locale.ChaseDown then |
shiftMacro:Populate("[pet:"..Locale.Pets.Bruiser.."] "..Locale.ChaseDown) |
end |
shiftMacro.Populate = nil |
if next(shiftMacro) then |
Locale.Macros.shift = "/cast "..table.concat(shiftMacro, "; ") |
end |
local controlMacro = {Populate = table.insert} |
if Locale.Charm then |
controlMacro:Populate("[pet:"..Locale.Pets.Temptress..",button:2,target=focus][pet:"..Locale.Pets.Temptress.."] "..Locale.Charm) |
end |
if Locale.Silence then |
controlMacro:Populate("[pet:"..Locale.Pets.Puppy..",button:2,target=focus][pet:"..Locale.Pets.Puppy.."] "..Locale.Silence) |
end |
controlMacro.Populate = nil |
if next(controlMacro) then |
Locale.Macros.ctrl = "/cast "..table.concat(controlMacro, "; ") |
end |
end |
end |
local actionType = Locale.Macros.shift and 'macro' |
PetFrame:SetAttribute('shift-type1', actionType) |
PetFrame:SetAttribute('shift-type2', Locale.Macros.shift and 'macro') |
PetFrame:SetAttribute('shift-macrotext*', Locale.Macros.shift) |
PetFrame:SetAttribute('ctrl-type1', Locale.Macros.ctrl and 'macro') |
PetFrame:SetAttribute('ctrl-type2', Locale.Macros.ctrl and 'macro') |
PetFrame:SetAttribute('ctrl-macrotext*', Locale.Macros.ctrl) |
if Locale.PopBlueberry and Locale.HealTank and Locale.ChaseDown and Locale.EatMagic and Locale.Silence and Locale.Charm then |
SetUpPetFrame = nil |
self:UnregisterEvent('UNIT_MODEL_CHANGED') |
end |
self:UnregisterEvent("PLAYER_REGEN_ENABLED") |
end |
PetFrame:SetAttribute("alt-type2", "assist") |
|
Demonomicon:SetAttribute("_onupdate", [[ |
if open then |
if self:IsUnderMouse(true) then |
open = 0 |
return nil, true |
end |
open = open + elapsed |
if open <= 2.5 then |
return nil, true |
else |
open = nil |
end |
end |
--self:ClearBindings() |
open = nil |
return "Close"]] |
) |
Demonomicon:SetAttribute("_onclick", [[ |
if open then |
--self:ClearBindings() |
open = nil |
return "Close" |
else |
--self:SetBindingClick(true, "ESCAPE", "Demonomicon", "LeftButton") |
open = 0 |
return button, true |
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 ({ |
["frFR"] = { |
Bindings = { |
[ Textures.Imp ] = "D", |
[ Textures.Voidwalker ] = "M", |
[ Textures.Succubus ] = "S", |
[ Textures.Felhunter ] = "C", |
[ Textures.Felguard ] = "G" |
} |
}, |
["deDE"] = { |
Bindings = { |
[ Textures.Imp ] = "W", |
[ Textures.Voidwalker ] = "L", |
[ Textures.Succubus ] = "S", |
[ Textures.Felhunter ] = "J", |
[ Textures.Felguard ] = "T" |
} |
}, |
["enUS"] = { |
Bindings = { |
[ Textures.Imp ] = "I", |
[ Textures.Voidwalker ] = "V", |
[ Textures.Succubus ] = "S", |
[ Textures.Felhunter ] = "F", |
[ Textures.Felguard ] = "G" |
} |
}, |
["enGB"] = { |
Bindings = { |
[ Textures.Imp ] = "I", |
[ Textures.Voidwalker ] = "V", |
[ Textures.Succubus ] = "S", |
[ Textures.Felhunter ] = "F", |
[ Textures.Felguard ] = "G" |
} |
} |
})[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, ...) |
if self.SetUpPetFrame and event ~= 'SPELLS_CHANGED' and (event ~= 'UNIT_MODEL_CHANGED' or (...) == 'pet') then |
self:SetUpPetFrame(event, ...) |
end |
end |
) |
self:UnregisterAllEvents() |
self:RegisterEvent('SPELLS_CHANGED') |
end |
) |
Demonomicon:RegisterEvent('ADDON_LOADED') |
|
Demonomicon:SetScript("OnShow", |
function (self) |
if self.SetUpPetFrame then |
self:RegisterEvent('UNIT_MODEL_CHANGED') |
end |
end |
) |
|
Demonomicon:SetScript("OnHide", |
function (self) |
self:UnregisterEvent('UNIT_MODEL_CHANGED') |
end |
) |
|
Demonomicon:SetScript("OnDragStart", Demonomicon.StartMoving) |
Demonomicon:SetScript("OnDragStop", Demonomicon.StopMovingOrSizing) |
Demonomicon:RegisterForDrag("LeftButton") |