Gradle build P2.

This commit is contained in:
Relintai 2017-10-01 01:02:05 +02:00
parent 708343b02c
commit 20da045794
3784 changed files with 43347 additions and 43183 deletions

140
Temp/Temp/build.gradle Normal file
View File

@ -0,0 +1,140 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.1'
classpath 'org.multi-os-engine:moe-gradle:1.3.12'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "mtg-forge-gradle"
gdxVersion = '1.9.6'
roboVMVersion = '2.3.1'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":forge-core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}
project(":forge-ai") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}
project(":forge-gui") {
apply plugin: "java"
dependencies {
compile project(":forge-core")
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}
project(":forge-gui-desktop") {
apply plugin: "java"
dependencies {
compile project(":forge-core")
compile project(":forge-ai")
compile project(":forge-gui")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}
}
project(":forge-gui-mobile") {
apply plugin: "java"
dependencies {
compile project(":forge-core")
compile project(":forge-ai")
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-backend-moe:$gdxVersion"
}
}
project(":forge-gui-ios") {
apply plugin: "moe"
configurations { natives }
dependencies {
compile project(":forge-core")
compile project(":forge-ai")
compile project(":forge-gui-mobile")
compile "com.badlogicgames.gdx:gdx-backend-moe:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
}
}
project(":ios-moe") {
apply plugin: "moe"
configurations { natives }
dependencies {
compile project(":forge-gui-mobile")
compile "com.badlogicgames.gdx:gdx-backend-moe:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
}
}
project(":forge-gui-ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":forge-gui-mobile")
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"
}
}
tasks.eclipse.doLast {
delete ".project"
}

View File

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/classes" path="src"> <classpathentry kind="src" output="target/classes" path="src">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/classes" path="gen"/> <classpathentry kind="src" output="target/classes" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>

View File

@ -1,39 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>forge-gui-android</name> <name>forge-gui-android</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name> <name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name> <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

@ -1,2 +1,2 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding/<project>=UTF-8 encoding/<project>=UTF-8

View File

@ -1,8 +1,8 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.compiler.source=1.7

View File

@ -1,4 +1,4 @@
activeProfiles= activeProfiles=
eclipse.preferences.version=1 eclipse.preferences.version=1
resolveWorkspaceProjects=true resolveWorkspaceProjects=true
version=1 version=1

View File

@ -1,31 +1,31 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="forge.app" package="forge.app"
android:versionCode="1" android:versionCode="1"
android:versionName="1.5.40" > android:versionName="1.5.40" >
<uses-sdk <uses-sdk
android:minSdkVersion="11" android:minSdkVersion="11"
android:targetSdkVersion="21" /> android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:largeHeap="true"> android:largeHeap="true">
<activity <activity
android:name=".Main" android:name=".Main"
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".Exiter" android:theme="@android:style/Theme.NoDisplay"/> <activity android:name=".Exiter" android:theme="@android:style/Theme.NoDisplay"/>
</application> </application>
</manifest> </manifest>

View File

Before

Width:  |  Height:  |  Size: 208 KiB

After

Width:  |  Height:  |  Size: 208 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1,15 +1,15 @@
cd ../forge-core cd ../forge-core
call mvn clean install call mvn clean install
cd ../forge-net cd ../forge-net
call mvn clean install call mvn clean install
cd ../forge-ai cd ../forge-ai
call mvn clean install call mvn clean install
cd ../forge-game cd ../forge-game
call mvn clean install call mvn clean install
cd ../forge-gui cd ../forge-gui
call mvn clean install call mvn clean install
cd ../forge-gui-mobile cd ../forge-gui-mobile
call mvn clean install call mvn clean install
cd ../forge-gui-android cd ../forge-gui-android
call mvn -U -B clean -P android-release-build,android-release-sign,android-release-upload install -Dsign.keystore=forge.keystore -Dsign.alias=Forge -Dsign.storepass=forge72 -Dsign.keypass=forge72 -Dcardforge.user=drdev@cardforge.org -Dcardforge.pass=W%GdM]_o7@wEUEJIvs call mvn -U -B clean -P android-release-build,android-release-sign,android-release-upload install -Dsign.keystore=forge.keystore -Dsign.alias=Forge -Dsign.storepass=forge72 -Dsign.keypass=forge72 -Dcardforge.user=drdev@cardforge.org -Dcardforge.pass=W%GdM]_o7@wEUEJIvs
pause pause

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" > android:orientation="vertical" >
</LinearLayout> </LinearLayout>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Forge</string> <string name="app_name">Forge</string>
</resources> </resources>

