LibGDX Update

-Update to 1.9.13
-Add additional info on Forge.log
This commit is contained in:
Anthony Calosa
2021-01-16 10:00:27 +08:00
parent a32611528e
commit da54db1fca
12 changed files with 78 additions and 21 deletions

View File

@@ -102,7 +102,7 @@
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-android</artifactId> <artifactId>gdx-backend-android</artifactId>
<version>1.9.10</version> <version>1.9.13</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -68,7 +68,7 @@ public class Main extends AndroidApplication {
boolean permissiongranted = checkPermission(); boolean permissiongranted = checkPermission();
Gadapter = new AndroidAdapter(this.getContext()); Gadapter = new AndroidAdapter(this.getContext());
initForge(Gadapter, permissiongranted, totalMemory, isTabletDevice(this.getContext()), android.os.Build.VERSION.SDK_INT); initForge(Gadapter, permissiongranted, totalMemory, isTabletDevice(this.getContext()), Build.VERSION.SDK_INT, Build.VERSION.RELEASE);
//permission //permission
if(!permissiongranted){ if(!permissiongranted){
@@ -207,7 +207,7 @@ public class Main extends AndroidApplication {
builder.show(); builder.show();
} }
private void initForge(AndroidAdapter adapter, boolean permissiongranted, int totalRAM, boolean isTabletDevice, int AndroidVersion){ private void initForge(AndroidAdapter adapter, boolean permissiongranted, int totalRAM, boolean isTabletDevice, int AndroidAPI, String AndroidRelease){
boolean isPortrait; boolean isPortrait;
if (permissiongranted){ if (permissiongranted){
//establish assets directory //establish assets directory
@@ -247,12 +247,12 @@ public class Main extends AndroidApplication {
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} }
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir, propertyConfig, isPortrait, totalRAM, isTabletDevice, AndroidVersion)); initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir, propertyConfig, isPortrait, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
} else { } else {
isPortrait = true; isPortrait = true;
//set current orientation //set current orientation
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation); Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM, isTabletDevice, AndroidVersion)); initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
} }
} }
@@ -291,6 +291,19 @@ public class Main extends AndroidApplication {
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
public boolean hasContents() {
if (cm.getPrimaryClip().getItemCount() > 0) {
try {
return cm.getPrimaryClip().getItemAt(0).coerceToText(getContext()).length() > 0;
}
catch (Exception ex) {
return false;
}
}
return false;
}
@Override @Override
public String getContents() { public String getContents() {
if (cm.getPrimaryClip().getItemCount() > 0) { if (cm.getPrimaryClip().getItemCount() > 0) {
@@ -440,4 +453,26 @@ public class Main extends AndroidApplication {
bmp.compress(Bitmap.CompressFormat.JPEG, 100, output); bmp.compress(Bitmap.CompressFormat.JPEG, 100, output);
} }
} }
public String getDeviceName() {
String manufacturer = Build.MANUFACTURER;
String model = Build.MODEL;
if (model.toLowerCase().startsWith(manufacturer.toLowerCase())) {
return capitalize(model);
} else {
return capitalize(manufacturer) + " " + model;
}
}
private String capitalize(String s) {
if (s == null || s.length() == 0) {
return "";
}
char first = s.charAt(0);
if (Character.isUpperCase(first)) {
return s;
} else {
return Character.toUpperCase(first) + s.substring(1);
}
}
} }

View File

