Fixed importing saves / File chooser bad size

This commit is contained in:
Anuken 2018-07-06 09:52:18 -04:00
parent fa0d89b6df
commit 2c97a4aefe
7 changed files with 33 additions and 27 deletions

View File

@ -141,7 +141,7 @@ text.savefail=Failed to save game!
text.save.delete.confirm=Are you sure you want to delete this save?
text.save.delete=Delete
text.save.export=Export Save
text.save.import.invalid=[orange]This save is invalid!\n\nNote that[scarlet]importing saves with custom maps[orange]\nfrom other devices does not work!
text.save.import.invalid=[orange]This save is invalid!
text.save.import.fail=[crimson]Failed to import save: [orange]{0}
text.save.export.fail=[crimson]Failed to export save: [orange]{0}
text.save.import=Import Save

View File

@ -4,20 +4,17 @@
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.Tile" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.game.Content" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.io.Maps" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.Player" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.units.BaseUnit" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.Map" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.game.SpawnGroup" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.core.GameState" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.game.EventType" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.io.SaveFileVersion" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.type.Recipe" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.ucore.entities.impl.EffectEntity" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.net.Packets" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.net.Packet" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.effect" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.bullet.Bullet" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.type.Recipe" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.game.Team" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.net.Streamable" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.meta.BlockBar" />
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.mapgen.WorldGenerator" />

View File

@ -74,7 +74,7 @@ public class SaveIO{
}
public static boolean isSaveValid(FileHandle file){
return isSaveValid(new DataInputStream(file.read()));
return isSaveValid(new DataInputStream(new InflaterInputStream(file.read())));
}
public static boolean isSaveValid(DataInputStream stream){
@ -85,6 +85,7 @@ public class SaveIO{
ver.getData(stream);
return true;
}catch (Exception e){
e.printStackTrace();
return false;
}
}

View File

@ -145,7 +145,7 @@ public class FileChooser extends FloatingDialog {
content.add(icontable).expandX().fillX();
content.row();
content.center().add(pane).width(UIUtils.portrait() ? Gdx.graphics.getWidth() : Gdx.graphics.getWidth()/Unit.dp.scl(2)).colspan(3).grow();
content.center().add(pane).width(UIUtils.portrait() ? Gdx.graphics.getWidth()/Unit.dp.scl(1) : Gdx.graphics.getWidth()/Unit.dp.scl(2)).colspan(3).grow();
content.row();
if(!open){

View File

@ -107,6 +107,7 @@ public class BuildBlock extends Block {
@Override
public void drawLayer(Tile tile) {
BuildEntity entity = tile.entity();
Shaders.blockbuild.color = Palette.accent;
@ -174,17 +175,17 @@ public class BuildBlock extends Block {
* If there is no recipe for this block, as is the case with rocks, 'previous' is used.*/
public Recipe recipe;
public double progress = 0;
public double lastProgress;
public double buildCost;
public float progress = 0;
public float lastProgress;
public float buildCost;
/**The block that used to be here.
* If a non-recipe block is being deconstructed, this is the block that is being deconstructed.*/
public Block previous;
private double[] accumulator;
private float[] accumulator;
public void construct(Unit builder, TileEntity core, double amount){
double maxProgress = checkRequired(core.items, amount);
public void construct(Unit builder, TileEntity core, float amount){
float maxProgress = checkRequired(core.items, amount);
for (int i = 0; i < recipe.requirements.length; i++) {
accumulator[i] += recipe.requirements[i].amount*maxProgress; //add min amount progressed to the accumulator
@ -201,7 +202,7 @@ public class BuildBlock extends Block {
}
}
public void deconstruct(Unit builder, TileEntity core, double amount){
public void deconstruct(Unit builder, TileEntity core, float amount){
Recipe recipe = Recipe.getByResult(previous);
if(recipe != null) {
@ -227,8 +228,8 @@ public class BuildBlock extends Block {
}
}
private double checkRequired(InventoryModule inventory, double amount){
double maxProgress = amount;
private float checkRequired(InventoryModule inventory, float amount){
float maxProgress = amount;
for(int i = 0; i < recipe.requirements.length; i ++){
int required = (int)(accumulator[i]); //calculate items that are required now
@ -237,7 +238,7 @@ public class BuildBlock extends Block {
//calculate how many items it can actually use
int maxUse = Math.min(required, inventory.getItem(recipe.requirements[i].item));
//get this as a fraction
double fraction = maxUse / (double)required;
float fraction = maxUse / (float)required;
//move max progress down if this fraction is less than 1
maxProgress = Math.min(maxProgress, maxProgress*fraction);
@ -259,7 +260,7 @@ public class BuildBlock extends Block {
public void setConstruct(Block previous, Recipe recipe){
this.recipe = recipe;
this.previous = previous;
this.accumulator = new double[recipe.requirements.length];
this.accumulator = new float[recipe.requirements.length];
this.buildCost = recipe.cost;
}
@ -268,7 +269,7 @@ public class BuildBlock extends Block {
this.progress = 1f;
if(Recipe.getByResult(previous) != null){
this.recipe = Recipe.getByResult(previous);
this.accumulator = new double[Recipe.getByResult(previous).requirements.length];
this.accumulator = new float[Recipe.getByResult(previous).requirements.length];
this.buildCost = Recipe.getByResult(previous).cost;
}else{
this.buildCost = 20f; //default no-recipe build cost is 20
@ -285,8 +286,8 @@ public class BuildBlock extends Block {
stream.writeByte(-1);
}else{
stream.writeByte(accumulator.length);
for(double d : accumulator){
stream.writeFloat((float)d);
for(float d : accumulator){
stream.writeFloat(d);
}
}
}
@ -299,7 +300,7 @@ public class BuildBlock extends Block {
byte acsize = stream.readByte();
if(acsize != -1){
accumulator = new double[acsize];
accumulator = new float[acsize];
for (int i = 0; i < acsize; i++) {
accumulator[i] = stream.readFloat();
}

View File

@ -240,7 +240,7 @@ public class WorldGenerator {
prepareTiles(tiles, seed, true);
}
static class OreEntry{
public static class OreEntry{
final float frequency;
final Item item;
final Simplex noise;

View File

@ -1,5 +1,6 @@
package io.anuke.mindustry.desktop;
import io.anuke.mindustry.io.Version;
import io.anuke.mindustry.net.Net;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.util.Strings;
@ -16,8 +17,12 @@ public class CrashHandler {
//TODO send full error report to server via HTTP
e.printStackTrace();
boolean netActive = false, netServer = false;
//attempt to close connections, if applicable
try{
netActive = Net.active();
netServer = Net.server();
Net.dispose();
}catch (Throwable p){
p.printStackTrace();
@ -26,15 +31,17 @@ public class CrashHandler {
//don't create crash logs for me (anuke), as it's expected
if(System.getProperty("user.name").equals("anuke")) return;
String header = "";
String header = "--CRASH REPORT--\n";
try{
header += "--GAME INFO-- \n";
header += "Multithreading: " + Settings.getBool("multithread")+ "\n";
header += "Net Active: " + Net.active()+ "\n";
header += "Net Server: " + Net.server()+ "\n";
header += "Build: " + Version.build + "\n";
header += "Net Active: " + netActive + "\n";
header += "Net Server: " + netServer + "\n";
header += "OS: " + System.getProperty("os.name")+ "\n----\n";
header += "Multithreading: " + Settings.getBool("multithread")+ "\n";
}catch (Throwable e4){
header += "[Error getting additional game info.]\n";
e4.printStackTrace();
}