mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-19 03:03:59 +07:00
Fixed importing saves / File chooser bad size
This commit is contained in:
parent
fa0d89b6df
commit
2c97a4aefe
@ -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.confirm=Are you sure you want to delete this save?
|
||||||
text.save.delete=Delete
|
text.save.delete=Delete
|
||||||
text.save.export=Export Save
|
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.import.fail=[crimson]Failed to import save: [orange]{0}
|
||||||
text.save.export.fail=[crimson]Failed to export save: [orange]{0}
|
text.save.export.fail=[crimson]Failed to export save: [orange]{0}
|
||||||
text.save.import=Import Save
|
text.save.import=Import Save
|
||||||
|
@ -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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.meta.BlockBar" />
|
||||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.mapgen.WorldGenerator" />
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.world.mapgen.WorldGenerator" />
|
||||||
|
@ -74,7 +74,7 @@ public class SaveIO{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSaveValid(FileHandle file){
|
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){
|
public static boolean isSaveValid(DataInputStream stream){
|
||||||
@ -85,6 +85,7 @@ public class SaveIO{
|
|||||||
ver.getData(stream);
|
ver.getData(stream);
|
||||||
return true;
|
return true;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class FileChooser extends FloatingDialog {
|
|||||||
content.add(icontable).expandX().fillX();
|
content.add(icontable).expandX().fillX();
|
||||||
content.row();
|
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();
|
content.row();
|
||||||
|
|
||||||
if(!open){
|
if(!open){
|
||||||
|
@ -107,6 +107,7 @@ public class BuildBlock extends Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawLayer(Tile tile) {
|
public void drawLayer(Tile tile) {
|
||||||
|
|
||||||
BuildEntity entity = tile.entity();
|
BuildEntity entity = tile.entity();
|
||||||
|
|
||||||
Shaders.blockbuild.color = Palette.accent;
|
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.*/
|
* If there is no recipe for this block, as is the case with rocks, 'previous' is used.*/
|
||||||
public Recipe recipe;
|
public Recipe recipe;
|
||||||
|
|
||||||
public double progress = 0;
|
public float progress = 0;
|
||||||
public double lastProgress;
|
public float lastProgress;
|
||||||
public double buildCost;
|
public float buildCost;
|
||||||
/**The block that used to be here.
|
/**The block that used to be here.
|
||||||
* If a non-recipe block is being deconstructed, this is the block that is being deconstructed.*/
|
* If a non-recipe block is being deconstructed, this is the block that is being deconstructed.*/
|
||||||
public Block previous;
|
public Block previous;
|
||||||
|
|
||||||
private double[] accumulator;
|
private float[] accumulator;
|
||||||
|
|
||||||
public void construct(Unit builder, TileEntity core, double amount){
|
public void construct(Unit builder, TileEntity core, float amount){
|
||||||
double maxProgress = checkRequired(core.items, amount);
|
float maxProgress = checkRequired(core.items, amount);
|
||||||
|
|
||||||
for (int i = 0; i < recipe.requirements.length; i++) {
|
for (int i = 0; i < recipe.requirements.length; i++) {
|
||||||
accumulator[i] += recipe.requirements[i].amount*maxProgress; //add min amount progressed to the accumulator
|
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);
|
Recipe recipe = Recipe.getByResult(previous);
|
||||||
|
|
||||||
if(recipe != null) {
|
if(recipe != null) {
|
||||||
@ -227,8 +228,8 @@ public class BuildBlock extends Block {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double checkRequired(InventoryModule inventory, double amount){
|
private float checkRequired(InventoryModule inventory, float amount){
|
||||||
double maxProgress = amount;
|
float maxProgress = amount;
|
||||||
|
|
||||||
for(int i = 0; i < recipe.requirements.length; i ++){
|
for(int i = 0; i < recipe.requirements.length; i ++){
|
||||||
int required = (int)(accumulator[i]); //calculate items that are required now
|
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
|
//calculate how many items it can actually use
|
||||||
int maxUse = Math.min(required, inventory.getItem(recipe.requirements[i].item));
|
int maxUse = Math.min(required, inventory.getItem(recipe.requirements[i].item));
|
||||||
//get this as a fraction
|
//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
|
//move max progress down if this fraction is less than 1
|
||||||
maxProgress = Math.min(maxProgress, maxProgress*fraction);
|
maxProgress = Math.min(maxProgress, maxProgress*fraction);
|
||||||
@ -259,7 +260,7 @@ public class BuildBlock extends Block {
|
|||||||
public void setConstruct(Block previous, Recipe recipe){
|
public void setConstruct(Block previous, Recipe recipe){
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
this.previous = previous;
|
this.previous = previous;
|
||||||
this.accumulator = new double[recipe.requirements.length];
|
this.accumulator = new float[recipe.requirements.length];
|
||||||
this.buildCost = recipe.cost;
|
this.buildCost = recipe.cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +269,7 @@ public class BuildBlock extends Block {
|
|||||||
this.progress = 1f;
|
this.progress = 1f;
|
||||||
if(Recipe.getByResult(previous) != null){
|
if(Recipe.getByResult(previous) != null){
|
||||||
this.recipe = Recipe.getByResult(previous);
|
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;
|
this.buildCost = Recipe.getByResult(previous).cost;
|
||||||
}else{
|
}else{
|
||||||
this.buildCost = 20f; //default no-recipe build cost is 20
|
this.buildCost = 20f; //default no-recipe build cost is 20
|
||||||
@ -285,8 +286,8 @@ public class BuildBlock extends Block {
|
|||||||
stream.writeByte(-1);
|
stream.writeByte(-1);
|
||||||
}else{
|
}else{
|
||||||
stream.writeByte(accumulator.length);
|
stream.writeByte(accumulator.length);
|
||||||
for(double d : accumulator){
|
for(float d : accumulator){
|
||||||
stream.writeFloat((float)d);
|
stream.writeFloat(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +300,7 @@ public class BuildBlock extends Block {
|
|||||||
byte acsize = stream.readByte();
|
byte acsize = stream.readByte();
|
||||||
|
|
||||||
if(acsize != -1){
|
if(acsize != -1){
|
||||||
accumulator = new double[acsize];
|
accumulator = new float[acsize];
|
||||||
for (int i = 0; i < acsize; i++) {
|
for (int i = 0; i < acsize; i++) {
|
||||||
accumulator[i] = stream.readFloat();
|
accumulator[i] = stream.readFloat();
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ public class WorldGenerator {
|
|||||||
prepareTiles(tiles, seed, true);
|
prepareTiles(tiles, seed, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class OreEntry{
|
public static class OreEntry{
|
||||||
final float frequency;
|
final float frequency;
|
||||||
final Item item;
|
final Item item;
|
||||||
final Simplex noise;
|
final Simplex noise;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.desktop;
|
package io.anuke.mindustry.desktop;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.io.Version;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.ucore.core.Settings;
|
import io.anuke.ucore.core.Settings;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
@ -16,8 +17,12 @@ public class CrashHandler {
|
|||||||
//TODO send full error report to server via HTTP
|
//TODO send full error report to server via HTTP
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
|
boolean netActive = false, netServer = false;
|
||||||
|
|
||||||
//attempt to close connections, if applicable
|
//attempt to close connections, if applicable
|
||||||
try{
|
try{
|
||||||
|
netActive = Net.active();
|
||||||
|
netServer = Net.server();
|
||||||
Net.dispose();
|
Net.dispose();
|
||||||
}catch (Throwable p){
|
}catch (Throwable p){
|
||||||
p.printStackTrace();
|
p.printStackTrace();
|
||||||
@ -26,15 +31,17 @@ public class CrashHandler {
|
|||||||
//don't create crash logs for me (anuke), as it's expected
|
//don't create crash logs for me (anuke), as it's expected
|
||||||
if(System.getProperty("user.name").equals("anuke")) return;
|
if(System.getProperty("user.name").equals("anuke")) return;
|
||||||
|
|
||||||
String header = "";
|
String header = "--CRASH REPORT--\n";
|
||||||
|
|
||||||
try{
|
try{
|
||||||
header += "--GAME INFO-- \n";
|
header += "--GAME INFO-- \n";
|
||||||
header += "Multithreading: " + Settings.getBool("multithread")+ "\n";
|
header += "Build: " + Version.build + "\n";
|
||||||
header += "Net Active: " + Net.active()+ "\n";
|
header += "Net Active: " + netActive + "\n";
|
||||||
header += "Net Server: " + Net.server()+ "\n";
|
header += "Net Server: " + netServer + "\n";
|
||||||
header += "OS: " + System.getProperty("os.name")+ "\n----\n";
|
header += "OS: " + System.getProperty("os.name")+ "\n----\n";
|
||||||
|
header += "Multithreading: " + Settings.getBool("multithread")+ "\n";
|
||||||
}catch (Throwable e4){
|
}catch (Throwable e4){
|
||||||
|
header += "[Error getting additional game info.]\n";
|
||||||
e4.printStackTrace();
|
e4.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user