Merge branch 'master' into schematic

This commit is contained in:
J-VdS
2020-08-19 16:14:48 +02:00
420 changed files with 16090 additions and 10744 deletions

View File

@@ -27,7 +27,7 @@ public class ChatFragment extends Table{
private boolean shown = false;
private TextField chatfield;
private Label fieldlabel = new Label(">");
private BitmapFont font;
private Font font;
private GlyphLayout layout = new GlyphLayout();
private float offsetx = Scl.scl(4), offsety = Scl.scl(4), fontoffsetx = Scl.scl(2), chatspace = Scl.scl(50);
private Color shadowColor = new Color(0, 0, 0, 0.4f);
@@ -124,7 +124,7 @@ public class ChatFragment extends Table{
Draw.color(shadowColor);
if(shown){
Fill.crect(offsetx, chatfield.getY(), chatfield.getWidth() + 15f, chatfield.getHeight() - 1);
Fill.crect(offsetx, chatfield.y, chatfield.getWidth() + 15f, chatfield.getHeight() - 1);
}
super.draw();
@@ -171,7 +171,7 @@ public class ChatFragment extends Table{
String message = chatfield.getText();
clearChatInput();
if(message.replaceAll(" ", "").isEmpty()) return;
if(message.replace(" ", "").isEmpty()) return;
history.insert(1, message);

View File

@@ -61,6 +61,7 @@ public class HudFragment extends Fragment{
//TODO full implementation
Events.on(ResetEvent.class, e -> {
coreItems.resetUsed();
coreItems.clear();
});
Events.on(TurnEvent.class, e -> {
@@ -70,7 +71,7 @@ public class HudFragment extends Fragment{
//paused table
parent.fill(t -> {
t.top().visible(() -> state.isPaused() && !state.isOutOfTime()).touchable = Touchable.disabled;
t.table(Styles.black5, top -> top.add("$paused").style(Styles.outlineLabel).pad(8f)).growX();
t.table(Styles.black5, top -> top.add("@paused").style(Styles.outlineLabel).pad(8f)).growX();
});
//TODO tear this all down
@@ -166,7 +167,7 @@ public class HudFragment extends Fragment{
{
editorMain.table(Tex.buttonEdge4, t -> {
//t.margin(0f);
t.add("$editor.teams").growX().left();
t.add("@editor.teams").growX().left();
t.row();
t.table(teams -> {
teams.left();
@@ -216,13 +217,13 @@ public class HudFragment extends Fragment{
//core items
parent.fill(t -> {
t.top().add(coreItems);
t.visible(() -> Core.settings.getBool("coreitems") && !mobile);
t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused());
});
//spawner warning
parent.fill(t -> {
t.touchable = Touchable.disabled;
t.table(Styles.black, c -> c.add("$nearpoint")
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;
@@ -230,7 +231,7 @@ public class HudFragment extends Fragment{
parent.fill(t -> {
t.visible(() -> netServer.isWaitingForPlayers());
t.table(Tex.button, c -> c.add("$waiting.players"));
t.table(Tex.button, c -> c.add("@waiting.players"));
});
//'core is under attack' table
@@ -240,7 +241,7 @@ public class HudFragment extends Fragment{
float[] coreAttackTime = {0};
float[] coreAttackOpacity = {0};
Events.on(Trigger.teamCoreDamage, () -> {
Events.run(Trigger.teamCoreDamage, () -> {
coreAttackTime[0] = notifDuration;
});
@@ -261,7 +262,7 @@ public class HudFragment extends Fragment{
return coreAttackOpacity[0] > 0;
});
t.table(Tex.button, top -> top.add("$coreattack").pad(2)
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);
});
@@ -311,7 +312,7 @@ public class HudFragment extends Fragment{
//'saving' indicator
parent.fill(t -> {
t.bottom().visible(() -> control.saves.isSaving());
t.add("$saving").style(Styles.outlineLabel);
t.add("@saving").style(Styles.outlineLabel);
});
parent.fill(p -> {
@@ -458,7 +459,7 @@ public class HudFragment extends Fragment{
//add to table
table.add(in).padRight(8);
table.add("$unlocked");
table.add("@unlocked");
table.pack();
//create container table which will align and move
@@ -554,17 +555,17 @@ public class HudFragment extends Fragment{
}
private void showLaunchConfirm(){
BaseDialog dialog = new BaseDialog("$launch");
BaseDialog dialog = new BaseDialog("@launch");
dialog.update(() -> {
if(!inLaunchWave()){
dialog.hide();
}
});
dialog.cont.add("$launch.confirm").width(500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
dialog.cont.add("@launch.confirm").width(500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
dialog.buttons.defaults().size(200f, 54f).pad(2f);
dialog.setFillParent(false);
dialog.buttons.button("$cancel", dialog::hide);
dialog.buttons.button("$ok", () -> {
dialog.buttons.button("@cancel", dialog::hide);
dialog.buttons.button("@ok", () -> {
dialog.hide();
Call.launchZone();
});
@@ -679,7 +680,7 @@ public class HudFragment extends Fragment{
if(net.client() && player.admin){
Call.adminRequest(player, AdminAction.wave);
}else if(inLaunchWave()){
ui.showConfirm("$confirm", "$launch.skip.confirm", () -> !canSkipWave(), () -> logic.skipWave());
ui.showConfirm("@confirm", "@launch.skip.confirm", () -> !canSkipWave(), () -> logic.skipWave());
}else{
logic.skipWave();
}

View File

@@ -14,6 +14,7 @@ public class LoadingFragment extends Fragment{
private Table table;
private TextButton button;
private Bar bar;
private Label nameLabel;
@Override
public void build(Group parent){
@@ -23,14 +24,16 @@ public class LoadingFragment extends Fragment{
t.add().height(133f).row();
t.add(new WarningBar()).growX().height(24f);
t.row();
t.add("$loading").name("namelabel").pad(10f).style(Styles.techLabel);
nameLabel = t.add("@loading").pad(10f).style(Styles.techLabel).get();
t.row();
t.add(new WarningBar()).growX().height(24f);
t.row();
text("@loading");
bar = t.add(new Bar()).pad(3).size(500f, 40f).visible(false).get();
t.row();
button = t.button("$cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get();
button = t.button("@cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get();
table = t;
});
}
@@ -48,20 +51,20 @@ public class LoadingFragment extends Fragment{
}
public void setText(String text){
table.<Label>find("namelabel").setText(text);
table.<Label>find("namelabel").setColor(Pal.accent);
text(text);
nameLabel.setColor(Pal.accent);
}
public void show(){
show("$loading");
show("@loading");
}
public void show(String text){
table.<Label>find("namelabel").setColor(Color.white);
nameLabel.setColor(Color.white);
bar.visible = false;
table.clearActions();
table.touchable = Touchable.enabled;
table.<Label>find("namelabel").setText(text);
text(text);
table.visible = true;
table.color.a = 1f;
table.toFront();
@@ -73,4 +76,20 @@ public class LoadingFragment extends Fragment{
table.touchable = Touchable.disabled;
table.actions(Actions.fadeOut(0.5f), Actions.visible(false));
}
private void text(String text){
nameLabel.setText(text);
CharSequence realText = nameLabel.getText();
//fallback to the default font if characters are missing
//TODO this should happen everywhere
for(int i = 0; i < realText.length(); i++){
if(Fonts.tech.getData().getGlyph(realText.charAt(i)) == null){
nameLabel.setStyle(Styles.defaultLabel);
return;
}
}
nameLabel.setStyle(Styles.techLabel);
}
}

View File

@@ -60,12 +60,12 @@ public class MenuFragment extends Fragment{
parent.fill(c -> c.bottom().left().button("", Styles.infot, ui.about::show).size(84, 45));
parent.fill(c -> c.bottom().right().button("", Styles.discordt, ui.discord::show).size(84, 45));
}else if(becontrol.active()){
parent.fill(c -> c.bottom().right().button("$be.check", Icon.refresh, () -> {
parent.fill(c -> c.bottom().right().button("@be.check", Icon.refresh, () -> {
ui.loadfrag.show();
becontrol.checkUpdate(result -> {
ui.loadfrag.hide();
if(!result){
ui.showInfo("$be.noupdates");
ui.showInfo("@be.noupdates");
}
});
}).size(200, 60).update(t -> {
@@ -100,15 +100,15 @@ public class MenuFragment extends Fragment{
container.defaults().size(size).pad(5).padTop(4f);
MobileButton
play = new MobileButton(Icon.play, "$campaign", () -> checkPlay(ui.planet::show)),
custom = new MobileButton(Icon.rightOpenOut, "$customgame", () -> checkPlay(ui.custom::show)),
maps = new MobileButton(Icon.download, "$loadgame", () -> checkPlay(ui.load::show)),
join = new MobileButton(Icon.add, "$joingame", () -> checkPlay(ui.join::show)),
editor = new MobileButton(Icon.terrain, "$editor", () -> checkPlay(ui.maps::show)),
tools = new MobileButton(Icon.settings, "$settings", ui.settings::show),
mods = new MobileButton(Icon.book, "$mods", ui.mods::show),
donate = new MobileButton(Icon.link, "$website", () -> Core.app.openURI("https://anuke.itch.io/mindustry")),
exit = new MobileButton(Icon.exit, "$quit", () -> Core.app.exit());
play = new MobileButton(Icon.play, "@campaign", () -> checkPlay(ui.planet::show)),
custom = new MobileButton(Icon.rightOpenOut, "@customgame", () -> checkPlay(ui.custom::show)),
maps = new MobileButton(Icon.download, "@loadgame", () -> checkPlay(ui.load::show)),
join = new MobileButton(Icon.add, "@joingame", () -> checkPlay(ui.join::show)),
editor = new MobileButton(Icon.terrain, "@editor", () -> checkPlay(ui.maps::show)),
tools = new MobileButton(Icon.settings, "@settings", ui.settings::show),
mods = new MobileButton(Icon.book, "@mods", ui.mods::show),
donate = new MobileButton(Icon.link, "@website", () -> Core.app.openURI("https://anuke.itch.io/mindustry")),
exit = new MobileButton(Icon.exit, "@quit", () -> Core.app.exit());
if(!Core.graphics.isPortrait()){
container.marginTop(60f);
@@ -164,20 +164,20 @@ public class MenuFragment extends Fragment{
t.defaults().width(width).height(70f);
buttons(t,
new Buttoni("$play", Icon.play,
new Buttoni("$campaign", Icon.play, () -> checkPlay(ui.planet::show)),
new Buttoni("$joingame", Icon.add, () -> checkPlay(ui.join::show)),
new Buttoni("$customgame", Icon.terrain, () -> checkPlay(ui.custom::show)),
new Buttoni("$loadgame", Icon.download, () -> checkPlay(ui.load::show)),
new Buttoni("$tutorial", Icon.info, () -> checkPlay(control::playTutorial))
new Buttoni("@play", Icon.play,
new Buttoni("@campaign", Icon.play, () -> checkPlay(ui.planet::show)),
new Buttoni("@joingame", Icon.add, () -> checkPlay(ui.join::show)),
new Buttoni("@customgame", Icon.terrain, () -> checkPlay(ui.custom::show)),
new Buttoni("@loadgame", Icon.download, () -> checkPlay(ui.load::show)),
new Buttoni("@tutorial", Icon.info, () -> checkPlay(control::playTutorial))
),
new Buttoni("$editor", Icon.terrain, () -> checkPlay(ui.maps::show)), steam ? new Buttoni("$workshop", Icon.book, platform::openWorkshop) : null,
new Buttoni("@editor", Icon.terrain, () -> checkPlay(ui.maps::show)), steam ? new Buttoni("@workshop", Icon.book, platform::openWorkshop) : null,
new Buttoni(Core.bundle.get("mods"), Icon.bookOpen, ui.mods::show),
//not enough space for this button
//new Buttoni("$schematics", Icon.paste, ui.schematics::show),
new Buttoni("$settings", Icon.settings, ui.settings::show),
new Buttoni("$about.button", Icon.info, ui.about::show),
new Buttoni("$quit", Icon.exit, Core.app::exit)
//new Buttoni("@schematics", Icon.paste, ui.schematics::show),
new Buttoni("@settings", Icon.settings, ui.settings::show),
new Buttoni("@about.button", Icon.info, ui.about::show),
new Buttoni("@quit", Icon.exit, Core.app::exit)
);
}).width(width).growY();
@@ -196,7 +196,7 @@ public class MenuFragment extends Fragment{
if(!mods.hasContentErrors()){
run.run();
}else{
ui.showInfo("$mod.noerrorplay");
ui.showInfo("@mod.noerrorplay");
}
}

View File

@@ -98,11 +98,11 @@ public class MinimapFragment extends Fragment{
t.visible(() -> shown);
t.update(() -> t.setBounds(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight()));
t.add("$minimap").style(Styles.outlineLabel).pad(10f);
t.add("@minimap").style(Styles.outlineLabel).pad(10f);
t.row();
t.add().growY();
t.row();
t.button("$back", Icon.leftOpen, () -> shown = false).size(220f, 60f).pad(10f);
t.button("@back", Icon.leftOpen, () -> shown = false).size(220f, 60f).pad(10f);
});
}

View File

@@ -22,6 +22,8 @@ import mindustry.input.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.BuildBlock.*;
import static mindustry.Vars.*;
@@ -93,7 +95,7 @@ public class PlacementFragment extends Fragment{
if(Core.input.keyDown(Binding.pick) && player.isBuilder()){ //mouse eyedropper select
Building tile = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
Block tryRecipe = tile == null ? null : tile.block();
Block tryRecipe = tile == null ? null : tile.block() instanceof BuildBlock ? ((BuildEntity)tile).cblock : tile.block;
Object tryConfig = tile == null ? null : tile.config();
for(BuildPlan req : player.builder().plans()){
@@ -160,7 +162,7 @@ public class PlacementFragment extends Fragment{
blockSelectEnd = true;
}
Seq<Block> blocks = getByCategory(currentCategory);
if(!unlocked(blocks.get(i))) return true;
if(i >= blocks.size || !unlocked(blocks.get(i))) return true;
input.block = (i < blocks.size) ? blocks.get(i) : null;
selectedBlocks.put(currentCategory, input.block);
blockSelectSeqMillis = Time.millis();
@@ -216,7 +218,7 @@ public class PlacementFragment extends Fragment{
if(unlocked(block)){
if(Core.input.keyDown(KeyCode.shiftLeft) && Fonts.getUnicode(block.name) != 0){
Core.app.setClipboardText((char)Fonts.getUnicode(block.name) + "");
ui.showInfoFade("$copied");
ui.showInfoFade("@copied");
}else{
control.input.block = control.input.block == block ? null : block;
selectedBlocks.put(currentCategory, control.input.block);
@@ -337,7 +339,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" : displayBlock.unplaceableMessage()).width(190f).wrap();
b.add(!player.isBuilder() ? "@unit.nobuild" : displayBlock.unplaceableMessage()).width(190f).wrap();
b.left();
}).padTop(2).left();
}

View File

@@ -16,8 +16,8 @@ import mindustry.ui.*;
import static mindustry.Vars.*;
public class PlayerListFragment extends Fragment{
public Table content = new Table().marginRight(13f).marginLeft(13f);
private boolean visible = false;
private Table content = new Table().marginRight(13f).marginLeft(13f);
private Interval timer = new Interval();
private TextField sField;
private boolean found = false;
@@ -57,9 +57,9 @@ public class PlayerListFragment extends Fragment{
pane.table(menu -> {
menu.defaults().growX().height(50f).fillY();
menu.button("$server.bans", ui.bans::show).disabled(b -> net.client());
menu.button("$server.admins", ui.admins::show).disabled(b -> net.client());
menu.button("$close", this::toggle);
menu.button("@server.bans", ui.bans::show).disabled(b -> net.client());
menu.button("@server.admins", ui.admins::show).disabled(b -> net.client());
menu.button("@close", this::toggle);
}).margin(0f).pad(10f).growX();
}).touchable(Touchable.enabled).margin(14f);
@@ -116,11 +116,11 @@ public class PlayerListFragment extends Fragment{
t.button(Icon.hammer, Styles.clearPartiali,
() -> {
ui.showConfirm("$confirm", Core.bundle.format("confirmban", user.name()), () -> Call.adminRequest(user, AdminAction.ban));
ui.showConfirm("@confirm", Core.bundle.format("confirmban", user.name()), () -> Call.adminRequest(user, AdminAction.ban));
});
t.button(Icon.cancel, Styles.clearPartiali,
() -> {
ui.showConfirm("$confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.adminRequest(user, AdminAction.kick));
ui.showConfirm("@confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.adminRequest(user, AdminAction.kick));
});
t.row();
@@ -131,9 +131,9 @@ public class PlayerListFragment extends Fragment{
String id = user.uuid();
if(netServer.admins.isAdmin(id, connection.address)){
ui.showConfirm("$confirm", Core.bundle.format("confirmunadmin", user.name()), () -> netServer.admins.unAdminPlayer(id));
ui.showConfirm("@confirm", Core.bundle.format("confirmunadmin", user.name()), () -> netServer.admins.unAdminPlayer(id));
}else{
ui.showConfirm("$confirm", Core.bundle.format("confirmadmin", user.name()), () -> netServer.admins.adminPlayer(id, user.usid()));
ui.showConfirm("@confirm", Core.bundle.format("confirmadmin", user.name()), () -> netServer.admins.adminPlayer(id, user.usid()));
}
}).update(b -> b.setChecked(user.admin))
.disabled(b -> net.client())
@@ -148,7 +148,7 @@ public class PlayerListFragment extends Fragment{
button.button(Icon.hammer, Styles.clearPartiali,
() -> {
ui.showConfirm("$confirm", Core.bundle.format("confirmvotekick", user.name()), () -> {
ui.showConfirm("@confirm", Core.bundle.format("confirmvotekick", user.name()), () -> {
Call.sendChatMessage("/votekick " + user.name());
});
}).size(h);

View File

@@ -24,7 +24,7 @@ public class ScriptConsoleFragment extends Table{
private boolean open = false, shown;
private TextField chatfield;
private Label fieldlabel = new Label(">");
private BitmapFont font;
private Font font;
private GlyphLayout layout = new GlyphLayout();
private float offsetx = Scl.scl(4), offsety = Scl.scl(4), fontoffsetx = Scl.scl(2), chatspace = Scl.scl(50);
private Color shadowColor = new Color(0, 0, 0, 0.4f);
@@ -53,7 +53,7 @@ public class ScriptConsoleFragment extends Table{
clearChatInput();
}
return shown && !Vars.net.active();
return shown;
});
update(() -> {
@@ -115,7 +115,7 @@ public class ScriptConsoleFragment extends Table{
Draw.color(shadowColor);
if(open){
Fill.crect(offsetx, chatfield.getY(), chatfield.getWidth() + 15f, chatfield.getHeight() - 1);
Fill.crect(offsetx, chatfield.y, chatfield.getWidth() + 15f, chatfield.getHeight() - 1);
}
super.draw();
@@ -159,7 +159,7 @@ public class ScriptConsoleFragment extends Table{
String message = chatfield.getText();
clearChatInput();
if(message.replaceAll(" ", "").isEmpty()) return;
if(message.replace(" ", "").isEmpty()) return;
//special case for 'clear' command
if(message.equals("clear")){