mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Add FPS Display
This commit is contained in:
@@ -48,6 +48,7 @@ public class Forge implements ApplicationListener {
|
|||||||
private static int screenWidth;
|
private static int screenWidth;
|
||||||
private static int screenHeight;
|
private static int screenHeight;
|
||||||
private static Graphics graphics;
|
private static Graphics graphics;
|
||||||
|
private static FrameRate frameRate;
|
||||||
private static FScreen currentScreen;
|
private static FScreen currentScreen;
|
||||||
private static SplashScreen splashScreen;
|
private static SplashScreen splashScreen;
|
||||||
private static KeyInputAdapter keyInputAdapter;
|
private static KeyInputAdapter keyInputAdapter;
|
||||||
@@ -59,6 +60,7 @@ public class Forge implements ApplicationListener {
|
|||||||
public static String extrawide = "default";
|
public static String extrawide = "default";
|
||||||
public static float heigtModifier = 0.0f;
|
public static float heigtModifier = 0.0f;
|
||||||
private static boolean isloadingaMatch = false;
|
private static boolean isloadingaMatch = false;
|
||||||
|
public static boolean showFPS = false;
|
||||||
|
|
||||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0) {
|
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0) {
|
||||||
if (GuiBase.getInterface() == null) {
|
if (GuiBase.getInterface() == null) {
|
||||||
@@ -79,6 +81,7 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
graphics = new Graphics();
|
graphics = new Graphics();
|
||||||
splashScreen = new SplashScreen();
|
splashScreen = new SplashScreen();
|
||||||
|
frameRate = new FrameRate();
|
||||||
Gdx.input.setInputProcessor(new MainInputProcessor());
|
Gdx.input.setInputProcessor(new MainInputProcessor());
|
||||||
/*
|
/*
|
||||||
Set CatchBackKey here and exit the app when you hit the
|
Set CatchBackKey here and exit the app when you hit the
|
||||||
@@ -101,6 +104,8 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
textureFiltering = prefs.getPrefBoolean(FPref.UI_LIBGDX_TEXTURE_FILTERING);
|
textureFiltering = prefs.getPrefBoolean(FPref.UI_LIBGDX_TEXTURE_FILTERING);
|
||||||
|
|
||||||
|
showFPS = prefs.getPrefBoolean(FPref.UI_SHOW_FPS);
|
||||||
|
|
||||||
final Localizer localizer = Localizer.getInstance();
|
final Localizer localizer = Localizer.getInstance();
|
||||||
|
|
||||||
//load model on background thread (using progress bar to report progress)
|
//load model on background thread (using progress bar to report progress)
|
||||||
@@ -366,6 +371,9 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
|
if (showFPS)
|
||||||
|
frameRate.update();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ImageCache.allowSingleLoad();
|
ImageCache.allowSingleLoad();
|
||||||
ForgeAnimation.advanceAll();
|
ForgeAnimation.advanceAll();
|
||||||
@@ -408,6 +416,8 @@ public class Forge implements ApplicationListener {
|
|||||||
graphics.end();
|
graphics.end();
|
||||||
BugReporter.reportException(ex);
|
BugReporter.reportException(ex);
|
||||||
}
|
}
|
||||||
|
if (showFPS)
|
||||||
|
frameRate.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
62
forge-gui-mobile/src/forge/FrameRate.java
Normal file
62
forge-gui-mobile/src/forge/FrameRate.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package forge;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
import com.badlogic.gdx.utils.TimeUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A nicer class for showing framerate that doesn't spam the console
|
||||||
|
* like Logger.log()
|
||||||
|
*
|
||||||
|
* @author William Hartman
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FrameRate implements Disposable{
|
||||||
|
long lastTimeCounted;
|
||||||
|
private float sinceChange;
|
||||||
|
private float frameRate;
|
||||||
|
private BitmapFont font;
|
||||||
|
private SpriteBatch batch;
|
||||||
|
private OrthographicCamera cam;
|
||||||
|
|
||||||
|
public FrameRate() {
|
||||||
|
lastTimeCounted = TimeUtils.millis();
|
||||||
|
sinceChange = 0;
|
||||||
|
frameRate = Gdx.graphics.getFramesPerSecond();
|
||||||
|
font = new BitmapFont();
|
||||||
|
batch = new SpriteBatch();
|
||||||
|
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resize(int screenWidth, int screenHeight) {
|
||||||
|
cam = new OrthographicCamera(screenWidth, screenHeight);
|
||||||
|
cam.translate(screenWidth / 2, screenHeight / 2);
|
||||||
|
cam.update();
|
||||||
|
batch.setProjectionMatrix(cam.combined);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
long delta = TimeUtils.timeSinceMillis(lastTimeCounted);
|
||||||
|
lastTimeCounted = TimeUtils.millis();
|
||||||
|
sinceChange += delta;
|
||||||
|
if(sinceChange >= 1000) {
|
||||||
|
sinceChange = 0;
|
||||||
|
frameRate = Gdx.graphics.getFramesPerSecond();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render() {
|
||||||
|
batch.begin();
|
||||||
|
font.draw(batch, (int)frameRate + " fps", 3, Gdx.graphics.getHeight() - 3);
|
||||||
|
batch.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
font.dispose();
|
||||||
|
batch.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -305,6 +305,16 @@ public class SettingsPage extends TabPage<SettingsScreen> {
|
|||||||
"Enable Round Border Mask",
|
"Enable Round Border Mask",
|
||||||
"When enabled, the card corners are rounded (Preferably Card with Full Borders)."),
|
"When enabled, the card corners are rounded (Preferably Card with Full Borders)."),
|
||||||
4);
|
4);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_SHOW_FPS,
|
||||||
|
"Show FPS Display",
|
||||||
|
"When enabled, show the FPS Display (Experimental)."){
|
||||||
|
@Override
|
||||||
|
public void select() {
|
||||||
|
super.select();
|
||||||
|
//update
|
||||||
|
Forge.showFPS = FModel.getPreferences().getPrefBoolean(FPref.UI_SHOW_FPS);
|
||||||
|
}
|
||||||
|
},4);
|
||||||
|
|
||||||
lstSettings.addItem(new CustomSelectSetting(FPref.UI_CARD_COUNTER_DISPLAY_TYPE,
|
lstSettings.addItem(new CustomSelectSetting(FPref.UI_CARD_COUNTER_DISPLAY_TYPE,
|
||||||
localizer.getMessage("cbpCounterDisplayType"),
|
localizer.getMessage("cbpCounterDisplayType"),
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
|
|||||||
UI_DYNAMIC_PLANECHASE_BG("false"),
|
UI_DYNAMIC_PLANECHASE_BG("false"),
|
||||||
UI_DISABLE_IMAGES_EFFECT_CARDS("false"),
|
UI_DISABLE_IMAGES_EFFECT_CARDS("false"),
|
||||||
UI_ENABLE_BORDER_MASKING("false"),
|
UI_ENABLE_BORDER_MASKING("false"),
|
||||||
|
UI_SHOW_FPS("false"),
|
||||||
UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"),
|
UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"),
|
||||||
UI_DEFAULT_FONT_SIZE("12"),
|
UI_DEFAULT_FONT_SIZE("12"),
|
||||||
UI_SELECT_FROM_CARD_DISPLAYS("true"),
|
UI_SELECT_FROM_CARD_DISPLAYS("true"),
|
||||||
|
|||||||
Reference in New Issue
Block a user