Mercurial > wow > devian
comparison Devian.lua @ 28:31ca76e04766 v1.4.4
/dvn tag and /dvc commands will respond to all of their arguments
Index assignment algorithm should stop breaking new channels.
current channel's ToFront is invoked after the initializer loop
| author | Nenue |
|---|---|
| date | Fri, 25 Dec 2015 03:32:56 -0500 |
| parents | b0e8bd30575f |
| children | 42e74b72726d |
comparison
equal
deleted
inserted
replaced
| 27:6d1528a55514 | 28:31ca76e04766 |
|---|---|
| 21 dnd_status = true, | 21 dnd_status = true, |
| 22 dnd_message = "Debugging. Your messages may get eaten.", | 22 dnd_message = "Debugging. Your messages may get eaten.", |
| 23 font = [[Interface\Addons\Devian\font\SourceCodePro-Regular.ttf]], | 23 font = [[Interface\Addons\Devian\font\SourceCodePro-Regular.ttf]], |
| 24 fontsize = 13, | 24 fontsize = 13, |
| 25 fontoutline = 'NONE', | 25 fontoutline = 'NONE', |
| 26 backdrop = {1,1,1,0.2}, | 26 backalpha = 0.5, |
| 27 backdrop = {0,0,0,0.4}, | |
| 27 backgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.3, 0, 0, 0, 0.5}, | 28 backgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.3, 0, 0, 0, 0.5}, |
| 28 backblend = 'BLEND', | 29 backblend = 'BLEND', |
| 29 frontdrop = {1,1,1,1}, | 30 frontdrop = {0,0,0,1}, |
| 30 frontgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.9, 0, 0, 0, 0.9}, | 31 frontgrad = {'VERTICAL', 0.1, 0.1, 0.1, 0.9, 0, 0, 0, 0.9}, |
| 31 frontblend = 'BLEND', | 32 frontblend = 'BLEND', |
| 33 frontalpha = 1, | |
| 32 frontborder = {1,0,0,1}, | 34 frontborder = {1,0,0,1}, |
| 33 backborder = {0,0,1,0.75}, | 35 backborder = {0,0,1,0.75}, |
| 34 } | 36 } |
| 35 | 37 |
| 36 | 38 |
| 58 return D:StackFrames() | 60 return D:StackFrames() |
| 59 elseif mode == 'grid' then | 61 elseif mode == 'grid' then |
| 60 return D:DistributeFrames() | 62 return D:DistributeFrames() |
| 61 elseif mode == 'tag' then -- tagging | 63 elseif mode == 'tag' then -- tagging |
| 62 if tag ~= nil and dest ~= nil then | 64 if tag ~= nil and dest ~= nil then |
| 63 local channel = D:SetChannel(dest:match('%a'), dest:match('%d')) | 65 local channel = D:SetChannel(dest:match('%a+'), dest:match('%d+')) |
| 64 if not D.tags[tag] then | 66 if not D.tags[tag] then |
| 65 D.tags[tag] = {} | 67 D.tags[tag] = {} |
| 66 end | 68 end |
| 67 if D.tags[tag][channel.index] then | 69 if D.tags[tag][channel.index] then |
| 68 D.tags[tag][channel.index] = nil | 70 D.tags[tag][channel.index] = nil |
| 197 -- Console frame toggler | 199 -- Console frame toggler |
| 198 -- @paramsig [...] | 200 -- @paramsig [...] |
| 199 -- @param ... one or more space-seperated channel keys | 201 -- @param ... one or more space-seperated channel keys |
| 200 local function Console_Toggle(input) | 202 local function Console_Toggle(input) |
| 201 local search = {} | 203 local search = {} |
| 202 local key, n = D:GetArgs(input, 1) | 204 local n = 0 |
| 203 if key then | 205 if D:GetArgs(input,1) then |
| 204 repeat | 206 repeat |
| 207 key, n = D:GetArgs(input,1,n) | |
| 205 if D.sig[key] then | 208 if D.sig[key] then |
| 206 table.insert(search, D.sig[key]) | 209 table.insert(search, D.sig[key]) |
| 207 elseif D.console[key] then | 210 elseif D.console[key] then |
| 208 table.insert(search, D.console[key]) | 211 table.insert(search, D.console[key]) |
| 209 end | 212 end |
| 210 key, n = D:GetArgs(input,1,n) | |
| 211 until n == 1e9 | 213 until n == 1e9 |
| 212 else | 214 else |
| 213 search = D.console | 215 search = D.console |
| 214 end | 216 end |
| 215 | 217 |
| 216 db.toggle = not db.toggle and true or nil | 218 db.toggle = not db.toggle and true or nil |
| 217 for _, c in ipairs(search) do | 219 for i, c in ipairs(search) do |
| 220 print(i,c.index) | |
| 218 if db.toggle then | 221 if db.toggle then |
| 222 c.enabled = true | |
| 219 c:Show() | 223 c:Show() |
| 220 if db.current_channel == c.index then | 224 if db.current_channel == c.index then |
| 221 c:ToFront() | 225 c:ToFront() |
| 222 end | 226 end |
| 223 else | 227 else |
| 242 --print(unpack(db.frontdrop)) | 246 --print(unpack(db.frontdrop)) |
| 243 --print(unpack(db.frontgrad)) | 247 --print(unpack(db.frontgrad)) |
| 244 --print(db.frontblend) | 248 --print(db.frontblend) |
| 245 -- D.raise_ct = D.raise_ct + 1 | 249 -- D.raise_ct = D.raise_ct + 1 |
| 246 c:Raise() | 250 c:Raise() |
| 251 c:SetAlpha(db.frontalpha) | |
| 247 c.out.backdrop:SetTexture(unpack(db.frontdrop)) | 252 c.out.backdrop:SetTexture(unpack(db.frontdrop)) |
| 248 c.out.backdrop:SetGradientAlpha(unpack(db.frontgrad)) | 253 c.out.backdrop:SetGradientAlpha(unpack(db.frontgrad)) |
| 249 c.out.backdrop:SetBlendMode(db.frontblend) | 254 c.out.backdrop:SetBlendMode(db.frontblend) |
| 250 db.current_channel = c.index | 255 db.current_channel = c.index |
| 251 | 256 |
| 257 if id ~= c.index then | 262 if id ~= c.index then |
| 258 --print(D.raise_ct, 'Lowering', bc.signature) | 263 --print(D.raise_ct, 'Lowering', bc.signature) |
| 259 --print(unpack(db.backdrop)) | 264 --print(unpack(db.backdrop)) |
| 260 --print(unpack(db.backgrad)) | 265 --print(unpack(db.backgrad)) |
| 261 --print(db.backblend) | 266 --print(db.backblend) |
| 267 bc:SetAlpha(db.backalpha) | |
| 262 bc.out.backdrop:SetTexture(unpack(db.backdrop)) | 268 bc.out.backdrop:SetTexture(unpack(db.backdrop)) |
| 263 bc.out.backdrop:SetGradientAlpha(unpack(db.backgrad)) | 269 bc.out.backdrop:SetGradientAlpha(unpack(db.backgrad)) |
| 264 bc.out.backdrop:SetBlendMode(db.backblend) | 270 bc.out.backdrop:SetBlendMode(db.backblend) |
| 265 | 271 |
| 266 for _, part in pairs(bc.border) do | 272 for _, part in pairs(bc.border) do |
| 455 -- @param i Console index. If valid, settings will be inherited from that channel. | 461 -- @param i Console index. If valid, settings will be inherited from that channel. |
| 456 function D:SetChannel(cinfo, i) | 462 function D:SetChannel(cinfo, i) |
| 457 --print('join:', i , cinfo) | 463 --print('join:', i , cinfo) |
| 458 local t_info = {} | 464 local t_info = {} |
| 459 local dbvars = db.channels[self.primary_channel] | 465 local dbvars = db.channels[self.primary_channel] |
| 466 local signame | |
| 467 | |
| 468 -- is cinfo a table or signature? | |
| 460 if type(cinfo) == 'string' then | 469 if type(cinfo) == 'string' then |
| 461 local signame = tostring(cinfo) | 470 signame = tostring(cinfo) |
| 462 t_info.signature = signame | 471 t_info.signature = signame |
| 463 end | 472 elseif type(cinfo) ~= 'table' then |
| 464 | |
| 465 if type(cinfo) ~= 'table' then | |
| 466 cinfo = {} | 473 cinfo = {} |
| 467 end | 474 end |
| 468 | 475 |
| 469 if i then | 476 -- did we get a signature string? |
| 477 if not (cinfo.signature or t_info.signature) then | |
| 478 t_info.signature = 'Console' | |
| 479 end | |
| 480 | |
| 481 -- was an index given? | |
| 482 if not i then | |
| 483 i = D.num_channels + 1 | |
| 484 t_info.index = i | |
| 485 -- make a new one | |
| 486 else | |
| 470 i = tonumber(i) | 487 i = tonumber(i) |
| 488 -- is it valid? | |
| 471 if db.channels[i] then | 489 if db.channels[i] then |
| 472 dbvars = db.channels[i] | 490 dbvars = db.channels[i] |
| 491 -- use that as our base vars | |
| 473 else | 492 else |
| 474 -- if there is no channels[i], then we need to check for sig collision | 493 if db.sig[t_info.signature] then |
| 475 local sigvar = signame | 494 local sigvar = t_info.signature |
| 476 local j = 2 | 495 local j = 2 |
| 477 while D.sig[sigvar] do | 496 while D.sig[sigvar] do |
| 478 sigvar = signame .. j | 497 sigvar = signame .. j |
| 479 j = j + 1 | 498 j = j + 1 |
| 480 end | 499 end |
| 481 t_info.signature = sigvar | 500 t_info.signature = sigvar |
| 482 end | 501 end |
| 483 end | 502 |
| 484 | 503 i = D.num_channels + 1 |
| 485 if not (cinfo.signature or t_info.signature) then | 504 t_info.index = i |
| 486 t_info.signature = 'Console'..i | 505 -- make a new index number and fix the signature |
| 487 end | 506 end |
| 488 | 507 end |
| 508 | |
| 509 -- can proceed to fill in from base vars here | |
| 489 for k,v in pairs(dbvars) do | 510 for k,v in pairs(dbvars) do |
| 490 if not t_info[k] then | 511 if not t_info[k] then |
| 491 if cinfo[k] then | 512 if cinfo[k] then |
| 492 t_info[k] = cinfo[k] | 513 t_info[k] = cinfo[k] |
| 493 elseif db.channels[self.primary_channel][k] then | 514 elseif db.channels[self.primary_channel][k] then |
| 494 t_info[k] = db.channels[self.primary_channel][k] | 515 t_info[k] = db.channels[self.primary_channel][k] |
| 495 end | 516 end |
| 496 end | 517 end |
| 497 end | 518 end |
| 498 | 519 |
| 520 -- we're working with a fresh channel right? | |
| 499 if not db.channels[i] then | 521 if not db.channels[i] then |
| 500 t_info.x = t_info.x + 20 | 522 t_info.x = t_info.x + 20 |
| 501 t_info.y = t_info.y - 20 | 523 t_info.y = t_info.y - 20 |
| 502 db.channels[i] = t_info | 524 db.channels[i] = t_info |
| 503 end | 525 -- set its position just off of the base vars and store it |
| 504 | 526 end |
| 527 | |
| 528 -- can proceed to display something from here | |
| 505 if not self.console[i] then | 529 if not self.console[i] then |
| 506 self.console[i] = CreateConsole(i, t_info) | 530 self.console[i] = CreateConsole(i, t_info) |
| 531 -- if it isn't already spawned, create the frame | |
| 507 end | 532 end |
| 508 local channel = self.console[i] | 533 local channel = self.console[i] |
| 509 self.sig[t_info.signature] = channel | 534 self.sig[t_info.signature] = channel |
| 510 self.sigID[t_info.signature] = i | 535 self.sigID[t_info.signature] = i |
| 511 self.IDsig[i] = t_info.signature | 536 self.IDsig[i] = t_info.signature |
| 512 if i == db.current_channel then | |
| 513 channel:ToFront() | |
| 514 end | |
| 515 | 537 |
| 516 return channel | 538 return channel |
| 517 end | 539 end |
| 518 | 540 |
| 519 function D:OnEnable() | 541 function D:OnEnable() |
| 589 self.num_channels = self.num_channels + 1 | 611 self.num_channels = self.num_channels + 1 |
| 590 end | 612 end |
| 591 | 613 |
| 592 if self.console[db.current_channel] then | 614 if self.console[db.current_channel] then |
| 593 self.console[db.current_channel]:ToFront() | 615 self.console[db.current_channel]:ToFront() |
| 616 -- bring the current channel to the front | |
| 594 end | 617 end |
| 595 | 618 |
| 596 if db.enabled then | 619 if db.enabled then |
| 597 for i, c in pairs(self.console) do | 620 for i, c in pairs(self.console) do |
| 598 self.console[i]:Hide() | 621 self.console[i]:Hide() |
