/
HudFragment.java
794 lines (658 loc) · 28.4 KB
/
HudFragment.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
package mindustry.ui.fragments;
import arc.*;
import arc.func.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.*;
import arc.scene.actions.*;
import arc.scene.event.*;
import arc.scene.style.*;
import arc.scene.ui.*;
import arc.scene.ui.ImageButton.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.ctype.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.input.*;
import mindustry.net.Packets.*;
import mindustry.type.*;
import mindustry.ui.*;
import static mindustry.Vars.*;
public class HudFragment extends Fragment{
private static final float dsize = 65f;
public final PlacementFragment blockfrag = new PlacementFragment();
public boolean shown = true;
private ImageButton flip;
private CoreItemsDisplay coreItems = new CoreItemsDisplay();
private String hudText = "";
private boolean showHudText;
private Table lastUnlockTable;
private Table lastUnlockLayout;
private long lastToast;
@Override
public void build(Group parent){
//warn about guardian/boss waves
Events.on(WaveEvent.class, e -> {
int max = 10;
int winWave = state.isCampaign() && state.rules.winWave > 0 ? state.rules.winWave : Integer.MAX_VALUE;
outer:
for(int i = state.wave - 1; i <= Math.min(state.wave + max, winWave - 2); i++){
for(SpawnGroup group : state.rules.spawns){
if(group.effect == StatusEffects.boss && group.getSpawned(i) > 0){
int diff = (i + 2) - state.wave;
//increments at which to warn about incoming guardian
if(diff == 1 || diff == 2 || diff == 5 || diff == 10){
showToast(Icon.warning, Core.bundle.format("wave.guardianwarn" + (diff == 1 ? ".one" : ""), diff));
}
break outer;
}
}
}
});
Events.on(SectorCaptureEvent.class, e ->{
showToast(Core.bundle.format("sector.captured", e.sector.isBeingPlayed() ? "" : e.sector.name() + " "));
});
Events.on(SectorLoseEvent.class, e -> {
showToast(Icon.warning, Core.bundle.format("sector.lost", e.sector.name()));
});
Events.on(SectorInvasionEvent.class, e -> {
showToast(Icon.warning, Core.bundle.format("sector.attacked", e.sector.name()));
});
Events.on(ResetEvent.class, e -> {
coreItems.resetUsed();
coreItems.clear();
});
//paused table
parent.fill(t -> {
t.name = "paused";
t.top().visible(() -> state.isPaused() && shown).touchable = Touchable.disabled;
t.table(Styles.black5, top -> top.label(() -> state.gameOver && state.isCampaign() ? "@sector.curlost" : "@paused").style(Styles.outlineLabel).pad(8f)).growX();
});
//minimap + position
parent.fill(t -> {
t.name = "minimap/position";
t.visible(() -> Core.settings.getBool("minimap") && shown);
//minimap
t.add(new Minimap()).name("minimap");
t.row();
//position
t.label(() -> player.tileX() + "," + player.tileY())
.visible(() -> Core.settings.getBool("position"))
.touchable(Touchable.disabled)
.name("position");
t.top().right();
});
//TODO tear this all down
//menu at top left
parent.fill(cont -> {
cont.name = "overlaymarker";
cont.top().left();
if(mobile){
cont.table(select -> {
select.name = "mobile buttons";
select.left();
select.defaults().size(dsize).left();
ImageButtonStyle style = Styles.clearTransi;
select.button(Icon.menu, style, ui.paused::show).name("menu");
flip = select.button(Icon.upOpen, style, this::toggleMenus).get();
flip.name = "flip";
select.button(Icon.paste, style, ui.schematics::show)
.name("schematics");
select.button(Icon.pause, style, () -> {
if(net.active()){
ui.listfrag.toggle();
}else{
state.set(state.is(State.paused) ? State.playing : State.paused);
}
}).name("pause").update(i -> {
if(net.active()){
i.getStyle().imageUp = Icon.players;
}else{
i.setDisabled(false);
i.getStyle().imageUp = state.is(State.paused) ? Icon.play : Icon.pause;
}
});
select.button(Icon.chat, style,() -> {
if(net.active() && mobile){
if(ui.chatfrag.shown()){
ui.chatfrag.hide();
}else{
ui.chatfrag.toggle();
}
}else if(state.isCampaign()){
ui.research.show();
}else{
ui.database.show();
}
}).name("chat").update(i -> {
if(net.active() && mobile){
i.getStyle().imageUp = Icon.chat;
}else if(state.isCampaign()){
i.getStyle().imageUp = Icon.tree;
}else{
i.getStyle().imageUp = Icon.book;
}
});
select.image().color(Pal.gray).width(4f).fillY();
});
cont.row();
cont.image().height(4f).color(Pal.gray).fillX();
cont.row();
}
cont.update(() -> {
if(Core.input.keyTap(Binding.toggle_menus) && !ui.chatfrag.shown() && !Core.scene.hasDialog() && !(Core.scene.getKeyboardFocus() instanceof TextField)){
Core.settings.getBoolOnce("ui-hidden", () -> {
ui.announce(Core.bundle.format("showui", Core.keybinds.get(Binding.toggle_menus).key.toString(), 11));
});
toggleMenus();
}
});
Table wavesMain, editorMain;
cont.stack(wavesMain = new Table(), editorMain = new Table()).height(wavesMain.getPrefHeight())
.name("waves/editor");
wavesMain.visible(() -> shown && !state.isEditor());
wavesMain.top().left().name = "waves";
wavesMain.table(s -> {
//wave info button with text
s.add(makeStatusTable()).grow().name("status");
//table with button to skip wave
s.button(Icon.play, Styles.righti, 30f, () -> {
if(net.client() && player.admin){
Call.adminRequest(player, AdminAction.wave);
}else{
logic.skipWave();
}
}).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()).name("skip");
}).width(dsize * 5 + 4f);
wavesMain.row();
wavesMain.table(Tex.button, t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.white))
.grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).name("boss");
wavesMain.row();
editorMain.name = "editor";
editorMain.table(Tex.buttonEdge4, t -> {
//t.margin(0f);
t.name = "teams";
t.add("@editor.teams").growX().left();
t.row();
t.table(teams -> {
teams.left();
int i = 0;
for(Team team : Team.baseTeams){
ImageButton button = teams.button(Tex.whiteui, Styles.clearTogglePartiali, 40f, () -> Call.setPlayerTeamEditor(player, team))
.size(50f).margin(6f).get();
button.getImageCell().grow();
button.getStyle().imageUpColor = team.color;
button.update(() -> button.setChecked(player.team() == team));
if(++i % 3 == 0){
teams.row();
}
}
}).left();
}).width(dsize * 5 + 4f);
editorMain.visible(() -> shown && state.isEditor());
//fps display
cont.table(info -> {
info.name = "fps/ping";
info.touchable = Touchable.disabled;
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps") && shown);
IntFormat fps = new IntFormat("fps");
IntFormat ping = new IntFormat("ping");
IntFormat mem = new IntFormat("memory");
IntFormat memnative = new IntFormat("memory2");
info.label(() -> fps.get(Core.graphics.getFramesPerSecond())).left().style(Styles.outlineLabel).name("fps");
info.row();
if(android){
info.label(() -> memnative.get((int)(Core.app.getJavaHeap() / 1024 / 1024), (int)(Core.app.getNativeHeap() / 1024 / 1024))).left().style(Styles.outlineLabel).name("memory2");
info.row();
}else{
info.label(() -> mem.get((int)(Core.app.getJavaHeap() / 1024 / 1024))).left().style(Styles.outlineLabel).name("memory");
info.row();
}
info.label(() -> ping.get(netClient.getPing())).visible(net::client).left().style(Styles.outlineLabel).name("ping");
}).top().left();
});
//core items
parent.fill(t -> {
t.name = "coreitems";
t.top().add(coreItems);
t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused() && shown);
});
//spawner warning
parent.fill(t -> {
t.name = "nearpoint";
t.touchable = Touchable.disabled;
t.table(Styles.black, c -> c.add("@nearpoint")
.update(l -> l.setColor(Tmp.c1.set(Color.white).lerp(Color.scarlet, Mathf.absin(Time.time(), 10f, 1f))))
.get().setAlignment(Align.center, Align.center))
.margin(6).update(u -> u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(spawner.playerNear()), 0.1f)).get().color.a = 0f;
});
parent.fill(t -> {
t.name = "waiting";
t.visible(() -> netServer.isWaitingForPlayers());
t.table(Tex.button, c -> c.add("@waiting.players"));
});
//'core is under attack' table
parent.fill(t -> {
t.name = "coreattack";
t.touchable = Touchable.disabled;
float notifDuration = 240f;
float[] coreAttackTime = {0};
float[] coreAttackOpacity = {0};
Events.run(Trigger.teamCoreDamage, () -> {
coreAttackTime[0] = notifDuration;
});
t.top().visible(() -> {
if(!shown) return false;
if(state.isMenu() || !state.teams.get(player.team()).hasCore()){
coreAttackTime[0] = 0f;
return false;
}
t.color.a = coreAttackOpacity[0];
if(coreAttackTime[0] > 0){
coreAttackOpacity[0] = Mathf.lerpDelta(coreAttackOpacity[0], 1f, 0.1f);
}else{
coreAttackOpacity[0] = Mathf.lerpDelta(coreAttackOpacity[0], 0f, 0.1f);
}
coreAttackTime[0] -= Time.delta;
return coreAttackOpacity[0] > 0;
});
t.table(Tex.button, top -> top.add("@coreattack").pad(2)
.update(label -> label.color.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time(), 2f, 1f)))).touchable(Touchable.disabled);
});
//TODO tutorial text
parent.fill(t -> {
t.name = "tutorial";
Runnable resize = () -> {
t.clearChildren();
t.top().right().visible(() -> false);
t.stack(new Button(){{
marginLeft(48f);
labelWrap(() -> control.tutorial.stage.text() + (control.tutorial.canNext() ? "\n\n" + Core.bundle.get("tutorial.next") : "")).width(!Core.graphics.isPortrait() ? 400f : 160f).pad(2f);
clicked(() -> control.tutorial.nextSentence());
setDisabled(() -> !control.tutorial.canNext());
}},
new Table(f -> {
f.left().button(Icon.left, Styles.emptyi, () -> {
control.tutorial.prevSentence();
}).width(44f).growY().visible(() -> control.tutorial.canPrev());
}));
};
resize.run();
Events.on(ResizeEvent.class, e -> resize.run());
});
//'saving' indicator
parent.fill(t -> {
t.name = "saving";
t.bottom().visible(() -> control.saves.isSaving());
t.add("@saving").style(Styles.outlineLabel);
});
parent.fill(p -> {
p.name = "hudtext";
p.top().table(Styles.black3, t -> t.margin(4).label(() -> hudText)
.style(Styles.outlineLabel)).padTop(10).visible(p.color.a >= 0.001f);
p.update(() -> {
p.color.a = Mathf.lerpDelta(p.color.a, Mathf.num(showHudText), 0.2f);
if(state.isMenu()){
p.color.a = 0f;
showHudText = false;
}
});
p.touchable = Touchable.disabled;
});
//TODO DEBUG: rate table
if(false)
parent.fill(t -> {
t.name = "rates";
t.bottom().left();
t.table(Styles.black6, c -> {
Bits used = new Bits(content.items().size);
Runnable rebuild = () -> {
c.clearChildren();
for(Item item : content.items()){
if(state.rules.sector != null && state.rules.sector.info.getExport(item) >= 1){
c.image(item.icon(Cicon.small));
c.label(() -> (int)state.rules.sector.info.getExport(item) + " /s").color(Color.lightGray);
c.row();
}
}
};
c.update(() -> {
boolean wrong = false;
for(Item item : content.items()){
boolean has = state.rules.sector != null && state.rules.sector.info.getExport(item) >= 1;
if(used.get(item.id) != has){
used.set(item.id, has);
wrong = true;
}
}
if(wrong){
rebuild.run();
}
});
}).visible(() -> state.isCampaign() && content.items().contains(i -> state.rules.sector != null && state.rules.sector.info.getExport(i) > 0));
});
blockfrag.build(parent);
}
@Remote(targets = Loc.both, forward = true, called = Loc.both)
public static void setPlayerTeamEditor(Player player, Team team){
if(state.isEditor() && player != null){
player.team(team);
}
}
public void setHudText(String text){
showHudText = true;
hudText = text;
}
public void toggleHudText(boolean shown){
showHudText = shown;
}
private void scheduleToast(Runnable run){
long duration = (int)(3.5 * 1000);
long since = Time.timeSinceMillis(lastToast);
if(since > duration){
lastToast = Time.millis();
run.run();
}else{
Time.runTask((duration - since) / 1000f * 60f, run);
lastToast += duration;
}
}
public void showToast(String text){
showToast(Icon.ok, text);
}
public void showToast(Drawable icon, String text){
if(state.isMenu()) return;
scheduleToast(() -> {
Sounds.message.play();
Table table = new Table(Tex.button);
table.update(() -> {
if(state.isMenu() || !ui.hudfrag.shown){
table.remove();
}
});
table.margin(12);
table.image(icon).pad(3);
table.add(text).wrap().width(280f).get().setAlignment(Align.center, Align.center);
table.pack();
//create container table which will align and move
Table container = Core.scene.table();
container.top().add(table);
container.setTranslation(0, table.getPrefHeight());
container.actions(Actions.translateBy(0, -table.getPrefHeight(), 1f, Interp.fade), Actions.delay(2.5f),
//nesting actions() calls is necessary so the right prefHeight() is used
Actions.run(() -> container.actions(Actions.translateBy(0, table.getPrefHeight(), 1f, Interp.fade), Actions.remove())));
});
}
/** Show unlock notification for a new recipe. */
public void showUnlock(UnlockableContent content){
//some content may not have icons... yet
//also don't play in the tutorial to prevent confusion
if(state.isMenu()) return;
Sounds.message.play();
//if there's currently no unlock notification...
if(lastUnlockTable == null){
scheduleToast(() -> {
Table table = new Table(Tex.button);
table.update(() -> {
if(state.isMenu()){
table.remove();
lastUnlockLayout = null;
lastUnlockTable = null;
}
});
table.margin(12);
Table in = new Table();
//create texture stack for displaying
Image image = new Image(content.icon(Cicon.xlarge));
image.setScaling(Scaling.fit);
in.add(image).size(8 * 6).pad(2);
//add to table
table.add(in).padRight(8);
table.add("@unlocked");
table.pack();
//create container table which will align and move
Table container = Core.scene.table();
container.top().add(table);
container.setTranslation(0, table.getPrefHeight());
container.actions(Actions.translateBy(0, -table.getPrefHeight(), 1f, Interp.fade), Actions.delay(2.5f),
//nesting actions() calls is necessary so the right prefHeight() is used
Actions.run(() -> container.actions(Actions.translateBy(0, table.getPrefHeight(), 1f, Interp.fade), Actions.run(() -> {
lastUnlockTable = null;
lastUnlockLayout = null;
}), Actions.remove())));
lastUnlockTable = container;
lastUnlockLayout = in;
});
}else{
//max column size
int col = 3;
//max amount of elements minus extra 'plus'
int cap = col * col - 1;
//get old elements
Seq<Element> elements = new Seq<>(lastUnlockLayout.getChildren());
int esize = elements.size;
//...if it's already reached the cap, ignore everything
if(esize > cap) return;
//get size of each element
float size = 48f / Math.min(elements.size + 1, col);
lastUnlockLayout.clearChildren();
lastUnlockLayout.defaults().size(size).pad(2);
for(int i = 0; i < esize; i++){
lastUnlockLayout.add(elements.get(i));
if(i % col == col - 1){
lastUnlockLayout.row();
}
}
//if there's space, add it
if(esize < cap){
Image image = new Image(content.icon(Cicon.medium));
image.setScaling(Scaling.fit);
lastUnlockLayout.add(image);
}else{ //else, add a specific icon to denote no more space
lastUnlockLayout.image(Icon.add);
}
lastUnlockLayout.pack();
}
}
public void showLaunchDirect(){
Image image = new Image();
image.color.a = 0f;
image.setFillParent(true);
image.actions(Actions.fadeIn(launchDuration / 60f, Interp.pow2In), Actions.delay(8f / 60f), Actions.remove());
Core.scene.add(image);
}
public void showLaunch(){
Image image = new Image();
image.color.a = 0f;
image.setFillParent(true);
image.actions(Actions.fadeIn(40f / 60f));
image.update(() -> {
if(state.isMenu()){
image.remove();
}
});
Core.scene.add(image);
}
public void showLand(){
Image image = new Image();
image.color.a = 1f;
image.touchable = Touchable.disabled;
image.setFillParent(true);
image.actions(Actions.fadeOut(0.8f), Actions.remove());
image.update(() -> {
image.toFront();
if(state.isMenu()){
image.remove();
}
});
Core.scene.add(image);
}
private void toggleMenus(){
if(flip != null){
flip.getStyle().imageUp = shown ? Icon.downOpen : Icon.upOpen;
}
shown = !shown;
}
private Table makeStatusTable(){
Table table = new Table(Tex.wavepane);
StringBuilder ibuild = new StringBuilder();
IntFormat wavef = new IntFormat("wave");
IntFormat wavefc = new IntFormat("wave.cap");
IntFormat enemyf = new IntFormat("wave.enemy");
IntFormat enemiesf = new IntFormat("wave.enemies");
IntFormat enemycf = new IntFormat("wave.enemycore");
IntFormat enemycsf = new IntFormat("wave.enemycores");
IntFormat waitingf = new IntFormat("wave.waiting", i -> {
ibuild.setLength(0);
int m = i/60;
int s = i % 60;
if(m > 0){
ibuild.append(m);
ibuild.append(":");
if(s < 10){
ibuild.append("0");
}
}
ibuild.append(s);
return ibuild.toString();
});
table.touchable = Touchable.enabled;
StringBuilder builder = new StringBuilder();
table.name = "waves";
table.marginTop(0).marginBottom(4).marginLeft(4);
class SideBar extends Element{
public final Floatp amount;
public final boolean flip;
public final Boolp flash;
float last, blink, value;
public SideBar(Floatp amount, Boolp flash, boolean flip){
this.amount = amount;
this.flip = flip;
this.flash = flash;
setColor(Pal.health);
}
@Override
public void draw(){
float next = amount.get();
if(Float.isNaN(next) || Float.isInfinite(next)) next = 1f;
if(next < last && flash.get()){
blink = 1f;
}
blink = Mathf.lerpDelta(blink, 0f, 0.2f);
value = Mathf.lerpDelta(value, next, 0.15f);
last = next;
if(Float.isNaN(value) || Float.isInfinite(value)) value = 1f;
drawInner(Pal.darkishGray);
Draw.beginStencil();
Fill.crect(x, y, width, height * value);
Draw.beginStenciled();
drawInner(Tmp.c1.set(color).lerp(Color.white, blink));
Draw.endStencil();
}
void drawInner(Color color){
if(flip){
x += width;
width = -width;
}
float stroke = width * 0.35f;
float bh = height/2f;
Draw.color(color);
Fill.quad(
x, y,
x + stroke, y,
x + width, y + bh,
x + width - stroke, y + bh
);
Fill.quad(
x + width, y + bh,
x + width - stroke, y + bh,
x, y + height,
x + stroke, y + height
);
Draw.reset();
if(flip){
width = -width;
x -= width;
}
}
}
table.stack(
new Element(){
@Override
public void draw(){
Draw.color(Pal.darkerGray);
Fill.poly(x + width/2f, y + height/2f, 6, height / Mathf.sqrt3);
Draw.reset();
Drawf.shadow(x + width/2f, y + height/2f, height * 1.13f);
}
},
new Table(t -> {
float bw = 40f;
float pad = -20;
t.margin(0);
t.add(new SideBar(() -> player.unit().healthf(), () -> true, true)).width(bw).growY().padRight(pad);
t.image(() -> player.icon()).scaling(Scaling.bounded).grow().maxWidth(54f).with(i -> {
if(mobile){
//on mobile, cause a respawn on tap
i.clicked(() -> {
if(!player.unit().spawnedByCore && !player.dead()){
Call.unitClear(player);
control.input.controlledType = null;
}
});
}
});
t.add(new SideBar(() -> player.dead() ? 0f : player.displayAmmo() ? player.unit().ammof() : player.unit().healthf(), () -> !player.displayAmmo(), false)).width(bw).growY().padLeft(pad).update(b -> {
b.color.set(player.displayAmmo() ? player.dead() || player.unit() instanceof BlockUnitc ? Pal.ammo : player.unit().type.ammoType.color : Pal.health);
});
t.getChildren().get(1).toFront();
})).size(120f, 80).padRight(4);
table.labelWrap(() -> {
builder.setLength(0);
if(!state.rules.waves && state.rules.attackMode){
int sum = Math.max(state.teams.present.sum(t -> t.team != player.team() ? t.cores.size : 0), 1);
builder.append(sum > 1 ? enemycsf.get(sum) : enemycf.get(sum));
return builder;
}
if(!state.rules.waves && state.isCampaign()){
builder.append("[lightgray]").append(Core.bundle.get("sector.curcapture"));
}
if(!state.rules.waves){
return builder;
}
if(state.rules.winWave > 1 && state.rules.winWave >= state.wave && state.isCampaign()){
builder.append(wavefc.get(state.wave, state.rules.winWave));
}else{
builder.append(wavef.get(state.wave));
}
builder.append("\n");
if(state.enemies > 0){
if(state.enemies == 1){
builder.append(enemyf.get(state.enemies));
}else{
builder.append(enemiesf.get(state.enemies));
}
builder.append("\n");
}
if(state.rules.waveTimer){
builder.append((logic.isWaitingWave() ? Core.bundle.get("wave.waveInProgress") : (waitingf.get((int)(state.wavetime/60)))));
}else if(state.enemies == 0){
builder.append(Core.bundle.get("waiting"));
}
return builder;
}).growX().pad(8f);
table.touchable(() -> state.rules.waves ? Touchable.enabled : Touchable.disabled);
return table;
}
private boolean canSkipWave(){
return state.rules.waves && ((net.server() || player.admin) || !net.active()) && state.enemies == 0 && !spawner.isSpawning();
}
}