Mercurial > wow > devian
comparison 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 |
comparison
equal
deleted
inserted
replaced
98:33bc8baba858 | 99:7d94df3804a7 |
---|---|
221 oldprint('fixing channels data') | 221 oldprint('fixing channels data') |
222 table.sort(sortedChannels, function(a,b) | 222 table.sort(sortedChannels, function(a,b) |
223 return (b.index > a.index) | 223 return (b.index > a.index) |
224 end) | 224 end) |
225 for i, info in ipairs(sortedChannels) do | 225 for i, info in ipairs(sortedChannels) do |
226 | |
227 info.tags = info.tags or {} | |
226 for tag, tagSet in pairs(currentProfile.tags) do | 228 for tag, tagSet in pairs(currentProfile.tags) do |
227 for _, index in pairs(tagSet) do | 229 for _, index in pairs(tagSet) do |
228 if index == info.index then | 230 if index == info.index then |
229 sortedTags[tag] = sortedTags[tag] or {} | 231 sortedTags[tag] = sortedTags[tag] or {} |
230 sortedTags[tag][i] = i | 232 sortedTags[tag][i] = i |
233 tinsert(info.tags, tag) | |
231 end | 234 end |
232 end | 235 end |
233 end | 236 end |
237 print('Set tags:', table.concat(info.tags, ', ')) | |
234 | 238 |
235 info.index = i | 239 info.index = i |
236 end | 240 end |
237 currentProfile.channels = sortedChannels | 241 currentProfile.channels = sortedChannels |
238 currentProfile.tags = sortedTags | 242 currentProfile.tags = sortedTags |
285 currentProfile.char[playerRealm] = currentProfile.char[playerRealm] or {} | 289 currentProfile.char[playerRealm] = currentProfile.char[playerRealm] or {} |
286 if currentProfile.workspace then | 290 if currentProfile.workspace then |
287 DEVIAN_WORKSPACE = true | 291 DEVIAN_WORKSPACE = true |
288 DEVIAN_PNAME = currentProfile.name | 292 DEVIAN_PNAME = currentProfile.name |
289 DEVIAN_PID = id | 293 DEVIAN_PID = id |
290 print('setting phandler') | |
291 setprinthandler(D.Message) | 294 setprinthandler(D.Message) |
292 else | 295 else |
293 DEVIAN_WORKSPACE = false | 296 DEVIAN_WORKSPACE = false |
294 DEVIAN_PNAME = nil | 297 DEVIAN_PNAME = nil |
295 print = nop | 298 print = nop |
520 charStates[name] = globalState | 523 charStates[name] = globalState |
521 end | 524 end |
522 end | 525 end |
523 | 526 |
524 D.UpdateTags = function() | 527 D.UpdateTags = function() |
525 | |
526 wipe(registeredTags) | 528 wipe(registeredTags) |
527 for tag, tagSet in pairs(currentProfile.tags) do | 529 for index, channel in ipairs(D.channels) do |
528 registeredTags[tag] = registeredTags[tag] or {} | 530 for _, tag in ipairs(channel.tags) do |
529 for _, id in pairs(tagSet) do | 531 registeredTags[tag] = registeredTags[tag] or {} |
530 if D.console[id] then | 532 tinsert(registeredTags[tag], D.console[index]) |
531 tinsert(registeredTags[tag], D.console[id]) | 533 end |
532 end | 534 end |
533 end | 535 end |
534 end | 536 |
535 end | 537 D.Tag = function(self, tag, id) |
536 | |
537 D.Tag = function(self, tag, dest) | |
538 local sig | 538 local sig |
539 if tag ~= nil and dest ~= nil then | 539 if tag and id then |
540 --@debug@ | 540 --@debug@ |
541 --print(tag, dest) | 541 --print(tag, dest) |
542 --@end-debug@ | 542 --@end-debug@ |
543 | 543 |
544 -- convert to ID | 544 -- convert to ID |
545 if tonumber(dest) == nil then | 545 local channel, sig |
546 if D.sigID[dest] then | 546 if tonumber(id) == nil then |
547 dest = currentProfile.channels[D.sigID[dest]].index | 547 sig = id |
548 else | 548 if D.sigID[id] then |
549 sig = dest | 549 id = D.sigID[id] |
550 channel = D.channels[id] | |
550 end | 551 end |
551 else | 552 else |
552 dest = tonumber(dest) | 553 id = tonumber(id) |
553 end | 554 channel = D.channels[id] |
554 --@debug@ | 555 end |
555 --print('2 tag,dest,sig', tag, dest, sig)--@end-debug@ | 556 |
556 | 557 -- if channel is still nil, create one |
557 -- make a new channel? | 558 if not channel then |
558 local channel | 559 id = #D.channels + 1 |
559 if not currentProfile.channels[dest] then | 560 D:Print(L('New channel created', (sig and (id..':'..sig)) or id)) |
560 dest = #D.channels + 1 | 561 channel = D:GetOrCreateChannel(id, sig) |
561 D:Print(L('New channel created', sig and (dest..':'..sig) or dest )) | |
562 channel = D:GetOrCreateChannel(dest, tag) | |
563 else | 562 else |
564 channel = currentProfile.channels[dest] | 563 sig = channel.signature |
565 end | 564 end |
566 --@debug@ | 565 --@debug@ |
567 --print('3 tag,dest,channel.sig=',tag, dest, channel.signature)--@end-debug@ | 566 --print('3 tag,dest,channel.sig=',tag, dest, channel.signature)--@end-debug@ |
568 | 567 |
569 if not currentProfile.tags[tag] then -- no tag table? | 568 if not currentProfile.tags[tag] then -- no tag table? |
570 currentProfile.tags[tag] = {} | 569 currentProfile.tags[tag] = {} |
571 end | 570 end |
572 | 571 |
573 if currentProfile.tags[tag][dest] then -- is tag set? | 572 local existingTag = tContains(channel.tags, tag) |
574 currentProfile.tags[tag][dest] = nil | 573 if existingTag then -- is tag set? |
575 D:Print(L('Tag removed from channel', tag, currentProfile.channels[dest].index, currentProfile.channels[dest].signature)) | 574 |
575 for i, tag in ipairs(channel.tags) do | |
576 if tag == tag then | |
577 tremove(channel.tags, i) | |
578 D:Print(L('Tag removed from channel', tag, channel.index, channel.signature)) | |
579 break | |
580 end | |
581 end | |
576 else | 582 else |
577 currentProfile.tags[tag][dest] = dest | 583 tinsert(channel.tags, tag) |
578 D:Print(L('Tag added to channel', tag, channel.index, channel.signature)) | 584 D:Print(L('Tag added to channel', tag, channel.index, channel.signature)) |
579 end | 585 end |
580 D.UpdateTags() | 586 D.UpdateTags() |
581 DevianDock:Update() | 587 DevianDock:Update() |
582 else | 588 else |
858 function D:GetActiveChannel() | 864 function D:GetActiveChannel() |
859 return D.console[currentProfile.current_channel] | 865 return D.console[currentProfile.current_channel] |
860 end | 866 end |
861 | 867 |
862 function D:GetOrCreateChannel(id, name) | 868 function D:GetOrCreateChannel(id, name) |
869 id = id or (#D.channels + 1) | |
870 | |
863 local info = D.channels[id] | 871 local info = D.channels[id] |
872 if not info then | |
873 --print('new channel') | |
874 name = name or ('Channel ' .. id) | |
875 info = { | |
876 index = id, | |
877 signature = name, | |
878 tags = {} | |
879 } | |
880 D.DeepCopy(defaults.default_channel, info) | |
881 D.channels[id] = info | |
882 elseif not info.tags then | |
883 -- fix old data? | |
884 info.tags = {info.signature} | |
885 oldprint(D.db) | |
886 for tag, tagSet in pairs(D.tags) do | |
887 for _, index in pairs(tagSet) do | |
888 if index == id then | |
889 tinsert(info.tags, tag) | |
890 end | |
891 end | |
892 end | |
893 end | |
894 | |
864 local frame = D.console[id] | 895 local frame = D.console[id] |
865 if not frame then | 896 if not frame then |
866 | 897 |
867 --print('new frame') | 898 if DEVIAN_WORKSPACE then |
899 D:Print('Adding '.. (info.index) .. ':' .. (info.signature) .. ' (|cFF00FFFF'.. concat(info.tags, '|r; |cFF00FFFF')..'|r)') | |
900 end | |
868 frame = CreateFrame('Frame', 'DevianConsole'..id, Devian, 'DevianConsoleTemplate') | 901 frame = CreateFrame('Frame', 'DevianConsole'..id, Devian, 'DevianConsoleTemplate') |
869 frame:SetID(id) | 902 frame:SetID(id) |
870 D.console[id] = frame | 903 D.console[id] = frame |
871 end | 904 D.sigID[info.signature] = id |
872 if not info then | 905 end |
873 --print('new channel') | |
874 info = { | |
875 } | |
876 D.DeepCopy(defaults.default_channel, info) | |
877 info.index = id | |
878 info.signature = name | |
879 D.channels[id] = info | |
880 end | |
881 | |
882 | 906 |
883 frame:Setup(info) | 907 frame:Setup(info) |
884 return frame | 908 return frame |
885 end | 909 end |