Moved pref saving to specific locations

This commit is contained in:
Anuken
2020-07-02 10:20:16 -04:00
parent 5f6c71b9d3
commit fd2deb0a82
15 changed files with 53 additions and 10 deletions

View File

@@ -327,6 +327,7 @@ public class Vars implements Loadable{
settings.defaults("locale", "default", "blocksync", true);
keybinds.setDefaults(Binding.values());
settings.setAutosave(false);
settings.load();
Scl.setProduct(settings.getInt("uiscale", 100) / 100f);

View File

@@ -178,6 +178,7 @@ public class Control implements ApplicationListener, Loadable{
Effects.shake(5f, 5f, core);
});
});
}
@Override

View File

@@ -96,7 +96,6 @@ public class Logic implements ApplicationListener{
//SectorDamage.apply(seconds);
//}
//add resources based on turns passed
if(state.rules.sector.save != null && core != null){
@@ -126,6 +125,9 @@ public class Logic implements ApplicationListener{
//enable infinite ammo for wave team by default
state.rules.waveTeam.rules().infiniteAmmo = true;
//save settings
Core.settings.manualSave();
});
}
@@ -161,6 +163,9 @@ public class Logic implements ApplicationListener{
Groups.all.clear();
Time.clear();
Events.fire(new ResetEvent());
//save settings on reset
Core.settings.manualSave();
}
public void runWave(){
@@ -295,6 +300,12 @@ public class Logic implements ApplicationListener{
netClient.setQuiet();
}
@Override
public void dispose(){
//save the settings before quitting
Core.settings.manualSave();
}
@Override
public void update(){
Events.fire(Trigger.update);

View File

@@ -18,6 +18,7 @@ import java.io.*;
import java.text.*;
import java.util.*;
import static arc.Core.*;
import static mindustry.Vars.net;
public class CrashSender{
@@ -39,6 +40,11 @@ public class CrashSender{
try{
exception.printStackTrace();
//try saving game data
try{
settings.manualSave();
}catch(Throwable ignored){}
//don't create crash logs for custom builds, as it's expected
if(Version.build == -1 || (System.getProperty("user.name").equals("anuke") && "release".equals(Version.modifier))){
ret();

View File

@@ -293,11 +293,11 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
stable.table(t -> {
t.left();
sector.save.meta.secinfo.exportRates().each(entry -> {
int total = (int)(entry.value * eventRate / 60f);
sector.save.meta.secinfo.production.each((item, stat) -> {
int total = (int)(stat.mean * 60);
if(total > 1){
t.image(entry.key.icon(Cicon.small)).padRight(3);
t.add(ui.formatAmount(total) + " /turn").color(Color.lightGray);
t.image(item.icon(Cicon.small)).padRight(3);
t.add(ui.formatAmount(total) + " /min").color(Color.lightGray);
t.row();
}
});

View File

@@ -17,12 +17,12 @@ public class SurgeWall extends Wall{
public class SurgeEntity extends Building{
@Override
public boolean collision(Bullet bullet){
super.collision(bullet);
if(Mathf.chance(lightningChance)){
Lightning.create(team(), Pal.surge, lightningDamage, x, y, bullet.rotation() + 180f, lightningLength);
}
return true;
return super.collision(bullet);
}
}
}