comparison UI.lua @ 70:d73b883b415b

Resolved channel state clobbering between reloads.
author Nenue
date Sat, 26 Mar 2016 13:57:17 -0400
parents e89244da507b
children da5ff1fc9fb6
comparison
equal deleted inserted replaced
69:e89244da507b 70:d73b883b415b
65 self:Save() 65 self:Save()
66 end 66 end
67 67
68 68
69 local function Console_Save(self) 69 local function Console_Save(self)
70 local db = D.channels[self.index] 70 local db = D.currentProfile.channels[self.index]
71 db.x = self:GetLeft() 71 db.x = self:GetLeft()
72 db.y = (self:GetTop() - GetScreenHeight()) 72 db.y = (self:GetTop() - GetScreenHeight())
73 db.width = self:GetWidth() 73 db.width = self:GetWidth()
74 74
75 if not self.minimized then 75 if not self.minimized then
78 end 78 end
79 79
80 db.dockedTo = self.dockedTo 80 db.dockedTo = self.dockedTo
81 db.docked = self.docked 81 db.docked = self.docked
82 82
83 db.minimized = self.minimized and true or nil 83 db.minimized = self.minimized
84 db.enabled = self:IsVisible() and true or nil 84 db.enabled = self.enabled
85 db.active = self.active and true or nil 85 db.active = self.active
86 self:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', db.x, db.y) 86 self:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', db.x, db.y)
87 self:SetWidth(db.width) 87 self:SetWidth(db.width)
88 end 88 end
89 89
90 --- Brings the console to the front. 90 --- Brings the console to the front.
173 end 173 end
174 if not vars then 174 if not vars then
175 vars = D.channels[i] and D.channels[i] or D.channels[db.primary_channel] 175 vars = D.channels[i] and D.channels[i] or D.channels[db.primary_channel]
176 end 176 end
177 local f 177 local f
178 f= CreateFrame('Frame', 'DevianChannelFrame' .. i, UIParent, DEVIAN_FRAME) 178 f = CreateFrame('Frame', 'DevianChannelFrame' .. i, UIParent, DEVIAN_FRAME)
179 179
180 --@debug@ 180 --@debug@
181 --print(f:GetName()) 181 --print(f:GetName())
182 182
183 --print('create(2)') 183 --print('create(2)')
312 ['docked'] = true, -- table 312 ['docked'] = true, -- table
313 ['dockedTo'] = true, -- table-related 313 ['dockedTo'] = true, -- table-related
314 ['signature'] = true} -- already determined 314 ['signature'] = true} -- already determined
315 for k,v in pairs(dbvars) do 315 for k,v in pairs(dbvars) do
316 if not t_info[k] and not blocked[k] then -- already set or blocked? 316 if not t_info[k] and not blocked[k] then -- already set or blocked?
317 --print('assign', k, '=', v)
317 t_info[k] = v 318 t_info[k] = v
318 end 319 end
319 end 320 end
320 -- new channel overrides 321 -- new channel overrides
321 if isNew then 322 if isNew then
358 else 359 else
359 channel:Maximize() 360 channel:Maximize()
360 end 361 end
361 362
362 if channel.enabled then -- hide or show last since Min/Max mess with visibility 363 if channel.enabled then -- hide or show last since Min/Max mess with visibility
363 --print('setchan(5a) enable') 364 --print('setchan(5a) enable')
364 channel:Show() 365 channel:Show()
365 --channel:ToFront() 366 --channel:ToFront()
366 else 367 else
367 --print('setchan(5a) disable') 368 --print('setchan(5a) disable')
368 channel:Hide() 369 channel:Hide()
379 local profile = D.currentProfile 380 local profile = D.currentProfile
380 local setAll 381 local setAll
381 local search = {} 382 local search = {}
382 local key 383 local key
383 local n = 0 384 local n = 0
384 while self:GetArgs(input,1,n) and n < 255 do --should end itself when it gets nil, but 385
385 key, n = self:GetArgs(input,1,n) 386 -- resolve key/sig values from args
386 387 while self:GetArgs(input,1,n) and n < 255 do
387 if self.sig[key] then 388 key, n = self:GetArgs(input,1,n)
388 --print(key, self.sigID[key]) 389
389 insert(search, self.sigID[key]) 390 if self.sig[key] then
390 elseif self.console[tonumber(key)] then 391 --print(key, self.sigID[key])
391 --print(key, tonumber(key)) 392 insert(search, self.sigID[key])
392 insert(search, tonumber(key)) 393 elseif self.console[tonumber(key)] then
393 end 394 --print(key, tonumber(key))
395 insert(search, tonumber(key))
396 end
394 397
395 --oldprint(#search, key, n) 398 --oldprint(#search, key, n)
396 end 399 end
400
401 -- if nothing was found, then do an all toggle
397 if #search < 1 then 402 if #search < 1 then
398 search = self.sigID 403 search = self.sigID -- using this since it lists frame ID's
399 setAll = true 404 setAll = true
400 end 405 end
406
407 -- sort global enable state
401 if setAll then 408 if setAll then
402 --oldprint('setall', setAll) 409 --oldprint('setall', setAll)
403 profile.enabled = (not profile.enabled) and true or nil 410 profile.enabled = (not profile.enabled) and true or nil
404 if force == 0 then 411 if force == 0 then
405 profile.enabled = nil 412 profile.enabled = nil
406 end 413 end
407 end 414 end
408 415
416 -- sort local enable states: if global enable, apply that change to channel
417 -- else, channel enable takes precedence
409 for i, id in pairs(search) do 418 for i, id in pairs(search) do
410 local c = self.console[id] 419 local c = self.console[id]
411 if setAll then 420 if setAll then
412 c.enabled = profile.enabled and profile.enabled or nil 421 c.enabled = profile.enabled
413 else 422 else
414
415 profile.enabled = true
416 c.enabled = (not c.enabled) and true or nil 423 c.enabled = (not c.enabled) and true or nil
417 if force == 0 then 424 if force == 0 then
418 c.enabled = nil 425 c.enabled = nil
419 end 426 end
420 end 427 end
421 428
422 if c.enabled or (setAll and profile.enabled) then 429 if c.enabled then
430 profile.enabled = true
423 c:Show() 431 c:Show()
424 elseif not (c.enabled and profile.enabled) then 432 else
425 c:Hide() 433 c:Hide()
426 end 434 end
427 c:Save() 435 c:Save()
428 end 436 end
429 437