Added control for debug mode

This commit is contained in:
Collin Smith
2019-11-24 16:29:04 -08:00
parent cb95b0c8ce
commit d7ba715fef
2 changed files with 12 additions and 1 deletions

View File

@ -35,6 +35,7 @@ public class Keys {
private Keys() {}
public static final MappedKey Console = new MappedKey("Console", "console", Input.Keys.GRAVE);
public static final MappedKey DebugMode = new MappedKey("Debug Mode", "debug", Input.Keys.F12);
public static final MappedKey Esc = new MappedKey("Esc", "esc", Input.Keys.ESCAPE, Input.Keys.BACK);
public static final MappedKey Inventory = new MappedKey("Inventory", "inventory", Input.Keys.I, Input.Keys.B);
public static final MappedKey Character = new MappedKey("Character", "character", Input.Keys.C, Input.Keys.A);

View File

@ -111,6 +111,13 @@ public class ClientScreen extends ScreenAdapter implements LoadingScreen.Loadabl
Stage stage;
Viewport viewport;
boolean isDebug;
MappedKeyStateAdapter debugKeyListener = new MappedKeyStateAdapter() {
@Override
public void onPressed(MappedKey key, int keycode) {
isDebug = !isDebug;
}
};
Engine engine;
RenderSystem renderer;
@ -483,7 +490,7 @@ public class ClientScreen extends ScreenAdapter implements LoadingScreen.Loadabl
batch.end();
if (Gdx.app.getType() != Application.ApplicationType.Android) {
if (isDebug) {
ShapeRenderer shapes = Riiablo.shapes;
shapes.identity();
shapes.setProjectionMatrix(iso.combined);
@ -550,6 +557,8 @@ public class ClientScreen extends ScreenAdapter implements LoadingScreen.Loadabl
@Override
public void show() {
isDebug = DEBUG && Gdx.app.getType() == Application.ApplicationType.Desktop;
Keys.DebugMode.addStateListener(debugKeyListener);
Keys.Esc.addStateListener(mappedKeyStateListener);
Keys.Enter.addStateListener(mappedKeyStateListener);
Keys.Inventory.addStateListener(mappedKeyStateListener);
@ -640,6 +649,7 @@ public class ClientScreen extends ScreenAdapter implements LoadingScreen.Loadabl
@Override
public void hide() {
Keys.DebugMode.removeStateListener(debugKeyListener);
Keys.Esc.removeStateListener(mappedKeyStateListener);
Keys.Enter.removeStateListener(mappedKeyStateListener);
Keys.Inventory.removeStateListener(mappedKeyStateListener);