- Improved the Forge Mobile Dev project: it can now function as a fullscreen back-port of the mobile Forge app running on Linux, Mac and Windows PCs.

- Added desktopMode parameter to forge-gui-mobile-dev Main: set it to "true" to make the game run in full-screen mode.
- Added desktopModeAssetsDir parameter to forge-gui-mobile-dev Main: it can be set to make the game use the standard desktop Forge assets folder structure.
- Disabled resizing for the forge-gui-mobile-dev screen when running in standard cellphone/tablet "emulation" mode since it causes visual graphics corruption.
- Added a Maven plugin to forge-gui-mobile-dev to build a .jar with dependencies (like for desktop Forge) that can function as a standalone executable running on Linux, Mac and Windows systems.
This commit is contained in:
Agetian
2016-12-22 18:06:34 +00:00
parent d1bd0f0293
commit e9385941cc
2 changed files with 57 additions and 1 deletions

View File

@@ -21,6 +21,37 @@
<target>1.7</target> <target>1.7</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<attach>false</attach>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>forge.app.Main</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Version>${fullversionstring}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- this is used for inheritance merges -->
<phase>package</phase>
<!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@@ -6,6 +6,7 @@ import java.io.IOException;
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.LwjglClipboard; import com.badlogic.gdx.backends.lwjgl.LwjglClipboard;
import forge.Forge; import forge.Forge;
@@ -18,18 +19,42 @@ import forge.util.Utils;
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
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/"; 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)
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)
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)
int fullscreenWidth = LwjglApplicationConfiguration.getDesktopDisplayMode().width;
int fullscreenHeight = LwjglApplicationConfiguration.getDesktopDisplayMode().height;
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.resizable = false;
config.width = desktopMode ? fullscreenWidth : screenWidth;
config.height = desktopMode ? fullscreenHeight : screenHeight;
config.fullscreen = desktopMode ? true : false;
config.title = "Forge";
//config.useHDPI = true; // enable HiDPI on Mac OS X (not tested)
new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile), new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile),
assetsDir), "Forge", screenWidth, screenHeight); desktopMode ? desktopModeAssetsDir : assetsDir), config);
} }
private static class DesktopAdapter implements IDeviceAdapter { private static class DesktopAdapter implements IDeviceAdapter {