File src/ChorusAuraButtonTemplate.lua changed (mode: 100644) (index e0490d7..0151ce4) |
... |
... |
local function applyOverlay(auraButton, category) |
87 |
87 |
end |
end |
88 |
88 |
end |
end |
89 |
89 |
|
|
90 |
|
local function applyDuration(auraButton, now, durationSec, expirationInstance) |
|
|
90 |
|
local function formatDuration(durationSec) |
|
91 |
|
assert(durationSec ~= nil) |
|
92 |
|
assert('number' == type(durationSec)) |
|
93 |
|
|
|
94 |
|
local t |
|
95 |
|
if durationSec < 60 then |
|
96 |
|
t = string.format("%.0f", durationSec) |
|
97 |
|
elseif durationSec < 3600 then |
|
98 |
|
t = string.format("%.0f m", durationSec / 60) |
|
99 |
|
else |
|
100 |
|
t = string.format("%.0f h", durationSec / 60 / 60) |
|
101 |
|
end |
|
102 |
|
return t |
|
103 |
|
end |
|
104 |
|
|
|
105 |
|
local function applyDuration(auraButton, now, totalDurationSec, expirationInstance) |
91 |
106 |
auraButtonValidate(auraButton) |
auraButtonValidate(auraButton) |
92 |
107 |
|
|
93 |
108 |
assert(now ~= nil) |
assert(now ~= nil) |
94 |
109 |
assert('number' == type(now)) |
assert('number' == type(now)) |
95 |
110 |
assert(now >= 0) |
assert(now >= 0) |
96 |
111 |
|
|
97 |
|
assert(durationSec ~= nil) |
|
98 |
|
assert('number' == type(durationSec)) |
|
99 |
|
assert(durationSec >= 0) |
|
|
112 |
|
assert(totalDurationSec ~= nil) |
|
113 |
|
assert('number' == type(totalDurationSec)) |
|
114 |
|
assert(totalDurationSec >= 0) |
100 |
115 |
|
|
101 |
116 |
assert(expirationInstance ~= nil) |
assert(expirationInstance ~= nil) |
102 |
117 |
assert('number' == type(expirationInstance)) |
assert('number' == type(expirationInstance)) |
|
... |
... |
local function applyDuration(auraButton, now, durationSec, expirationInstance) |
105 |
120 |
local label = auraButton.label |
local label = auraButton.label |
106 |
121 |
assert (label ~= nil) |
assert (label ~= nil) |
107 |
122 |
|
|
108 |
|
local t |
|
109 |
|
if durationSec and now < expirationInstance then |
|
110 |
|
local d = expirationInstance - now |
|
111 |
|
if d < 60 then |
|
112 |
|
t = string.format("%.0f", d) |
|
113 |
|
elseif d < 3600 then |
|
114 |
|
t = string.format("%.0f m", d / 60) |
|
115 |
|
else |
|
116 |
|
t = string.format("%.0f h", d / 60 / 60) |
|
|
123 |
|
local durationRemainingSec |
|
124 |
|
if totalDurationSec and now < expirationInstance then |
|
125 |
|
durationRemainingSec = expirationInstance - now |
|
126 |
|
end |
|
127 |
|
|
|
128 |
|
local isButtonLarge = auraButton:GetHeight() >= 24 |
|
129 |
|
|
|
130 |
|
--[[ User readability tweaks. ]]-- |
|
131 |
|
local t = nil |
|
132 |
|
if isButtonLarge then |
|
133 |
|
--[[ Given large button, separate text from artwork. ]]-- |
|
134 |
|
label:SetJustifyV('BOTTOM') |
|
135 |
|
if durationRemainingSec then |
|
136 |
|
t = formatDuration(durationRemainingSec) |
117 |
137 |
end |
end |
118 |
138 |
else |
else |
119 |
|
t = nil |
|
|
139 |
|
--[[ Given small button, overlap text with artwork. Additionally, only show short durations. ]]-- |
|
140 |
|
label:SetJustifyV('CENTER') |
|
141 |
|
if durationRemainingSec and durationRemainingSec < 60 then |
|
142 |
|
t = formatDuration(durationRemainingSec) |
|
143 |
|
end |
120 |
144 |
end |
end |
121 |
145 |
|
|
122 |
146 |
label:SetText(t) |
label:SetText(t) |
123 |
147 |
|
|
124 |
|
if auraButton:GetHeight() >= 24 then |
|
125 |
|
label:SetJustifyV('BOTTOM') |
|
|
148 |
|
local artwork = auraButton.artwork |
|
149 |
|
if artwork and totalDurationSec and durationRemainingSec and totalDurationSec >= 12 and durationRemainingSec <= 3 then |
|
150 |
|
artwork:SetAlpha(0.6) |
126 |
151 |
else |
else |
127 |
|
label:SetJustifyV('CENTER') |
|
|
152 |
|
artwork:SetAlpha(1) |
128 |
153 |
end |
end |
129 |
154 |
end |
end |
130 |
155 |
|
|
File src/ChorusAuraFrameTemplate.lua changed (mode: 100644) (index 3f93a2c..cb1d4f4) |
... |
... |
local function getAuraWeight(unitDesignation, auraIndex, filter) |
73 |
73 |
end |
end |
74 |
74 |
|
|
75 |
75 |
--[[ TODO Make sure getAuraWeight implementation does not depend on locale. ]]-- |
--[[ TODO Make sure getAuraWeight implementation does not depend on locale. ]]-- |
76 |
|
local major = 1 |
|
|
76 |
|
local categoryPrio = 1 |
77 |
77 |
if 'Magic' == category then |
if 'Magic' == category then |
78 |
|
major = 5 |
|
|
78 |
|
categoryPrio = 5 |
79 |
79 |
elseif 'Poison' == category then |
elseif 'Poison' == category then |
80 |
|
major = 4 |
|
|
80 |
|
categoryPrio = 4 |
81 |
81 |
elseif 'Disease' == category then |
elseif 'Disease' == category then |
82 |
|
major = 3 |
|
|
82 |
|
categoryPrio = 3 |
83 |
83 |
elseif 'Curse' == category then |
elseif 'Curse' == category then |
84 |
|
major = 2 |
|
|
84 |
|
categoryPrio = 2 |
85 |
85 |
end |
end |
86 |
|
major = math.min(math.max(1, math.floor(math.abs(major))), 9) |
|
|
86 |
|
categoryPrio = math.min(math.max(1, math.floor(math.abs(categoryPrio))), 9) |
87 |
87 |
|
|
88 |
|
local minor = auraWeightMap[name] or 0 |
|
89 |
|
minor = math.min(math.max(1, math.floor(math.abs(minor))), 9) |
|
|
88 |
|
local specialPrio = auraWeightMap[name] or 0 |
|
89 |
|
specialPrio = math.min(math.max(1, math.floor(math.abs(specialPrio))), 9) |
90 |
90 |
|
|
91 |
|
local patch = 1 |
|
|
91 |
|
local durationIsLimited = 1 |
92 |
92 |
if not durationSec or durationSec < 1 then |
if not durationSec or durationSec < 1 then |
93 |
|
patch = 0 |
|
|
93 |
|
durationIsLimited = 0 |
94 |
94 |
end |
end |
95 |
95 |
|
|
96 |
96 |
local ownerPrio = 1 |
local ownerPrio = 1 |
|
... |
... |
local function getAuraWeight(unitDesignation, auraIndex, filter) |
98 |
98 |
ownerPrio = 2 |
ownerPrio = 2 |
99 |
99 |
end |
end |
100 |
100 |
|
|
101 |
|
return 1000000 * ownerPrio + major * 100000 + minor * 10000 + patch * (3601 - math.min(durationSec, 3600)) |
|
|
101 |
|
local weight = 1000 * ownerPrio + |
|
102 |
|
100 * specialPrio + |
|
103 |
|
durationIsLimited * (91 - math.min(durationSec, 90)) + |
|
104 |
|
categoryPrio |
|
105 |
|
return math.abs(math.floor(weight)) |
102 |
106 |
end |
end |
103 |
107 |
|
|
104 |
108 |
local function getAuraPriorityList(unitDesignation, filter) |
local function getAuraPriorityList(unitDesignation, filter) |