mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-04 15:27:19 +07:00
Switched to binary preference file for desktop
This commit is contained in:
@ -26,7 +26,7 @@ public abstract class BulletType extends BaseBulletType<Bullet> implements Conte
|
||||
/**Whether to sync this bullet to clients.*/
|
||||
public boolean syncable;
|
||||
/**Whether this bullet type collides with tiles.*/
|
||||
public boolean collidesTiles;
|
||||
public boolean collidesTiles = true;
|
||||
|
||||
public BulletType(float speed, float damage){
|
||||
this.id = lastid ++;
|
||||
|
@ -1,11 +1,15 @@
|
||||
package io.anuke.mindustry.desktop;
|
||||
|
||||
import com.apple.eawt.Application;
|
||||
import com.badlogic.gdx.ApplicationListener;
|
||||
import com.badlogic.gdx.Files.FileType;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import io.anuke.kryonet.KryoClient;
|
||||
import io.anuke.kryonet.KryoServer;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
@ -13,6 +17,7 @@ import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.io.Saves.SaveSlot;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.io.BinaryPreferences;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.OS;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
@ -23,7 +28,8 @@ import java.util.List;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class DesktopLauncher {
|
||||
public class DesktopLauncher extends Lwjgl3Application{
|
||||
ObjectMap<String, Preferences> prefmap;
|
||||
|
||||
public static void main (String[] arg) {
|
||||
|
||||
@ -70,17 +76,36 @@ public class DesktopLauncher {
|
||||
});
|
||||
}
|
||||
|
||||
config.setPreferencesConfig(OS.getAppDataDirectoryString("Mindustry"), FileType.Absolute);
|
||||
|
||||
Platform.instance = new DesktopPlatform(arg);
|
||||
|
||||
Net.setClientProvider(new KryoClient());
|
||||
Net.setServerProvider(new KryoServer());
|
||||
|
||||
try {
|
||||
new Lwjgl3Application(new Mindustry(), config);
|
||||
new DesktopLauncher(new Mindustry(), config);
|
||||
}catch (Throwable e){
|
||||
CrashHandler.handle(e);
|
||||
}
|
||||
}
|
||||
|
||||
public DesktopLauncher(ApplicationListener listener, Lwjgl3ApplicationConfiguration config) {
|
||||
super(listener, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Preferences getPreferences(String name) {
|
||||
String prefsDirectory = OS.getAppDataDirectoryString("Mindustry");
|
||||
|
||||
if(prefmap == null){
|
||||
prefmap = new ObjectMap<>();
|
||||
}
|
||||
|
||||
if(prefmap.containsKey(name)){
|
||||
return prefmap.get(name);
|
||||
}else{
|
||||
Preferences prefs = new BinaryPreferences(new Lwjgl3FileHandle(new File(prefsDirectory, name), FileType.Absolute));
|
||||
prefmap.put(name, prefs);
|
||||
return prefs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,20 +2,33 @@ package io.anuke.mindustry.server;
|
||||
|
||||
import com.badlogic.gdx.ApplicationListener;
|
||||
import com.badlogic.gdx.ApplicationLogger;
|
||||
import com.badlogic.gdx.Files.FileType;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.backends.headless.HeadlessApplication;
|
||||
import com.badlogic.gdx.backends.headless.HeadlessApplicationConfiguration;
|
||||
import com.badlogic.gdx.backends.headless.HeadlessFileHandle;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import io.anuke.kryonet.KryoClient;
|
||||
import io.anuke.kryonet.KryoServer;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.io.BinaryPreferences;
|
||||
import io.anuke.ucore.util.OS;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ServerLauncher extends HeadlessApplication{
|
||||
ObjectMap<String, Preferences> prefmap;
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
Net.setClientProvider(new KryoClient());
|
||||
Net.setServerProvider(new KryoServer());
|
||||
|
||||
new ServerLauncher(new MindustryServer(args));
|
||||
HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration();
|
||||
config.preferencesDirectory = OS.getAppDataDirectoryString("Mindustry");
|
||||
|
||||
new ServerLauncher(new MindustryServer(args), config);
|
||||
|
||||
//find and handle uncaught exceptions in libGDX thread
|
||||
for(Thread thread : Thread.getAllStackTraces().keySet()){
|
||||
@ -29,8 +42,8 @@ public class ServerLauncher extends HeadlessApplication{
|
||||
}
|
||||
}
|
||||
|
||||
public ServerLauncher(ApplicationListener listener) {
|
||||
super(listener);
|
||||
public ServerLauncher(ApplicationListener listener, HeadlessApplicationConfiguration config) {
|
||||
super(listener, config);
|
||||
|
||||
//don't do anything at all for GDX logging: don't want controller info and such
|
||||
Gdx.app.setApplicationLogger(new ApplicationLogger() {
|
||||
@ -42,4 +55,21 @@ public class ServerLauncher extends HeadlessApplication{
|
||||
@Override public void debug(String tag, String message, Throwable exception) { }
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Preferences getPreferences(String name) {
|
||||
String prefsDirectory = OS.getAppDataDirectoryString("Mindustry");
|
||||
|
||||
if(prefmap == null){
|
||||
prefmap = new ObjectMap<>();
|
||||
}
|
||||
|
||||
if(prefmap.containsKey(name)){
|
||||
return prefmap.get(name);
|
||||
}else{
|
||||
Preferences prefs = new BinaryPreferences(new HeadlessFileHandle(new File(prefsDirectory, name), FileType.Absolute));
|
||||
prefmap.put(name, prefs);
|
||||
return prefs;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user