Removed html module
This commit is contained in:
@@ -78,8 +78,6 @@ public class Vars{
|
||||
public static boolean mobile;
|
||||
public static boolean ios;
|
||||
public static boolean android;
|
||||
//shorthand for whether or not this is running on GWT
|
||||
public static boolean gwt;
|
||||
//main data directory
|
||||
public static FileHandle dataDirectory;
|
||||
//directory for user-created map data
|
||||
@@ -139,7 +137,7 @@ public class Vars{
|
||||
}
|
||||
}
|
||||
|
||||
Arrays.sort(locales, (l1, l2) -> Platform.instance.getLocaleName(l1).compareTo(Platform.instance.getLocaleName(l2)));
|
||||
Arrays.sort(locales, (l1, l2) -> l1.getDisplayName(l1).compareTo(l2.getDisplayName(l2)));
|
||||
Version.init();
|
||||
|
||||
content = new ContentLoader();
|
||||
@@ -171,13 +169,10 @@ public class Vars{
|
||||
mobile = Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS || testMobile;
|
||||
ios = Gdx.app.getType() == ApplicationType.iOS;
|
||||
android = Gdx.app.getType() == ApplicationType.Android;
|
||||
gwt = Gdx.app.getType() == ApplicationType.WebGL;
|
||||
|
||||
if(!gwt){
|
||||
dataDirectory = OS.getAppDataDirectory(appName);
|
||||
customMapDirectory = dataDirectory.child("maps/");
|
||||
saveDirectory = dataDirectory.child("saves/");
|
||||
}
|
||||
dataDirectory = OS.getAppDataDirectory(appName);
|
||||
customMapDirectory = dataDirectory.child("maps/");
|
||||
saveDirectory = dataDirectory.child("saves/");
|
||||
|
||||
fontScale = Math.max(Unit.dp.scl(1f) / 2f, 0.5f);
|
||||
baseCameraScale = Math.round(Unit.dp.scl(4));
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Control extends Module{
|
||||
saves = new Saves();
|
||||
unlocks = new Unlocks();
|
||||
|
||||
Inputs.useControllers(!gwt);
|
||||
Inputs.useControllers(true);
|
||||
|
||||
Gdx.input.setCatchBackKey(true);
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.scene.ui.TextField;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class Platform {
|
||||
@@ -35,10 +34,6 @@ public abstract class Platform {
|
||||
public boolean canDonate(){
|
||||
return false;
|
||||
}
|
||||
/**Return the localized name for the locale. This is basically a workaround for GWT not supporting getName().*/
|
||||
public String getLocaleName(Locale locale){
|
||||
return locale.toString();
|
||||
}
|
||||
/**Must be a base64 string 8 bytes in length.*/
|
||||
public String getUUID(){
|
||||
String uuid = Settings.getString("uuid", "");
|
||||
@@ -54,8 +49,6 @@ public abstract class Platform {
|
||||
}
|
||||
/**Only used for iOS or android: open the share menu for a map or save.*/
|
||||
public void shareFile(FileHandle file){}
|
||||
/**Download a file. Only used on GWT backend.*/
|
||||
public void downloadFile(String name, byte[] bytes){}
|
||||
|
||||
/**Show a file chooser. Desktop only.
|
||||
*
|
||||
|
||||
@@ -38,7 +38,6 @@ import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -113,73 +112,40 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}, true, mapExtension);
|
||||
},
|
||||
"$text.editor.importimage", "$text.editor.importimage.description", "icon-file-image", (Runnable)() -> {
|
||||
if(gwt){
|
||||
ui.showError("$text.web.unsupported");
|
||||
}else {
|
||||
Platform.instance.showFileChooser("$text.loadimage", "Image Files", file -> {
|
||||
ui.loadGraphics(() -> {
|
||||
try{
|
||||
MapTileData data = MapIO.readLegacyPixmap(new Pixmap(file));
|
||||
Platform.instance.showFileChooser("$text.loadimage", "Image Files", file -> {
|
||||
ui.loadGraphics(() -> {
|
||||
try{
|
||||
MapTileData data = MapIO.readLegacyPixmap(new Pixmap(file));
|
||||
|
||||
editor.beginEdit(data, editor.getTags(), false);
|
||||
view.clearStack();
|
||||
}catch (Exception e){
|
||||
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
||||
Log.err(e);
|
||||
}
|
||||
});
|
||||
}, true, "png");
|
||||
}
|
||||
editor.beginEdit(data, editor.getTags(), false);
|
||||
view.clearStack();
|
||||
}catch (Exception e){
|
||||
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
||||
Log.err(e);
|
||||
}
|
||||
});
|
||||
}, true, "png");
|
||||
}));
|
||||
|
||||
t.addImageTextButton("$text.editor.export", "icon-save-map", isize, () -> createDialog("$text.editor.export",
|
||||
"$text.editor.exportfile", "$text.editor.exportfile.description", "icon-file", (Runnable) () -> {
|
||||
if(!gwt){
|
||||
Platform.instance.showFileChooser("$text.saveimage", "Map Files", file -> {
|
||||
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
||||
FileHandle result = file;
|
||||
ui.loadGraphics(() -> {
|
||||
Platform.instance.showFileChooser("$text.saveimage", "Map Files", file -> {
|
||||
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
||||
FileHandle result = file;
|
||||
ui.loadGraphics(() -> {
|
||||
|
||||
try{
|
||||
if(!editor.getTags().containsKey("name")){
|
||||
editor.getTags().put("name", result.nameWithoutExtension());
|
||||
}
|
||||
MapIO.writeMap(result.write(false), editor.getTags(), editor.getMap());
|
||||
}catch(Exception e){
|
||||
ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
||||
Log.err(e);
|
||||
try{
|
||||
if(!editor.getTags().containsKey("name")){
|
||||
editor.getTags().put("name", result.nameWithoutExtension());
|
||||
}
|
||||
});
|
||||
}, false, mapExtension);
|
||||
}else{
|
||||
try{
|
||||
ByteArrayOutputStream ba = new ByteArrayOutputStream();
|
||||
MapIO.writeMap(ba, editor.getTags(), editor.getMap());
|
||||
Platform.instance.downloadFile(editor.getTags().get("name", "unknown") + "." + mapExtension, ba.toByteArray());
|
||||
}catch(IOException e){
|
||||
ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
||||
Log.err(e);
|
||||
}
|
||||
}
|
||||
}/*,
|
||||
"$text.editor.exportimage", "$text.editor.exportimage.description", "icon-file-image", (Listenable)() -> {
|
||||
if(gwt){
|
||||
ui.showError("$text.web.unsupported");
|
||||
}else{
|
||||
Platform.instance.showFileChooser("$text.saveimage", "Image Files", file -> {
|
||||
file = file.parent().child(file.nameWithoutExtension() + ".png");
|
||||
FileHandle result = file;
|
||||
ui.loadGraphics(() -> {
|
||||
try{
|
||||
Pixmaps.write(MapIO.generatePixmap(editor.getMap()), result);
|
||||
}catch (Exception e){
|
||||
ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
||||
Log.err(e);
|
||||
}
|
||||
});
|
||||
}, false, "png");
|
||||
}
|
||||
}*/));
|
||||
MapIO.writeMap(result.write(false), editor.getTags(), editor.getMap());
|
||||
}catch(Exception e){
|
||||
ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
||||
Log.err(e);
|
||||
}
|
||||
});
|
||||
}, false, mapExtension);
|
||||
}));
|
||||
|
||||
t.row();
|
||||
|
||||
|
||||
@@ -256,9 +256,7 @@ public class Saves{
|
||||
}
|
||||
|
||||
public void delete(){
|
||||
if(!gwt){ //can't delete files
|
||||
SaveIO.fileFor(index).delete();
|
||||
}
|
||||
SaveIO.fileFor(index).delete();
|
||||
saves.removeValue(this, true);
|
||||
saveMap.remove(index);
|
||||
if(this == current){
|
||||
|
||||
@@ -2,12 +2,10 @@ package io.anuke.mindustry.io;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Base64Coder;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.io.versions.Save16;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
@@ -33,40 +31,23 @@ public class SaveIO{
|
||||
}
|
||||
|
||||
public static void saveToSlot(int slot){
|
||||
if(gwt){
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
write(stream);
|
||||
Settings.putString("save-" + slot + "-data", new String(Base64Coder.encode(stream.toByteArray())));
|
||||
Settings.save();
|
||||
}else{
|
||||
FileHandle file = fileFor(slot);
|
||||
boolean exists = file.exists();
|
||||
if(exists) file.moveTo(file.sibling(file.name() + "-backup." + file.extension()));
|
||||
try{
|
||||
write(fileFor(slot));
|
||||
}catch(Exception e){
|
||||
if(exists) file.sibling(file.name() + "-backup." + file.extension()).moveTo(file);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
FileHandle file = fileFor(slot);
|
||||
boolean exists = file.exists();
|
||||
if(exists) file.moveTo(file.sibling(file.name() + "-backup." + file.extension()));
|
||||
try{
|
||||
write(fileFor(slot));
|
||||
}catch(Exception e){
|
||||
if(exists) file.sibling(file.name() + "-backup." + file.extension()).moveTo(file);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadFromSlot(int slot){
|
||||
if(gwt){
|
||||
load(getSlotStream(slot));
|
||||
}else{
|
||||
load(fileFor(slot));
|
||||
}
|
||||
load(fileFor(slot));
|
||||
}
|
||||
|
||||
public static DataInputStream getSlotStream(int slot){
|
||||
if(gwt){
|
||||
String string = Settings.getString("save-" + slot + "-data", "");
|
||||
byte[] bytes = Base64Coder.decode(string);
|
||||
return new DataInputStream(new ByteArrayInputStream(bytes));
|
||||
}else{
|
||||
return new DataInputStream(new InflaterInputStream(fileFor(slot).read()));
|
||||
}
|
||||
return new DataInputStream(new InflaterInputStream(fileFor(slot).read()));
|
||||
}
|
||||
|
||||
public static boolean isSaveValid(int slot){
|
||||
|
||||
@@ -4,16 +4,16 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Base64Coder;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import io.anuke.mindustry.io.MapIO;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.function.Supplier;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.ThreadArray;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -29,8 +29,6 @@ public class Maps implements Disposable{
|
||||
private Array<Map> allMaps = new ThreadArray<>();
|
||||
/**Temporary array used for returning things.*/
|
||||
private Array<Map> returnArray = new ThreadArray<>();
|
||||
/**Used for storing a list of custom map names for GWT.*/
|
||||
private Array<String> customMapNames;
|
||||
|
||||
/**Returns a list of all maps, including custom ones.*/
|
||||
public Array<Map> all(){
|
||||
@@ -76,25 +74,14 @@ public class Maps implements Disposable{
|
||||
|
||||
/**Save a map. This updates all values and stored data necessary.*/
|
||||
public void saveMap(String name, MapTileData data, ObjectMap<String, String> tags){
|
||||
try {
|
||||
try{
|
||||
//create copy of tags to prevent mutation later
|
||||
ObjectMap<String, String> newTags = new ObjectMap<>();
|
||||
newTags.putAll(tags);
|
||||
tags = newTags;
|
||||
|
||||
if (!gwt) {
|
||||
FileHandle file = customMapDirectory.child(name + "." + mapExtension);
|
||||
MapIO.writeMap(file.write(false), tags, data);
|
||||
} else {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
MapIO.writeMap(stream, tags, data);
|
||||
Settings.putString("map-data-" + name, new String(Base64Coder.encode(stream.toByteArray())));
|
||||
if(!customMapNames.contains(name, false)){
|
||||
customMapNames.add(name);
|
||||
Settings.putObject("custom-maps", customMapNames);
|
||||
}
|
||||
Settings.save();
|
||||
}
|
||||
FileHandle file = customMapDirectory.child(name + "." + mapExtension);
|
||||
MapIO.writeMap(file.write(false), tags, data);
|
||||
|
||||
if(maps.containsKey(name)){
|
||||
if(maps.get(name).texture != null) {
|
||||
@@ -105,7 +92,7 @@ public class Maps implements Disposable{
|
||||
}
|
||||
|
||||
Map map = new Map(name, new MapMeta(version, tags, data.width(), data.height(), null), true, getStreamFor(name));
|
||||
if (!headless){
|
||||
if(!headless){
|
||||
map.texture = new Texture(MapIO.generatePixmap(data));
|
||||
}
|
||||
allMaps.add(map);
|
||||
@@ -126,14 +113,7 @@ public class Maps implements Disposable{
|
||||
maps.remove(map.name);
|
||||
allMaps.removeValue(map, true);
|
||||
|
||||
if (!gwt) {
|
||||
customMapDirectory.child(map.name + "." + mapExtension).delete();
|
||||
} else {
|
||||
customMapNames.removeValue(map.name, false);
|
||||
Settings.putString("map-data-" + map.name, "");
|
||||
Settings.putObject("custom-maps", customMapNames);
|
||||
Settings.save();
|
||||
}
|
||||
customMapDirectory.child(map.name + "." + mapExtension).delete();
|
||||
}
|
||||
|
||||
private void loadMap(String name, Supplier<InputStream> supplier, boolean custom) throws IOException{
|
||||
@@ -151,43 +131,21 @@ public class Maps implements Disposable{
|
||||
}
|
||||
|
||||
private void loadCustomMaps(){
|
||||
if(!gwt){
|
||||
for(FileHandle file : customMapDirectory.list()){
|
||||
try{
|
||||
if(file.extension().equalsIgnoreCase(mapExtension)){
|
||||
loadMap(file.nameWithoutExtension(), file::read, true);
|
||||
}
|
||||
}catch (Exception e){
|
||||
Log.err("Failed to load custom map file '{0}'!", file);
|
||||
Log.err(e);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
customMapNames = Settings.getObject("custom-maps", Array.class, Array::new);
|
||||
|
||||
for(String name : customMapNames){
|
||||
try{
|
||||
String data = Settings.getString("map-data-" + name, "");
|
||||
byte[] bytes = Base64Coder.decode(data);
|
||||
loadMap(name, () -> new ByteArrayInputStream(bytes), true);
|
||||
}catch (Exception e){
|
||||
Log.err("Failed to load custom map '{0}'!", name);
|
||||
Log.err(e);
|
||||
for(FileHandle file : customMapDirectory.list()){
|
||||
try{
|
||||
if(file.extension().equalsIgnoreCase(mapExtension)){
|
||||
loadMap(file.nameWithoutExtension(), file::read, true);
|
||||
}
|
||||
}catch (Exception e){
|
||||
Log.err("Failed to load custom map file '{0}'!", file);
|
||||
Log.err(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**Returns an input stream supplier for a given map name.*/
|
||||
private Supplier<InputStream> getStreamFor(String name){
|
||||
if(!gwt){
|
||||
return customMapDirectory.child(name + "." + mapExtension)::read;
|
||||
}else{
|
||||
String data = Settings.getString("map-data-" + name, "");
|
||||
byte[] bytes = Base64Coder.decode(data);
|
||||
return () -> new ByteArrayInputStream(bytes);
|
||||
}
|
||||
return customMapDirectory.child(name + "." + mapExtension)::read;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -165,7 +165,7 @@ public class Net{
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts discovering servers on a different thread. Does not work with GWT.
|
||||
* Starts discovering servers on a different thread.
|
||||
* Callback is run on the main libGDX thread.
|
||||
*/
|
||||
public static void discoverServers(Consumer<Host> cons, Runnable done){
|
||||
|
||||
@@ -20,8 +20,6 @@ public class AdminsDialog extends FloatingDialog{
|
||||
private void setup(){
|
||||
content().clear();
|
||||
|
||||
if(gwt) return;
|
||||
|
||||
float w = 400f, h = 80f;
|
||||
|
||||
Table table = new Table();
|
||||
|
||||
@@ -21,8 +21,6 @@ public class BansDialog extends FloatingDialog{
|
||||
private void setup(){
|
||||
content().clear();
|
||||
|
||||
if(gwt) return;
|
||||
|
||||
float w = 400f, h = 80f;
|
||||
|
||||
Table table = new Table();
|
||||
|
||||
@@ -49,7 +49,7 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
modes.marginBottom(5);
|
||||
|
||||
for(GameMode mode : GameMode.values()){
|
||||
if(mode.hidden || (mode.isPvp && gwt)) continue;
|
||||
if(mode.hidden) continue;
|
||||
|
||||
modes.addButton("$mode." + mode.name() + ".name", "toggle", () -> state.mode = mode)
|
||||
.update(b -> b.setChecked(state.mode == mode)).group(group).size(140f, 54f).padBottom(-5);
|
||||
|
||||
@@ -21,15 +21,13 @@ import io.anuke.ucore.util.Pooling;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static io.anuke.mindustry.Vars.gwt;
|
||||
|
||||
public class FileChooser extends FloatingDialog{
|
||||
public static Predicate<FileHandle> pngFilter = file -> file.extension().equalsIgnoreCase("png");
|
||||
public static Predicate<FileHandle> mapFilter = file -> file.extension().equalsIgnoreCase(Vars.mapExtension);
|
||||
public static Predicate<FileHandle> jpegFilter = file -> file.extension().equalsIgnoreCase("png") || file.extension().equalsIgnoreCase("jpg") || file.extension().equalsIgnoreCase("jpeg");
|
||||
public static Predicate<FileHandle> defaultFilter = file -> true;
|
||||
private Table files;
|
||||
private FileHandle homeDirectory = gwt ? Gdx.files.internal("") : Gdx.files.absolute(OS.isMac ? OS.getProperty("user.home") + "/Downloads/" :
|
||||
private FileHandle homeDirectory = Gdx.files.absolute(OS.isMac ? OS.getProperty("user.home") + "/Downloads/" :
|
||||
Gdx.files.getExternalStoragePath());
|
||||
private FileHandle directory = homeDirectory;
|
||||
private ScrollPane pane;
|
||||
|
||||
@@ -247,16 +247,14 @@ public class JoinDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void refreshLocal(){
|
||||
if(!Vars.gwt){
|
||||
totalHosts = 0;
|
||||
totalHosts = 0;
|
||||
|
||||
local.clear();
|
||||
local.background((Drawable)null);
|
||||
local.table("button", t -> {
|
||||
t.label(() -> "[accent]" + Bundles.get("text.hosts.discovering") + Strings.animated(4, 10f, ".")).pad(10f);
|
||||
}).growX();
|
||||
Net.discoverServers(this::addLocalHost, this::finishLocalHosts);
|
||||
}
|
||||
local.clear();
|
||||
local.background((Drawable)null);
|
||||
local.table("button", t -> {
|
||||
t.label(() -> "[accent]" + Bundles.get("text.hosts.discovering") + Strings.animated(4, 10f, ".")).pad(10f);
|
||||
}).growX();
|
||||
Net.discoverServers(this::addLocalHost, this::finishLocalHosts);
|
||||
}
|
||||
|
||||
void finishLocalHosts(){
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
@@ -31,7 +30,7 @@ public class LanguageDialog extends FloatingDialog{
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
|
||||
for(Locale loc : locales){
|
||||
TextButton button = new TextButton(Platform.instance.getLocaleName(loc), "toggle");
|
||||
TextButton button = new TextButton(loc.getDisplayName(loc), "toggle");
|
||||
button.clicked(() -> {
|
||||
if(getLocale().equals(loc)) return;
|
||||
Settings.putString("locale", loc.toString());
|
||||
|
||||
@@ -86,28 +86,27 @@ public class LoadDialog extends FloatingDialog{
|
||||
});
|
||||
}).size(14 * 3).right();
|
||||
|
||||
if(!gwt){
|
||||
t.addImageButton("icon-save", "empty", 14 * 3, () -> {
|
||||
if(!ios){
|
||||
Platform.instance.showFileChooser(Bundles.get("text.save.export"), "Mindustry Save", file -> {
|
||||
try{
|
||||
slot.exportFile(file);
|
||||
setup();
|
||||
}catch(IOException e){
|
||||
ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false)));
|
||||
}
|
||||
}, false, saveExtension);
|
||||
}else{
|
||||
t.addImageButton("icon-save", "empty", 14 * 3, () -> {
|
||||
if(!ios){
|
||||
Platform.instance.showFileChooser(Bundles.get("text.save.export"), "Mindustry Save", file -> {
|
||||
try{
|
||||
FileHandle file = Gdx.files.local("save-" + slot.getName() + "." + Vars.saveExtension);
|
||||
slot.exportFile(file);
|
||||
Platform.instance.shareFile(file);
|
||||
}catch(Exception e){
|
||||
setup();
|
||||
}catch(IOException e){
|
||||
ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false)));
|
||||
}
|
||||
}, false, saveExtension);
|
||||
}else{
|
||||
try{
|
||||
FileHandle file = Gdx.files.local("save-" + slot.getName() + "." + Vars.saveExtension);
|
||||
slot.exportFile(file);
|
||||
Platform.instance.shareFile(file);
|
||||
}catch(Exception e){
|
||||
ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false)));
|
||||
}
|
||||
}).size(14 * 3).right();
|
||||
}
|
||||
}
|
||||
}).size(14 * 3).right();
|
||||
|
||||
|
||||
}).padRight(-10).growX();
|
||||
|
||||
@@ -153,7 +152,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
|
||||
slots.row();
|
||||
|
||||
if(gwt || ios) return;
|
||||
if(ios) return;
|
||||
|
||||
slots.addImageTextButton("$text.save.import", "icon-add", "clear", 14 * 3, () -> {
|
||||
Platform.instance.showFileChooser(Bundles.get("text.save.import"), "Mindustry Save", file -> {
|
||||
|
||||
@@ -61,25 +61,14 @@ public class PausedDialog extends FloatingDialog{
|
||||
content().addButton("$text.settings", ui.settings::show);
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.savegame", () -> {
|
||||
save.show();
|
||||
}).disabled(s -> world.getSector() != null);
|
||||
content().addButton("$text.savegame", save::show).disabled(s -> world.getSector() != null);
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.loadgame", () -> {
|
||||
load.show();
|
||||
}).disabled(b -> Net.active());
|
||||
content().addButton("$text.loadgame", load::show).disabled(b -> Net.active());
|
||||
|
||||
content().row();
|
||||
|
||||
content().addButton("$text.hostserver", () -> {
|
||||
if(!gwt){
|
||||
ui.host.show();
|
||||
}else{
|
||||
ui.showInfo("$text.web.unsupported");
|
||||
}
|
||||
}).disabled(b -> Net.active());
|
||||
|
||||
content().addButton("$text.hostserver", ui.host::show).disabled(b -> Net.active());
|
||||
|
||||
content().row();
|
||||
|
||||
|
||||
@@ -175,11 +175,8 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
Settings.prefs().put(map);
|
||||
Settings.save();
|
||||
|
||||
if(!gwt){
|
||||
Settings.prefs().clear();
|
||||
for(FileHandle file : dataDirectory.list()){
|
||||
file.deleteDirectory();
|
||||
}
|
||||
for(FileHandle file : dataDirectory.list()){
|
||||
file.deleteDirectory();
|
||||
}
|
||||
|
||||
Gdx.app.exit();
|
||||
@@ -193,19 +190,15 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
}
|
||||
});
|
||||
|
||||
if(!gwt){
|
||||
graphics.sliderPref("fpscap", 125, 5, 125, 5, s -> (s > 120 ? Bundles.get("setting.fpscap.none") : Bundles.format("setting.fpscap.text", s)));
|
||||
graphics.sliderPref("fpscap", 125, 5, 125, 5, s -> (s > 120 ? Bundles.get("setting.fpscap.none") : Bundles.format("setting.fpscap.text", s)));
|
||||
graphics.checkPref("multithread", mobile, threads::setEnabled);
|
||||
|
||||
if(Settings.getBool("multithread")){
|
||||
threads.setEnabled(true);
|
||||
}
|
||||
|
||||
if(!gwt){
|
||||
graphics.checkPref("multithread", mobile, threads::setEnabled);
|
||||
|
||||
if(Settings.getBool("multithread")){
|
||||
threads.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if(!mobile && !gwt){
|
||||
if(!mobile){
|
||||
graphics.checkPref("vsync", true, b -> Gdx.graphics.setVSync(b));
|
||||
graphics.checkPref("fullscreen", false, b -> {
|
||||
if(b){
|
||||
|
||||
@@ -127,7 +127,7 @@ public class HudFragment extends Fragment{
|
||||
t.label(() -> tps.get(threads.getTPS())).visible(() -> threads.isEnabled());
|
||||
t.row();
|
||||
if(Net.hasClient()){
|
||||
t.label(() -> ping.get(Net.getPing())).visible(() -> Net.client() && !gwt).colspan(2);
|
||||
t.label(() -> ping.get(Net.getPing())).visible(Net::client).colspan(2);
|
||||
}
|
||||
}).size(-1).visible(() -> Settings.getBool("fps")).update(t -> t.setTranslation(0, (!waves.isVisible() ? wavetable.getHeight() : Math.min(wavetable.getTranslation().y, wavetable.getHeight())) )).get();
|
||||
|
||||
|
||||
@@ -132,9 +132,7 @@ public class MenuFragment extends Fragment{
|
||||
|
||||
out.row();
|
||||
|
||||
if(!gwt){
|
||||
out.add(new MenuButton("icon-exit", "$text.quit", Gdx.app::exit)).width(bw).colspan(2);
|
||||
}
|
||||
out.add(new MenuButton("icon-exit", "$text.quit", Gdx.app::exit)).width(bw).colspan(2);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -153,12 +151,8 @@ public class MenuFragment extends Fragment{
|
||||
dialog.content().row();
|
||||
|
||||
dialog.content().add(new MenuButton("icon-add", "$text.joingame", () -> {
|
||||
if(!gwt){
|
||||
ui.join.show();
|
||||
dialog.hide();
|
||||
}else{
|
||||
ui.showInfo("$text.web.unsupported");
|
||||
}
|
||||
ui.join.show();
|
||||
dialog.hide();
|
||||
}));
|
||||
|
||||
dialog.content().add(new MenuButton("icon-editor", "$text.customgame", () -> {
|
||||
|
||||
@@ -3,14 +3,12 @@ package io.anuke.mindustry.ui.fragments;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetConnection;
|
||||
import io.anuke.mindustry.net.Packets.AdminAction;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
@@ -73,7 +71,7 @@ public class PlayerListFragment extends Fragment{
|
||||
float h = 74f;
|
||||
|
||||
playerGroup.forEach(player -> {
|
||||
NetConnection connection = gwt ? null : player.con;
|
||||
NetConnection connection = player.con;
|
||||
|
||||
if(connection == null && Net.server() && !player.isLocal) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user