local CreateButton; do-- Prototype for function
-- Drag Handlers
local function OnDragStart(self) self:GetParent():StartMoving(); end
local function OnDragStop(self) self:GetParent():StopMovingOrSizing(); end
-- Tooltip Handlers
local function OnEnter(self)
if self.Tooltip then
GameTooltip:SetOwner(self,"ANCHOR_TOP");
GameTooltip:AddLine(self.Tooltip,0,1,0.5,1,1,1);
GameTooltip:Show();
end
end
local function OnLeave(self) if GameTooltip:IsOwned(self) then GameTooltip:Hide(); end end
-- Button Generator (this will be assigned to the upvalue noted as a function prototype)
function CreateButton(parent,name,texture,text,tooltip)
tooltip=tooltip or text;-- If no tooltip, use button text
-- Create our button
local btn=CreateFrame("Button",name,parent,"SecureActionButtonTemplate");
btn:SetSize(38,38);
-- Setup button text
btn:SetNormalFontObject("GameFontNormalSmall");
btn:SetHighlightFontObject("GameFontHighlightSmall");
btn:SetDisabledFontObject("GameFontDisableSmall");
btn:SetText(text);
-- Setup button's backgorund, you can use :SetNormalTexture() and other functions to set state-based textures
local tex=btn:CreateTexture(nil,"BACKGROUND");
tex:SetAllPoints(btn);
tex:SetTexture(texture);
btn.Texture=tex;
-- Register handlers
btn:RegisterForClicks("AnyUp");-- Register all buttons
btn:RegisterForDrag("LeftButton");-- Register for left drag
btn:SetScript("OnDragStart",OnDragStart);
btn:SetScript("OnDragStop",OnDragStop);
btn:SetScript("OnEnter",OnEnter);
btn:SetScript("OnLeave",OnLeave);
btn.Tooltip=tooltip;
-- Return our button
return btn;
end
end
local frame = CreateFrame("Frame","ACFrame",UIParent)
frame:SetPoint("CENTER",UIParent)
frame:SetSize(40+40+20,(7*40)+20)
frame:SetBackdrop(StaticPopup1:GetBackdrop())
frame:SetMovable(true)
frame:RegisterForDrag("LeftButton")-- Register left button for dragging
frame:SetScript("OnDragStart",frame.StartMoving)-- Set script for drag start
frame:SetScript("OnDragStop",frame.StopMovingOrSizing)-- Set script for drag stop
local button=CreateButton(frame,"AshranCommanderButton1","Interface\\Icons\\achievement_pvp_a_h",nil,"Warspear Keep");
button:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-10,-8);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Warspear Keep ","SAY")
DoEmote("follow")
end )
local button=CreateButton(frame,"AshranCommanderButton2","Interface\\Icons\\achievement_garrison_tier02_horde",nil,"Emberfall Tower");
button:SetPoint("TOP",AshranCommanderButton1,"BOTTOM",0,-1);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Emberfall Tower ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton3","Interface\\Icons\\achievement_garrison_tier01_horde",nil,"Volrath's Advance");
button:SetPoint("TOP",AshranCommanderButton2,"BOTTOM",0,-1);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Volrath's Advance ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton4","Interface\\Icons\\achievement_doublejeopardy",nil,"The Crossroads");
button:SetPoint("TOP",AshranCommanderButton3,"BOTTOM",0,-1);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("The Crossroads ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton5","Interface\\Icons\\achievement_garrison_tier01_alliance",nil,"Tremblade's Vanguard");
button:SetPoint("TOP",AshranCommanderButton4,"BOTTOM",0,-1);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Tremblade's Vanguard ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton6","Interface\\Icons\\achievement_garrison_tier02_alliance",nil,"Archmage Overwatch");
button:SetPoint("TOP",AshranCommanderButton5,"BOTTOM",0,-1);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Archmage Overwatch ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton7","Interface\\Icons\\achievement_pvp_h_a",nil,"Stormshield Stronghold");
button:SetPoint("TOP",AshranCommanderButton6,"BOTTOM",0,-1);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Stormshield Stronghold ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton8","Interface\\Icons\\Ability_rogue_sprint",nil,"Amphitheater of Annihilation(AoA)");
button:SetPoint("RIGHT",AshranCommanderButton1,"LEFT",0,0);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("AoA - EVENT:STADIUM RACING - Block the entrance!","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton9","Interface\\Icons\\spell_fire_fire",nil,"Brute's Rise(BR)");
button:SetPoint("RIGHT",AshranCommanderButton2,"LEFT",0,0);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("BR - EVENT:OGRE FIRES - Block the stairs! ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton10","Interface\\Icons\\achievement_boss_furyfurnace",nil,"Ring of Conquest(RoC)");
button:SetPoint("RIGHT",AshranCommanderButton3,"LEFT",0,0);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Ring of Conquest GO RoC ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton11","Interface\\Icons\\Trade_archaeology_apexisstatue",nil,"Ashran Excavation(Mines)");
button:SetPoint("RIGHT",AshranCommanderButton4,"LEFT",0,0);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Ashran Excavation - EVENT:APEXIS MARKS - Secure the center! ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton12","Interface\\Icons\\achievement_reputation_ogre",nil,"Seat of Kor'lok");
button:SetPoint("RIGHT",AshranCommanderButton5,"LEFT",0,0);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Seat of Kor'lok - Kor'lok - Kill the ogre! ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton13","Interface\\Icons\\Spell_lifegivingspeed",nil,"Molten Quarry(MQ)");
button:SetPoint("RIGHT",AshranCommanderButton6,"LEFT",0,0);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Molten Quarry - EVENT:Empowered Ore - Block the entrance! ","SAY")
DoEmote("follow" , UnitName("target"))
end )
local button=CreateButton(frame,"AshranCommanderButton14","Interface\\Icons\\Achievement_halloween_ghost_01",nil,"Ashmaul Burial Grounds(ABG)");
button:SetPoint("RIGHT",AshranCommanderButton7,"LEFT",0,0);-- Anchors always default to an object's parent
button:SetScript("OnClick", function()
SendChatMessage("Ashmaul Burial Grounds - EVENT:RISEN SPIRITS - Clear the center and block the entrance! ","SAY")
DoEmote("follow" , UnitName("target"))
end )