public
Description: WoW Addon - Food/water macro generator
Homepage: http://www.tekkub.net
Clone URL: git://github.com/tekkub/buffet.git
Click here to lend your support to: buffet and make a donation at www.pledgie.com !
buffet / Config.lua
100644 49 lines (39 sloc) 1.79 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
local GAP = 8
local tekbutt = LibStub("tekKonfig-Button")
local scan = BUFFET_SCAN
BUFFET_SCAN = nil
 
 
local frame = CreateFrame("Frame", nil, UIParent)
frame.name = "Buffet"
frame:Hide()
frame:SetScript("OnShow", function()
  local title, subtitle = LibStub("tekKonfig-Heading").new(frame, "Buffet", "This panel allows you to quickly create the base macros for Buffet to edit. You only need to do this once unless you delete the macros.")
 
  local function OnClick(self)
    if InCombatLockdown() then ChatFrame1:AddMessage("|cFF33FF99Buffet:|r Cannot create macros in combat.")
    elseif GetNumMacros() >= 18 then ChatFrame1:AddMessage("|cFF33FF99Buffet:|r All global macros in use.")
    else
      CreateMacro(self.name, 1, "", 1)
      scan()
    end
  end
 
  local hpbutt = tekbutt.new(frame, "TOPLEFT", subtitle, "BOTTOMLEFT", -2, -GAP)
  hpbutt:SetText("Create HP")
  hpbutt.tiptext = "Generate a global macro for food, bandages, health potions and health stones."
  hpbutt.name = "AutoHP"
  hpbutt:SetScript("OnClick", OnClick)
 
  local mpbutt = tekbutt.new(frame, "TOPLEFT", hpbutt, "TOPRIGHT", GAP, 0)
  mpbutt:SetText("Create MP")
  mpbutt.tiptext = "Generate a global macro for water, mana potions and mana stones."
  mpbutt.name = "AutoMP"
  mpbutt:SetScript("OnClick", OnClick)
 
  local function Refresh(self)
    if GetMacroIndexByName("AutoHP") == 0 then hpbutt:Enable() else hpbutt:Disable() end
    if GetMacroIndexByName("AutoMP") == 0 then mpbutt:Enable() else mpbutt:Disable() end
    self:RegisterEvent("UPDATE_MACROS")
  end
  frame:SetScript("OnEvent", Refresh)
  frame:SetScript("OnShow", Refresh)
  frame:SetScript("OnHide", function(self) self:UnregisterEvent("UPDATE_MACROS") end)
  Refresh(frame)
end)
 
InterfaceOptions_AddCategory(frame)
 
LibStub("tekKonfig-AboutPanel").new("Buffet", "Buffet")