public
Description: WoW Addon - Generic reminder framework
Homepage: http://www.tekkub.net/
Clone URL: git://github.com/tekkub/cork.git
Click here to lend your support to: cork and make a donation at www.pledgie.com !
tekkub (author)
Sun Nov 08 00:19:33 -0800 2009
commit  2ba4ab9a865cb86eb4d370f1ad2a56537199cffe
tree    6163f9a847195e9203b2cae77593785883dacf9e
parent  d9adecf318c59858137aaf0eb157f01a478acec0 parent  8706d8c0edf1d084f7c2d649ae878482fa689384
cork / Config.lua
100644 254 lines (200 sloc) 9.812 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
local Cork = Cork
 
local GAP = 8
local tekcheck = LibStub("tekKonfig-Checkbox")
 
 
local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
Cork.config = frame
frame.name = "Cork"
frame:Hide()
 
frame:SetScript("OnShow", function()
local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 16, 16, 2, 4
 
local title, subtitle = LibStub("tekKonfig-Heading").new(frame, "Cork", "Most of these settings are saved on a per-talent spec basis. Settings will automatically switch when you swap specs.")
 
local showanchor = tekcheck.new(frame, nil, "Show anchor", "TOPLEFT", subtitle, "BOTTOMLEFT", -2, -GAP)
showanchor.tiptext = "Toggle the tooltip anchor. \n|cffffff9aThis setting is global."
showanchor:SetScript("OnClick", function(self)
Cork.db.showanchor = not Cork.db.showanchor
if Cork.db.showanchor then Cork.anchor:Show() else Cork.anchor:Hide() end
end)
 
 
local resetanchor = LibStub("tekKonfig-Button").new_small(frame, "LEFT", showanchor, "RIGHT", 105, 0)
resetanchor:SetWidth(60) resetanchor:SetHeight(18)
resetanchor.tiptext = "Click to reset the anchor to it's default position. \n|cffffff9aPosition is a global setting."
resetanchor:SetText("Reset")
resetanchor:SetScript("OnClick", function()
Cork.db.point, Cork.db.x, Cork.db.y = nil
Cork.anchor:ClearAllPoints()
Cork.anchor:SetPoint(Cork.db.point, Cork.db.x, Cork.db.y)
Cork.Update()
end)
 
 
local showbg = tekcheck.new(frame, nil, "Show toolip in BG", "TOPLEFT", showanchor, "BOTTOMLEFT", 0, -GAP)
showbg.tiptext = "Show the tooltip when in a battleground or Wintergrasp. When the tooltip is hidden the macro will still work."
showbg:SetScript("OnClick", function(self)
Cork.db.showbg = not Cork.db.showbg
Cork.Update()
end)
 
 
local showunit = tekcheck.new(frame, nil, "Show unitID", "TOPLEFT", showbg, "BOTTOMLEFT", 0, -GAP)
showunit.tiptext = "Show unitID (target, party1, raidpet5) in tooltip. \n|cffffff9aThis setting is global."
showunit:SetScript("OnClick", function(self)
Cork.db.showunit = not Cork.db.showunit
Cork.Update()
end)
 
 
local bindwheel = tekcheck.new(frame, nil, "Bind mousewheel", "TOPLEFT", showunit, "BOTTOMLEFT", 0, -GAP)
bindwheel.tiptext = "Bind to mousewheel when out of combat and needs are present. \n|cffffff9aThis setting is global."
bindwheel:SetScript("OnClick", function(self)
Cork.db.bindwheel = not Cork.db.bindwheel
Cork.UpdateMouseBinding()
end)
 
 
local tooltiplimit, tooltiplimittext, ttlcontainer = LibStub("tekKonfig-Slider").new(frame, "Tooltip Limit: " .. Cork.dbpc.tooltiplimit, 0, 40, "TOP", showanchor, "TOP")
ttlcontainer:SetPoint("LEFT", frame, "CENTER", GAP*5/2, 0)
tooltiplimit.tiptext = "The number of units to show in the Cork tooltip."
tooltiplimit:SetValueStep(1)
tooltiplimit:SetValue(Cork.dbpc.tooltiplimit)
tooltiplimit:SetScript("OnValueChanged", function(self, newvalue)
Cork.dbpc.tooltiplimit = newvalue
tooltiplimittext:SetText("Tooltip Limit: " .. newvalue)
Cork.Update()
end)
 
 
local castonpets, groupthresh, groupthreshtext, groupthreshcont
if Cork.hasgroupspell then
groupthresh, groupthreshtext, groupthreshcont = LibStub("tekKonfig-Slider").new(frame, "Group Threshold: ".. Cork.dbpc.multithreshold, 1, 6, "TOPLEFT", ttlcontainer, "BOTTOMLEFT") --, GAP*2, -GAP)
groupthresh.tiptext = "Minimum number of needy players in a group required to cast multi-target spells. Setting this to six will disable the automatic use of group spells when in a party."
groupthresh:SetValueStep(1)
groupthresh:SetScript("OnValueChanged", function(self, newvalue)
Cork.dbpc.multithreshold = newvalue
groupthreshtext:SetText("Group Threshold: ".. newvalue)
end)
 
