Mercurial > wow > devian
comparison Devian.lua @ 33:e6650821a2c0
Debugging pass on console code.
author | Nenue |
---|---|
date | Sun, 27 Dec 2015 02:30:46 -0500 |
parents | c6a2c2df4790 |
children | 7441f3bce940 |
comparison
equal
deleted
inserted
replaced
32:c6a2c2df4790 | 33:e6650821a2c0 |
---|---|
9 local MAJOR, MINOR = 'Devian-1.3', 'r@project-revision@' | 9 local MAJOR, MINOR = 'Devian-1.3', 'r@project-revision@' |
10 local D = _G.Devian | 10 local D = _G.Devian |
11 local WORKSPACE_ON, WORKSPACE_OFF = 1, 2 | 11 local WORKSPACE_ON, WORKSPACE_OFF = 1, 2 |
12 local PLAYER_REALM = UnitName("player") .. '-' .. GetRealmName() | 12 local PLAYER_REALM = UnitName("player") .. '-' .. GetRealmName() |
13 local DEVIAN_FRAME = 'DevianConsole' | 13 local DEVIAN_FRAME = 'DevianConsole' |
14 local DEVIAN_DOCK_FRAME = 'DevianDockFrame' | |
15 local MSG_NEED_DEV_MODE = 'Must be in development mode to use this function.' | |
14 local print = _G.print | 16 local print = _G.print |
15 local db | 17 local db |
16 local defaults = { | 18 local defaults = { |
17 ['global'] = {{}, {}}, | 19 ['global'] = {{}, {}}, |
18 ['tags'] = {}, | 20 ['tags'] = {}, |
19 ['channels'] = {[1] = {signature = 'Main', index = 1, x = 100, y = 800, height = 500, width = 600, enabled = true}}, | 21 ['channels'] = {[1] = {signature = 'Main', index = 1, x = 100, y = 800, height = 500, width = 600, enabled = true}}, |
20 primary_channel = 1, | 22 primary_channel = 1, -- the channel to which default output is sent |
21 current_channel = 1, | 23 current_channel = 1, -- the front channel |
22 max_channel = 1, | 24 max_channel = 1, -- the highest created channel id |
23 toggle = true, | 25 enable = true, -- allow enabled consoles to appear |
24 load_message = "Defaults loaded.", | 26 load_message = "Defaults loaded.", -- messages to be displayed after reload |
25 font = [[Interface\Addons\Devian\font\SourceCodePro-Regular.ttf]], | 27 font = [[Interface\Addons\Devian\font\SourceCodePro-Regular.ttf]], -- font info |
26 fontsize = 13, | 28 fontsize = 13, |
27 fontoutline = 'NONE', | 29 fontoutline = 'NONE', |
28 headergrab = {'VERTICAL', 0, 0, 0, 0.5, 0.1, 0.1, 0.1, 0.3}, | 30 headergrad = {'VERTICAL', 0, 0, 0, 0.5, 0.1, 0.1, 0.1, 0.3}, -- header info |
29 backalpha = 0.5, | 31 headerdrop = {1,1,1,1}, |
30 backdrop = {0,0,0,0.4}, | 32 headeralpha = 1, |
33 backdrop = {0,0,0,1}, -- background frame info | |
31 backgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.3, 0, 0, 0, 0.5}, | 34 backgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.3, 0, 0, 0, 0.5}, |
32 backblend = 'BLEND', | 35 backblend = 'MOD', |
33 frontdrop = {0,0,0,1}, | 36 backalpha = 0.7, |
37 backborder = {0,0,1,0.75}, | |
38 frontdrop = {0,0,0,1}, -- foreground frame info | |
34 frontgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.9, 0, 0, 0, 0.9}, | 39 frontgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.9, 0, 0, 0, 0.9}, |
35 frontblend = 'BLEND', | 40 frontblend = 'MOD', |
36 frontalpha = 1, | 41 frontalpha = 1, |
37 frontborder = {1,0,0,1}, | 42 frontborder = {1,0,0,1}, |
38 backborder = {0,0,1,0.75}, | 43 tagcolor = {}, -- tag color repository |
39 tagcolor = {}, | 44 workspace = 1, -- current profile |
40 workspace = 1, | 45 last_workspace = 2 -- default workspace to alternate with when just "/dvn" is issued |
41 } | 46 } |
42 | 47 |
43 | 48 |
44 local function ScanAddOnList(cmd, ...) | 49 local function ScanAddOnList(cmd, ...) |
45 local list_state | 50 local list_state |
53 local mode, tag, dest = unpack(args) | 58 local mode, tag, dest = unpack(args) |
54 | 59 |
55 | 60 |
56 -- no args, toggle ui | 61 -- no args, toggle ui |
57 if mode == 'dock' then | 62 if mode == 'dock' then |
63 if db.workspace == 1 then | |
64 D:Print('Must be in dev mode to use this.') | |
65 return | |
66 end | |
58 if #args <= 2 then | 67 if #args <= 2 then |
59 D:Print("Not enough arguments for dock command.") | 68 D:Print("Not enough arguments for dock command.") |
60 return | 69 return |
61 end | 70 end |
62 | 71 |
91 D:Print("Docking |cFF88FFFF"..table.concat(worklist, "|r, |cFF88FFFF").."|r with |cFFFFFF00"..target.index..', '..target.signature.."|r.") | 100 D:Print("Docking |cFF88FFFF"..table.concat(worklist, "|r, |cFF88FFFF").."|r with |cFFFFFF00"..target.index..', '..target.signature.."|r.") |
92 return D:DockFrame(target.index, unpack(worklist)) | 101 return D:DockFrame(target.index, unpack(worklist)) |
93 | 102 |
94 | 103 |
95 elseif mode == 'stack' then | 104 elseif mode == 'stack' then |
105 if db.workspace == 1 then | |
106 return D:Print(MSG_NEED_DEV_MODE) | |
107 end | |
96 return D:StackFrames() | 108 return D:StackFrames() |
97 elseif mode == 'grid' then | 109 elseif mode == 'grid' then |
110 if db.workspace == 1 then | |
111 return D:Print(MSG_NEED_DEV_MODE) | |
112 end | |
98 return D:DistributeFrames() | 113 return D:DistributeFrames() |
99 elseif mode == 'tag' then -- tagging | 114 elseif mode == 'tag' then -- tagging |
115 if db.workspace == 1 then | |
116 return D:Print(MSG_NEED_DEV_MODE) | |
117 end | |
100 | 118 |
101 if tag ~= nil and dest ~= nil then | 119 if tag ~= nil and dest ~= nil then |
102 -- convert to ID | 120 -- convert to ID |
103 if tonumber(dest) == nil and D.sigID[dest] then | 121 if tonumber(dest) == nil and D.sigID[dest] then |
104 dest = db.channels[D.sigID[dest]].index | 122 dest = db.channels[D.sigID[dest]].index |
133 end | 151 end |
134 list_state = tonumber(tag) | 152 list_state = tonumber(tag) |
135 else | 153 else |
136 list_state = tonumber(mode) | 154 list_state = tonumber(mode) |
137 db.workspace = list_state | 155 db.workspace = list_state |
156 if list_state ~= 1 then | |
157 db.last_workspace = list_state | |
158 end | |
159 | |
138 end | 160 end |
139 elseif mode == nil then | 161 elseif mode == nil then |
140 list_state = db.last_workspace and db.last_workspace or 1 | 162 list_state = (db.workspace == 1) and db.last_workspace or 1 |
163 db.workspace = list_state | |
164 db.load_message = "quick swapped workspace #"..list_state | |
141 else | 165 else |
142 return D:PrintHelp() | 166 return D:PrintHelp() |
143 end | 167 end |
144 | 168 |
145 -- start the iterating | 169 -- start the iterating |
170 value = UnitName("player") | 194 value = UnitName("player") |
171 end | 195 end |
172 --print('DisableAddOn(', i, ',', value,')') | 196 --print('DisableAddOn(', i, ',', value,')') |
173 DisableAddOn(i,value) | 197 DisableAddOn(i,value) |
174 end | 198 end |
175 else | 199 elseif mode ~= 'save' then |
176 if type(db.unlisted) ~= 'table' then | 200 if type(db.unlisted) ~= 'table' then |
177 db.unlisted = {} | 201 db.unlisted = {} |
178 end | 202 end |
179 table.insert(db.unlisted, name) | 203 table.insert(db.unlisted, name) |
180 end | 204 end |
181 | 205 |
182 end | 206 end |
183 end | 207 end |
184 | 208 |
185 if mode ~= 'save' then | 209 if mode ~= 'save' then |
186 db.load_message = "AddOn profile ".. list_state .." was loaded." | 210 --db.load_message = "AddOn profile ".. list_state .." was loaded." |
187 ReloadUI() | 211 ReloadUI() |
188 else | 212 else |
189 D:Print('Profile #'.. (list_state)..' saved.') | 213 D:Print('Profile #'.. (list_state)..' saved.') |
190 if list_state == 1 then | 214 if list_state == 1 then |
191 D:Print('This will be your main AddOn list.') | 215 D:Print('This will be your main AddOn list.') |
265 | 289 |
266 -- Console frame toggler | 290 -- Console frame toggler |
267 -- @paramsig [...] | 291 -- @paramsig [...] |
268 -- @param ... one or more space-seperated channel keys | 292 -- @param ... one or more space-seperated channel keys |
269 local function Console_Toggle(input) | 293 local function Console_Toggle(input) |
294 if db.workspace == 1 then | |
295 return D:Print(MSG_NEED_DEV_MODE) | |
296 end | |
270 local search = {} | 297 local search = {} |
271 local n = 0 | 298 local n = 0 |
272 if D:GetArgs(input,1) then | 299 if D:GetArgs(input,1) then |
273 repeat | 300 repeat |
274 key, n = D:GetArgs(input,1,n) | 301 key, n = D:GetArgs(input,1,n) |
280 until n == 1e9 | 307 until n == 1e9 |
281 else | 308 else |
282 search = D.console | 309 search = D.console |
283 end | 310 end |
284 | 311 |
285 db.toggle = not db.toggle and true or nil | 312 db.enabled = (not db.enabled) and true or nil |
286 for i, c in ipairs(search) do | 313 for i, c in ipairs(search) do |
287 print(i,c.index) | 314 --print(i,c.index) |
288 if db.toggle then | 315 if db.enabled then |
289 c.enabled = true | 316 c.enabled = true |
290 c:Show() | 317 c:Show() |
291 if db.current_channel == c.index then | 318 if db.current_channel == c.index then |
292 c:ToFront() | 319 c:ToFront() |
293 end | 320 end |
321 c:Save() | |
294 else | 322 else |
295 c.enabled = nil | |
296 c.minimized = nil | |
297 c:Maximize() | |
298 c:Hide() | 323 c:Hide() |
299 end | 324 end |
300 end | 325 end |
301 | 326 |
302 if db.toggle then | 327 if db.enabled then |
303 D:Print('toggled on?') | 328 D:Print('toggled on?') |
304 else | 329 else |
305 D:Print('toggled off?') | 330 D:Print('toggled off?') |
306 end | 331 end |
307 end | 332 end |
374 -- The first argument describes the channel to output on, and the remaining arguments are concatenated in a manner similar to default print() | 399 -- The first argument describes the channel to output on, and the remaining arguments are concatenated in a manner similar to default print() |
375 -- This becomes the print handler when development mode is active. The original print() function is assigned to oldprint(). | 400 -- This becomes the print handler when development mode is active. The original print() function is assigned to oldprint(). |
376 -- @param Tag, signature, or numeric index of the channel to output on. Defaults to primary channel. | 401 -- @param Tag, signature, or numeric index of the channel to output on. Defaults to primary channel. |
377 -- @param ... Output contents. | 402 -- @param ... Output contents. |
378 local function Message(prefix, ...) | 403 local function Message(prefix, ...) |
379 if db.enabled == true then | 404 if not db.enabled then |
380 return D.oldprint(prefix, ...) | 405 return D.oldprint(prefix, ...) |
381 end | 406 end |
382 | 407 |
383 if prefix == nil then | 408 if prefix == nil then |
384 prefix = 1 | 409 prefix = 1 |
451 -- Initializes the console channel at a specified index. | 476 -- Initializes the console channel at a specified index. |
452 -- Configuration data can be overridden by passing a desired settings table. | 477 -- Configuration data can be overridden by passing a desired settings table. |
453 -- @param i Numeric index of the channel as it manifests in db.channels | 478 -- @param i Numeric index of the channel as it manifests in db.channels |
454 -- @param vars Optional settings table to be used. | 479 -- @param vars Optional settings table to be used. |
455 local function CreateConsole(i, vars) | 480 local function CreateConsole(i, vars) |
456 | 481 if tonumber(i) == nil or math.floor(i) ~= i then |
482 error('Non-integer index value.') | |
483 end | |
457 if not vars then | 484 if not vars then |
458 vars = db.channels[i] | 485 vars = db.channels[i] and db.channels[i] or db.channels[db.primary_channel] |
459 end | 486 end |
460 | 487 local f |
461 --print('make:', vars.signature, '(', vars.x, vars.y, ')', vars.width, 'x', vars.height) | 488 if vars.docked then |
462 local f = CreateFrame('Frame', 'DevianChannelFrame' .. tostring(i), UIParent, DEVIAN_FRAME) | 489 f = CreateFrame('Frame','DevianDockFrame' .. i, DEVIAN_DOCK_FRAME) |
490 else | |
491 f= CreateFrame('Frame', 'DevianChannelFrame' .. i, UIParent, DEVIAN_FRAME) | |
492 end | |
493 --@debug@ | |
494 --print(f:GetName()) | |
495 | |
496 --print('create(2)') | |
497 for k,v in pairs(vars) do | |
498 f[k] = v | |
499 --@debug@ | |
500 --print(' f['..type(k)..' '..tostring(k)..'] = '..type(v)..' '..tostring(v)) | |
501 end | |
502 | |
463 f:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', vars.x, vars.y) | 503 f:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', vars.x, vars.y) |
464 f:SetSize(vars.width, vars.height) | 504 f:SetSize(vars.width, vars.height) |
465 f:Lower() | 505 f:Lower() |
466 f.out:SetFont(db.font, db.fontsize, db.fontoutline) | 506 f.out:SetFont(db.font, db.fontsize, db.fontoutline) |
467 if (db.current_channel == i) then | 507 if (db.current_channel == i) then |
468 f.out.backdrop:SetTexture(unpack(db.frontdrop)) | 508 f.out.backdrop:SetTexture(unpack(db.frontdrop)) |
469 else | 509 else |
470 f.out.backdrop:SetTexture(unpack(db.backdrop)) | 510 f.out.backdrop:SetTexture(unpack(db.backdrop)) |
471 end | 511 end |
472 | 512 |
513 | |
514 | |
473 f.Save = Console_Save | 515 f.Save = Console_Save |
474 f.Minimize = Console_Minimize | 516 f.Minimize = Console_Minimize |
475 f.Maximize = Console_Maximize | 517 f.Maximize = Console_Maximize |
476 f.MinMax = Console_MinMax | 518 f.MinMax = Console_MinMax |
477 f.ToFront = Console_ToFront | 519 f.ToFront = Console_ToFront |
478 f.Toggle = D.Console_Toggle | 520 f.Toggle = D.Console_Toggle |
479 f.name = vars.name | |
480 f.index = i | |
481 f.signature = vars.signature | |
482 f.format = vars.header | |
483 f.x = vars.x | |
484 f.y = vars.y | |
485 f.width = vars.width | |
486 f.height = vars.height | |
487 f.docked = vars.docked | |
488 f.dockedTo = vars.dockedTo | |
489 | |
490 f:SetScript('OnMouseDown', Console_MouseDown) | 521 f:SetScript('OnMouseDown', Console_MouseDown) |
491 f:SetScript('OnMouseUp', Console_MouseUp) | 522 f:SetScript('OnMouseUp', Console_MouseUp) |
492 if vars.enabled then | 523 |
493 f.enabled = true | |
494 if db.toggle then | |
495 f:Show() | |
496 end | |
497 end | |
498 if vars.minimized then | 524 if vars.minimized then |
499 f:Minimize() | 525 f:Minimize() |
500 else | 526 else |
501 f:Maximize() | 527 f:Maximize() |
502 end | 528 end |
529 if db.enabled and f.enabled then | |
530 f:Show() | |
531 end | |
503 | 532 |
504 return f | 533 return f |
505 end | 534 end |
506 | 535 |
507 --- Updates a console "channel" entry, generating a new one if necessary. | 536 --- Updates console information and returns the handle of the channel object that was worked on. |
508 -- Config data will be take from cinfo. If cinfo is a string, then only channel signature is set. The remaining variables are filled in from the primary channel. | 537 -- When key is nil or not a valid handle, a new channel is created using whatever signature can be found in cinfo. |
509 -- i can be given to select a specific channel table entry to work on. Otherwise, it will just create a new channel and the frame associated with it. | 538 -- The signature can be passed as a string, or as a table entry under the key 'signature' |
510 -- @usage cinfo [, i] | 539 -- If the signature of a new channel is also a tag, the channel will be added to that tag |
511 -- @param cinfo Config variables table, or a string to be used as channel signature | 540 -- @param cinfo string signature of a new channel, or a table of config variables to be imposed on the channel |
512 -- @param i Console index. If valid, settings will be inherited from that channel. | 541 -- @param key string signature or index number of channel to operate on |
513 function D:SetChannel(cinfo, i) | 542 -- @usage channel = D:SetChannel('new', nil) -- creates a new channel |
514 -- try to resolve from arguments | 543 -- @usage channel = D:SetChannel({x = 200, y = 100}, 4) -- updates channel #4 |
515 local dbvars | 544 function D:SetChannel(cinfo, key) |
516 local t_info = {} | 545 local t_info = {} |
546 local channel, isNew, id, sig, t_id | |
547 -- obtain source data | |
548 if tonumber(key) ~= nil and db.channels[key] then | |
549 id = tonumber(key) | |
550 elseif D.sigID[tostring(key)] then | |
551 id = D.sigID[tostring(key)] | |
552 else | |
553 id = db.primary_channel | |
554 isNew = true | |
555 end | |
556 local dbvars = db.channels[id] | |
557 t_id = id -- overridden later if new | |
558 t_info.index = t_id -- | |
559 --@debug@ | |
560 --print('setchan(1) cinfo, key, id=', cinfo, key, id)--@end-debug@ | |
561 | |
562 | |
563 -- obtain config info | |
564 if type(cinfo) == 'string' then | |
565 sig = cinfo | |
566 cinfo = {signature = sig} | |
567 elseif type(cinfo) ~= 'table' then -- stop here if a table wans't passed | |
568 error('Expecting table of string as arg1') | |
569 elseif cinfo.signature then -- new sig | |
570 sig = cinfo.signature | |
571 elseif isNew then -- new channel sig | |
572 sig = 'Ch' | |
573 else -- old sig | |
574 sig = db.channels[id].signature | |
575 end | |
576 t_info.signature = sig | |
577 --@debug@ | |
578 --print('setchan(2) sig,id,isNew=', sig, id, isNew)--@end-debug@ | |
579 | |
580 for k,v in pairs(cinfo) do -- allow all cinfo to pass | |
581 t_info[k] = v | |
582 end | |
583 | |
584 local blocked = { -- ignore these vars: | |
585 ['docked'] = true, -- table | |
586 ['dockedTo'] = true, -- table-related | |
587 ['signature'] = true} -- already determined | |
588 for k,v in pairs(dbvars) do | |
589 if not t_info[k] and not blocked[k] then -- already set or blocked? | |
590 t_info[k] = v | |
591 end | |
592 end | |
593 -- new channel overrides | |
594 if isNew then | |
595 if D.sigID[sig]then -- find a non-clashing signature | |
596 local result, i = sig, 1 | |
597 while D.sigID[result] do | |
598 result = sig .. i | |
599 i = i + 1 | |
600 end | |
601 t_info.signature = result | |
602 end | |
603 t_id = db.max_channel + 1 | |
604 t_info.index = t_id | |
605 --@debug@ | |
606 --print('setchan(3a) isNew, sig, t_info.signature=', isNew, sig, t_info.signature)--@end-debug@ | |
607 else | |
608 --@debug@ | |
609 --print('setchan(3b) isNew, sig, t_info.signature=', isNew, sig, t_info.signature)--@end-debug@ | |
610 end | |
611 | |
517 local channel | 612 local channel |
518 local isNew | 613 if not self.console[t_id] then -- create a frame |
519 if type(i) =='number' and db.channels[i] then | 614 if isNew then -- position the channel frame |
520 dbvars = db.channels[i] | 615 t_info.x = t_info.x + 20 |
521 elseif type(i) == 'string' and D.sig[i] then | 616 t_info.y = t_info.y - 20 |
522 dbvars = db.channels[D.sig[i].index] | 617 db.channels[t_id] = t_info |
523 else | 618 --@debug@ |
524 dbvars = db.channels[db.primary_channel] | 619 print('setchan(4a)', 't_id, x, y=', t_id, t_info.x, t_info.y)--@end-debug@ |
525 isNew = true | 620 end |
526 end | 621 channel = CreateConsole(t_id, t_info) |
527 | 622 self.console[t_id] = channel |
623 self.sig[t_info.signature] = channel | |
624 self.sigID[t_info.signature] = t_id | |
625 self.IDsig[t_id] = t_info.signature | |
626 | |
627 end | |
628 channel = self.console[t_id] | |
629 if channel.minimized then | |
630 channel:Minimize() | |
631 else | |
632 channel:Maximize() | |
633 end | |
634 | |
635 if channel.enabled and db.enabled then -- hide or show last since Min/Max mess with visibility | |
636 print('setchan(5a) enable') | |
637 channel:Show() | |
638 else | |
639 print('setchan(5a) disable') | |
640 channel:Hide() | |
641 end | |
528 --@debug@ | 642 --@debug@ |
529 print('setchan(1)', cinfo, i, isNew)--@end-debug@ | 643 --print('setchan(end); c:IsVisible(), c.enabled, db.enabled=', channel:IsVisible(), channel.enabled, db.enabled)--@end-debug@ |
530 | |
531 if type(cinfo) == 'string' and not db.sig[cinfo] then | |
532 t_info.signature = cinfo | |
533 cinfo = {} | |
534 elseif type(cinfo) ~= 'table' then | |
535 error('Expecting table of string as arg1') | |
536 end | |
537 | |
538 --@debug@ | |
539 print('setchan(2)', cinfo, i, isNew)--@end-debug@ | |
540 | |
541 --TODO: figure out why tag assignments are getting eaten | |
542 -- is cinfo a table or signature? | |
543 | |
544 | |
545 | |
546 -- did we get a signature string? | |
547 if not (cinfo.signature or t_info.signature) then | |
548 t_info.signature = 'noname' | |
549 end | |
550 | |
551 --@debug@ | |
552 print('setchan(3)', cinfo, i, isNew, t_info.signature)--@end-debug@ | |
553 -- look for existing sigs | |
554 if D.sig[t_info.signature] then | |
555 local sigvar = t_info.signature | |
556 local j = 2 | |
557 while D.sig[sigvar] do | |
558 sigvar = sigvar .. j | |
559 j = j + 1 | |
560 end | |
561 t_info.signature = sigvar | |
562 end | |
563 | |
564 --@debug@ | |
565 print('setchan(4)', cinfo, i, isNew, t_info.signature)--@end-debug@ | |
566 -- can proceed to fill in from base vars here | |
567 for k,v in pairs(dbvars) do | |
568 if not t_info[k] then | |
569 if cinfo[k] then | |
570 t_info[k] = cinfo[k] | |
571 --@debug@ | |
572 print('setchan(5a)', 'cinfo', k)--@end-debug@ | |
573 elseif db.channels[self.primary_channel][k] then | |
574 t_info[k] = db.channels[self.primary_channel][k] | |
575 --@debug@ | |
576 print('setchan(5b)', 'db', self.primary_channel, k)--@end-debug@ | |
577 end | |
578 end | |
579 end | |
580 | |
581 -- we're working with a fresh channel right? | |
582 if isNew then | |
583 i = D.num_channels + 1 | |
584 t_info.index = i | |
585 t_info.x = t_info.x + 20 | |
586 t_info.y = t_info.y - 20 | |
587 db.channels[i] = t_info | |
588 --@debug@ | |
589 print('setchan(6)', 'new index', i)--@end-debug@ | |
590 end | |
591 | |
592 -- can proceed to display something from here | |
593 if not self.console[i] then | |
594 self.console[i] = CreateConsole(i, t_info) | |
595 -- if it isn't already spawned, create the frame | |
596 --@debug@ | |
597 print('setchan(7)', 'new console', i)--@end-debug@ | |
598 end | |
599 local channel = self.console[i] | |
600 self.sig[t_info.signature] = channel | |
601 self.sigID[t_info.signature] = i | |
602 self.IDsig[i] = t_info.signature | |
603 | |
604 --@debug@ | |
605 print('setchan(8)', 'end', self.sig[t_info.signature], self.sigID[t_info.signature], self.IDsig[i], self.docked)--@end-debug@ | |
606 return channel | 644 return channel |
607 end | 645 end |
608 | 646 |
609 function D:PrintHelp() | 647 function D:PrintHelp() |
610 D:Print("|cFFFFFF00/dvn|r", | 648 D:Print("|cFFFFFF00/dvn|r", |
613 D:Print("|cFFFFFF00/resetdvn|r", "- Resets all but profile data SavedVariables.") | 651 D:Print("|cFFFFFF00/resetdvn|r", "- Resets all but profile data SavedVariables.") |
614 D:Print("|cFFFFFF00/cleandvn|r", "- Fully resets SavedVariables, profiles and all.") | 652 D:Print("|cFFFFFF00/cleandvn|r", "- Fully resets SavedVariables, profiles and all.") |
615 end | 653 end |
616 | 654 |
617 function D:OnEnable() | 655 function D:OnEnable() |
656 print(MAJOR, MINOR) | |
657 | |
658 if db.unlisted and #db.unlisted > 0 then | |
659 D:Print('New AddOns have been found since the last profile update: '.. table.concat(db.unlisted, ', ')) | |
660 table.wipe(db.unlisted) | |
661 end | |
662 | |
663 if db.workspace == 1 then | |
664 D:Print('Gameplay mode active (list #'..db.workspace..'). Print handling turned |cFFFFFF00OFF|r.') | |
665 else | |
666 D:Print('Development mode active (list #'..db.workspace..'). Print handling |cFF00FF00ON|r.') | |
667 end | |
668 | |
669 end | |
670 | |
671 function D:OnInitialize() | |
618 -- commands | 672 -- commands |
673 self:RegisterChatCommand("cleandvn", function(args) | |
674 DevianDB = nil | |
675 DevianDB = { | |
676 load_message = "All SavedVars wiped." | |
677 } | |
678 ReloadUI() | |
679 end) | |
680 self:RegisterChatCommand("resetdvn", function(args) | |
681 for k,v in pairs(DevianDB) do | |
682 if k ~= 'global' then | |
683 DevianDB[k] = nil | |
684 end | |
685 end | |
686 | |
687 DevianDB.load_message = "Non-user SavedVars have been reset." | |
688 for k,v in pairs(defaults) do | |
689 DevianDB[k] = v | |
690 end | |
691 ReloadUI() | |
692 end) | |
619 local cmdlist = { | 693 local cmdlist = { |
620 ['dvn'] = ScanAddOnList, | 694 ['dvn'] = ScanAddOnList, |
621 ['devian'] = ScanAddOnList, | 695 ['devian'] = ScanAddOnList, |
622 ['dvc'] = Console_Toggle, | 696 ['dvc'] = Console_Toggle, |
623 } | 697 } |
624 for cmd, func in pairs(cmdlist) do | 698 for cmd, func in pairs(cmdlist) do |
625 self:RegisterChatCommand(cmd, func, true) | 699 self:RegisterChatCommand(cmd, func, true) |
626 end | 700 end |
627 | 701 |
628 if db.workspace == 1 then | 702 -- pull defaults |
629 D:Print('Gameplay mode active. Print handling turned |cFFFFFF00OFF|r..') | |
630 else | |
631 D:Print('Development mode active (list #'..db.workspace..'). Print handling |cFF00FF00ON|r.') | |
632 end | |
633 | |
634 end | |
635 | |
636 function D:OnInitialize() | |
637 -- emergency button | |
638 self:RegisterChatCommand("cleandvn", function(args) | |
639 DevianDB = nil | |
640 ReloadUI() | |
641 end) | |
642 self:RegisterChatCommand("resetdvn", function(args) | |
643 for k,v in pairs(DevianDB) do | |
644 if k ~= 'global' then | |
645 DevianDB[k] = nil | |
646 end | |
647 end | |
648 | |
649 for k,v in pairs(defaults) do | |
650 DevianDB[k] = v | |
651 end | |
652 ReloadUI() | |
653 end) | |
654 | |
655 -- savedvars | |
656 local cherry = false | |
657 if not _G.DevianDB then | 703 if not _G.DevianDB then |
658 _G.DevianDB = defaults | 704 _G.DevianDB = defaults |
659 end | 705 end |
660 db = _G.DevianDB | 706 db = _G.DevianDB |
661 self.tags = db.tags | 707 self.tags = db.tags |
672 D.oldprint = getprinthandler() | 718 D.oldprint = getprinthandler() |
673 if not _G.oldprint then | 719 if not _G.oldprint then |
674 _G.oldprint = D.oldprint | 720 _G.oldprint = D.oldprint |
675 end | 721 end |
676 | 722 |
677 --self.raise_ct = 0 | 723 -- Stop here in game mode |
724 if db.workspace == 1 then | |
725 return | |
726 end | |
727 | |
678 self.max_channel = 0 | 728 self.max_channel = 0 |
679 self.num_channels = 0 | 729 self.num_channels = 0 |
680 self.console = {} | 730 self.console = {} |
681 self.sig = {} | 731 self.sig = {} |
682 self.sigID = {} | 732 self.sigID = {} |
700 | 750 |
701 if self.console[db.current_channel] then | 751 if self.console[db.current_channel] then |
702 self.console[db.current_channel]:ToFront() | 752 self.console[db.current_channel]:ToFront() |
703 -- bring the current channel to the front | 753 -- bring the current channel to the front |
704 end | 754 end |
705 | 755 setprinthandler(Message) |
706 if db.enabled then | 756 print = function(...) |
707 for i, c in pairs(self.console) do | 757 _G.print('Dvn', ...) |
708 self.console[i]:Hide() | 758 end |
709 end | 759 end |
710 end | |
711 | |
712 | |
713 -- only do this in dev mode | |
714 if db.workspace > 1 then | |
715 | |
716 setprinthandler(Message) | |
717 print = function(...) | |
718 _G.print('Dvn', ...) | |
719 end | |
720 end | |
721 print(MAJOR, MINOR) | |
722 end |