@@ -73,7 +73,7 @@
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-robovm</artifactId> <artifactId>gdx-backend-robovm</artifactId>
<version>1.9.10</version> <version>1.9.13</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -33,7 +33,7 @@ public class Main extends IOSApplication.Delegate {
config.useCompass = false; config.useCompass = false;
ForgePreferences prefs = FModel.getPreferences(); ForgePreferences prefs = FModel.getPreferences();
boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);//todo get totalRAM && isTabletDevice boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);//todo get totalRAM && isTabletDevice
final ApplicationListener app = Forge.getApp(new IOSClipboard(), new IOSAdapter(), assetsDir, propertyConfig, false, 0, false, 0); final ApplicationListener app = Forge.getApp(new IOSClipboard(), new IOSAdapter(), assetsDir, propertyConfig, false, 0, false, 0, "", "");
final IOSApplication iosApp = new IOSApplication(app, config); final IOSApplication iosApp = new IOSApplication(app, config);
return iosApp; return iosApp;
} }
@@ -46,6 +46,11 @@ public class Main extends IOSApplication.Delegate {
//special clipboard that works on iOS //special clipboard that works on iOS
private static final class IOSClipboard implements com.badlogic.gdx.utils.Clipboard { private static final class IOSClipboard implements com.badlogic.gdx.utils.Clipboard {
@Override
public boolean hasContents() {
return UIPasteboard.getGeneralPasteboard().toString().length() > 0;
}
@Override @Override
public String getContents() { public String getContents() {
return UIPasteboard.getGeneralPasteboard().getString(); return UIPasteboard.getGeneralPasteboard().getString();

View File

@@ -60,18 +60,18 @@
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId> <artifactId>gdx-backend-lwjgl</artifactId>
<version>1.9.10</version> <version>1.9.13</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId> <artifactId>gdx-platform</artifactId>
<version>1.9.10</version> <version>1.9.13</version>
<classifier>natives-desktop</classifier> <classifier>natives-desktop</classifier>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype-platform</artifactId> <artifactId>gdx-freetype-platform</artifactId>
<version>1.9.10</version> <version>1.9.13</version>
<classifier>natives-desktop</classifier> <classifier>natives-desktop</classifier>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli --> <!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->

View File

@@ -97,7 +97,7 @@ public class Main {
ForgePreferences prefs = FModel.getPreferences(); ForgePreferences prefs = FModel.getPreferences();
boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT); boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);
new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile),//todo get totalRAM && isTabletDevice new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile),//todo get totalRAM && isTabletDevice
desktopMode ? desktopModeAssetsDir : assetsDir, propertyConfig, false, 0, false, 0), config); desktopMode ? desktopModeAssetsDir : assetsDir, propertyConfig, false, 0, false, 0, "", ""), config);
} }
private static class DesktopAdapter implements IDeviceAdapter { private static class DesktopAdapter implements IDeviceAdapter {

View File

@@ -63,12 +63,12 @@
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx</artifactId> <artifactId>gdx</artifactId>
<version>1.9.10</version> <version>1.9.13</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.badlogicgames.gdx</groupId> <groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype</artifactId> <artifactId>gdx-freetype</artifactId>
<version>1.9.10</version> <version>1.9.13</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -75,10 +75,9 @@ public class Forge implements ApplicationListener {
public static boolean gameInProgress = false; public static boolean gameInProgress = false;
public static int cacheSize = 400; public static int cacheSize = 400;
public static int totalDeviceRAM = 0; public static int totalDeviceRAM = 0;
public static int androidVersion = 0;
public static boolean autoCache = false; public static boolean autoCache = false;
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidVersion) { public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
if (GuiBase.getInterface() == null) { if (GuiBase.getInterface() == null) {
clipboard = clipboard0; clipboard = clipboard0;
deviceAdapter = deviceAdapter0; deviceAdapter = deviceAdapter0;
@@ -87,8 +86,8 @@ public class Forge implements ApplicationListener {
isPortraitMode = androidOrientation; isPortraitMode = androidOrientation;
totalDeviceRAM = totalRAM; totalDeviceRAM = totalRAM;
isTabletDevice = isTablet; isTabletDevice = isTablet;
androidVersion = AndroidVersion;
} }
GuiBase.setDeviceInfo(deviceName, AndroidRelease, AndroidAPI);
return app; return app;
} }
@@ -877,19 +876,19 @@ public class Forge implements ApplicationListener {
} }
@Override @Override
public boolean scrolled(int amount) { public boolean scrolled(float amountX, float amountY) {
updatePotentialListeners(mouseMovedX, mouseMovedY); updatePotentialListeners(mouseMovedX, mouseMovedY);
if (KeyInputAdapter.isCtrlKeyDown()) { //zoom in or out based on amount if (KeyInputAdapter.isCtrlKeyDown()) { //zoom in or out based on amount
return zoom(mouseMovedX, mouseMovedY, -Utils.AVG_FINGER_WIDTH * amount); return zoom(mouseMovedX, mouseMovedY, -Utils.AVG_FINGER_WIDTH * amountY);
} }
boolean handled; boolean handled;
if (KeyInputAdapter.isShiftKeyDown()) { if (KeyInputAdapter.isShiftKeyDown()) {
handled = pan(mouseMovedX, mouseMovedY, -Utils.AVG_FINGER_WIDTH * amount, 0, false); handled = pan(mouseMovedX, mouseMovedY, -Utils.AVG_FINGER_WIDTH * amountX, 0, false);
} }
else { else {
handled = pan(mouseMovedX, mouseMovedY, 0, -Utils.AVG_FINGER_HEIGHT * amount, true); handled = pan(mouseMovedX, mouseMovedY, 0, -Utils.AVG_FINGER_HEIGHT * amountY, true);
} }
if (panStop(mouseMovedX, mouseMovedY)) { if (panStop(mouseMovedX, mouseMovedY)) {
handled = true; handled = true;

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.Gdx;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import forge.FThreads; import forge.FThreads;
import forge.Forge; import forge.Forge;
import forge.GuiBase;
import forge.download.GuiDownloadZipService; import forge.download.GuiDownloadZipService;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
import forge.screens.SplashScreen; import forge.screens.SplashScreen;
@@ -50,7 +51,7 @@ public class AssetsDownloader {
"https://releases.cardforge.org/forge/forge-gui-android/" + version + "/" + filename, "https://releases.cardforge.org/forge/forge-gui-android/" + version + "/" + filename,
Forge.getDeviceAdapter().getDownloadsDir(), null, splashScreen.getProgressBar()).download(filename); Forge.getDeviceAdapter().getDownloadsDir(), null, splashScreen.getProgressBar()).download(filename);
if (apkFile != null) { if (apkFile != null) {
if (Forge.androidVersion < 29) { //Android 9 and below... if (GuiBase.getAndroidAPILevel() < 29) { //Android 9 and below...
Forge.getDeviceAdapter().openFile(apkFile); Forge.getDeviceAdapter().openFile(apkFile);
Forge.exit(true); Forge.exit(true);
return; return;

View File

@@ -20,6 +20,7 @@ public abstract class FGestureAdapter extends InputAdapter {
public abstract boolean pan(float x, float y, float deltaX, float deltaY, boolean moreVertical); public abstract boolean pan(float x, float y, float deltaX, float deltaY, boolean moreVertical);
public abstract boolean panStop(float x, float y); public abstract boolean panStop(float x, float y);
public abstract boolean zoom(float x, float y, float amount); public abstract boolean zoom(float x, float y, float amount);
public abstract boolean scrolled(float amountX, float amountY);
private float tapSquareSize, longPressDelay, lastTapX, lastTapY, tapSquareCenterX, tapSquareCenterY; private float tapSquareSize, longPressDelay, lastTapX, lastTapY, tapSquareCenterX, tapSquareCenterY;
private long tapCountInterval, flingDelay, lastTapTime; private long tapCountInterval, flingDelay, lastTapTime;

View File

@@ -8,6 +8,9 @@ public class GuiBase {
private static boolean networkplay = false; private static boolean networkplay = false;
private static boolean isAndroidport = false; private static boolean isAndroidport = false;
private static boolean interrupted = false; private static boolean interrupted = false;
private static String deviceName = "";
private static String androidRelease = "";
private static int androidAPI = 0;
public static IGuiBase getInterface() { return guiInterface; } public static IGuiBase getInterface() { return guiInterface; }
public static void setInterface(IGuiBase i0) { guiInterface = i0; } public static void setInterface(IGuiBase i0) { guiInterface = i0; }
@@ -15,6 +18,11 @@ public class GuiBase {
public static void setIsAndroid(boolean value) { isAndroidport = value; } public static void setIsAndroid(boolean value) { isAndroidport = value; }
public static boolean isAndroid() { return isAndroidport; } public static boolean isAndroid() { return isAndroidport; }
public static void setDeviceInfo(String device, String androidName, int androidAPI) { deviceName = device; androidRelease = androidName; androidAPI = androidAPI; }
public static String getDeviceName() { return deviceName; }
public static String getAndroidRelease() { return androidRelease; }
public static int getAndroidAPILevel() { return androidAPI; }
public static boolean isNetworkplay() { return networkplay; } public static boolean isNetworkplay() { return networkplay; }
public static void setNetworkplay(boolean value) { networkplay = value; } public static void setNetworkplay(boolean value) { networkplay = value; }

View File

@@ -98,6 +98,14 @@ public final class FModel {
private static GameFormat.Collection formats; private static GameFormat.Collection formats;
public static void initialize(final IProgressBar progressBar, Function<ForgePreferences, Void> adjustPrefs) { public static void initialize(final IProgressBar progressBar, Function<ForgePreferences, Void> adjustPrefs) {
//init version to log
System.out.println("Forge v." + GuiBase.getInterface().getCurrentVersion() + " (" + GuiBase.getInterface() + ")");
//Device
if (GuiBase.isAndroid()) //todo get device on other mobile platforms
System.out.println(GuiBase.getDeviceName() + " (Android " + GuiBase.getAndroidRelease() + " API Level " + GuiBase.getAndroidAPILevel() + ")");
else
System.out.println(System.getProperty("os.name") + " (" + System.getProperty("os.version") + " " + System.getProperty("os.arch") + ")");
ImageKeys.initializeDirs( ImageKeys.initializeDirs(
ForgeConstants.CACHE_CARD_PICS_DIR, ForgeConstants.CACHE_CARD_PICS_SUBDIR, ForgeConstants.CACHE_CARD_PICS_DIR, ForgeConstants.CACHE_CARD_PICS_SUBDIR,
ForgeConstants.CACHE_TOKEN_PICS_DIR, ForgeConstants.CACHE_ICON_PICS_DIR, ForgeConstants.CACHE_TOKEN_PICS_DIR, ForgeConstants.CACHE_ICON_PICS_DIR,