Mercurial > wow > devian
comparison Devian.lua @ 77:d11b67d25aee v2.1.78
- Added some title info manipulation to make DVN more prevalent in the load order.
- Added Devian.LoadMessage function for spooling post-reload messages.
- Fixed a lua error caused by switching to non-existent profiles.
author | Nenue |
---|---|
date | Wed, 06 Jul 2016 16:30:19 -0400 |
parents | 3a33e47eeca8 |
children | 94abbdec03fa |
comparison
equal
deleted
inserted
replaced
76:1b2d6d4a54fd | 77:d11b67d25aee |
---|---|
54 | 54 |
55 local MAJOR, MINOR = 'Devian-2.0', 'r@project-revision@' | 55 local MAJOR, MINOR = 'Devian-2.0', 'r@project-revision@' |
56 local D = LibStub("AceAddon-3.0"):NewAddon(D, "Devian", "AceConsole-3.0", "AceEvent-3.0") | 56 local D = LibStub("AceAddon-3.0"):NewAddon(D, "Devian", "AceConsole-3.0", "AceEvent-3.0") |
57 local L = D.L | 57 local L = D.L |
58 _G.Devian = D | 58 _G.Devian = D |
59 _G.DevianLoadMessage = {} | |
59 D:SetDefaultModuleState(false) | 60 D:SetDefaultModuleState(false) |
60 D.oldprint = getprinthandler() | 61 D.oldprint = getprinthandler() |
61 if not _G.oldprint then _G.oldprint = D.oldprint end | 62 if not _G.oldprint then _G.oldprint = D.oldprint end |
62 | 63 |
63 local pairs, tostring, tonumber, ipairs, type = pairs, tostring, tonumber, ipairs, type | 64 local pairs, tostring, tonumber, ipairs, type = pairs, tostring, tonumber, ipairs, type |
248 D.Profile(list_id, dest) | 249 D.Profile(list_id, dest) |
249 scan_func = D.Save | 250 scan_func = D.Save |
250 D:Print("Profile |cFFFFFF00".. list_id .."|r saved.") | 251 D:Print("Profile |cFFFFFF00".. list_id .."|r saved.") |
251 else | 252 else |
252 | 253 |
253 _G.DevianLoadMessage = "Switched profiles." | 254 D.LoadMessage "Switched profiles." |
254 | 255 |
255 list_id = tonumber(mode) | 256 list_id = tonumber(mode) |
256 if list_id ~= db.main_profile then | 257 if list_id ~= db.main_profile then |
257 db.last_profile = list_id | 258 db.last_profile = list_id |
258 end | 259 end |
259 db.current_profile = list_id | 260 db.current_profile = list_id |
260 scan_func = D.Load | 261 scan_func = D.Load |
261 end | 262 end |
262 elseif mode == nil then | 263 elseif mode == nil then |
263 list_id = (db.current_profile ~= db.main_profile) and db.main_profile or db.last_profile | 264 list_id = (db.current_profile ~= db.main_profile) and db.main_profile or db.last_profile |
264 _G.DevianLoadMessage = "Switched between main and recent profile ("..db.current_profile..' and '..list_id..')' | 265 D.LoadMessage ("Switched between main and recent profile ("..db.current_profile..' and '..list_id..')') |
265 db.current_profile = list_id | 266 db.current_profile = list_id |
266 scan_func = D.Load | 267 scan_func = D.Load |
267 else | 268 else |
268 return D:PrintHelp() | 269 return D:PrintHelp() |
270 end | |
271 | |
272 if not db.profiles[list_id] then | |
273 db.profiles[list_id] = {global = {}, char = {} } | |
274 D.LoadMessage ("Starting profile #|cFF00FFFF".. list_id..'|r') | |
269 end | 275 end |
270 if not db.profiles[list_id].char[playerRealm] then | 276 if not db.profiles[list_id].char[playerRealm] then |
271 db.profiles[list_id].char[playerRealm] = {} | 277 db.profiles[list_id].char[playerRealm] = {} |
272 end | 278 end |
273 | 279 |
399 D:UpdateDock() | 405 D:UpdateDock() |
400 D:Print('Removed channel #'..dest) | 406 D:Print('Removed channel #'..dest) |
401 end | 407 end |
402 end | 408 end |
403 | 409 |
410 --- Queue up a message to appear after UI reload | |
411 function D.LoadMessage(msg) | |
412 | |
413 tinsert(_G.DevianLoadMessage, msg) | |
414 end | |
415 | |
404 --- Creates a Devian-style output. | 416 --- Creates a Devian-style output. |
405 -- The first argument describes the channel to output on, and the remaining arguments are concatenated in a manner similar to default print() | 417 -- The first argument describes the channel to output on, and the remaining arguments are concatenated in a manner similar to default print() |
406 -- This becomes the print handler when development mode is active. The original print() function is assigned to oldprint(). | 418 -- This becomes the print handler when development mode is active. The original print() function is assigned to oldprint(). |
407 -- @param Tag, signature, or numeric index of the channel to output on. Defaults to primary channel. | 419 -- @param Tag, signature, or numeric index of the channel to output on. Defaults to primary channel. |
408 -- @param ... Output contents. | 420 -- @param ... Output contents. |
517 if not blocked[k] then | 529 if not blocked[k] then |
518 DevianDB[k] = v | 530 DevianDB[k] = v |
519 end | 531 end |
520 end | 532 end |
521 | 533 |
522 _G.DevianLoadMessage = "Non-user SavedVars have been reset." | 534 D.LoadMessage "Non-user SavedVars have been reset." |
523 _G.ReloadUI() | 535 _G.ReloadUI() |
524 end | 536 end |
525 D.SetDefaultsAll = function () | 537 D.SetDefaultsAll = function () |
526 _G.DevianDB = nil | 538 _G.DevianDB = nil |
527 _G.DevianLoadMessage = "All SavedVars wiped." | 539 D.LoadMessage "All SavedVars wiped." |
528 _G.ReloadUI() | 540 _G.ReloadUI() |
529 end | 541 end |
530 | 542 |
531 D.UnsetColors = function() | 543 D.UnsetColors = function() |
532 db.tagcolor = {} | 544 db.tagcolor = {} |
566 end | 578 end |
567 db = _G.DevianDB | 579 db = _G.DevianDB |
568 self.db = db | 580 self.db = db |
569 | 581 |
570 --- | 582 --- |
571 if _G.DevianLoadMessage then | 583 if #_G.DevianLoadMessage >= 1 then |
572 D:Print(_G.DevianLoadMessage) | 584 for i, msg in ipairs(_G.DevianLoadMessage) do |
573 _G.DevianLoadMessage = nil | 585 D:Print(msg) |
586 end | |
587 | |
588 table.wipe(_G.DevianLoadMessage) | |
574 end | 589 end |
575 | 590 |
576 | 591 |
577 --- initialize the current profile | 592 --- initialize the current profile |
578 local id, name = D.Profile(db.current_profile or 1) | 593 local id, name = D.Profile(db.current_profile or 1) |