public
Description: WoW Addon - Crowd control assistance
Homepage: http://www.tekkub.net
Clone URL: git://github.com/tekkub/controlfreak.git
Click here to lend your support to: controlfreak and make a donation at www.pledgie.com !
controlfreak / ConfigMacro.lua
100644 97 lines (74 sloc) 3.976 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

if not ControlFreak then return end
 
 
----------------------------
-- Localization --
----------------------------
 
local L = CONTROLFREAK_LOCALE
CONTROLFREAK_LOCALE = nil
 
 
----------------------
-- Locals --
----------------------
 
local ww = LibStub("WidgetWarlock-Alpha1")
local GAP, EDGEGAP = 8, 16
 
 
---------------------
-- Panel --
---------------------
 
local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
frame.parent = "Control Freak"
frame.name = "Macro"
frame:Hide()
frame:SetScript("OnShow", function(frame)
  local ControlFreak = ControlFreak
  local title, subtitle = LibStub("tekKonfig-Heading").new(frame, "Control Freak - Macro", "These controls let you customize the macro, creature types it applies to, and the debuffs to watch.")
 
 
  local checkgrouplabel = ww:SummonFontString(frame, "OVERLAY", "GameFontHighlightSmall", "Creature Types", "TOPLEFT", subtitle, "BOTTOMLEFT", -2 + EDGEGAP, -GAP)
  local checkgroup = ww:SummonGroupBox(frame, 305, 102, "TOPLEFT", checkgrouplabel, "BOTTOMLEFT", -EDGEGAP, 0)
  checkgroup:SetPoint("RIGHT", frame, "RIGHT", -EDGEGAP, 0)
 
 
  local a1, af, a2, dx, dy = "TOPLEFT", checkgroup, "TOPLEFT", 5, -5
  local checks = {}
  local creaturetypes = {L["Beast"], L["Demon"], L["Elemental"], L["Dragonkin"], L["Giant"], L["Humanoid"], L["Mechanical"], L["Undead"], L["Not specified"], L["Unknown"]}
  for i,v in ipairs(creaturetypes) do
    local check = ww:SummonCheckBox(checkgroup, 22, a1, af, a2, dx, dy)
    checks[v] = check
    ww:EnslaveLabel(check, v)
    check:SetHitRectInsets(0, -100, 0, 0)
    check:SetScript("OnClick", function() ControlFreak.db.profile.targtypes[v] = not ControlFreak.db.profile.targtypes[v] end)
 
    if i == 5 then a1, af, a2, dx, dy = "TOPLEFT", checkgroup, "TOP", 5, -5
    else a1, af, a2, dx, dy = "TOPLEFT", check, "BOTTOMLEFT", 0, 4 end
  end
 
 
  local debufflabel = ww:SummonFontString(frame, "OVERLAY", "GameFontNormalSmall", "Debuff", "TOPLEFT", checkgroup, "BOTTOMLEFT", 0, -GAP)
  local debuff = ww:SummonEditBox(frame, 200, "LEFT", debufflabel, "RIGHT", 10, 0)
  debuff:SetPoint("RIGHT", frame, "RIGHT", -EDGEGAP, 0)
  ww:EnslaveTooltip(debuff, "Debuffs to track for control. Separate multiple debuffs with commas.")
  debuff:SetScript("OnEditFocusLost", function()
    ControlFreak.db.profile.spellname = debuff:GetText()
    ControlFreak:ParseDebuffs(string.split(",", ControlFreak.db.profile.spellname))
  end)
  debuff:SetScript("OnEscapePressed", debuff.ClearFocus)
 
 
  local macrolabel = ww:SummonFontString(frame, "OVERLAY", "GameFontNormalSmall", "Macro", "TOPLEFT", debufflabel, "BOTTOMLEFT", 0, -GAP)
  local editbox = CreateFrame("EditBox", nil, frame)
  editbox:SetPoint("TOP", macrolabel, "BOTTOM", 0, -5)
  editbox:SetPoint("LEFT", EDGEGAP/3, 0)
  editbox:SetPoint("BOTTOMRIGHT", -EDGEGAP/3, EDGEGAP/3)
  editbox:SetFontObject(GameFontHighlight)
  editbox:SetTextInsets(8,8,8,8)
  editbox:SetBackdrop(ww.TooltipBorderBG)
  editbox:SetBackdropColor(.1,.1,.1,.3)
  editbox:SetMultiLine(true)
  editbox:SetAutoFocus(false)
  editbox:SetScript("OnEditFocusLost", function()
    ControlFreak.db.profile.macrotext = editbox:GetText()
    ControlFreak.macroupdated = true
    if not InCombatLockdown() then ControlFreak:PLAYER_REGEN_ENABLED() end
  end)
  editbox:SetScript("OnEscapePressed", editbox.ClearFocus)
  ControlFreak.combatwarn = ww:EnslaveLabel(editbox, "|cffff0000Macro changes will not apply until combat ends!", "BOTTOMRIGHT", editbox, "TOPRIGHT", -5, 0)
  if InCombatLockdown() then ControlFreak.combatwarn:Show() else ControlFreak.combatwarn:Hide() end
 
 
  local function OnShow(frame)
    debuff:SetText(ControlFreak.db.profile.spellname)
    editbox:SetText(ControlFreak.db.profile.macrotext or "/script ChatFrame1:AddMessage(\"Error loading macro!\")")
    for i,v in ipairs(creaturetypes) do checks[v]:SetChecked(ControlFreak.db.profile.targtypes[v]) end
  end
  frame:SetScript("OnShow", OnShow)
  OnShow(frame)
end)
 
InterfaceOptions_AddCategory(frame)