View Single Post
02-12-16, 02:59 PM   #11
tyroneexe
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Feb 2016
Posts: 13
Thank you guys/girls so much. It's working now and with the cleanup SDPhantom gave it, !buggrabber (ty FizzleMizz) stopped complaining.

EDIT: I should specify what is working. The buttons are now movable and with them the frame. I also changed the first button to align to the frames TOPRIGHT instead
Lua Code:
  1. local button=CreateButton(frame,"AshranCommanderButton1","Interface\\Icons\\achievement_pvp_a_h",nil,"Warspear Keep");
  2. button:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-10,-8);-- Anchors always default to an object's parent
  3. button:SetScript("OnClick", function()
  4.          SendChatMessage("Warspear Keep ","SAY")
  5.          DoEmote("follow")
  6.     end )

Looking at it, I'm thinking if there's a better way to size the frame based on the button size or vice-versa.

Mess with
Lua Code:
  1. frame:SetSize(40+40+20,(7*40)+20)
Or
Lua Code:
  1. btn:SetSize(38,38);


Tried changing "40+40" to SecureActionButtonTemplate, hoping it would act similar to

Lua Code:
  1. frame:SetHeight((#CLASS_SORT_ORDER*40)+20) --NOT FROM THIS LUA

but no, that was not the way

Current complete Lua
Lua Code:
  1. local CreateButton; do-- Prototype for function
  2.     --  Drag Handlers
  3.     local function OnDragStart(self) self:GetParent():StartMoving(); end
  4.     local function OnDragStop(self) self:GetParent():StopMovingOrSizing(); end
  5.  
  6.     --  Tooltip Handlers
  7.     local function OnEnter(self)
  8.         if self.Tooltip then
  9.             GameTooltip:SetOwner(self,"ANCHOR_TOP");
  10.             GameTooltip:AddLine(self.Tooltip,0,1,0.5,1,1,1);
  11.             GameTooltip:Show();
  12.         end
  13.     end
  14.     local function OnLeave(self) if GameTooltip:IsOwned(self) then GameTooltip:Hide(); end end
  15.  
  16.     --  Button Generator (this will be assigned to the upvalue noted as a function prototype)
  17.     function CreateButton(parent,name,texture,text,tooltip)
  18.         tooltip=tooltip or text;--  If no tooltip, use button text
  19.  
  20.         --      Create our button
  21.         local btn=CreateFrame("Button",name,parent,"SecureActionButtonTemplate");
  22.         btn:SetSize(38,38);
  23.  
  24.         --      Setup button text
  25.         btn:SetNormalFontObject("GameFontNormalSmall");
  26.         btn:SetHighlightFontObject("GameFontHighlightSmall");
  27.         btn:SetDisabledFontObject("GameFontDisableSmall");
  28.         btn:SetText(text);
  29.  
  30.         --      Setup button's backgorund, you can use :SetNormalTexture() and other functions to set state-based textures
  31.         local tex=btn:CreateTexture(nil,"BACKGROUND");
  32.         tex:SetAllPoints(btn);
  33.         tex:SetTexture(texture);
  34.         btn.Texture=tex;
  35.  
  36.         --      Register handlers
  37.         btn:RegisterForClicks("AnyUp");--   Register all buttons
  38.         btn:RegisterForDrag("LeftButton");--    Register for left drag
  39.         btn:SetScript("OnDragStart",OnDragStart);
  40.         btn:SetScript("OnDragStop",OnDragStop);
  41.         btn:SetScript("OnEnter",OnEnter);
  42.         btn:SetScript("OnLeave",OnLeave);
  43.         btn.Tooltip=tooltip;
  44.  
  45.         --      Return our button
  46.         return btn;
  47.     end
  48. end
  49.  
  50. local frame = CreateFrame("Frame","ACFrame",UIParent)
  51. frame:SetPoint("CENTER",UIParent)
  52. frame:SetSize(40+40+20,(7*40)+20)
  53. frame:SetBackdrop(StaticPopup1:GetBackdrop())
  54.  
  55. frame:SetMovable(true)
  56. frame:RegisterForDrag("LeftButton")--   Register left button for dragging
  57. frame:SetScript("OnDragStart",frame.StartMoving)--  Set script for drag start
  58. frame:SetScript("OnDragStop",frame.StopMovingOrSizing)--    Set script for drag stop
  59.  
  60. local button=CreateButton(frame,"AshranCommanderButton1","Interface\\Icons\\achievement_pvp_a_h",nil,"Warspear Keep");
  61. button:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-10,-8);-- Anchors always default to an object's parent
  62. button:SetScript("OnClick", function()
  63.          SendChatMessage("Warspear Keep ","SAY")
  64.          DoEmote("follow")
  65.     end )
  66. local button=CreateButton(frame,"AshranCommanderButton2","Interface\\Icons\\achievement_garrison_tier02_horde",nil,"Emberfall Tower");
  67. button:SetPoint("TOP",AshranCommanderButton1,"BOTTOM",0,-1);-- Anchors always default to an object's parent
  68. button:SetScript("OnClick", function()
  69.          SendChatMessage("Emberfall Tower ","SAY")
  70.          DoEmote("follow" , UnitName("target"))
  71.     end )
  72. local button=CreateButton(frame,"AshranCommanderButton3","Interface\\Icons\\achievement_garrison_tier01_horde",nil,"Volrath's Advance");
  73. button:SetPoint("TOP",AshranCommanderButton2,"BOTTOM",0,-1);-- Anchors always default to an object's parent
  74. button:SetScript("OnClick", function()
  75.          SendChatMessage("Volrath's Advance ","SAY")
  76.          DoEmote("follow" , UnitName("target"))
  77.     end )
  78. local button=CreateButton(frame,"AshranCommanderButton4","Interface\\Icons\\achievement_doublejeopardy",nil,"The Crossroads");
  79. button:SetPoint("TOP",AshranCommanderButton3,"BOTTOM",0,-1);-- Anchors always default to an object's parent
  80. button:SetScript("OnClick", function()
  81.          SendChatMessage("The Crossroads ","SAY")
  82.          DoEmote("follow" , UnitName("target"))
  83.     end )
  84. local button=CreateButton(frame,"AshranCommanderButton5","Interface\\Icons\\achievement_garrison_tier01_alliance",nil,"Tremblade's Vanguard");
  85. button:SetPoint("TOP",AshranCommanderButton4,"BOTTOM",0,-1);-- Anchors always default to an object's parent
  86. button:SetScript("OnClick", function()
  87.          SendChatMessage("Tremblade's Vanguard ","SAY")
  88.          DoEmote("follow" , UnitName("target"))
  89.     end )
  90. local button=CreateButton(frame,"AshranCommanderButton6","Interface\\Icons\\achievement_garrison_tier02_alliance",nil,"Archmage Overwatch");
  91. button:SetPoint("TOP",AshranCommanderButton5,"BOTTOM",0,-1);-- Anchors always default to an object's parent
  92. button:SetScript("OnClick", function()
  93.          SendChatMessage("Archmage Overwatch ","SAY")
  94.          DoEmote("follow" , UnitName("target"))
  95.     end )
  96. local button=CreateButton(frame,"AshranCommanderButton7","Interface\\Icons\\achievement_pvp_h_a",nil,"Stormshield Stronghold");
  97. button:SetPoint("TOP",AshranCommanderButton6,"BOTTOM",0,-1);-- Anchors always default to an object's parent
  98. button:SetScript("OnClick", function()
  99.          SendChatMessage("Stormshield Stronghold ","SAY")
  100.          DoEmote("follow" , UnitName("target"))
  101.     end )
  102. local button=CreateButton(frame,"AshranCommanderButton8","Interface\\Icons\\Ability_rogue_sprint",nil,"Amphitheater of Annihilation(AoA)");
  103. button:SetPoint("RIGHT",AshranCommanderButton1,"LEFT",0,0);-- Anchors always default to an object's parent
  104. button:SetScript("OnClick", function()
  105.          SendChatMessage("AoA - EVENT:STADIUM RACING - Block the entrance!","SAY")
  106.          DoEmote("follow" , UnitName("target"))
  107.     end )
  108. local button=CreateButton(frame,"AshranCommanderButton9","Interface\\Icons\\spell_fire_fire",nil,"Brute's Rise(BR)");
  109. button:SetPoint("RIGHT",AshranCommanderButton2,"LEFT",0,0);-- Anchors always default to an object's parent
  110. button:SetScript("OnClick", function()
  111.          SendChatMessage("BR - EVENT:OGRE FIRES - Block the stairs! ","SAY")
  112.          DoEmote("follow" , UnitName("target"))
  113.     end )
  114. local button=CreateButton(frame,"AshranCommanderButton10","Interface\\Icons\\achievement_boss_furyfurnace",nil,"Ring of Conquest(RoC)");
  115. button:SetPoint("RIGHT",AshranCommanderButton3,"LEFT",0,0);-- Anchors always default to an object's parent
  116. button:SetScript("OnClick", function()
  117.          SendChatMessage("Ring of Conquest GO RoC ","SAY")
  118.          DoEmote("follow" , UnitName("target"))
  119.     end )
  120. local button=CreateButton(frame,"AshranCommanderButton11","Interface\\Icons\\Trade_archaeology_apexisstatue",nil,"Ashran Excavation(Mines)");
  121. button:SetPoint("RIGHT",AshranCommanderButton4,"LEFT",0,0);-- Anchors always default to an object's parent
  122. button:SetScript("OnClick", function()
  123.          SendChatMessage("Ashran Excavation - EVENT:APEXIS MARKS - Secure the center!  ","SAY")
  124.          DoEmote("follow" , UnitName("target"))
  125.     end )
  126. local button=CreateButton(frame,"AshranCommanderButton12","Interface\\Icons\\achievement_reputation_ogre",nil,"Seat of Kor'lok");
  127. button:SetPoint("RIGHT",AshranCommanderButton5,"LEFT",0,0);-- Anchors always default to an object's parent
  128. button:SetScript("OnClick", function()
  129.          SendChatMessage("Seat of Kor'lok - Kor'lok - Kill the ogre!  ","SAY")
  130.          DoEmote("follow" , UnitName("target"))
  131.     end )
  132. local button=CreateButton(frame,"AshranCommanderButton13","Interface\\Icons\\Spell_lifegivingspeed",nil,"Molten Quarry(MQ)");
  133. button:SetPoint("RIGHT",AshranCommanderButton6,"LEFT",0,0);-- Anchors always default to an object's parent
  134. button:SetScript("OnClick", function()
  135.          SendChatMessage("Molten Quarry - EVENT:Empowered Ore - Block the entrance!  ","SAY")
  136.          DoEmote("follow" , UnitName("target"))
  137.     end )
  138. local button=CreateButton(frame,"AshranCommanderButton14","Interface\\Icons\\Achievement_halloween_ghost_01",nil,"Ashmaul Burial Grounds(ABG)");
  139. button:SetPoint("RIGHT",AshranCommanderButton7,"LEFT",0,0);-- Anchors always default to an object's parent
  140. button:SetScript("OnClick", function()
  141.          SendChatMessage("Ashmaul Burial Grounds - EVENT:RISEN SPIRITS - Clear the center and block the entrance!  ","SAY")
  142.          DoEmote("follow" , UnitName("target"))
  143.     end )

Last edited by tyroneexe : 02-12-16 at 03:10 PM. Reason: specify what's working
  Reply With Quote