annotate HotCorners.lua @ 8:3d3823b0f3f2

- ToC Update.
author Tercio
date Tue, 23 Jun 2015 13:24:43 -0300
parents d8a463c5ef5a
children 371e14cd2feb
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@2 488 }
tercio@2 489
tercio@0 490 function HotCornersOnEnter (self)
tercio@0 491
tercio@0 492 if (not LibHotCorners.db.profile.is_enabled) then
tercio@0 493 return
tercio@0 494 end
tercio@0 495
tercio@0 496 if (not LibHotCorners.db.profile [self.position .. "_enabled"]) then
tercio@0 497 return
tercio@0 498 end
tercio@0 499
tercio@2 500 if (self:GetWidth() < 1.1 and self:GetHeight() < 1.1) then
tercio@2 501 --print ("abrindo...")
tercio@2 502 end
tercio@2 503
tercio@0 504 set_size (self)
tercio@0 505
tercio@0 506 HotCornersBackgroundFrame:EnableMouse (true)
tercio@2 507 self.item_frame:Show()
tercio@0 508
tercio@0 509 local i = 1
tercio@0 510
tercio@0 511 local sort = {}
tercio@0 512 local clicks = LibHotCorners.db.profile.clicks
tercio@0 513 for index, button_table in ipairs (LibHotCorners [self.position]) do
tercio@0 514 tinsert (sort, {clicks [button_table.name] or 0, button_table})
tercio@0 515 end
tercio@0 516 table.sort (sort, more_clicked)
tercio@0 517
tercio@0 518 local last_button
tercio@0 519
tercio@0 520 local disabled = LibHotCorners.db.profile.disabled
tercio@0 521
tercio@0 522 for index, button_table in ipairs (sort) do
tercio@0 523 button_table = button_table [2]
tercio@0 524 if (not button_table.widget) then
tercio@0 525 LibHotCorners:CreateAddonWidget (self, button_table, index, self.position)
tercio@0 526 end
tercio@0 527
tercio@0 528 button_table.widget:ClearAllPoints()
tercio@0 529
tercio@1 530 if (not disabled [button_table.name] and not button_table.optionstable.hide) then
tercio@0 531 if (self.position == "topleft" or self.position == "topright") then
tercio@2 532
tercio@0 533 local y = i * 35 * -1
tercio@2 534 --button_table.widget:SetPoint ("topleft", self, "topleft", 4, y)
tercio@0 535 button_table.widget.y = y
tercio@2 536 HotCornersStartAnimOnShow (button_table.widget, "y")
tercio@2 537
tercio@2 538 else --bottom left / bottom right
tercio@0 539 local x = i * 35
tercio@0 540 button_table.widget:SetPoint ("topleft", self, "topleft", x, -4)
tercio@0 541 button_table.widget.x = x
tercio@0 542 end
tercio@0 543
tercio@0 544 button_table.widget:Show()
tercio@0 545 last_button = button_table.widget
tercio@0 546
tercio@0 547 i = i + 1
tercio@0 548 else
tercio@0 549 button_table.widget:Hide()
tercio@0 550 end
tercio@0 551 end
tercio@0 552
tercio@0 553 local OptionsButton = LibHotCorners [self.position].optionsbutton
tercio@0 554 local y = i * 35 * -1
tercio@0 555 OptionsButton:SetPoint ("top", self, "top", 0, y)
tercio@0 556 OptionsButton:Show()
tercio@0 557
tercio@2 558 --item frame
tercio@2 559 LibHotCorners:RefereshItems (self)
tercio@2 560
tercio@3 561 self.AnimOnShow:Play()
tercio@3 562 HotCornersInfosFrame:Show()
tercio@3 563 HotCornersInfosFrame:SetAlpha (0)
tercio@3 564 HotCornersInfosFrame.AnimOnShow:Play()
tercio@3 565
tercio@3 566 --update repair
tercio@3 567 local percent, items = 0, 0
tercio@3 568 for i = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
tercio@3 569 local durability, maxdurability = GetInventoryItemDurability (i)
tercio@3 570 if (durability and maxdurability) then
tercio@3 571 local p = durability / maxdurability * 100
tercio@3 572 percent = percent + p
tercio@3 573 items = items + 1
tercio@3 574 end
tercio@3 575 end
tercio@3 576
tercio@3 577 if (items == 0) then
tercio@3 578 HotCornersInfosFrame.repairText:SetText ("-- %")
tercio@3 579 end
tercio@3 580
tercio@3 581 percent = percent / items
tercio@3 582 HotCornersInfosFrame.repairText:SetText (math.floor (percent) .. "%")
tercio@3 583
tercio@3 584 --update date
tercio@3 585 HotCornersInfosFrame.clockText:SetText (date ("%H:%M"))
tercio@3 586 HotCornersInfosFrame.dayText:SetText (date ("%A\n%B %d"))
tercio@3 587
tercio@3 588 --update money
tercio@3 589 local money = GetMoney()
tercio@3 590 HotCornersInfosFrame.goldText:SetText (math.floor (money / 100 / 100))
tercio@3 591 HotCornersInfosFrame.silverText:SetText (math.floor ((money / 100) % 100))
tercio@3 592 HotCornersInfosFrame.bronzeText:SetText (math.floor (money % 100))
tercio@3 593
tercio@3 594 --HotCornersInfosFrame.clockText:SetText (date ("%A %B %d %H:%M:%S %Y"))
tercio@3 595
tercio@0 596 end
tercio@0 597
tercio@2 598 function LibHotCorners:RefereshItems (self)
tercio@2 599
Tercio@7 600 if (HotCornersItemUsed and LibHotCorners.LastItemButtonClick < GetTime() and not self) then
Tercio@7 601 for _, button in pairs (LibHotCorners.ItemButtons) do
Tercio@7 602 if (not button.itemtable[6]) then --> isn't a profession cooldown
Tercio@7 603 button.cooldown:SetCooldown (GetTime(), 1.5)
Tercio@7 604 end
Tercio@7 605 end
Tercio@7 606 HotCornersItemUsed = nil
Tercio@7 607 LibHotCorners.LastItemButtonClick = GetTime()+1.5
Tercio@7 608 end
Tercio@7 609
tercio@2 610 if (not self) then
tercio@2 611 return LibHotCorners:ScheduleTimer ("RefereshItems", 1, LibHotCornersTopLeft)
tercio@2 612 end
tercio@2 613
tercio@2 614 if (not UnitAffectingCombat ("player") and not InCombatLockdown()) then
tercio@2 615 for itemId, itemTable in pairs (LibHotCorners.ItemOnInventory) do
tercio@2 616 itemTable [1] = 0
tercio@2 617 end
tercio@2 618
tercio@2 619 for bagID = 0, 4 do
tercio@2 620 local numItems = GetContainerNumSlots (bagID)
tercio@2 621 for slot = 1, numItems do
tercio@2 622 local itemId = GetContainerItemID (bagID, slot)
tercio@2 623 if (LibHotCorners.BackPackItemList [itemId]) then
tercio@2 624 local texture, itemCount, locked, quality, readable, lootable, itemLink = GetContainerItemInfo (bagID, slot)
tercio@2 625 if (not LibHotCorners.ItemOnInventory [itemId]) then
tercio@2 626 LibHotCorners.ItemOnInventory [itemId] = {itemCount, texture, quality, itemLink, itemId}
tercio@2 627 else
tercio@2 628 LibHotCorners.ItemOnInventory [itemId] [1] = LibHotCorners.ItemOnInventory [itemId] [1] + itemCount
tercio@2 629 end
tercio@2 630 end
tercio@2 631 end
tercio@2 632 end
tercio@2 633
tercio@2 634 local index = 1
tercio@2 635 for itemId, itemTable in pairs (LibHotCorners.ItemOnInventory) do
tercio@2 636 local itemCount, texture, quality, itemLink = unpack (itemTable)
tercio@2 637
tercio@2 638 local item_button = LibHotCorners:GetItemButton (index, self)
tercio@2 639 if (item_button) then
tercio@2 640 item_button:SetNormalTexture (texture)
tercio@2 641 item_button:SetHighlightTexture (texture)
tercio@2 642 item_button:SetPushedTexture (texture)
tercio@2 643
tercio@2 644 item_button.item_count:SetText (itemCount or 0)
Tercio@7 645 item_button:SetAttribute ("macrotext", "/use " .. GetItemInfo (itemId) .. ";\n/script HotCornersItemUsed=GetTime(); HotCorners:RefereshItems()")
tercio@2 646
tercio@2 647 item_button.itemtable = itemTable
tercio@2 648
tercio@2 649 if (not item_button:IsShown() or item_button:GetAlpha() < 1) then
tercio@2 650 HotCornersStartAnimOnShow (item_button, "item_topleft")
tercio@2 651 end
tercio@2 652 end
Tercio@7 653 index = index + 1
tercio@2 654 end
Tercio@7 655
Tercio@7 656 LibHotCorners:RefereshProfessions (self, index)
tercio@2 657
tercio@2 658 end
tercio@2 659 --/run local itemid=GetContainerItemID (0, 1);print (itemid)
tercio@2 660 --UseContainerItem(bagID, slot[, onSelf])
Tercio@7 661 end
Tercio@7 662
Tercio@7 663 local get_profession = function (icon)
Tercio@7 664 if (icon:find ("Trade_Engineering")) then
Tercio@7 665 return "en"
Tercio@7 666 elseif (icon:find ("Trade_LeatherWorking")) then
Tercio@7 667 return "lw"
Tercio@7 668 elseif (icon:find ("Trade_Tailoring")) then
Tercio@7 669 return "tl"
Tercio@7 670 elseif (icon:find ("Trade_Engraving")) then
Tercio@7 671 return "ec"
Tercio@7 672 elseif (icon:find ("Trade_BlackSmithing")) then
Tercio@7 673 return "bs"
Tercio@7 674 elseif (icon:find ("Trade_Alchemy")) then
Tercio@7 675 return "al"
Tercio@7 676 elseif (icon:find ("INV_Misc_Gem_01")) then
Tercio@7 677 return "jc"
Tercio@7 678 elseif (icon:find ("INV_Inscription_Tradeskill01")) then
Tercio@7 679 return "in"
Tercio@7 680 end
Tercio@7 681 end
Tercio@7 682 local secrets_index = {
Tercio@7 683 ["tl"] = 176058, --tailoring
Tercio@7 684 ["ec"] = 177043, --enchanting
Tercio@7 685 ["lw"] = 176089, --letherwork
Tercio@7 686 ["en"] = 177054, --engeener
Tercio@7 687 ["bs"] = 176090, --blacksmith
Tercio@7 688 ["al"] = 175880, --alchemy
Tercio@7 689 ["jc"] = 176087, --jewelcraft
Tercio@7 690 ["in"] = 177045, --inscription
Tercio@7 691 }
Tercio@7 692 local secrets_icons = {
Tercio@7 693 ["tl"] = "inv_misc_book_03", --tailoring
Tercio@7 694 ["ec"] = "inv_misc_book_08", --enchant
Tercio@7 695 ["al"] = "inv_misc_book_08", -- alchemy
Tercio@7 696 ["bs"] = "inv_misc_book_11", --bs
Tercio@7 697 ["en"] = "inv_misc_book_08", --engeener
Tercio@7 698 ["in"] = "inv_misc_book_08", --inscritp
Tercio@7 699 ["jc"] = "inv_misc_book_10", --jc
Tercio@7 700 ["lw"] = "inv_misc_book_09", --lw
Tercio@7 701 }
Tercio@7 702
Tercio@7 703 function LibHotCorners:RefereshProfessions (self, index)
Tercio@7 704
Tercio@7 705 index = index + 1
Tercio@7 706
Tercio@7 707 local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions()
Tercio@7 708
Tercio@7 709 if (prof1) then
Tercio@7 710 local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier, specializationIndex, specializationOffset = GetProfessionInfo (prof1)
Tercio@7 711 local prof = get_profession (icon)
Tercio@7 712 local secrets_spellID = secrets_index [prof]
Tercio@7 713 if (secrets_spellID) then
Tercio@7 714 local name, _, texture = GetSpellInfo (secrets_spellID)
Tercio@7 715 texture = "Interface\\Icons\\" .. secrets_icons [prof]
Tercio@7 716 local item_button = LibHotCorners:GetItemButton (index, self)
Tercio@7 717 if (item_button) then
Tercio@7 718 item_button:SetNormalTexture (texture)
Tercio@7 719 item_button:SetHighlightTexture (texture)
Tercio@7 720 item_button:SetPushedTexture (texture)
Tercio@7 721
Tercio@7 722 item_button:SetAttribute ("macrotext", "/cast " .. name .. ";\n/script HotCornersItemUsed=GetTime(); HotCorners:RefereshItems()")
Tercio@7 723
Tercio@7 724 item_button.itemtable = {false, false, false, GetSpellLink (secrets_spellID), false, true}
Tercio@7 725
Tercio@7 726 local start, duration = GetSpellCooldown (secrets_spellID)
Tercio@7 727 if (start and start > 0) then
Tercio@7 728 item_button.cooldown:SetCooldown (start, duration)
Tercio@7 729 else
Tercio@7 730 item_button.item_count:SetText (1)
Tercio@7 731 end
Tercio@7 732
Tercio@7 733 if (not item_button:IsShown() or item_button:GetAlpha() < 1) then
Tercio@7 734 HotCornersStartAnimOnShow (item_button, "item_topleft")
Tercio@7 735 end
Tercio@7 736 end
Tercio@7 737 index = index + 1
Tercio@7 738 end
Tercio@7 739 end
Tercio@7 740
Tercio@7 741 if (prof2) then
Tercio@7 742 local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier, specializationIndex, specializationOffset = GetProfessionInfo (prof2)
Tercio@7 743 local prof = get_profession (icon)
Tercio@7 744 local secrets_spellID = secrets_index [prof]
Tercio@7 745 if (secrets_spellID) then
Tercio@7 746 local name, _, texture = GetSpellInfo (secrets_spellID)
Tercio@7 747 texture = "Interface\\Icons\\" .. secrets_icons [prof]
Tercio@7 748 local item_button = LibHotCorners:GetItemButton (index, self)
Tercio@7 749 if (item_button) then
Tercio@7 750 item_button:SetNormalTexture (texture)
Tercio@7 751 item_button:SetHighlightTexture (texture)
Tercio@7 752 item_button:SetPushedTexture (texture)
Tercio@7 753
Tercio@7 754 item_button:SetAttribute ("macrotext", "/cast " .. name .. ";\n/script HotCornersItemUsed=GetTime(); HotCorners:RefereshItems()")
Tercio@7 755
Tercio@7 756 item_button.itemtable = {false, false, false, GetSpellLink (secrets_spellID), false, true}
Tercio@7 757
Tercio@7 758 local start, duration = GetSpellCooldown (secrets_spellID)
Tercio@7 759 if (start and start > 0) then
Tercio@7 760 item_button.cooldown:SetCooldown (start, duration)
Tercio@7 761 else
Tercio@7 762 item_button.item_count:SetText (1)
Tercio@7 763 end
Tercio@7 764
Tercio@7 765 if (not item_button:IsShown() or item_button:GetAlpha() < 1) then
Tercio@7 766 HotCornersStartAnimOnShow (item_button, "item_topleft")
Tercio@7 767 end
Tercio@7 768 end
Tercio@7 769 index = index + 1
Tercio@7 770 end
Tercio@7 771 end
Tercio@7 772
Tercio@7 773 end
tercio@2 774
tercio@2 775 function LibHotCorners:GetItemButton (index, parent)
tercio@2 776 local button = LibHotCorners.ItemButtons [index]
tercio@2 777 if (not button) then
tercio@2 778 button = CreateFrame ("button", "HotCornersItemButton" .. index, parent.item_frame, "HotCornersUseItemButtonTemplate")
tercio@2 779 button.isItem = true
tercio@2 780
tercio@2 781 if (parent.position == "topleft") then
tercio@2 782 local x = (index-1) * 33
tercio@2 783 button:SetPoint ("topleft", parent.item_frame, "topleft", x, -2)
tercio@2 784 button.x = x
tercio@2 785 elseif (parent.position == "topright") then
tercio@2 786 local x = (index-1) * 33
tercio@2 787 button:SetPoint ("topright", parent.item_frame, "topright", -x, -2)
tercio@2 788 end
tercio@2 789
tercio@2 790 LibHotCorners.ItemButtons [index] = button
tercio@2 791 end
tercio@2 792 return button
tercio@2 793 end
tercio@2 794
tercio@0 795 --> corner frame on leave
tercio@2 796 function HotCornersOnLeave (self, from_background)
tercio@2 797 if (not from_background) then
tercio@2 798 return
tercio@2 799 end
tercio@2 800
tercio@0 801 self:SetSize (1, 1)
tercio@0 802 for index, button_table in ipairs (LibHotCorners [self.position]) do
tercio@1 803 if (button_table.widget) then
tercio@1 804 button_table.widget:Hide()
tercio@1 805 end
tercio@0 806 end
tercio@2 807 for _, button in pairs (LibHotCorners.ItemButtons) do
tercio@2 808 button:Hide()
tercio@2 809 end
tercio@2 810
tercio@0 811 local OptionsButton = LibHotCorners [self.position].optionsbutton
tercio@0 812 OptionsButton:Hide()
tercio@2 813
tercio@2 814 self.item_frame:Hide()
tercio@3 815 HotCornersInfosFrame:Hide()
tercio@0 816 end
tercio@0 817
tercio@0 818 --> quick corner on click
tercio@0 819 function HotCornersOnQuickClick (self, button)
tercio@0 820 local parent_position = self:GetParent().position
tercio@1 821 local func = LibHotCorners.QuickFunctions [parent_position]
tercio@1 822 if (func) then
tercio@1 823 func (self, button)
tercio@0 824 end
tercio@0 825 end
tercio@0 826
tercio@0 827 --> options button onenter
tercio@0 828 function HotCornersOptionsButtonOnEnter (self)
tercio@0 829 set_size (self:GetParent())
tercio@0 830 for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do
tercio@0 831 if (not LibHotCorners.db.profile.disabled [button_table.name]) then
tercio@0 832 button_table.widget:Show()
tercio@0 833 end
tercio@0 834 end
tercio@0 835 self:Show()
tercio@0 836 end
tercio@0 837
tercio@0 838 function HotCornersOpenOptions (self)
tercio@0 839 InterfaceOptionsFrame_OpenToCategory ("HotCorners")
tercio@0 840 InterfaceOptionsFrame_OpenToCategory ("HotCorners")
tercio@0 841 end
tercio@0 842
tercio@0 843 function HotCornersSetEnabled (state)
tercio@0 844 LibHotCorners.db.profile.is_enabled = state
tercio@0 845 end
tercio@0 846
tercio@0 847 --> options button onleave
tercio@0 848 function HotCornersOptionsButtonOnLeave (self)
tercio@0 849 self:GetParent():GetScript("OnLeave")(self:GetParent())
tercio@0 850 end
tercio@0 851
tercio@0 852 --> button onenter
tercio@0 853 function HotCornersButtonOnEnter (self)
tercio@2 854 --set_size (self:GetParent())
tercio@2 855 --for index, button_table in ipairs (LibHotCorners [self:GetParent().position]) do
tercio@2 856 -- if (not LibHotCorners.db.profile.disabled [button_table.name] and button_table.widget) then
tercio@2 857 -- button_table.widget:Show()
tercio@2 858 -- end
tercio@2 859 --end
tercio@0 860 show_tooltip (self)
tercio@2 861 --local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
tercio@2 862 --OptionsButton:Show()
tercio@0 863 end
tercio@0 864
tercio@0 865 --> button onleave
tercio@0 866 function HotCornersButtonOnLeave (self)
tercio@0 867 GameTooltip:Hide()
tercio@2 868 if (self.table and self.table.onleave) then
tercio@0 869 self.table.onleave (self)
tercio@0 870 end
tercio@2 871 --self:GetParent():GetScript("OnLeave")(self:GetParent())
tercio@2 872 --local OptionsButton = LibHotCorners [self:GetParent().position].optionsbutton
tercio@2 873 --OptionsButton:Hide()
tercio@0 874 end
tercio@0 875
tercio@0 876 --> button onmousedown
tercio@0 877 function HotCornersButtonOnMouseDown (self, button)
tercio@2 878 if (self.isItem) then
tercio@2 879 if (self:GetParent():GetParent().position == "topleft") then
tercio@2 880 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -3)
tercio@2 881 end
tercio@0 882 else
tercio@2 883 if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
tercio@2 884 self:SetPoint ("topleft", self:GetParent(), "topleft", 5, self.y - 1)
tercio@2 885 else
tercio@2 886 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x+1, -6)
tercio@2 887 end
tercio@0 888 end
tercio@0 889 end
tercio@0 890
tercio@0 891 --> button onmouseup
tercio@0 892 function HotCornersButtonOnMouseUp (self, button)
tercio@2 893 if (self.isItem) then
tercio@2 894 if (self:GetParent():GetParent().position == "topleft") then
tercio@2 895 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -2)
tercio@2 896 end
tercio@0 897 else
tercio@2 898 if (self:GetParent().position == "topleft" or self:GetParent().position == "topright") then
tercio@2 899 self:SetPoint ("topleft", self:GetParent(), "topleft", 4, self.y)
tercio@2 900 else
tercio@2 901 self:SetPoint ("topleft", self:GetParent(), "topleft", self.x, -4)
tercio@2 902 end
tercio@2 903 if (self.table.click) then
tercio@2 904 local clicks = LibHotCorners.db.profile.clicks
tercio@2 905 clicks [self.table.name] = clicks [self.table.name] or 0
tercio@2 906 clicks [self.table.name] = clicks [self.table.name] + 1
tercio@2 907 self.table.click (self, button)
tercio@2 908 end
tercio@0 909 end
tercio@2 910 end
tercio@2 911
tercio@2 912 --> start show animation
tercio@2 913 function HotCornersStartAnimOnShow (button, axis)
tercio@2 914 if (axis == "y") then
tercio@2 915 --button:SetPoint ("topleft", button:GetParent(), "topleft", -32, button.y)
tercio@2 916 button:SetPoint ("topleft", button:GetParent(), "topleft", 4, button.y)
tercio@2 917 button.AnimOnShow:Play()
tercio@2 918
tercio@2 919 elseif (axis == "item_topleft") then
tercio@2 920 button:Show()
tercio@2 921 button.AnimOnShow:Play()
tercio@2 922
tercio@0 923 end
tercio@0 924 end
tercio@2 925
tercio@2 926 --> on start / finish show animation
tercio@2 927 function HotCornersAnimOnShowStarted (button)
tercio@2 928
tercio@2 929 end
tercio@2 930 function HotCornersAnimOnShowFinished (button)
tercio@2 931 --button:SetPoint ("topleft", button:GetParent(), "topleft", 4, button.y)
tercio@2 932 button:Show()
tercio@2 933 --button:SetPoint ("topleft", button:GetParent(), "topleft", -4, button.y)
tercio@2 934 end
tercio@0 935
tercio@0 936 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tercio@0 937 --> create top left corner
tercio@0 938
tercio@0 939 local TopLeftCorner = CreateFrame ("Frame", "LibHotCornersTopLeft", nil, "HotCornersFrameCornerTemplate")
tercio@0 940 TopLeftCorner:SetPoint ("topleft", UIParent, "topleft", 0, 0)
tercio@0 941 TopLeftCorner.position = "topleft"
tercio@0 942
tercio@0 943 --fast corner button
tercio@0 944 local QuickClickButton = CreateFrame ("button", "LibHotCornersTopLeftFastButton", TopLeftCorner, "HotCornersQuickCornerButtonTemplate")
tercio@0 945
tercio@0 946 --options button
tercio@0 947 local OptionsButton = CreateFrame ("button", "LibHotCornersTopLeftOptionsButton", TopLeftCorner, "HotCornersOptionsButtonTemplate")
tercio@0 948
tercio@0 949 if (debug) then
tercio@0 950 QuickClickButton:SetSize (20, 20)
tercio@0 951 QuickClickButton:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]], tile = true, tileSize = 40})
tercio@0 952 QuickClickButton:SetBackdropColor (1, 0, 0, 1)
tercio@0 953 end
tercio@0 954
tercio@0 955 LibHotCorners.topleft.quickbutton = QuickClickButton
tercio@0 956 LibHotCorners.topleft.optionsbutton = OptionsButton
tercio@0 957
tercio@0 958 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tercio@0 959 --> buttons
tercio@0 960
tercio@0 961 function LibHotCorners:CreateAddonWidget (frame, button_table, index, side)
tercio@0 962
tercio@0 963 --> create the button
tercio@0 964 local button = CreateFrame ("button", "LibHotCorners" .. side .. button_table.fname, frame, "HotCornersButtonTemplate")
tercio@0 965
tercio@0 966 --> write some attributes
tercio@0 967 button.index = index
tercio@0 968 button.table = button_table
tercio@0 969 button.parent = frame
tercio@0 970 button_table.widget = button
tercio@0 971
tercio@0 972 --> set the icon
tercio@0 973 button:SetNormalTexture (button_table.icon)
tercio@0 974 button:SetHighlightTexture (button_table.icon)
tercio@0 975
tercio@0 976 if (string.lower (button_table.icon):find ([[\icons\]])) then
tercio@0 977 button:GetNormalTexture():SetTexCoord (0.078125, 0.9375, 0.078125, 0.9375)
tercio@0 978 button:GetHighlightTexture():SetTexCoord (0.078125, 0.9375, 0.078125, 0.9375)
tercio@0 979 end
tercio@0 980
tercio@0 981 return button
tercio@0 982 end