# HG changeset patch # User Nenue # Date 1451222385 18000 # Node ID bec37163b7fefac3863d1e0348248416b70b5178 # Parent 3304455a3f454d8a995cc3ab1cfd364bfbee5634 rewrote the blocks for '/dvn tag' and SetChannel to be more predictable; currently follows: /dvn tag if matches a channel, then the tag for is added or removed if is a string and it doesn't match a channel, then that channel is created with as a signature if is a number that doesn't match a channel index, then is set to , the channel is created under that, and is used as its signature SetChannel(cinfo, key) start with an empty table t_info that is filled in as follows: if key doesn't match a valid index/signature, then a channel is being created if key does match a valid index, then a channel is being updated if cinfo is a string, then only the signature value is imposed if cinfo is a table, the values from that table are imposed if a channel is being created, then the new channel info is filled in from primary channel, the index is auto-generated, and the signature value is checked for collision, and the information is passed through CreateConsole to form internal assignments if a channel is being updated, then t_info is populated from the channel data, and any internal table assignments are switched over to t_info the old tables sink into garbage collection diff -r 3304455a3f45 -r bec37163b7fe Devian.lua --- a/Devian.lua Sun Dec 27 03:51:17 2015 -0500 +++ b/Devian.lua Sun Dec 27 08:19:45 2015 -0500 @@ -8,6 +8,7 @@ Devian = LibStub("AceAddon-3.0"):NewAddon("Devian", "AceConsole-3.0", "AceEvent-3.0") local MAJOR, MINOR = 'Devian-1.3', 'r@project-revision@' local D = _G.Devian +local MSG_NEED_DEV_MODE = 'Must be in development mode to use this function.' local WORKSPACE_ON, WORKSPACE_OFF = 1, 2 local PLAYER_REALM = UnitName("player") .. '-' .. GetRealmName() local print = _G.print @@ -27,18 +28,19 @@ headergrad = {'VERTICAL', 0, 0, 0, 0.5, 0.1, 0.1, 0.1, 0.3}, -- header info headerdrop = {1,1,1,1}, headeralpha = 1, - backdrop = {0,0,0,1}, -- background frame info + headerfontcolor = {1,0.2,0.2,1}, + backdrop = {1,1,1,1}, -- background frame info backgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.3, 0, 0, 0, 0.5}, backblend = 'MOD', backalpha = 0.7, backborder = {0,0,1,0.75}, - frontdrop = {0,0,0,1}, -- foreground frame info - frontgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.9, 0, 0, 0, 0.9}, + frontdrop = {1,1,1,1}, -- foreground frame info + frontgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.8, 0, 0, 0, 0.6}, frontblend = 'MOD', frontalpha = 1, frontborder = {1,0,0,1}, tagcolor = {}, -- tag color repository - workspace = 1, -- current profile + workspace = 2, -- current profile last_workspace = 2 -- default workspace to alternate with when just "/dvn" is issued } @@ -114,18 +116,30 @@ return D:Print(MSG_NEED_DEV_MODE) end + local sig if tag ~= nil and dest ~= nil then + --@debug@ + print(tag, dest) + --@end-debug@ + -- convert to ID - if tonumber(dest) == nil and D.sigID[dest] then - dest = db.channels[D.sigID[dest]].index + if tonumber(dest) == nil then + if D.sigID[dest] then + dest = db.channels[D.sigID[dest]].index + else + sig = dest + end end + print('2 tag,dest,sig', tag, dest, sig) -- make a new channel? + local channel if not db.channels[dest] then - dest = db.max_channel + 1 - D:Print('Creating a new channel for '.. tag) - D:SetChannel(tag, dest) + dest = D.max_channel + 1 + D:Print('Created channel |cFF88FFFF'.. (sig and (dest..':'..sig) or dest ) .. '|r') + channel = D:SetChannel(sig or tag,dest) end + print('3',tag, dest) if db.tags[tag] and db.tags[tag][dest] then db.tags[tag][dest] = nil @@ -165,6 +179,13 @@ end -- start the iterating + if not db[PLAYER_REALM][list_state] then + db[PLAYER_REALM][list_state] = {} + end + if not db.global[list_state] then + db.global[list_state] = {} + end + local char_list, global_list = db[PLAYER_REALM][list_state], db.global[list_state] local playername = UnitName("player") @@ -332,23 +353,25 @@ } ReloadUI() end) + local blocked = {global = true, [PLAYER_REALM] = true} self:RegisterChatCommand("resetdvn", function(args) for k,v in pairs(DevianDB) do - if k ~= 'global' then + if not blocked[k] then DevianDB[k] = nil end end - + for k,v in pairs(defaults) do + if not blocked[k] then + DevianDB[k] = v + end + end DevianDB.load_message = "Non-user SavedVars have been reset." - for k,v in pairs(defaults) do - DevianDB[k] = v - end ReloadUI() end) local cmdlist = { ['dvn'] = ScanAddOnList, ['devian'] = ScanAddOnList, - ['dvc'] = Console_Toggle, + ['dvc'] = "Console_Toggle", } for cmd, func in pairs(cmdlist) do self:RegisterChatCommand(cmd, func, true) @@ -398,6 +421,7 @@ self.num_channels = self.num_channels + 1 end + for i, channel in pairs(db.channels) do if type(channel.docked) == 'table' then oldprint('docking',i, unpack(channel.docked)) @@ -413,4 +437,50 @@ print = function(...) _G.print('Dvn', ...) end +end + +--- Console frame toggler +-- @paramsig [...] +-- @param ... one or more space-seperated channel keys +function D:Console_Toggle(input) + oldprint(input) + if db.workspace == 1 then + return self:Print(MSG_NEED_DEV_MODE) + end + local search = {} + local n = 0 + if self:GetArgs(input,1) then + repeat + local key, n = self:GetArgs(input,1,n) + if self.sig[key] then + table.insert(search, self.sigID[key]) + elseif self.console[key] then + table.insert(search, tonumber(key)) + end + until n == 1e9 + else + search = self.sigID + end + + db.enabled = (not db.enabled) and true or nil + for i, id in pairs(search) do + oldprint(i, id) + local c = self.console[id] + if db.enabled then + c.enabled = true + c:Show() + if db.current_channel == c.index then + c:ToFront() + end + c:Save() + else + c:Hide() + end + end + + if db.enabled then + self:Print('toggled on: '..table.concat(search, ', ')) + else + self:Print('toggled off: '..table.concat(search, ', ')) + end end \ No newline at end of file diff -r 3304455a3f45 -r bec37163b7fe Devian.xml --- a/Devian.xml Sun Dec 27 03:51:17 2015 -0500 +++ b/Devian.xml Sun Dec 27 08:19:45 2015 -0500 @@ -12,7 +12,7 @@ - + @@ -25,17 +25,18 @@ - + diff -r 3304455a3f45 -r bec37163b7fe UI.lua --- a/UI.lua Sun Dec 27 03:51:17 2015 -0500 +++ b/UI.lua Sun Dec 27 08:19:45 2015 -0500 @@ -14,7 +14,6 @@ local DEVIAN_FRAME = 'DevianConsole' local DEVIAN_DOCK_FRAME = 'DevianDockFrame' -local MSG_NEED_DEV_MODE = 'Must be in development mode to use this function.' local function Console_MinMax(self) @@ -83,51 +82,6 @@ self:SetWidth(db.width) end --- Console frame toggler --- @paramsig [...] --- @param ... one or more space-seperated channel keys -local function Console_Toggle(input) - local db = D.db - if db.workspace == 1 then - return D:Print(MSG_NEED_DEV_MODE) - end - local search = {} - local n = 0 - if D:GetArgs(input,1) then - repeat - key, n = D:GetArgs(input,1,n) - if D.sig[key] then - table.insert(search, D.sig[key]) - elseif D.console[key] then - table.insert(search, D.console[key]) - end - until n == 1e9 - else - search = D.console - end - - db.enabled = (not db.enabled) and true or nil - for i, c in ipairs(search) do - --print(i,c.index) - if db.enabled then - c.enabled = true - c:Show() - if db.current_channel == c.index then - c:ToFront() - end - c:Save() - else - c:Hide() - end - end - - if db.enabled then - D:Print('toggled on?') - else - D:Print('toggled off?') - end -end - --- Brings the console to the front. -- Frame method used to bring a console frame to the front of the display stack. local function Console_ToFront(c) @@ -142,6 +96,8 @@ c.out.backdrop:SetTexture(unpack(db.frontdrop)) c.out.backdrop:SetGradientAlpha(unpack(db.frontgrad)) c.out.backdrop:SetBlendMode(db.frontblend) + c.dropmenu.icon:SetVertexColor(unpack(db.headerfontcolor)) + c.title:SetTextColor(unpack(db.headerfontcolor)) db.current_channel = c.index for _, part in pairs(c.border) do @@ -158,6 +114,8 @@ bc.out.backdrop:SetTexture(unpack(db.backdrop)) bc.out.backdrop:SetGradientAlpha(unpack(db.backgrad)) bc.out.backdrop:SetBlendMode(db.backblend) + bc.dropmenu.icon:SetVertexColor(unpack(db.backborder)) + bc.title:SetTextColor(unpack(db.backborder)) for _, part in pairs(bc.border) do part:SetTexture(unpack(db.backborder)) @@ -219,7 +177,7 @@ for k,v in pairs(vars) do f[k] = v --@debug@ - print(' f['..type(k)..' '..tostring(k)..'] = '..type(v)..' '..tostring(v)) + --print(' f['..type(k)..' '..tostring(k)..'] = '..type(v)..' '..tostring(v)) end f:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', vars.x, vars.y) @@ -228,12 +186,12 @@ f.out:SetFont(db.font, db.fontsize, db.fontoutline) if (db.current_channel == i) then f.out.backdrop:SetTexture(unpack(db.frontdrop)) + f.dropmenu.icon:SetVertexColor(unpack(db.headerfontcolor)) + f.title:SetTextColor(unpack(db.headerfontcolor)) else f.out.backdrop:SetTexture(unpack(db.backdrop)) end - - f.Save = Console_Save f.Minimize = Console_Minimize f.Maximize = Console_Maximize @@ -243,6 +201,26 @@ f:SetScript('OnMouseDown', Console_MouseDown) f:SetScript('OnMouseUp', Console_MouseUp) + + UIDropDownMenu_Initialize(f.menuFrame, function() + local info = { { + text= "Close", + value = "OptClose", + func = function () + f.enabled = nil + f:Hide() + f:Save() + end }, + { + text = "Dock", + value = "OptDock", + func = function() print('Dvn', 'docking shenanary') end } + } + for _, v in ipairs(info) do + UIDropDownMenu_AddButton(v) + end + end, 'MENU') + if vars.minimized then f:Minimize() else @@ -268,6 +246,8 @@ local db = self.db local t_info = {} local channel, isNew, id, sig, t_id + --@debug@ + print('setchan(0) cinfo, key', cinfo, key)--@end-debug@ -- obtain source data if tonumber(key) ~= nil and db.channels[key] then id = tonumber(key) @@ -281,7 +261,7 @@ t_id = id -- overridden later if new t_info.index = t_id -- --@debug@ - --print('setchan(1) cinfo, key, id=', cinfo, key, id)--@end-debug@ + print('setchan(1) cinfo, key, id=', cinfo, key, id)--@end-debug@ -- obtain config info @@ -299,7 +279,7 @@ end t_info.signature = sig --@debug@ - --print('setchan(2) sig,id,isNew=', sig, id, isNew)--@end-debug@ + print('setchan(2) sig,id,isNew=', sig, id, isNew)--@end-debug@ for k,v in pairs(cinfo) do -- allow all cinfo to pass t_info[k] = v @@ -324,23 +304,25 @@ end t_info.signature = result end - t_id = db.max_channel + 1 + t_id = self.max_channel + 1 t_info.index = t_id --@debug@ - --print('setchan(3a) isNew, sig, t_info.signature=', isNew, sig, t_info.signature)--@end-debug@ + print('setchan(3a) t_id, isNew, sig, t_info.signature=', t_id, isNew, sig, t_info.signature)--@end-debug@ else --@debug@ - --print('setchan(3b) isNew, sig, t_info.signature=', isNew, sig, t_info.signature)--@end-debug@ + print('setchan(3b) t_id, isNew, sig, t_info.signature=', t_id, isNew, sig, t_info.signature)--@end-debug@ end local channel if not self.console[t_id] then -- create a frame if isNew then -- position the channel frame - t_info.x = t_info.x + 20 - t_info.y = t_info.y - 20 - db.channels[t_id] = t_info - --@debug@ - print('setchan(4a)', 't_id, x, y=', t_id, t_info.x, t_info.y)--@end-debug@ + self.max_channel = t_id + db.max_channel = t_id + t_info.x = t_info.x + 20 + t_info.y = t_info.y - 20 + db.channels[t_id] = t_info + --@debug@ + print('setchan(4a)', 't_id, x, y=', t_id, t_info.x, t_info.y)--@end-debug@ end channel = CreateConsole(t_id, t_info) self.console[t_id] = channel