Go で書き直した Ikemen
Revisão | e5aba2968e4df6666ff9faf4b8afea719ab572eb (tree) |
---|---|
Hora | 2016-11-28 00:07:08 |
Autor | SUEHIRO <supersuehiro@user...> |
Commiter | SUEHIRO |
ライフバー記述中
@@ -284,6 +284,12 @@ func ReadAction(sff *Sff, lines []string, i *int) (no int32, a *Animation) { | ||
284 | 284 | (*i)++ |
285 | 285 | return Atoi(subname[spi+1:]), ReadAnimation(sff, lines, i) |
286 | 286 | } |
287 | +func (a *Animation) reset() { | |
288 | + a.current, a.drawidx = 0, 0 | |
289 | + a.time, a.sumtime = 0, 0 | |
290 | + a.newframe, a.loopend = false, false | |
291 | + a.spr = nil | |
292 | +} | |
287 | 293 | func (a *Animation) AnimTime() int32 { |
288 | 294 | return a.sumtime - a.totaltime |
289 | 295 | } |
@@ -372,11 +372,3 @@ func readLayout(pre string, is IniSection) *Layout { | ||
372 | 372 | is.ReadF32(pre+"scale", &l.scale[0], &l.scale[1]) |
373 | 373 | return l |
374 | 374 | } |
375 | -func (l *Layout) setup() { | |
376 | - if l.facing < 0 { | |
377 | - l.offset[0] += lifebarFontScale | |
378 | - } | |
379 | - if l.vfacing < 0 { | |
380 | - l.offset[1] += lifebarFontScale | |
381 | - } | |
382 | -} |
@@ -5,6 +5,36 @@ import ( | ||
5 | 5 | "strings" |
6 | 6 | ) |
7 | 7 | |
8 | +var lifebar Lifebar | |
9 | + | |
10 | +type WinType int32 | |
11 | + | |
12 | +const ( | |
13 | + WT_N WinType = iota | |
14 | + WT_S | |
15 | + WT_H | |
16 | + WT_C | |
17 | + WT_T | |
18 | + WT_Throw | |
19 | + WT_Suicide | |
20 | + WT_Teammate | |
21 | + WT_Perfect | |
22 | + WT_NumTypes | |
23 | + WT_PN | |
24 | + WT_PS | |
25 | + WT_PH | |
26 | + WT_PC | |
27 | + WT_PT | |
28 | + WT_PThrow | |
29 | + WT_PSuicide | |
30 | + WT_PTeammate | |
31 | +) | |
32 | + | |
33 | +func (wt *WinType) SetPerfect() { | |
34 | + if *wt >= WT_N && *wt <= WT_Teammate { | |
35 | + *wt += WT_PN - WT_N | |
36 | + } | |
37 | +} | |
8 | 38 | func readSpr(name string, is IniSection, a *Animation) { |
9 | 39 | a.frames = make([]AnimFrame, 1) |
10 | 40 | var g, n int32 = -1, 0 |
@@ -22,7 +52,6 @@ func readAnm(name string, is IniSection, a *Animation, at *AnimationTable) { | ||
22 | 52 | } |
23 | 53 | |
24 | 54 | type HealthBar struct { |
25 | - at *AnimationTable | |
26 | 55 | pos [2]int32 |
27 | 56 | range_x [2]int32 |
28 | 57 | bg0 Animation |
@@ -37,15 +66,15 @@ type HealthBar struct { | ||
37 | 66 | front_lay Layout |
38 | 67 | } |
39 | 68 | |
40 | -func newHealthBar(sff *Sff, at *AnimationTable) (hb *HealthBar) { | |
41 | - hb = &HealthBar{at: at, bg0: *newAnimation(sff), bg1: *newAnimation(sff), | |
69 | +func newHealthBar(sff *Sff) (hb *HealthBar) { | |
70 | + hb = &HealthBar{bg0: *newAnimation(sff), bg1: *newAnimation(sff), | |
42 | 71 | bg2: *newAnimation(sff), mid: *newAnimation(sff), |
43 | 72 | front: *newAnimation(sff)} |
44 | 73 | return |
45 | 74 | } |
46 | 75 | func readHealthBar(pre string, is IniSection, |
47 | 76 | sff *Sff, at *AnimationTable) *HealthBar { |
48 | - hb := newHealthBar(sff, at) | |
77 | + hb := newHealthBar(sff) | |
49 | 78 | is.ReadI32(pre+"pos", &hb.pos[0], &hb.pos[1]) |
50 | 79 | is.ReadI32(pre+"range.x", &hb.range_x[0], &hb.range_x[1]) |
51 | 80 | readSpr(pre+"bg0.spr", is, &hb.bg0) |
@@ -65,32 +94,43 @@ func readHealthBar(pre string, is IniSection, | ||
65 | 94 | hb.front_lay = *readLayout(pre+"front.", is) |
66 | 95 | return hb |
67 | 96 | } |
97 | +func (hb *HealthBar) reset() { | |
98 | + hb.bg0.reset() | |
99 | + hb.bg1.reset() | |
100 | + hb.bg2.reset() | |
101 | + hb.mid.reset() | |
102 | + hb.front.reset() | |
103 | +} | |
68 | 104 | |
69 | 105 | type PowerBar struct { |
70 | - at *AnimationTable | |
71 | - pos [2]int32 | |
72 | - range_x [2]int32 | |
73 | - bg0 Animation | |
74 | - bg0_lay Layout | |
75 | - bg1 Animation | |
76 | - bg1_lay Layout | |
77 | - bg2 Animation | |
78 | - bg2_lay Layout | |
79 | - mid Animation | |
80 | - mid_lay Layout | |
81 | - front Animation | |
82 | - front_lay Layout | |
106 | + snd *Snd | |
107 | + pos [2]int32 | |
108 | + range_x [2]int32 | |
109 | + bg0 Animation | |
110 | + bg0_lay Layout | |
111 | + bg1 Animation | |
112 | + bg1_lay Layout | |
113 | + bg2 Animation | |
114 | + bg2_lay Layout | |
115 | + mid Animation | |
116 | + mid_lay Layout | |
117 | + front Animation | |
118 | + front_lay Layout | |
119 | + counter_font [3]int32 | |
120 | + counter_lay Layout | |
121 | + level_snd [3][2]int32 | |
83 | 122 | } |
84 | 123 | |
85 | -func newPowerBar(sff *Sff, at *AnimationTable) (pb *PowerBar) { | |
86 | - pb = &PowerBar{at: at, bg0: *newAnimation(sff), bg1: *newAnimation(sff), | |
87 | - bg2: *newAnimation(sff), mid: *newAnimation(sff), | |
88 | - front: *newAnimation(sff)} | |
124 | +func newPowerBar(sff *Sff, snd *Snd) (pb *PowerBar) { | |
125 | + pb = &PowerBar{snd: snd, bg0: *newAnimation(sff), | |
126 | + bg1: *newAnimation(sff), bg2: *newAnimation(sff), mid: *newAnimation(sff), | |
127 | + front: *newAnimation(sff), counter_font: [3]int32{-1}, | |
128 | + level_snd: [3][2]int32{{-1}, {-1}, {-1}}} | |
89 | 129 | return |
90 | 130 | } |
91 | 131 | func readPowerBar(pre string, is IniSection, |
92 | - sff *Sff, at *AnimationTable) *PowerBar { | |
93 | - pb := newPowerBar(sff, at) | |
132 | + sff *Sff, at *AnimationTable, snd *Snd) *PowerBar { | |
133 | + pb := newPowerBar(sff, snd) | |
94 | 134 | is.ReadI32(pre+"pos", &pb.pos[0], &pb.pos[1]) |
95 | 135 | is.ReadI32(pre+"range.x", &pb.range_x[0], &pb.range_x[1]) |
96 | 136 | readSpr(pre+"bg0.spr", is, &pb.bg0) |
@@ -108,48 +148,246 @@ func readPowerBar(pre string, is IniSection, | ||
108 | 148 | readSpr(pre+"front.spr", is, &pb.front) |
109 | 149 | readAnm(pre+"front.anim", is, &pb.front, at) |
110 | 150 | pb.front_lay = *readLayout(pre+"front.", is) |
151 | + is.ReadI32(pre+"counter.font", &pb.counter_font[0], &pb.counter_font[1], | |
152 | + &pb.counter_font[2]) | |
153 | + pb.counter_lay = *readLayout(pre+"counter.", is) | |
154 | + for i := range pb.level_snd { | |
155 | + is.ReadI32(fmt.Sprintf("%slevel%d.snd", pre, i+1), &pb.level_snd[i][0], | |
156 | + &pb.level_snd[i][1]) | |
157 | + } | |
111 | 158 | return pb |
112 | 159 | } |
160 | +func (pb *PowerBar) reset() { | |
161 | + pb.bg0.reset() | |
162 | + pb.bg1.reset() | |
163 | + pb.bg2.reset() | |
164 | + pb.mid.reset() | |
165 | + pb.front.reset() | |
166 | +} | |
113 | 167 | |
114 | -type LifeBarFace struct{ at *AnimationTable } | |
168 | +type LifeBarFace struct { | |
169 | + pos [2]int32 | |
170 | + bg Animation | |
171 | + bg_lay Layout | |
172 | + face_spr [2]int32 | |
173 | + face *Sprite | |
174 | + face_lay Layout | |
175 | + teammate_pos [2]int32 | |
176 | + teammate_spacing [2]int32 | |
177 | + teammate_bg Animation | |
178 | + teammate_bg_lay Layout | |
179 | + teammate_ko Animation | |
180 | + teammate_ko_lay Layout | |
181 | + teammate_face_spr [2]int32 | |
182 | + teammate_face []*Sprite | |
183 | + teammate_face_lay Layout | |
184 | +} | |
115 | 185 | |
116 | -func newLifeBarFace(sff *Sff, at *AnimationTable) *LifeBarFace { | |
117 | - return &LifeBarFace{at: at} | |
186 | +func newLifeBarFace(sff *Sff) *LifeBarFace { | |
187 | + return &LifeBarFace{bg: *newAnimation(sff), face_spr: [2]int32{-1}, | |
188 | + teammate_bg: *newAnimation(sff), teammate_ko: *newAnimation(sff), | |
189 | + teammate_face_spr: [2]int32{-1}} | |
190 | +} | |
191 | +func readLifeBarFace(pre string, is IniSection, | |
192 | + sff *Sff, at *AnimationTable) *LifeBarFace { | |
193 | + f := newLifeBarFace(sff) | |
194 | + is.ReadI32(pre+"pos", &f.pos[0], &f.pos[1]) | |
195 | + readSpr(pre+"bg.spr", is, &f.bg) | |
196 | + readAnm(pre+"bg.anim", is, &f.bg, at) | |
197 | + f.bg_lay = *readLayout(pre+"bg.", is) | |
198 | + is.ReadI32(pre+"face.spr", &f.face_spr[0], &f.face_spr[1]) | |
199 | + f.face_lay = *readLayout(pre+"face.", is) | |
200 | + is.ReadI32(pre+"teammate.pos", &f.teammate_pos[0], &f.teammate_pos[1]) | |
201 | + is.ReadI32(pre+"teammate.spacing", &f.teammate_spacing[0], | |
202 | + &f.teammate_spacing[1]) | |
203 | + readSpr(pre+"teammate.bg.spr", is, &f.teammate_bg) | |
204 | + readAnm(pre+"teammate.bg.anim", is, &f.teammate_bg, at) | |
205 | + f.teammate_bg_lay = *readLayout(pre+"teammate.bg.", is) | |
206 | + readSpr(pre+"teammate.ko.spr", is, &f.teammate_ko) | |
207 | + readAnm(pre+"teammate.ko.anim", is, &f.teammate_ko, at) | |
208 | + f.teammate_ko_lay = *readLayout(pre+"teammate.ko.", is) | |
209 | + is.ReadI32(pre+"teammate.face.spr", &f.teammate_face_spr[0], | |
210 | + &f.teammate_face_spr[1]) | |
211 | + f.teammate_face_lay = *readLayout(pre+"teammate.face.", is) | |
212 | + return f | |
213 | +} | |
214 | +func (f *LifeBarFace) reset() { | |
215 | + f.bg.reset() | |
216 | + f.teammate_bg.reset() | |
217 | + f.teammate_ko.reset() | |
118 | 218 | } |
119 | 219 | |
120 | -type LifeBarName struct{ at *AnimationTable } | |
220 | +type LifeBarName struct { | |
221 | + pos [2]int32 | |
222 | + name_font [3]int32 | |
223 | + name_lay Layout | |
224 | + bg Animation | |
225 | + bg_lay Layout | |
226 | +} | |
121 | 227 | |
122 | -func newLifeBarName(sff *Sff, at *AnimationTable) *LifeBarName { | |
123 | - return &LifeBarName{at: at} | |
228 | +func newLifeBarName(sff *Sff) *LifeBarName { | |
229 | + return &LifeBarName{name_font: [3]int32{-1}, bg: *newAnimation(sff)} | |
230 | +} | |
231 | +func readLifeBarName(pre string, is IniSection, | |
232 | + sff *Sff, at *AnimationTable) *LifeBarName { | |
233 | + n := newLifeBarName(sff) | |
234 | + is.ReadI32(pre+"pos", &n.pos[0], &n.pos[1]) | |
235 | + is.ReadI32(pre+"name.font", &n.name_font[0], &n.name_font[1], | |
236 | + &n.name_font[2]) | |
237 | + n.name_lay = *readLayout(pre+"name.", is) | |
238 | + readSpr(pre+"bg.spr", is, &n.bg) | |
239 | + readAnm(pre+"bg.anim", is, &n.bg, at) | |
240 | + n.bg_lay = *readLayout(pre+"bg.", is) | |
241 | + return n | |
124 | 242 | } |
243 | +func (n *LifeBarName) reset() { n.bg.reset() } | |
125 | 244 | |
126 | -type LifeBarWinIcon struct{ at *AnimationTable } | |
245 | +type LifeBarWinIcon struct { | |
246 | + pos [2]int32 | |
247 | + iconoffset [2]int32 | |
248 | + useiconupto int32 | |
249 | + counter_font [3]int32 | |
250 | + counter_lay Layout | |
251 | + icon [WT_NumTypes]Animation | |
252 | + icon_lay [WT_NumTypes]Layout | |
253 | + wins []WinType | |
254 | + numWins int | |
255 | + added, addedp *Animation | |
256 | +} | |
127 | 257 | |
128 | -func newLifeBarWinIcon(sff *Sff, at *AnimationTable) *LifeBarWinIcon { | |
129 | - return &LifeBarWinIcon{at: at} | |
258 | +func newLifeBarWinIcon(sff *Sff) (wi *LifeBarWinIcon) { | |
259 | + wi = &LifeBarWinIcon{useiconupto: 4, counter_font: [3]int32{-1}} | |
260 | + for i := range wi.icon { | |
261 | + wi.icon[i] = *newAnimation(sff) | |
262 | + } | |
263 | + return | |
264 | +} | |
265 | +func readLifeBarWinIcon(pre string, is IniSection, | |
266 | + sff *Sff, at *AnimationTable) *LifeBarWinIcon { | |
267 | + wi := newLifeBarWinIcon(sff) | |
268 | + is.ReadI32(pre+"pos", &wi.pos[0], &wi.pos[1]) | |
269 | + is.ReadI32(pre+"iconoffset", &wi.iconoffset[0], &wi.iconoffset[1]) | |
270 | + is.ReadI32(pre+"useiconupto", &wi.useiconupto) | |
271 | + is.ReadI32(pre+"counter.font", &wi.counter_font[0], &wi.counter_font[1], | |
272 | + &wi.counter_font[2]) | |
273 | + wi.counter_lay = *readLayout(pre+"counter.", is) | |
274 | + readSpr(pre+"n.spr", is, &wi.icon[WT_N]) | |
275 | + readAnm(pre+"n.anim", is, &wi.icon[WT_N], at) | |
276 | + wi.icon_lay[WT_N] = *readLayout(pre+"n.", is) | |
277 | + readSpr(pre+"s.spr", is, &wi.icon[WT_S]) | |
278 | + readAnm(pre+"s.anim", is, &wi.icon[WT_S], at) | |
279 | + wi.icon_lay[WT_S] = *readLayout(pre+"s.", is) | |
280 | + readSpr(pre+"h.spr", is, &wi.icon[WT_H]) | |
281 | + readAnm(pre+"h.anim", is, &wi.icon[WT_H], at) | |
282 | + wi.icon_lay[WT_H] = *readLayout(pre+"h.", is) | |
283 | + readSpr(pre+"c.spr", is, &wi.icon[WT_C]) | |
284 | + readAnm(pre+"c.anim", is, &wi.icon[WT_C], at) | |
285 | + wi.icon_lay[WT_C] = *readLayout(pre+"c.", is) | |
286 | + readSpr(pre+"t.spr", is, &wi.icon[WT_T]) | |
287 | + readAnm(pre+"t.anim", is, &wi.icon[WT_T], at) | |
288 | + wi.icon_lay[WT_T] = *readLayout(pre+"t.", is) | |
289 | + readSpr(pre+"throw.spr", is, &wi.icon[WT_Throw]) | |
290 | + readAnm(pre+"throw.anim", is, &wi.icon[WT_Throw], at) | |
291 | + wi.icon_lay[WT_Throw] = *readLayout(pre+"throw.", is) | |
292 | + readSpr(pre+"suicide.spr", is, &wi.icon[WT_Suicide]) | |
293 | + readAnm(pre+"suicide.anim", is, &wi.icon[WT_Suicide], at) | |
294 | + wi.icon_lay[WT_Suicide] = *readLayout(pre+"suicide.", is) | |
295 | + readSpr(pre+"teammate.spr", is, &wi.icon[WT_Teammate]) | |
296 | + readAnm(pre+"teammate.anim", is, &wi.icon[WT_Teammate], at) | |
297 | + wi.icon_lay[WT_Teammate] = *readLayout(pre+"teammate.", is) | |
298 | + readSpr(pre+"perfect.spr", is, &wi.icon[WT_Perfect]) | |
299 | + readAnm(pre+"perfect.anim", is, &wi.icon[WT_Perfect], at) | |
300 | + wi.icon_lay[WT_Perfect] = *readLayout(pre+"perfect.", is) | |
301 | + return wi | |
302 | +} | |
303 | +func (wi *LifeBarWinIcon) reset() { | |
304 | + for i := range wi.icon { | |
305 | + wi.icon[i].reset() | |
306 | + } | |
307 | + wi.numWins = len(wi.wins) | |
308 | + wi.added, wi.addedp = nil, nil | |
130 | 309 | } |
310 | +func (wi *LifeBarWinIcon) clear() { wi.wins = nil } | |
131 | 311 | |
132 | -type LifeBarTime struct{ at *AnimationTable } | |
312 | +type LifeBarTime struct { | |
313 | + pos [2]int32 | |
314 | + counter_font [3]int32 | |
315 | + counter_lay Layout | |
316 | + bg Animation | |
317 | + bg_lay Layout | |
318 | + framespercount int32 | |
319 | +} | |
133 | 320 | |
134 | -func newLifeBarTime(sff *Sff, at *AnimationTable) *LifeBarTime { | |
135 | - return &LifeBarTime{at: at} | |
321 | +func newLifeBarTime(sff *Sff) *LifeBarTime { | |
322 | + return &LifeBarTime{counter_font: [3]int32{-1}, bg: *newAnimation(sff), | |
323 | + framespercount: 60} | |
324 | +} | |
325 | +func readLifeBarTime(is IniSection, | |
326 | + sff *Sff, at *AnimationTable) *LifeBarTime { | |
327 | + t := newLifeBarTime(sff) | |
328 | + is.ReadI32("pos", &t.pos[0], &t.pos[1]) | |
329 | + is.ReadI32("counter.font", &t.counter_font[0], &t.counter_font[1], | |
330 | + &t.counter_font[2]) | |
331 | + t.counter_lay = *readLayout("counter.", is) | |
332 | + readSpr("bg.spr", is, &t.bg) | |
333 | + readAnm("bg.anim", is, &t.bg, at) | |
334 | + t.bg_lay = *readLayout("bg.", is) | |
335 | + is.ReadI32("framespercount", &t.framespercount) | |
336 | + return t | |
136 | 337 | } |
338 | +func (t *LifeBarTime) reset() { t.bg.reset() } | |
137 | 339 | |
138 | -type LifeBarCombo struct{} | |
340 | +type LifeBarCombo struct { | |
341 | + pos [2]int32 | |
342 | + start_x float32 | |
343 | + counter_font [3]int32 | |
344 | + counter_shake int32 | |
345 | + counter_lay Layout | |
346 | + text_font [3]int32 | |
347 | + text_text string | |
348 | + text_lay Layout | |
349 | + displaytime int32 | |
350 | + cur, old [2]int32 | |
351 | + resttime [2]int32 | |
352 | + counterX [2]float32 | |
353 | + shaketime [2]int32 | |
354 | +} | |
139 | 355 | |
140 | 356 | func newLifeBarCombo() *LifeBarCombo { |
141 | - return &LifeBarCombo{} | |
357 | + return &LifeBarCombo{counter_font: [3]int32{-1}, | |
358 | + counter_lay: Layout{layerno: 2}, | |
359 | + text_font: [3]int32{-1}, text_lay: Layout{layerno: 2}, displaytime: 90} | |
360 | +} | |
361 | +func readLifeBarCombo(is IniSection) *LifeBarCombo { | |
362 | + c := newLifeBarCombo() | |
363 | + is.ReadI32("pos", &c.pos[0], &c.pos[1]) | |
364 | + is.ReadF32("start.x", &c.start_x) | |
365 | + is.ReadI32("counter.font", &c.counter_font[0], &c.counter_font[1], | |
366 | + &c.counter_font[2]) | |
367 | + is.ReadI32("counter.shake", &c.counter_shake) | |
368 | + c.counter_lay = *readLayout("counter.", is) | |
369 | + c.counter_lay.offset = [2]float32{0, 0} | |
370 | + is.ReadI32("text.font", &c.text_font[0], &c.text_font[1], &c.text_font[2]) | |
371 | + c.text_text = is["text.text"] | |
372 | + c.text_lay = *readLayout("text.", is) | |
373 | + is.ReadI32("displaytime", &c.displaytime) | |
374 | + return c | |
375 | +} | |
376 | +func (c *LifeBarCombo) reset() { | |
377 | + c.cur, c.old, c.resttime = [2]int32{}, [2]int32{}, [2]int32{} | |
378 | + c.counterX = [2]float32{c.start_x * 2, c.start_x * 2} | |
379 | + c.shaketime = [2]int32{} | |
142 | 380 | } |
143 | 381 | |
144 | -type LifeBarRound struct{ at *AnimationTable } | |
382 | +type LifeBarRound struct{} | |
145 | 383 | |
146 | -func newLifeBarRound(sff *Sff, at *AnimationTable) *LifeBarRound { | |
147 | - return &LifeBarRound{at: at} | |
384 | +func newLifeBarRound(sff *Sff) *LifeBarRound { | |
385 | + return &LifeBarRound{} | |
148 | 386 | } |
149 | 387 | |
150 | 388 | type Lifebar struct { |
151 | - snd, fsnd *Snd | |
152 | 389 | at, fat *AnimationTable |
390 | + snd, fsnd *Snd | |
153 | 391 | fnt [10]*Fnt |
154 | 392 | hb [3][]*HealthBar |
155 | 393 | pb [2]*PowerBar |
@@ -167,7 +405,7 @@ func LoadLifebar(deffile string) (*Lifebar, error) { | ||
167 | 405 | return nil, err |
168 | 406 | } |
169 | 407 | sff, fsff, lines, i := &Sff{}, &Sff{}, SplitAndTrim(str, "\n"), 0 |
170 | - l := &Lifebar{at: ReadAnimationTable(sff, lines, &i), | |
408 | + l := &Lifebar{at: ReadAnimationTable(sff, lines, &i), snd: &Snd{}, | |
171 | 409 | hb: [3][]*HealthBar{make([]*HealthBar, 2), make([]*HealthBar, 4), |
172 | 410 | make([]*HealthBar, 2)}, |
173 | 411 | fa: [3][]*LifeBarFace{make([]*LifeBarFace, 2), make([]*LifeBarFace, 4), |
@@ -193,8 +431,12 @@ func LoadLifebar(deffile string) (*Lifebar, error) { | ||
193 | 431 | return nil, err |
194 | 432 | } |
195 | 433 | if is.LoadFile("snd", deffile, func(filename string) error { |
196 | - l.snd, err = LoadSnd(filename) | |
197 | - return err | |
434 | + s, err := LoadSnd(filename) | |
435 | + if err != nil { | |
436 | + return err | |
437 | + } | |
438 | + *l.snd = *s | |
439 | + return nil | |
198 | 440 | }); err != nil { |
199 | 441 | return nil, err |
200 | 442 | } |
@@ -243,8 +485,26 @@ func LoadLifebar(deffile string) (*Lifebar, error) { | ||
243 | 485 | l.hb[0][1] = readHealthBar("p2.", is, sff, l.at) |
244 | 486 | } |
245 | 487 | case "powerbar": |
488 | + if l.pb[0] == nil { | |
489 | + l.pb[0] = readPowerBar("p1.", is, sff, l.at, l.snd) | |
490 | + } | |
491 | + if l.pb[1] == nil { | |
492 | + l.pb[1] = readPowerBar("p2.", is, sff, l.at, l.snd) | |
493 | + } | |
246 | 494 | case "face": |
495 | + if l.fa[0][0] == nil { | |
496 | + l.fa[0][0] = readLifeBarFace("p1.", is, sff, l.at) | |
497 | + } | |
498 | + if l.fa[0][1] == nil { | |
499 | + l.fa[0][1] = readLifeBarFace("p2.", is, sff, l.at) | |
500 | + } | |
247 | 501 | case "name": |
502 | + if l.nm[0][0] == nil { | |
503 | + l.nm[0][0] = readLifeBarName("p1.", is, sff, l.at) | |
504 | + } | |
505 | + if l.nm[0][1] == nil { | |
506 | + l.nm[0][1] = readLifeBarName("p2.", is, sff, l.at) | |
507 | + } | |
248 | 508 | case "simul ": |
249 | 509 | subname = strings.ToLower(subname) |
250 | 510 | switch { |
@@ -262,7 +522,31 @@ func LoadLifebar(deffile string) (*Lifebar, error) { | ||
262 | 522 | l.hb[1][3] = readHealthBar("p4.", is, sff, l.at) |
263 | 523 | } |
264 | 524 | case len(subname) >= 4 && subname[:4] == "face": |
525 | + if l.fa[1][0] == nil { | |
526 | + l.fa[1][0] = readLifeBarFace("p1.", is, sff, l.at) | |
527 | + } | |
528 | + if l.fa[1][1] == nil { | |
529 | + l.fa[1][1] = readLifeBarFace("p2.", is, sff, l.at) | |
530 | + } | |
531 | + if l.fa[1][2] == nil { | |
532 | + l.fa[1][2] = readLifeBarFace("p3.", is, sff, l.at) | |
533 | + } | |
534 | + if l.fa[1][3] == nil { | |
535 | + l.fa[1][3] = readLifeBarFace("p4.", is, sff, l.at) | |
536 | + } | |
265 | 537 | case len(subname) >= 4 && subname[:4] == "name": |
538 | + if l.nm[1][0] == nil { | |
539 | + l.nm[1][0] = readLifeBarName("p1.", is, sff, l.at) | |
540 | + } | |
541 | + if l.nm[1][1] == nil { | |
542 | + l.nm[1][1] = readLifeBarName("p2.", is, sff, l.at) | |
543 | + } | |
544 | + if l.nm[1][2] == nil { | |
545 | + l.nm[1][2] = readLifeBarName("p3.", is, sff, l.at) | |
546 | + } | |
547 | + if l.nm[1][3] == nil { | |
548 | + l.nm[1][3] = readLifeBarName("p4.", is, sff, l.at) | |
549 | + } | |
266 | 550 | } |
267 | 551 | case "turns ": |
268 | 552 | subname = strings.ToLower(subname) |
@@ -275,11 +559,35 @@ func LoadLifebar(deffile string) (*Lifebar, error) { | ||
275 | 559 | l.hb[2][1] = readHealthBar("p2.", is, sff, l.at) |
276 | 560 | } |
277 | 561 | case len(subname) >= 4 && subname[:4] == "face": |
562 | + if l.fa[2][0] == nil { | |
563 | + l.fa[2][0] = readLifeBarFace("p1.", is, sff, l.at) | |
564 | + } | |
565 | + if l.fa[2][1] == nil { | |
566 | + l.fa[2][1] = readLifeBarFace("p2.", is, sff, l.at) | |
567 | + } | |
278 | 568 | case len(subname) >= 4 && subname[:4] == "name": |
569 | + if l.nm[2][0] == nil { | |
570 | + l.nm[2][0] = readLifeBarName("p1.", is, sff, l.at) | |
571 | + } | |
572 | + if l.nm[2][1] == nil { | |
573 | + l.nm[2][1] = readLifeBarName("p2.", is, sff, l.at) | |
574 | + } | |
279 | 575 | } |
280 | 576 | case "winicon": |
577 | + if l.wi[0] == nil { | |
578 | + l.wi[0] = readLifeBarWinIcon("p1.", is, sff, l.at) | |
579 | + } | |
580 | + if l.wi[1] == nil { | |
581 | + l.wi[1] = readLifeBarWinIcon("p2.", is, sff, l.at) | |
582 | + } | |
281 | 583 | case "time": |
584 | + if l.ti == nil { | |
585 | + l.ti = readLifeBarTime(is, sff, l.at) | |
586 | + } | |
282 | 587 | case "combo": |
588 | + if l.co == nil { | |
589 | + l.co = readLifeBarCombo(is) | |
590 | + } | |
283 | 591 | case "round": |
284 | 592 | } |
285 | 593 | } |