Fixed bug with conveyor belt rotation not being saved
This commit is contained in:
@@ -56,7 +56,7 @@ public class Control extends RendererModule{
|
||||
|
||||
Draw.addSurface("shadow", cameraScale);
|
||||
|
||||
atlas = new Atlas("mindustry.atlas");
|
||||
atlas = new Atlas("sprites.atlas");
|
||||
|
||||
Sounds.load("shoot.wav", "place.wav", "explosion.wav", "enemyshoot.wav",
|
||||
"corexplode.wav", "break.wav", "spawn.wav", "flame.wav", "die.wav",
|
||||
|
||||
@@ -62,7 +62,7 @@ public class UI extends SceneModule{
|
||||
Dialog.closePadT = 4;
|
||||
|
||||
Textures.load("sprites/");
|
||||
Textures.repeatWrap("conveyor", "conveyort", "back");
|
||||
Textures.repeatWrap("conveyort", "back");
|
||||
}
|
||||
|
||||
void drawBackground(){
|
||||
@@ -400,12 +400,14 @@ public class UI extends SceneModule{
|
||||
new button("Play", () -> {
|
||||
levels.show();
|
||||
});
|
||||
|
||||
row();
|
||||
|
||||
new button("Load Game", () -> {
|
||||
load.show();
|
||||
});
|
||||
if(Gdx.app.getType() != ApplicationType.WebGL){
|
||||
row();
|
||||
|
||||
new button("Load Game", () -> {
|
||||
load.show();
|
||||
});
|
||||
}
|
||||
|
||||
row();
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package io.anuke.mindustry.io;
|
||||
|
||||
import static io.anuke.mindustry.Vars.android;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
@@ -66,6 +67,7 @@ import io.anuke.ucore.entities.Entity;
|
||||
* Tile type (boolean)- whether the block has a tile entity attached
|
||||
* Block ID - the block ID
|
||||
* (the following only applies to tile entity blocks)
|
||||
* Block rotation (byte)
|
||||
* Block health (int)
|
||||
* Amount of items (byte)
|
||||
* (item list)
|
||||
@@ -75,9 +77,9 @@ import io.anuke.ucore.entities.Entity;
|
||||
*/
|
||||
public class SaveIO{
|
||||
/**Save file version ID. Should be incremented every breaking release.*/
|
||||
private static final int fileVersionID = 0;
|
||||
private static final int fileVersionID = 2;
|
||||
|
||||
private static final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
|
||||
private static FormatProvider provider = null;
|
||||
|
||||
//TODO automatic registration of types?
|
||||
private static final ObjectMap<Class<? extends Enemy>, Byte> enemyIDs = new ObjectMap<Class<? extends Enemy>, Byte>(){{
|
||||
@@ -113,7 +115,7 @@ public class SaveIO{
|
||||
try(DataInputStream stream = new DataInputStream(fileFor(slot).read())){
|
||||
stream.readInt();
|
||||
Date date = new Date(stream.readLong());
|
||||
return format.format(date);
|
||||
return provider.format(date);
|
||||
}catch (IOException e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -123,6 +125,10 @@ public class SaveIO{
|
||||
return Gdx.files.local("mindustry-saves/" + slot + ".mins");
|
||||
}
|
||||
|
||||
public static void setFormatProvider(FormatProvider prov){
|
||||
provider = prov;
|
||||
}
|
||||
|
||||
public static void write(FileHandle file){
|
||||
|
||||
try(DataOutputStream stream = new DataOutputStream(file.write(false))){
|
||||
@@ -212,6 +218,7 @@ public class SaveIO{
|
||||
stream.writeInt(tile.block().id); //block ID
|
||||
|
||||
if(tile.entity != null){
|
||||
stream.writeByte(tile.rotation);
|
||||
stream.writeInt(tile.entity.health); //health
|
||||
stream.writeByte(tile.entity.items.size); //amount of items
|
||||
|
||||
@@ -282,6 +289,8 @@ public class SaveIO{
|
||||
|
||||
//enemies
|
||||
|
||||
Entities.clear();
|
||||
|
||||
int enemies = stream.readInt();
|
||||
|
||||
for(int i = 0; i < enemies; i ++){
|
||||
@@ -304,6 +313,9 @@ public class SaveIO{
|
||||
|
||||
Vars.control.setWaveData(enemies, wave, wavetime);
|
||||
|
||||
if(!android)
|
||||
Vars.player.add();
|
||||
|
||||
//map
|
||||
|
||||
int mapid = stream.readByte();
|
||||
@@ -333,10 +345,12 @@ public class SaveIO{
|
||||
tile.setBlock(Block.getByID(blockid));
|
||||
|
||||
if(hasEntity){
|
||||
int rotation = stream.readByte();
|
||||
int health = stream.readInt();
|
||||
int items = stream.readByte();
|
||||
|
||||
tile.entity.health = health;
|
||||
tile.rotation = rotation;
|
||||
|
||||
for(int j = 0; j < items; j ++){
|
||||
int itemid = stream.readByte();
|
||||
@@ -350,4 +364,8 @@ public class SaveIO{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static interface FormatProvider{
|
||||
public String format(Date date);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class LevelDialog extends Dialog{
|
||||
Timers.run(18, ()->{
|
||||
Vars.ui.hideLoading();
|
||||
});
|
||||
});
|
||||
}).pad(3).size(180, 44).units(Unit.dp);
|
||||
|
||||
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
|
||||
|
||||
|
||||
@@ -2,11 +2,15 @@ package io.anuke.mindustry.ui;
|
||||
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
import com.badlogic.gdx.Application.ApplicationType;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
|
||||
import io.anuke.mindustry.GameState;
|
||||
import io.anuke.mindustry.GameState.State;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.ucore.scene.ui.ConfirmDialog;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class MenuDialog extends Dialog{
|
||||
@@ -38,22 +42,27 @@ public class MenuDialog extends Dialog{
|
||||
});
|
||||
}
|
||||
|
||||
content().row();
|
||||
content().addButton("Save Game", ()->{
|
||||
save.show();
|
||||
});
|
||||
if(Gdx.app.getType() != ApplicationType.WebGL){
|
||||
content().row();
|
||||
content().addButton("Save Game", ()->{
|
||||
save.show();
|
||||
});
|
||||
|
||||
content().row();
|
||||
content().addButton("Load Game", ()->{
|
||||
load.show();
|
||||
});
|
||||
content().row();
|
||||
content().addButton("Load Game", ()->{
|
||||
load.show();
|
||||
});
|
||||
}
|
||||
|
||||
content().row();
|
||||
content().addButton("Back to menu", ()->{
|
||||
new ConfirmDialog("Confirm", "Are you sure you want to quit?", ()->{
|
||||
hide();
|
||||
GameState.set(State.menu);
|
||||
}).show();
|
||||
}){{
|
||||
for(Cell<?> cell : getButtonTable().getCells())
|
||||
cell.pad(3).size(180, 44).units(Unit.dp);
|
||||
}}.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.anuke.mindustry.GameState;
|
||||
import io.anuke.mindustry.GameState.State;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.scene.ui.TextDialog;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class TutorialDialog extends TextDialog{
|
||||
|
||||
@@ -23,7 +24,7 @@ public class TutorialDialog extends TextDialog{
|
||||
|
||||
getButtonTable().addButton("OK", ()->{
|
||||
hide();
|
||||
});
|
||||
}).pad(2).size(180, 44).units(Unit.dp);
|
||||
|
||||
content().pad(8);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user