# HG changeset patch # User Nenue # Date 1460198044 14400 # Node ID 3745540e8996fc6b4e7d4346e16c63a690b43686 # Parent da5ff1fc9fb678d2560d71d062d44c78ff3d81e6 - 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 diff -r da5ff1fc9fb6 -r 3745540e8996 Devian.lua --- 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" diff -r da5ff1fc9fb6 -r 3745540e8996 Dock.lua --- a/Dock.lua Sat Apr 09 05:51:19 2016 -0400 +++ b/Dock.lua Sat Apr 09 06:34:04 2016 -0400 @@ -47,10 +47,17 @@ function D:UpdateDock() local pad_offset = 12 local draw_offset = pad_offset - for i = 1, #self.dock.buttons do + + local dockn = 1 + for i, d in pairs(self.dock.buttons) do + dockn = max(i, dockn) + end + for i = 1, dockn do local d = self.dock.buttons[i] - d:SetPoint('TOPLEFT', DevianDock, 'TOPLEFT', draw_offset, 0) - draw_offset= draw_offset + d:GetWidth() + pad_offset + if d then + d:SetPoint('TOPLEFT', DevianDock, 'TOPLEFT', draw_offset, 0) + draw_offset= draw_offset + d:GetWidth() + pad_offset + end end self.dock:SetWidth(draw_offset) end