File src/ChorusProgressFrameTemplate.lua changed (mode: 100644) (index 1815f31..0ee693c) |
... |
... |
local function validateProgressFrame(self) |
29 |
29 |
local artwork = self.artwork |
local artwork = self.artwork |
30 |
30 |
assert(artwork ~= nil) |
assert(artwork ~= nil) |
31 |
31 |
|
|
32 |
|
local label = self.label |
|
33 |
|
assert(label ~= nil) |
|
|
32 |
|
local label1 = self.label1 |
|
33 |
|
assert(label1 ~= nil) |
|
34 |
|
|
|
35 |
|
local label2 = self.label2 |
|
36 |
|
assert(label2 ~= nil) |
|
37 |
|
|
|
38 |
|
local label3 = self.label3 |
|
39 |
|
assert(label3 ~= nil) |
34 |
40 |
|
|
35 |
41 |
local ratio = self:GetValue() |
local ratio = self:GetValue() |
36 |
42 |
assert(ratio ~= nil) |
assert(ratio ~= nil) |
|
... |
... |
end |
77 |
83 |
local function applySize(self) |
local function applySize(self) |
78 |
84 |
assert(self ~= nil) |
assert(self ~= nil) |
79 |
85 |
|
|
80 |
|
local label = self.label |
|
81 |
|
assert(label ~= nil) |
|
|
86 |
|
local label1 = self.label1 |
|
87 |
|
assert(label1 ~= nil) |
|
88 |
|
|
|
89 |
|
local label2 = self.label2 |
|
90 |
|
assert(label2 ~= nil) |
|
91 |
|
|
|
92 |
|
local label3 = self.label3 |
|
93 |
|
assert(label3 ~= nil) |
82 |
94 |
|
|
83 |
95 |
if self:GetHeight() >= 12 then |
if self:GetHeight() >= 12 then |
84 |
|
label:Show() |
|
|
96 |
|
label1:Show() |
|
97 |
|
label2:Show() |
|
98 |
|
label3:Show() |
85 |
99 |
else |
else |
86 |
|
label:Hide() |
|
|
100 |
|
label1:Hide() |
|
101 |
|
label2:Hide() |
|
102 |
|
label3:Hide() |
87 |
103 |
end |
end |
88 |
104 |
end |
end |
89 |
105 |
|
|
|
... |
... |
local function applyRatio(self, a, b) |
94 |
110 |
self:SetValue(getRatio(a, b)) |
self:SetValue(getRatio(a, b)) |
95 |
111 |
end |
end |
96 |
112 |
|
|
|
113 |
|
local function formatQuantity(quantity) |
|
114 |
|
assert(quantity ~= nil) |
|
115 |
|
assert('number' == type(quantity)) |
|
116 |
|
|
|
117 |
|
local t |
|
118 |
|
if math.abs(quantity) < 1000 then |
|
119 |
|
t = string.format('%d',quantity) |
|
120 |
|
elseif math.abs(quantity) < 1000000 then |
|
121 |
|
t = string.format('%.2f K', quantity / 1000) |
|
122 |
|
else |
|
123 |
|
t = string.format('%.2f M', quantity / 1000000) |
|
124 |
|
end |
|
125 |
|
|
|
126 |
|
return t |
|
127 |
|
end |
|
128 |
|
|
97 |
129 |
local function applyOverlay(self, a, b) |
local function applyOverlay(self, a, b) |
98 |
130 |
assert(self ~= nil) |
assert(self ~= nil) |
99 |
131 |
|
|
|
... |
... |
local function applyOverlay(self, a, b) |
111 |
143 |
|
|
112 |
144 |
local ratio = getRatio(a, b) |
local ratio = getRatio(a, b) |
113 |
145 |
|
|
114 |
|
local t = '' |
|
115 |
|
local scale |
|
116 |
|
local fontSize = 12 |
|
117 |
|
if a < 1000 then |
|
118 |
|
t = t .. string.format('%d', a) |
|
119 |
|
elseif a < 1000000 then |
|
120 |
|
t = t .. string.format('%.2f K', a / 1000) |
|
121 |
|
else |
|
122 |
|
t = t .. string.format('%.2f M', a / 1000000) |
|
123 |
|
end |
|
124 |
|
|
|
125 |
|
if 23 <= self:GetHeight() then |
|
126 |
|
t = t .. '\n' |
|
127 |
|
scale = 1 / fontSize / 2 |
|
128 |
|
else |
|
129 |
|
scale = 1 / fontSize |
|
130 |
|
t = t .. ' ' |
|
131 |
|
end |
|
132 |
|
|
|
133 |
|
t = t .. string.format('%.0f%%', ratio * 100) |
|
|
146 |
|
local label1 = self.label1 or _G[self:GetName() .. 'Text1'] |
|
147 |
|
assert(label1 ~= nil) |
|
148 |
|
local t = formatQuantity(a) |
|
149 |
|
label1:SetText(t) |
134 |
150 |
|
|
135 |
|
local label = self.label or _G[self:GetName() .. 'Text'] |
|
136 |
|
assert(label ~= nil) |
|
137 |
|
label:SetText(t) |
|
|
151 |
|
local label2 = self.label2 or _G[self:GetName() .. 'Text2'] |
|
152 |
|
assert(label2 ~= nil) |
|
153 |
|
local e = string.format('%.0f%%', ratio * 100) |
|
154 |
|
label2:SetText(e) |
138 |
155 |
|
|
139 |
156 |
--[[ ShadowedUnitFrames recommend this approach for adjusting font size. ]]-- |
--[[ ShadowedUnitFrames recommend this approach for adjusting font size. ]]-- |
140 |
157 |
if t ~= nil and string.len(t) >= 1 then |
if t ~= nil and string.len(t) >= 1 then |
141 |
|
self:SetScale(label:GetStringHeight() * scale) |
|
|
158 |
|
local fontSize = 12 |
|
159 |
|
self:SetScale(label1:GetStringHeight() / fontSize) |
142 |
160 |
end |
end |
143 |
161 |
end |
end |
144 |
162 |
|
|
|
... |
... |
local function applyRatioHealth(self, unitDesignation) |
153 |
171 |
applyRatio(self, a, b) |
applyRatio(self, a, b) |
154 |
172 |
end |
end |
155 |
173 |
|
|
|
174 |
|
local function applyOverlayHealthDeficit(self, a, b) |
|
175 |
|
assert(self ~= nil) |
|
176 |
|
|
|
177 |
|
local label3 = self.label3 or _G[self:GetName() .. 'Text3'] |
|
178 |
|
assert(label3 ~= nil) |
|
179 |
|
if a and b and a >= 1 and b >= 1 and a < b then |
|
180 |
|
local c = a - b |
|
181 |
|
local t = formatQuantity(c) |
|
182 |
|
label3:SetText(t) |
|
183 |
|
else |
|
184 |
|
label3:SetText(nil) |
|
185 |
|
end |
|
186 |
|
end |
|
187 |
|
|
156 |
188 |
local function applyOverlayHealth(self, unitDesignation) |
local function applyOverlayHealth(self, unitDesignation) |
157 |
189 |
assert(self ~= nil) |
assert(self ~= nil) |
158 |
190 |
|
|
159 |
191 |
assert(unitDesignation ~= nil) |
assert(unitDesignation ~= nil) |
160 |
192 |
|
|
161 |
|
local label = self.label |
|
162 |
|
assert(label ~= nil) |
|
|
193 |
|
local label1 = self.label1 |
|
194 |
|
assert(label1 ~= nil) |
163 |
195 |
|
|
164 |
196 |
local artwork = self.artwork |
local artwork = self.artwork |
165 |
197 |
assert(artwork ~= nil) |
assert(artwork ~= nil) |
166 |
198 |
|
|
167 |
199 |
--[[ TODO Use indicators instead of localized text for character alive statuses. ]]-- |
--[[ TODO Use indicators instead of localized text for character alive statuses. ]]-- |
168 |
200 |
if UnitIsCorpse(unitDesignation) then |
if UnitIsCorpse(unitDesignation) then |
169 |
|
label:SetText('(Corpse)') |
|
|
201 |
|
label1:SetText('(Corpse)') |
170 |
202 |
elseif UnitIsGhost(unitDesignation) then |
elseif UnitIsGhost(unitDesignation) then |
171 |
|
label:SetText('(Ghost)') |
|
|
203 |
|
label1:SetText('(Ghost)') |
172 |
204 |
elseif UnitIsDead(unitDesignation) then |
elseif UnitIsDead(unitDesignation) then |
173 |
|
label:SetText('(Dead)') |
|
|
205 |
|
label1:SetText('(Dead)') |
174 |
206 |
else |
else |
175 |
207 |
local a = UnitHealth(unitDesignation) or 0 |
local a = UnitHealth(unitDesignation) or 0 |
176 |
208 |
local b = UnitHealthMax(unitDesignation) or 1 |
local b = UnitHealthMax(unitDesignation) or 1 |
177 |
209 |
|
|
178 |
210 |
applyOverlay(self, a, b) |
applyOverlay(self, a, b) |
|
211 |
|
applyOverlayHealthDeficit(self, a, b) |
179 |
212 |
end |
end |
180 |
213 |
end |
end |
181 |
214 |
|
|
|
... |
... |
function Chorus.progressFrameMain(self) |
403 |
436 |
assert(artwork ~= nil) |
assert(artwork ~= nil) |
404 |
437 |
self.artwork = artwork |
self.artwork = artwork |
405 |
438 |
|
|
406 |
|
local label = _G[frameDesignation .. 'Text'] |
|
407 |
|
assert(label ~= nil) |
|
408 |
|
self.label = label |
|
|
439 |
|
local label1 = _G[frameDesignation .. 'Text1'] |
|
440 |
|
assert(label1 ~= nil) |
|
441 |
|
self.label1 = label1 |
|
442 |
|
|
|
443 |
|
local label2 = _G[frameDesignation .. 'Text2'] |
|
444 |
|
assert(label2 ~= nil) |
|
445 |
|
self.label2 = label2 |
|
446 |
|
|
|
447 |
|
local label3 = _G[frameDesignation .. 'Text3'] |
|
448 |
|
assert(label3 ~= nil) |
|
449 |
|
self.label3 = label3 |
409 |
450 |
|
|
410 |
451 |
self:RegisterEvent('PARTY_CONVERTED_TO_RAID') |
self:RegisterEvent('PARTY_CONVERTED_TO_RAID') |
411 |
452 |
self:RegisterEvent('PARTY_MEMBERS_CHANGED') |
self:RegisterEvent('PARTY_MEMBERS_CHANGED') |