annotate HotCorners.lua @ 12:6c1cc07c389d

- added potion ids for legion.
author Tercio
date Thu, 29 Dec 2016 14:14:57 -0200
parents 371e14cd2feb
children fc72b86a3b66
rev   line source
tercio@0 1 LibHotCorners = LibStub ("AceAddon-3.0"):NewAddon ("HotCorners", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")
tercio@1 2 _G.HotCorners = LibHotCorners
tercio@0 3 local LibHotCorners = LibHotCorners
tercio@0 4
tercio@0 5 local LBD = LibStub ("LibDataBroker-1.1")
tercio@0 6
tercio@0 7 local debug = false
tercio@0 8 local tinsert = tinsert
tercio@0 9
tercio@0 10 local default_db = {
tercio@0 11 profile = {
tercio@0 12 is_enabled = true,
tercio@0 13 topleft_enabled = true,
tercio@1 14 topleft_quickfunc = false,
tercio@0 15 clicks = {},
tercio@0 16 disabled = {}
tercio@0 17 },
tercio@0 18 }
tercio@0 19
tercio@1 20 LibHotCorners.RegistredQuickFunctions = {}
tercio@1 21 LibHotCorners.QuickFunctions = {topleft = false}
tercio@1 22
Tercio@7 23 LibHotCorners.LastItemButtonClick = GetTime()
Tercio@7 24
tercio@0 25 function LibHotCorners:OnEnable()
tercio@0 26
tercio@0 27 end
tercio@0 28
tercio@0 29 function LibHotCorners:OnDisable()
tercio@0 30
tercio@0 31 end
tercio@0 32
tercio@2 33 LibHotCorners.ItemButtons = {}
tercio@2 34 LibHotCorners.ItemOnInventory = {}
tercio@2 35
tercio@0 36 local refresh_topleft = function()
tercio@0 37 LibHotCorners ["topleft"].is_enabled = LibHotCorners.db.profile.topleft_enabled
tercio@0 38 end
tercio@0 39
tercio@0 40 local OptionsTable = {
tercio@0 41 name = "HotCorners",
tercio@0 42 type = "group",
tercio@0 43 args = {
tercio@0 44 Enabled = {
tercio@0 45 type = "toggle",
tercio@0 46 name = "Enabled",
tercio@0 47 desc = "Enable or Disable this addon.",
tercio@0 48 order = 1,
tercio@0 49 get = function() return LibHotCorners.db.profile.is_enabled end,
tercio@0 50 set = function (self, val) LibHotCorners.db.profile.is_enabled = not LibHotCorners.db.profile.is_enabled; --[[ do something]] end,
tercio@0 51 },
tercio@0 52 TopLeftEnabled = {
tercio@0 53 type = "toggle",
tercio@0 54 name = "Top Left",
tercio@0 55 desc = "Enable or Disable the Top Left bar.",
tercio@0 56 order = 2,
tercio@0 57 get = function() return LibHotCorners.db.profile.topleft_enabled end,
tercio@0 58 set = function (self, val) LibHotCorners.db.profile.topleft_enabled = not LibHotCorners.db.profile.topleft_enabled; refresh_topleft() end,
tercio@0 59 },
tercio@1 60 QuickClickFunc = {
tercio@1 61 type = "select",
tercio@1 62 name = "Quick Click",
tercio@1 63 desc = "Select the behavior when clicking over the absolute topleft corner.",
tercio@1 64 values = function()
tercio@1 65 local options = {}
tercio@1 66 for index, quickfunc in ipairs (LibHotCorners.RegistredQuickFunctions) do
tercio@1 67 options [quickfunc.name] = quickfunc.name
tercio@1 68 end
tercio@1 69 return options
tercio@1 70 end,
tercio@1 71 get = function() return LibHotCorners.db.profile.topleft_quickfunc or "" end,
tercio@1 72 set = function (self, funcname)
tercio@1 73 LibHotCorners.db.profile.topleft_quickfunc = funcname;
tercio@1 74 for index, quickfunc in ipairs (LibHotCorners.RegistredQuickFunctions) do
tercio@1 75 if (quickfunc.name == funcname) then
tercio@1 76 LibHotCorners.QuickFunctions.topleft = quickfunc.func
tercio@1 77 break
tercio@1 78 end
tercio@1 79 end
tercio@1 80 end,
tercio@1 81 order = 4,
tercio@1 82 }
tercio@0 83 }
tercio@0 84 }
tercio@0 85
tercio@0 86 function LibHotCorners:OnInitialize()
tercio@0 87
tercio@0 88 --declarar primeiro o db usando a global que é declarada no toc.
tercio@0 89 self.db = LibStub ("AceDB-3.0"):New ("HotCornersDB", default_db, true)
tercio@0 90
tercio@0 91 --declara agora as opções da tab raiz
tercio@0 92 LibStub("AceConfig-3.0"):RegisterOptionsTable ("HotCorners", OptionsTable)
tercio@0 93 LibHotCorners.OptionsFrame1 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("HotCorners", "HotCorners")
tercio@0 94 --sub tab
tercio@0 95 LibStub ("AceConfig-3.0"):RegisterOptionsTable ("HotCorners-Profiles", LibStub ("AceDBOptions-3.0"):GetOptionsTable (self.db))
tercio@0 96 LibHotCorners.OptionsFrame2 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("HotCorners-Profiles", "Profiles", "HotCorners")
tercio@0 97
tercio@0 98 LibHotCorners ["topleft"].is_enabled = self.db.topleft_enabled
tercio@0 99 refresh_topleft()
tercio@0 100
tercio@0 101 SLASH_HOTCORNER1, SLASH_HOTCORNER2 = "/hotcorners", "/hotcorner"
tercio@0 102 function SlashCmdList.HOTCORNER (msg, editbox)
tercio@0 103 HotCornersOpenOptions (self);
tercio@0 104 end
tercio@0 105
tercio@0 106 for name, dataobj in LBD:DataObjectIterator() do
tercio@0 107 if (dataobj.type and dataobj.icon and dataobj.OnClick) then
tercio@0 108 LibHotCorners:RegisterHotCornerButton (name, "TopLeft", nil, name .. "HotCornerLauncher", dataobj.icon, dataobj.OnTooltipShow, dataobj.OnClick, nil, nil, dataobj.OnEnter, dataobj.OnLeave)
tercio@0 109 end
tercio@0 110 end
tercio@0 111 for k, v in pairs (LBD.attributestorage) do
tercio@0 112 --print (k, v)
tercio@0 113 --print ("----------------")
tercio@0 114 --vardump (v)
tercio@0 115 end
tercio@0 116
tercio@0 117 end
tercio@0 118
tercio@0 119 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tercio@0 120 --> main function
tercio@0 121
tercio@0 122 LibHotCorners.embeds = LibHotCorners.embeds or {}
tercio@0 123 local embed_functions = {
tercio@0 124 "RegisterHotCornerButton",
tercio@0 125 "HideHotCornerButton",
tercio@0 126 }
tercio@0 127
tercio@0 128 function LibHotCorners:Embed (target)
tercio@0 129 for k, v in pairs (embed_functions) do
tercio@0 130 target[v] = self[v]
tercio@0 131 end
tercio@0 132 self.embeds [target] = true
tercio@0 133 return target
tercio@0 134 end
tercio@0 135
tercio@0 136 local CallbackHandler = LibStub:GetLibrary ("CallbackHandler-1.0")
tercio@0 137 LibHotCorners.callbacks = LibHotCorners.callbacks or CallbackHandler:New (LibHotCorners)
tercio@0 138
tercio@0 139 LibHotCorners.topleft = LibHotCorners.topleft or {widgets = {}, quickclick = false, is_enabled = false, map = {}}
tercio@0 140 LibHotCorners.bottomleft = {}
tercio@0 141 LibHotCorners.topright = {}
tercio@0 142 LibHotCorners.bottomright = {}
tercio@0 143
tercio@0 144 local function test (corner)
tercio@0 145 assert (corner == "topleft" or corner == "bottomleft" or corner == "topright" or corner == "bottomright", "LibHotCorners:RegisterAddon expects a corner on #1 argument.")
tercio@0 146 end
tercio@0 147
tercio@1 148 function LibHotCorners:AddQuickFunction (quickfunc, corner)
tercio@1 149
tercio@1 150 local current_quickfunc = LibHotCorners.db.profile [corner .. "_quickfunc"] or ""
tercio@1 151
tercio@1 152 --> passed only one table
tercio@1 153 if (quickfunc.name) then
tercio@1 154 --> check if already exists
tercio@1 155 local already_exists = false
tercio@1 156 for _, registred in ipairs (LibHotCorners.RegistredQuickFunctions) do
tercio@1 157 if (registred.name == quickfunc.name) then
tercio@1 158 registred.func = quickfunc.func
tercio@1 159 if (current_quickfunc == quickfunc.name) then
tercio@1 160 LibHotCorners.QuickFunctions [corner] = quickfunc.func
tercio@1 161 end
tercio@1 162 already_exists = true
tercio@1 163 break
tercio@1 164 end
tercio@1 165 end
tercio@1 166 --> add table
tercio@1 167 if (not already_exists) then
tercio@1 168 table.insert (LibHotCorners.RegistredQuickFunctions, quickfunc)
tercio@1 169 if (current_quickfunc == quickfunc.name) then
tercio@1 170 LibHotCorners.QuickFunctions [corner] = quickfunc.func
tercio@1 171 end
tercio@1 172 end
tercio@1 173 --> check if there is a quickfunc to be use
tercio@1 174 if (current_quickfunc == "") then
tercio@1 175 LibHotCorners.db.profile [corner .. "_quickfunc"] = quickfunc.name
tercio@1 176 LibHotCorners.QuickFunctions [corner] = quickfunc.func
tercio@1 177 end
tercio@1 178 else
tercio@1 179 --> passed a table of tables
tercio@1 180 for _, this_quickfunc in ipairs (quickfunc) do
tercio@1 181 --> check if already exists
tercio@1 182 local already_exists = false
tercio@1 183 for _, registred in ipairs (LibHotCorners.RegistredQuickFunctions) do
tercio@1 184 if (registred.name == this_quickfunc.name) then
tercio@1 185 registred.func = this_quickfunc.func
tercio@1 186 if (current_quickfunc == this_quickfunc.name) then
tercio@1 187 LibHotCorners.QuickFunctions [corner] = this_quickfunc.func
tercio@1 188 end
tercio@1 189 already_exists = true
tercio@1 190 break
tercio@1 191 end
tercio@1 192 end
tercio@1 193 --> add table
tercio@1 194 if (not already_exists) then
tercio@1 195 table.insert (LibHotCorners.RegistredQuickFunctions, this_quickfunc)
tercio@1 196 if (current_quickfunc == this_quickfunc.name) then
tercio@1 197 LibHotCorners.QuickFunctions [corner] = this_quickfunc.func
tercio@1 198 end
tercio@1 199 end
tercio@1 200 --> check if there is a quickfunc to be use
tercio@1 201 if (current_quickfunc == "") then
tercio@1 202 LibHotCorners.db.profile [corner .. "_quickfunc"] = this_quickfunc.name
tercio@1 203 LibHotCorners.QuickFunctions [corner] = this_quickfunc.func
tercio@1 204 current_quickfunc = this_quickfunc.name
tercio@1 205 end
tercio@1 206 end
tercio@1 207 end
tercio@1 208
tercio@1 209 end
tercio@1 210
tercio@1 211 function LibHotCorners:RegisterHotCornerButton (name, corner, optionstable, fname, icon, tooltip, clickfunc, menus, quickfunc, onenter, onleave, is_install)
tercio@0 212 corner = string.lower (corner)
tercio@0 213 test (corner)
tercio@0 214
tercio@1 215 optionstable = optionstable or {hide = false}
tercio@1 216
tercio@0 217 if (is_install) then
tercio@0 218 --> overwrite if already exists a widget
tercio@0 219 for i, widget in ipairs (LibHotCorners [corner]) do
tercio@0 220 if (widget.name == name) then
tercio@0 221 table.remove (LibHotCorners [corner], i)
tercio@1 222 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 223 if (quickfunc) then
tercio@1 224 LibHotCorners:AddQuickFunction (quickfunc, corner)
tercio@1 225 end
tercio@0 226 return LibHotCorners [corner].map [name]
tercio@0 227 end
tercio@0 228 end
tercio@1 229 --> add
tercio@1 230 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 231 LibHotCorners [corner].map [name] = #LibHotCorners [corner]
tercio@1 232 if (quickfunc) then
tercio@1 233 LibHotCorners:AddQuickFunction (quickfunc, corner)
tercio@1 234 end
tercio@0 235 return LibHotCorners [corner].map [name]
tercio@0 236 else
tercio@1 237 --> check if already exists
tercio@1 238 for i, widget in ipairs (LibHotCorners [corner]) do
tercio@1 239 if (widget.name == name) then
tercio@1 240 return
tercio@0 241 end
tercio@0 242 end
tercio@1 243 --> add
tercio@1 244 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 245 LibHotCorners [corner].map [name] = #LibHotCorners [corner]
tercio@1 246 if (quickfunc) then
tercio@1 247 LibHotCorners:AddQuickFunction (quickfunc, corner)
tercio@0 248 end
tercio@1 249 return LibHotCorners [corner].map [name]
tercio@0 250 end
tercio@0 251 end
tercio@0 252
tercio@0 253 function LibHotCorners:HideHotCornerButton (name, corner, value)
tercio@0 254
tercio@0 255 corner = string.lower (corner)
tercio@0 256 test (corner)
tercio@0 257
tercio@0 258 local corner_table = LibHotCorners [corner]
tercio@0 259 local addon_table = corner_table [corner_table.map [name]]
tercio@0 260
tercio@1 261 if (addon_table) then
tercio@1 262 addon_table.optionstable.hide = value
tercio@1 263 end
tercio@0 264
tercio@0 265 LibHotCorners [corner].is_enabled = false
tercio@0 266
tercio@1 267 for index, button_table in ipairs (corner_table) do
tercio@1 268 if (not button_table.optionstable.hide) then
tercio@0 269 LibHotCorners [corner].is_enabled = true
tercio@0 270 break
tercio@0 271 end
tercio@0 272 end
tercio@0 273
tercio@0 274 return true
tercio@0 275 end
tercio@0 276
tercio@0 277 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tercio@0 278 --> data broker stuff
tercio@0 279 function LibHotCorners:DataBrokerCallback (event, name, dataobj)
tercio@0 280 if (not name or not dataobj or not dataobj.type) then
tercio@0 281 return
tercio@0 282 end
tercio@0 283 if (dataobj.icon and dataobj.OnClick) then
tercio@0 284 LibHotCorners:RegisterHotCornerButton (name, "TopLeft", nil, name .. "HotCornerLauncher", dataobj.icon, dataobj.OnTooltipShow, dataobj.OnClick, nil, nil, dataobj.OnEnter, dataobj.OnLeave)
tercio@0 285 end
tercio@0 286 end
tercio@0 287 LBD.RegisterCallback (LibHotCorners, "DataBrokerCallback")
tercio@0 288
tercio@0 289 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tercio@0 290 --> scripts
tercio@0 291
tercio@0 292 --> background (window mode fix)
tercio@0 293 function HotCornersBackgroundOnEnter (self)
tercio@0 294 if (LibHotCornersTopLeft and LibHotCornersTopLeft:IsShown()) then
tercio@0 295 if (LibHotCornersTopLeft:GetWidth() > 2) then
tercio@2 296 HotCornersOnLeave (LibHotCornersTopLeft, true)
tercio@0 297 end
tercio@0 298 end
tercio@0 299 self:EnableMouse (false)
tercio@0 300 end
tercio@0 301
tercio@0 302 --> set size
tercio@0 303 local function set_size (self)
tercio@0 304 if (self.position == "topleft" or self.position == "topright") then
tercio@0 305 self:SetSize (40, GetScreenHeight())
tercio@0 306 else
tercio@0 307 self:SetSize (GetScreenWidth(), 40)
tercio@0 308 end
tercio@0 309 end
tercio@0 310
tercio@0 311 --> show tooltip
tercio@0 312 local show_tooltip = function (self)
tercio@2 313 if (self.table and self.table.tooltip) then
tercio@0 314 if (type (self.table.tooltip) == "function") then
tercio@0 315 GameTooltip:SetOwner (self, "ANCHOR_RIGHT")
tercio@0 316 self.table.tooltip (GameTooltip)
tercio@0 317 GameTooltip:Show()
tercio@0 318 elseif (type (self.table.tooltip) == "string") then
tercio@0 319 GameTooltip:SetOwner (self, "ANCHOR_RIGHT")
tercio@0 320 GameTooltip:AddLine (self.table.tooltip)
tercio@0 321 GameTooltip:Show()
tercio@0 322 end
tercio@2 323 elseif (self.table and self.table.onenter) then
tercio@0 324 self.table.onenter (self)
tercio@2 325 elseif (self.isItem) then
tercio@2 326 GameTooltip:SetOwner (self, "ANCHOR_BOTTOMRIGHT")
tercio@2 327 GameTooltip:SetHyperlink (self.itemtable[4])
tercio@2 328 GameTooltip:Show()
tercio@0 329 end
tercio@0 330 end
tercio@0 331
tercio@0 332 --> corner frame on enter
tercio@0 333 local more_clicked = function (t1, t2)
tercio@0 334 return t1[1] > t2[1]
tercio@0 335 end
tercio@0 336
tercio@2 337 LibHotCorners.BackPackItemList = {
tercio@2 338
tercio@2 339 --> alchemy
Tercio@7 340
Tercio@7 341 --MOP
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@7 368
Tercio@7 369 --WOD
Tercio@7 370 [118704] = true, --Pure Rage Potion
Tercio@7 371 [109156] = true, --Greater Draenic Strength Flask
Tercio@7 372 [109160] = true, --Greater Draenic Stamina Flask
Tercio@7 373 [109155] = true, --Greater Draenic Intellect Flask
Tercio@7 374 [109153] = true, --Greater Draenic Agility Flask
Tercio@7 375 [118711] = true, --Draenic Water Walking Elixir
Tercio@7 376 [116271] = true, --Draenic Water Breathing Elixir
Tercio@7 377 [116266] = true, --Draenic Swiftness Potion
Tercio@7 378 [109219] = true, --Draenic Strength Potion
Tercio@7 379 [109148] = true, --Draenic Strength Flask
Tercio@7 380 [109152] = true, --Draenic Stamina Flask
Tercio@7 381 [109226] = true, --Draenic Rejuvenation Potion
Tercio@7 382 [109222] = true, --Draenic Mana Potion
Tercio@7 383 [116276] = true, --Draenic Living Action Potion
Tercio@7 384 [116268] = true, --Draenic Invisibility Potion
Tercio@7 385 [109218] = true, --Draenic Intellect Potion
Tercio@7 386 [109147] = true, --Draenic Intellect Flask
Tercio@7 387 [109221] = true, --Draenic Channeled Mana Potion
Tercio@7 388 [109220] = true, --Draenic Armor Potion
Tercio@7 389 [109217] = true, --Draenic Agility Potion
Tercio@7 390 [109145] = true, --Draenic Agility Flask
Tercio@7 391 [112090] = true, --Transmorphic Tincture
Tercio@7 392
tercio@2 393 --> cooking
Tercio@7 394 --WOD
Tercio@7 395 [111449] = true, --Blackrock Barbecue
Tercio@7 396 [111433] = true, --Blackrock Ham
Tercio@7 397 [111436] = true, --Braised Riverbeast
Tercio@7 398 [122348] = true, --Buttered Sturgeon
Tercio@7 399 [111453] = true, --Calamari Crepes
Tercio@7 400 [111438] = true, --Clefthoof Sausages
Tercio@7 401 [126935] = true, --Fancy Darkmoon Feast
Tercio@7 402 [111444] = true, --Fat Sleeper Cakes
Tercio@7 403 [111457] = true, --Feast of Blood
Tercio@7 404 [111458] = true, --Feast of the Waters
Tercio@7 405 [111445] = true, --Fiery Calamari
Tercio@7 406 [111450] = true, --Frosty Stew
Tercio@7 407 [111454] = true, --Gorgrond Chowder
Tercio@7 408 [111441] = true, --Grilled Gulper
Tercio@7 409 [111456] = true, --Grilled Saberfish
Tercio@7 410 [111431] = true, --Hearty Elekk Steak
Tercio@7 411 [122346] = true, --Jumbo Sea Dog
Tercio@7 412 [126934] = true, --Lemon Herb Filet
Tercio@7 413 [111434] = true, --Pan-Seared Talbuk
Tercio@7 414 [122345] = true, --Pickled Eel
Tercio@7 415 [111437] = true, --Rylak Crepes
Tercio@7 416 [111455] = true, --Saberfish Broth
Tercio@7 417 [122344] = true, --Salty Squid Roll
Tercio@7 418 [111446] = true, --Skulker Chowder
Tercio@7 419 [111452] = true, --Sleeper Surprise
Tercio@7 420 [122343] = true, --Sleeper Sushi
Tercio@7 421 [111439] = true, --Steamed Scorpion
Tercio@7 422 [111442] = true, --Sturgeon Stew
Tercio@7 423 [126936] = true, --Sugar-Crusted Fish Feast
Tercio@7 424 [111447] = true, --Talador Surf and Turf
Tercio@7 425 [122347] = true, --Whiptail Fillet
Tercio@7 426 --[] = true, --
Tercio@7 427 --MOP
Tercio@7 428 --Way of the Grill: Strength
tercio@2 429 [74642] = true, -- Charbroiled Tiger Steak
tercio@2 430 [74645] = true, -- Eternal Blossom Fish
tercio@2 431 [74646] = true, -- Black Pepper Ribs and Shrimp
tercio@2 432
tercio@2 433 --Way of the Oven: Stamina
tercio@2 434 [74654] = true, -- Wildfowl Roast
tercio@2 435 [74655] = true, -- Twin Fish Platter
tercio@2 436 [74656] = true, -- Chun Tian Spring Rolls
tercio@2 437
tercio@2 438 --Way of the Pot: Intellect
tercio@2 439
tercio@2 440 [74644] = true, -- Swirling Mist Soup
tercio@2 441 [74649] = true, -- Braised Turtle
tercio@2 442 [74650] = true, -- Mogu Fish Stew
tercio@2 443
tercio@2 444 --Way of the Steamer: Spirit
tercio@2 445
tercio@2 446 [74651] = true, -- Shrimp Dumplings
tercio@2 447 [74652] = true, -- Fire Spirit Salmon
tercio@2 448 [74653] = true, -- Steamed Crab Surprise
tercio@2 449
tercio@2 450 --Way of the Wok: Agility
tercio@2 451
tercio@2 452 [74643] = true, -- Sauteed Carrots
tercio@2 453 [74647] = true, -- Valley Stir Fry
tercio@2 454 [74648] = true, -- Sea Mist Rice Noodles
tercio@2 455
tercio@2 456 --Way of the Brew: Headaches and Grandeur
tercio@2 457
tercio@2 458 [74626] = true, -- Ginseng Tea
tercio@2 459 [74637] = true, -- Jade Witch Brew
tercio@2 460 [74638] = true, -- Mad Brewer's Breakfast
tercio@2 461
tercio@2 462 --General Cooking
tercio@2 463
tercio@2 464 [74641] = true, -- Fish Cake
tercio@2 465 [74636] = true, -- Golden Carp Consomme
tercio@2 466 [86070] = true, -- Wildfowl Ginseng Soup
tercio@2 467 [86069] = true, -- Rice Pudding
tercio@2 468 [86074] = true, -- Spicy Vegetable Chips
tercio@2 469 [86073] = true, -- Spicy Salmon
tercio@2 470
tercio@2 471 --5.4 Recipes
tercio@2 472
tercio@2 473 [145308] = true, -- Mango Ice
tercio@2 474 [145309] = true, -- Farmer's Delight
tercio@2 475 [145311] = true, -- Fluffy Silkfeather Omelet
tercio@2 476 [145310] = true, -- Stuffed Lushrooms
tercio@2 477 [145307] = true, -- Spiced Blossom Soup
tercio@2 478 [145305] = true, -- Seasoned Pomfruit Slices
tercio@2 479
tercio@2 480 --Cart Kits
tercio@2 481 [101630] = true, -- Noodle Cart Kit
tercio@2 482 [101661] = true, -- Deluxe Noodle Cart Kit
tercio@2 483 [101662] = true, -- Pandaren Treasure Noodle Cart Kit
tercio@2 484
tercio@2 485 [101618] = true, -- Pandaren Treasure Noodle Soup
tercio@2 486 [101617] = true, -- Deluxe Noodle Soup
tercio@2 487 [101616] = true, -- Noodle Soup
Tercio@12 488
Tercio@12 489
Tercio@12 490 --LEGION
Tercio@12 491 [188028] = true, --Potion of the Old War
Tercio@12 492 [188027] = true, --Potion of Deadly Grace
Tercio@12 493 [188029] = true, --Unbending Potion
Tercio@12 494 [188017] = true, --Ancient Mana Potion
Tercio@12 495 [188030] = true, --Leytorrent Potion
Tercio@12 496 [229206] = true, --Potion of Prolongued Power
Tercio@12 497
Tercio@12 498
Tercio@12 499
tercio@2 500 }
tercio@2 501
tercio@0 502 function HotCornersOnEnter (self)
tercio@0 503
tercio@0 504 if (not LibHotCorners.db.profile.is_enabled) then
tercio@0 505 return
tercio@0 506 end
tercio@0 507
tercio@0 508 if (not LibHotCorners.db.profile [self.position .. "_enabled"]) then
tercio@0 509 return
tercio@0 510 end
tercio@0 511
tercio@2 512 if (self:GetWidth() < 1.1 and self:GetHeight() < 1.1) then
tercio@2 513 --print ("abrindo...")
tercio@2 514 end
tercio@2 515
tercio@0 516 set_size (self)
tercio@0 517
tercio@0 518 HotCornersBackgroundFrame:EnableMouse (true)
tercio@2 519 self.item_frame:Show()
tercio@0 520
tercio@0 521 local i = 1
tercio@0 522
tercio@0 523 local sort = {}
tercio@0 524 local clicks = LibHotCorners.db.profile.clicks
tercio@0 525 for index, button_table in ipairs (LibHotCorners [self.position]) do
tercio@0 526 tinsert (sort, {clicks [button_table.name] or 0, button_table})
tercio@0 527 end
tercio@0 528 table.sort (sort, more_clicked)
tercio@0 529
tercio@0 530 local last_button
tercio@0 531
tercio@0 532 local disabled = LibHotCorners.db.profile.disabled
tercio@0 533
tercio@0 534 for index, button_table in ipairs (sort) do
tercio@0 535 button_table = button_table [2]
tercio@0 536 if (not button_table.widget) then
tercio@0 537 LibHotCorners:CreateAddonWidget (self, button_table, index, self.position)
tercio@0 538 end
tercio@0 539
tercio@0 540 button_table.widget:ClearAllPoints()
tercio@0 541
tercio@1 542 if (not disabled [button_table.name] and not button_table.optionstable.hide) then
tercio@0 543 if (self.position == "topleft" or self.position == "topright") then
tercio@2 544
tercio@0 545 local y = i * 35 * -1
tercio@2 546 --button_table.widget:SetPoint ("topleft", self, "topleft", 4, y)
tercio@0 547 button_table.widget.y = y
tercio@2 548 HotCornersStartAnimOnShow (button_table.widget, "y")
tercio@2 549
tercio@2 550 else --bottom left / bottom right
tercio@0 551 local x = i * 35
tercio@0 552 button_table.widget:SetPoint ("topleft", self, "topleft", x, -4)
tercio@0 553 button_table.widget.x = x
tercio@0 554 end
tercio@0 555
tercio@0 556 button_table.widget:Show()
tercio@0 557 last_button = button_table.widget
tercio@0 558
tercio@0 559 i = i + 1
tercio@0 560 else
tercio@0 561 button_table.widget:Hide()
tercio@0 562 end
tercio@0 563 end
tercio@0 564
tercio@0 565 local OptionsButton = LibHotCorners [self.position].optionsbutton
tercio@0 566 local y = i * 35 * -1
tercio@0 567 OptionsButton:SetPoint ("top", self, "top", 0, y)
tercio@0 568 OptionsButton:Show()
tercio@0 569
tercio@2 570 --item frame
tercio@2 571 LibHotCorners:RefereshItems (self)
tercio@2 572
Tercio@11 573 --self.AnimOnShow:Play()
tercio@3 574 HotCornersInfosFrame:Show()
tercio@3 575 HotCornersInfosFrame:SetAlpha (0)
Tercio@11 576 --HotCornersInfosFrame.AnimOnShow:Play()
tercio@3 577
tercio@3 578 --update repair
tercio@3 579 local percent, items = 0, 0
tercio@3 580 for i = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
tercio@3 581 local durability, maxdurability = GetInventoryItemDurability (i)
tercio@3 582 if (durability and maxdurability) then
tercio@3 583 local p = durability / maxdurability * 100
tercio@3 584 percent = percent + p
tercio@3 585 items = items + 1
tercio@3 586 end
tercio@3 587 end
tercio@3 588
tercio@3 589 if (items == 0) then
tercio@3 590 HotCornersInfosFrame.repairText:SetText ("-- %")
tercio@3 591 end
tercio@3 592
tercio@3 593 percent = percent / items
tercio@3 594 HotCornersInfosFrame.repairText:SetText (math.floor (percent) .. "%")
tercio@3 595
tercio@3 596 --update date
tercio@3 597 HotCornersInfosFrame.clockText:SetText (date ("%H:%M"))
tercio@3 598 HotCornersInfosFrame.dayText:SetText (date ("%A\n%B %d"))
tercio@3 599
tercio@3 600 --update money
tercio@3 601 local money = GetMoney()
tercio@3 602 HotCornersInfosFrame.goldText:SetText (math.floor (money / 100 / 100))
tercio@3 603 HotCornersInfosFrame.silverText:SetText (math.floor ((money / 100) % 100))
tercio@3 604 HotCornersInfosFrame.bronzeText:SetText (math.floor (money % 100))
tercio@3 605
tercio@3 606 --HotCornersInfosFrame.clockText:SetText (date ("%A %B %d %H:%M:%S %Y"))
tercio@3 607
tercio@0 608 end
tercio@0 609
tercio@2 610 function LibHotCorners:RefereshItems (self)
tercio@2 611
Tercio@7 612 if (HotCornersItemUsed and LibHotCorners.LastItemButtonClick < GetTime() and not self) then
Tercio@7 613 for _, button in pairs (LibHotCorners.ItemButtons) do
Tercio@7 614 if (not button.itemtable[6]) then --> isn't a profession cooldown
Tercio@7 615 button.cooldown:SetCooldown (GetTime(), 1.5)
Tercio@7 616 end
Tercio@7 617 end
Tercio@7 618 HotCornersItemUsed = nil
Tercio@7 619 LibHotCorners.LastItemButtonClick = GetTime()+1.5
Tercio@7 620 end
Tercio@7 621
tercio@2 622 if (not self) then
tercio@2 623 return LibHotCorners:ScheduleTimer ("RefereshItems", 1, LibHotCornersTopLeft)
tercio@2 624 end
tercio@2 625
tercio@2 626 if (not UnitAffectingCombat ("player") and not InCombatLockdown()) then
tercio@2 627 for itemId, itemTable in pairs (LibHotCorners.ItemOnInventory) do
tercio@2 628 itemTable [1] = 0
tercio@2 629 end
tercio@2 630
tercio@2 631 for bagID = 0, 4 do
tercio@2 632 local numItems = GetContainerNumSlots (bagID)
tercio@2 633 for slot = 1, numItems do
tercio@2 634 local itemId = GetContainerItemID (bagID, slot)
tercio@2 635 if (LibHotCorners.BackPackItemList [itemId]) then
tercio@2 636 local texture, itemCount, locked, quality, readable, lootable, itemLink = GetContainerItemInfo (bagID, slot)
tercio@2 637 if (not LibHotCorners.ItemOnInventory [itemId]) then
tercio@2 638 LibHotCorners.ItemOnInventory [itemId] = {itemCount, texture, quality, itemLink, itemId}
tercio@2 639 else
tercio@2 640 LibHotCorners.ItemOnInventory [itemId] [1] = LibHotCorners.ItemOnInventory [itemId] [1] + itemCount
tercio@2 641 end
tercio@2 642 end
tercio@2 643 end
tercio@2 644 end
tercio@2 645
tercio@2 646 local index = 1
tercio@2 647 for itemId, itemTable in pairs (LibHotCorners.ItemOnInventory) do
tercio@2 648 local itemCount, texture, quality, itemLink = unpack (itemTable)
tercio@2 649
tercio@2 650 local item_button = LibHotCorners:GetItemButton (index, self)
tercio@2 651 if (item_button) then
tercio@2 652 item_button:SetNormalTexture (texture)
tercio@2 653 item_button:SetHighlightTexture (texture)
tercio@2 654 item_button:SetPushedTexture (texture)
tercio@2 655
tercio@2 656 item_button.item_count:SetText (itemCount or 0)
Tercio@7 657 item_button:SetAttribute ("macrotext", "/use " .. GetItemInfo (itemId) .. ";\n/script HotCornersItemUsed=GetTime(); HotCorners:RefereshItems()")
tercio@2 658
tercio@2 659 item_button.itemtable = itemTable
tercio@2 660
tercio@2 661 if (not item_button:IsShown() or item_button:GetAlpha() < 1) then
Tercio@11 662 -- HotCornersStartAnimOnShow (item_button, "item_topleft")
tercio@2 663 end
tercio@2 664 end
Tercio@7 665 index = index + 1
tercio@2 666 end
Tercio@7 667
Tercio@7 668 LibHotCorners:RefereshProfessions (self, index)
tercio@2 669
tercio@2 670 end
tercio@2 671 --/run local itemid=GetContainerItemID (0, 1);print (itemid)
tercio@2 672 --UseContainerItem(bagID, slot[, onSelf])
Tercio@7 673 end
Tercio@7 674
Tercio@7 675 local get_profession = function (icon)
Tercio@7 676 if (icon:find ("Trade_Engineering")) then
Tercio@7 677 return "en"
Tercio@7 678 elseif (icon:find ("Trade_LeatherWorking")) then
Tercio@7 679 return "lw"
Tercio@7 680 elseif (icon:find ("Trade_Tailoring")) then
Tercio@7 681 return "tl"
Tercio@7 682 elseif (icon:find ("Trade_Engraving")) then
Tercio@7 683 return "ec"
Tercio@7 684 elseif (icon:find ("Trade_BlackSmithing")) then
Tercio@7 685 return "bs"
Tercio@7 686 elseif (icon:find ("Trade_Alchemy")) then
Tercio@7 687 return "al"
Tercio@7 688 elseif (icon:find ("INV_Misc_Gem_01")) then
Tercio@7 689 return "jc"
Tercio@7 690 elseif (icon:find ("INV_Inscription_Tradeskill01")) then
Tercio@7 691 return "in"
Tercio@7 692 end
Tercio@7 693 end
Tercio@7 694 local secrets_index = {
Tercio@7 695 ["tl"] = 176058, --tailoring
Tercio@7 696 ["ec"] = 177043, --enchanting
Tercio@7 697 ["lw"] = 176089, --letherwork
Tercio@7 698 ["en"] = 177054, --engeener
Tercio@7 699 ["bs"] = 176090, --blacksmith
Tercio@7 700 ["al"] = 175880, --alchemy
Tercio@7 701 ["jc"] = 176087, --jewelcraft
Tercio@7 702 ["in"] = 177045, --inscription
Tercio@7 703 }
Tercio@7 704 local secrets_icons = {
Tercio@7 705 ["tl"] = "inv_misc_book_03", --tailoring
Tercio@7 706 ["ec"] = "inv_misc_book_08", --enchant
Tercio@7 707 ["al"] = "inv_misc_book_08", -- alchemy
Tercio@7 708 ["bs"] = "inv_misc_book_11", --bs
Tercio@7 709 ["en"] = "inv_misc_book_08", --engeener
Tercio@7 710 ["in"] = "inv_misc_book_08", --inscritp
Tercio@7 711 ["jc"] = "inv_misc_book_10", --jc
Tercio@7 712 ["lw"] = "inv_misc_book_09", --lw
Tercio@7 713 }
Tercio@7 714
Tercio@7 715 function LibHotCorners:RefereshProfessions (self, index)
Tercio@7 716
Tercio@7 717 index = index + 1
Tercio@7 718
Tercio@7 719 local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions()
Tercio@7 720
Tercio@7 721 if (prof1) then
Tercio@7 722 local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier, specializationIndex, specializationOffset = GetProfessionInfo (prof1)
Tercio@7 723 local prof = get_profession (icon)
Tercio@7 724 local secrets_spellID = secrets_index [prof]
Tercio@7 725 if (secrets_spellID) then
Tercio@7 726 local name, _, texture = GetSpellInfo (secrets_spellID)
Tercio@7 727 texture = "Interface\\Icons\\" .. secrets_icons [prof]
Tercio@7 728 local item_button = LibHotCorners:GetItemButton (index, self)
Tercio@7 729 if (item_button) then
Tercio@7 730 item_button:SetNormalTexture (texture)
Tercio@7 731 item_button:SetHighlightTexture (texture)
Tercio@7 732 item_button:SetPushedTexture (texture)
Tercio@7 733
Tercio@7 734 item_button:SetAttribute ("macrotext", "/cast " .. name .. ";\n/script HotCornersItemUsed=GetTime(); HotCorners:RefereshItems()")
Tercio@7 735
Tercio@7 736 item_button.itemtable = {false, false, false, GetSpellLink (secrets_spellID), false, true}
Tercio@7 737
Tercio@7 738 local start, duration = GetSpellCooldown (secrets_spellID)
Tercio@7 739 if (start and start > 0) then
Tercio@7 740 item_button.cooldown:SetCooldown (start, duration)
Tercio@7 741 else
Tercio@7 742 item_button.item_count:SetText (1)
Tercio@7 743 end
Tercio@7 744
Tercio@7 745 if (not item_button:IsShown() or item_button:GetAlpha() < 1) then
Tercio@11 746 -- HotCornersStartAnimOnShow (item_button, "item_topleft")
Tercio@7 747 end
Tercio@7 748 end
Tercio@7 749 index = index + 1
Tercio@7 750 end
Tercio@7 751 end
Tercio@7 752
Tercio@7 753 if (prof2) then
Tercio@7 754 local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier, specializationIndex, specializationOffset = GetProfessionInfo (prof2)
Tercio@7 755 local prof = get_profession (icon)
Tercio@7 756 local secrets_spellID = secrets_index [prof]
Tercio@7 757 if (secrets_spellID) then
Tercio@7 758 local name, _, texture = GetSpellInfo (secrets_spellID)
Tercio@7 759 texture = "Interface\\Icons\\" .. secrets_icons [prof]
Tercio@7 760 local item_button = LibHotCorners:GetItemButton (index, self)
Tercio@7 761 if (item_button) then
Tercio@7 762 item_button:SetNormalTexture (texture)
Tercio@7 763 item_button:SetHighlightTexture (texture)
Tercio@7 764 item_button:SetPushedTexture (texture)
Tercio@7 765
Tercio@7 766 item_button:SetAttribute ("macrotext", "/cast " .. name .. ";\n/script HotCornersItemUsed=GetTime(); HotCorners:RefereshItems()")
Tercio@7 767
Tercio@7 768 item_button.itemtable = {false, false, false, GetSpellLink (secrets_spellID), false, true}
Tercio@7 769
Tercio@7 770 local start, duration = GetSpellCooldown (secrets_spellID)
Tercio@7 771 if (start and start > 0) then
Tercio@7 772 item_button.cooldown:SetCooldown (start, duration)
Tercio@7 773 else
Tercio@7 774 item_button.item_count:SetText (1)
Tercio@7 775 end
Tercio@7 776
Tercio@7 777 if (not item_button:IsShown() or item_button:GetAlpha() < 1) then
Tercio@11 778 -- HotCornersStartAnimOnShow (item_button, "item_topleft")
Tercio@7 779 end
Tercio@7 780 end
Tercio@7 781 index = index + 1
Tercio@7 782 end
Tercio@7 783 end
Tercio@7 784
Tercio@7 785 end
tercio@2 786
tercio@2 787 function LibHotCorners:GetItemButton (index, parent)
tercio@2 788 local button = LibHotCorners.ItemButtons [index]
tercio@2 789 if (not button) then
tercio@2 790 button = CreateFrame ("button", "HotCornersItemButton" .. index, parent.item_frame, "HotCornersUseItemButtonTemplate")
tercio@2 791 button.isItem = true
tercio@2 792
tercio@2 793 if (parent.position == "topleft") then
tercio@2 794 local x = (index-1) * 33
tercio@2 795 button:SetPoint ("topleft", parent.item_frame, "topleft", x, -2)
tercio@2 796 button.x = x
tercio@2 797 elseif (parent.position == "topright") then
tercio@2 798 local x = (index-1) * 33
tercio@2 799 button:SetPoint ("topright", parent.item_frame, "topright", -x, -2)
tercio@2 800 end
tercio@2 801
tercio@2 802 LibHotCorners.ItemButtons [index] = button
tercio@2 803 end
tercio@2 804 return button
tercio@2 805 end
tercio@2 806
tercio@0 807 --> corner frame on leave
tercio@2 808 function HotCornersOnLeave (self, from_background)
tercio@2 809 if (not from_background) then
tercio@2 810 return
tercio@2 811 end
tercio@2 812
tercio@0 813 self:SetSize (1, 1)
tercio@0 814 for index, button_table in ipairs (LibHotCorners [self.position]) do
tercio@1 815 if (button_table.widget) then
tercio@1 816 button_table.widget:Hide()
tercio@1 817 end
tercio@0 818 end
tercio@2 819 for _, button in pairs (LibHotCorners.ItemButtons) do
tercio@2 820 button:Hide()
tercio@2 821 end
tercio@2 822
tercio@0 823 local OptionsButton = LibHotCorners [self.position].optionsbutton
tercio@0 824 OptionsButton:Hide()
tercio@2 825
tercio@2 826 self.item_frame:Hide()
tercio@3 827 HotCornersInfosFrame:Hide()
tercio@0 828 end
tercio@0 829
tercio@0 830 --> quick corner on click
tercio@0 831 function HotCornersOnQuickClick (self, button)
tercio@0 832 local parent_position = self:GetParent().position
tercio@1 833 local func = LibHotCorners.QuickFunctions [parent_position]
tercio@1 834 if (func) then
tercio@1 835 func (self, button)
tercio@0 836 end
tercio@0 837 end
tercio@0 838
tercio@0 839 --> options button onenter
tercio@0 840 function HotCornersOptionsButtonOnEnter (self)
tercio@0 841 set_size (self:GetParent())
tercio@0 842 for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do
tercio@0 843 if (not LibHotCorners.db.profile.disabled [button_table.name]) then
tercio@0 844 button_table.widget:Show()
tercio@0 845 end
tercio@0 846 end
tercio@0 847 self:Show()
tercio@0 848 end
tercio@0 849
tercio@0 850 function HotCornersOpenOptions (self)
tercio@0 851 InterfaceOptionsFrame_OpenToCategory ("HotCorners")
tercio@0 852 InterfaceOptionsFrame_OpenToCategory ("HotCorners")
tercio@0 853 end
tercio@0 854
tercio@0 855 function HotCornersSetEnabled (state)
tercio@0 856 LibHotCorners.db.profile.is_enabled = state
tercio@0 857 end
tercio@0 858
tercio@0 859 --> options button onleave
tercio@0 860 function HotCornersOptionsButtonOnLeave (self)
tercio@0 861 self:GetParent():GetScript("OnLeave")(self:GetParent())
tercio@0 862 end
tercio@0 863
tercio@0 864 --> button onenter
tercio@0 865 function HotCornersButtonOnEnter (self)
tercio@2 866 --set_size (self:GetParent())
tercio@2 867 --for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do
tercio@2 868 -- if (not LibHotCorners.db.profile.disabled [button_table.name] and button_table.widget) then
tercio@2 869 -- button_table.widget:Show()
tercio@2 870 -- end
tercio@2 871 --end
tercio@0 872 show_tooltip (self)
tercio@2 873 --local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
tercio@2 874 --OptionsButton:Show()
tercio@0 875 end
tercio@0 876
tercio@0 877 --> button onleave
tercio@0 878 function HotCornersButtonOnLeave (self)
tercio@0 879 GameTooltip:Hide()
tercio@2 880 if (self.table and self.table.onleave) then
tercio@0 881 self.table.onleave (self)
tercio@0 882 end
tercio@2 883 --self:GetParent():GetScript("OnLeave")(self:GetParent())
tercio@2 884 --local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
tercio@2 885 --OptionsButton:Hide()
tercio@0 886 end
tercio@0 887
tercio@0 888 --> button onmousedown
tercio@0 889 function HotCornersButtonOnMouseDown (self, button)
tercio@2 890 if (self.isItem) then
tercio@2 891 if (self:GetParent():GetParent().position == "topleft") then
tercio@2 892 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -3)
tercio@2 893 end
tercio@0 894 else
tercio@2 895 if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
tercio@2 896 self:SetPoint ("topleft", self:GetParent(), "topleft", 5, self.y - 1)
tercio@2 897 else
tercio@2 898 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -6)
tercio@2 899 end
tercio@0 900 end
tercio@0 901 end
tercio@0 902
tercio@0 903 --> button onmouseup
tercio@0 904 function HotCornersButtonOnMouseUp (self, button)
tercio@2 905 if (self.isItem) then
tercio@2 906 if (self:GetParent():GetParent().position == "topleft") then
tercio@2 907 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -2)
tercio@2 908 end
tercio@0 909 else
tercio@2 910 if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
tercio@2 911 self:SetPoint ("topleft", self:GetParent(), "topleft", 4, self.y)
tercio@2 912 else
tercio@2 913 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -4)
tercio@2 914 end
tercio@2 915 if (self.table.click) then
tercio@2 916 local clicks = LibHotCorners.db.profile.clicks
tercio@2 917 clicks [self.table.name] = clicks [self.table.name] or 0
tercio@2 918 clicks [self.table.name] = clicks [self.table.name] + 1
tercio@2 919 self.table.click (self, button)
tercio@2 920 end
tercio@0 921 end
tercio@2 922 end
tercio@2 923
tercio@2 924 --> start show animation
tercio@2 925 function HotCornersStartAnimOnShow (button, axis)
tercio@2 926 if (axis == "y") then
tercio@2 927 --button:SetPoint ("topleft", button:GetParent(), "topleft", -32, button.y)
tercio@2 928 button:SetPoint ("topleft", button:GetParent(), "topleft", 4, button.y)
Tercio@11 929 --button.AnimOnShow:Play()
Tercio@11 930 button:Show()
Tercio@11 931 button:SetAlpha (1)
tercio@2 932
tercio@2 933 elseif (axis == "item_topleft") then
Tercio@11 934 --button.AnimOnShow:Play()
tercio@2 935 button:Show()
Tercio@11 936 button:SetAlpha (1)
tercio@0 937 end
tercio@0 938 end
tercio@2 939
tercio@2 940 --> on start / finish show animation
tercio@2 941 function HotCornersAnimOnShowStarted (button)
tercio@2 942
tercio@2 943 end
tercio@2 944 function HotCornersAnimOnShowFinished (button)
tercio@2 945 --button:SetPoint ("topleft", button:GetParent(), "topleft", 4, button.y)
tercio@2 946 button:Show()
tercio@2 947 --button:SetPoint ("topleft", button:GetParent(), "topleft", -4, button.y)
tercio@2 948 end
tercio@0 949
tercio@0 950 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tercio@0 951 --> create top left corner
tercio@0 952
tercio@0 953 local TopLeftCorner = CreateFrame ("Frame", "LibHotCornersTopLeft", nil, "HotCornersFrameCornerTemplate")
tercio@0 954 TopLeftCorner:SetPoint ("topleft", UIParent, "topleft", 0, 0)
tercio@0 955 TopLeftCorner.position = "topleft"
tercio@0 956
tercio@0 957 --fast corner button
tercio@0 958 local QuickClickButton = CreateFrame ("button", "LibHotCornersTopLeftFastButton", TopLeftCorner, "HotCornersQuickCornerButtonTemplate")
tercio@0 959
tercio@0 960 --options button
tercio@0 961 local OptionsButton = CreateFrame ("button", "LibHotCornersTopLeftOptionsButton", TopLeftCorner, "HotCornersOptionsButtonTemplate")
tercio@0 962
tercio@0 963 if (debug) then
tercio@0 964 QuickClickButton:SetSize (20, 20)
tercio@0 965 QuickClickButton:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]], tile = true, tileSize = 40})
tercio@0 966 QuickClickButton:SetBackdropColor (1, 0, 0, 1)
tercio@0 967 end
tercio@0 968
tercio@0 969 LibHotCorners.topleft.quickbutton = QuickClickButton
tercio@0 970 LibHotCorners.topleft.optionsbutton = OptionsButton
tercio@0 971
tercio@0 972 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tercio@0 973 --> buttons
tercio@0 974
tercio@0 975 function LibHotCorners:CreateAddonWidget (frame, button_table, index, side)
tercio@0 976
tercio@0 977 --> create the button
tercio@0 978 local button = CreateFrame ("button", "LibHotCorners" .. side .. button_table.fname, frame, "HotCornersButtonTemplate")
tercio@0 979
tercio@0 980 --> write some attributes
tercio@0 981 button.index = index
tercio@0 982 button.table = button_table
tercio@0 983 button.parent = frame
tercio@0 984 button_table.widget = button
tercio@0 985
tercio@0 986 --> set the icon
tercio@0 987 button:SetNormalTexture (button_table.icon)
tercio@0 988 button:SetHighlightTexture (button_table.icon)
Tercio@11 989
Tercio@11 990 if (string.lower (button_table.icon):find ([[\icons\]]) or string.lower (button_table.icon):find ([[\ICONS\]]) or string.lower (button_table.icon):find ([[\Icons\]])) then
tercio@0 991 button:GetNormalTexture():SetTexCoord (0.078125, 0.9375, 0.078125, 0.9375)
tercio@0 992 button:GetHighlightTexture():SetTexCoord (0.078125, 0.9375, 0.078125, 0.9375)
tercio@0 993 end
tercio@0 994
Tercio@11 995 button:SetNormalTexture (button_table.icon)
Tercio@11 996 button:SetHighlightTexture (button_table.icon)
Tercio@11 997
Tercio@11 998 button.Icon = button:CreateTexture (nil, "overlay")
Tercio@11 999 button.Icon:SetTexture (button_table.icon)
Tercio@11 1000 button.Icon:SetSize (32, 32)
Tercio@11 1001 button.Icon:SetPoint ("center", button, "center", 0, 0)
Tercio@11 1002
Tercio@11 1003 --print (button:GetName())
Tercio@11 1004 --print (1, button:GetAlpha())
Tercio@11 1005
tercio@0 1006 return button
tercio@0 1007 end