diff 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
line wrap: on
line diff
--- a/Devian.lua	Wed Aug 10 07:12:43 2016 -0400
+++ b/Devian.lua	Wed Oct 19 16:47:38 2016 -0400
@@ -21,7 +21,7 @@
 local playerName = UnitName("player")
 local playerRealm = playerName .. '-' .. GetRealmName()
 local num_dock_tabs = 0
-
+local charStates ={}
 
 DevianLoadMessage = setmetatable({}, {
   __call = function(t, msg)
@@ -43,7 +43,7 @@
   if D.debugmode then
     return print('Dvn', ...)
   else
-    return function() end
+    return nop
   end
 end
 local print = D.print
@@ -169,7 +169,7 @@
 
   for k,v in pairs(src) do
     if not dest[k] then
-      oldprint('Rebuilding conf value', k)
+      --oldprint('Rebuilding conf value', k)
       if type(v) == 'table' then
         dest[k] = {}
         D.DeepCopy(v, dest[k], ...)
@@ -232,8 +232,8 @@
     setprinthandler(D.Message)
   else
     DEVIAN_WORKSPACE = false
-    DEVIAN_PNAME = ''
-    print = function() end
+    DEVIAN_PNAME = nil
+    print = nop
   end
   DEVIAN_PID =id
 
@@ -274,17 +274,20 @@
 
   -- no args, toggle ui
   if mode == 'rc' then
-    return D.ResetChannels(self, tag)
+    return D:ResetChannels(tag)
   elseif  mode == 'stack' then
     return D:StackFrames()
   elseif mode == 'grid' then
     return D:DistributeFrames()
   elseif mode == 'tag' then -- tagging
-    return D.Tag(self, tag, dest)
+    return D:Tag(tag, dest)
   elseif mode == 'new' then
-    return D.New(self, tag)
+    return D:New(tag)
+  elseif mode == 'dock' then
+    D.db.dockPoint = tag
+    return D:UpdateDock()
   elseif mode == 'remove' then
-    return D.Remove(self, tag)
+    return D:Remove(tag)
   elseif mode ~= nil then
     -- profile selector or save command
     if mode == 'save' then
@@ -363,6 +366,7 @@
 
 
   if scan_func then
+    wipe(charStates)
     for id, name, enableState, globalState in D.Addons() do
       scan_func(id, name, enableState, globalState)
     end
@@ -370,7 +374,32 @@
 
   if scan_func == D.Load then
     _G.ReloadUI()
+    if AddonList_Update then
+      AddonList_Update()
+    end
+  elseif (scan_func == D.Save) then
+    print('reckoning')
+    local updated = {}
+    for addon, newState in pairs(charStates) do
+      for character, addons in pairs(db.profiles[list_id].char) do
+        if addons[addon] then
+          print(addon, addons[addon], '::', newState)
+          if (addons[addon] ~= newState) then
+            addons[addon] = newState
+            updated[character] = (updated[character] or 0) + 1
+          end
+
+        end
+
+      end
+    end
+    for character, numAddons in pairs(updated) do
+      print(character, numAddons, 'settings')
+    end
+
   end
+
+
   D.Profile(db.current_profile)
 end
 
@@ -389,27 +418,36 @@
 end
 
 D.Load = function(id, name, charState, globalState)
-  if targetChar[name] or targetGlobal[name] then
-    if targetGlobal[name] == 2 then
-      EnableAddOn(id, true)
-    elseif targetChar[name] == 2 then
-      EnableAddOn(id, playerName)
-    else
-      if targetChar[name] == 2 and targetGlobal[name] ~= 2 then
-        DisableAddOn(id)
-      else
-        DisableAddOn(id, true)
-      end
-    end
-    --print('load', name, 'global =', targetGlobal[name], 'char =', targetChar[name])
-  else
+  print('load', tostring(name), tostring(charState), tostring(globalState))
+  if targetGlobal[name] == 2 then
+    EnableAddOn(id, true)
+  elseif targetChar[name] == 2 then
+    EnableAddOn(id, playerName)
+  elseif targetGlobal[name] == 0 then
+    DisableAddOn(id, true)
+  elseif targetChar[name] == 0 then
+    DisableAddOn(id, playerName)
+  end
+
+  if not (targetChar[name] or targetGlobal[name]) then
     tinsert(D.unlisted, name)
   end
+
 end
+
+
 D.Save = function(id, name, charState, globalState)
-  --print('save', id, name, charState, globalState)
+  if (charState ~= 0) or (globalState ~= 0) then
+    print('save', id, name, playerRealm .. ': '.. charState, 'All: '.. globalState)
+  end
+
   targetGlobal[name] = globalState
   targetChar[name] = charState
+
+  -- if enabling/disabling globally
+  if globalState ~= 1 then
+    charStates[name] = globalState
+  end
 end
 
 D.Tag = function(self, tag, dest)
@@ -492,7 +530,7 @@
     D.console[dest]:Hide()
     D.channels[dest] = nil
     tremove(D.console, dest)
-    tremove(D.dock.buttons, dest)
+    D.dock.buttons[dest]:SetShown(false)
     D:UpdateDock()
     D:Print('Removed channel #'..dest)
   end
@@ -589,9 +627,10 @@
     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
-      D.UpdateBeacon(D.dock.buttons[id])
+    if not D.dock.usedButtons[id].newMessage then
+      D.dock.usedButtons[id].newMessage = true
+      D.dock.usedButtons[id].caption.pulse:Play()
+      D.dock.usedButtons[id]:Update()
     end
   end
   wipe(buffer)
@@ -677,10 +716,10 @@
     _G['SLASH_' .. CMD .. '1'] = "/"..cmd
 
     if type(func == 'string') then
-      print('SLASH_' .. CMD .. '1','/'.. cmd, func)
+      --print('SLASH_' .. CMD .. '1','/'.. cmd, func)
       SlashCmdList[CMD] = D[func]
     else
-      print('SLASH_' .. CMD .. '1','/'.. cmd, func)
+      --print('SLASH_' .. CMD .. '1','/'.. cmd, func)
       SlashCmdList[CMD] = func
     end
   end