|
|
|
@@ -32,7 +32,7 @@ public class RhythmBullet extends Game {
|
|
|
|
|
public static final int SPAWN_CIRCLE_RADIUS = 6;
|
|
|
|
|
public static int pixels_per_unit;
|
|
|
|
|
private boolean initiated;
|
|
|
|
|
private boolean resizing;
|
|
|
|
|
private boolean resizing, simpleResizeOnce;
|
|
|
|
|
private int screenWidth, screenHeight;
|
|
|
|
|
public static final String VERSION = "(1.0.0) R1-PreAlpha";
|
|
|
|
|
|
|
|
|
@@ -53,15 +53,25 @@ public class RhythmBullet extends Game {
|
|
|
|
|
this.initialScreen = initialScreen;
|
|
|
|
|
this.assetPack = assetPack;
|
|
|
|
|
this.screenConfiguration = screenConfiguration;
|
|
|
|
|
screenConfiguration.queueBorderless(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void create() {
|
|
|
|
|
Gdx.app.setLogLevel(Application.LOG_DEBUG);
|
|
|
|
|
initialScreen.init();
|
|
|
|
|
setScreen(initialScreen);
|
|
|
|
|
|
|
|
|
|
assetPack.initiateResources();
|
|
|
|
|
Gdx.app.setLogLevel(Application.LOG_DEBUG);
|
|
|
|
|
screenWidth = Gdx.graphics.getWidth();
|
|
|
|
|
screenHeight = Gdx.graphics.getHeight();
|
|
|
|
|
initialScreen.init();
|
|
|
|
|
initialLoad();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initialLoad() {
|
|
|
|
|
if (initiated) throw new IllegalStateException("Initiation cannot occur more than once.");
|
|
|
|
|
|
|
|
|
|
simpleResizeOnce = true;
|
|
|
|
|
skin = new Skin();
|
|
|
|
|
assetPack.initiate();
|
|
|
|
|
|
|
|
|
|
preferences = Gdx.app.getPreferences("RhythmBullet Preferences");
|
|
|
|
|
|
|
|
|
@@ -84,18 +94,23 @@ public class RhythmBullet extends Game {
|
|
|
|
|
assetManager.setLoader(Sound.class, new SoundLoader(genericFileFinder));
|
|
|
|
|
|
|
|
|
|
rRHandler.setResolution(getPreferences().getInteger("screen-width"), getPreferences().getInteger("screen-height"));
|
|
|
|
|
queueAssets();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initialLoadComplete() {
|
|
|
|
|
screenConfiguration.queueBorderless(preferences.getBoolean("borderless", false));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screenWidth = Gdx.graphics.getWidth();
|
|
|
|
|
screenHeight = Gdx.graphics.getHeight();
|
|
|
|
|
|
|
|
|
|
skin.addRegions(assetManager.get("uiskin.atlas", TextureAtlas.class));
|
|
|
|
|
pixels_per_unit = (int) (Float.valueOf(screenHeight)/Float.valueOf(WORLD_HEIGHT));
|
|
|
|
|
|
|
|
|
|
if (getPreferences().getBoolean("fullscreen", true)) {
|
|
|
|
|
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
|
|
|
|
|
} else {
|
|
|
|
|
Gdx.graphics.setWindowedMode(getPreferences().getInteger("screen-width"), getPreferences().getInteger("screen-height"));
|
|
|
|
|
}
|
|
|
|
|
assetPack.generateFonts(skin);
|
|
|
|
|
assetPack.setupSkin(skin);
|
|
|
|
|
assetPack.complete(assetManager);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@@ -110,8 +125,7 @@ public class RhythmBullet extends Game {
|
|
|
|
|
Gdx.app.debug("Resize", "Post resize is starting...");
|
|
|
|
|
if (skin != null) skin.dispose();
|
|
|
|
|
skin = new Skin();
|
|
|
|
|
skinAtlas = assetManager.get("uiskin.atlas", TextureAtlas.class);
|
|
|
|
|
getSkin().addRegions(skinAtlas);
|
|
|
|
|
skin.addRegions(assetManager.get("uiskin.atlas", TextureAtlas.class));
|
|
|
|
|
|
|
|
|
|
assetPack.generateFonts(skin);
|
|
|
|
|
assetPack.setupSkin(skin);
|
|
|
|
@@ -119,15 +133,14 @@ public class RhythmBullet extends Game {
|
|
|
|
|
if (getScreen() instanceof ResizeReadyScreen) {
|
|
|
|
|
((ResizeReadyScreen) getScreen()).postAssetLoad();
|
|
|
|
|
} else {
|
|
|
|
|
throw new IllegalStateException("Cannot perform window resize on a screen that isn't using a resize ready screen.");
|
|
|
|
|
throw new IllegalStateException("Cannot perform window resize on a screen that isn't resize ready.");
|
|
|
|
|
}
|
|
|
|
|
Gdx.app.debug("Resize", "Post resize has ended.");
|
|
|
|
|
|
|
|
|
|
if (!initiated) {
|
|
|
|
|
setScreen(((InitialScreen) initialScreen).createMainScreen(this));
|
|
|
|
|
initiated = true;
|
|
|
|
|
}
|
|
|
|
|
resizing = false;
|
|
|
|
|
} else if (!initiated) {
|
|
|
|
|
initiated = true;
|
|
|
|
|
initialLoadComplete();
|
|
|
|
|
setScreen(((InitialScreen) initialScreen).advance(this));
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@@ -142,6 +155,7 @@ public class RhythmBullet extends Game {
|
|
|
|
|
try {
|
|
|
|
|
advancedResizeScreen.preAssetLoad();
|
|
|
|
|
} catch (NullPointerException cleanScreen) {
|
|
|
|
|
Gdx.app.debug("Screen", "clean screen: " + advancedResizeScreen.getClass().getSimpleName());
|
|
|
|
|
//Tried to perform pre-asset reload, but had uninitialized objects, meaning this is a new screen, or "clean" screen.
|
|
|
|
|
} finally {
|
|
|
|
|
advancedResizeScreen.postAssetLoad();
|
|
|
|
@@ -152,25 +166,30 @@ public class RhythmBullet extends Game {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void resize(int width, int height) {
|
|
|
|
|
Gdx.app.debug("resize", "Current size:" + screenWidth + "x" + screenHeight + " new size: " + width + "x" + height);
|
|
|
|
|
if (width != screenWidth || height != screenHeight) {
|
|
|
|
|
screenWidth = Gdx.graphics.getWidth();
|
|
|
|
|
screenHeight = Gdx.graphics.getHeight();
|
|
|
|
|
|
|
|
|
|
if (screenWidth != width || screenHeight != height) {
|
|
|
|
|
Gdx.app.debug("resize", "Current size:" + screenWidth + "x" + screenHeight + " new size: " + width + "x" + height);
|
|
|
|
|
screenWidth = width;
|
|
|
|
|
screenHeight = height;
|
|
|
|
|
pixels_per_unit = (int) (Float.valueOf(screenHeight)/Float.valueOf(WORLD_HEIGHT));
|
|
|
|
|
Gdx.app.debug("Resize", "Pre-resize is happening. Resizing to " + width + "x" + height);
|
|
|
|
|
rRHandler.setResolution(width, height);
|
|
|
|
|
if (getScreen() instanceof ResizeReadyScreen) {
|
|
|
|
|
((ResizeReadyScreen) getScreen()).preAssetLoad();
|
|
|
|
|
} else {
|
|
|
|
|
throw new IllegalStateException("Cannot perform window resize on a screen that isn't using a resize ready screen.");
|
|
|
|
|
}
|
|
|
|
|
preferences.putInteger("screen-width", width);
|
|
|
|
|
preferences.putInteger("screen-height", height);
|
|
|
|
|
preferences.flush();
|
|
|
|
|
resizing = true;
|
|
|
|
|
assetManager.clear();
|
|
|
|
|
queueAssets();
|
|
|
|
|
|
|
|
|
|
if (!simpleResizeOnce) {
|
|
|
|
|
Gdx.app.debug("Resize", "complex pre-resize is happening. Resizing to " + width + "x" + height);
|
|
|
|
|
if (getScreen() instanceof ResizeReadyScreen) {
|
|
|
|
|
((ResizeReadyScreen) getScreen()).preAssetLoad();
|
|
|
|
|
} else {
|
|
|
|
|
throw new IllegalStateException("Cannot perform window resize on a screen that isn't using a resize ready screen.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resizing = true;
|
|
|
|
|
assetManager.clear();
|
|
|
|
|
queueAssets();
|
|
|
|
|
} else {
|
|
|
|
|
simpleResizeOnce = false;
|
|
|
|
|
}
|
|
|
|
|
super.resize(width, height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|