View File

@ -1,14 +1,14 @@
package forge.app; package forge.app;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
public class Exiter extends Activity { public class Exiter extends Activity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
finish(); finish();
//ensure process fully killed //ensure process fully killed
System.exit(0); System.exit(0);
} }
} }

View File

@ -1,251 +1,251 @@
package forge.app; package forge.app;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.PowerManager; import android.os.PowerManager;
import android.view.WindowManager; import android.view.WindowManager;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplication;
import forge.FThreads; import forge.FThreads;
import forge.Forge; import forge.Forge;
import forge.interfaces.IDeviceAdapter; import forge.interfaces.IDeviceAdapter;
import forge.model.FModel; import forge.model.FModel;
import forge.properties.ForgePreferences; import forge.properties.ForgePreferences;
import forge.util.FileUtil; import forge.util.FileUtil;
import forge.util.ThreadUtil; import forge.util.ThreadUtil;
import java.io.File; import java.io.File;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
public class Main extends AndroidApplication { public class Main extends AndroidApplication {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
AndroidAdapter adapter = new AndroidAdapter(this.getContext()); AndroidAdapter adapter = new AndroidAdapter(this.getContext());
//establish assets directory //establish assets directory
if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
Gdx.app.error("Forge", "Can't access external storage"); Gdx.app.error("Forge", "Can't access external storage");
adapter.exit(); adapter.exit();
return; return;
} }
String assetsDir = Environment.getExternalStorageDirectory() + "/Forge/"; String assetsDir = Environment.getExternalStorageDirectory() + "/Forge/";
if (!FileUtil.ensureDirectoryExists(assetsDir)) { if (!FileUtil.ensureDirectoryExists(assetsDir)) {
Gdx.app.error("Forge", "Can't access external storage"); Gdx.app.error("Forge", "Can't access external storage");
adapter.exit(); adapter.exit();
return; return;
} }
//ensure .nomedia file exists in Forge directory so its images //ensure .nomedia file exists in Forge directory so its images
//and other media files don't appear in Gallery or other apps //and other media files don't appear in Gallery or other apps
String noMediaFile = assetsDir + ".nomedia"; String noMediaFile = assetsDir + ".nomedia";
if (!FileUtil.doesFileExist(noMediaFile)) { if (!FileUtil.doesFileExist(noMediaFile)) {
FileUtil.writeFile(noMediaFile, ""); FileUtil.writeFile(noMediaFile, "");
} }
//enforce orientation based on whether device is a tablet and user preference //enforce orientation based on whether device is a tablet and user preference
adapter.switchOrientationFile = assetsDir + "switch_orientation.ini"; adapter.switchOrientationFile = assetsDir + "switch_orientation.ini";
boolean landscapeMode = adapter.isTablet == !FileUtil.doesFileExist(adapter.switchOrientationFile); boolean landscapeMode = adapter.isTablet == !FileUtil.doesFileExist(adapter.switchOrientationFile);
if (landscapeMode) { if (landscapeMode) {
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} }
else { else {
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} }
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir)); initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir));
} }
/*@Override /*@Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
//ensure app doesn't stick around //ensure app doesn't stick around
//ActivityManager am = (ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE); //ActivityManager am = (ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE);
//am.killBackgroundProcesses(getApplicationContext().getPackageName()); //am.killBackgroundProcesses(getApplicationContext().getPackageName());
}*/ }*/
@Override @Override
protected void onPause() protected void onPause()
{ {
super.onPause(); super.onPause();
ForgePreferences prefs = FModel.getPreferences(); ForgePreferences prefs = FModel.getPreferences();
boolean minimizeonScreenLock = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_ANDROID_MINIMIZE_ON_SCRLOCK); boolean minimizeonScreenLock = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_ANDROID_MINIMIZE_ON_SCRLOCK);
if (minimizeonScreenLock) { if (minimizeonScreenLock) {
// If the screen is off then the device has been locked // If the screen is off then the device has been locked
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
boolean isScreenOn = powerManager.isScreenOn(); boolean isScreenOn = powerManager.isScreenOn();
if (!isScreenOn) { if (!isScreenOn) {
this.moveTaskToBack(true); this.moveTaskToBack(true);
// Minimize the app to the background... // Minimize the app to the background...
} }
} }
} }
//special clipboard that words on Android //special clipboard that words on Android
private class AndroidClipboard implements com.badlogic.gdx.utils.Clipboard { private class AndroidClipboard implements com.badlogic.gdx.utils.Clipboard {
private final ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); private final ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
@Override @Override
public String getContents() { public String getContents() {
if (cm.getPrimaryClip().getItemCount() > 0) { if (cm.getPrimaryClip().getItemCount() > 0) {
try { try {
return cm.getPrimaryClip().getItemAt(0).coerceToText(getContext()).toString(); return cm.getPrimaryClip().getItemAt(0).coerceToText(getContext()).toString();
} }
catch (Exception ex) { catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
return ""; return "";
} }
@Override @Override
public void setContents(String contents0) { public void setContents(String contents0) {
cm.setPrimaryClip(ClipData.newPlainText("Forge", contents0)); cm.setPrimaryClip(ClipData.newPlainText("Forge", contents0));
} }
} }
private class AndroidAdapter implements IDeviceAdapter { private class AndroidAdapter implements IDeviceAdapter {
private final boolean isTablet; private final boolean isTablet;
private final ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); private final ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
private String switchOrientationFile; private String switchOrientationFile;
private AndroidAdapter(Context context) { private AndroidAdapter(Context context) {
isTablet = (context.getResources().getConfiguration().screenLayout isTablet = (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) & Configuration.SCREENLAYOUT_SIZE_MASK)
>= Configuration.SCREENLAYOUT_SIZE_LARGE; >= Configuration.SCREENLAYOUT_SIZE_LARGE;
} }
@Override @Override
public boolean isConnectedToInternet() { public boolean isConnectedToInternet() {
return Boolean.TRUE.equals(ThreadUtil.executeWithTimeout(new Callable<Boolean>() { return Boolean.TRUE.equals(ThreadUtil.executeWithTimeout(new Callable<Boolean>() {
@Override @Override
public Boolean call() throws Exception { public Boolean call() throws Exception {
NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo(); NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected(); return activeNetworkInfo != null && activeNetworkInfo.isConnected();
} }
}, 2000)); //if can't determine Internet connection within two seconds, assume not connected }, 2000)); //if can't determine Internet connection within two seconds, assume not connected
} }
@Override @Override
public boolean isConnectedToWifi() { public boolean isConnectedToWifi() {
return Boolean.TRUE.equals(ThreadUtil.executeWithTimeout(new Callable<Boolean>() { return Boolean.TRUE.equals(ThreadUtil.executeWithTimeout(new Callable<Boolean>() {
@Override @Override
public Boolean call() throws Exception { public Boolean call() throws Exception {
NetworkInfo wifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo wifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return wifi.isConnected(); return wifi.isConnected();
} }
}, 2000)); //if can't determine Internet connection within two seconds, assume not connected }, 2000)); //if can't determine Internet connection within two seconds, assume not connected
} }
@Override @Override
public String getDownloadsDir() { public String getDownloadsDir() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/"; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/";
} }
@Override @Override
public boolean openFile(String filename) { public boolean openFile(String filename) {
try { try {
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //ensure this task isn't linked to this application intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //ensure this task isn't linked to this application
Uri uri = Uri.fromFile(new File(filename)); Uri uri = Uri.fromFile(new File(filename));
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension( String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
MimeTypeMap.getFileExtensionFromUrl(uri.toString())); MimeTypeMap.getFileExtensionFromUrl(uri.toString()));
intent.setDataAndType(uri, type); intent.setDataAndType(uri, type);
startActivity(intent); startActivity(intent);
return true; return true;
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
} }
@Override @Override
public void restart() { public void restart() {
try { //solution from http://stackoverflow.com/questions/6609414/howto-programatically-restart-android-app try { //solution from http://stackoverflow.com/questions/6609414/howto-programatically-restart-android-app
Context c = getApplicationContext(); Context c = getApplicationContext();
PackageManager pm = c.getPackageManager(); PackageManager pm = c.getPackageManager();
if (pm != null) { if (pm != null) {
//create the intent with the default start activity for your application //create the intent with the default start activity for your application
Intent mStartActivity = pm.getLaunchIntentForPackage(c.getPackageName()); Intent mStartActivity = pm.getLaunchIntentForPackage(c.getPackageName());
if (mStartActivity != null) { if (mStartActivity != null) {
mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//create a pending intent so the application is restarted after System.exit(0) was called. //create a pending intent so the application is restarted after System.exit(0) was called.
// We use an AlarmManager to call this intent in 100ms // We use an AlarmManager to call this intent in 100ms
int mPendingIntentId = 223344; int mPendingIntentId = 223344;
PendingIntent mPendingIntent = PendingIntent.getActivity(c, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent mPendingIntent = PendingIntent.getActivity(c, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager mgr = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); AlarmManager mgr = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
//kill the application //kill the application
System.exit(0); System.exit(0);
} }
} }
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Override @Override
public void exit() { public void exit() {
// Replace the current task with one that is excluded from the recent // Replace the current task with one that is excluded from the recent
// apps and that will finish itself immediately. It's critical that this // apps and that will finish itself immediately. It's critical that this
// activity get launched in the task that you want to hide. // activity get launched in the task that you want to hide.
final Intent relaunch = new Intent(getApplicationContext(), Exiter.class) final Intent relaunch = new Intent(getApplicationContext(), Exiter.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // CLEAR_TASK requires this .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // CLEAR_TASK requires this
| Intent.FLAG_ACTIVITY_CLEAR_TASK // finish everything else in the task | Intent.FLAG_ACTIVITY_CLEAR_TASK // finish everything else in the task
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // hide (remove, in this case) task from recents | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // hide (remove, in this case) task from recents
startActivity(relaunch); startActivity(relaunch);
} }
@Override @Override
public boolean isTablet() { public boolean isTablet() {
return isTablet; return isTablet;
} }
@Override @Override
public void setLandscapeMode(boolean landscapeMode) { public void setLandscapeMode(boolean landscapeMode) {
//create file to indicate that portrait mode should be used for tablet or landscape should be used for phone //create file to indicate that portrait mode should be used for tablet or landscape should be used for phone
if (landscapeMode != isTablet) { if (landscapeMode != isTablet) {
FileUtil.writeFile(switchOrientationFile, "1"); FileUtil.writeFile(switchOrientationFile, "1");
} }
else { else {
FileUtil.deleteFile(switchOrientationFile); FileUtil.deleteFile(switchOrientationFile);
} }
} }
@Override @Override
public void preventSystemSleep(final boolean preventSleep) { public void preventSystemSleep(final boolean preventSleep) {
FThreads.invokeInEdtNowOrLater(new Runnable() { //must set window flags from EDT thread FThreads.invokeInEdtNowOrLater(new Runnable() { //must set window flags from EDT thread
@Override @Override
public void run() { public void run() {
if (preventSleep) { if (preventSleep) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} }
else { else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} }
} }
}); });
} }
} }
} }

View File

@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/classes" path="src"> <classpathentry kind="src" output="target/classes" path="src">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="libs/gdx-backend-lwjgl-natives.jar"/> <classpathentry kind="lib" path="libs/gdx-backend-lwjgl-natives.jar"/>
<classpathentry kind="lib" path="libs/gdx-backend-lwjgl.jar" sourcepath="libs/gdx-backend-lwjgl-sources.jar"/> <classpathentry kind="lib" path="libs/gdx-backend-lwjgl.jar" sourcepath="libs/gdx-backend-lwjgl-sources.jar"/>
<classpathentry kind="lib" path="libs/gdx-natives.jar"/> <classpathentry kind="lib" path="libs/gdx-natives.jar"/>
<classpathentry kind="lib" path="libs/gdx-freetype-natives.jar"/> <classpathentry kind="lib" path="libs/gdx-freetype-natives.jar"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -1,29 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>forge-gui-mobile-dev</name> <name>forge-gui-mobile-dev</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name> <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
</natures> </natures>
<variableList> <variableList>
<variable> <variable>
<name>copy_PARENT</name> <name>copy_PARENT</name>
<value>$%7BPARENT-1-PROJECT_LOC%7D/trunk</value> <value>$%7BPARENT-1-PROJECT_LOC%7D/trunk</value>
</variable> </variable>
</variableList> </variableList>
</projectDescription> </projectDescription>

View File

@ -1,12 +1,12 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.compiler.source=1.7

View File

@ -1,4 +1,4 @@
activeProfiles= activeProfiles=
eclipse.preferences.version=1 eclipse.preferences.version=1
resolveWorkspaceProjects=true resolveWorkspaceProjects=true
version=1 version=1

View File

Before

Width:  |  Height:  |  Size: 208 KiB

After

Width:  |  Height:  |  Size: 208 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -1,137 +1,137 @@
package forge.app; package forge.app;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl.LwjglClipboard; import com.badlogic.gdx.backends.lwjgl.LwjglClipboard;
import forge.Forge; import forge.Forge;
import forge.assets.AssetsDownloader; import forge.assets.AssetsDownloader;
import forge.interfaces.IDeviceAdapter; import forge.interfaces.IDeviceAdapter;
import forge.util.FileUtil; import forge.util.FileUtil;
import forge.util.OperatingSystem; import forge.util.OperatingSystem;
import forge.util.RestartUtil; import forge.util.RestartUtil;
import forge.util.Utils; import forge.util.Utils;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
// Set this to "true" to make the mobile game port run as a full-screen desktop application // Set this to "true" to make the mobile game port run as a full-screen desktop application
boolean desktopMode = false; boolean desktopMode = false;
// Set this to the location where you want the mobile game port to look for assets when working as a full-screen desktop application // Set this to the location where you want the mobile game port to look for assets when working as a full-screen desktop application
// (uncomment the bottom version and comment the top one to load the res folder from the current folder the .jar is in if you would // (uncomment the bottom version and comment the top one to load the res folder from the current folder the .jar is in if you would
// like to make the game load from a desktop game folder configuration). // like to make the game load from a desktop game folder configuration).
String desktopModeAssetsDir = "../forge-gui/"; String desktopModeAssetsDir = "../forge-gui/";
//String desktopModeAssetsDir = "./"; //String desktopModeAssetsDir = "./";
// Assets directory used when the game fully emulates smartphone/tablet mode (desktopMode = false), useful when debugging from IDE // Assets directory used when the game fully emulates smartphone/tablet mode (desktopMode = false), useful when debugging from IDE
String assetsDir = AssetsDownloader.SHARE_DESKTOP_ASSETS ? "../forge-gui/" : "testAssets/"; String assetsDir = AssetsDownloader.SHARE_DESKTOP_ASSETS ? "../forge-gui/" : "testAssets/";
if (!AssetsDownloader.SHARE_DESKTOP_ASSETS) { if (!AssetsDownloader.SHARE_DESKTOP_ASSETS) {
FileUtil.ensureDirectoryExists(assetsDir); FileUtil.ensureDirectoryExists(assetsDir);
} }
// Place the file "switch_orientation.ini" to your assets folder to make the game switch to landscape orientation (unless desktopMode = true) // Place the file "switch_orientation.ini" to your assets folder to make the game switch to landscape orientation (unless desktopMode = true)
String switchOrientationFile = assetsDir + "switch_orientation.ini"; String switchOrientationFile = assetsDir + "switch_orientation.ini";
boolean landscapeMode = FileUtil.doesFileExist(switchOrientationFile); boolean landscapeMode = FileUtil.doesFileExist(switchOrientationFile);
// Width and height for standard smartphone/tablet mode (desktopMode = false) // Width and height for standard smartphone/tablet mode (desktopMode = false)
int screenWidth = landscapeMode ? (int)(Utils.BASE_HEIGHT * 16 / 9) : (int)Utils.BASE_WIDTH; int screenWidth = landscapeMode ? (int)(Utils.BASE_HEIGHT * 16 / 9) : (int)Utils.BASE_WIDTH;
int screenHeight = (int)Utils.BASE_HEIGHT; int screenHeight = (int)Utils.BASE_HEIGHT;
// Fullscreen width and height for desktop mode (desktopMode = true) // Fullscreen width and height for desktop mode (desktopMode = true)
// Can be specified inside the file fullscreen_resolution.ini to override default (in the format WxH, e.g. 1920x1080) // Can be specified inside the file fullscreen_resolution.ini to override default (in the format WxH, e.g. 1920x1080)
int desktopScreenWidth = LwjglApplicationConfiguration.getDesktopDisplayMode().width; int desktopScreenWidth = LwjglApplicationConfiguration.getDesktopDisplayMode().width;
int desktopScreenHeight = LwjglApplicationConfiguration.getDesktopDisplayMode().height; int desktopScreenHeight = LwjglApplicationConfiguration.getDesktopDisplayMode().height;
boolean fullscreenFlag = true; boolean fullscreenFlag = true;
if (FileUtil.doesFileExist(desktopModeAssetsDir + "screen_resolution.ini")) { if (FileUtil.doesFileExist(desktopModeAssetsDir + "screen_resolution.ini")) {
String[] res = FileUtil.readFileToString(desktopModeAssetsDir + "screen_resolution.ini").split("x"); String[] res = FileUtil.readFileToString(desktopModeAssetsDir + "screen_resolution.ini").split("x");
fullscreenFlag = res.length == 3 ? Integer.parseInt(res[2].trim()) > 0 : true; fullscreenFlag = res.length == 3 ? Integer.parseInt(res[2].trim()) > 0 : true;
if (res.length >= 2) { if (res.length >= 2) {
desktopScreenWidth = Integer.parseInt(res[0].trim()); desktopScreenWidth = Integer.parseInt(res[0].trim());
desktopScreenHeight = Integer.parseInt(res[1].trim()); desktopScreenHeight = Integer.parseInt(res[1].trim());
} }
} }
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.resizable = false; config.resizable = false;
config.width = desktopMode ? desktopScreenWidth : screenWidth; config.width = desktopMode ? desktopScreenWidth : screenWidth;
config.height = desktopMode ? desktopScreenHeight : screenHeight; config.height = desktopMode ? desktopScreenHeight : screenHeight;
config.fullscreen = desktopMode && fullscreenFlag; config.fullscreen = desktopMode && fullscreenFlag;
config.title = "Forge"; config.title = "Forge";
config.useHDPI = desktopMode; // enable HiDPI on Mac OS config.useHDPI = desktopMode; // enable HiDPI on Mac OS
new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile), new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile),
desktopMode ? desktopModeAssetsDir : assetsDir), config); desktopMode ? desktopModeAssetsDir : assetsDir), config);
} }
private static class DesktopAdapter implements IDeviceAdapter { private static class DesktopAdapter implements IDeviceAdapter {
private final String switchOrientationFile; private final String switchOrientationFile;
private DesktopAdapter(String switchOrientationFile0) { private DesktopAdapter(String switchOrientationFile0) {
switchOrientationFile = switchOrientationFile0; switchOrientationFile = switchOrientationFile0;
} }
//just assume desktop always connected to wifi //just assume desktop always connected to wifi
@Override @Override
public boolean isConnectedToInternet() { public boolean isConnectedToInternet() {
return true; return true;
} }
@Override @Override
public boolean isConnectedToWifi() { public boolean isConnectedToWifi() {
return true; return true;
} }
@Override @Override
public String getDownloadsDir() { public String getDownloadsDir() {
return System.getProperty("user.home") + "/Downloads/"; return System.getProperty("user.home") + "/Downloads/";
} }
@Override @Override
public boolean openFile(String filename) { public boolean openFile(String filename) {
try { try {
Desktop.getDesktop().open(new File(filename)); Desktop.getDesktop().open(new File(filename));
return true; return true;
} }
catch (IOException e) { catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
} }
@Override @Override
public void restart() { public void restart() {
if (RestartUtil.prepareForRestart()) { if (RestartUtil.prepareForRestart()) {
Gdx.app.exit(); Gdx.app.exit();
} }
} }
@Override @Override
public void exit() { public void exit() {
Gdx.app.exit(); //can just use Gdx.app.exit for desktop Gdx.app.exit(); //can just use Gdx.app.exit for desktop
} }
@Override @Override
public boolean isTablet() { public boolean isTablet() {
return true; //treat desktop the same as a tablet return true; //treat desktop the same as a tablet
} }
@Override @Override
public void setLandscapeMode(boolean landscapeMode) { public void setLandscapeMode(boolean landscapeMode) {
//create file to indicate that landscape mode should be used //create file to indicate that landscape mode should be used
if (landscapeMode) { if (landscapeMode) {
FileUtil.writeFile(switchOrientationFile, "1"); FileUtil.writeFile(switchOrientationFile, "1");
} }
else { else {
FileUtil.deleteFile(switchOrientationFile); FileUtil.deleteFile(switchOrientationFile);
} }
} }
@Override @Override
public void preventSystemSleep(boolean preventSleep) { public void preventSystemSleep(boolean preventSleep) {
OperatingSystem.preventSystemSleep(preventSleep); OperatingSystem.preventSystemSleep(preventSleep);
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More