mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-02 20:33:50 +07:00
Platform cleanup
This commit is contained in:
parent
6d9a59c60b
commit
3b9d3fd233
@ -1,32 +1,28 @@
|
||||
package io.anuke.mindustry;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.telephony.TelephonyManager;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.backends.android.surfaceview.AndroidApplication;
|
||||
import io.anuke.arc.backends.android.surfaceview.AndroidApplicationConfiguration;
|
||||
import io.anuke.arc.files.FileHandle;
|
||||
import io.anuke.arc.function.Consumer;
|
||||
import io.anuke.arc.function.Predicate;
|
||||
import io.anuke.arc.scene.ui.layout.UnitScl;
|
||||
import io.anuke.arc.util.Strings;
|
||||
import io.anuke.arc.util.serialization.Base64Coder;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import android.*;
|
||||
import android.content.*;
|
||||
import android.content.pm.*;
|
||||
import android.net.*;
|
||||
import android.os.*;
|
||||
import android.provider.Settings.*;
|
||||
import android.telephony.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.backends.android.surfaceview.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.mindustry.game.Saves.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.lang.System;
|
||||
import java.util.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@ -42,7 +38,14 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
|
||||
config.useImmersiveMode = true;
|
||||
config.depth = 0;
|
||||
Platform.instance = new Platform(){
|
||||
if(doubleScaleTablets && isTablet(this.getContext())){
|
||||
UnitScl.dp.addition = 0.5f;
|
||||
}
|
||||
|
||||
config.hideStatusBar = true;
|
||||
Net.setClientProvider(new ArcNetClient());
|
||||
Net.setServerProvider(new ArcNetServer());
|
||||
initialize(new ClientLauncher(){
|
||||
|
||||
@Override
|
||||
public void hide(){
|
||||
@ -70,7 +73,7 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
@Override
|
||||
public void requestExternalPerms(Runnable callback){
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M || (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
|
||||
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
|
||||
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
|
||||
callback.run();
|
||||
}else{
|
||||
permCallback = callback;
|
||||
@ -93,7 +96,7 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, Predicate<String> filetype){
|
||||
chooser = new FileChooser(text, file -> filetype.test(file.extension().toLowerCase()), open, cons);
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M || (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
|
||||
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
|
||||
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
|
||||
chooser.show();
|
||||
chooser = null;
|
||||
}else{
|
||||
@ -122,16 +125,7 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
public boolean canDonate(){
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
if(doubleScaleTablets && isTablet(this.getContext())){
|
||||
UnitScl.dp.addition = 0.5f;
|
||||
}
|
||||
|
||||
config.hideStatusBar = true;
|
||||
Net.setClientProvider(new ArcNetClient());
|
||||
Net.setServerProvider(new ArcNetServer());
|
||||
initialize(new ClientLauncher(), config);
|
||||
}, config);
|
||||
checkFiles(getIntent());
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import io.anuke.mindustry.maps.*;
|
||||
import static io.anuke.arc.Core.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ClientLauncher extends ApplicationCore{
|
||||
public abstract class ClientLauncher extends ApplicationCore implements Platform{
|
||||
private static final int loadingFPS = 20;
|
||||
|
||||
private float smoothProgress;
|
||||
@ -27,6 +27,7 @@ public class ClientLauncher extends ApplicationCore{
|
||||
|
||||
@Override
|
||||
public void setup(){
|
||||
Vars.platform = this;
|
||||
Log.setUseColors(false);
|
||||
beginTime = Time.millis();
|
||||
|
||||
@ -48,9 +49,7 @@ public class ClientLauncher extends ApplicationCore{
|
||||
assets.load(new Vars());
|
||||
assets.load(new AssetDescriptor<>("sprites/sprites.atlas", TextureAtlas.class)).loaded = t -> atlas = (TextureAtlas)t;
|
||||
|
||||
assets.loadRun("maps", Map.class, () -> {
|
||||
maps.loadPreviews();
|
||||
});
|
||||
assets.loadRun("maps", Map.class, () -> maps.loadPreviews());
|
||||
|
||||
Musics.load();
|
||||
Sounds.load();
|
||||
@ -137,6 +136,13 @@ public class ClientLauncher extends ApplicationCore{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause(){
|
||||
if(finished){
|
||||
super.pause();
|
||||
}
|
||||
}
|
||||
|
||||
void drawLoading(){
|
||||
smoothProgress = Mathf.lerpDelta(smoothProgress, assets.getProgress(), 0.1f);
|
||||
|
||||
|
@ -139,6 +139,7 @@ public class Vars implements Loadable{
|
||||
public static EntityCollisions collisions;
|
||||
public static DefaultWaves defaultWaves;
|
||||
public static LoopControl loops;
|
||||
public static Platform platform;
|
||||
|
||||
public static World world;
|
||||
public static Maps maps;
|
||||
|
@ -51,7 +51,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
public Control(){
|
||||
Events.on(StateChangeEvent.class, event -> {
|
||||
if((event.from == State.playing && event.to == State.menu) || (event.from == State.menu && event.to != State.menu)){
|
||||
Time.runTask(5f, Platform.instance::updateRPC);
|
||||
Time.runTask(5f, platform::updateRPC);
|
||||
}
|
||||
});
|
||||
|
||||
@ -184,7 +184,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
settings.getBoolOnce("classic-backup-check", () -> {
|
||||
app.post(() -> app.post(() -> ui.showConfirm("$classic.export", "$classic.export.text", () -> {
|
||||
try{
|
||||
Platform.instance.requestExternalPerms(() -> {
|
||||
platform.requestExternalPerms(() -> {
|
||||
FileHandle external = files.external("MindustryClassic");
|
||||
if(files.local("mindustry-maps").exists()){
|
||||
files.local("mindustry-maps").copyTo(external);
|
||||
@ -336,7 +336,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
Platform.instance.updateRPC();
|
||||
platform.updateRPC();
|
||||
|
||||
//play tutorial on stop
|
||||
if(!settings.getBool("playedtutorial", false)){
|
||||
@ -426,7 +426,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
|
||||
//auto-update rpc every 5 seconds
|
||||
if(timer.get(0, 60 * 5)){
|
||||
Platform.instance.updateRPC();
|
||||
platform.updateRPC();
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.pause) && !scene.hasDialog() && !ui.restart.isShown() && (state.is(State.paused) || state.is(State.playing))){
|
||||
@ -452,7 +452,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
}
|
||||
|
||||
if(!scene.hasDialog() && !scene.root.getChildren().isEmpty() && !(scene.root.getChildren().peek() instanceof Dialog) && Core.input.keyTap(KeyCode.BACK)){
|
||||
Platform.instance.hide();
|
||||
platform.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class NetClient implements ApplicationListener{
|
||||
c.versionType = Version.type;
|
||||
c.color = Color.rgba8888(player.color);
|
||||
c.usid = getUsid(packet.addressTCP);
|
||||
c.uuid = Platform.instance.getUUID();
|
||||
c.uuid = platform.getUUID();
|
||||
|
||||
if(c.uuid == null){
|
||||
ui.showError("$invalidid");
|
||||
@ -101,7 +101,7 @@ public class NetClient implements ApplicationListener{
|
||||
connecting = false;
|
||||
state.set(State.menu);
|
||||
logic.reset();
|
||||
Platform.instance.updateRPC();
|
||||
platform.updateRPC();
|
||||
|
||||
if(quiet) return;
|
||||
|
||||
@ -356,7 +356,7 @@ public class NetClient implements ApplicationListener{
|
||||
ui.join.hide();
|
||||
Net.setClientLoaded(true);
|
||||
Core.app.post(Call::connectConfirm);
|
||||
Time.runTask(40f, Platform.instance::updateRPC);
|
||||
Time.runTask(40f, platform::updateRPC);
|
||||
Core.app.post(() -> ui.loadfrag.hide());
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
sendWorldData(player, id);
|
||||
|
||||
Platform.instance.updateRPC();
|
||||
platform.updateRPC();
|
||||
});
|
||||
|
||||
Net.handleServer(InvokePacket.class, (id, packet) -> {
|
||||
|
@ -11,18 +11,15 @@ import io.anuke.arc.util.serialization.Base64Coder;
|
||||
|
||||
import static io.anuke.mindustry.Vars.mobile;
|
||||
|
||||
public abstract class Platform{
|
||||
/** Each separate game platform should set this instance to their own implementation. */
|
||||
public static Platform instance = new Platform(){
|
||||
};
|
||||
public interface Platform{
|
||||
|
||||
/** Add a text input dialog that should show up after the field is tapped. */
|
||||
public void addDialog(TextField field){
|
||||
default void addDialog(TextField field){
|
||||
addDialog(field, 16);
|
||||
}
|
||||
|
||||
/** See addDialog(). */
|
||||
public void addDialog(TextField field, int maxLength){
|
||||
default void addDialog(TextField field, int maxLength){
|
||||
if(!mobile) return; //this is mobile only, desktop doesn't need dialogs
|
||||
|
||||
field.tapped(() -> {
|
||||
@ -40,21 +37,21 @@ public abstract class Platform{
|
||||
}
|
||||
|
||||
/** Request external read/write perms. Run callback when complete.*/
|
||||
public void requestExternalPerms(Runnable callback){
|
||||
default void requestExternalPerms(Runnable callback){
|
||||
callback.run();
|
||||
}
|
||||
|
||||
/** Update discord RPC. */
|
||||
public void updateRPC(){
|
||||
default void updateRPC(){
|
||||
}
|
||||
|
||||
/** Whether donating is supported. */
|
||||
public boolean canDonate(){
|
||||
default boolean canDonate(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Must be a base64 string 8 bytes in length. */
|
||||
public String getUUID(){
|
||||
default String getUUID(){
|
||||
String uuid = Core.settings.getString("uuid", "");
|
||||
if(uuid.isEmpty()){
|
||||
byte[] result = new byte[8];
|
||||
@ -68,7 +65,7 @@ public abstract class Platform{
|
||||
}
|
||||
|
||||
/** Only used for iOS or android: open the share menu for a map or save. */
|
||||
public void shareFile(FileHandle file){
|
||||
default void shareFile(FileHandle file){
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,18 +76,18 @@ public abstract class Platform{
|
||||
* @param open Whether to open or save files
|
||||
* @param filetype File extension to filter
|
||||
*/
|
||||
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, Predicate<String> filetype){
|
||||
default void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, Predicate<String> filetype){
|
||||
}
|
||||
|
||||
/** Hide the app. Android only. */
|
||||
public void hide(){
|
||||
default void hide(){
|
||||
}
|
||||
|
||||
/** Forces the app into landscape mode. Currently Android only. */
|
||||
public void beginForceLandscape(){
|
||||
default void beginForceLandscape(){
|
||||
}
|
||||
|
||||
/** Stops forcing the app into landscape orientation. Currently Android only. */
|
||||
public void endForceLandscape(){
|
||||
default void endForceLandscape(){
|
||||
}
|
||||
}
|
@ -287,7 +287,7 @@ public class UI implements ApplicationListener, Loadable{
|
||||
TextField field = cont.addField(def, t -> {
|
||||
}).size(170f, 50f).get();
|
||||
field.setFilter((f, c) -> field.getText().length() < textLength && filter.acceptChar(f, c));
|
||||
Platform.instance.addDialog(field);
|
||||
platform.addDialog(field);
|
||||
buttons.defaults().size(120, 54).pad(4);
|
||||
buttons.addButton("$ok", () -> {
|
||||
confirmed.accept(field.getText());
|
||||
|
@ -19,7 +19,6 @@ import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
@ -92,7 +91,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
createDialog("$editor.import",
|
||||
"$editor.importmap", "$editor.importmap.description", "icon-load-map", (Runnable)loadDialog::show,
|
||||
"$editor.importfile", "$editor.importfile.description", "icon-file", (Runnable)() ->
|
||||
Platform.instance.showFileChooser("$editor.loadmap", "Map Files", file -> ui.loadAnd(() -> {
|
||||
platform.showFileChooser("$editor.loadmap", "Map Files", file -> ui.loadAnd(() -> {
|
||||
maps.tryCatchMapError(() -> {
|
||||
if(MapIO.isImage(file)){
|
||||
ui.showInfo("$editor.errorimage");
|
||||
@ -105,7 +104,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}), true, FileChooser.anyMapFiles),
|
||||
|
||||
"$editor.importimage", "$editor.importimage.description", "icon-file-image", (Runnable)() ->
|
||||
Platform.instance.showFileChooser("$loadimage", "Image Files", file ->
|
||||
platform.showFileChooser("$loadimage", "Image Files", file ->
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
Pixmap pixmap = new Pixmap(file);
|
||||
@ -121,7 +120,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
Cell cell = t.addImageTextButton("$editor.export", "icon-save-map", isize, () -> {
|
||||
if(!ios){
|
||||
Platform.instance.showFileChooser("$editor.savemap", "Map Files", file -> {
|
||||
platform.showFileChooser("$editor.savemap", "Map Files", file -> {
|
||||
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
||||
FileHandle result = file;
|
||||
ui.loadAnd(() -> {
|
||||
@ -141,7 +140,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
try{
|
||||
FileHandle result = Core.files.local(editor.getTags().get("name", "unknown") + "." + mapExtension);
|
||||
MapIO.writeMap(result, editor.createMap(result));
|
||||
Platform.instance.shareFile(result);
|
||||
platform.shareFile(result);
|
||||
}catch(Exception e){
|
||||
ui.showError(Core.bundle.format("editor.errorsave", Strings.parseException(e, true)));
|
||||
Log.err(e);
|
||||
@ -210,7 +209,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
shown(() -> {
|
||||
|
||||
saved = true;
|
||||
if(!Core.settings.getBool("landscape")) Platform.instance.beginForceLandscape();
|
||||
if(!Core.settings.getBool("landscape")) platform.beginForceLandscape();
|
||||
editor.clearOp();
|
||||
Core.scene.setScrollFocus(view);
|
||||
if(!shownWithMap){
|
||||
@ -221,13 +220,13 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}
|
||||
shownWithMap = false;
|
||||
|
||||
Time.runTask(10f, Platform.instance::updateRPC);
|
||||
Time.runTask(10f, platform::updateRPC);
|
||||
});
|
||||
|
||||
hidden(() -> {
|
||||
editor.clearOp();
|
||||
Platform.instance.updateRPC();
|
||||
if(!Core.settings.getBool("landscape")) Platform.instance.endForceLandscape();
|
||||
platform.updateRPC();
|
||||
if(!Core.settings.getBool("landscape")) platform.endForceLandscape();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
@ -76,9 +75,9 @@ public class MapInfoDialog extends FloatingDialog{
|
||||
description.change();
|
||||
author.change();
|
||||
|
||||
Platform.instance.addDialog(name, 50);
|
||||
Platform.instance.addDialog(author, 50);
|
||||
Platform.instance.addDialog(description, 1000);
|
||||
Vars.platform.addDialog(name, 50);
|
||||
Vars.platform.addDialog(author, 50);
|
||||
Vars.platform.addDialog(description, 1000);
|
||||
t.margin(16f);
|
||||
});
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package io.anuke.mindustry.editor;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
|
||||
@ -18,7 +17,7 @@ public class MapSaveDialog extends FloatingDialog{
|
||||
field = new TextField();
|
||||
listener = cons;
|
||||
|
||||
Platform.instance.addDialog(field);
|
||||
Vars.platform.addDialog(field);
|
||||
|
||||
shown(() -> {
|
||||
cont.clear();
|
||||
|
@ -5,7 +5,6 @@ import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.pooling.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
import io.anuke.mindustry.net.Streamable.*;
|
||||
@ -117,7 +116,7 @@ public class Net{
|
||||
active = true;
|
||||
server = true;
|
||||
|
||||
Time.runTask(60f, Platform.instance::updateRPC);
|
||||
Time.runTask(60f, platform::updateRPC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,9 +4,9 @@ import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.Rules;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
@ -102,7 +102,7 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
t.left();
|
||||
t.add(text).left().padRight(5)
|
||||
.update(a -> a.setColor(condition.get() ? Color.WHITE : Color.GRAY));
|
||||
Platform.instance.addDialog(t.addField((integer ? (int)prov.get() : prov.get()) + "", s -> cons.accept(Strings.parseFloat(s)))
|
||||
Vars.platform.addDialog(t.addField((integer ? (int)prov.get() : prov.get()) + "", s -> cons.accept(Strings.parseFloat(s)))
|
||||
.padRight(100f)
|
||||
.update(a -> a.setDisabled(!condition.get()))
|
||||
.valid(Strings::canParsePositiveFloat).width(120f).left().get());
|
||||
|
@ -15,7 +15,6 @@ import io.anuke.arc.scene.utils.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.Saves.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.io.SaveIO.*;
|
||||
@ -52,7 +51,7 @@ public class DeployDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
public void setup(){
|
||||
Platform.instance.updateRPC();
|
||||
platform.updateRPC();
|
||||
|
||||
cont.clear();
|
||||
titleTable.remove();
|
||||
|
@ -12,7 +12,6 @@ import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.scene.ui.layout.UnitScl;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -61,7 +60,7 @@ public class FileChooser extends FloatingDialog{
|
||||
|
||||
filefield = new TextField();
|
||||
filefield.setOnlyFontChars(false);
|
||||
if(!open) Platform.instance.addDialog(filefield);
|
||||
if(!open) platform.addDialog(filefield);
|
||||
filefield.setDisabled(open);
|
||||
|
||||
ok = new TextButton(open ? "$load" : "$save");
|
||||
|
@ -10,7 +10,6 @@ import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.*;
|
||||
@ -48,7 +47,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
Core.settings.save();
|
||||
}).size(320f, 54f).get();
|
||||
|
||||
Platform.instance.addDialog(field, 100);
|
||||
platform.addDialog(field, 100);
|
||||
|
||||
add.cont.row();
|
||||
add.buttons.defaults().size(140f, 60f).pad(4f);
|
||||
|
@ -8,7 +8,6 @@ import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.Saves.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.io.SaveIO.*;
|
||||
@ -86,7 +85,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
|
||||
t.addImageButton("icon-save", "empty", iconsize, () -> {
|
||||
if(!ios){
|
||||
Platform.instance.showFileChooser(Core.bundle.get("save.export"), "Mindustry Save", file -> {
|
||||
platform.showFileChooser(Core.bundle.get("save.export"), "Mindustry Save", file -> {
|
||||
try{
|
||||
slot.exportFile(file);
|
||||
setup();
|
||||
@ -98,7 +97,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
try{
|
||||
FileHandle file = Core.files.local("save-" + slot.getName() + "." + Vars.saveExtension);
|
||||
slot.exportFile(file);
|
||||
Platform.instance.shareFile(file);
|
||||
platform.shareFile(file);
|
||||
}catch(Exception e){
|
||||
ui.showError(Core.bundle.format("save.export.fail", Strings.parseException(e, true)));
|
||||
}
|
||||
@ -148,7 +147,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
if(ios) return;
|
||||
|
||||
slots.addImageTextButton("$save.import", "icon-add", iconsize, () -> {
|
||||
Platform.instance.showFileChooser(Core.bundle.get("save.import"), "Mindustry Save", file -> {
|
||||
platform.showFileChooser(Core.bundle.get("save.import"), "Mindustry Save", file -> {
|
||||
if(SaveIO.isSaveValid(file)){
|
||||
try{
|
||||
control.saves.importSave(file);
|
||||
|
@ -9,7 +9,6 @@ import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
@ -62,7 +61,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
|
||||
if(!ios){
|
||||
buttons.addImageTextButton("$editor.importmap", "icon-load", iconsize, () -> {
|
||||
Platform.instance.showFileChooser("$editor.importmap", "Map File", file -> {
|
||||
platform.showFileChooser("$editor.importmap", "Map File", file -> {
|
||||
maps.tryCatchMapError(() -> {
|
||||
if(MapIO.isImage(file)){
|
||||
ui.showError("$editor.errorimage");
|
||||
|
@ -13,7 +13,6 @@ import io.anuke.arc.scene.ui.SettingsDialog.SettingsTable.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
@ -119,9 +118,9 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
}catch(Exception e){
|
||||
ui.showError(Strings.parseException(e, true));
|
||||
}
|
||||
Platform.instance.shareFile(file);
|
||||
platform.shareFile(file);
|
||||
}else{
|
||||
Platform.instance.showFileChooser("$data.export", "Zip Files", file -> {
|
||||
platform.showFileChooser("$data.export", "Zip Files", file -> {
|
||||
FileHandle ff = file;
|
||||
if(!ff.extension().equals("zip")){
|
||||
ff = ff.sibling(ff.nameWithoutExtension() + ".zip");
|
||||
@ -141,7 +140,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
//iOS doesn't have a file chooser.
|
||||
if(!ios){
|
||||
t.addButton("$data.import", style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> Platform.instance.showFileChooser("$data.import", "Zip Files", file -> {
|
||||
t.addButton("$data.import", style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser("$data.import", "Zip Files", file -> {
|
||||
try{
|
||||
data.importData(file);
|
||||
Core.app.exit();
|
||||
@ -269,14 +268,14 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
}else{
|
||||
graphics.checkPref("landscape", false, b -> {
|
||||
if(b){
|
||||
Platform.instance.beginForceLandscape();
|
||||
platform.beginForceLandscape();
|
||||
}else{
|
||||
Platform.instance.endForceLandscape();
|
||||
platform.endForceLandscape();
|
||||
}
|
||||
});
|
||||
|
||||
if(Core.settings.getBool("landscape")){
|
||||
Platform.instance.beginForceLandscape();
|
||||
platform.beginForceLandscape();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.Button;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.EventType.DisposeEvent;
|
||||
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||
import io.anuke.mindustry.game.Version;
|
||||
@ -118,7 +117,7 @@ public class MenuFragment extends Fragment{
|
||||
table.add(editor);
|
||||
table.add(tools);
|
||||
|
||||
if(Platform.instance.canDonate()) table.add(donate);
|
||||
if(platform.canDonate()) table.add(donate);
|
||||
if(!ios) table.add(exit);
|
||||
}).colspan(4);
|
||||
}else{
|
||||
@ -136,7 +135,7 @@ public class MenuFragment extends Fragment{
|
||||
container.table(table -> {
|
||||
table.defaults().set(container.defaults());
|
||||
|
||||
if(Platform.instance.canDonate()) table.add(donate);
|
||||
if(platform.canDonate()) table.add(donate);
|
||||
if(!ios) table.add(exit);
|
||||
}).colspan(2);
|
||||
}
|
||||
|
@ -2,20 +2,16 @@ package io.anuke.mindustry.desktop;
|
||||
|
||||
import io.anuke.arc.Files.*;
|
||||
import io.anuke.arc.backends.sdl.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
|
||||
public class DesktopLauncher{
|
||||
|
||||
public static void main(String[] arg){
|
||||
try{
|
||||
Platform.instance = new DesktopPlatform(arg);
|
||||
|
||||
Net.setClientProvider(new ArcNetClient());
|
||||
Net.setServerProvider(new ArcNetServer());
|
||||
|
||||
new SdlApplication(new ClientLauncher(), new SdlConfig(){{
|
||||
new SdlApplication(new DesktopPlatform(arg), new SdlConfig(){{
|
||||
title = "Mindustry";
|
||||
maximized = true;
|
||||
depth = 0;
|
||||
|
@ -1,14 +1,14 @@
|
||||
package io.anuke.mindustry.desktop;
|
||||
|
||||
import club.minnced.discord.rpc.*;
|
||||
import io.anuke.arc.backends.sdl.jni.SDL;
|
||||
import io.anuke.arc.backends.sdl.jni.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
|
||||
@ -18,7 +18,7 @@ import java.util.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
|
||||
public class DesktopPlatform extends Platform{
|
||||
public class DesktopPlatform extends ClientLauncher{
|
||||
static boolean useDiscord = OS.is64Bit;
|
||||
final static String applicationId = "610508934456934412";
|
||||
String[] args;
|
||||
|
@ -6,7 +6,6 @@ import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.io.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.Saves.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
@ -36,7 +35,8 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
UnitScl.dp.addition = -0.5f;
|
||||
}
|
||||
|
||||
Platform.instance = new Platform(){
|
||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
return new IOSApplication(new ClientLauncher(){
|
||||
|
||||
@Override
|
||||
public void shareFile(FileHandle file){
|
||||
@ -63,10 +63,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
forced = false;
|
||||
UINavigationController.attemptRotationToDeviceOrientation();
|
||||
}
|
||||
};
|
||||
|
||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
return new IOSApplication(new ClientLauncher(), config);
|
||||
}, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user