diff --git a/android/build.gradle b/android/build.gradle index 1380bed960..bc3c955d02 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -10,6 +10,7 @@ repositories { dependencies { implementation 'com.android.support:support-v4:22.1.1' implementation 'org.sufficientlysecure:donations:2.5' + implementation 'com.google.android.gms:play-services-auth:11.8.0' } task deploy(type: Copy){ @@ -22,7 +23,7 @@ task deploy(type: Copy){ android { buildToolsVersion '26.0.2' - compileSdkVersion 27 + compileSdkVersion 26 sourceSets { main { manifest.srcFile 'AndroidManifest.xml' @@ -58,7 +59,7 @@ android { } applicationId "io.anuke.mindustry" - minSdkVersion 9 + minSdkVersion 14 targetSdkVersion 27 versionCode code versionName versionNameResult diff --git a/android/src/io/anuke/mindustry/AndroidLauncher.java b/android/src/io/anuke/mindustry/AndroidLauncher.java index f380aba764..beb54052be 100644 --- a/android/src/io/anuke/mindustry/AndroidLauncher.java +++ b/android/src/io/anuke/mindustry/AndroidLauncher.java @@ -8,9 +8,14 @@ import android.os.Build; import android.os.Bundle; import android.provider.Settings.Secure; import android.telephony.TelephonyManager; +import android.util.Log; import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; import com.badlogic.gdx.utils.Base64Coder; +import com.google.android.gms.common.GoogleApiAvailability; +import com.google.android.gms.common.GooglePlayServicesNotAvailableException; +import com.google.android.gms.common.GooglePlayServicesRepairableException; +import com.google.android.gms.security.ProviderInstaller; import io.anuke.kryonet.DefaultThreadImpl; import io.anuke.kryonet.KryoClient; import io.anuke.kryonet.KryoServer; @@ -119,9 +124,8 @@ public class AndroidLauncher extends AndroidApplication{ return data; }catch (Exception e){ - Settings.defaults("uuid", ""); - String uuid = Settings.getString("uuid"); + String uuid = Settings.getString("uuid", ""); if(uuid.isEmpty()){ byte[] result = new byte[8]; new Random().nextBytes(result); @@ -135,6 +139,15 @@ public class AndroidLauncher extends AndroidApplication{ } }; + try { + ProviderInstaller.installIfNeeded(this); + } catch (GooglePlayServicesRepairableException e) { + GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); + apiAvailability.getErrorDialog(this, e.getConnectionStatusCode(), 0).show(); + } catch (GooglePlayServicesNotAvailableException e) { + Log.e("SecurityException", "Google Play Services not available."); + } + if(doubleScaleTablets && isTablet(this.getContext())){ Unit.dp.addition = 0.5f; } diff --git a/android/src/io/anuke/mindustry/TextFieldDialogListener.java b/android/src/io/anuke/mindustry/TextFieldDialogListener.java index e533a23951..c6f328d785 100644 --- a/android/src/io/anuke/mindustry/TextFieldDialogListener.java +++ b/android/src/io/anuke/mindustry/TextFieldDialogListener.java @@ -26,7 +26,7 @@ public class TextFieldDialogListener extends ClickListener{ } public static void add(TextField field){ - add(field, 0, 15); + add(field, 0, 16); } //type - 0 is text, 1 is numbers, 2 is decimals diff --git a/build.gradle b/build.gradle index 98e2f7c15e..4a7535ec55 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,7 @@ buildscript { jcenter() } dependencies { + classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0' classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6' classpath 'com.android.tools.build:gradle:3.0.1' classpath "com.badlogicgames.gdx:gdx-tools:1.9.8" @@ -24,6 +25,7 @@ allprojects { versionType = 'pre-alpha' appName = 'Mindustry' gdxVersion = '1.9.8' + roboVMVersion = '2.3.0' aiVersion = '1.8.1' uCoreVersion = 'dd5eb72' @@ -103,6 +105,27 @@ project(":android") { } } +project(":ios") { + apply plugin: "java" + apply plugin: "robovm" + + + dependencies { + compile project(":core") + implementation project(":kryonet") + + compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion" + compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion" + compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios" + } + + robovm { + iosSignIdentity = "a" + iosProvisioningProfile = "" + } +} + project(":core") { apply plugin: "java" diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index caded6bfe6..9a3f5de03a 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1,4 +1,4 @@ -text.about=Created by [ROYAL]Anuken[] - [SKY]anukendev@gmail.com[]\nOriginally an entry in the [orange]GDL[] Metal Monstrosity Jam.\n\nCredits:\n- SFX made with [YELLOW]bfxr[]\n- Music made by [GREEN]RoccoW[] / found on [lime]FreeMusicArchive.org[]\n\nSpecial thanks to:\n- [coral]MitchellFJN[]: extensive playtesting and feedback\n- [sky]Luxray5474[]: wiki work, code contributions\n- [lime]Epowerj[]: code build system, icon\n- All the beta testers on itch.io and Google Play\n +text.about=Created by [ROYAL]Anuken[] - [SKY]anukendev@gmail.com[]\nOriginally an entry in the [orange]GDL[] Metal Monstrosity Jam.\n\nCredits:\n- SFX made with [YELLOW]bfxr[]\n- Music made by [GREEN]a drop a day[]\n\nSpecial thanks to:\n- [coral]MitchellFJN[]: extensive playtesting and feedback\n- [sky]Luxray5474[]: wiki work, code contributions\n- [lime]Epowerj[]: code build system, icon\n- All the beta testers on itch.io and Google Play\n text.credits=Credits text.discord=Join the mindustry discord! text.changes=[SCARLET]Attention!\n[]Some important game mechanics have been changed.\n\n- [accent]Teleporters[] now use power.\n- [accent]Smelteries[] and [accent]crucibles[] now have a maximum item capacity.\n- [accent]Crucibles[] now require coal as fuel. @@ -133,7 +133,8 @@ text.back=Back text.quit.confirm=Are you sure you want to quit? text.changelog.title=Changelog text.changelog.loading=Getting changelog... -text.changelog.error.android=[orange]Note that the changelog does not work on Android 4.4 and below!\nThis is due to an internal Android bug. +text.changelog.error.android=[orange]Note that the changelog sometimes does not work on Android 4.4 and below!\nThis is due to an internal Android bug. +text.changelog.error.ios=[orange]The changelog is currently not supported in iOS. text.changelog.error=[scarlet]Error getting changelog!\nCheck your internet connection. text.changelog.current=[yellow][[Current version] text.changelog.latest=[orange][[Latest version] diff --git a/core/assets/music/1.mp3 b/core/assets/music/1.mp3 new file mode 100644 index 0000000000..cdbb366b48 Binary files /dev/null and b/core/assets/music/1.mp3 differ diff --git a/core/assets/music/1.ogg b/core/assets/music/1.ogg deleted file mode 100644 index bb92288e32..0000000000 Binary files a/core/assets/music/1.ogg and /dev/null differ diff --git a/core/assets/music/2.mp3 b/core/assets/music/2.mp3 new file mode 100644 index 0000000000..cab7d699eb Binary files /dev/null and b/core/assets/music/2.mp3 differ diff --git a/core/assets/music/2.ogg b/core/assets/music/2.ogg deleted file mode 100644 index a41c41249d..0000000000 Binary files a/core/assets/music/2.ogg and /dev/null differ diff --git a/core/assets/music/3.mp3 b/core/assets/music/3.mp3 new file mode 100644 index 0000000000..f03d72bbcc Binary files /dev/null and b/core/assets/music/3.mp3 differ diff --git a/core/assets/music/3.ogg b/core/assets/music/3.ogg deleted file mode 100644 index e19290f0e9..0000000000 Binary files a/core/assets/music/3.ogg and /dev/null differ diff --git a/core/assets/music/4.mp3 b/core/assets/music/4.mp3 new file mode 100644 index 0000000000..48c4ff24fc Binary files /dev/null and b/core/assets/music/4.mp3 differ diff --git a/core/assets/music/4.ogg b/core/assets/music/4.ogg deleted file mode 100644 index 0a5bff409e..0000000000 Binary files a/core/assets/music/4.ogg and /dev/null differ diff --git a/core/assets/music/5.mp3 b/core/assets/music/5.mp3 new file mode 100644 index 0000000000..65a5034fbf Binary files /dev/null and b/core/assets/music/5.mp3 differ diff --git a/core/assets/music/6.mp3 b/core/assets/music/6.mp3 new file mode 100644 index 0000000000..88f04f33a8 Binary files /dev/null and b/core/assets/music/6.mp3 differ diff --git a/core/assets/sounds/bang.mp3 b/core/assets/sounds/bang.mp3 new file mode 100644 index 0000000000..d859b89aab Binary files /dev/null and b/core/assets/sounds/bang.mp3 differ diff --git a/core/assets/sounds/bang.ogg b/core/assets/sounds/bang.ogg deleted file mode 100644 index 9f8de5b434..0000000000 Binary files a/core/assets/sounds/bang.ogg and /dev/null differ diff --git a/core/assets/sounds/bang2.mp3 b/core/assets/sounds/bang2.mp3 new file mode 100644 index 0000000000..71e3deffa4 Binary files /dev/null and b/core/assets/sounds/bang2.mp3 differ diff --git a/core/assets/sounds/bang2.ogg b/core/assets/sounds/bang2.ogg deleted file mode 100644 index 6e744bbacf..0000000000 Binary files a/core/assets/sounds/bang2.ogg and /dev/null differ diff --git a/core/assets/sounds/bigshot.mp3 b/core/assets/sounds/bigshot.mp3 new file mode 100644 index 0000000000..2139d15232 Binary files /dev/null and b/core/assets/sounds/bigshot.mp3 differ diff --git a/core/assets/sounds/bigshot.ogg b/core/assets/sounds/bigshot.ogg deleted file mode 100644 index 764d0ff910..0000000000 Binary files a/core/assets/sounds/bigshot.ogg and /dev/null differ diff --git a/core/assets/sounds/blast.mp3 b/core/assets/sounds/blast.mp3 new file mode 100644 index 0000000000..f05f080eae Binary files /dev/null and b/core/assets/sounds/blast.mp3 differ diff --git a/core/assets/sounds/blast.ogg b/core/assets/sounds/blast.ogg deleted file mode 100644 index c772039289..0000000000 Binary files a/core/assets/sounds/blast.ogg and /dev/null differ diff --git a/core/assets/sounds/bloop.mp3 b/core/assets/sounds/bloop.mp3 new file mode 100644 index 0000000000..c77f53d7fe Binary files /dev/null and b/core/assets/sounds/bloop.mp3 differ diff --git a/core/assets/sounds/bloop.ogg b/core/assets/sounds/bloop.ogg deleted file mode 100644 index d07415f877..0000000000 Binary files a/core/assets/sounds/bloop.ogg and /dev/null differ diff --git a/core/assets/sounds/break.mp3 b/core/assets/sounds/break.mp3 new file mode 100644 index 0000000000..56487e4af1 Binary files /dev/null and b/core/assets/sounds/break.mp3 differ diff --git a/core/assets/sounds/break.ogg b/core/assets/sounds/break.ogg deleted file mode 100644 index 96e51cfefe..0000000000 Binary files a/core/assets/sounds/break.ogg and /dev/null differ diff --git a/core/assets/sounds/corexplode.mp3 b/core/assets/sounds/corexplode.mp3 new file mode 100644 index 0000000000..2ee50fb405 Binary files /dev/null and b/core/assets/sounds/corexplode.mp3 differ diff --git a/core/assets/sounds/corexplode.ogg b/core/assets/sounds/corexplode.ogg deleted file mode 100644 index 94babbb4e8..0000000000 Binary files a/core/assets/sounds/corexplode.ogg and /dev/null differ diff --git a/core/assets/sounds/die.mp3 b/core/assets/sounds/die.mp3 new file mode 100644 index 0000000000..ae87ef7aa9 Binary files /dev/null and b/core/assets/sounds/die.mp3 differ diff --git a/core/assets/sounds/die.ogg b/core/assets/sounds/die.ogg deleted file mode 100644 index d4520c4f11..0000000000 Binary files a/core/assets/sounds/die.ogg and /dev/null differ diff --git a/core/assets/sounds/enemyshoot.mp3 b/core/assets/sounds/enemyshoot.mp3 new file mode 100644 index 0000000000..7deb792726 Binary files /dev/null and b/core/assets/sounds/enemyshoot.mp3 differ diff --git a/core/assets/sounds/enemyshoot.ogg b/core/assets/sounds/enemyshoot.ogg deleted file mode 100644 index 7b8911baef..0000000000 Binary files a/core/assets/sounds/enemyshoot.ogg and /dev/null differ diff --git a/core/assets/sounds/explosion.mp3 b/core/assets/sounds/explosion.mp3 new file mode 100644 index 0000000000..f5f6e08fa7 Binary files /dev/null and b/core/assets/sounds/explosion.mp3 differ diff --git a/core/assets/sounds/explosion.ogg b/core/assets/sounds/explosion.ogg deleted file mode 100644 index e0992f0555..0000000000 Binary files a/core/assets/sounds/explosion.ogg and /dev/null differ diff --git a/core/assets/sounds/flame.mp3 b/core/assets/sounds/flame.mp3 new file mode 100644 index 0000000000..a49ae44245 Binary files /dev/null and b/core/assets/sounds/flame.mp3 differ diff --git a/core/assets/sounds/flame.ogg b/core/assets/sounds/flame.ogg deleted file mode 100644 index 35aa016ef5..0000000000 Binary files a/core/assets/sounds/flame.ogg and /dev/null differ diff --git a/core/assets/sounds/flame2.mp3 b/core/assets/sounds/flame2.mp3 new file mode 100644 index 0000000000..c0d71a7b1d Binary files /dev/null and b/core/assets/sounds/flame2.mp3 differ diff --git a/core/assets/sounds/flame2.ogg b/core/assets/sounds/flame2.ogg deleted file mode 100644 index b0343457e5..0000000000 Binary files a/core/assets/sounds/flame2.ogg and /dev/null differ diff --git a/core/assets/sounds/laser.mp3 b/core/assets/sounds/laser.mp3 new file mode 100644 index 0000000000..f0b2398aef Binary files /dev/null and b/core/assets/sounds/laser.mp3 differ diff --git a/core/assets/sounds/laser.ogg b/core/assets/sounds/laser.ogg deleted file mode 100644 index 8b0d5ccdcf..0000000000 Binary files a/core/assets/sounds/laser.ogg and /dev/null differ diff --git a/core/assets/sounds/lasershot.mp3 b/core/assets/sounds/lasershot.mp3 new file mode 100644 index 0000000000..1db62aa08a Binary files /dev/null and b/core/assets/sounds/lasershot.mp3 differ diff --git a/core/assets/sounds/lasershot.ogg b/core/assets/sounds/lasershot.ogg deleted file mode 100644 index f22a189e27..0000000000 Binary files a/core/assets/sounds/lasershot.ogg and /dev/null differ diff --git a/core/assets/sounds/missile.mp3 b/core/assets/sounds/missile.mp3 new file mode 100644 index 0000000000..89af9f5157 Binary files /dev/null and b/core/assets/sounds/missile.mp3 differ diff --git a/core/assets/sounds/missile.ogg b/core/assets/sounds/missile.ogg deleted file mode 100644 index 8c35b516cd..0000000000 Binary files a/core/assets/sounds/missile.ogg and /dev/null differ diff --git a/core/assets/sounds/ping.mp3 b/core/assets/sounds/ping.mp3 new file mode 100644 index 0000000000..b9692a37fc Binary files /dev/null and b/core/assets/sounds/ping.mp3 differ diff --git a/core/assets/sounds/ping.ogg b/core/assets/sounds/ping.ogg deleted file mode 100644 index c3e797cebb..0000000000 Binary files a/core/assets/sounds/ping.ogg and /dev/null differ diff --git a/core/assets/sounds/place.mp3 b/core/assets/sounds/place.mp3 new file mode 100644 index 0000000000..3f5369e4fa Binary files /dev/null and b/core/assets/sounds/place.mp3 differ diff --git a/core/assets/sounds/place.ogg b/core/assets/sounds/place.ogg deleted file mode 100644 index cb7d26844b..0000000000 Binary files a/core/assets/sounds/place.ogg and /dev/null differ diff --git a/core/assets/sounds/purchase.mp3 b/core/assets/sounds/purchase.mp3 new file mode 100644 index 0000000000..6edc48eebd Binary files /dev/null and b/core/assets/sounds/purchase.mp3 differ diff --git a/core/assets/sounds/purchase.ogg b/core/assets/sounds/purchase.ogg deleted file mode 100644 index fe43a21926..0000000000 Binary files a/core/assets/sounds/purchase.ogg and /dev/null differ diff --git a/core/assets/sounds/railgun.mp3 b/core/assets/sounds/railgun.mp3 new file mode 100644 index 0000000000..a9bb203a7c Binary files /dev/null and b/core/assets/sounds/railgun.mp3 differ diff --git a/core/assets/sounds/railgun.ogg b/core/assets/sounds/railgun.ogg deleted file mode 100644 index 75a4ea886b..0000000000 Binary files a/core/assets/sounds/railgun.ogg and /dev/null differ diff --git a/core/assets/sounds/resonate.mp3 b/core/assets/sounds/resonate.mp3 new file mode 100644 index 0000000000..ea456660de Binary files /dev/null and b/core/assets/sounds/resonate.mp3 differ diff --git a/core/assets/sounds/resonate.ogg b/core/assets/sounds/resonate.ogg deleted file mode 100644 index 4ba46f9fb7..0000000000 Binary files a/core/assets/sounds/resonate.ogg and /dev/null differ diff --git a/core/assets/sounds/respawn.mp3 b/core/assets/sounds/respawn.mp3 new file mode 100644 index 0000000000..56e6fff2fc Binary files /dev/null and b/core/assets/sounds/respawn.mp3 differ diff --git a/core/assets/sounds/respawn.ogg b/core/assets/sounds/respawn.ogg deleted file mode 100644 index bba099421c..0000000000 Binary files a/core/assets/sounds/respawn.ogg and /dev/null differ diff --git a/core/assets/sounds/shoot.mp3 b/core/assets/sounds/shoot.mp3 new file mode 100644 index 0000000000..4a826fdfdd Binary files /dev/null and b/core/assets/sounds/shoot.mp3 differ diff --git a/core/assets/sounds/shoot.ogg b/core/assets/sounds/shoot.ogg deleted file mode 100644 index bd1986d256..0000000000 Binary files a/core/assets/sounds/shoot.ogg and /dev/null differ diff --git a/core/assets/sounds/shoot_old.mp3 b/core/assets/sounds/shoot_old.mp3 new file mode 100644 index 0000000000..bfe18e8806 Binary files /dev/null and b/core/assets/sounds/shoot_old.mp3 differ diff --git a/core/assets/sounds/shoot_old.ogg b/core/assets/sounds/shoot_old.ogg deleted file mode 100644 index cdd2363d23..0000000000 Binary files a/core/assets/sounds/shoot_old.ogg and /dev/null differ diff --git a/core/assets/sounds/spawn.mp3 b/core/assets/sounds/spawn.mp3 new file mode 100644 index 0000000000..c0235b640c Binary files /dev/null and b/core/assets/sounds/spawn.mp3 differ diff --git a/core/assets/sounds/spawn.ogg b/core/assets/sounds/spawn.ogg deleted file mode 100644 index 0f62d2655a..0000000000 Binary files a/core/assets/sounds/spawn.ogg and /dev/null differ diff --git a/core/assets/sounds/tesla.mp3 b/core/assets/sounds/tesla.mp3 new file mode 100644 index 0000000000..c8f053fbd3 Binary files /dev/null and b/core/assets/sounds/tesla.mp3 differ diff --git a/core/assets/sounds/tesla.ogg b/core/assets/sounds/tesla.ogg deleted file mode 100644 index f6da103775..0000000000 Binary files a/core/assets/sounds/tesla.ogg and /dev/null differ diff --git a/core/assets/sounds/waveend.mp3 b/core/assets/sounds/waveend.mp3 new file mode 100644 index 0000000000..60a48c0ba4 Binary files /dev/null and b/core/assets/sounds/waveend.mp3 differ diff --git a/core/assets/sounds/waveend.ogg b/core/assets/sounds/waveend.ogg deleted file mode 100644 index 6c20f4eed3..0000000000 Binary files a/core/assets/sounds/waveend.ogg and /dev/null differ diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index dbb78e1042..3d8c0c91d7 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -27,9 +27,12 @@ import java.util.Locale; public class Vars{ - public static final boolean testAndroid = false; + public static final boolean testMobile = false; //shorthand for whether or not this is running on android - public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid; + public static final boolean mobile = (Gdx.app.getType() == ApplicationType.Android) || + Gdx.app.getType() == ApplicationType.iOS || testMobile; + public static final boolean ios = Gdx.app.getType() == ApplicationType.iOS; + public static final boolean android = Gdx.app.getType() == ApplicationType.Android; //shorthand for whether or not this is running on GWT public static final boolean gwt = (Gdx.app.getType() == ApplicationType.WebGL); //whether to send block state change events to players @@ -39,7 +42,7 @@ public class Vars{ //respawn time in frames public static final float respawnduration = 60*4; //time between waves in frames (on normal mode) - public static final float wavespace = 60*60*(android ? 1 : 1); + public static final float wavespace = 60*60*(mobile ? 1 : 1); //waves can last no longer than 3 minutes, otherwise the next one spawns public static final float maxwavespace = 60*60*4f; //advance time the pathfinding starts at diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 5b4d652508..c6dbd9be5d 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -60,7 +60,7 @@ public class Control extends Module{ Gdx.input.setCatchBackKey(true); - if(android){ + if(mobile){ input = new AndroidInput(); }else{ input = new DesktopInput(); @@ -98,19 +98,21 @@ public class Control extends Module{ item.init(); } - Sounds.load("shoot.ogg", "place.ogg", "explosion.ogg", "enemyshoot.ogg", - "corexplode.ogg", "break.ogg", "spawn.ogg", "flame.ogg", "die.ogg", - "respawn.ogg", "purchase.ogg", "flame2.ogg", "bigshot.ogg", "laser.ogg", "lasershot.ogg", - "ping.ogg", "tesla.ogg", "waveend.ogg", "railgun.ogg", "blast.ogg", "bang2.ogg"); + Sounds.load("shoot.mp3", "place.mp3", "explosion.mp3", "enemyshoot.mp3", + "corexplode.mp3", "break.mp3", "spawn.mp3", "flame.mp3", "die.mp3", + "respawn.mp3", "purchase.mp3", "flame2.mp3", "bigshot.mp3", "laser.mp3", "lasershot.mp3", + "ping.mp3", "tesla.mp3", "waveend.mp3", "railgun.mp3", "blast.mp3", "bang2.mp3"); Sounds.setFalloff(9000f); + Musics.load("1.mp3", "2.mp3", "3.mp3", "4.mp3", "5.mp3", "6.mp3"); + DefaultKeybinds.load(); Settings.defaultList( "ip", "localhost", "port", port+"", - "name", android || gwt ? "player" : UCore.getProperty("user.name"), + "name", mobile || gwt ? "player" : UCore.getProperty("user.name"), "servers", "", "color", Color.rgba8888(playerColors[8]), "lastVersion", "3.2", @@ -121,7 +123,7 @@ public class Control extends Module{ player = new Player(); player.name = Settings.getString("name"); - player.mech = android ? Mechs.standardShip : Mechs.standard; + player.mech = mobile ? Mechs.standardShip : Mechs.standard; player.color.set(Settings.getInt("color")); player.isLocal = true; diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index a7a004c0f4..9ac24e69b7 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -68,7 +68,7 @@ public class NetClient extends Module { ConnectPacket c = new ConnectPacket(); c.name = player.name; - c.android = android; + c.android = mobile; c.color = Color.rgba8888(player.color); c.uuid = Platform.instance.getUUID(); diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 967d371261..b8b1ffadb9 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -170,7 +170,7 @@ public class NetServer extends Module{ if(!Timers.get("fastshoot-" + id + "-" + weapon.id, wtrc)){ info.fastShots.getAndIncrement(weapon.id, 0, 1); - if(info.fastShots.get(weapon.id, 0) > (int)(wtrc / (weapon.getReload() / 2f)) + 6){ + if(info.fastShots.get(weapon.id, 0) > (int)(wtrc / (weapon.getReload() / 2f)) + 8){ kick(id, KickReason.kick); } }else{ diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 25b83c07d3..1a53f75e6d 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -173,7 +173,7 @@ public class Renderer extends RendererModule{ float deltax = camera.position.x - prex, deltay = camera.position.y - prey; - if(android){ + if(mobile){ player.x += camera.position.x - prevx; player.y += camera.position.y - prevy; } @@ -405,7 +405,7 @@ public class Renderer extends RendererModule{ int tilex = control.input().getBlockX(); int tiley = control.input().getBlockY(); - if(android){ + if(mobile){ Vector2 vec = Graphics.world(Gdx.input.getX(0), Gdx.input.getY(0)); tilex = Mathf.scl2(vec.x, tilesize); tiley = Mathf.scl2(vec.y, tilesize); @@ -414,7 +414,7 @@ public class Renderer extends RendererModule{ InputHandler input = control.input(); //draw placement box - if((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && (!ui.hasMouse() || android) + if((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && (!ui.hasMouse() || mobile) && control.input().drawPlace())){ input.placeMode.draw(control.input().getBlockX(), control.input().getBlockY(), @@ -425,7 +425,7 @@ public class Renderer extends RendererModule{ }else if(input.breakMode.delete && control.input().drawPlace() && (input.recipe == null || !state.inventory.hasItems(input.recipe.requirements)) - && (input.placeMode.delete || input.breakMode.both || !android)){ + && (input.placeMode.delete || input.breakMode.both || !mobile)){ if(input.breakMode == PlaceMode.holdDelete) input.breakMode.draw(tilex, tiley, 0, 0); diff --git a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java index 95eadd2a92..19df515a07 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java @@ -166,7 +166,7 @@ public class MapEditorDialog extends Dialog{ openImage.show(); menu.hide(); }); - + /* loadDialog = new MapLoadDialog(map -> { @@ -365,13 +365,13 @@ public class MapEditorDialog extends Dialog{ }}.left().growY().end(); - + new table("button"){{ margin(5); marginBottom(10); add(view).grow(); }}.grow().end(); - + new table(){{ row(); @@ -413,7 +413,7 @@ public class MapEditorDialog extends Dialog{ } } } - + private void addBlockSelection(Table table){ Table content = new Table(); pane = new ScrollPane(content, "volume"); diff --git a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java index 04dfab35ed..8773402088 100644 --- a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java @@ -28,7 +28,7 @@ public class BlockRenderer{ private int iterateidx = 0; private float storeX, storeY; - + public BlockRenderer(){ floorRenderer = new FloorRenderer(); @@ -59,7 +59,7 @@ public class BlockRenderer{ int rangex = (int) (camera.viewportWidth * camera.zoom / tilesize / 2)+2; int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2)+2; - + int expandr = 4; Graphics.surface(renderer.shadowSurface); diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 00e1c6fd5c..49e684a3fc 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -25,8 +25,8 @@ public abstract class InputHandler extends InputAdapter{ public float breaktime = 0; public Recipe recipe; public int rotation; - public PlaceMode placeMode = android ? PlaceMode.cursor : PlaceMode.hold; - public PlaceMode breakMode = android ? PlaceMode.none : PlaceMode.holdDelete; + public PlaceMode placeMode = mobile ? PlaceMode.cursor : PlaceMode.hold; + public PlaceMode breakMode = mobile ? PlaceMode.none : PlaceMode.holdDelete; public PlaceMode lastPlaceMode = placeMode; public PlaceMode lastBreakMode = breakMode; public boolean droppingItem, transferring; diff --git a/core/src/io/anuke/mindustry/input/PlaceMode.java b/core/src/io/anuke/mindustry/input/PlaceMode.java index 76d789d3e7..0dc63c2b04 100644 --- a/core/src/io/anuke/mindustry/input/PlaceMode.java +++ b/core/src/io/anuke/mindustry/input/PlaceMode.java @@ -28,8 +28,8 @@ public enum PlaceMode{ float x = tilex * tilesize; float y = tiley * tilesize; - boolean valid = control.input().validPlace(tilex, tiley, control.input().recipe.result) && (android || control.input().cursorNear()); - + boolean valid = control.input().validPlace(tilex, tiley, control.input().recipe.result) && (mobile || control.input().cursorNear()); + Vector2 offset = control.input().recipe.result.getPlaceOffset(); float si = MathUtils.sin(Timers.time() / 6f) + 1.5f; @@ -89,7 +89,7 @@ public enum PlaceMode{ tile = tile.getLinked(); float fin = control.input().breaktime / tile.getBreakTime(); - if(android && control.input().breaktime > 0){ + if(mobile && control.input().breaktime > 0){ Draw.color(Colors.get("breakStart"), Colors.get("break"), fin); Lines.poly(tile.drawx(), tile.drawy(), 25, 4 + (1f - fin) * 26); } @@ -169,8 +169,8 @@ public enum PlaceMode{ process(tilex, tiley, endx, endy); tilex = this.tilex; tiley = this.tiley; endx = this.endx; endy = this.endy; - - if(android){ + + if(mobile){ ToolFragment t = ui.toolfrag; if(!t.confirming || t.px != tilex || t.py != tiley || t.px2 != endx || t.py2 != endy) { t.confirming = true; @@ -236,7 +236,7 @@ public enum PlaceMode{ } public void draw(int tilex, int tiley, int endx, int endy){ - if(android && !Gdx.input.isTouched(0) && !control.showCursor()){ + if(mobile && !Gdx.input.isTouched(0) && !control.showCursor()){ return; } @@ -300,8 +300,8 @@ public enum PlaceMode{ Lines.stroke(2f); Draw.color("placeInvalid"); Lines.crect( - px * t + (isX ? 0 : offset.x) + (ex < tx && isX ? t : 0) - (block.size == 3 && ex > tx && isX ? t : 0), - py * t + (isX ? offset.y : 0) + (ey < ty && !isX ? t : 0) - (block.size == 3 && ey > ty && !isX ? t : 0), + px * t + (isX ? 0 : offset.x) + (ex < tx && isX && block.size > 1 ? t : 0) - (block.size == 3 && ex > tx && isX ? t : 0), + py * t + (isX ? offset.y : 0) + (ey < ty && !isX && block.size > 1 ? t : 0) - (block.size == 3 && ey > ty && !isX ? t : 0), t*(isX ? 1 : block.size), t*(isX ? block.size : 1)); Draw.color("place"); diff --git a/core/src/io/anuke/mindustry/io/Platform.java b/core/src/io/anuke/mindustry/io/Platform.java index 1f361c8895..b280fdf4d0 100644 --- a/core/src/io/anuke/mindustry/io/Platform.java +++ b/core/src/io/anuke/mindustry/io/Platform.java @@ -1,12 +1,15 @@ package io.anuke.mindustry.io; +import com.badlogic.gdx.utils.Base64Coder; import io.anuke.mindustry.core.ThreadHandler.ThreadProvider; +import io.anuke.ucore.core.Settings; import io.anuke.ucore.entities.Entity; import io.anuke.ucore.entities.EntityGroup; import io.anuke.ucore.scene.ui.TextField; import java.util.Date; import java.util.Locale; +import java.util.Random; public abstract class Platform { public static Platform instance = new Platform() {}; @@ -31,7 +34,18 @@ public abstract class Platform { } public boolean isDebug(){return false;} /**Must be 8 bytes in length.*/ - public byte[] getUUID(){return null;} + public byte[] getUUID(){ + String uuid = Settings.getString("uuid", ""); + if(uuid.isEmpty()){ + byte[] result = new byte[8]; + new Random().nextBytes(result); + uuid = new String(Base64Coder.encode(result)); + Settings.putString("uuid", uuid); + Settings.save(); + return result; + } + return Base64Coder.decode(uuid); + } public ThreadProvider getThreadProvider(){ return new ThreadProvider() { @Override public boolean isOnThread() {return true;} diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ChangelogDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ChangelogDialog.java index 665b5831dd..a6251d4c6f 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ChangelogDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ChangelogDialog.java @@ -44,6 +44,11 @@ public class ChangelogDialog extends FloatingDialog{ table.row(); table.add("$text.changelog.error.android").padTop(8); } + + if(Vars.ios){ + table.row(); + table.add("$text.changelog.error.ios").padTop(8); + } }else{ for(VersionInfo info : versions){ Table in = new Table("clear"); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java index d588c7c089..7ba3921bc0 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java @@ -35,7 +35,7 @@ public class PausedDialog extends FloatingDialog{ if(!Net.active()) state.set(State.paused); }); - if(!android){ + if(!mobile){ content().defaults().width(220).height(50); content().addButton("$text.back", () -> { diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java index ce6f3cab9c..9b1c077250 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -84,7 +84,7 @@ public class SettingsMenuDialog extends SettingsDialog{ menu.addButton("$text.settings.graphics", () -> visible(1)); menu.row(); menu.addButton("$text.settings.sound", () -> visible(2)); - if(!Vars.android) { + if(!Vars.mobile) { menu.row(); menu.addButton("$text.settings.controls", ui.controls::show); } @@ -142,7 +142,7 @@ public class SettingsMenuDialog extends SettingsDialog{ } } - if(!android && !gwt) { + if(!mobile && !gwt) { graphics.checkPref("vsync", true, b -> Gdx.graphics.setVSync(b)); graphics.checkPref("fullscreen", false, b -> { if (b) { diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java index d0861945f5..99b7d2bb6c 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java @@ -39,7 +39,7 @@ public class BlocksFragment implements Fragment{ private boolean shown = true; private Recipe hoveredDescriptionRecipe; private IntSet itemset = new IntSet(); - + public void build(){ InputHandler input = control.input(); diff --git a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java index f4acb97e59..9d28551304 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java @@ -107,12 +107,12 @@ public class ChatFragment extends Table implements Fragment{ add(chatfield).padBottom(offsety).padLeft(offsetx).growX().padRight(offsetx).height(28); - if(Vars.android) { + if(Vars.mobile) { marginBottom(105f); marginRight(240f); } - if(Vars.android) { + if(Vars.mobile) { addImageButton("icon-arrow-right", 14 * 2, this::toggle).size(46f, 51f).visible(() -> chatOpen).pad(2f); } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 9e8240ea1a..29ece10da0 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -71,14 +71,14 @@ public class HudFragment implements Fragment{ }).get(); new imagebutton("icon-pause", isize, () -> { - if(android) DebugFragment.printDebugInfo(); - if (Net.active() && android) { + if(mobile) DebugFragment.printDebugInfo(); + if (Net.active() && mobile) { ui.listfrag.visible = !ui.listfrag.visible; } else { state.set(state.is(State.paused) ? State.playing : State.paused); } }).update(i -> { - if (Net.active() && android) { + if (Net.active() && mobile) { i.getStyle().imageUp = Core.skin.getDrawable("icon-players"); } else { i.setDisabled(Net.active()); @@ -87,7 +87,7 @@ public class HudFragment implements Fragment{ }).get(); new imagebutton("icon-settings", isize, () -> { - if (Net.active() && android) { + if (Net.active() && mobile) { if (ui.chatfrag.chatOpen()) { ui.chatfrag.hide(); } else { @@ -97,7 +97,7 @@ public class HudFragment implements Fragment{ ui.settings.show(); } }).update(i -> { - if (Net.active() && android) { + if (Net.active() && mobile) { i.getStyle().imageUp = Core.skin.getDrawable("icon-chat"); } else { i.getStyle().imageUp = Core.skin.getDrawable("icon-settings"); diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index 3bb831dd07..2fdf323635 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -18,7 +18,7 @@ public class MenuFragment implements Fragment{ new table(){{ visible(() -> state.is(State.menu)); - if(!android){ + if(!mobile){ new table(){{ float w = 200f; diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index c25fa3a103..c4717f2be9 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -29,7 +29,7 @@ public class PlacementFragment implements Fragment{ Label modelabel; public void build(){ - if(!android) return; + if(!mobile) return; InputHandler input = control.input(); diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java index e1300c6259..295043ef10 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java @@ -63,7 +63,7 @@ public class PlayerListFragment implements Fragment{ }}.end(); update(t -> { - if(!android){ + if(!mobile){ visible = Inputs.keyDown("player_list"); } if(!(Net.active() && !state.is(State.menu))){ diff --git a/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java index 0b31f54ed6..67cad267d4 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java @@ -11,8 +11,6 @@ import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Graphics; import io.anuke.ucore.scene.ui.layout.Table; -import static io.anuke.mindustry.Vars.*; - public class ToolFragment implements Fragment{ private Table tools; public int px, py, px2, py2; @@ -50,7 +48,7 @@ public class ToolFragment implements Fragment{ Core.scene.add(tools); tools.setVisible(() -> - !state.is(State.menu) && android && ((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && + !state.is(State.menu) && mobile && ((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && input.placeMode == PlaceMode.cursor) || confirming) ); diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java b/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java index 734cbc664b..526ac6917b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java @@ -48,7 +48,7 @@ public class WeaponFactory extends Block{ @Override public boolean isConfigurable(Tile tile){ - return !Vars.android; + return !Vars.mobile; } @Override diff --git a/desktop/build.gradle b/desktop/build.gradle index e4b394151f..2dcc0cf38d 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -13,18 +13,23 @@ ext.writeVersion = { def pfile = new File('core/assets/version.properties') def props = new Properties() - pfile.createNewFile() + try{ + pfile.createNewFile() + }catch (Exception e){} - props.load(new FileInputStream(pfile)) + if(pfile.exists()) { - String code = getBuildVersion() + props.load(new FileInputStream(pfile)) - props["name"] = appName - props["version"] = versionType - props["code"] = versionNumber - props["build"] = code + String code = getBuildVersion() - props.store(pfile.newWriter(), "Autogenerated file. Do not modify.") + props["name"] = appName + props["version"] = versionType + props["code"] = versionNumber + props["build"] = code + + props.store(pfile.newWriter(), "Autogenerated file. Do not modify.") + } } ext.getPlatform = { @@ -51,6 +56,9 @@ task run(dependsOn: classes, type: JavaExec) { classpath = sourceSets.main.runtimeClasspath standardInput = System.in workingDir = project.assetsDir + if(System.getProperty("os.name").toLowerCase().contains("mac")){ + jvmArgs "-XstartOnFirstThread" + } ignoreExitValue = true if (project.hasProperty("appArgs")) { args Eval.me(appArgs) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b979729db0..a5fe1cb94b 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 746a7bf80a..dcf30dc421 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Tue Dec 19 19:08:24 EST 2017 +#Sat Apr 28 09:57:33 EDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 91a7e269e1..cccdd3d517 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,47 +6,6 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -61,9 +20,49 @@ while [ -h "$PRG" ] ; do fi done SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- +cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" -cd "$SAVED" >&- +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` @@ -154,11 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index aec99730b4..e95643d6a2 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,10 +46,9 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -60,11 +59,6 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ :execute @rem Setup the command line diff --git a/ios/Info.plist.xml b/ios/Info.plist.xml new file mode 100644 index 0000000000..048a1c6319 --- /dev/null +++ b/ios/Info.plist.xml @@ -0,0 +1,58 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${app.name} + CFBundleExecutable + ${app.executable} + CFBundleIdentifier + ${app.id} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${app.name} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${app.version} + CFBundleSignature + ???? + CFBundleVersion + ${app.build} + LSRequiresIPhoneOS + + UIViewControllerBasedStatusBarAppearance + + UIStatusBarHidden + + UIDeviceFamily + + 1 + 2 + + UIRequiredDeviceCapabilities + + armv7 + opengles-2 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CFBundleIcons + + CFBundlePrimaryIcon + + CFBundleIconFiles + + Icon + Icon-72 + + + + + diff --git a/ios/build.gradle b/ios/build.gradle new file mode 100644 index 0000000000..b14d976190 --- /dev/null +++ b/ios/build.gradle @@ -0,0 +1,22 @@ +sourceSets.main.java.srcDirs = [ "src/" ] + +sourceCompatibility = '1.8' +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +ext { + mainClassName = "io.anuke.mindustry.IOSLauncher" +} + +launchIPhoneSimulator.dependsOn build +launchIPadSimulator.dependsOn build +launchIOSDevice.dependsOn build +createIPA.dependsOn build + +robovm { + archs = "thumbv7:arm64" +} + +eclipse.project { + name = appName + "-ios" + natures 'org.robovm.eclipse.RoboVMNature' +} \ No newline at end of file diff --git a/ios/data/Default-568h@2x~iphone.png b/ios/data/Default-568h@2x~iphone.png new file mode 100644 index 0000000000..f557df3353 Binary files /dev/null and b/ios/data/Default-568h@2x~iphone.png differ diff --git a/ios/data/Default-667h.png b/ios/data/Default-667h.png new file mode 100644 index 0000000000..53540c0bee Binary files /dev/null and b/ios/data/Default-667h.png differ diff --git a/ios/data/Default-736h.png b/ios/data/Default-736h.png new file mode 100644 index 0000000000..93870ef71e Binary files /dev/null and b/ios/data/Default-736h.png differ diff --git a/ios/data/Default-Landscape-736h.png b/ios/data/Default-Landscape-736h.png new file mode 100644 index 0000000000..f7e12aa617 Binary files /dev/null and b/ios/data/Default-Landscape-736h.png differ diff --git a/ios/data/Default-Landscape@2x~ipad.png b/ios/data/Default-Landscape@2x~ipad.png new file mode 100644 index 0000000000..303312fd8a Binary files /dev/null and b/ios/data/Default-Landscape@2x~ipad.png differ diff --git a/ios/data/Default-Landscape~ipad.png b/ios/data/Default-Landscape~ipad.png new file mode 100644 index 0000000000..a454227fe4 Binary files /dev/null and b/ios/data/Default-Landscape~ipad.png differ diff --git a/ios/data/Default-Portrait@2x~ipad.png b/ios/data/Default-Portrait@2x~ipad.png new file mode 100644 index 0000000000..d37ccb0ee8 Binary files /dev/null and b/ios/data/Default-Portrait@2x~ipad.png differ diff --git a/ios/data/Default-Portrait~ipad.png b/ios/data/Default-Portrait~ipad.png new file mode 100644 index 0000000000..2a421f9359 Binary files /dev/null and b/ios/data/Default-Portrait~ipad.png differ diff --git a/ios/data/Default@2x~iphone.png b/ios/data/Default@2x~iphone.png new file mode 100644 index 0000000000..3071d29ad1 Binary files /dev/null and b/ios/data/Default@2x~iphone.png differ diff --git a/ios/data/Default~iphone.png b/ios/data/Default~iphone.png new file mode 100644 index 0000000000..9f3ae021da Binary files /dev/null and b/ios/data/Default~iphone.png differ diff --git a/ios/data/icon-72.png b/ios/data/icon-72.png new file mode 100644 index 0000000000..b5ac036c98 Binary files /dev/null and b/ios/data/icon-72.png differ diff --git a/ios/data/icon-72@2x.png b/ios/data/icon-72@2x.png new file mode 100644 index 0000000000..b58b93d117 Binary files /dev/null and b/ios/data/icon-72@2x.png differ diff --git a/ios/data/icon.png b/ios/data/icon.png new file mode 100644 index 0000000000..7a00e2b46a Binary files /dev/null and b/ios/data/icon.png differ diff --git a/ios/data/icon@2x.png b/ios/data/icon@2x.png new file mode 100644 index 0000000000..1b76170cd0 Binary files /dev/null and b/ios/data/icon@2x.png differ diff --git a/ios/robovm.properties b/ios/robovm.properties new file mode 100644 index 0000000000..c47b07a461 --- /dev/null +++ b/ios/robovm.properties @@ -0,0 +1,6 @@ +app.version=1.0 +app.id=io.anuke.mindustry +app.mainclass=io.anuke.mindustry.IOSLauncher +app.executable=IOSLauncher +app.build=1 +app.name=Mindustry diff --git a/ios/robovm.xml b/ios/robovm.xml new file mode 100644 index 0000000000..31ffe9e1f2 --- /dev/null +++ b/ios/robovm.xml @@ -0,0 +1,47 @@ + + ${app.executable} + ${app.mainclass} + ios + thumbv7 + ios + Info.plist.xml + + + ../core/assets + + ** + + true + + + data + + + + io.anuke.ucore.scene.** + io.anuke.mindustry.net.** + com.android.okhttp.HttpHandler + com.android.okhttp.HttpsHandler + com.android.org.conscrypt.** + com.android.org.bouncycastle.jce.provider.BouncyCastleProvider + com.android.org.bouncycastle.jcajce.provider.keystore.BC$Mappings + com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi + com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi$Std + com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi + com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL + org.apache.harmony.security.provider.cert.DRLCertFactory + org.apache.harmony.security.provider.crypto.CryptoProvider + + + z + + + UIKit + OpenGLES + QuartzCore + CoreGraphics + OpenAL + AudioToolbox + AVFoundation + + diff --git a/ios/src/io/anuke/mindustry/IOSLauncher.java b/ios/src/io/anuke/mindustry/IOSLauncher.java new file mode 100644 index 0000000000..3662dabe1f --- /dev/null +++ b/ios/src/io/anuke/mindustry/IOSLauncher.java @@ -0,0 +1,73 @@ +package io.anuke.mindustry; + +import com.badlogic.gdx.backends.iosrobovm.IOSApplication; +import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration; +import io.anuke.kryonet.DefaultThreadImpl; +import io.anuke.kryonet.KryoClient; +import io.anuke.kryonet.KryoServer; +import io.anuke.mindustry.core.ThreadHandler; +import io.anuke.mindustry.io.Platform; +import io.anuke.mindustry.net.Net; +import io.anuke.ucore.scene.ui.TextField; +import io.anuke.ucore.scene.ui.layout.Unit; +import org.robovm.apple.foundation.NSAutoreleasePool; +import org.robovm.apple.uikit.UIApplication; + +import java.text.DateFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +public class IOSLauncher extends IOSApplication.Delegate { + @Override + protected IOSApplication createApplication() { + Net.setClientProvider(new KryoClient()); + Net.setServerProvider(new KryoServer()); + + Unit.dp.addition -= 0.25f; + + Platform.instance = new Platform() { + DateFormat format = SimpleDateFormat.getDateTimeInstance(); + + @Override + public String format(Date date) { + return format.format(date); + } + + @Override + public String format(int number) { + return NumberFormat.getIntegerInstance().format(number); + } + + @Override + public void addDialog(TextField field) { + TextFieldDialogListener.add(field, 16); + } + + @Override + public void addDialog(TextField field, int maxLength) { + TextFieldDialogListener.add(field, maxLength); + } + + @Override + public String getLocaleName(Locale locale) { + return locale.getDisplayName(locale); + } + + @Override + public ThreadHandler.ThreadProvider getThreadProvider() { + return new DefaultThreadImpl(); + } + }; + + IOSApplicationConfiguration config = new IOSApplicationConfiguration(); + return new IOSApplication(new Mindustry(), config); + } + + public static void main(String[] argv) { + NSAutoreleasePool pool = new NSAutoreleasePool(); + UIApplication.main(argv, null, IOSLauncher.class); + pool.close(); + } +} \ No newline at end of file diff --git a/ios/src/io/anuke/mindustry/TextFieldDialogListener.java b/ios/src/io/anuke/mindustry/TextFieldDialogListener.java new file mode 100644 index 0000000000..527e45c6ef --- /dev/null +++ b/ios/src/io/anuke/mindustry/TextFieldDialogListener.java @@ -0,0 +1,104 @@ +package io.anuke.mindustry; + +import com.badlogic.gdx.Gdx; +import io.anuke.ucore.scene.event.ClickListener; +import io.anuke.ucore.scene.event.InputEvent; +import io.anuke.ucore.scene.event.InputListener; +import io.anuke.ucore.scene.ui.TextField; +import org.robovm.apple.foundation.NSRange; +import org.robovm.apple.uikit.*; +import org.robovm.rt.bro.annotation.ByVal; + +public class TextFieldDialogListener { + + public static void add(TextField field, int maxLength){ + field.addListener(new ClickListener(){ + public void clicked(final InputEvent event, float x, float y){ + show(field, maxLength); + event.cancel(); + } + }); + field.addListener(new InputListener(){ + public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { + Gdx.input.setOnscreenKeyboardVisible(false); + return false; + } + }); + } + + private static void show(TextField field, int maxLength){ + + UIAlertViewDelegateAdapter delegate = new UIAlertViewDelegateAdapter() { + + @Override + public void didDismiss(UIAlertView alertView, long buttonIndex) { + if (buttonIndex == 1) { + UITextField textField = alertView.getTextField(0); + final String result = textField.getText(); + + Gdx.app.postRunnable(() -> { + field.setText(result); + field.change(); + }); + } + } + + @Override + public void clicked(UIAlertView alertView, long buttonIndex) { + + } + + @Override + public void cancel(UIAlertView alertView) { + + } + + @Override + public void willPresent(UIAlertView alertView) { + + } + + @Override + public void didPresent(UIAlertView alertView) { + + } + + @Override + public void willDismiss(UIAlertView alertView, long buttonIndex) { + + } + + @Override + public boolean shouldEnableFirstOtherButton(UIAlertView alertView) { + return false; + } + }; + + String[] otherButtons = new String[1]; + otherButtons[0] = "OK"; + + UIAlertView alertView = new UIAlertView("", "", delegate, "Cancel", otherButtons); + + alertView.setAlertViewStyle(UIAlertViewStyle.PlainTextInput); + + UITextField uiTextField = alertView.getTextField(0); + uiTextField.setText(field.getText()); + + uiTextField.setDelegate(new UITextFieldDelegateAdapter() { + @Override + public boolean shouldChangeCharacters(UITextField textField, @ByVal NSRange nsRange, String additionalText) { + + if (textField.getText().length() + additionalText.length() > maxLength) { + String oldText = textField.getText(); + String newText = oldText + additionalText; + textField.setText(newText.substring(0, maxLength)); + return false; + } + return true; + } + }); + + alertView.show(); + + } +} diff --git a/settings.gradle b/settings.gradle index 420a1f02eb..ac95167d02 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -include 'desktop', 'html', 'core', 'android', 'kryonet', 'server' +include 'desktop', 'html', 'core', 'android', 'kryonet', 'server', 'ios' if(System.properties["release"] == null || System.properties["release"].equals("false")){ if (new File(settingsDir, '../uCore').exists()) {