Created constants for Client.Display.DrawFPS values

This commit is contained in:
Collin Smith 2020-06-06 22:53:28 -07:00
parent da53dabad6
commit da152ff5c6
2 changed files with 23 additions and 9 deletions

View File

@ -114,6 +114,12 @@ public class Client extends Game {
private boolean forceWindowed;
private boolean forceDrawFps;
private byte drawFpsMethod;
public static final byte FPS_NONE = 0;
public static final byte FPS_TOPLEFT = 1;
public static final byte FPS_TOPRIGHT = 2;
public static final byte FPS_BOTTOMLEFT = 3;
public static final byte FPS_BOTTOMRIGHT = 4;
public static final byte FPS_MAX = FPS_BOTTOMRIGHT;
private final GlyphLayout fps = new GlyphLayout();
@ -437,25 +443,25 @@ public class Client extends Game {
fps.setText(font, Integer.toString(Gdx.graphics.getFramesPerSecond()));
int drawFpsMethod = this.drawFpsMethod;
if (forceDrawFps && drawFpsMethod == 0) {
drawFpsMethod = 1;
if (forceDrawFps && drawFpsMethod == FPS_NONE) {
drawFpsMethod = FPS_TOPLEFT;
}
float x, y;
switch (drawFpsMethod) {
case 1:
case FPS_TOPLEFT:
x = 2;
y = Riiablo.viewport.getScreenHeight() - 2;
break;
case 2:
case FPS_TOPRIGHT:
x = Riiablo.viewport.getScreenWidth() - fps.width;
y = viewportHeight - 2;
break;
case 3:
case FPS_BOTTOMLEFT:
x = 2;
y = fps.height;
break;
case 4:
case FPS_BOTTOMRIGHT:
x = Riiablo.viewport.getScreenWidth() - fps.width;
y = fps.height;
break;

View File

@ -17,6 +17,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Locale;
import static com.riiablo.Client.FPS_BOTTOMLEFT;
import static com.riiablo.Client.FPS_BOTTOMRIGHT;
import static com.riiablo.Client.FPS_MAX;
import static com.riiablo.Client.FPS_NONE;
import static com.riiablo.Client.FPS_TOPLEFT;
import static com.riiablo.Client.FPS_TOPRIGHT;
public class Cvars {
public static Collection<Throwable> addTo(CvarManager cvarManager) {
return addTo(cvarManager, Cvars.class, new ArrayList<Throwable>());
@ -128,9 +135,10 @@ public class Cvars {
.alias("Client.Display.ShowFPS")
.description(
"Whether or not to draw the current FPS. " +
"0=Off, 1=Top Left, 2=Top Right, 3=Bottom Left, 4=Bottom Right")
.defaultValue((byte) 0)
.validator(NumberRangeValidator.of(Byte.class, (byte) 0, (byte) 4))
String.format("%d=Off, %d=Top Left, %d=Top Right, %d=Bottom Left, %d=Bottom Right",
FPS_NONE, FPS_TOPLEFT, FPS_TOPRIGHT, FPS_BOTTOMLEFT, FPS_BOTTOMRIGHT))
.defaultValue(FPS_NONE)
.validator(NumberRangeValidator.of(Byte.class, FPS_NONE, FPS_MAX))
.build();
Cvar<Boolean> StatusBar = Cvar.builder(Boolean.class)