mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Fix so average finger size doesn't exceed a certain amount relative to the overall screen size
This commit is contained in:
@@ -9,6 +9,6 @@ import forge.util.Utils;
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
new LwjglApplication(Forge.getApp(new LwjglClipboard(), "../forge-gui/", null),
|
||||
"Forge", (int)Utils.BASE_WIDTH, (int)Utils.BASE_HEIGHT);
|
||||
"Forge", Utils.DEV_SCREEN_WIDTH, Utils.DEV_SCREEN_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,22 +5,30 @@ import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
public class Utils {
|
||||
private static final float ppcX = Gdx.graphics.getPpcX(), ppcY = Gdx.graphics.getPpcY();
|
||||
public static final float BASE_WIDTH = 320f, BASE_HEIGHT = 480f;
|
||||
public static final float BASE_WIDTH = 320f;
|
||||
public static final float BASE_HEIGHT = 480f;
|
||||
public static final float SCREEN_WIDTH = (float)Gdx.graphics.getWidth();
|
||||
public static final float SCREEN_HEIGHT = (float)Gdx.graphics.getHeight();
|
||||
public static final float WIDTH_RATIO = SCREEN_WIDTH / BASE_WIDTH;
|
||||
public static final float HEIGHT_RATIO = SCREEN_HEIGHT / BASE_HEIGHT;
|
||||
public static final float MIN_RATIO = Math.min(WIDTH_RATIO, HEIGHT_RATIO);
|
||||
public static final float MAX_RATIO = Math.max(WIDTH_RATIO, HEIGHT_RATIO);
|
||||
|
||||
private static final float AVG_FINGER_SIZE_CM = 1.1f;
|
||||
|
||||
//Uncomment below and comment out above to specify AVG_FINGER_WIDTH and AVG_FINGER_HEIGHT
|
||||
//Swap commented out line below to specify average finger size and dev screen size
|
||||
private static final float ppcX = Gdx.graphics.getPpcX(), ppcY = Gdx.graphics.getPpcY();
|
||||
public static final int DEV_SCREEN_WIDTH = (int)BASE_WIDTH, DEV_SCREEN_HEIGHT = (int)BASE_HEIGHT;
|
||||
//private static final float ppcX = 169f / AVG_FINGER_SIZE_CM, ppcY = 237f / AVG_FINGER_SIZE_CM;
|
||||
//public static final float BASE_WIDTH = 540f, BASE_HEIGHT = 960f;
|
||||
//public static final int DEV_SCREEN_WIDTH = 540, DEV_SCREEN_HEIGHT = 960;
|
||||
|
||||
public static final float AVG_FINGER_WIDTH = Math.round(cmToPixelsX(AVG_FINGER_SIZE_CM)); //round to nearest int to reduce floating point display issues
|
||||
public static final float AVG_FINGER_HEIGHT = Math.round(cmToPixelsY(AVG_FINGER_SIZE_CM));
|
||||
//round to nearest int to reduce floating point display issues
|
||||
//reduce if either would take up too large a percentage of the screen to prevent layouts not working
|
||||
private static final float MIN_FINGERS_WIDE = 5;//ensure screen considered to be at least 5 "fingers" wide
|
||||
private static final float MIN_FINGERS_TALL = MIN_FINGERS_WIDE * BASE_HEIGHT / BASE_WIDTH; //ensure screen tall enough based on fingers wide and base ratio
|
||||
|
||||
public static final float WIDTH_RATIO = ((float)Gdx.graphics.getWidth() / BASE_WIDTH);
|
||||
public static final float HEIGHT_RATIO = ((float)Gdx.graphics.getHeight() / BASE_HEIGHT);
|
||||
public static final float MIN_RATIO = Math.min(WIDTH_RATIO, HEIGHT_RATIO);
|
||||
public static final float MAX_RATIO = Math.max(WIDTH_RATIO, HEIGHT_RATIO);
|
||||
public static final float AVG_FINGER_WIDTH = Math.round(Math.min(cmToPixelsX(AVG_FINGER_SIZE_CM), SCREEN_WIDTH / MIN_FINGERS_WIDE));
|
||||
public static final float AVG_FINGER_HEIGHT = Math.round(Math.min(cmToPixelsY(AVG_FINGER_SIZE_CM), SCREEN_HEIGHT / MIN_FINGERS_TALL));
|
||||
|
||||
public static float cmToPixelsX(float cm) {
|
||||
return ppcX * cm;
|
||||
|
||||
Reference in New Issue
Block a user