Merge branch 'master' into multiplayer
This commit is contained in:
@@ -2,12 +2,23 @@ package io.anuke.mindustry.core;
|
||||
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.Packets.Connect;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
|
||||
public class NetClient extends Module {
|
||||
|
||||
public NetClient(){
|
||||
|
||||
Net.handle(Connect.class, packet -> {
|
||||
Gdx.app.postRunnable(() -> {
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.showLoading("$text.connecting.data");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void update(){
|
||||
|
||||
@@ -248,7 +248,7 @@ public class UI extends SceneModule{
|
||||
prefs.game.checkPref("indicators", true);
|
||||
prefs.game.checkPref("effects", true);
|
||||
prefs.game.sliderPref("sensitivity", 100, 10, 300, i -> i + "%");
|
||||
prefs.game.sliderPref("saveinterval", 120, 15, 5*120, i -> Bundles.format("setting.seconds", i));
|
||||
prefs.game.sliderPref("saveinterval", 90, 15, 5*120, i -> Bundles.format("setting.seconds", i));
|
||||
|
||||
prefs.graphics.checkPref("fps", false);
|
||||
prefs.graphics.checkPref("vsync", true, b -> Gdx.graphics.setVSync(b));
|
||||
|
||||
@@ -37,6 +37,10 @@ public class Saves {
|
||||
}
|
||||
}
|
||||
|
||||
public SaveSlot getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if(!GameState.is(State.menu) && !GameState.is(State.dead) && current != null && current.isAutosave()){
|
||||
time += Timers.delta();
|
||||
@@ -94,7 +98,7 @@ public class Saves {
|
||||
|
||||
public void save(){
|
||||
current = this;
|
||||
SaveIO.isSaveValid(index);
|
||||
SaveIO.saveToSlot(index);
|
||||
}
|
||||
|
||||
public String getDate(){
|
||||
@@ -152,7 +156,9 @@ public class Saves {
|
||||
|
||||
public void delete(){
|
||||
SaveIO.fileFor(index).delete();
|
||||
load();
|
||||
if(this == current){
|
||||
current = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,7 @@ public class Packets {
|
||||
public String addressTCP;
|
||||
}
|
||||
|
||||
public static class WorldData {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,13 @@ package io.anuke.mindustry.ui;
|
||||
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.UCore;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.builders.build;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
@@ -78,7 +81,8 @@ public class MenuDialog extends FloatingDialog{
|
||||
content().row();
|
||||
|
||||
content().addButton("$text.quit", () -> {
|
||||
Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||
Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||
runSave();
|
||||
hide();
|
||||
GameState.set(State.menu);
|
||||
});
|
||||
@@ -106,6 +110,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
|
||||
new imagebutton("icon-quit", isize, () -> {
|
||||
Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||
runSave();
|
||||
hide();
|
||||
GameState.set(State.menu);
|
||||
});
|
||||
@@ -120,4 +125,22 @@ public class MenuDialog extends FloatingDialog{
|
||||
build.end();
|
||||
}
|
||||
}
|
||||
|
||||
private void runSave(){
|
||||
if(Vars.control.getSaves().getCurrent() == null ||
|
||||
!Vars.control.getSaves().getCurrent().isAutosave()) return;
|
||||
|
||||
Vars.ui.showLoading("$text.saveload");
|
||||
|
||||
Timers.runTask(5f, () -> {
|
||||
Vars.ui.hideLoading();
|
||||
try{
|
||||
Vars.control.getSaves().getCurrent().save();
|
||||
}catch(Throwable e){
|
||||
e = (e.getCause() == null ? e : e.getCause());
|
||||
|
||||
Vars.ui.showError("[orange]"+ Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class SaveDialog extends LoadDialog{
|
||||
}
|
||||
|
||||
void save(SaveSlot slot){
|
||||
|
||||
Vars.ui.showLoading("$text.saveload");
|
||||
|
||||
Timers.runTask(5f, () -> {
|
||||
|
||||
@@ -149,11 +149,11 @@ public class Tile{
|
||||
public byte getExtra(){
|
||||
return Bits.getRightByte(Bits.getRightByte(data));
|
||||
}
|
||||
|
||||
|
||||
public boolean passable(){
|
||||
Block block = block();
|
||||
Block floor = floor();
|
||||
return isLinked() || !(floor.solid || (block.solid && (!block.destructible && !block.update)));
|
||||
return isLinked() || !((floor.solid && (block == Blocks.air || block.solidifes)) || (block.solid && (!block.destructible && !block.update)));
|
||||
}
|
||||
|
||||
public boolean solid(){
|
||||
|
||||
@@ -164,6 +164,11 @@ public class ProductionBlocks{
|
||||
tryDump(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLayer(Tile tile){
|
||||
return tile.floor().drops == null;
|
||||
}
|
||||
},
|
||||
coalgenerator = new ItemPowerGenerator("coalgenerator"){
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user