Mercurial > wow > devian
diff Devian.lua @ 99:7d94df3804a7
- Console drag buttons for resizing
- While dragging a console frame, other frames are ghosted out
- Dropdown menu includes Toggle, Pin, and MinMax
author | Nenue |
---|---|
date | Thu, 27 Oct 2016 06:11:04 -0400 |
parents | 33bc8baba858 |
children | 790dca545f1d |
line wrap: on
line diff
--- a/Devian.lua Wed Oct 26 10:17:43 2016 -0400 +++ b/Devian.lua Thu Oct 27 06:11:04 2016 -0400 @@ -223,14 +223,18 @@ return (b.index > a.index) end) for i, info in ipairs(sortedChannels) do + + info.tags = info.tags or {} for tag, tagSet in pairs(currentProfile.tags) do for _, index in pairs(tagSet) do if index == info.index then sortedTags[tag] = sortedTags[tag] or {} sortedTags[tag][i] = i + tinsert(info.tags, tag) end end end + print('Set tags:', table.concat(info.tags, ', ')) info.index = i end @@ -287,7 +291,6 @@ DEVIAN_WORKSPACE = true DEVIAN_PNAME = currentProfile.name DEVIAN_PID = id - print('setting phandler') setprinthandler(D.Message) else DEVIAN_WORKSPACE = false @@ -522,59 +525,62 @@ end D.UpdateTags = function() - wipe(registeredTags) - for tag, tagSet in pairs(currentProfile.tags) do - registeredTags[tag] = registeredTags[tag] or {} - for _, id in pairs(tagSet) do - if D.console[id] then - tinsert(registeredTags[tag], D.console[id]) - end + for index, channel in ipairs(D.channels) do + for _, tag in ipairs(channel.tags) do + registeredTags[tag] = registeredTags[tag] or {} + tinsert(registeredTags[tag], D.console[index]) end end end -D.Tag = function(self, tag, dest) +D.Tag = function(self, tag, id) local sig - if tag ~= nil and dest ~= nil then + if tag and id then --@debug@ --print(tag, dest) --@end-debug@ -- convert to ID - if tonumber(dest) == nil then - if D.sigID[dest] then - dest = currentProfile.channels[D.sigID[dest]].index - else - sig = dest + local channel, sig + if tonumber(id) == nil then + sig = id + if D.sigID[id] then + id = D.sigID[id] + channel = D.channels[id] end else - dest = tonumber(dest) + id = tonumber(id) + channel = D.channels[id] end - --@debug@ - --print('2 tag,dest,sig', tag, dest, sig)--@end-debug@ - -- make a new channel? - local channel - if not currentProfile.channels[dest] then - dest = #D.channels + 1 - D:Print(L('New channel created', sig and (dest..':'..sig) or dest )) - channel = D:GetOrCreateChannel(dest, tag) + -- if channel is still nil, create one + if not channel then + id = #D.channels + 1 + D:Print(L('New channel created', (sig and (id..':'..sig)) or id)) + channel = D:GetOrCreateChannel(id, sig) else - channel = currentProfile.channels[dest] + sig = channel.signature end --@debug@ --print('3 tag,dest,channel.sig=',tag, dest, channel.signature)--@end-debug@ if not currentProfile.tags[tag] then -- no tag table? - currentProfile.tags[tag] = {} + currentProfile.tags[tag] = {} end - if currentProfile.tags[tag][dest] then -- is tag set? - currentProfile.tags[tag][dest] = nil - D:Print(L('Tag removed from channel', tag, currentProfile.channels[dest].index, currentProfile.channels[dest].signature)) + local existingTag = tContains(channel.tags, tag) + if existingTag then -- is tag set? + + for i, tag in ipairs(channel.tags) do + if tag == tag then + tremove(channel.tags, i) + D:Print(L('Tag removed from channel', tag, channel.index, channel.signature)) + break + end + end else - currentProfile.tags[tag][dest] = dest + tinsert(channel.tags, tag) D:Print(L('Tag added to channel', tag, channel.index, channel.signature)) end D.UpdateTags() @@ -860,25 +866,43 @@ end function D:GetOrCreateChannel(id, name) + id = id or (#D.channels + 1) + local info = D.channels[id] + if not info then + --print('new channel') + name = name or ('Channel ' .. id) + info = { + index = id, + signature = name, + tags = {} + } + D.DeepCopy(defaults.default_channel, info) + D.channels[id] = info + elseif not info.tags then + -- fix old data? + info.tags = {info.signature} + oldprint(D.db) + for tag, tagSet in pairs(D.tags) do + for _, index in pairs(tagSet) do + if index == id then + tinsert(info.tags, tag) + end + end + end + end + local frame = D.console[id] if not frame then - --print('new frame') + if DEVIAN_WORKSPACE then + D:Print('Adding '.. (info.index) .. ':' .. (info.signature) .. ' (|cFF00FFFF'.. concat(info.tags, '|r; |cFF00FFFF')..'|r)') + end frame = CreateFrame('Frame', 'DevianConsole'..id, Devian, 'DevianConsoleTemplate') frame:SetID(id) D.console[id] = frame + D.sigID[info.signature] = id end - if not info then - --print('new channel') - info = { - } - D.DeepCopy(defaults.default_channel, info) - info.index = id - info.signature = name - D.channels[id] = info - end - frame:Setup(info) return frame