Merge branch 'master' of https://github.com/Anuken/Mindustry into 4.0

# Conflicts:
#	build.gradle
#	core/src/io/anuke/mindustry/Vars.java
#	core/src/io/anuke/mindustry/core/Control.java
#	core/src/io/anuke/mindustry/core/Logic.java
#	core/src/io/anuke/mindustry/core/NetClient.java
#	core/src/io/anuke/mindustry/core/NetServer.java
#	core/src/io/anuke/mindustry/core/UI.java
#	core/src/io/anuke/mindustry/editor/MapSaveDialog.java
#	core/src/io/anuke/mindustry/input/GestureHandler.java
#	core/src/io/anuke/mindustry/mapeditor/MapEditorDialog.java
#	core/src/io/anuke/mindustry/ui/dialogs/FileChooser.java
#	core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java
#	gradle/wrapper/gradle-wrapper.properties
#	server/src/io/anuke/mindustry/server/ServerControl.java
This commit is contained in:
Anuken
2018-05-23 10:36:59 -04:00
74 changed files with 533 additions and 147 deletions

View File

@@ -1,9 +1,13 @@
package io.anuke.mindustry;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Filter;
import com.badlogic.gdx.graphics.PixmapIO;
import io.anuke.mindustry.core.*;
import io.anuke.mindustry.core.ContentLoader;
import io.anuke.mindustry.io.BundleLoader;
import io.anuke.mindustry.io.Platform;
import io.anuke.ucore.modules.ModuleCore;
import io.anuke.ucore.util.Log;

View File

@@ -11,9 +11,9 @@ import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.effect.Fire;
import io.anuke.mindustry.entities.effect.Puddle;
import io.anuke.mindustry.entities.effect.Shield;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.net.ClientDebug;
import io.anuke.mindustry.net.ServerDebug;
import io.anuke.ucore.entities.EffectEntity;
@@ -103,7 +103,7 @@ public class Vars{
public static final int tilesize = 8;
public static final Locale[] locales = {new Locale("en"), new Locale("fr"), new Locale("ru"), new Locale("uk", "UA"), new Locale("pl", "PL"),
public static final Locale[] locales = {new Locale("en"), new Locale("fr"), new Locale("ru"), new Locale("uk", "UA"), new Locale("pl"),
new Locale("de"), new Locale("pt", "BR"), new Locale("ko"), new Locale("in", "ID"), new Locale("ita"), new Locale("es")};
public static final Color[] playerColors = {

View File

@@ -102,7 +102,7 @@ public class Control extends Module{
}
}));
Musics.load("1.mp3", "2.mp3", "3.mp3", "4.mp3");
Musics.load("1.mp3", "2.mp3", "3.mp3", "4.mp3", "5.mp3", "6.mp3");
DefaultKeybinds.load();

View File

@@ -8,7 +8,6 @@ import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.SyncEntity;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.Net.SendMode;
import io.anuke.mindustry.net.NetworkIO;

View File

