Mercurial > wow > devian
comparison Devian.lua @ 73:3745540e8996 v2.1.74
- New commands:
- /dvn remove (index|tag) will remove a channel from the current profile
- /dvncolors resets the tag color cache
- Fixed an issue with creating more than one output channel per UI session.
- Performance improvements:
- Color caching now ignores decimal timestamps, removing a source of cache bloat
- Cleaned up a bunch of global variable use in many areas
author | Nenue |
---|---|
date | Sat, 09 Apr 2016 06:34:04 -0400 |
parents | da5ff1fc9fb6 |
children | 3a33e47eeca8 |
comparison
equal
deleted
inserted
replaced
72:da5ff1fc9fb6 | 73:3745540e8996 |
---|---|
5 | 5 |
6 --GLOBALS: Devian, DevCon, DevianLoadMessage | 6 --GLOBALS: Devian, DevCon, DevianLoadMessage |
7 local ADDON, D = ... | 7 local ADDON, D = ... |
8 local sub, GetTime, print, _G = string.sub, GetTime, print, _G | 8 local sub, GetTime, print, _G = string.sub, GetTime, print, _G |
9 local format, setmetatable, getprinthandler, setprinthandler = string.format, setmetatable, getprinthandler, setprinthandler | 9 local format, setmetatable, getprinthandler, setprinthandler = string.format, setmetatable, getprinthandler, setprinthandler |
10 local tinsert = tinsert | 10 local tinsert, tremove = tinsert, tremove |
11 local currentProfile | 11 local currentProfile |
12 local playerName = UnitName("player") | 12 local playerName = UnitName("player") |
13 local playerRealm = playerName .. '-' .. GetRealmName() | 13 local playerRealm = playerName .. '-' .. GetRealmName() |
14 local num_dock_tabs = 0 | 14 local num_dock_tabs = 0 |
15 local in_workspace = false | 15 local in_workspace = false |
232 return D:StackFrames() | 232 return D:StackFrames() |
233 elseif mode == 'grid' then | 233 elseif mode == 'grid' then |
234 return D:DistributeFrames() | 234 return D:DistributeFrames() |
235 elseif mode == 'tag' then -- tagging | 235 elseif mode == 'tag' then -- tagging |
236 return D.Tag(self, tag, dest) | 236 return D.Tag(self, tag, dest) |
237 elseif mode == 'new' then | |
238 return D.New(self, tag) | |
239 elseif mode == 'remove' then | |
240 return D.Remove(self, tag) | |
237 elseif tonumber(mode) ~= nil or mode == 'save' then | 241 elseif tonumber(mode) ~= nil or mode == 'save' then |
238 -- either a number of the save command | 242 -- either a number of the save command |
239 if mode == 'save' then | 243 if mode == 'save' then |
240 list_id = tonumber(tag) | 244 list_id = tonumber(tag) |
241 if list_id == nil then | 245 if list_id == nil then |
368 else | 372 else |
369 D:Print(L['Command tag help']) | 373 D:Print(L['Command tag help']) |
370 end | 374 end |
371 end | 375 end |
372 | 376 |
373 | 377 D.New = function(self, tag) |
378 if tag and not self.sigID[tag] then | |
379 local id = D.max_channel + 1 | |
380 D.SetChannel(tag, id) | |
381 end | |
382 end | |
383 | |
384 D.Remove = function(self, dest) | |
385 dest = D.sigID[dest] or tonumber(dest) | |
386 if D.console[dest] and D.channels[dest] then | |
387 for tag, tagDest in pairs(D.tags) do | |
388 for i = #tagDest, 0 do | |
389 -- work downward so we aren't skipping entries | |
390 if tagDest[i] == dest then | |
391 tremove(tagDest, i) | |
392 end | |
393 end | |
394 end | |
395 D.console[dest]:Hide() | |
396 D.channels[dest] = nil | |
397 tremove(D.console, dest) | |
398 tremove(D.dock.buttons, dest) | |
399 D:UpdateDock() | |
400 D:Print('Removed channel #'..dest) | |
401 end | |
402 end | |
374 | 403 |
375 --- Creates a Devian-style output. | 404 --- Creates a Devian-style output. |
376 -- The first argument describes the channel to output on, and the remaining arguments are concatenated in a manner similar to default print() | 405 -- The first argument describes the channel to output on, and the remaining arguments are concatenated in a manner similar to default print() |
377 -- This becomes the print handler when development mode is active. The original print() function is assigned to oldprint(). | 406 -- This becomes the print handler when development mode is active. The original print() function is assigned to oldprint(). |
378 -- @param Tag, signature, or numeric index of the channel to output on. Defaults to primary channel. | 407 -- @param Tag, signature, or numeric index of the channel to output on. Defaults to primary channel. |
408 end | 437 end |
409 | 438 |
410 -- color me timbers | 439 -- color me timbers |
411 local pcolor | 440 local pcolor |
412 if (not db.tagcolor[prefix]) and byName then | 441 if (not db.tagcolor[prefix]) and byName then |
413 local c = { | 442 if prefix:match('^%d+%.%d+$') then |
414 rand(64,255), rand(64,255), rand(64,255) | 443 pcolor = 'FFFFFF' |
415 } | 444 else |
416 if c[1] > 223 and c[2] > 223 and c[3] > 223 then | 445 local c = { |
417 c[rand(1,3)] = rand(64,223) | 446 rand(64,255), rand(64,255), rand(64,255) |
418 end | 447 } |
419 | 448 if c[1] > 223 and c[2] > 223 and c[3] > 223 then |
420 db.tagcolor[prefix] = format('%02X%02X%02X', unpack(c)) | 449 c[rand(1,3)] = rand(64,223) |
421 end | 450 end |
422 pcolor = db.tagcolor[prefix] | 451 db.tagcolor[prefix] = format('%02X%02X%02X', unpack(c)) |
452 pcolor = db.tagcolor[prefix] | |
453 end | |
454 else | |
455 pcolor = db.tagcolor[prefix] | |
456 end | |
423 | 457 |
424 local buffer = {} | 458 local buffer = {} |
425 for i = 1, select('#',...) do | 459 for i = 1, select('#',...) do |
426 local var = select(i, ...) | 460 local var = select(i, ...) |
427 | 461 |
447 local message = concat(buffer, ' ') | 481 local message = concat(buffer, ' ') |
448 for id, channel in pairs(sendq) do | 482 for id, channel in pairs(sendq) do |
449 if channel.width < 250 then | 483 if channel.width < 250 then |
450 prefix = sub(prefix, 0,2) | 484 prefix = sub(prefix, 0,2) |
451 end | 485 end |
486 --currentProfile.last_channel = channel.index | |
452 channel.out:AddMessage('|cFF'.. pcolor..prefix ..'|r ' .. message, 0.8, 0.8, 0.8, nil, nil, prefix, GetTime()) | 487 channel.out:AddMessage('|cFF'.. pcolor..prefix ..'|r ' .. message, 0.8, 0.8, 0.8, nil, nil, prefix, GetTime()) |
453 if not D.dock.buttons[id].newMessage then | 488 if not D.dock.buttons[id].newMessage then |
454 D.dock.buttons[id].newMessage = true | 489 D.dock.buttons[id].newMessage = true |
455 D.UpdateBeacon(D.dock.buttons[id]) | 490 D.UpdateBeacon(D.dock.buttons[id]) |
456 end | 491 end |
481 for k,v in pairs(defaults) do | 516 for k,v in pairs(defaults) do |
482 if not blocked[k] then | 517 if not blocked[k] then |
483 DevianDB[k] = v | 518 DevianDB[k] = v |
484 end | 519 end |
485 end | 520 end |
521 | |
486 _G.DevianLoadMessage = "Non-user SavedVars have been reset." | 522 _G.DevianLoadMessage = "Non-user SavedVars have been reset." |
487 _G.ReloadUI() | 523 _G.ReloadUI() |
488 end | 524 end |
489 D.SetDefaultsAll = function () | 525 D.SetDefaultsAll = function () |
490 _G.DevianDB = nil | 526 _G.DevianDB = nil |
491 _G.DevianLoadMessage = "All SavedVars wiped." | 527 _G.DevianLoadMessage = "All SavedVars wiped." |
492 _G.ReloadUI() | 528 _G.ReloadUI() |
529 end | |
530 | |
531 D.UnsetColors = function() | |
532 db.tagcolor = {} | |
533 D:Print('Tag color cache cleared.') | |
493 end | 534 end |
494 D.ConfigCommand = function(self, input) | 535 D.ConfigCommand = function(self, input) |
495 if not self.config then | 536 if not self.config then |
496 self.config = DevCon | 537 self.config = DevCon |
497 self:EnableModule("Config") | 538 self:EnableModule("Config") |
505 local cmdlist = { | 546 local cmdlist = { |
506 ['dfs'] = 'FrameHelper_Update', | 547 ['dfs'] = 'FrameHelper_Update', |
507 ['dvn'] = "Command", | 548 ['dvn'] = "Command", |
508 ['devian'] = "Command", | 549 ['devian'] = "Command", |
509 ['dvc'] = "Console_Toggle", | 550 ['dvc'] = "Console_Toggle", |
551 ['dvncolors'] = "UnsetColors", | |
510 ['cleandvn'] = "SetDefaultsAll", | 552 ['cleandvn'] = "SetDefaultsAll", |
511 ['resetdvn'] = "SetDefaults", | 553 ['resetdvn'] = "SetDefaults", |
512 ['dvg'] = "ConfigCommand" | 554 ['dvg'] = "ConfigCommand" |
513 } | 555 } |
514 for cmd, func in pairs(cmdlist) do | 556 for cmd, func in pairs(cmdlist) do |