Mercurial > wow > devian
diff 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 |
line wrap: on
line diff
--- a/Devian.lua Sat Apr 09 05:51:19 2016 -0400 +++ b/Devian.lua Sat Apr 09 06:34:04 2016 -0400 @@ -7,7 +7,7 @@ local ADDON, D = ... local sub, GetTime, print, _G = string.sub, GetTime, print, _G local format, setmetatable, getprinthandler, setprinthandler = string.format, setmetatable, getprinthandler, setprinthandler -local tinsert = tinsert +local tinsert, tremove = tinsert, tremove local currentProfile local playerName = UnitName("player") local playerRealm = playerName .. '-' .. GetRealmName() @@ -234,6 +234,10 @@ return D:DistributeFrames() elseif mode == 'tag' then -- tagging return D.Tag(self, tag, dest) + elseif mode == 'new' then + return D.New(self, tag) + elseif mode == 'remove' then + return D.Remove(self, tag) elseif tonumber(mode) ~= nil or mode == 'save' then -- either a number of the save command if mode == 'save' then @@ -370,7 +374,32 @@ end end +D.New = function(self, tag) + if tag and not self.sigID[tag] then + local id = D.max_channel + 1 + D.SetChannel(tag, id) + end +end +D.Remove = function(self, dest) + dest = D.sigID[dest] or tonumber(dest) + if D.console[dest] and D.channels[dest] then + for tag, tagDest in pairs(D.tags) do + for i = #tagDest, 0 do + -- work downward so we aren't skipping entries + if tagDest[i] == dest then + tremove(tagDest, i) + end + end + end + D.console[dest]:Hide() + D.channels[dest] = nil + tremove(D.console, dest) + tremove(D.dock.buttons, dest) + D:UpdateDock() + D:Print('Removed channel #'..dest) + end +end --- Creates a Devian-style output. -- The first argument describes the channel to output on, and the remaining arguments are concatenated in a manner similar to default print() @@ -410,16 +439,21 @@ -- color me timbers local pcolor if (not db.tagcolor[prefix]) and byName then - local c = { - rand(64,255), rand(64,255), rand(64,255) - } - if c[1] > 223 and c[2] > 223 and c[3] > 223 then - c[rand(1,3)] = rand(64,223) + if prefix:match('^%d+%.%d+$') then + pcolor = 'FFFFFF' + else + local c = { + rand(64,255), rand(64,255), rand(64,255) + } + if c[1] > 223 and c[2] > 223 and c[3] > 223 then + c[rand(1,3)] = rand(64,223) + end + db.tagcolor[prefix] = format('%02X%02X%02X', unpack(c)) + pcolor = db.tagcolor[prefix] end - - db.tagcolor[prefix] = format('%02X%02X%02X', unpack(c)) + else + pcolor = db.tagcolor[prefix] end - pcolor = db.tagcolor[prefix] local buffer = {} for i = 1, select('#',...) do @@ -449,6 +483,7 @@ if channel.width < 250 then prefix = sub(prefix, 0,2) end + --currentProfile.last_channel = channel.index channel.out:AddMessage('|cFF'.. pcolor..prefix ..'|r ' .. message, 0.8, 0.8, 0.8, nil, nil, prefix, GetTime()) if not D.dock.buttons[id].newMessage then D.dock.buttons[id].newMessage = true @@ -483,6 +518,7 @@ DevianDB[k] = v end end + _G.DevianLoadMessage = "Non-user SavedVars have been reset." _G.ReloadUI() end @@ -491,6 +527,11 @@ _G.DevianLoadMessage = "All SavedVars wiped." _G.ReloadUI() end + +D.UnsetColors = function() + db.tagcolor = {} + D:Print('Tag color cache cleared.') +end D.ConfigCommand = function(self, input) if not self.config then self.config = DevCon @@ -507,6 +548,7 @@ ['dvn'] = "Command", ['devian'] = "Command", ['dvc'] = "Console_Toggle", + ['dvncolors'] = "UnsetColors", ['cleandvn'] = "SetDefaultsAll", ['resetdvn'] = "SetDefaults", ['dvg'] = "ConfigCommand"