Merge branch 'master' into 'master'

minor fixes

See merge request core-developers/forge!3432
This commit is contained in:
Anthony Calosa
2020-11-25 04:39:00 +00:00
7 changed files with 31 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
package forge.app;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.AlertDialog;
@@ -28,6 +29,8 @@ import android.os.PowerManager;
import android.provider.Settings;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
@@ -65,7 +68,7 @@ public class Main extends AndroidApplication {
boolean permissiongranted = checkPermission();
Gadapter = new AndroidAdapter(this.getContext());
initForge(Gadapter, permissiongranted, totalMemory);
initForge(Gadapter, permissiongranted, totalMemory, isTabletDevice(this.getContext()));
//permission
if(!permissiongranted){
@@ -73,7 +76,19 @@ public class Main extends AndroidApplication {
displayMessage(Gadapter);
}
}
private static boolean isTabletDevice(Context activityContext) {
Display display = ((Activity) activityContext).getWindowManager().getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
float widthInches = metrics.widthPixels / metrics.xdpi;
float heightInches = metrics.heightPixels / metrics.ydpi;
double diagonalInches = Math.sqrt(Math.pow(widthInches, 2) + Math.pow(heightInches, 2));
if (diagonalInches >= 7.0) {
return true;
}
return false;
}
private void displayMessage(AndroidAdapter adapter){
TableLayout TL = new TableLayout(this);
TableRow row = new TableRow(this);
@@ -192,7 +207,7 @@ public class Main extends AndroidApplication {
builder.show();
}
private void initForge(AndroidAdapter adapter, boolean permissiongranted, int totalRAM){
private void initForge(AndroidAdapter adapter, boolean permissiongranted, int totalRAM, boolean isTabletDevice){
boolean isPortrait;
if (permissiongranted){
//establish assets directory
@@ -232,12 +247,12 @@ public class Main extends AndroidApplication {
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir, propertyConfig, isPortrait, totalRAM));
initialize(Forge.getApp(new AndroidClipboard(), adapter, assetsDir, propertyConfig, isPortrait, totalRAM, isTabletDevice));
} else {
isPortrait = true;
//set current orientation
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM));
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, isPortrait, totalRAM, isTabletDevice));
}
}

View File

@@ -32,8 +32,8 @@ public class Main extends IOSApplication.Delegate {
config.useAccelerometer = false;
config.useCompass = false;
ForgePreferences prefs = FModel.getPreferences();
boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);//todo get totalRAM
final ApplicationListener app = Forge.getApp(new IOSClipboard(), new IOSAdapter(), assetsDir, propertyConfig, false, 0);
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);
final IOSApplication iosApp = new IOSApplication(app, config);
return iosApp;
}

View File

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

View File

@@ -67,6 +67,7 @@ public class Forge implements ApplicationListener {
public static boolean altPlayerLayout = false;
public static boolean enableUIMask = false;
public static boolean enablePreloadExtendedArt = false;
public static boolean isTabletDevice = false;
public static String locale = "en-US";
public static boolean hdbuttons = false;
public static boolean hdstart = false;
@@ -75,7 +76,7 @@ public class Forge implements ApplicationListener {
public static int cacheSize = 400;
public static int totalDeviceRAM = 0;
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM) {
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet) {
if (GuiBase.getInterface() == null) {
clipboard = clipboard0;
deviceAdapter = deviceAdapter0;
@@ -83,6 +84,7 @@ public class Forge implements ApplicationListener {
GuiBase.enablePropertyConfig(value);
isPortraitMode = androidOrientation;
totalDeviceRAM = totalRAM;
isTabletDevice = isTablet;
//increase cacheSize for devices with RAM more than 5GB, default is 400. Some phones have more than 10GB RAM (Mi 10, OnePlus 8, S20, etc..)
if (totalDeviceRAM>5000) //devices with more than 10GB RAM will have 1000 Cache size, 700 Cache size for morethan 5GB RAM
cacheSize = totalDeviceRAM>10000 ? 1000: 700;

View File

@@ -143,7 +143,8 @@ public class MatchController extends AbstractGuiGame {
}
}
view = new MatchScreen(playerPanels);
view.resetFields();
if(GuiBase.isNetworkplay())
view.resetFields();
clearSelectables(); //fix uncleared selection
if (noHumans) {

View File

@@ -62,7 +62,7 @@ public class ConquestRewardDialog extends FScrollPane {
columnCount = 1;
}
else if (cardCount < 5) {
if (Forge.extrawide.equals("default"))
if (Forge.extrawide.equals("default") && !Forge.isTabletDevice)
columnCount = 2;
else {
if (cardCount == 4)
@@ -72,7 +72,7 @@ public class ConquestRewardDialog extends FScrollPane {
}
}
else {
if (Forge.extrawide.equals("extrawide"))
if (Forge.extrawide.equals("extrawide") || Forge.isTabletDevice)
columnCount = 5;
else if (Forge.extrawide.equals("wide"))
columnCount = 4;

View File

@@ -1,6 +1,6 @@
Name:Unleash Fury
ManaCost:1 R
Types:Instant
A:SP$ Pump | Cost$ 1R | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ +X | References$ X | SpellDescription$ Double the power of target creature until end of turn.
A:SP$ Pump | Cost$ 1 R | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ +X | References$ X | SpellDescription$ Double the power of target creature until end of turn.
SVar:X:Targeted$CardPower
Oracle:Double the power of target creature until end of turn.