File choir.lua changed (mode: 100644) (index 3571a23..a42686c) |
|
1 |
|
local function trace(...) |
|
2 |
|
print(date('%X'), '[Choir]:', ...) |
|
3 |
|
end |
|
4 |
|
|
1 |
5 |
local function getDefaultUnitButtonBarColor() |
local function getDefaultUnitButtonBarColor() |
2 |
6 |
return 0, 1, 0 |
return 0, 1, 0 |
3 |
7 |
end |
end |
|
... |
... |
local function updateUnitButtonBarOverlay(bar, unitDesignation) |
110 |
114 |
|
|
111 |
115 |
--[[ Apply bar color update ]]-- |
--[[ Apply bar color update ]]-- |
112 |
116 |
local r, g, b = getDefaultUnitButtonBarColor() |
local r, g, b = getDefaultUnitButtonBarColor() |
113 |
|
--[[ TODO Range indicator ]]-- |
|
114 |
|
local a = 1 |
|
|
117 |
|
|
115 |
118 |
local _, classDesignation = UnitClass(unitDesignation) |
local _, classDesignation = UnitClass(unitDesignation) |
116 |
119 |
if classDesignation then |
if classDesignation then |
117 |
120 |
r, g, b = getClassColor(classDesignation) |
r, g, b = getClassColor(classDesignation) |
118 |
121 |
end |
end |
119 |
122 |
|
|
|
123 |
|
--[[ TODO Add line of sight indicator ]]-- |
|
124 |
|
local a = 1 |
|
125 |
|
local rangeSpell = ChoirRangeSpellName |
|
126 |
|
--[[ NOTE IsSpellInRange returns either 0, 1 or nil ]]-- |
|
127 |
|
if rangeSpell and 1 ~= IsSpellInRange(rangeSpell, unitDesignation) then |
|
128 |
|
a = 1 / 2 |
|
129 |
|
end |
|
130 |
|
|
120 |
131 |
local overlay = bar.overlay |
local overlay = bar.overlay |
121 |
132 |
assert (overlay ~= nil) |
assert (overlay ~= nil) |
122 |
133 |
overlay:SetTexture(r, g, b, a) |
overlay:SetTexture(r, g, b, a) |
|
... |
... |
local function createUnitButtonBar(unitButton) |
149 |
160 |
|
|
150 |
161 |
bar.unitButton = unitButton |
bar.unitButton = unitButton |
151 |
162 |
|
|
152 |
|
bar:SetScript('OnEvent', function(healthBarFrame, eventCategory, targetUnit) |
|
|
163 |
|
--[[ Update health indicator ]]-- |
|
164 |
|
bar:SetScript('OnEvent', function(healthBarFrame) |
153 |
165 |
assert (healthBarFrame ~= nil) |
assert (healthBarFrame ~= nil) |
154 |
|
assert ('UNIT_HEALTH' == eventCategory) |
|
155 |
|
assert (targetUnit ~= nil) |
|
156 |
166 |
assert (unitButton ~= nil) |
assert (unitButton ~= nil) |
157 |
167 |
|
|
158 |
168 |
local u = unitButton:GetAttribute('unit') |
local u = unitButton:GetAttribute('unit') |
159 |
169 |
assert (u ~= nil) |
assert (u ~= nil) |
160 |
|
if targetUnit == u then |
|
161 |
|
updateUnitButtonBarOverlay(healthBarFrame, targetUnit) |
|
162 |
|
updateUnitButtonBarText(healthBarFrame, targetUnit) |
|
163 |
|
end |
|
|
170 |
|
updateUnitButtonBarOverlay(healthBarFrame, u) |
|
171 |
|
updateUnitButtonBarText(healthBarFrame, u) |
164 |
172 |
end) |
end) |
|
173 |
|
bar:RegisterEvent('PLAYER_FOCUS_CHANGED') |
|
174 |
|
bar:RegisterEvent('PLAYER_TARGET_CHANGED') |
165 |
175 |
bar:RegisterEvent('UNIT_HEALTH') |
bar:RegisterEvent('UNIT_HEALTH') |
|
176 |
|
bar:RegisterEvent('UNIT_SPELLCAST_FAILED') |
|
177 |
|
bar:RegisterEvent('UNIT_SPELLCAST_FAILED_QUIET') |
|
178 |
|
bar:RegisterEvent('UNIT_SPELLCAST_SENT') |
|
179 |
|
bar:RegisterEvent('UNIT_SPELLCAST_START') |
166 |
180 |
|
|
167 |
181 |
return bar |
return bar |
168 |
182 |
end |
end |
|
... |
... |
local function createGroup(rootFrame, groupNumber, unitTable) |
346 |
360 |
return spoiler |
return spoiler |
347 |
361 |
end |
end |
348 |
362 |
|
|
349 |
|
local function init(rootFrame) |
|
350 |
|
assert (rootFrame ~= nil) |
|
|
363 |
|
local function getRangeSpellNameSuggestion() |
|
364 |
|
local _, classDesignation = UnitClass('player') |
|
365 |
|
assert (classDesignation ~= nil) |
|
366 |
|
assert ('string' == type(classDesignation)) |
|
367 |
|
classDesignation = strtrim(classDesignation) |
|
368 |
|
assert (string.len(classDesignation) >= 2) |
|
369 |
|
assert (string.len(classDesignation) <= 64) |
351 |
370 |
|
|
352 |
|
rootFrame:UnregisterAllEvents() |
|
|
371 |
|
local map = { |
|
372 |
|
['DRUID'] = {'Cure Poison', 'Healing Touch'}, |
|
373 |
|
['PALADIN'] = {'Cleanse', 'Purify', 'Holy Light'}, |
|
374 |
|
['PRIEST'] = {'Dispel Magic', 'Cure Disease', 'Lesser Heal'}, |
|
375 |
|
['SHAMAN'] = {'Healing Wave'}, |
|
376 |
|
} |
353 |
377 |
|
|
354 |
|
rootFrame:SetSize(1024, 768) |
|
355 |
|
rootFrame:SetPoint('CENTER', 0, 0) |
|
|
378 |
|
local t = map[classDesignation] |
|
379 |
|
if not t then |
|
380 |
|
return |
|
381 |
|
end |
|
382 |
|
assert (t ~= nil) |
|
383 |
|
assert ('table' == type(t)) |
|
384 |
|
assert (#t >= 1) |
|
385 |
|
|
|
386 |
|
local s = nil |
|
387 |
|
local i = 0 |
|
388 |
|
while (i < #t) do |
|
389 |
|
i = i + 1 |
|
390 |
|
local candidate = t[i] |
|
391 |
|
assert (candidate ~= nil) |
|
392 |
|
local spellName = GetSpellInfo(candidate) |
|
393 |
|
if spellName then |
|
394 |
|
s = spellName |
|
395 |
|
break |
|
396 |
|
end |
|
397 |
|
end |
|
398 |
|
|
|
399 |
|
return s |
|
400 |
|
end |
|
401 |
|
|
|
402 |
|
local function initRangeSpellName(rootFrame) |
|
403 |
|
local f = CreateFrame('FRAME', rootFrame:GetName() .. 'RangeSpellFrame') |
|
404 |
|
f:SetScript('OnEvent', function() |
|
405 |
|
ChoirRangeSpellName = getRangeSpellNameSuggestion() |
|
406 |
|
end) |
|
407 |
|
f:RegisterEvent('SPELLS_CHANGED') |
|
408 |
|
|
|
409 |
|
local s = ChoirRangeSpellName |
|
410 |
|
if s then |
|
411 |
|
assert (s ~= nil) |
|
412 |
|
assert ('string' == type(s)) |
|
413 |
|
s = strtrim(s) |
|
414 |
|
assert (string.len(s) >= 2) |
|
415 |
|
assert (string.len(s) <= 256) |
|
416 |
|
else |
|
417 |
|
s = getRangeSpellNameSuggestion() |
|
418 |
|
end |
|
419 |
|
|
|
420 |
|
ChoirRangeSpellName = s |
|
421 |
|
|
|
422 |
|
return s |
|
423 |
|
end |
|
424 |
|
|
|
425 |
|
local function initSpoiler(rootFrame) |
|
426 |
|
assert (rootFrame ~= nil) |
356 |
427 |
|
|
357 |
428 |
createGroup(rootFrame, 1) |
createGroup(rootFrame, 1) |
358 |
429 |
createGroup(rootFrame, 2) |
createGroup(rootFrame, 2) |
|
... |
... |
local function init(rootFrame) |
375 |
446 |
_G['BINDING_NAME_CLICK ' .. spoilerParty:GetName() .. ':LeftButton'] = 'Player party' |
_G['BINDING_NAME_CLICK ' .. spoilerParty:GetName() .. ':LeftButton'] = 'Player party' |
376 |
447 |
|
|
377 |
448 |
BINDING_HEADER_CHOIR = 'Choir' |
BINDING_HEADER_CHOIR = 'Choir' |
|
449 |
|
end |
|
450 |
|
|
|
451 |
|
local function init(rootFrame) |
|
452 |
|
assert (rootFrame ~= nil) |
|
453 |
|
|
|
454 |
|
local locale = GetLocale() |
|
455 |
|
assert (locale == 'enGB' or locale == 'enUS', 'requires English localization') |
|
456 |
|
|
|
457 |
|
rootFrame:UnregisterAllEvents() |
|
458 |
|
|
|
459 |
|
rootFrame:SetSize(1024, 768) |
|
460 |
|
rootFrame:SetPoint('CENTER', 0, 0) |
|
461 |
|
|
|
462 |
|
initRangeSpellName(rootFrame) |
|
463 |
|
initSpoiler(rootFrame) |
378 |
464 |
|
|
379 |
|
print('[Choir]: init') |
|
|
465 |
|
trace('init') |
380 |
466 |
end |
end |
381 |
467 |
|
|
382 |
468 |
local function main() |
local function main() |