comparison Devian.lua @ 93:f6fae1a4c66c v2.2.95-rc1

- revision and simplification dock layout - fixed character-specific addon choices getting erroneously toggled The XML template was missing header information; that has been filled in, and it should be easier to catch problems arising from that area.
author Nenue
date Wed, 19 Oct 2016 16:47:38 -0400
parents 4370eefcecdd
children 33bc8baba858
comparison
equal deleted inserted replaced
92:4370eefcecdd 93:f6fae1a4c66c
19 local tinsert, tremove, rawset = tinsert, tremove, rawset 19 local tinsert, tremove, rawset = tinsert, tremove, rawset
20 local currentProfile 20 local currentProfile
21 local playerName = UnitName("player") 21 local playerName = UnitName("player")
22 local playerRealm = playerName .. '-' .. GetRealmName() 22 local playerRealm = playerName .. '-' .. GetRealmName()
23 local num_dock_tabs = 0 23 local num_dock_tabs = 0
24 24 local charStates ={}
25 25
26 DevianLoadMessage = setmetatable({}, { 26 DevianLoadMessage = setmetatable({}, {
27 __call = function(t, msg) 27 __call = function(t, msg)
28 rawset(t, #t+1, msg) 28 rawset(t, #t+1, msg)
29 end, 29 end,
41 end 41 end
42 42
43 if D.debugmode then 43 if D.debugmode then
44 return print('Dvn', ...) 44 return print('Dvn', ...)
45 else 45 else
46 return function() end 46 return nop
47 end 47 end
48 end 48 end
49 local print = D.print 49 local print = D.print
50 50
51 D.L = setmetatable({}, { 51 D.L = setmetatable({}, {
167 -- If he value is a function, then it will invoke f(...) and use whatever gets returned 167 -- If he value is a function, then it will invoke f(...) and use whatever gets returned
168 function D.DeepCopy(src, dest, ...) 168 function D.DeepCopy(src, dest, ...)
169 169
170 for k,v in pairs(src) do 170 for k,v in pairs(src) do
171 if not dest[k] then 171 if not dest[k] then
172 oldprint('Rebuilding conf value', k) 172 --oldprint('Rebuilding conf value', k)
173 if type(v) == 'table' then 173 if type(v) == 'table' then
174 dest[k] = {} 174 dest[k] = {}
175 D.DeepCopy(v, dest[k], ...) 175 D.DeepCopy(v, dest[k], ...)
176 176
177 else 177 else
230 DEVIAN_PNAME = currentProfile.name 230 DEVIAN_PNAME = currentProfile.name
231 DEVIAN_PID = id 231 DEVIAN_PID = id
232 setprinthandler(D.Message) 232 setprinthandler(D.Message)
233 else 233 else
234 DEVIAN_WORKSPACE = false 234 DEVIAN_WORKSPACE = false
235 DEVIAN_PNAME = '' 235 DEVIAN_PNAME = nil
236 print = function() end 236 print = nop
237 end 237 end
238 DEVIAN_PID =id 238 DEVIAN_PID =id
239 239
240 D.unlisted = currentProfile.unlisted 240 D.unlisted = currentProfile.unlisted
241 D.channels = currentProfile.channels 241 D.channels = currentProfile.channels
272 local mode, tag, dest = unpack(args) 272 local mode, tag, dest = unpack(args)
273 273
274 274
275 -- no args, toggle ui 275 -- no args, toggle ui
276 if mode == 'rc' then 276 if mode == 'rc' then
277 return D.ResetChannels(self, tag) 277 return D:ResetChannels(tag)
278 elseif mode == 'stack' then 278 elseif mode == 'stack' then
279 return D:StackFrames() 279 return D:StackFrames()
280 elseif mode == 'grid' then 280 elseif mode == 'grid' then
281 return D:DistributeFrames() 281 return D:DistributeFrames()
282 elseif mode == 'tag' then -- tagging 282 elseif mode == 'tag' then -- tagging
283 return D.Tag(self, tag, dest) 283 return D:Tag(tag, dest)
284 elseif mode == 'new' then 284 elseif mode == 'new' then
285 return D.New(self, tag) 285 return D:New(tag)
286 elseif mode == 'dock' then
287 D.db.dockPoint = tag
288 return D:UpdateDock()
286 elseif mode == 'remove' then 289 elseif mode == 'remove' then
287 return D.Remove(self, tag) 290 return D:Remove(tag)
288 elseif mode ~= nil then 291 elseif mode ~= nil then
289 -- profile selector or save command 292 -- profile selector or save command
290 if mode == 'save' then 293 if mode == 'save' then
291 list_id = tonumber(tag) 294 list_id = tonumber(tag)
292 else 295 else
361 targetGlobal = db.profiles[list_id].global 364 targetGlobal = db.profiles[list_id].global
362 targetChar = db.profiles[list_id].char[playerRealm] 365 targetChar = db.profiles[list_id].char[playerRealm]
363 366
364 367
365 if scan_func then 368 if scan_func then
369 wipe(charStates)
366 for id, name, enableState, globalState in D.Addons() do 370 for id, name, enableState, globalState in D.Addons() do
367 scan_func(id, name, enableState, globalState) 371 scan_func(id, name, enableState, globalState)
368 end 372 end
369 end 373 end
370 374
371 if scan_func == D.Load then 375 if scan_func == D.Load then
372 _G.ReloadUI() 376 _G.ReloadUI()
373 end 377 if AddonList_Update then
378 AddonList_Update()
379 end
380 elseif (scan_func == D.Save) then
381 print('reckoning')
382 local updated = {}
383 for addon, newState in pairs(charStates) do
384 for character, addons in pairs(db.profiles[list_id].char) do
385 if addons[addon] then
386 print(addon, addons[addon], '::', newState)
387 if (addons[addon] ~= newState) then
388 addons[addon] = newState
389 updated[character] = (updated[character] or 0) + 1
390 end
391
392 end
393
394 end
395 end
396 for character, numAddons in pairs(updated) do
397 print(character, numAddons, 'settings')
398 end
399
400 end
401
402
374 D.Profile(db.current_profile) 403 D.Profile(db.current_profile)
375 end 404 end
376 405
377 D.Addons = function() 406 D.Addons = function()
378 local playername = UnitName("player") 407 local playername = UnitName("player")
387 return i, name, enableState, globalState 416 return i, name, enableState, globalState
388 end, GetNumAddOns(), 0 417 end, GetNumAddOns(), 0
389 end 418 end
390 419
391 D.Load = function(id, name, charState, globalState) 420 D.Load = function(id, name, charState, globalState)
392 if targetChar[name] or targetGlobal[name] then 421 print('load', tostring(name), tostring(charState), tostring(globalState))
393 if targetGlobal[name] == 2 then 422 if targetGlobal[name] == 2 then
394 EnableAddOn(id, true) 423 EnableAddOn(id, true)
395 elseif targetChar[name] == 2 then 424 elseif targetChar[name] == 2 then
396 EnableAddOn(id, playerName) 425 EnableAddOn(id, playerName)
397 else 426 elseif targetGlobal[name] == 0 then
398 if targetChar[name] == 2 and targetGlobal[name] ~= 2 then 427 DisableAddOn(id, true)
399 DisableAddOn(id) 428 elseif targetChar[name] == 0 then
400 else 429 DisableAddOn(id, playerName)
401 DisableAddOn(id, true) 430 end
402 end 431
403 end 432 if not (targetChar[name] or targetGlobal[name]) then
404 --print('load', name, 'global =', targetGlobal[name], 'char =', targetChar[name])
405 else
406 tinsert(D.unlisted, name) 433 tinsert(D.unlisted, name)
407 end 434 end
408 end 435
436 end
437
438
409 D.Save = function(id, name, charState, globalState) 439 D.Save = function(id, name, charState, globalState)
410 --print('save', id, name, charState, globalState) 440 if (charState ~= 0) or (globalState ~= 0) then
441 print('save', id, name, playerRealm .. ': '.. charState, 'All: '.. globalState)
442 end
443
411 targetGlobal[name] = globalState 444 targetGlobal[name] = globalState
412 targetChar[name] = charState 445 targetChar[name] = charState
446
447 -- if enabling/disabling globally
448 if globalState ~= 1 then
449 charStates[name] = globalState
450 end
413 end 451 end
414 452
415 D.Tag = function(self, tag, dest) 453 D.Tag = function(self, tag, dest)
416 local sig 454 local sig
417 if tag ~= nil and dest ~= nil then 455 if tag ~= nil and dest ~= nil then
490 end 528 end
491 end 529 end
492 D.console[dest]:Hide() 530 D.console[dest]:Hide()
493 D.channels[dest] = nil 531 D.channels[dest] = nil
494 tremove(D.console, dest) 532 tremove(D.console, dest)
495 tremove(D.dock.buttons, dest) 533 D.dock.buttons[dest]:SetShown(false)
496 D:UpdateDock() 534 D:UpdateDock()
497 D:Print('Removed channel #'..dest) 535 D:Print('Removed channel #'..dest)
498 end 536 end
499 end 537 end
500 538
587 if channel.width < 250 then 625 if channel.width < 250 then
588 prefix = sub(prefix, 0,2) 626 prefix = sub(prefix, 0,2)
589 end 627 end
590 --currentProfile.last_channel = channel.index 628 --currentProfile.last_channel = channel.index
591 channel.out:AddMessage('|cFF'.. pcolor..prefix ..'|r ' .. message, 0.8, 0.8, 0.8, nil, nil, prefix, GetTime()) 629 channel.out:AddMessage('|cFF'.. pcolor..prefix ..'|r ' .. message, 0.8, 0.8, 0.8, nil, nil, prefix, GetTime())
592 if not D.dock.buttons[id].newMessage then 630 if not D.dock.usedButtons[id].newMessage then
593 D.dock.buttons[id].newMessage = true 631 D.dock.usedButtons[id].newMessage = true
594 D.UpdateBeacon(D.dock.buttons[id]) 632 D.dock.usedButtons[id].caption.pulse:Play()
633 D.dock.usedButtons[id]:Update()
595 end 634 end
596 end 635 end
597 wipe(buffer) 636 wipe(buffer)
598 end 637 end
599 638
675 for cmd, func in pairs(cmdlist) do 714 for cmd, func in pairs(cmdlist) do
676 local CMD = cmd:upper() 715 local CMD = cmd:upper()
677 _G['SLASH_' .. CMD .. '1'] = "/"..cmd 716 _G['SLASH_' .. CMD .. '1'] = "/"..cmd
678 717
679 if type(func == 'string') then 718 if type(func == 'string') then
680 print('SLASH_' .. CMD .. '1','/'.. cmd, func) 719 --print('SLASH_' .. CMD .. '1','/'.. cmd, func)
681 SlashCmdList[CMD] = D[func] 720 SlashCmdList[CMD] = D[func]
682 else 721 else
683 print('SLASH_' .. CMD .. '1','/'.. cmd, func) 722 --print('SLASH_' .. CMD .. '1','/'.. cmd, func)
684 SlashCmdList[CMD] = func 723 SlashCmdList[CMD] = func
685 end 724 end
686 end 725 end
687 726
688 --- initialize the current profile 727 --- initialize the current profile