--~ castonpets = tekcheck.new(frame, nil, "Cast on group pets", "TOPLEFT", groupthreshcont, "BOTTOMLEFT", -GAP*2, 0)
castonpets = tekcheck.new(frame, nil, "Cast on group pets", "TOPLEFT", bindwheel, "BOTTOMLEFT", 0, -GAP)
castonpets.tiptext = "Pets need buffs too! When disabled you can still cast on a pet by targetting it directly."
castonpets:SetScript("OnClick", function(self)
Cork.dbpc.castonpets = not Cork.dbpc.castonpets
for name,dataobj in pairs(Cork.corks) do dataobj:Scan() end
end)
end
 
if Cork.hasgroupspell or Cork.hasraidspell then
local raidgroupdropdown, raidgroupdropdowntext, raidgroupdropdowncontainer, raidgroupdropdownlabel = LibStub("tekKonfig-Dropdown").new(frame, "Raid mode", "TOPLEFT", groupthreshcont or ttlcontainer, "BOTTOMLEFT", -12, -6)
raidgroupdropdowncontainer:SetHeight(28)
raidgroupdropdown:SetWidth(120)
raidgroupdropdown:ClearAllPoints()
raidgroupdropdown:SetPoint("LEFT", raidgroupdropdownlabel, "RIGHT", -8, -2)
raidgroupdropdowntext:SetText((Cork.dbpc.raid_thresh*5).."-man")
raidgroupdropdown.tiptext = "Select which raid groups should be monitored for buffs."
 
