Partial 7.0 merge - API preview

This commit is contained in:
Anuken
2021-06-02 11:08:08 -04:00
parent ea75a357ca
commit 28b235ef07
531 changed files with 12356 additions and 6286 deletions

View File

@@ -17,6 +17,7 @@ import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.core.*;
import mindustry.ctype.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
@@ -30,7 +31,7 @@ import mindustry.ui.*;
import static mindustry.Vars.*;
public class HudFragment extends Fragment{
private static final float dsize = 65f;
private static final float dsize = 65f, pauseHeight = 36f;
public final PlacementFragment blockfrag = new PlacementFragment();
public boolean shown = true;
@@ -60,7 +61,7 @@ public class HudFragment extends Fragment{
//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));
showToast(Icon.warning, group.type.emoji() + " " + Core.bundle.format("wave.guardianwarn" + (diff == 1 ? ".one" : ""), diff));
}
break outer;
@@ -90,7 +91,9 @@ public class HudFragment extends Fragment{
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();
t.table(Styles.black6, top -> top.label(() -> netServer.isWaitingForPlayers() ? "@waiting.players" : state.gameOver && state.isCampaign() ? "@sector.curlost" : "@paused")
.style(Styles.outlineLabel).pad(8f)).height(pauseHeight).growX();
//.padLeft(dsize * 5 + 4f) to prevent alpha overlap on left
});
//minimap + position
@@ -208,10 +211,7 @@ public class HudFragment extends Fragment{
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();
addInfoTable(wavesMain.table().width(dsize * 5f + 4f).left().get());
editorMain.name = "editor";
editorMain.table(Tex.buttonEdge4, t -> {
@@ -244,6 +244,7 @@ public class HudFragment extends Fragment{
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps") && shown);
IntFormat fps = new IntFormat("fps");
IntFormat ping = new IntFormat("ping");
IntFormat tps = new IntFormat("tps");
IntFormat mem = new IntFormat("memory");
IntFormat memnative = new IntFormat("memory2");
@@ -257,68 +258,83 @@ public class HudFragment extends Fragment{
}
info.row();
info.label(() -> ping.get(netClient.getPing())).visible(net::client).left().style(Styles.outlineLabel).name("ping");
info.label(() -> ping.get(netClient.getPing())).visible(net::client).left().style(Styles.outlineLabel).name("ping").row();
info.label(() -> tps.get(state.serverTps == -1 ? 60 : state.serverTps)).visible(net::client).left().style(Styles.outlineLabel).name("tps").row();
}).top().left();
});
//core items
//core info
parent.fill(t -> {
t.name = "coreitems";
t.top().add(coreItems);
t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused() && shown);
t.top();
t.name = "coreinfo";
t.collapser(v -> v.add().height(pauseHeight), () -> state.isPaused()).row();
t.table(c -> {
//core items
c.top().collapser(coreItems, () -> Core.settings.getBool("coreitems") && !mobile && shown).fillX().row();
float notifDuration = 240f;
float[] coreAttackTime = {0};
Events.run(Trigger.teamCoreDamage, () -> coreAttackTime[0] = notifDuration);
//'core is under attack' table
c.collapser(top -> top.background(Styles.black6).add("@coreattack").pad(8)
.update(label -> label.color.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f))), true,
() -> {
if(!shown || state.isPaused()) return false;
if(state.isMenu() || !state.teams.get(player.team()).hasCore()){
coreAttackTime[0] = 0f;
return false;
}
return (coreAttackTime[0] -= Time.delta) > 0;
})
.touchable(Touchable.disabled)
.fillX().row();
}).row();
var bossb = new StringBuilder();
var bossText = Core.bundle.get("guardian");
int maxBosses = 6;
t.table(v -> v.margin(10f)
.add(new Bar(() -> {
bossb.setLength(0);
for(int i = 0; i < Math.min(state.teams.bosses.size, maxBosses); i++){
bossb.append(state.teams.bosses.get(i).type.emoji());
}
if(state.teams.bosses.size > maxBosses){
bossb.append("[accent]+[]");
}
bossb.append(" ");
bossb.append(bossText);
return bossb;
}, () -> Pal.health, () -> {
if(state.boss() == null) return 0f;
float max = 0f, val = 0f;
for(var boss : state.teams.bosses){
max += boss.maxHealth;
val += boss.health;
}
return max == 0f ? 0f : val / max;
}).blink(Color.white).outline(new Color(0, 0, 0, 0.6f), 7f)).grow())
.fillX().width(320f).height(60f).name("boss").visible(() -> state.rules.waves && state.boss() != null).padTop(7);
});
//spawner warning
parent.fill(t -> {
t.name = "nearpoint";
t.touchable = Touchable.disabled;
t.table(Styles.black, c -> c.add("@nearpoint")
t.table(Styles.black6, 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))
.labelAlign(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);
});
//'saving' indicator
parent.fill(t -> {
t.name = "saving";
@@ -343,7 +359,6 @@ public class HudFragment extends Fragment{
//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);
@@ -353,7 +368,7 @@ public class HudFragment extends Fragment{
for(Item item : content.items()){
if(state.rules.sector != null && state.rules.sector.info.getExport(item) >= 1){
c.image(item.icon(Cicon.small));
c.image(item.uiIcon);
c.label(() -> (int)state.rules.sector.info.getExport(item) + " /s").color(Color.lightGray);
c.row();
}
@@ -412,6 +427,10 @@ public class HudFragment extends Fragment{
}
public void showToast(Drawable icon, String text){
showToast(icon, -1, text);
}
public void showToast(Drawable icon, float size, String text){
if(state.isMenu()) return;
scheduleToast(() -> {
@@ -424,7 +443,8 @@ public class HudFragment extends Fragment{
}
});
table.margin(12);
table.image(icon).pad(3);
var cell = table.image(icon).pad(3);
if(size > 0) cell.size(size);
table.add(text).wrap().width(280f).get().setAlignment(Align.center, Align.center);
table.pack();
@@ -462,7 +482,7 @@ public class HudFragment extends Fragment{
Table in = new Table();
//create texture stack for displaying
Image image = new Image(content.icon(Cicon.xlarge));
Image image = new Image(content.uiIcon);
image.setScaling(Scaling.fit);
in.add(image).size(8 * 6).pad(2);
@@ -516,7 +536,7 @@ public class HudFragment extends Fragment{
//if there's space, add it
if(esize < cap){
Image image = new Image(content.icon(Cicon.medium));
Image image = new Image(content.uiIcon);
image.setScaling(Scaling.fit);
lastUnlockLayout.add(image);
@@ -758,6 +778,12 @@ public class HudFragment extends Fragment{
table.row();
return table;
}
private void addInfoTable(Table table){
table.left();
var count = new float[]{-1};
table.table().update(t -> {
if(player.unit() instanceof Payloadc payload){
@@ -770,8 +796,29 @@ public class HudFragment extends Fragment{
t.clear();
}
}).growX().visible(() -> player.unit() instanceof Payloadc p && p.payloadUsed() > 0).colspan(2);
table.row();
return table;
Bits statuses = new Bits();
table.table().update(t -> {
t.left();
Bits applied = player.unit().statusBits();
if(!statuses.equals(applied)){
t.clear();
if(applied != null){
for(StatusEffect effect : content.statusEffects()){
if(applied.get(effect.id) && !effect.isHidden()){
t.image(effect.uiIcon).size(iconMed).get()
.addListener(new Tooltip(l -> l.label(() ->
effect.localizedName + " [lightgray]" + UI.formatTime(player.unit().getDuration(effect))).style(Styles.outlineLabel)));
}
}
statuses.set(applied);
}
}
}).left();
}
private boolean canSkipWave(){