time for a crusade against dialogs
This commit is contained in:
@@ -636,7 +636,7 @@ public class Bullets implements ContentList{
|
||||
}
|
||||
};
|
||||
|
||||
arc = new BulletType(0.001f, 25){
|
||||
arc = new BulletType(0.001f, 21){
|
||||
{
|
||||
lifetime = 1;
|
||||
despawnEffect = Fx.none;
|
||||
|
||||
@@ -37,8 +37,8 @@ public class StatusEffects implements ContentList{
|
||||
speedMultiplier = 0.9f;
|
||||
effect = Fx.wet;
|
||||
|
||||
trans(() -> shocked, ((unit, time, newTime, result) -> unit.damage(15f)));
|
||||
opposite(() -> burning, () -> shocked);
|
||||
trans(() -> shocked, ((unit, time, newTime, result) -> unit.damage(20f)));
|
||||
opposite(() -> burning);
|
||||
}};
|
||||
|
||||
melting = new StatusEffect(){{
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
net.host(port);
|
||||
player.isAdmin = true;
|
||||
}catch(IOException e){
|
||||
ui.showError(Core.bundle.format("server.error", Strings.parseException(e, true)));
|
||||
ui.showException("$server.error", e);
|
||||
Core.app.post(() -> state.set(State.menu));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class NetClient implements ApplicationListener{
|
||||
c.uuid = platform.getUUID();
|
||||
|
||||
if(c.uuid == null){
|
||||
ui.showError("$invalidid");
|
||||
ui.showErrorMessage("$invalidid");
|
||||
ui.loadfrag.hide();
|
||||
disconnectQuietly();
|
||||
return;
|
||||
@@ -117,7 +117,7 @@ public class NetClient implements ApplicationListener{
|
||||
ui.showSmall("$disconnect", "$disconnect.error");
|
||||
}
|
||||
}else{
|
||||
ui.showError("$disconnect");
|
||||
ui.showErrorMessage("$disconnect");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -360,7 +360,7 @@ public class NetClient implements ApplicationListener{
|
||||
Log.err("Failed to load data!");
|
||||
ui.loadfrag.hide();
|
||||
quiet = true;
|
||||
ui.showError("$disconnect.data");
|
||||
ui.showErrorMessage("$disconnect.data");
|
||||
net.disconnect();
|
||||
timeoutTime = 0f;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.net.Net.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
@@ -15,16 +16,20 @@ import static io.anuke.mindustry.Vars.mobile;
|
||||
|
||||
public interface Platform{
|
||||
|
||||
/** Steam: Update lobby visibility.*/
|
||||
default void updateLobby(){}
|
||||
|
||||
/** Steam: Show multiplayer friend invite dialog.*/
|
||||
default void inviteFriends(){}
|
||||
|
||||
/** Steam: Share a map on the workshop.*/
|
||||
default void publishMap(Map map){}
|
||||
|
||||
/** Get the networking implementation.*/
|
||||
default NetProvider getNet(){
|
||||
return new ArcNetImpl();
|
||||
}
|
||||
|
||||
/** Steam: Update lobby visibility.*/
|
||||
default void updateLobby(){
|
||||
|
||||
}
|
||||
|
||||
/** Add a text input dialog that should show up after the field is tapped. */
|
||||
default void addDialog(TextField field){
|
||||
addDialog(field, 16);
|
||||
@@ -95,11 +100,11 @@ public interface Platform{
|
||||
default void hide(){
|
||||
}
|
||||
|
||||
/** Forces the app into landscape mode. Currently Android only. */
|
||||
/** Forces the app into landscape mode.*/
|
||||
default void beginForceLandscape(){
|
||||
}
|
||||
|
||||
/** Stops forcing the app into landscape orientation. Currently Android only. */
|
||||
/** Stops forcing the app into landscape orientation.*/
|
||||
default void endForceLandscape(){
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class Renderer implements ApplicationListener{
|
||||
e.printStackTrace();
|
||||
settings.put("bloom", false);
|
||||
settings.save();
|
||||
ui.showError("$error.bloom");
|
||||
ui.showErrorMessage("$error.bloom");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class UI implements ApplicationListener, Loadable{
|
||||
|
||||
Core.settings.setErrorHandler(e -> {
|
||||
e.printStackTrace();
|
||||
Core.app.post(() -> showError("Failed to access local storage.\nSettings will not be saved."));
|
||||
Core.app.post(() -> showErrorMessage("Failed to access local storage.\nSettings will not be saved."));
|
||||
});
|
||||
|
||||
ClickListener.clicked = () -> Sounds.press.play();
|
||||
@@ -330,19 +330,42 @@ public class UI implements ApplicationListener, Loadable{
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showError(String text){
|
||||
public void showErrorMessage(String text){
|
||||
new Dialog("", "dialog"){{
|
||||
setFillParent(true);
|
||||
setFillParent(false);
|
||||
cont.margin(15f);
|
||||
cont.add("$error.title");
|
||||
cont.row();
|
||||
cont.margin(15).pane(t -> {
|
||||
Label l = t.add(text).pad(14f).get();
|
||||
l.setAlignment(Align.center, Align.left);
|
||||
if(mobile){
|
||||
t.getCell(l).wrap().width(400f);
|
||||
}
|
||||
});
|
||||
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
|
||||
cont.addImage("whiteui").fillX().pad(2).height(4f).color(Color.SCARLET);
|
||||
cont.row();
|
||||
cont.add(text).pad(2f);
|
||||
buttons.addButton("$ok", this::hide).size(120, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showException(Throwable t){
|
||||
showException("", t);
|
||||
}
|
||||
|
||||
public void showException(String text, Throwable exc){
|
||||
new Dialog("", "dialog"){{
|
||||
String message = Strings.getFinalMesage(exc);
|
||||
|
||||
setFillParent(true);
|
||||
cont.margin(15);
|
||||
cont.add("$error.title").colspan(2);
|
||||
cont.row();
|
||||
cont.addImage("whiteui").fillX().pad(2).colspan(2).height(4f).color(Color.SCARLET);
|
||||
cont.row();
|
||||
cont.add((text.startsWith("$") ? Core.bundle.get(text.substring(1)) : text) + (message == null ? "" : "\n[lightgray](" + message + ")")).colspan(2).center().get().setAlignment(Align.center);
|
||||
cont.row();
|
||||
|
||||
Collapser col = new Collapser(base -> base.pane(t -> t.margin(14f).add(Strings.parseException(exc, true)).color(Color.LIGHT_GRAY).left()), true);
|
||||
|
||||
cont.addButton("$details", "toggle", col::toggle).size(180f, 50f).checked(b -> !col.isCollapsed()).fillX().right();
|
||||
cont.addButton("$ok", this::hide).size(100, 50).fillX().left();
|
||||
cont.row();
|
||||
cont.add(col).colspan(2).pad(2);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ public class World{
|
||||
}catch(Exception e){
|
||||
Log.err(e);
|
||||
if(!headless){
|
||||
ui.showError("$map.invalid");
|
||||
ui.showErrorMessage("$map.invalid");
|
||||
Core.app.post(() -> state.set(State.menu));
|
||||
invalidMap = true;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ public class World{
|
||||
|
||||
if(!headless){
|
||||
if(state.teams.get(defaultTeam).cores.size == 0 && !checkRules.pvp){
|
||||
ui.showError("$map.nospawn");
|
||||
ui.showErrorMessage("$map.nospawn");
|
||||
invalidMap = true;
|
||||
}else if(checkRules.pvp){ //pvp maps need two cores to be valid
|
||||
int teams = 0;
|
||||
@@ -240,12 +240,12 @@ public class World{
|
||||
}
|
||||
if(teams < 2){
|
||||
invalidMap = true;
|
||||
ui.showError("$map.nospawn.pvp");
|
||||
ui.showErrorMessage("$map.nospawn.pvp");
|
||||
}
|
||||
}else if(checkRules.attackMode){ //attack maps need two cores to be valid
|
||||
invalidMap = state.teams.get(waveTeam).cores.isEmpty();
|
||||
if(invalidMap){
|
||||
ui.showError("$map.nospawn.attack");
|
||||
ui.showErrorMessage("$map.nospawn.attack");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
@@ -109,7 +109,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
editor.beginEdit(pixmap);
|
||||
pixmap.dispose();
|
||||
}catch(Exception e){
|
||||
ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, true)));
|
||||
ui.showException("$editor.errorload", e);
|
||||
Log.err(e);
|
||||
}
|
||||
})))
|
||||
@@ -126,7 +126,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}
|
||||
MapIO.writeMap(file, editor.createMap(file));
|
||||
}catch(Exception e){
|
||||
ui.showError(Core.bundle.format("editor.errorsave", Strings.parseException(e, true)));
|
||||
ui.showException("$editor.errorsave", e);
|
||||
Log.err(e);
|
||||
}
|
||||
});
|
||||
@@ -138,7 +138,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
MapIO.writeMap(result, editor.createMap(result));
|
||||
platform.shareFile(result);
|
||||
}catch(Exception e){
|
||||
ui.showError(Core.bundle.format("editor.errorsave", Strings.parseException(e, true)));
|
||||
ui.showException("$editor.errorsave", e);
|
||||
Log.err(e);
|
||||
}
|
||||
});
|
||||
@@ -173,7 +173,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
try{
|
||||
editor.beginEdit(map);
|
||||
}catch(Exception e){
|
||||
ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, true)));
|
||||
ui.showException("$editor.errorload", e);
|
||||
Log.err(e);
|
||||
}
|
||||
}));
|
||||
@@ -227,11 +227,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
shown(this::build);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(float x, float y){
|
||||
drawDefaultBackground(x, y);
|
||||
}
|
||||
|
||||
public void resumeEditing(){
|
||||
state.set(State.menu);
|
||||
shownWithMap = true;
|
||||
@@ -280,7 +275,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
if(name.isEmpty()){
|
||||
infoDialog.show();
|
||||
Core.app.post(() -> ui.showError("$editor.save.noname"));
|
||||
Core.app.post(() -> ui.showErrorMessage("$editor.save.noname"));
|
||||
}else{
|
||||
Map map = maps.all().find(m -> m.name().equals(name));
|
||||
if(map != null && !map.custom){
|
||||
@@ -297,7 +292,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
/** Called when a built-in map save is attempted.*/
|
||||
protected void handleSaveBuiltin(Map map){
|
||||
ui.showError("$editor.save.overwrite");
|
||||
ui.showErrorMessage("$editor.save.overwrite");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +361,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
show();
|
||||
}catch(Exception e){
|
||||
Log.err(e);
|
||||
ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, true)));
|
||||
ui.showException("$editor.errorload", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class MapSaveDialog extends FloatingDialog{
|
||||
if(!invalid()){
|
||||
listener.accept(field.getText());
|
||||
}else{
|
||||
ui.showError("$editor.failoverwrite");
|
||||
ui.showErrorMessage("$editor.failoverwrite");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class WaveInfoDialog extends FloatingDialog{
|
||||
groups = maps.readWaves(Core.app.getClipboardText());
|
||||
buildGroups();
|
||||
}catch(Exception e){
|
||||
ui.showError("$waves.invalid");
|
||||
ui.showErrorMessage("$waves.invalid");
|
||||
}
|
||||
dialog.hide();
|
||||
}).disabled(b -> Core.app.getClipboardText() == null || Core.app.getClipboardText().isEmpty());
|
||||
|
||||
@@ -17,7 +17,7 @@ import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.effectGroup;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||
private Vector2 from = new Vector2();
|
||||
|
||||
@@ -22,7 +22,6 @@ public enum Gamemode{
|
||||
attack(rules -> {
|
||||
rules.unitDrops = true;
|
||||
rules.attackMode = true;
|
||||
rules.waves = true;
|
||||
}, map -> map.teams.contains(waveTeam.ordinal())),
|
||||
pvp(rules -> {
|
||||
rules.pvp = true;
|
||||
|
||||
@@ -19,7 +19,6 @@ import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.fragments.*;
|
||||
@@ -60,11 +59,11 @@ public abstract class InputHandler implements InputProcessor{
|
||||
@Remote(targets = Loc.both, forward = true, called = Loc.server)
|
||||
public static void transferInventory(Player player, Tile tile){
|
||||
if(!player.timer.get(Player.timerTransfer, 40)) return;
|
||||
if(net.server() && (player.item().amount <= 0 || player.isTransferring)){
|
||||
if(net.server() && (player.item().amount <= 0 || player.isTransferring|| !tile.interactable(player.getTeam()))){
|
||||
throw new ValidateException(player, "Player cannot transfer an item.");
|
||||
}
|
||||
|
||||
if(player == null || tile.entity == null) return;
|
||||
if(tile.entity == null) return;
|
||||
|
||||
player.isTransferring = true;
|
||||
|
||||
|
||||
@@ -207,11 +207,11 @@ public class Maps{
|
||||
Log.err(e);
|
||||
|
||||
if("Outdated legacy map format".equals(e.getMessage())){
|
||||
ui.showError("$editor.errornot");
|
||||
ui.showErrorMessage("$editor.errornot");
|
||||
}else if(e.getMessage() != null && e.getMessage().contains("Incorrect header!")){
|
||||
ui.showError("$editor.errorheader");
|
||||
ui.showErrorMessage("$editor.errorheader");
|
||||
}else{
|
||||
ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, true)));
|
||||
ui.showException("$editor.errorload", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +61,12 @@ public class Net{
|
||||
}else if(error.equals("alreadyconnected") || error.contains("connection is closed")){
|
||||
error = Core.bundle.get("error.alreadyconnected");
|
||||
}else if(!error.isEmpty()){
|
||||
error = Core.bundle.get("error.any") + "\n" + Strings.parseException(e, true);
|
||||
error = Core.bundle.get("error.any");
|
||||
isError = true;
|
||||
}
|
||||
|
||||
if(isError){
|
||||
ui.showError(Core.bundle.format("connectfail", error));
|
||||
ui.showException("$error.any", e);
|
||||
}else{
|
||||
ui.showText("", Core.bundle.format("connectfail", error));
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ public class Plugins{
|
||||
|
||||
PluginMeta meta = JsonIO.read(PluginMeta.class, metaf.readString());
|
||||
|
||||
|
||||
URLClassLoader classLoader = new URLClassLoader(new URL[]{jar.file().toURI().toURL()}, ClassLoader.getSystemClassLoader());
|
||||
Class<?> main = classLoader.loadClass(meta.main);
|
||||
return new LoadedPlugin(jar, zip, (Plugin)main.newInstance(), meta);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AboutDialog extends FloatingDialog{
|
||||
|
||||
table.addImageButton("icon-link", iconsize, () -> {
|
||||
if(!Core.net.openURI(link.link)){
|
||||
ui.showError("$linkfail");
|
||||
ui.showErrorMessage("$linkfail");
|
||||
Core.app.setClipboardText(link.link);
|
||||
}
|
||||
}).size(h - 5, h);
|
||||
|
||||
@@ -168,11 +168,6 @@ public class DeployDialog extends FloatingDialog{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(float x, float y){
|
||||
drawDefaultBackground(x, y);
|
||||
}
|
||||
|
||||
void buildButton(Zone zone, Button button){
|
||||
button.setDisabled(() -> hidden(zone));
|
||||
button.clicked(() -> info.show(zone));
|
||||
|
||||
@@ -43,7 +43,7 @@ public class DiscordDialog extends Dialog{
|
||||
});
|
||||
buttons.addButton("$openlink", () -> {
|
||||
if(!Core.net.openURI(discordURL)){
|
||||
ui.showError("$linkfail");
|
||||
ui.showErrorMessage("$linkfail");
|
||||
Core.app.setClipboardText(discordURL);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.files.FileHandle;
|
||||
import io.anuke.arc.function.Consumer;
|
||||
import io.anuke.arc.function.Predicate;
|
||||
import io.anuke.arc.graphics.g2d.GlyphLayout;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.scene.event.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.scene.ui.layout.UnitScl;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.arc.util.pooling.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -31,13 +29,9 @@ public class FileChooser extends FloatingDialog{
|
||||
private Consumer<FileHandle> selectListener;
|
||||
private boolean open;
|
||||
|
||||
public static final Predicate<String> pngFiles = str -> str.equals("png");
|
||||
public static final Predicate<String> anyMapFiles = str -> str.equals(oldMapExtension) || str.equals(mapExtension);
|
||||
public static final Predicate<String> mapFiles = str -> str.equals(mapExtension);
|
||||
public static final Predicate<String> saveFiles = str -> str.equals(saveExtension);
|
||||
|
||||
public FileChooser(String title, Predicate<FileHandle> filter, boolean open, Consumer<FileHandle> result){
|
||||
super(title);
|
||||
setFillParent(true);
|
||||
this.open = open;
|
||||
this.filter = filter;
|
||||
this.selectListener = result;
|
||||
@@ -88,11 +82,7 @@ public class FileChooser extends FloatingDialog{
|
||||
files.marginRight(10);
|
||||
files.marginLeft(3);
|
||||
|
||||
pane = new ScrollPane(files){
|
||||
public float getPrefHeight(){
|
||||
return Core.graphics.getHeight();
|
||||
}
|
||||
};
|
||||
pane = new ScrollPane(files);
|
||||
pane.setOverscroll(false, false);
|
||||
pane.setFadeScrollBars(false);
|
||||
|
||||
@@ -152,7 +142,7 @@ public class FileChooser extends FloatingDialog{
|
||||
content.add(icontable).expandX().fillX();
|
||||
content.row();
|
||||
|
||||
content.center().add(pane).width(Core.graphics.isPortrait() ? Core.graphics.getWidth() / UnitScl.dp.scl(1) : Core.graphics.getWidth() / UnitScl.dp.scl(2)).colspan(3).grow();
|
||||
content.center().add(pane).colspan(3).grow();
|
||||
content.row();
|
||||
|
||||
if(!open){
|
||||
@@ -162,7 +152,7 @@ public class FileChooser extends FloatingDialog{
|
||||
|
||||
content.add(buttons).growX();
|
||||
|
||||
cont.add(content);
|
||||
cont.add(content).grow();
|
||||
}
|
||||
|
||||
private void updateFileFieldStatus(){
|
||||
|
||||
@@ -66,7 +66,7 @@ public class HostDialog extends FloatingDialog{
|
||||
net.host(Vars.port);
|
||||
player.isAdmin = true;
|
||||
}catch(IOException e){
|
||||
ui.showError(Core.bundle.format("server.error", Strings.parseException(e, true)));
|
||||
ui.showException("$server.error", e);
|
||||
}
|
||||
ui.loadfrag.hide();
|
||||
hide();
|
||||
|
||||
@@ -94,7 +94,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
slot.exportFile(file);
|
||||
setup();
|
||||
}catch(IOException e){
|
||||
ui.showError(Core.bundle.format("save.export.fail", Strings.parseException(e, true)));
|
||||
ui.showException("save.export.fail", e);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
@@ -103,7 +103,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
slot.exportFile(file);
|
||||
platform.shareFile(file);
|
||||
}catch(Exception e){
|
||||
ui.showError(Core.bundle.format("save.export.fail", Strings.parseException(e, true)));
|
||||
ui.showException("save.export.fail", e);
|
||||
}
|
||||
}
|
||||
}).size(iconsize).right();
|
||||
@@ -177,10 +177,10 @@ public class LoadDialog extends FloatingDialog{
|
||||
setup();
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
ui.showError(Core.bundle.format("save.import.fail", Strings.parseException(e, true)));
|
||||
ui.showException("save.import.fail", e);
|
||||
}
|
||||
}else{
|
||||
ui.showError("$save.import.invalid");
|
||||
ui.showErrorMessage("$save.import.invalid");
|
||||
}
|
||||
});
|
||||
}).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
||||
@@ -199,7 +199,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
Log.err(e);
|
||||
state.set(State.menu);
|
||||
logic.reset();
|
||||
ui.showError("$save.corrupted");
|
||||
ui.showErrorMessage("$save.corrupted");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
ui.loadAnd(() -> {
|
||||
maps.tryCatchMapError(() -> {
|
||||
if(MapIO.isImage(file)){
|
||||
ui.showError("$editor.errorimage");
|
||||
ui.showErrorMessage("$editor.errorimage");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
|
||||
//this will never actually get called, but it remains just in case
|
||||
if(name == null){
|
||||
ui.showError("$editor.errorname");
|
||||
ui.showErrorMessage("$editor.errorname");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
hide();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
ui.showError("$error.mapnotfound");
|
||||
ui.showErrorMessage("$error.mapnotfound");
|
||||
}
|
||||
}).fillX().height(54f).marginLeft(10);
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@ public class MinimapDialog extends FloatingDialog{
|
||||
onResize(this::setup);
|
||||
}
|
||||
|
||||
public void drawBackground(float x, float y){
|
||||
drawDefaultBackground(x, y);
|
||||
}
|
||||
|
||||
void setup(){
|
||||
cont.clearChildren();
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.input.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -123,7 +122,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
control.saves.getCurrent().save();
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
ui.showError("[accent]" + Core.bundle.get("savefail"));
|
||||
ui.showException("[accent]" + Core.bundle.get("savefail"), e);
|
||||
}
|
||||
state.set(State.menu);
|
||||
logic.reset();
|
||||
|
||||
@@ -53,7 +53,7 @@ public class SaveDialog extends LoadDialog{
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
|
||||
ui.showError("[accent]" + Core.bundle.get("savefail"));
|
||||
ui.showException("[accent]" + Core.bundle.get("savefail"), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
|
||||
import static io.anuke.arc.Core.bundle;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@@ -108,7 +107,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
try{
|
||||
data.exportData(file);
|
||||
}catch(Exception e){
|
||||
ui.showError(Strings.parseException(e, true));
|
||||
ui.showException(e);
|
||||
}
|
||||
platform.shareFile(file);
|
||||
}else{
|
||||
@@ -118,7 +117,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
ui.showInfo("$data.exported");
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
ui.showError(Strings.parseException(e, true));
|
||||
ui.showException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -133,13 +132,13 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
data.importData(file);
|
||||
Core.app.exit();
|
||||
}catch(IllegalArgumentException e){
|
||||
ui.showError("$data.invalid");
|
||||
ui.showErrorMessage("$data.invalid");
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
if(e.getMessage() == null || !e.getMessage().contains("too short")){
|
||||
ui.showError(Strings.parseException(e, true));
|
||||
ui.showException(e);
|
||||
}else{
|
||||
ui.showError("$data.invalid");
|
||||
ui.showErrorMessage("$data.invalid");
|
||||
}
|
||||
}
|
||||
})));
|
||||
@@ -215,9 +214,11 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
game.checkPref("savecreate", true);
|
||||
|
||||
game.checkPref("publichost", false, i -> {
|
||||
platform.updateLobby();
|
||||
});
|
||||
if(steam){
|
||||
game.checkPref("publichost", false, i -> {
|
||||
platform.updateLobby();
|
||||
});
|
||||
}
|
||||
|
||||
game.pref(new Setting(){
|
||||
@Override
|
||||
|
||||
@@ -53,11 +53,6 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
}).size(210f, 64f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(float x, float y){
|
||||
drawDefaultBackground(x, y);
|
||||
}
|
||||
|
||||
void treeLayout(){
|
||||
TreeLayout layout = new TreeLayout();
|
||||
layout.gapBetweenLevels = UnitScl.dp.scl(60f);
|
||||
|
||||
@@ -24,11 +24,6 @@ public class ZoneInfoDialog extends FloatingDialog{
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(float x, float y){
|
||||
drawDefaultBackground(x, y);
|
||||
}
|
||||
|
||||
public void show(Zone zone){
|
||||
setup(zone);
|
||||
show();
|
||||
|
||||
@@ -40,7 +40,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
|
||||
@Remote(called = Loc.server, targets = Loc.both, forward = true)
|
||||
public static void requestItem(Player player, Tile tile, Item item, int amount){
|
||||
if(player == null || tile == null || !player.timer.get(Player.timerTransfer, 20)) return;
|
||||
if(player == null || tile == null || !player.timer.get(Player.timerTransfer, 20) || !tile.interactable(player.getTeam())) return;
|
||||
|
||||
int removed = tile.block().removeStack(tile, item, amount);
|
||||
|
||||
|
||||
@@ -1,29 +1,24 @@
|
||||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.IntArray;
|
||||
import io.anuke.arc.collection.IntSet;
|
||||
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.collection.IntSet.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Layer;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ItemBridge extends Block{
|
||||
protected int timerTransport = timers++;
|
||||
@@ -270,6 +265,52 @@ public class ItemBridge extends Block{
|
||||
return tile.entity.items.total() < itemCapacity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canDumpLiquid(Tile tile, Tile to, Liquid liquid){
|
||||
ItemBridgeEntity entity = tile.entity();
|
||||
|
||||
Tile other = world.tile(entity.link);
|
||||
if(!linkValid(tile, other)){
|
||||
Tile edge = Edges.getFacingEdge(to, tile);
|
||||
int i = tile.absoluteRelativeTo(edge.x, edge.y);
|
||||
|
||||
IntSetIterator it = entity.incoming.iterator();
|
||||
|
||||
while(it.hasNext){
|
||||
int v = it.next();
|
||||
if(tile.absoluteRelativeTo(Pos.x(v), Pos.y(v)) == i){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int rel = tile.absoluteRelativeTo(other.x, other.y);
|
||||
int rel2 = tile.relativeTo(to.x, to.y);
|
||||
|
||||
return rel != rel2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
if(tile.getTeam() != source.getTeam()) return false;
|
||||
|
||||
ItemBridgeEntity entity = tile.entity();
|
||||
Tile other = world.tile(entity.link);
|
||||
|
||||
if(linkValid(tile, other)){
|
||||
int rel = tile.absoluteRelativeTo(other.x, other.y);
|
||||
int rel2 = tile.relativeTo(source.x, source.y);
|
||||
|
||||
if(rel == rel2) return false;
|
||||
}else if(!(source.block() instanceof ItemBridge && source.<ItemBridgeEntity>entity().link == tile.pos())){
|
||||
return false;
|
||||
}
|
||||
|
||||
return tile.entity.liquids.get(liquid) + amount < liquidCapacity && (tile.entity.liquids.current() == liquid || tile.entity.liquids.get(tile.entity.liquids.current()) < 0.2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDump(Tile tile, Tile to, Item item){
|
||||
ItemBridgeEntity entity = tile.entity();
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
@@ -56,49 +54,4 @@ public class LiquidBridge extends ItemBridge{
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
if(tile.getTeam() != source.getTeam()) return false;
|
||||
|
||||
ItemBridgeEntity entity = tile.entity();
|
||||
Tile other = world.tile(entity.link);
|
||||
|
||||
if(linkValid(tile, other)){
|
||||
int rel = tile.absoluteRelativeTo(other.x, other.y);
|
||||
int rel2 = tile.relativeTo(source.x, source.y);
|
||||
|
||||
if(rel == rel2) return false;
|
||||
}else if(!(source.block() instanceof ItemBridge && source.<ItemBridgeEntity>entity().link == tile.pos())){
|
||||
return false;
|
||||
}
|
||||
|
||||
return tile.entity.liquids.get(liquid) + amount < liquidCapacity && (tile.entity.liquids.current() == liquid || tile.entity.liquids.get(tile.entity.liquids.current()) < 0.2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDumpLiquid(Tile tile, Tile to, Liquid liquid){
|
||||
ItemBridgeEntity entity = tile.entity();
|
||||
|
||||
Tile other = world.tile(entity.link);
|
||||
if(!linkValid(tile, other)){
|
||||
Tile edge = Edges.getFacingEdge(to, tile);
|
||||
int i = tile.absoluteRelativeTo(edge.x, edge.y);
|
||||
|
||||
IntSetIterator it = entity.incoming.iterator();
|
||||
|
||||
while(it.hasNext){
|
||||
int v = it.next();
|
||||
if(tile.absoluteRelativeTo(Pos.x(v), Pos.y(v)) == i){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int rel = tile.absoluteRelativeTo(other.x, other.y);
|
||||
int rel2 = tile.relativeTo(to.x, to.y);
|
||||
|
||||
return rel != rel2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Pos;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
@@ -53,34 +50,4 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return tile.entity.liquids.get(liquid) + amount < liquidCapacity && (tile.entity.liquids.current() == liquid || tile.entity.liquids.get(tile.entity.liquids.current()) < 0.2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDumpLiquid(Tile tile, Tile to, Liquid liquid){
|
||||
ItemBridgeEntity entity = tile.entity();
|
||||
|
||||
Tile other = world.tile(entity.link);
|
||||
if(!linkValid(tile, other)){
|
||||
int i = tile.absoluteRelativeTo(to.x, to.y);
|
||||
|
||||
IntSetIterator it = entity.incoming.iterator();
|
||||
|
||||
while(it.hasNext){
|
||||
int v = it.next();
|
||||
if(tile.absoluteRelativeTo(Pos.x(v), Pos.y(v)) == i){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int rel = tile.absoluteRelativeTo(other.x, other.y);
|
||||
int rel2 = tile.relativeTo(to.x, to.y);
|
||||
|
||||
return rel != rel2;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user