local function OnClick(self)
raidgroupdropdowntext:SetText((self.value*5).."-man")
Cork.dbpc.raid_thresh = self.value
for name,dataobj in pairs(Cork.corks) do dataobj:Scan() end
end
UIDropDownMenu_Initialize(raidgroupdropdown, function()
local selected, info = (Cork.dbpc.raid_thresh*5).."-man", UIDropDownMenu_CreateInfo()
 
info.func = OnClick
 
info.text = "10-man"
info.value = 2
info.checked = "10-man" == selected
UIDropDownMenu_AddButton(info)
 
info.text = "25-man"
info.value = 5
info.checked = "25-man" == selected
UIDropDownMenu_AddButton(info)
 
info.text = "40-man"
info.value = 8
info.checked = "40-man" == selected
UIDropDownMenu_AddButton(info)
end)
end
 
 
local group = LibStub("tekKonfig-Group").new(frame, "Modules", "TOP", castonpets or bindwheel, "BOTTOM", 0, -27)
group:SetPoint("LEFT", EDGEGAP, 0)
group:SetPoint("BOTTOMRIGHT", -EDGEGAP, EDGEGAP)
 
 
local macrobutt = LibStub("tekKonfig-Button").new_small(frame, "BOTTOMRIGHT", group, "TOPRIGHT")
macrobutt:SetWidth(60) macrobutt:SetHeight(18)
macrobutt.tiptext = "Click to generate a macro, or pick it up if already generated."
macrobutt:SetText("Macro")
macrobutt:SetScript("OnClick", Cork.GenerateMacro)
 
 
local rows, corknames, anchor = {}, {}
local NUMROWS = math.floor((group:GetHeight()-EDGEGAP+ROWGAP + 2) / (ROWHEIGHT+ROWGAP))
for name in pairs(Cork.corks) do table.insert(corknames, (name:gsub("Cork ", ""))) end
table.sort(corknames)
local function OnClick(self)
Cork.dbpc[self.name.."-enabled"] = not Cork.dbpc[self.name.."-enabled"]
PlaySound(Cork.dbpc[self.name.."-enabled"] and "igMainMenuOptionCheckBoxOn" or "igMainMenuOptionCheckBoxOff")
Cork.corks["Cork ".. self.name]:Scan()
end
for i=1,NUMROWS do
local row = CreateFrame("Button", nil, group)
if anchor then row:SetPoint("TOP", anchor , "BOTTOM", 0, -ROWGAP)
else row:SetPoint("TOP", 0, -EDGEGAP/2) end
row:SetPoint("LEFT", EDGEGAP/2, 0)
row:SetPoint("RIGHT", -EDGEGAP/2 - 22, 0)
row:SetHeight(ROWHEIGHT)
anchor = row
rows[i] = row
 
 
local check = CreateFrame("CheckButton", nil, row)
check:SetWidth(ROWHEIGHT+4)
check:SetHeight(ROWHEIGHT+4)
check:SetPoint("LEFT")
check:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up")
check:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down")
check:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
check:SetDisabledCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled")
check:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check")
check:SetHitRectInsets(0, -100, 0, 0)
check:SetScript("OnClick", OnClick)
row.check = check
 
 
local title = row:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall")
title:SetPoint("LEFT", check, "RIGHT", 4, 0)
row.title = title
end
 
 
local scrollbar = LibStub("tekKonfig-Scroll").new(group, 6, #rows/2)
local f = scrollbar:GetScript("OnValueChanged")
scrollbar:SetScript("OnValueChanged", function(self, value, ...)
local offset = math.floor(value)
 
for _,name in pairs(corknames) do
local configframe = Cork.corks["Cork "..name].configframe
if configframe then configframe:Hide() end
end
 
for i,row in pairs(rows) do
local name = corknames[i + offset]
if name then
row:Show()
row.check.name = name
row.title:SetText(name)
row.check:SetChecked(Cork.dbpc[name.."-enabled"])
 
local configframe = Cork.corks["Cork "..name].configframe
if configframe then
configframe:SetPoint("RIGHT", row)
configframe:SetFrameLevel(row:GetFrameLevel() + 1)
configframe:Show()
end
else
row:Hide()
row.check.name = nil
row.title:SetText()
row.check:SetChecked(false)
end
end
return f(self, value, ...)
end)
scrollbar:SetMinMaxValues(0, math.max(0, #corknames-#rows))
scrollbar:SetValue(0)
 
group:EnableMouseWheel()
group:SetScript("OnMouseWheel", function(self, val) scrollbar:SetValue(scrollbar:GetValue() - val*#rows/2) end)
 
 
local function Update(self)
showanchor:SetChecked(Cork.db.showanchor)
showbg:SetChecked(Cork.db.showbg)
showunit:SetChecked(Cork.db.showunit)
bindwheel:SetChecked(Cork.db.bindwheel)
if castonpets then castonpets:SetChecked(Cork.dbpc.castonpets) end
if groupthresh then groupthresh:SetValue(Cork.dbpc.multithreshold) end
end
 
frame:SetScript("OnShow", Update)
Update(frame)
end)
 
InterfaceOptions_AddCategory(frame)
 
 
----------------------------
-- LDB Launcher --
----------------------------
 
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local dataobj = ldb:GetDataObjectByName("CorkLauncher") or ldb:NewDataObject("CorkLauncher", {type = "launcher", icon = "Interface\\Icons\\INV_Drink_11", tocname = "Cork"})
dataobj.OnClick = function() InterfaceOptionsFrame_OpenToCategory(frame) end
 
 
----------------------------
-- Key Binding --
----------------------------
 
setglobal("BINDING_HEADER_CORK", "Cork")
setglobal("BINDING_NAME_CLICK CorkFrame:LeftButton", "Click the Cork frame")