Merge branch 'master' of https://github.com/Anuken/Mindustry into 4.0
This commit is contained in:
@@ -26,9 +26,7 @@ import io.anuke.ucore.core.Inputs.DeviceType;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Atlas;
|
||||
import io.anuke.ucore.util.InputProxy;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ public class NetClient extends Module {
|
||||
|
||||
private Timer timer = new Timer(5);
|
||||
private boolean connecting = false;
|
||||
private boolean gotData = false;
|
||||
private boolean kicked = false;
|
||||
private IntSet recieved = new IntSet();
|
||||
private IntMap<Entity> recent = new IntMap<>();
|
||||
private float timeoutTime = 0f; //data timeout counter
|
||||
|
||||
public NetClient(){
|
||||
|
||||
@@ -51,8 +51,8 @@ public class NetClient extends Module {
|
||||
Net.setClientLoaded(false);
|
||||
recieved.clear();
|
||||
recent.clear();
|
||||
timeoutTime = 0f;
|
||||
connecting = true;
|
||||
gotData = false;
|
||||
kicked = false;
|
||||
|
||||
ui.chatfrag.clearMessages();
|
||||
@@ -75,14 +75,6 @@ public class NetClient extends Module {
|
||||
}
|
||||
|
||||
Net.send(c, SendMode.tcp);
|
||||
|
||||
Timers.runTask(dataTimeout, () -> {
|
||||
if (!gotData) {
|
||||
Log.err("Failed to load data!");
|
||||
ui.loadfrag.hide();
|
||||
Net.disconnect();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Net.handleClient(Disconnect.class, packet -> {
|
||||
@@ -103,8 +95,6 @@ public class NetClient extends Module {
|
||||
NetworkIO.loadWorld(data.stream);
|
||||
player.set(world.getSpawnX(), world.getSpawnY());
|
||||
|
||||
gotData = true;
|
||||
|
||||
finishConnecting();
|
||||
});
|
||||
|
||||
@@ -121,7 +111,7 @@ public class NetClient extends Module {
|
||||
});
|
||||
|
||||
Net.handleClient(SyncPacket.class, packet -> {
|
||||
if (!gotData) return;
|
||||
if (connecting) return;
|
||||
int players = 0;
|
||||
int enemies = 0;
|
||||
|
||||
@@ -179,9 +169,8 @@ public class NetClient extends Module {
|
||||
}
|
||||
});
|
||||
|
||||
Net.handleClient(BreakPacket.class, (packet) -> {
|
||||
Placement.breakBlock(packet.x, packet.y, true, Timers.get("breakblocksound", 10));
|
||||
});
|
||||
Net.handleClient(BreakPacket.class, (packet) ->
|
||||
Placement.breakBlock(packet.x, packet.y, true, Timers.get("breakblocksound", 10)));
|
||||
|
||||
Net.handleClient(EntitySpawnPacket.class, packet -> {
|
||||
EntityGroup group = packet.group;
|
||||
@@ -245,7 +234,7 @@ public class NetClient extends Module {
|
||||
kicked = true;
|
||||
Net.disconnect();
|
||||
state.set(State.menu);
|
||||
ui.showError("$text.server.kicked." + packet.reason.name());
|
||||
if(!packet.reason.quiet) ui.showError("$text.server.kicked." + packet.reason.name());
|
||||
ui.loadfrag.hide();
|
||||
});
|
||||
|
||||
@@ -282,16 +271,22 @@ public class NetClient extends Module {
|
||||
if(!Net.client()) return;
|
||||
|
||||
if(!state.is(State.menu)){
|
||||
if(gotData) sync();
|
||||
if(!connecting) sync();
|
||||
}else if(!connecting){
|
||||
Net.disconnect();
|
||||
}else{ //...must be connecting
|
||||
timeoutTime += Timers.delta();
|
||||
if(timeoutTime > dataTimeout){
|
||||
Log.err("Failed to load data!");
|
||||
ui.loadfrag.hide();
|
||||
kicked = true;
|
||||
ui.showError("$text.disconnect.data");
|
||||
Net.disconnect();
|
||||
timeoutTime = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasData(){
|
||||
return gotData;
|
||||
}
|
||||
|
||||
public boolean isConnecting(){
|
||||
return connecting;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class UI extends SceneModule{
|
||||
if(Vars.debug && !Vars.showUI) return;
|
||||
|
||||
if(Graphics.drawing()) Graphics.end();
|
||||
|
||||
|
||||
act();
|
||||
|
||||
if(control.showCursor()) {
|
||||
|
||||
@@ -17,16 +17,16 @@ import io.anuke.ucore.util.Mathf;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class DesktopInput extends InputHandler{
|
||||
int mousex, mousey;
|
||||
int endx, endy;
|
||||
float mousex, mousey;
|
||||
float endx, endy;
|
||||
private boolean enableHold = false;
|
||||
private boolean beganBreak;
|
||||
private boolean rotated = false, rotatedAlt, zoomed;
|
||||
|
||||
@Override public float getCursorEndX(){ return select() ? getCursorX() : endx; }
|
||||
@Override public float getCursorEndY(){ return select() ? getCursorY() : endy; }
|
||||
@Override public float getCursorX(){ return (int)(Graphics.screen(mousex, mousey).x); }
|
||||
@Override public float getCursorY(){ return (int)(Gdx.graphics.getHeight() - Graphics.screen(mousex, mousey).y); }
|
||||
@Override public float getCursorEndX(){ return endx; }
|
||||
@Override public float getCursorEndY(){ return endy; }
|
||||
@Override public float getCursorX(){ return Graphics.screen(mousex, mousey).x; }
|
||||
@Override public float getCursorY(){ return Gdx.graphics.getHeight() - 1 - Graphics.screen(mousex, mousey).y; }
|
||||
@Override public boolean drawPlace(){ return !beganBreak; }
|
||||
|
||||
@Override
|
||||
@@ -48,8 +48,8 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(!Inputs.keyDown("select") && !Inputs.keyDown("break")){
|
||||
mousex = (int)Graphics.mouseWorld().x;
|
||||
mousey = (int)Graphics.mouseWorld().y;
|
||||
mousex = Graphics.mouseWorld().x;
|
||||
mousey = Graphics.mouseWorld().y;
|
||||
}
|
||||
|
||||
endx = Gdx.input.getX();
|
||||
@@ -156,11 +156,6 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
}
|
||||
|
||||
boolean select(){
|
||||
return !Inputs.keyDown("select") && !Inputs.keyRelease("select") &&
|
||||
!Inputs.keyDown("break") && !Inputs.keyRelease("break");
|
||||
}
|
||||
|
||||
public int tilex(){
|
||||
return (recipe != null && recipe.result.isMultiblock() &&
|
||||
recipe.result.size % 2 == 0) ?
|
||||
|
||||
@@ -383,7 +383,14 @@ public class Packets {
|
||||
}
|
||||
|
||||
public enum KickReason{
|
||||
kick, invalidPassword, clientOutdated, serverOutdated, banned
|
||||
kick, invalidPassword, clientOutdated, serverOutdated, banned, gameover(true);
|
||||
public final boolean quiet;
|
||||
|
||||
KickReason(){ quiet = false; }
|
||||
|
||||
KickReason(boolean quiet){
|
||||
this.quiet = quiet;
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpgradePacket implements Packet{
|
||||
|
||||
@@ -40,6 +40,7 @@ public class MenuButton extends Button{
|
||||
scale = Unit.dp.scl(1f);
|
||||
}
|
||||
add(text, style, scale).color(hasInvalid ? Color.DARK_GRAY : Color.WHITE);
|
||||
|
||||
if(hasInvalid){
|
||||
row();
|
||||
add(text, style, scale).padTop(Unit.dp.scl(-Core.font.getData().lineHeight * scale * 2f - 4f)).color(Color.WHITE);
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.io.Changelogs;
|
||||
import io.anuke.mindustry.io.Changelogs.VersionInfo;
|
||||
import io.anuke.mindustry.io.Version;
|
||||
@@ -17,6 +18,10 @@ public class ChangelogDialog extends FloatingDialog{
|
||||
public ChangelogDialog(){
|
||||
super("$text.changelog.title");
|
||||
|
||||
addCloseButton();
|
||||
|
||||
content().add("$text.changelog.loading");
|
||||
|
||||
Changelogs.getChangelog(result -> {
|
||||
versions = result;
|
||||
Gdx.app.postRunnable(this::setup);
|
||||
@@ -30,12 +35,15 @@ public class ChangelogDialog extends FloatingDialog{
|
||||
Table table = new Table();
|
||||
ScrollPane pane = new ScrollPane(table, "clear");
|
||||
|
||||
content().clear();
|
||||
content().add(pane).grow();
|
||||
|
||||
addCloseButton();
|
||||
|
||||
if(versions == null){
|
||||
table.add("$text.changelog.error");
|
||||
if(Vars.android){
|
||||
table.row();
|
||||
table.add("$text.changelog.error.android").padTop(8);
|
||||
}
|
||||
}else{
|
||||
for(VersionInfo info : versions){
|
||||
Table in = new Table("clear");
|
||||
@@ -45,7 +53,7 @@ public class ChangelogDialog extends FloatingDialog{
|
||||
if(info.build == Version.build){
|
||||
in.row();
|
||||
in.add("$text.changelog.current");
|
||||
}else if(info == versions.peek()){
|
||||
}else if(info == versions.first()){
|
||||
in.row();
|
||||
in.add("$text.changelog.latest");
|
||||
}
|
||||
|
||||
@@ -124,8 +124,7 @@ public class DebugFragment implements Fragment {
|
||||
Net.client() ?
|
||||
"chat.open: " + ui.chatfrag.chatOpen() + "\n" +
|
||||
"chat.messages: " + ui.chatfrag.getMessagesSize() + "\n" +
|
||||
"client.connecting: " + netClient.isConnecting() + "\n" +
|
||||
"client.hasdata: " + netClient.hasData() : "",
|
||||
"client.connecting: " + netClient.isConnecting() + "\n" : "",
|
||||
"players: " + playerGroup.size(),
|
||||
"enemies: " + enemyGroup.size(),
|
||||
"tiles: " + tileGroup.size(),
|
||||
|
||||
@@ -130,6 +130,7 @@ public class Block extends BaseBlock {
|
||||
public void configure(Tile tile, byte data){}
|
||||
|
||||
public void setConfigure(Tile tile, byte data){
|
||||
configure(tile, data);
|
||||
if(Net.active()) NetEvents.handleBlockConfig(tile, data);
|
||||
configure(tile, data);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ public class WeaponBlocks{
|
||||
reload = 13f;
|
||||
bullet = BulletType.stone;
|
||||
ammo = Item.stone;
|
||||
health = 55;
|
||||
health = 45;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user