changeset 70:d73b883b415b

Resolved channel state clobbering between reloads.
author Nenue
date Sat, 26 Mar 2016 13:57:17 -0400
parents e89244da507b
children d636ff1b17ce
files Devian.lua UI.lua
diffstat 2 files changed, 33 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/Devian.lua	Tue Mar 15 20:06:56 2016 -0400
+++ b/Devian.lua	Sat Mar 26 13:57:17 2016 -0400
@@ -302,15 +302,15 @@
     elseif targetChar[name] == 2 then
       EnableAddOn(id, playerName)
     else
-      DisableAddOn(id, playerName)
+      DisableAddOn(id)
     end
-    print('load', name, 'global =', targetGlobal[name], 'char =', targetChar[name])
+    --print('load', name, 'global =', targetGlobal[name], 'char =', targetChar[name])
   else
     tinsert(D.unlisted, name)
   end
 end
 D.Save = function(id, name, charState, globalState)
-  print('save', id, name, charState, globalState)
+  --print('save', id, name, charState, globalState)
   targetGlobal[name] = globalState
   targetChar[name] = charState
 end
@@ -483,7 +483,7 @@
   DevianLoadMessage = "All SavedVars wiped."
   ReloadUI()
 end
-D.ConfigCommand = function(input)
+D.ConfigCommand = function(self, input)
   if not self.config then
     self.config = DevCon
     self:EnableModule("Config")
--- a/UI.lua	Tue Mar 15 20:06:56 2016 -0400
+++ b/UI.lua	Sat Mar 26 13:57:17 2016 -0400
@@ -67,7 +67,7 @@
 
 
 local function Console_Save(self)
-  local db = D.channels[self.index]
+  local db = D.currentProfile.channels[self.index]
     db.x = self:GetLeft()
     db.y = (self:GetTop() - GetScreenHeight())
     db.width = self:GetWidth()
@@ -80,9 +80,9 @@
   db.dockedTo = self.dockedTo
   db.docked = self.docked
 
-  db.minimized = self.minimized and true or nil
-  db.enabled = self:IsVisible() and true or nil
-  db.active = self.active and true or nil
+  db.minimized = self.minimized
+  db.enabled = self.enabled
+  db.active = self.active
   self:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', db.x, db.y)
   self:SetWidth(db.width)
 end
@@ -175,7 +175,7 @@
     vars = D.channels[i] and D.channels[i] or D.channels[db.primary_channel]
   end
   local f
-  f= CreateFrame('Frame', 'DevianChannelFrame' .. i, UIParent, DEVIAN_FRAME)
+  f = CreateFrame('Frame', 'DevianChannelFrame' .. i, UIParent, DEVIAN_FRAME)
 
   --@debug@
   --print(f:GetName())
@@ -314,6 +314,7 @@
     ['signature'] = true}    -- already determined
   for k,v in pairs(dbvars) do
     if not t_info[k] and not blocked[k] then -- already set or blocked?
+    --print('assign', k, '=', v)
     t_info[k] = v
     end
   end
@@ -360,7 +361,7 @@
   end
 
   if channel.enabled then -- hide or show last since Min/Max mess with visibility
-  --print('setchan(5a) enable')
+    --print('setchan(5a) enable')
     channel:Show()
     --channel:ToFront()
   else
@@ -381,23 +382,29 @@
   local search = {}
   local key
   local n = 0
-  while self:GetArgs(input,1,n) and n < 255 do --should end itself when it gets nil, but
-  key, n = self:GetArgs(input,1,n)
 
-  if self.sig[key] then
-    --print(key, self.sigID[key])
-    insert(search, self.sigID[key])
-  elseif self.console[tonumber(key)] then
-    --print(key, tonumber(key))
-    insert(search, tonumber(key))
-  end
+  -- resolve key/sig values from args
+  while self:GetArgs(input,1,n) and n < 255 do
+    key, n = self:GetArgs(input,1,n)
+
+    if self.sig[key] then
+      --print(key, self.sigID[key])
+      insert(search, self.sigID[key])
+    elseif self.console[tonumber(key)] then
+      --print(key, tonumber(key))
+      insert(search, tonumber(key))
+    end
 
   --oldprint(#search, key, n)
   end
+
+  -- if nothing was found, then do an all toggle
   if #search < 1 then
-    search = self.sigID
+    search = self.sigID -- using this since it lists frame ID's
     setAll = true
   end
+
+  -- sort global enable state
   if setAll then
     --oldprint('setall', setAll)
     profile.enabled = (not profile.enabled) and true or nil
@@ -406,22 +413,23 @@
     end
   end
 
+  -- sort local enable states: if global enable, apply that change to channel
+  -- else, channel enable takes precedence
   for i, id in pairs(search) do
     local c = self.console[id]
     if setAll then
-      c.enabled = profile.enabled and profile.enabled or nil
+      c.enabled = profile.enabled
     else
-
-      profile.enabled = true
       c.enabled = (not c.enabled) and true or nil
       if force == 0 then
         c.enabled = nil
       end
     end
 
-    if c.enabled or (setAll and profile.enabled) then
+    if c.enabled then
+      profile.enabled = true
       c:Show()
-    elseif not (c.enabled and profile.enabled) then
+    else
       c:Hide()
     end
     c:Save()