Mercurial > wow > devian
comparison Devian.lua @ 30:42e74b72726d
Prefix auto-color checks for and deals with color levels that are close to white.
| author | Nenue |
|---|---|
| date | Fri, 25 Dec 2015 13:56:20 -0500 |
| parents | 31ca76e04766 |
| children | 6fcfe60bbd0f |
comparison
equal
deleted
inserted
replaced
| 29:60a9dc276ece | 30:42e74b72726d |
|---|---|
| 344 if prefix == nil then | 344 if prefix == nil then |
| 345 prefix = 1 | 345 prefix = 1 |
| 346 end | 346 end |
| 347 | 347 |
| 348 local sendq = {} | 348 local sendq = {} |
| 349 local tag, id | 349 local tag, id, tagged |
| 350 local byName = true | 350 local byName = true |
| 351 if D.tags[prefix] then | 351 if D.tags[prefix] then |
| 352 for _, id in pairs(D.tags[prefix]) do | 352 for _, id in pairs(D.tags[prefix]) do |
| 353 if D.console[id] then | 353 if D.console[id] then |
| 354 sendq[id] = D.console[id] | 354 sendq[id] = D.console[id] |
| 355 tagged = true | |
| 355 end | 356 end |
| 356 end | 357 end |
| 357 end | 358 end |
| 358 | 359 |
| 359 if D.sig[prefix] then | 360 if D.sig[prefix] then |
| 360 sendq[D.sig[prefix].index] = D.sig[prefix] | 361 sendq[D.sig[prefix].index] = D.sig[prefix] |
| 361 elseif D.console[prefix] then | 362 elseif D.console[prefix] then |
| 362 sendq[D.console[prefix]] = D.console[prefix] | 363 sendq[D.console[prefix]] = D.console[prefix] |
| 363 else | 364 elseif not tagged then |
| 364 sendq[D.primary_channel] = D.console[D.primary_channel] | 365 sendq[D.primary_channel] = D.console[D.primary_channel] |
| 365 end | 366 end |
| 366 | 367 |
| 367 -- color me timbers | 368 -- color me timbers |
| 368 local pcolor | 369 local pcolor |
| 369 if (not db.tagcolor[prefix]) and byName then | 370 if (not db.tagcolor[prefix]) and byName then |
| 370 local c = {0, 0, 0 } | 371 local c = { |
| 371 local max = string.len(prefix) | 372 math.random(64,255), math.random(64,255), math.random(64,255) |
| 372 for i = 1, max, 3 do | 373 } |
| 373 for k, v in ipairs(c) do | 374 if c[1] > 223 and c[2] > 223 and c[3] > 223 then |
| 374 local j = i + (k - 1) | 375 c[math.random(1,3)] = math.random(64,223) |
| 375 c[k] = c[k] + (j <= max and string.byte(prefix,j) or 0) | 376 end |
| 376 end | 377 |
| 377 end | |
| 378 for k,v in ipairs(c) do | |
| 379 c[k] = c[k] % 255 | |
| 380 if c[k] < 64 then | |
| 381 c[k] = 0 | |
| 382 elseif c[k] > 127 then | |
| 383 c[k] = 255 | |
| 384 end | |
| 385 end | |
| 386 db.tagcolor[prefix] = string.format('%02X%02X%02X', unpack(c)) | 378 db.tagcolor[prefix] = string.format('%02X%02X%02X', unpack(c)) |
| 387 end | 379 end |
| 388 pcolor = db.tagcolor[prefix] | 380 pcolor = db.tagcolor[prefix] |
| 389 | 381 |
| 390 local buffer = {'|cFF'.. pcolor..prefix ..'|r'} | 382 local buffer = {'|cFF'.. pcolor..prefix ..'|r'} |
| 488 -- is it valid? | 480 -- is it valid? |
| 489 if db.channels[i] then | 481 if db.channels[i] then |
| 490 dbvars = db.channels[i] | 482 dbvars = db.channels[i] |
| 491 -- use that as our base vars | 483 -- use that as our base vars |
| 492 else | 484 else |
| 493 if db.sig[t_info.signature] then | 485 if D.sig[t_info.signature] then |
| 494 local sigvar = t_info.signature | 486 local sigvar = t_info.signature |
| 495 local j = 2 | 487 local j = 2 |
| 496 while D.sig[sigvar] do | 488 while D.sig[sigvar] do |
| 497 sigvar = signame .. j | 489 sigvar = sigvar .. j |
| 498 j = j + 1 | 490 j = j + 1 |
| 499 end | 491 end |
| 500 t_info.signature = sigvar | 492 t_info.signature = sigvar |
| 501 end | 493 end |
| 502 | 494 |
