tercio@2
|
1
|
tercio@2
|
2 -- fazer ele fechar apenas com o HotCornersBackgroundFrame.
|
tercio@2
|
3 -- assim vai dar + estabilidade sabendo exatamente quando ele esta aberto ou fechado.
|
tercio@0
|
4
|
tercio@0
|
5 LibHotCorners = LibStub ("AceAddon-3.0"):NewAddon ("HotCorners", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")
|
tercio@1
|
6 _G.HotCorners = LibHotCorners
|
tercio@0
|
7 local LibHotCorners = LibHotCorners
|
tercio@0
|
8
|
tercio@0
|
9 local LBD = LibStub ("LibDataBroker-1.1")
|
tercio@0
|
10
|
tercio@0
|
11 local debug = false
|
tercio@0
|
12 local tinsert = tinsert
|
tercio@0
|
13
|
tercio@0
|
14 local default_db = {
|
tercio@0
|
15 profile = {
|
tercio@0
|
16 is_enabled = true,
|
tercio@0
|
17 topleft_enabled = true,
|
tercio@1
|
18 topleft_quickfunc = false,
|
tercio@0
|
19 clicks = {},
|
tercio@0
|
20 disabled = {}
|
tercio@0
|
21 },
|
tercio@0
|
22 }
|
tercio@0
|
23
|
tercio@1
|
24 LibHotCorners.RegistredQuickFunctions = {}
|
tercio@1
|
25 LibHotCorners.QuickFunctions = {topleft = false}
|
tercio@1
|
26
|
tercio@0
|
27 function LibHotCorners:OnEnable()
|
tercio@0
|
28
|
tercio@0
|
29 end
|
tercio@0
|
30
|
tercio@0
|
31 function LibHotCorners:OnDisable()
|
tercio@0
|
32
|
tercio@0
|
33 end
|
tercio@0
|
34
|
tercio@2
|
35 LibHotCorners.ItemButtons = {}
|
tercio@2
|
36 LibHotCorners.ItemOnInventory = {}
|
tercio@2
|
37
|
tercio@0
|
38 local refresh_topleft = function()
|
tercio@0
|
39 LibHotCorners ["topleft"].is_enabled = LibHotCorners.db.profile.topleft_enabled
|
tercio@0
|
40 end
|
tercio@0
|
41
|
tercio@0
|
42 local OptionsTable = {
|
tercio@0
|
43 name = "HotCorners",
|
tercio@0
|
44 type = "group",
|
tercio@0
|
45 args = {
|
tercio@0
|
46 Enabled = {
|
tercio@0
|
47 type = "toggle",
|
tercio@0
|
48 name = "Enabled",
|
tercio@0
|
49 desc = "Enable or Disable this addon.",
|
tercio@0
|
50 order = 1,
|
tercio@0
|
51 get = function() return LibHotCorners.db.profile.is_enabled end,
|
tercio@0
|
52 set = function (self, val) LibHotCorners.db.profile.is_enabled = not LibHotCorners.db.profile.is_enabled; --[[ do something]] end,
|
tercio@0
|
53 },
|
tercio@0
|
54 TopLeftEnabled = {
|
tercio@0
|
55 type = "toggle",
|
tercio@0
|
56 name = "Top Left",
|
tercio@0
|
57 desc = "Enable or Disable the Top Left bar.",
|
tercio@0
|
58 order = 2,
|
tercio@0
|
59 get = function() return LibHotCorners.db.profile.topleft_enabled end,
|
tercio@0
|
60 set = function (self, val) LibHotCorners.db.profile.topleft_enabled = not LibHotCorners.db.profile.topleft_enabled; refresh_topleft() end,
|
tercio@0
|
61 },
|
tercio@1
|
62 QuickClickFunc = {
|
tercio@1
|
63 type = "select",
|
tercio@1
|
64 name = "Quick Click",
|
tercio@1
|
65 desc = "Select the behavior when clicking over the absolute topleft corner.",
|
tercio@1
|
66 values = function()
|
tercio@1
|
67 local options = {}
|
tercio@1
|
68 for index, quickfunc in ipairs (LibHotCorners.RegistredQuickFunctions) do
|
tercio@1
|
69 options [quickfunc.name] = quickfunc.name
|
tercio@1
|
70 end
|
tercio@1
|
71 return options
|
tercio@1
|
72 end,
|
tercio@1
|
73 get = function() return LibHotCorners.db.profile.topleft_quickfunc or "" end,
|
tercio@1
|
74 set = function (self, funcname)
|
tercio@1
|
75 LibHotCorners.db.profile.topleft_quickfunc = funcname;
|
tercio@1
|
76 for index, quickfunc in ipairs (LibHotCorners.RegistredQuickFunctions) do
|
tercio@1
|
77 if (quickfunc.name == funcname) then
|
tercio@1
|
78 LibHotCorners.QuickFunctions.topleft = quickfunc.func
|
tercio@1
|
79 break
|
tercio@1
|
80 end
|
tercio@1
|
81 end
|
tercio@1
|
82 end,
|
tercio@1
|
83 order = 4,
|
tercio@1
|
84 }
|
tercio@0
|
85 }
|
tercio@0
|
86 }
|
tercio@0
|
87
|
tercio@0
|
88 function LibHotCorners:OnInitialize()
|
tercio@0
|
89
|
tercio@0
|
90 --declarar primeiro o db usando a global que é declarada no toc.
|
tercio@0
|
91 self.db = LibStub ("AceDB-3.0"):New ("HotCornersDB", default_db, true)
|
tercio@0
|
92
|
tercio@0
|
93 --declara agora as opções da tab raiz
|
tercio@0
|
94 LibStub("AceConfig-3.0"):RegisterOptionsTable ("HotCorners", OptionsTable)
|
tercio@0
|
95 LibHotCorners.OptionsFrame1 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("HotCorners", "HotCorners")
|
tercio@0
|
96 --sub tab
|
tercio@0
|
97 LibStub ("AceConfig-3.0"):RegisterOptionsTable ("HotCorners-Profiles", LibStub ("AceDBOptions-3.0"):GetOptionsTable (self.db))
|
tercio@0
|
98 LibHotCorners.OptionsFrame2 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("HotCorners-Profiles", "Profiles", "HotCorners")
|
tercio@0
|
99
|
tercio@0
|
100 LibHotCorners ["topleft"].is_enabled = self.db.topleft_enabled
|
tercio@0
|
101 refresh_topleft()
|
tercio@0
|
102
|
tercio@0
|
103 SLASH_HOTCORNER1, SLASH_HOTCORNER2 = "/hotcorners", "/hotcorner"
|
tercio@0
|
104 function SlashCmdList.HOTCORNER (msg, editbox)
|
tercio@0
|
105 HotCornersOpenOptions (self);
|
tercio@0
|
106 end
|
tercio@0
|
107
|
tercio@0
|
108 for name, dataobj in LBD:DataObjectIterator() do
|
tercio@0
|
109 if (dataobj.type and dataobj.icon and dataobj.OnClick) then
|
tercio@0
|
110 LibHotCorners:RegisterHotCornerButton (name, "TopLeft", nil, name .. "HotCornerLauncher", dataobj.icon, dataobj.OnTooltipShow, dataobj.OnClick, nil, nil, dataobj.OnEnter, dataobj.OnLeave)
|
tercio@0
|
111 end
|
tercio@0
|
112 end
|
tercio@0
|
113 for k, v in pairs (LBD.attributestorage) do
|
tercio@0
|
114 --print (k, v)
|
tercio@0
|
115 --print ("----------------")
|
tercio@0
|
116 --vardump (v)
|
tercio@0
|
117 end
|
tercio@0
|
118
|
tercio@0
|
119 end
|
tercio@0
|
120
|
tercio@0
|
121 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
122 --> main function
|
tercio@0
|
123
|
tercio@0
|
124 LibHotCorners.embeds = LibHotCorners.embeds or {}
|
tercio@0
|
125 local embed_functions = {
|
tercio@0
|
126 "RegisterHotCornerButton",
|
tercio@0
|
127 "HideHotCornerButton",
|
tercio@0
|
128 }
|
tercio@0
|
129
|
tercio@0
|
130 function LibHotCorners:Embed (target)
|
tercio@0
|
131 for k, v in pairs (embed_functions) do
|
tercio@0
|
132 target[v] = self[v]
|
tercio@0
|
133 end
|
tercio@0
|
134 self.embeds [target] = true
|
tercio@0
|
135 return target
|
tercio@0
|
136 end
|
tercio@0
|
137
|
tercio@0
|
138 local CallbackHandler = LibStub:GetLibrary ("CallbackHandler-1.0")
|
tercio@0
|
139 LibHotCorners.callbacks = LibHotCorners.callbacks or CallbackHandler:New (LibHotCorners)
|
tercio@0
|
140
|
tercio@0
|
141 LibHotCorners.topleft = LibHotCorners.topleft or {widgets = {}, quickclick = false, is_enabled = false, map = {}}
|
tercio@0
|
142 LibHotCorners.bottomleft = {}
|
tercio@0
|
143 LibHotCorners.topright = {}
|
tercio@0
|
144 LibHotCorners.bottomright = {}
|
tercio@0
|
145
|
tercio@0
|
146 local function test (corner)
|
tercio@0
|
147 assert (corner == "topleft" or corner == "bottomleft" or corner == "topright" or corner == "bottomright", "LibHotCorners:RegisterAddon expects a corner on #1 argument.")
|
tercio@0
|
148 end
|
tercio@0
|
149
|
tercio@1
|
150 function LibHotCorners:AddQuickFunction (quickfunc, corner)
|
tercio@1
|
151
|
tercio@1
|
152 local current_quickfunc = LibHotCorners.db.profile [corner .. "_quickfunc"] or ""
|
tercio@1
|
153
|
tercio@1
|
154 --> passed only one table
|
tercio@1
|
155 if (quickfunc.name) then
|
tercio@1
|
156 --> check if already exists
|
tercio@1
|
157 local already_exists = false
|
tercio@1
|
158 for _, registred in ipairs (LibHotCorners.RegistredQuickFunctions) do
|
tercio@1
|
159 if (registred.name == quickfunc.name) then
|
tercio@1
|
160 registred.func = quickfunc.func
|
tercio@1
|
161 if (current_quickfunc == quickfunc.name) then
|
tercio@1
|
162 LibHotCorners.QuickFunctions [corner] = quickfunc.func
|
tercio@1
|
163 end
|
tercio@1
|
164 already_exists = true
|
tercio@1
|
165 break
|
tercio@1
|
166 end
|
tercio@1
|
167 end
|
tercio@1
|
168 --> add table
|
tercio@1
|
169 if (not already_exists) then
|
tercio@1
|
170 table.insert (LibHotCorners.RegistredQuickFunctions, quickfunc)
|
tercio@1
|
171 if (current_quickfunc == quickfunc.name) then
|
tercio@1
|
172 LibHotCorners.QuickFunctions [corner] = quickfunc.func
|
tercio@1
|
173 end
|
tercio@1
|
174 end
|
tercio@1
|
175 --> check if there is a quickfunc to be use
|
tercio@1
|
176 if (current_quickfunc == "") then
|
tercio@1
|
177 LibHotCorners.db.profile [corner .. "_quickfunc"] = quickfunc.name
|
tercio@1
|
178 LibHotCorners.QuickFunctions [corner] = quickfunc.func
|
tercio@1
|
179 end
|
tercio@1
|
180 else
|
tercio@1
|
181 --> passed a table of tables
|
tercio@1
|
182 for _, this_quickfunc in ipairs (quickfunc) do
|
tercio@1
|
183 --> check if already exists
|
tercio@1
|
184 local already_exists = false
|
tercio@1
|
185 for _, registred in ipairs (LibHotCorners.RegistredQuickFunctions) do
|
tercio@1
|
186 if (registred.name == this_quickfunc.name) then
|
tercio@1
|
187 registred.func = this_quickfunc.func
|
tercio@1
|
188 if (current_quickfunc == this_quickfunc.name) then
|
tercio@1
|
189 LibHotCorners.QuickFunctions [corner] = this_quickfunc.func
|
tercio@1
|
190 end
|
tercio@1
|
191 already_exists = true
|
tercio@1
|
192 break
|
tercio@1
|
193 end
|
tercio@1
|
194 end
|
tercio@1
|
195 --> add table
|
tercio@1
|
196 if (not already_exists) then
|
tercio@1
|
197 table.insert (LibHotCorners.RegistredQuickFunctions, this_quickfunc)
|
tercio@1
|
198 if (current_quickfunc == this_quickfunc.name) then
|
tercio@1
|
199 LibHotCorners.QuickFunctions [corner] = this_quickfunc.func
|
tercio@1
|
200 end
|
tercio@1
|
201 end
|
tercio@1
|
202 --> check if there is a quickfunc to be use
|
tercio@1
|
203 if (current_quickfunc == "") then
|
tercio@1
|
204 LibHotCorners.db.profile [corner .. "_quickfunc"] = this_quickfunc.name
|
tercio@1
|
205 LibHotCorners.QuickFunctions [corner] = this_quickfunc.func
|
tercio@1
|
206 current_quickfunc = this_quickfunc.name
|
tercio@1
|
207 end
|
tercio@1
|
208 end
|
tercio@1
|
209 end
|
tercio@1
|
210
|
tercio@1
|
211 end
|
tercio@1
|
212
|
tercio@1
|
213 function LibHotCorners:RegisterHotCornerButton (name, corner, optionstable, fname, icon, tooltip, clickfunc, menus, quickfunc, onenter, onleave, is_install)
|
tercio@0
|
214 corner = string.lower (corner)
|
tercio@0
|
215 test (corner)
|
tercio@0
|
216
|
tercio@1
|
217 optionstable = optionstable or {hide = false}
|
tercio@1
|
218
|
tercio@0
|
219 if (is_install) then
|
tercio@0
|
220 --> overwrite if already exists a widget
|
tercio@0
|
221 for i, widget in ipairs (LibHotCorners [corner]) do
|
tercio@0
|
222 if (widget.name == name) then
|
tercio@0
|
223 table.remove (LibHotCorners [corner], i)
|
tercio@1
|
224 table.insert (LibHotCorners [corner], i, {name = name, fname = fname, optionstable = optionstable, icon = icon, tooltip = tooltip, click = clickfunc, menus = menus, quickfunc = quickfunc, onenter = onenter, onleave = onleave, is_install = true})
|
tercio@1
|
225 if (quickfunc) then
|
tercio@1
|
226 LibHotCorners:AddQuickFunction (quickfunc, corner)
|
tercio@1
|
227 end
|
tercio@0
|
228 return LibHotCorners [corner].map [name]
|
tercio@0
|
229 end
|
tercio@0
|
230 end
|
tercio@1
|
231 --> add
|
tercio@1
|
232 table.insert (LibHotCorners [corner], {name = name, fname = fname, optionstable = optionstable, icon = icon, tooltip = tooltip, click = clickfunc, menus = menus, quickfunc = quickfunc, onenter = onenter, onleave = onleave, is_install = true})
|
tercio@0
|
233 LibHotCorners [corner].map [name] = #LibHotCorners [corner]
|
tercio@1
|
234 if (quickfunc) then
|
tercio@1
|
235 LibHotCorners:AddQuickFunction (quickfunc, corner)
|
tercio@1
|
236 end
|
tercio@0
|
237 return LibHotCorners [corner].map [name]
|
tercio@0
|
238 else
|
tercio@1
|
239 --> check if already exists
|
tercio@1
|
240 for i, widget in ipairs (LibHotCorners [corner]) do
|
tercio@1
|
241 if (widget.name == name) then
|
tercio@1
|
242 return
|
tercio@0
|
243 end
|
tercio@0
|
244 end
|
tercio@1
|
245 --> add
|
tercio@1
|
246 table.insert (LibHotCorners [corner], {name = name, fname = fname, optionstable = optionstable, icon = icon, tooltip = tooltip, click = clickfunc, menus = menus, quickfunc = quickfunc, onenter = onenter, onleave = onleave})
|
tercio@1
|
247 LibHotCorners [corner].map [name] = #LibHotCorners [corner]
|
tercio@1
|
248 if (quickfunc) then
|
tercio@1
|
249 LibHotCorners:AddQuickFunction (quickfunc, corner)
|
tercio@0
|
250 end
|
tercio@1
|
251 return LibHotCorners [corner].map [name]
|
tercio@0
|
252 end
|
tercio@0
|
253 end
|
tercio@0
|
254
|
tercio@0
|
255 function LibHotCorners:HideHotCornerButton (name, corner, value)
|
tercio@0
|
256
|
tercio@0
|
257 corner = string.lower (corner)
|
tercio@0
|
258 test (corner)
|
tercio@0
|
259
|
tercio@0
|
260 local corner_table = LibHotCorners [corner]
|
tercio@0
|
261 local addon_table = corner_table [corner_table.map [name]]
|
tercio@0
|
262
|
tercio@1
|
263 if (addon_table) then
|
tercio@1
|
264 addon_table.optionstable.hide = value
|
tercio@1
|
265 end
|
tercio@0
|
266
|
tercio@0
|
267 LibHotCorners [corner].is_enabled = false
|
tercio@0
|
268
|
tercio@1
|
269 for index, button_table in ipairs (corner_table) do
|
tercio@1
|
270 if (not button_table.optionstable.hide) then
|
tercio@0
|
271 LibHotCorners [corner].is_enabled = true
|
tercio@0
|
272 break
|
tercio@0
|
273 end
|
tercio@0
|
274 end
|
tercio@0
|
275
|
tercio@0
|
276 return true
|
tercio@0
|
277 end
|
tercio@0
|
278
|
tercio@0
|
279 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
280 --> data broker stuff
|
tercio@0
|
281 function LibHotCorners:DataBrokerCallback (event, name, dataobj)
|
tercio@0
|
282 if (not name or not dataobj or not dataobj.type) then
|
tercio@0
|
283 return
|
tercio@0
|
284 end
|
tercio@0
|
285 if (dataobj.icon and dataobj.OnClick) then
|
tercio@0
|
286 LibHotCorners:RegisterHotCornerButton (name, "TopLeft", nil, name .. "HotCornerLauncher", dataobj.icon, dataobj.OnTooltipShow, dataobj.OnClick, nil, nil, dataobj.OnEnter, dataobj.OnLeave)
|
tercio@0
|
287 end
|
tercio@0
|
288 end
|
tercio@0
|
289 LBD.RegisterCallback (LibHotCorners, "DataBrokerCallback")
|
tercio@0
|
290
|
tercio@0
|
291 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
292 --> scripts
|
tercio@0
|
293
|
tercio@0
|
294 --> background (window mode fix)
|
tercio@0
|
295 function HotCornersBackgroundOnEnter (self)
|
tercio@0
|
296 if (LibHotCornersTopLeft and LibHotCornersTopLeft:IsShown()) then
|
tercio@0
|
297 if (LibHotCornersTopLeft:GetWidth() > 2) then
|
tercio@2
|
298 HotCornersOnLeave (LibHotCornersTopLeft, true)
|
tercio@0
|
299 end
|
tercio@0
|
300 end
|
tercio@0
|
301 self:EnableMouse (false)
|
tercio@0
|
302 end
|
tercio@0
|
303
|
tercio@0
|
304 --> set size
|
tercio@0
|
305 local function set_size (self)
|
tercio@0
|
306 if (self.position == "topleft" or self.position == "topright") then
|
tercio@0
|
307 self:SetSize (40, GetScreenHeight())
|
tercio@0
|
308 else
|
tercio@0
|
309 self:SetSize (GetScreenWidth(), 40)
|
tercio@0
|
310 end
|
tercio@0
|
311 end
|
tercio@0
|
312
|
tercio@0
|
313 --> show tooltip
|
tercio@0
|
314 local show_tooltip = function (self)
|
tercio@2
|
315 if (self.table and self.table.tooltip) then
|
tercio@0
|
316 if (type (self.table.tooltip) == "function") then
|
tercio@0
|
317 GameTooltip:SetOwner (self, "ANCHOR_RIGHT")
|
tercio@0
|
318 self.table.tooltip (GameTooltip)
|
tercio@0
|
319 GameTooltip:Show()
|
tercio@0
|
320 elseif (type (self.table.tooltip) == "string") then
|
tercio@0
|
321 GameTooltip:SetOwner (self, "ANCHOR_RIGHT")
|
tercio@0
|
322 GameTooltip:AddLine (self.table.tooltip)
|
tercio@0
|
323 GameTooltip:Show()
|
tercio@0
|
324 end
|
tercio@2
|
325 elseif (self.table and self.table.onenter) then
|
tercio@0
|
326 self.table.onenter (self)
|
tercio@2
|
327 elseif (self.isItem) then
|
tercio@2
|
328 GameTooltip:SetOwner (self, "ANCHOR_BOTTOMRIGHT")
|
tercio@2
|
329 GameTooltip:SetHyperlink (self.itemtable[4])
|
tercio@2
|
330 GameTooltip:Show()
|
tercio@0
|
331 end
|
tercio@0
|
332 end
|
tercio@0
|
333
|
tercio@0
|
334 --> corner frame on enter
|
tercio@0
|
335 local more_clicked = function (t1, t2)
|
tercio@0
|
336 return t1[1] > t2[1]
|
tercio@0
|
337 end
|
tercio@0
|
338
|
tercio@2
|
339 LibHotCorners.BackPackItemList = {
|
tercio@2
|
340
|
tercio@2
|
341 --> alchemy
|
tercio@2
|
342 [76086] = true, -- Flask of Falling Leaves
|
tercio@2
|
343 [76084] = true, -- Flask of Spring Blossoms
|
tercio@2
|
344 [76085] = true, -- Flask of the Warm Sun
|
tercio@2
|
345 [76087] = true, -- Flask of the Earth
|
tercio@2
|
346 [76088] = true, -- Flask of Winter's Bite
|
tercio@2
|
347
|
tercio@2
|
348 [76081] = true, -- Elixir of Mirrors
|
tercio@2
|
349 [76079] = true, -- Elixir of Peace
|
tercio@2
|
350 [76080] = true, -- Elixir of Perfection
|
tercio@2
|
351 [76078] = true, -- Elixir of the Rapids
|
tercio@2
|
352 [76077] = true, -- Elixir of Weaponry
|
tercio@2
|
353 [70676] = true, -- Mad Hozen Elixir
|
tercio@2
|
354 [76075] = true, -- Mantid Elixir
|
tercio@2
|
355 [76083] = true, -- Monk's Elixir
|
tercio@2
|
356
|
tercio@2
|
357 [76094] = true, -- Alchemist's Rejuvenation
|
tercio@2
|
358 [96096] = true, -- Darkwater Potion
|
tercio@2
|
359 [75218] = true, -- Electrified Oil
|
tercio@2
|
360 [76097] = true, -- Master Healing Potion
|
tercio@2
|
361 [76098] = true, -- Master Mana Potion
|
tercio@2
|
362 [76092] = true, -- Potion of Focus
|
tercio@2
|
363 [76093] = true, -- Potion of the Jade Serpent
|
tercio@2
|
364 [76095] = true, -- Potion of Mogu Power
|
tercio@2
|
365 [76090] = true, -- Potion of the Mountains
|
tercio@2
|
366 [76091] = true, -- Greater Potion of Luck
|
tercio@2
|
367 [76089] = true, -- Virmen's Bite
|
tercio@2
|
368
|
tercio@2
|
369 --> cooking
|
tercio@2
|
370
|
tercio@2
|
371 --Way of the Grill: Strength
|
tercio@2
|
372 [74642] = true, -- Charbroiled Tiger Steak
|
tercio@2
|
373 [74645] = true, -- Eternal Blossom Fish
|
tercio@2
|
374 [74646] = true, -- Black Pepper Ribs and Shrimp
|
tercio@2
|
375
|
tercio@2
|
376 --Way of the Oven: Stamina
|
tercio@2
|
377 [74654] = true, -- Wildfowl Roast
|
tercio@2
|
378 [74655] = true, -- Twin Fish Platter
|
tercio@2
|
379 [74656] = true, -- Chun Tian Spring Rolls
|
tercio@2
|
380
|
tercio@2
|
381 --Way of the Pot: Intellect
|
tercio@2
|
382
|
tercio@2
|
383 [74644] = true, -- Swirling Mist Soup
|
tercio@2
|
384 [74649] = true, -- Braised Turtle
|
tercio@2
|
385 [74650] = true, -- Mogu Fish Stew
|
tercio@2
|
386
|
tercio@2
|
387 --Way of the Steamer: Spirit
|
tercio@2
|
388
|
tercio@2
|
389 [74651] = true, -- Shrimp Dumplings
|
tercio@2
|
390 [74652] = true, -- Fire Spirit Salmon
|
tercio@2
|
391 [74653] = true, -- Steamed Crab Surprise
|
tercio@2
|
392
|
tercio@2
|
393 --Way of the Wok: Agility
|
tercio@2
|
394
|
tercio@2
|
395 [74643] = true, -- Sauteed Carrots
|
tercio@2
|
396 [74647] = true, -- Valley Stir Fry
|
tercio@2
|
397 [74648] = true, -- Sea Mist Rice Noodles
|
tercio@2
|
398
|
tercio@2
|
399 --Way of the Brew: Headaches and Grandeur
|
tercio@2
|
400
|
tercio@2
|
401 [74626] = true, -- Ginseng Tea
|
tercio@2
|
402 [74637] = true, -- Jade Witch Brew
|
tercio@2
|
403 [74638] = true, -- Mad Brewer's Breakfast
|
tercio@2
|
404
|
tercio@2
|
405 --General Cooking
|
tercio@2
|
406
|
tercio@2
|
407 [74641] = true, -- Fish Cake
|
tercio@2
|
408 [74636] = true, -- Golden Carp Consomme
|
tercio@2
|
409 [86070] = true, -- Wildfowl Ginseng Soup
|
tercio@2
|
410 [86069] = true, -- Rice Pudding
|
tercio@2
|
411 [86074] = true, -- Spicy Vegetable Chips
|
tercio@2
|
412 [86073] = true, -- Spicy Salmon
|
tercio@2
|
413
|
tercio@2
|
414 --5.4 Recipes
|
tercio@2
|
415
|
tercio@2
|
416 [145308] = true, -- Mango Ice
|
tercio@2
|
417 [145309] = true, -- Farmer's Delight
|
tercio@2
|
418 [145311] = true, -- Fluffy Silkfeather Omelet
|
tercio@2
|
419 [145310] = true, -- Stuffed Lushrooms
|
tercio@2
|
420 [145307] = true, -- Spiced Blossom Soup
|
tercio@2
|
421 [145305] = true, -- Seasoned Pomfruit Slices
|
tercio@2
|
422
|
tercio@2
|
423 --Cart Kits
|
tercio@2
|
424 [101630] = true, -- Noodle Cart Kit
|
tercio@2
|
425 [101661] = true, -- Deluxe Noodle Cart Kit
|
tercio@2
|
426 [101662] = true, -- Pandaren Treasure Noodle Cart Kit
|
tercio@2
|
427
|
tercio@2
|
428 [101618] = true, -- Pandaren Treasure Noodle Soup
|
tercio@2
|
429 [101617] = true, -- Deluxe Noodle Soup
|
tercio@2
|
430 [101616] = true, -- Noodle Soup
|
tercio@2
|
431 }
|
tercio@2
|
432
|
tercio@0
|
433 function HotCornersOnEnter (self)
|
tercio@0
|
434
|
tercio@0
|
435 if (not LibHotCorners.db.profile.is_enabled) then
|
tercio@0
|
436 return
|
tercio@0
|
437 end
|
tercio@0
|
438
|
tercio@0
|
439 if (not LibHotCorners.db.profile [self.position .. "_enabled"]) then
|
tercio@0
|
440 return
|
tercio@0
|
441 end
|
tercio@0
|
442
|
tercio@2
|
443 if (self:GetWidth() < 1.1 and self:GetHeight() < 1.1) then
|
tercio@2
|
444 --print ("abrindo...")
|
tercio@2
|
445 end
|
tercio@2
|
446
|
tercio@0
|
447 set_size (self)
|
tercio@0
|
448
|
tercio@0
|
449 HotCornersBackgroundFrame:EnableMouse (true)
|
tercio@2
|
450 self.item_frame:Show()
|
tercio@0
|
451
|
tercio@0
|
452 local i = 1
|
tercio@0
|
453
|
tercio@0
|
454 local sort = {}
|
tercio@0
|
455 local clicks = LibHotCorners.db.profile.clicks
|
tercio@0
|
456 for index, button_table in ipairs (LibHotCorners [self.position]) do
|
tercio@0
|
457 tinsert (sort, {clicks [button_table.name] or 0, button_table})
|
tercio@0
|
458 end
|
tercio@0
|
459 table.sort (sort, more_clicked)
|
tercio@0
|
460
|
tercio@0
|
461 local last_button
|
tercio@0
|
462
|
tercio@0
|
463 local disabled = LibHotCorners.db.profile.disabled
|
tercio@0
|
464
|
tercio@0
|
465 for index, button_table in ipairs (sort) do
|
tercio@0
|
466 button_table = button_table [2]
|
tercio@0
|
467 if (not button_table.widget) then
|
tercio@0
|
468 LibHotCorners:CreateAddonWidget (self, button_table, index, self.position)
|
tercio@0
|
469 end
|
tercio@0
|
470
|
tercio@0
|
471 button_table.widget:ClearAllPoints()
|
tercio@0
|
472
|
tercio@1
|
473 if (not disabled [button_table.name] and not button_table.optionstable.hide) then
|
tercio@0
|
474 if (self.position == "topleft" or self.position == "topright") then
|
tercio@2
|
475
|
tercio@0
|
476 local y = i * 35 * -1
|
tercio@2
|
477 --button_table.widget:SetPoint ("topleft", self, "topleft", 4, y)
|
tercio@0
|
478 button_table.widget.y = y
|
tercio@2
|
479 HotCornersStartAnimOnShow (button_table.widget, "y")
|
tercio@2
|
480
|
tercio@2
|
481 else --bottom left / bottom right
|
tercio@0
|
482 local x = i * 35
|
tercio@0
|
483 button_table.widget:SetPoint ("topleft", self, "topleft", x, -4)
|
tercio@0
|
484 button_table.widget.x = x
|
tercio@0
|
485 end
|
tercio@0
|
486
|
tercio@0
|
487 button_table.widget:Show()
|
tercio@0
|
488 last_button = button_table.widget
|
tercio@0
|
489
|
tercio@0
|
490 i = i + 1
|
tercio@0
|
491 else
|
tercio@0
|
492 button_table.widget:Hide()
|
tercio@0
|
493 end
|
tercio@0
|
494 end
|
tercio@0
|
495
|
tercio@0
|
496 local OptionsButton = LibHotCorners [self.position].optionsbutton
|
tercio@0
|
497 local y = i * 35 * -1
|
tercio@0
|
498 OptionsButton:SetPoint ("top", self, "top", 0, y)
|
tercio@0
|
499 OptionsButton:Show()
|
tercio@0
|
500
|
tercio@2
|
501 --item frame
|
tercio@2
|
502 LibHotCorners:RefereshItems (self)
|
tercio@2
|
503
|
tercio@0
|
504 end
|
tercio@0
|
505
|
tercio@2
|
506 function LibHotCorners:RefereshItems (self)
|
tercio@2
|
507
|
tercio@2
|
508 if (not self) then
|
tercio@2
|
509 return LibHotCorners:ScheduleTimer ("RefereshItems", 1, LibHotCornersTopLeft)
|
tercio@2
|
510 end
|
tercio@2
|
511
|
tercio@2
|
512 if (not UnitAffectingCombat ("player") and not InCombatLockdown()) then
|
tercio@2
|
513 for itemId, itemTable in pairs (LibHotCorners.ItemOnInventory) do
|
tercio@2
|
514 itemTable [1] = 0
|
tercio@2
|
515 end
|
tercio@2
|
516
|
tercio@2
|
517 for bagID = 0, 4 do
|
tercio@2
|
518 local numItems = GetContainerNumSlots (bagID)
|
tercio@2
|
519 for slot = 1, numItems do
|
tercio@2
|
520 local itemId = GetContainerItemID (bagID, slot)
|
tercio@2
|
521 if (LibHotCorners.BackPackItemList [itemId]) then
|
tercio@2
|
522 local texture, itemCount, locked, quality, readable, lootable, itemLink = GetContainerItemInfo (bagID, slot)
|
tercio@2
|
523 if (not LibHotCorners.ItemOnInventory [itemId]) then
|
tercio@2
|
524 LibHotCorners.ItemOnInventory [itemId] = {itemCount, texture, quality, itemLink, itemId}
|
tercio@2
|
525 else
|
tercio@2
|
526 LibHotCorners.ItemOnInventory [itemId] [1] = LibHotCorners.ItemOnInventory [itemId] [1] + itemCount
|
tercio@2
|
527 end
|
tercio@2
|
528 end
|
tercio@2
|
529 end
|
tercio@2
|
530 end
|
tercio@2
|
531
|
tercio@2
|
532 local index = 1
|
tercio@2
|
533 for itemId, itemTable in pairs (LibHotCorners.ItemOnInventory) do
|
tercio@2
|
534 local itemCount, texture, quality, itemLink = unpack (itemTable)
|
tercio@2
|
535
|
tercio@2
|
536 local item_button = LibHotCorners:GetItemButton (index, self)
|
tercio@2
|
537 if (item_button) then
|
tercio@2
|
538 item_button:SetNormalTexture (texture)
|
tercio@2
|
539 item_button:SetHighlightTexture (texture)
|
tercio@2
|
540 item_button:SetPushedTexture (texture)
|
tercio@2
|
541
|
tercio@2
|
542 item_button.item_count:SetText (itemCount or 0)
|
tercio@2
|
543 item_button:SetAttribute ("macrotext", "/use " .. GetItemInfo (itemId) .. ";\n/script HotCorners:RefereshItems()")
|
tercio@2
|
544
|
tercio@2
|
545 item_button.itemtable = itemTable
|
tercio@2
|
546
|
tercio@2
|
547 if (not item_button:IsShown() or item_button:GetAlpha() < 1) then
|
tercio@2
|
548 HotCornersStartAnimOnShow (item_button, "item_topleft")
|
tercio@2
|
549 end
|
tercio@2
|
550 end
|
tercio@2
|
551 index = index + 1
|
tercio@2
|
552 end
|
tercio@2
|
553
|
tercio@2
|
554 end
|
tercio@2
|
555
|
tercio@2
|
556 --/run local itemid=GetContainerItemID (0, 1);print (itemid)
|
tercio@2
|
557 --UseContainerItem(bagID, slot[, onSelf])
|
tercio@2
|
558 end
|
tercio@2
|
559
|
tercio@2
|
560 function LibHotCorners:GetItemButton (index, parent)
|
tercio@2
|
561 local button = LibHotCorners.ItemButtons [index]
|
tercio@2
|
562 if (not button) then
|
tercio@2
|
563 button = CreateFrame ("button", "HotCornersItemButton" .. index, parent.item_frame, "HotCornersUseItemButtonTemplate")
|
tercio@2
|
564 button.isItem = true
|
tercio@2
|
565
|
tercio@2
|
566 if (parent.position == "topleft") then
|
tercio@2
|
567 local x = (index-1) * 33
|
tercio@2
|
568 button:SetPoint ("topleft", parent.item_frame, "topleft", x, -2)
|
tercio@2
|
569 button.x = x
|
tercio@2
|
570 elseif (parent.position == "topright") then
|
tercio@2
|
571 local x = (index-1) * 33
|
tercio@2
|
572 button:SetPoint ("topright", parent.item_frame, "topright", -x, -2)
|
tercio@2
|
573 end
|
tercio@2
|
574
|
tercio@2
|
575 LibHotCorners.ItemButtons [index] = button
|
tercio@2
|
576 end
|
tercio@2
|
577 return button
|
tercio@2
|
578 end
|
tercio@2
|
579
|
tercio@0
|
580 --> corner frame on leave
|
tercio@2
|
581 function HotCornersOnLeave (self, from_background)
|
tercio@2
|
582 if (not from_background) then
|
tercio@2
|
583 return
|
tercio@2
|
584 end
|
tercio@2
|
585
|
tercio@0
|
586 self:SetSize (1, 1)
|
tercio@0
|
587 for index, button_table in ipairs (LibHotCorners [self.position]) do
|
tercio@1
|
588 if (button_table.widget) then
|
tercio@1
|
589 button_table.widget:Hide()
|
tercio@1
|
590 end
|
tercio@0
|
591 end
|
tercio@2
|
592 for _, button in pairs (LibHotCorners.ItemButtons) do
|
tercio@2
|
593 button:Hide()
|
tercio@2
|
594 end
|
tercio@2
|
595
|
tercio@0
|
596 local OptionsButton = LibHotCorners [self.position].optionsbutton
|
tercio@0
|
597 OptionsButton:Hide()
|
tercio@2
|
598
|
tercio@2
|
599 self.item_frame:Hide()
|
tercio@0
|
600 end
|
tercio@0
|
601
|
tercio@0
|
602 --> quick corner on click
|
tercio@0
|
603 function HotCornersOnQuickClick (self, button)
|
tercio@0
|
604 local parent_position = self:GetParent().position
|
tercio@1
|
605 local func = LibHotCorners.QuickFunctions [parent_position]
|
tercio@1
|
606 if (func) then
|
tercio@1
|
607 func (self, button)
|
tercio@0
|
608 end
|
tercio@0
|
609 end
|
tercio@0
|
610
|
tercio@0
|
611 --> options button onenter
|
tercio@0
|
612 function HotCornersOptionsButtonOnEnter (self)
|
tercio@0
|
613 set_size (self:GetParent())
|
tercio@0
|
614 for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do
|
tercio@0
|
615 if (not LibHotCorners.db.profile.disabled [button_table.name]) then
|
tercio@0
|
616 button_table.widget:Show()
|
tercio@0
|
617 end
|
tercio@0
|
618 end
|
tercio@0
|
619 self:Show()
|
tercio@0
|
620 end
|
tercio@0
|
621
|
tercio@0
|
622 function HotCornersOpenOptions (self)
|
tercio@0
|
623 InterfaceOptionsFrame_OpenToCategory ("HotCorners")
|
tercio@0
|
624 InterfaceOptionsFrame_OpenToCategory ("HotCorners")
|
tercio@0
|
625 end
|
tercio@0
|
626
|
tercio@0
|
627 function HotCornersSetEnabled (state)
|
tercio@0
|
628 LibHotCorners.db.profile.is_enabled = state
|
tercio@0
|
629 end
|
tercio@0
|
630
|
tercio@0
|
631 --> options button onleave
|
tercio@0
|
632 function HotCornersOptionsButtonOnLeave (self)
|
tercio@0
|
633 self:GetParent():GetScript("OnLeave")(self:GetParent())
|
tercio@0
|
634 end
|
tercio@0
|
635
|
tercio@0
|
636 --> button onenter
|
tercio@0
|
637 function HotCornersButtonOnEnter (self)
|
tercio@2
|
638 --set_size (self:GetParent())
|
tercio@2
|
639 --for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do
|
tercio@2
|
640 -- if (not LibHotCorners.db.profile.disabled [button_table.name] and button_table.widget) then
|
tercio@2
|
641 -- button_table.widget:Show()
|
tercio@2
|
642 -- end
|
tercio@2
|
643 --end
|
tercio@0
|
644 show_tooltip (self)
|
tercio@2
|
645 --local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
|
tercio@2
|
646 --OptionsButton:Show()
|
tercio@0
|
647 end
|
tercio@0
|
648
|
tercio@0
|
649 --> button onleave
|
tercio@0
|
650 function HotCornersButtonOnLeave (self)
|
tercio@0
|
651 GameTooltip:Hide()
|
tercio@2
|
652 if (self.table and self.table.onleave) then
|
tercio@0
|
653 self.table.onleave (self)
|
tercio@0
|
654 end
|
tercio@2
|
655 --self:GetParent():GetScript("OnLeave")(self:GetParent())
|
tercio@2
|
656 --local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
|
tercio@2
|
657 --OptionsButton:Hide()
|
tercio@0
|
658 end
|
tercio@0
|
659
|
tercio@0
|
660 --> button onmousedown
|
tercio@0
|
661 function HotCornersButtonOnMouseDown (self, button)
|
tercio@2
|
662 if (self.isItem) then
|
tercio@2
|
663 if (self:GetParent():GetParent().position == "topleft") then
|
tercio@2
|
664 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -3)
|
tercio@2
|
665 end
|
tercio@0
|
666 else
|
tercio@2
|
667 if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
|
tercio@2
|
668 self:SetPoint ("topleft", self:GetParent(), "topleft", 5, self.y - 1)
|
tercio@2
|
669 else
|
tercio@2
|
670 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -6)
|
tercio@2
|
671 end
|
tercio@0
|
672 end
|
tercio@0
|
673 end
|
tercio@0
|
674
|
tercio@0
|
675 --> button onmouseup
|
tercio@0
|
676 function HotCornersButtonOnMouseUp (self, button)
|
tercio@2
|
677 if (self.isItem) then
|
tercio@2
|
678 if (self:GetParent():GetParent().position == "topleft") then
|
tercio@2
|
679 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -2)
|
tercio@2
|
680 end
|
tercio@0
|
681 else
|
tercio@2
|
682 if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
|
tercio@2
|
683 self:SetPoint ("topleft", self:GetParent(), "topleft", 4, self.y)
|
tercio@2
|
684 else
|
tercio@2
|
685 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -4)
|
tercio@2
|
686 end
|
tercio@2
|
687 if (self.table.click) then
|
tercio@2
|
688 local clicks = LibHotCorners.db.profile.clicks
|
tercio@2
|
689 clicks [self.table.name] = clicks [self.table.name] or 0
|
tercio@2
|
690 clicks [self.table.name] = clicks [self.table.name] + 1
|
tercio@2
|
691 self.table.click (self, button)
|
tercio@2
|
692 end
|
tercio@0
|
693 end
|
tercio@2
|
694 end
|
tercio@2
|
695
|
tercio@2
|
696 --> start show animation
|
tercio@2
|
697 function HotCornersStartAnimOnShow (button, axis)
|
tercio@2
|
698 if (axis == "y") then
|
tercio@2
|
699 --button:SetPoint ("topleft", button:GetParent(), "topleft", -32, button.y)
|
tercio@2
|
700 button:SetPoint ("topleft", button:GetParent(), "topleft", 4, button.y)
|
tercio@2
|
701 button.AnimOnShow:Play()
|
tercio@2
|
702
|
tercio@2
|
703 elseif (axis == "item_topleft") then
|
tercio@2
|
704 button:Show()
|
tercio@2
|
705 button.AnimOnShow:Play()
|
tercio@2
|
706
|
tercio@0
|
707 end
|
tercio@0
|
708 end
|
tercio@2
|
709
|
tercio@2
|
710 --> on start / finish show animation
|
tercio@2
|
711 function HotCornersAnimOnShowStarted (button)
|
tercio@2
|
712
|
tercio@2
|
713 end
|
tercio@2
|
714 function HotCornersAnimOnShowFinished (button)
|
tercio@2
|
715 --button:SetPoint ("topleft", button:GetParent(), "topleft", 4, button.y)
|
tercio@2
|
716 button:Show()
|
tercio@2
|
717 --button:SetPoint ("topleft", button:GetParent(), "topleft", -4, button.y)
|
tercio@2
|
718 end
|
tercio@0
|
719
|
tercio@0
|
720 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
721 --> create top left corner
|
tercio@0
|
722
|
tercio@0
|
723 local TopLeftCorner = CreateFrame ("Frame", "LibHotCornersTopLeft", nil, "HotCornersFrameCornerTemplate")
|
tercio@0
|
724 TopLeftCorner:SetPoint ("topleft", UIParent, "topleft", 0, 0)
|
tercio@0
|
725 TopLeftCorner.position = "topleft"
|
tercio@0
|
726
|
tercio@0
|
727 --fast corner button
|
tercio@0
|
728 local QuickClickButton = CreateFrame ("button", "LibHotCornersTopLeftFastButton", TopLeftCorner, "HotCornersQuickCornerButtonTemplate")
|
tercio@0
|
729
|
tercio@0
|
730 --options button
|
tercio@0
|
731 local OptionsButton = CreateFrame ("button", "LibHotCornersTopLeftOptionsButton", TopLeftCorner, "HotCornersOptionsButtonTemplate")
|
tercio@0
|
732
|
tercio@0
|
733 if (debug) then
|
tercio@0
|
734 QuickClickButton:SetSize (20, 20)
|
tercio@0
|
735 QuickClickButton:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]], tile = true, tileSize = 40})
|
tercio@0
|
736 QuickClickButton:SetBackdropColor (1, 0, 0, 1)
|
tercio@0
|
737 end
|
tercio@0
|
738
|
tercio@0
|
739 LibHotCorners.topleft.quickbutton = QuickClickButton
|
tercio@0
|
740 LibHotCorners.topleft.optionsbutton = OptionsButton
|
tercio@0
|
741
|
tercio@0
|
742 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
tercio@0
|
743 --> buttons
|
tercio@0
|
744
|
tercio@0
|
745 function LibHotCorners:CreateAddonWidget (frame, button_table, index, side)
|
tercio@0
|
746
|
tercio@0
|
747 --> create the button
|
tercio@0
|
748 local button = CreateFrame ("button", "LibHotCorners" .. side .. button_table.fname, frame, "HotCornersButtonTemplate")
|
tercio@0
|
749
|
tercio@0
|
750 --> write some attributes
|
tercio@0
|
751 button.index = index
|
tercio@0
|
752 button.table = button_table
|
tercio@0
|
753 button.parent = frame
|
tercio@0
|
754 button_table.widget = button
|
tercio@0
|
755
|
tercio@0
|
756 --> set the icon
|
tercio@0
|
757 button:SetNormalTexture (button_table.icon)
|
tercio@0
|
758 button:SetHighlightTexture (button_table.icon)
|
tercio@0
|
759
|
tercio@0
|
760 if (string.lower (button_table.icon):find ([[\icons\]])) then
|
tercio@0
|
761 button:GetNormalTexture():SetTexCoord (0.078125, 0.9375, 0.078125, 0.9375)
|
tercio@0
|
762 button:GetHighlightTexture():SetTexCoord (0.078125, 0.9375, 0.078125, 0.9375)
|
tercio@0
|
763 end
|
tercio@0
|
764
|
tercio@0
|
765 return button
|
tercio@0
|
766 end |