@@ -10,7 +10,7 @@ import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.SyncEntity;
import io.anuke.mindustry.gen.CallServer;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.io.Version;
import io.anuke.mindustry.net.*;
import io.anuke.mindustry.net.Administration.PlayerInfo;

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.io;
package io.anuke.mindustry.core;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Base64Coder;
import io.anuke.mindustry.core.ThreadHandler.ThreadProvider;
import io.anuke.ucore.core.Settings;
@@ -12,26 +13,40 @@ import java.util.Locale;
import java.util.Random;
public abstract class Platform {
/**Each separate game platform should set this instance to their own implementation.*/
public static Platform instance = new Platform() {};
/**Format the date using the default date formatter.*/
public String format(Date date){return "invalid";}
/**Format a number by adding in commas or periods where needed.*/
public String format(int number){return "invalid";}
/**Show a native error dialog.*/
public void showError(String text){}
/**Add a text input dialog that should show up after the field is tapped.*/
public void addDialog(TextField field){
addDialog(field, 16);
}
/**See addDialog().*/
public void addDialog(TextField field, int maxLength){}
/**Update discord RPC.*/
public void updateRPC(){}
/**Called when the game is exited.*/
public void onGameExit(){}
/**Open donation dialog. Currently android only.*/
public void openDonations(){}
/**Whether discord RPC is supported.*/
public boolean hasDiscord(){return true;}
/**Request Android permissions for writing files.*/
public void requestWritePerms(){}
/**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();
}
/**Whether joining games is supported.*/
public boolean canJoinGame(){
return true;
}
/**Whether debug mode is enabled.*/
public boolean isDebug(){return false;}
/**Must be 8 bytes in length.*/
public byte[] getUUID(){
@@ -46,6 +61,9 @@ public abstract class Platform {
}
return Base64Coder.decode(uuid);
}
/**Only used for iOS or android: open the share menu for a map or save.*/
public void shareFile(FileHandle file){}
/**Use the default thread provider from the kryonet module for this.*/
public ThreadProvider getThreadProvider(){
return new ThreadProvider() {
@Override public boolean isOnThread() {return true;}

View File

@@ -9,7 +9,7 @@ import io.anuke.mindustry.Vars;
import io.anuke.mindustry.editor.MapEditorDialog;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.ui.dialogs.*;
import io.anuke.mindustry.ui.fragments.*;
import io.anuke.ucore.core.Core;
@@ -173,9 +173,9 @@ public class UI extends SceneModule{
admins = new AdminsDialog();
traces = new TraceDialog();
localplayers = new LocalPlayerDialog();
build.begin(scene);
Group group = Core.scene.getRoot();
backfrag.build(group);

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.io;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.I18NBundle;
import io.anuke.mindustry.core.Platform;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.util.Log;

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.io;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.game.Difficulty;
import io.anuke.mindustry.game.GameMode;

View File

@@ -86,7 +86,7 @@ public class Saves {
current = slot;
}
public void importSave(FileHandle file) throws IOException{
public SaveSlot importSave(FileHandle file) throws IOException{
SaveSlot slot = new SaveSlot(nextSlot);
slot.importFile(file);
nextSlot ++;
@@ -94,6 +94,7 @@ public class Saves {
saves.add(slot);
slot.meta = SaveIO.getData(slot.index);
current = slot;
return slot;
}
public Array<SaveSlot> getSaveSlots(){

View File

@@ -10,7 +10,7 @@ import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.Pools;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.net.Packet.ImportantPacket;
import io.anuke.mindustry.net.Packet.UnimportantPacket;
import io.anuke.mindustry.net.Streamable.StreamBegin;

View File

@@ -9,6 +9,7 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.layout.Table;
import static io.anuke.mindustry.Vars.ios;
import static io.anuke.mindustry.Vars.ui;
public class AboutDialog extends FloatingDialog {
@@ -25,6 +26,10 @@ public class AboutDialog extends FloatingDialog {
ScrollPane pane = new ScrollPane(in, "clear");
for(LinkEntry link : Links.getLinks()){
if(ios && link.name.equals("google-play")){ //because Apple doesn't like me mentioning android
continue;
}
Table table = new Table("button");
table.margin(0);
table.table(img -> {
@@ -59,7 +64,10 @@ public class AboutDialog extends FloatingDialog {
content().add(pane).growX();
buttons().addButton("$text.credits", this::showCredits).size(200f, 64f);
buttons().addButton("$text.changelog.title", ui.changelog::show).size(200f, 64f);
if(!ios){
buttons().addButton("$text.changelog.title", ui.changelog::show).size(200f, 64f);
}
}
private void showCredits(){

View File

@@ -11,6 +11,8 @@ import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Log;
import static io.anuke.mindustry.Vars.ios;
public class ChangelogDialog extends FloatingDialog{
private final float vw = 600;
private Array<VersionInfo> versions;
@@ -22,13 +24,15 @@ public class ChangelogDialog extends FloatingDialog{
content().add("$text.changelog.loading");
Changelogs.getChangelog(result -> {
versions = result;
Gdx.app.postRunnable(this::setup);
}, t -> {
Log.err(t);
Gdx.app.postRunnable(this::setup);
});
if(!ios) {
Changelogs.getChangelog(result -> {
versions = result;
Gdx.app.postRunnable(this::setup);
}, t -> {
Log.err(t);
Gdx.app.postRunnable(this::setup);
});
}
}
void setup(){
@@ -45,7 +49,7 @@ public class ChangelogDialog extends FloatingDialog{
table.add("$text.changelog.error.android").padTop(8);
}
if(Vars.ios){
if(ios){
table.row();
table.add("$text.changelog.error.ios").padTop(8);
}

View File

@@ -6,8 +6,7 @@ import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pools;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.core.Platform;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.function.Consumer;

View File

@@ -5,8 +5,7 @@ import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Json;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.io.Version;
import io.anuke.mindustry.net.Host;
import io.anuke.mindustry.net.Net;

View File

@@ -1,6 +1,6 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.mindustry.io.Platform;
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;

View File

@@ -1,7 +1,10 @@
package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.io.Saves.SaveSlot;
import io.anuke.ucore.core.Core;
@@ -83,14 +86,24 @@ public class LoadDialog extends FloatingDialog{
if(!gwt) {
t.addImageButton("icon-save", "empty", 14 * 3, () -> {
new FileChooser("$text.save.export", false, file -> {
try {
slot.exportFile(file);
setup();
} catch (IOException e) {
ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false)));
}
}).show();
if(!ios) {
new FileChooser("$text.save.export", false, file -> {
try {
slot.exportFile(file);
setup();
} catch (IOException e) {
ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false)));
}
}).show();
}else{
try {
FileHandle file = Gdx.files.local("save-" + slot.getName() + ".mins");
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();
}
@@ -134,7 +147,7 @@ public class LoadDialog extends FloatingDialog{
slots.row();
if(gwt) return;
if(gwt || ios) return;
slots.addImageTextButton("$text.save.import", "icon-add", "clear", 14*3, () -> {
new FileChooser("$text.save.import", f -> f.extension().equals("mins"), true, file -> {
@@ -152,26 +165,30 @@ public class LoadDialog extends FloatingDialog{
}).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
}
public void runLoadSave(SaveSlot slot){
ui.loadfrag.show();
Timers.runTask(3f, () -> {
ui.loadfrag.hide();
hide();
try{
slot.load();
state.set(State.playing);
ui.paused.hide();
}catch(Exception e){
Log.err(e);
ui.paused.hide();
state.set(State.menu);
logic.reset();
ui.showError("$text.save.corrupted");
}
});
}
public void modifyButton(TextButton button, SaveSlot slot){
button.clicked(() -> {
if(!button.childrenPressed()){
ui.loadfrag.show();
Timers.runTask(3f, () -> {
ui.loadfrag.hide();
hide();
try{
slot.load();
state.set(State.playing);
ui.paused.hide();
}catch(Exception e){
Log.err(e);
ui.paused.hide();
state.set(State.menu);
logic.reset();
ui.showError("$text.save.corrupted");
}
});
runLoadSave(slot);
}
});
}

View File

@@ -8,7 +8,7 @@ import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetEvents;
import io.anuke.ucore.core.Core;

View File

@@ -2,7 +2,7 @@ package io.anuke.mindustry.ui.fragments;
import com.badlogic.gdx.Gdx;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.io.Version;
import io.anuke.mindustry.ui.MenuButton;
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
@@ -58,7 +58,8 @@ public class MenuFragment implements Fragment{
}else {
new table() {{
defaults().size(120f).pad(5);
float size = 120f;
defaults().size(size).pad(5);
float isize = 14f * 4;
new imagebutton("icon-play-2", isize, ui.levels::show).text("$text.play").padTop(4f);
@@ -71,13 +72,21 @@ public class MenuFragment implements Fragment{
row();
new imagebutton("icon-editor", isize, ui.editor::show).text("$text.editor").padTop(4f);
new table(){{
new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f);
defaults().size(size).pad(5);
new imagebutton("icon-info", isize, ui.about::show).text("$text.about.button").padTop(4f);
new imagebutton("icon-editor", isize, ui.editor::show).text("$text.editor").padTop(4f);
new imagebutton("icon-donate", isize, Platform.instance::openDonations).text("$text.donate").padTop(4f);
new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f);
new imagebutton("icon-info", isize, ui.about::show).text("$text.about.button").padTop(4f);
if (!ios) {
new imagebutton("icon-donate", isize, Platform.instance::openDonations).text("$text.donate").padTop(4f);
}
}}.colspan(4).end();
}}.end();
}
}}.end();

View File

@@ -35,6 +35,7 @@ public class PlayerListFragment implements Fragment{
public void build(Group parent){
new table(){{
new table("pane"){{
touchable(Touchable.enabled);
margin(14f);
new label(() -> Bundles.format(playerGroup.size() == 1 ? "text.players.single" :
"text.players", playerGroup.size()));