Partial 7.0 merge - API preview
This commit is contained in:
@@ -17,7 +17,6 @@ import arc.util.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -147,7 +146,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
HandCursorListener l = new HandCursorListener();
|
||||
l.enabled = canPick;
|
||||
|
||||
Element image = itemImage(item.icon(Cicon.xlarge), () -> {
|
||||
Element image = itemImage(item.uiIcon, () -> {
|
||||
if(tile == null || !tile.isValid()){
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ public class HintsFragment extends Fragment{
|
||||
schematicSelect(visibleDesktop, () -> ui.hints.placedBlocks.contains(Blocks.router), () -> Core.input.keyRelease(Binding.schematic_select) || Core.input.keyTap(Binding.pick)),
|
||||
conveyorPathfind(() -> control.input.block == Blocks.titaniumConveyor, () -> Core.input.keyRelease(Binding.diagonal_placement) || (mobile && Core.settings.getBool("swapdiagonal"))),
|
||||
boost(visibleDesktop, () -> !player.dead() && player.unit().type.canBoost, () -> Core.input.keyDown(Binding.boost)),
|
||||
blockInfo(() -> true, () -> ui.content.isShown()),
|
||||
command(() -> state.rules.defaultTeam.data().units.size > 3 && !net.active(), () -> player.unit().isCommanding()),
|
||||
payloadPickup(() -> !player.unit().dead && player.unit() instanceof Payloadc p && p.payloads().isEmpty(), () -> player.unit() instanceof Payloadc p && p.payloads().any()),
|
||||
payloadDrop(() -> !player.unit().dead && player.unit() instanceof Payloadc p && p.payloads().any(), () -> player.unit() instanceof Payloadc p && p.payloads().isEmpty()),
|
||||
|
||||
@@ -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(){
|
||||
|
||||
@@ -98,7 +98,7 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
if(Core.input.keyTap(Binding.pick) && player.isBuilder()){ //mouse eyedropper select
|
||||
var build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
Block tryRecipe = build == null ? null : build instanceof ConstructBuild c ? c.cblock : build.block;
|
||||
Block tryRecipe = build == null ? null : build instanceof ConstructBuild c ? c.current : build.block;
|
||||
Object tryConfig = build == null || !build.block.copyConfig ? null : build.config();
|
||||
|
||||
for(BuildPlan req : player.unit().plans()){
|
||||
@@ -224,7 +224,7 @@ public class PlacementFragment extends Fragment{
|
||||
blockTable.row();
|
||||
}
|
||||
|
||||
ImageButton button = blockTable.button(new TextureRegionDrawable(block.icon(Cicon.medium)), Styles.selecti, () -> {
|
||||
ImageButton button = blockTable.button(new TextureRegionDrawable(block.uiIcon), Styles.selecti, () -> {
|
||||
if(unlocked(block)){
|
||||
if(Core.input.keyDown(KeyCode.shiftLeft) && Fonts.getUnicode(block.name) != 0){
|
||||
Core.app.setClipboardText((char)Fonts.getUnicode(block.name) + "");
|
||||
@@ -235,7 +235,7 @@ public class PlacementFragment extends Fragment{
|
||||
}
|
||||
}
|
||||
}).size(46f).group(group).name("block-" + block.name).get();
|
||||
button.resizeImage(Cicon.medium.size);
|
||||
button.resizeImage(iconMed);
|
||||
|
||||
button.update(() -> { //color unplacable things gray
|
||||
Building core = player.core();
|
||||
@@ -309,7 +309,7 @@ public class PlacementFragment extends Fragment{
|
||||
}
|
||||
final String keyComboFinal = keyCombo;
|
||||
header.left();
|
||||
header.add(new Image(displayBlock.icon(Cicon.medium))).size(8 * 4);
|
||||
header.add(new Image(displayBlock.uiIcon)).size(8 * 4);
|
||||
header.labelWrap(() -> !unlocked(displayBlock) ? Core.bundle.get("block.unknown") : displayBlock.localizedName + keyComboFinal)
|
||||
.left().width(190f).padLeft(5);
|
||||
header.add().growX();
|
||||
@@ -328,7 +328,7 @@ public class PlacementFragment extends Fragment{
|
||||
for(ItemStack stack : displayBlock.requirements){
|
||||
req.table(line -> {
|
||||
line.left();
|
||||
line.image(stack.item.icon(Cicon.small)).size(8 * 2);
|
||||
line.image(stack.item.uiIcon).size(8 * 2);
|
||||
line.add(stack.item.localizedName).maxWidth(140f).fillX().color(Color.lightGray).padLeft(2).left().get().setEllipsis(true);
|
||||
line.labelWrap(() -> {
|
||||
Building core = player.core();
|
||||
@@ -349,7 +349,7 @@ public class PlacementFragment extends Fragment{
|
||||
topTable.row();
|
||||
topTable.table(b -> {
|
||||
b.image(Icon.cancel).padRight(2).color(Color.scarlet);
|
||||
b.add(!player.isBuilder() ? "@unit.nobuild" : "@banned").width(190f).wrap();
|
||||
b.add(!player.isBuilder() ? "@unit.nobuild" : !displayBlock.supportsEnv(state.rules.environment) ? "@unsupported.environment" : "@banned").width(190f).wrap();
|
||||
b.left();
|
||||
}).padTop(2).left();
|
||||
}
|
||||
@@ -471,7 +471,7 @@ public class PlacementFragment extends Fragment{
|
||||
}
|
||||
|
||||
//if the tile has a drop, display the drop
|
||||
if(hoverTile.drop() != null){
|
||||
if(hoverTile.drop() != null || hoverTile.wallDrop() != null){
|
||||
return hoverTile;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user