Usage of ExtendedPreferences
This commit is contained in:
@@ -30,6 +30,7 @@ import java.util.Locale;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Vars{
|
||||
public static final String appName = "Mindustry";
|
||||
public static final String discordURL = "https://discord.gg/mindustry";
|
||||
public static final String releasesURL = "https://api.github.com/repos/Anuken/Mindustry/releases";
|
||||
public static final String crashReportURL = "http://mindustry.us.to/report";
|
||||
@@ -174,7 +175,7 @@ public class Vars{
|
||||
gwt = Gdx.app.getType() == ApplicationType.WebGL;
|
||||
|
||||
if(!gwt){
|
||||
dataDirectory = OS.getAppDataDirectory("Mindustry");
|
||||
dataDirectory = OS.getAppDataDirectory(appName);
|
||||
customMapDirectory = dataDirectory.child("maps/");
|
||||
saveDirectory = dataDirectory.child("saves/");
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Saves{
|
||||
|
||||
public void load(){
|
||||
saves.clear();
|
||||
IntArray slots = Settings.getBinary("save-slots", IntArray.class, IntArray::new);
|
||||
IntArray slots = Settings.getObject("save-slots", IntArray.class, IntArray::new);
|
||||
|
||||
for(int i = 0; i < slots.size; i ++){
|
||||
int index = slots.get(i);
|
||||
@@ -143,7 +143,7 @@ public class Saves{
|
||||
IntArray result = new IntArray(saves.size);
|
||||
for(int i = 0; i < saves.size; i++) result.add(saves.get(i).index);
|
||||
|
||||
Settings.putBinary("save-slots", result);
|
||||
Settings.putObject("save-slots", result);
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Unlocks{
|
||||
public void load(){
|
||||
sets.clear();
|
||||
|
||||
ObjectMap<String, ObjectMap<ContentType, Array<String>>> result = Settings.getBinary("content-sets", ObjectMap.class, () -> new ObjectMap<>());
|
||||
ObjectMap<String, ObjectMap<ContentType, Array<String>>> result = Settings.getObject("content-sets", ObjectMap.class, () -> new ObjectMap<>());
|
||||
|
||||
for(Entry<String, ObjectMap<ContentType, Array<String>>> outer : result.entries()){
|
||||
ContentUnlockSet cset = new ContentUnlockSet();
|
||||
@@ -102,7 +102,7 @@ public class Unlocks{
|
||||
output.put(centry.key, write);
|
||||
}
|
||||
|
||||
Settings.putBinary("content-sets", output);
|
||||
Settings.putObject("content-sets", output);
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class BundleLoader{
|
||||
|
||||
public static void load(){
|
||||
Settings.defaults("locale", "default");
|
||||
Settings.load(headless ? "io.anuke.mindustry.server" : "io.anuke.mindustry");
|
||||
Settings.load(Vars.appName, headless ? "io.anuke.mindustry.server" : "io.anuke.mindustry");
|
||||
loadBundle();
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Maps implements Disposable{
|
||||
Settings.putString("map-data-" + name, new String(Base64Coder.encode(stream.toByteArray())));
|
||||
if(!customMapNames.contains(name, false)){
|
||||
customMapNames.add(name);
|
||||
Settings.putBinary("custom-maps", customMapNames);
|
||||
Settings.putObject("custom-maps", customMapNames);
|
||||
}
|
||||
Settings.save();
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class Maps implements Disposable{
|
||||
} else {
|
||||
customMapNames.removeValue(map.name, false);
|
||||
Settings.putString("map-data-" + map.name, "");
|
||||
Settings.putBinary("custom-maps", customMapNames);
|
||||
Settings.putObject("custom-maps", customMapNames);
|
||||
Settings.save();
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class Maps implements Disposable{
|
||||
}
|
||||
|
||||
}else{
|
||||
customMapNames = Settings.getBinary("custom-maps", Array.class, () -> new Array<>());
|
||||
customMapNames = Settings.getObject("custom-maps", Array.class, () -> new Array<>());
|
||||
|
||||
for(String name : customMapNames){
|
||||
try{
|
||||
|
||||
@@ -262,7 +262,7 @@ public class Sectors{
|
||||
}
|
||||
grid.clear();
|
||||
|
||||
Array<Sector> out = Settings.getBinary("sectors", Array.class, () -> new Array<>());
|
||||
Array<Sector> out = Settings.getObject("sectors", Array.class, () -> new Array<>());
|
||||
|
||||
for(Sector sector : out){
|
||||
createTexture(sector);
|
||||
@@ -286,7 +286,7 @@ public class Sectors{
|
||||
out.add(sector);
|
||||
}
|
||||
|
||||
Settings.putBinary("sectors", out);
|
||||
Settings.putObject("sectors", out);
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
||||
@@ -270,14 +270,14 @@ public class Administration{
|
||||
}
|
||||
|
||||
public void save(){
|
||||
Settings.putBinary("player-info", playerInfo);
|
||||
Settings.putBinary("banned-ips", bannedIPs);
|
||||
Settings.putObject("player-info", playerInfo);
|
||||
Settings.putObject("banned-ips", bannedIPs);
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
private void load(){
|
||||
playerInfo = Settings.getBinary("player-info", ObjectMap.class, () -> new ObjectMap<>());
|
||||
bannedIPs = Settings.getBinary("banned-ips", Array.class, () -> new Array<>());
|
||||
playerInfo = Settings.getObject("player-info", ObjectMap.class, () -> new ObjectMap<>());
|
||||
bannedIPs = Settings.getObject("banned-ips", Array.class, () -> new Array<>());
|
||||
}
|
||||
|
||||
@Serialize
|
||||
|
||||
@@ -327,11 +327,11 @@ public class JoinDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
private void loadServers(){
|
||||
servers = Settings.getBinary("server-list", Array.class, () -> new Array<>());
|
||||
servers = Settings.getObject("server-list", Array.class, () -> new Array<>());
|
||||
}
|
||||
|
||||
private void saveServers(){
|
||||
Settings.putBinary("server-list", servers);
|
||||
Settings.putObject("server-list", servers);
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user