Gradle build P2.
140
Temp/Temp/build.gradle
Normal 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"
|
||||
}
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB |
@ -1,24 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="gen"/>
|
||||
<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.DEPENDENCIES"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="gen"/>
|
||||
<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.DEPENDENCIES"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
@ -1,39 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>forge-gui-android</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>forge-gui-android</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -1,2 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
@ -1,8 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
@ -1,4 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
@ -1,31 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="forge.app"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.5.40" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="11"
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="forge.app"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.5.40" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="11"
|
||||
android:targetSdkVersion="21" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<application
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true">
|
||||
<activity
|
||||
android:name=".Main"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
android:largeHeap="true">
|
||||
<activity
|
||||
android:name=".Main"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".Exiter" android:theme="@android:style/Theme.NoDisplay"/>
|
||||
</application>
|
||||
</manifest>
|
||||
<activity android:name=".Exiter" android:theme="@android:style/Theme.NoDisplay"/>
|
||||
</application>
|
||||
</manifest>
|
Before Width: | Height: | Size: 208 KiB After Width: | Height: | Size: 208 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
@ -1,15 +1,15 @@
|
||||
cd ../forge-core
|
||||
call mvn clean install
|
||||
cd ../forge-net
|
||||
call mvn clean install
|
||||
cd ../forge-ai
|
||||
call mvn clean install
|
||||
cd ../forge-game
|
||||
call mvn clean install
|
||||
cd ../forge-gui
|
||||
call mvn clean install
|
||||
cd ../forge-gui-mobile
|
||||
call mvn clean install
|
||||
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
|
||||
cd ../forge-core
|
||||
call mvn clean install
|
||||
cd ../forge-net
|
||||
call mvn clean install
|
||||
cd ../forge-ai
|
||||
call mvn clean install
|
||||
cd ../forge-game
|
||||
call mvn clean install
|
||||
cd ../forge-gui
|
||||
call mvn clean install
|
||||
cd ../forge-gui-mobile
|
||||
call mvn clean install
|
||||
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
|
||||
pause
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
</LinearLayout>
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Forge</string>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Forge</string>
|
||||
</resources>
|
@ -1,14 +1,14 @@
|
||||
package forge.app;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class Exiter extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
finish();
|
||||
|
||||
//ensure process fully killed
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
package forge.app;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class Exiter extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
finish();
|
||||
|
||||
//ensure process fully killed
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
@ -1,251 +1,251 @@
|
||||
package forge.app;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.PowerManager;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.ThreadUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class Main extends AndroidApplication {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndroidAdapter adapter = new AndroidAdapter(this.getContext());
|
||||
|
||||
//establish assets directory
|
||||
if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||
Gdx.app.error("Forge", "Can't access external storage");
|
||||
adapter.exit();
|
||||
return;
|
||||
}
|
||||
String assetsDir = Environment.getExternalStorageDirectory() + "/Forge/";
|
||||
if (!FileUtil.ensureDirectoryExists(assetsDir)) {
|
||||
Gdx.app.error("Forge", "Can't access external storage");
|
||||
adapter.exit();
|
||||
return;
|
||||
}
|
||||
|
||||
//ensure .nomedia file exists in Forge directory so its images
|
||||
//and other media files don't appear in Gallery or other apps
|
||||
String noMediaFile = assetsDir + ".nomedia";
|
||||
if (!FileUtil.doesFileExist(noMediaFile)) {
|
||||
FileUtil.writeFile(noMediaFile, "");
|
||||
}
|
||||
|
||||
//enforce orientation based on whether device is a tablet and user preference
|
||||
adapter.switchOrientationFile = assetsDir + "switch_orientation.ini";
|
||||
boolean landscapeMode = adapter.isTablet == !FileUtil.doesFileExist(adapter.switchOrientationFile);
|
||||
if (landscapeMode) {
|
||||
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
else {
|
||||
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir));
|
||||
}
|
||||
|
||||
/*@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
//ensure app doesn't stick around
|
||||
//ActivityManager am = (ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE);
|
||||
//am.killBackgroundProcesses(getApplicationContext().getPackageName());
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
|
||||
ForgePreferences prefs = FModel.getPreferences();
|
||||
boolean minimizeonScreenLock = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_ANDROID_MINIMIZE_ON_SCRLOCK);
|
||||
|
||||
if (minimizeonScreenLock) {
|
||||
// If the screen is off then the device has been locked
|
||||
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
boolean isScreenOn = powerManager.isScreenOn();
|
||||
if (!isScreenOn) {
|
||||
this.moveTaskToBack(true);
|
||||
// Minimize the app to the background...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//special clipboard that words on Android
|
||||
private class AndroidClipboard implements com.badlogic.gdx.utils.Clipboard {
|
||||
private final ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
|
||||
@Override
|
||||
public String getContents() {
|
||||
if (cm.getPrimaryClip().getItemCount() > 0) {
|
||||
try {
|
||||
return cm.getPrimaryClip().getItemAt(0).coerceToText(getContext()).toString();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContents(String contents0) {
|
||||
cm.setPrimaryClip(ClipData.newPlainText("Forge", contents0));
|
||||
}
|
||||
}
|
||||
|
||||
private class AndroidAdapter implements IDeviceAdapter {
|
||||
private final boolean isTablet;
|
||||
private final ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
private String switchOrientationFile;
|
||||
|
||||
private AndroidAdapter(Context context) {
|
||||
isTablet = (context.getResources().getConfiguration().screenLayout
|
||||
& Configuration.SCREENLAYOUT_SIZE_MASK)
|
||||
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnectedToInternet() {
|
||||
return Boolean.TRUE.equals(ThreadUtil.executeWithTimeout(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
}
|
||||
}, 2000)); //if can't determine Internet connection within two seconds, assume not connected
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnectedToWifi() {
|
||||
return Boolean.TRUE.equals(ThreadUtil.executeWithTimeout(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
NetworkInfo wifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
return wifi.isConnected();
|
||||
}
|
||||
}, 2000)); //if can't determine Internet connection within two seconds, assume not connected
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadsDir() {
|
||||
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openFile(String filename) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //ensure this task isn't linked to this application
|
||||
Uri uri = Uri.fromFile(new File(filename));
|
||||
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
||||
MimeTypeMap.getFileExtensionFromUrl(uri.toString()));
|
||||
intent.setDataAndType(uri, type);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restart() {
|
||||
try { //solution from http://stackoverflow.com/questions/6609414/howto-programatically-restart-android-app
|
||||
Context c = getApplicationContext();
|
||||
PackageManager pm = c.getPackageManager();
|
||||
if (pm != null) {
|
||||
//create the intent with the default start activity for your application
|
||||
Intent mStartActivity = pm.getLaunchIntentForPackage(c.getPackageName());
|
||||
if (mStartActivity != null) {
|
||||
mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
//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
|
||||
int mPendingIntentId = 223344;
|
||||
PendingIntent mPendingIntent = PendingIntent.getActivity(c, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
AlarmManager mgr = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE);
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
|
||||
//kill the application
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
// Replace the current task with one that is excluded from the recent
|
||||
// apps and that will finish itself immediately. It's critical that this
|
||||
// activity get launched in the task that you want to hide.
|
||||
final Intent relaunch = new Intent(getApplicationContext(), Exiter.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // CLEAR_TASK requires this
|
||||
| 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
|
||||
startActivity(relaunch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTablet() {
|
||||
return isTablet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLandscapeMode(boolean landscapeMode) {
|
||||
//create file to indicate that portrait mode should be used for tablet or landscape should be used for phone
|
||||
if (landscapeMode != isTablet) {
|
||||
FileUtil.writeFile(switchOrientationFile, "1");
|
||||
}
|
||||
else {
|
||||
FileUtil.deleteFile(switchOrientationFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preventSystemSleep(final boolean preventSleep) {
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() { //must set window flags from EDT thread
|
||||
@Override
|
||||
public void run() {
|
||||
if (preventSleep) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
else {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
package forge.app;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.PowerManager;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.ThreadUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class Main extends AndroidApplication {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndroidAdapter adapter = new AndroidAdapter(this.getContext());
|
||||
|
||||
//establish assets directory
|
||||
if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||
Gdx.app.error("Forge", "Can't access external storage");
|
||||
adapter.exit();
|
||||
return;
|
||||
}
|
||||
String assetsDir = Environment.getExternalStorageDirectory() + "/Forge/";
|
||||
if (!FileUtil.ensureDirectoryExists(assetsDir)) {
|
||||
Gdx.app.error("Forge", "Can't access external storage");
|
||||
adapter.exit();
|
||||
return;
|
||||
}
|
||||
|
||||
//ensure .nomedia file exists in Forge directory so its images
|
||||
//and other media files don't appear in Gallery or other apps
|
||||
String noMediaFile = assetsDir + ".nomedia";
|
||||
if (!FileUtil.doesFileExist(noMediaFile)) {
|
||||
FileUtil.writeFile(noMediaFile, "");
|
||||
}
|
||||
|
||||
//enforce orientation based on whether device is a tablet and user preference
|
||||
adapter.switchOrientationFile = assetsDir + "switch_orientation.ini";
|
||||
boolean landscapeMode = adapter.isTablet == !FileUtil.doesFileExist(adapter.switchOrientationFile);
|
||||
if (landscapeMode) {
|
||||
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
else {
|
||||
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
|
||||
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir));
|
||||
}
|
||||
|
||||
/*@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
//ensure app doesn't stick around
|
||||
//ActivityManager am = (ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE);
|
||||
//am.killBackgroundProcesses(getApplicationContext().getPackageName());
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
|
||||
ForgePreferences prefs = FModel.getPreferences();
|
||||
boolean minimizeonScreenLock = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_ANDROID_MINIMIZE_ON_SCRLOCK);
|
||||
|
||||
if (minimizeonScreenLock) {
|
||||
// If the screen is off then the device has been locked
|
||||
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
boolean isScreenOn = powerManager.isScreenOn();
|
||||
if (!isScreenOn) {
|
||||
this.moveTaskToBack(true);
|
||||
// Minimize the app to the background...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//special clipboard that words on Android
|
||||
private class AndroidClipboard implements com.badlogic.gdx.utils.Clipboard {
|
||||
private final ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
|
||||
@Override
|
||||
public String getContents() {
|
||||
if (cm.getPrimaryClip().getItemCount() > 0) {
|
||||
try {
|
||||
return cm.getPrimaryClip().getItemAt(0).coerceToText(getContext()).toString();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContents(String contents0) {
|
||||
cm.setPrimaryClip(ClipData.newPlainText("Forge", contents0));
|
||||
}
|
||||
}
|
||||
|
||||
private class AndroidAdapter implements IDeviceAdapter {
|
||||
private final boolean isTablet;
|
||||
private final ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
private String switchOrientationFile;
|
||||
|
||||
private AndroidAdapter(Context context) {
|
||||
isTablet = (context.getResources().getConfiguration().screenLayout
|
||||
& Configuration.SCREENLAYOUT_SIZE_MASK)
|
||||
>= Configuration.SCREENLAYOUT_SIZE_LARGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnectedToInternet() {
|
||||
return Boolean.TRUE.equals(ThreadUtil.executeWithTimeout(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
}
|
||||
}, 2000)); //if can't determine Internet connection within two seconds, assume not connected
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnectedToWifi() {
|
||||
return Boolean.TRUE.equals(ThreadUtil.executeWithTimeout(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
NetworkInfo wifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
return wifi.isConnected();
|
||||
}
|
||||
}, 2000)); //if can't determine Internet connection within two seconds, assume not connected
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadsDir() {
|
||||
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openFile(String filename) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //ensure this task isn't linked to this application
|
||||
Uri uri = Uri.fromFile(new File(filename));
|
||||
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
||||
MimeTypeMap.getFileExtensionFromUrl(uri.toString()));
|
||||
intent.setDataAndType(uri, type);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restart() {
|
||||
try { //solution from http://stackoverflow.com/questions/6609414/howto-programatically-restart-android-app
|
||||
Context c = getApplicationContext();
|
||||
PackageManager pm = c.getPackageManager();
|
||||
if (pm != null) {
|
||||
//create the intent with the default start activity for your application
|
||||
Intent mStartActivity = pm.getLaunchIntentForPackage(c.getPackageName());
|
||||
if (mStartActivity != null) {
|
||||
mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
//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
|
||||
int mPendingIntentId = 223344;
|
||||
PendingIntent mPendingIntent = PendingIntent.getActivity(c, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
AlarmManager mgr = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE);
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
|
||||
//kill the application
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
// Replace the current task with one that is excluded from the recent
|
||||
// apps and that will finish itself immediately. It's critical that this
|
||||
// activity get launched in the task that you want to hide.
|
||||
final Intent relaunch = new Intent(getApplicationContext(), Exiter.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK // CLEAR_TASK requires this
|
||||
| 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
|
||||
startActivity(relaunch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTablet() {
|
||||
return isTablet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLandscapeMode(boolean landscapeMode) {
|
||||
//create file to indicate that portrait mode should be used for tablet or landscape should be used for phone
|
||||
if (landscapeMode != isTablet) {
|
||||
FileUtil.writeFile(switchOrientationFile, "1");
|
||||
}
|
||||
else {
|
||||
FileUtil.deleteFile(switchOrientationFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preventSystemSleep(final boolean preventSleep) {
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() { //must set window flags from EDT thread
|
||||
@Override
|
||||
public void run() {
|
||||
if (preventSleep) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
else {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<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-natives.jar"/>
|
||||
<classpathentry kind="lib" path="libs/gdx-freetype-natives.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<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-natives.jar"/>
|
||||
<classpathentry kind="lib" path="libs/gdx-freetype-natives.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
@ -1,29 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>forge-gui-mobile-dev</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<variableList>
|
||||
<variable>
|
||||
<name>copy_PARENT</name>
|
||||
<value>$%7BPARENT-1-PROJECT_LOC%7D/trunk</value>
|
||||
</variable>
|
||||
</variableList>
|
||||
</projectDescription>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>forge-gui-mobile-dev</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<variableList>
|
||||
<variable>
|
||||
<name>copy_PARENT</name>
|
||||
<value>$%7BPARENT-1-PROJECT_LOC%7D/trunk</value>
|
||||
</variable>
|
||||
</variableList>
|
||||
</projectDescription>
|
@ -1,12 +1,12 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
@ -1,4 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
Before Width: | Height: | Size: 208 KiB After Width: | Height: | Size: 208 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
@ -1,137 +1,137 @@
|
||||
package forge.app;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglClipboard;
|
||||
import forge.Forge;
|
||||
import forge.assets.AssetsDownloader;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.OperatingSystem;
|
||||
import forge.util.RestartUtil;
|
||||
import forge.util.Utils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
// Set this to "true" to make the mobile game port run as a full-screen desktop application
|
||||
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
|
||||
// (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).
|
||||
String desktopModeAssetsDir = "../forge-gui/";
|
||||
//String desktopModeAssetsDir = "./";
|
||||
|
||||
// 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/";
|
||||
if (!AssetsDownloader.SHARE_DESKTOP_ASSETS) {
|
||||
FileUtil.ensureDirectoryExists(assetsDir);
|
||||
}
|
||||
|
||||
// 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";
|
||||
boolean landscapeMode = FileUtil.doesFileExist(switchOrientationFile);
|
||||
|
||||
// Width and height for standard smartphone/tablet mode (desktopMode = false)
|
||||
int screenWidth = landscapeMode ? (int)(Utils.BASE_HEIGHT * 16 / 9) : (int)Utils.BASE_WIDTH;
|
||||
int screenHeight = (int)Utils.BASE_HEIGHT;
|
||||
|
||||
// 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)
|
||||
int desktopScreenWidth = LwjglApplicationConfiguration.getDesktopDisplayMode().width;
|
||||
int desktopScreenHeight = LwjglApplicationConfiguration.getDesktopDisplayMode().height;
|
||||
boolean fullscreenFlag = true;
|
||||
if (FileUtil.doesFileExist(desktopModeAssetsDir + "screen_resolution.ini")) {
|
||||
String[] res = FileUtil.readFileToString(desktopModeAssetsDir + "screen_resolution.ini").split("x");
|
||||
fullscreenFlag = res.length == 3 ? Integer.parseInt(res[2].trim()) > 0 : true;
|
||||
if (res.length >= 2) {
|
||||
desktopScreenWidth = Integer.parseInt(res[0].trim());
|
||||
desktopScreenHeight = Integer.parseInt(res[1].trim());
|
||||
}
|
||||
}
|
||||
|
||||
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
||||
config.resizable = false;
|
||||
config.width = desktopMode ? desktopScreenWidth : screenWidth;
|
||||
config.height = desktopMode ? desktopScreenHeight : screenHeight;
|
||||
config.fullscreen = desktopMode && fullscreenFlag;
|
||||
config.title = "Forge";
|
||||
config.useHDPI = desktopMode; // enable HiDPI on Mac OS
|
||||
|
||||
new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile),
|
||||
desktopMode ? desktopModeAssetsDir : assetsDir), config);
|
||||
}
|
||||
|
||||
private static class DesktopAdapter implements IDeviceAdapter {
|
||||
private final String switchOrientationFile;
|
||||
|
||||
private DesktopAdapter(String switchOrientationFile0) {
|
||||
switchOrientationFile = switchOrientationFile0;
|
||||
}
|
||||
|
||||
//just assume desktop always connected to wifi
|
||||
@Override
|
||||
public boolean isConnectedToInternet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnectedToWifi() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadsDir() {
|
||||
return System.getProperty("user.home") + "/Downloads/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openFile(String filename) {
|
||||
try {
|
||||
Desktop.getDesktop().open(new File(filename));
|
||||
return true;
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restart() {
|
||||
if (RestartUtil.prepareForRestart()) {
|
||||
Gdx.app.exit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
Gdx.app.exit(); //can just use Gdx.app.exit for desktop
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTablet() {
|
||||
return true; //treat desktop the same as a tablet
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLandscapeMode(boolean landscapeMode) {
|
||||
//create file to indicate that landscape mode should be used
|
||||
if (landscapeMode) {
|
||||
FileUtil.writeFile(switchOrientationFile, "1");
|
||||
}
|
||||
else {
|
||||
FileUtil.deleteFile(switchOrientationFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preventSystemSleep(boolean preventSleep) {
|
||||
OperatingSystem.preventSystemSleep(preventSleep);
|
||||
}
|
||||
}
|
||||
}
|
||||
package forge.app;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglClipboard;
|
||||
import forge.Forge;
|
||||
import forge.assets.AssetsDownloader;
|
||||
import forge.interfaces.IDeviceAdapter;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.OperatingSystem;
|
||||
import forge.util.RestartUtil;
|
||||
import forge.util.Utils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
// Set this to "true" to make the mobile game port run as a full-screen desktop application
|
||||
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
|
||||
// (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).
|
||||
String desktopModeAssetsDir = "../forge-gui/";
|
||||
//String desktopModeAssetsDir = "./";
|
||||
|
||||
// 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/";
|
||||
if (!AssetsDownloader.SHARE_DESKTOP_ASSETS) {
|
||||
FileUtil.ensureDirectoryExists(assetsDir);
|
||||
}
|
||||
|
||||
// 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";
|
||||
boolean landscapeMode = FileUtil.doesFileExist(switchOrientationFile);
|
||||
|
||||
// Width and height for standard smartphone/tablet mode (desktopMode = false)
|
||||
int screenWidth = landscapeMode ? (int)(Utils.BASE_HEIGHT * 16 / 9) : (int)Utils.BASE_WIDTH;
|
||||
int screenHeight = (int)Utils.BASE_HEIGHT;
|
||||
|
||||
// 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)
|
||||
int desktopScreenWidth = LwjglApplicationConfiguration.getDesktopDisplayMode().width;
|
||||
int desktopScreenHeight = LwjglApplicationConfiguration.getDesktopDisplayMode().height;
|
||||
boolean fullscreenFlag = true;
|
||||
if (FileUtil.doesFileExist(desktopModeAssetsDir + "screen_resolution.ini")) {
|
||||
String[] res = FileUtil.readFileToString(desktopModeAssetsDir + "screen_resolution.ini").split("x");
|
||||
fullscreenFlag = res.length == 3 ? Integer.parseInt(res[2].trim()) > 0 : true;
|
||||
if (res.length >= 2) {
|
||||
desktopScreenWidth = Integer.parseInt(res[0].trim());
|
||||
desktopScreenHeight = Integer.parseInt(res[1].trim());
|
||||
}
|
||||
}
|
||||
|
||||
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
||||
config.resizable = false;
|
||||
config.width = desktopMode ? desktopScreenWidth : screenWidth;
|
||||
config.height = desktopMode ? desktopScreenHeight : screenHeight;
|
||||
config.fullscreen = desktopMode && fullscreenFlag;
|
||||
config.title = "Forge";
|
||||
config.useHDPI = desktopMode; // enable HiDPI on Mac OS
|
||||
|
||||
new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile),
|
||||
desktopMode ? desktopModeAssetsDir : assetsDir), config);
|
||||
}
|
||||
|
||||
private static class DesktopAdapter implements IDeviceAdapter {
|
||||
private final String switchOrientationFile;
|
||||
|
||||
private DesktopAdapter(String switchOrientationFile0) {
|
||||
switchOrientationFile = switchOrientationFile0;
|
||||
}
|
||||
|
||||
//just assume desktop always connected to wifi
|
||||
@Override
|
||||
public boolean isConnectedToInternet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnectedToWifi() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadsDir() {
|
||||
return System.getProperty("user.home") + "/Downloads/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openFile(String filename) {
|
||||
try {
|
||||
Desktop.getDesktop().open(new File(filename));
|
||||
return true;
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restart() {
|
||||
if (RestartUtil.prepareForRestart()) {
|
||||
Gdx.app.exit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
Gdx.app.exit(); //can just use Gdx.app.exit for desktop
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTablet() {
|
||||
return true; //treat desktop the same as a tablet
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLandscapeMode(boolean landscapeMode) {
|
||||
//create file to indicate that landscape mode should be used
|
||||
if (landscapeMode) {
|
||||
FileUtil.writeFile(switchOrientationFile, "1");
|
||||
}
|
||||
else {
|
||||
FileUtil.deleteFile(switchOrientationFile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preventSystemSleep(boolean preventSleep) {
|
||||
OperatingSystem.preventSystemSleep(preventSleep);
|
||||
}
|
||||
}
|
||||
}
|