splash screen more reasonable; resizing now functions as intended;
This commit is contained in:
@@ -31,7 +31,7 @@ public class DesktopAssetPack implements AssetPack {
|
||||
private FreeTypeFontGenerator darktech_ldr_fontGenerator;
|
||||
|
||||
@Override
|
||||
public void initiateResources() {
|
||||
public void initiate() {
|
||||
default_fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/Gasalt-Regular.ttf"));
|
||||
darktech_ldr_fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/darktech_ldr.ttf"));
|
||||
}
|
||||
|
@@ -17,6 +17,8 @@ public class DesktopLauncher {
|
||||
config.resizable = false;
|
||||
config.useHDPI = true;
|
||||
config.samples = 2;
|
||||
config.width = 320;
|
||||
config.height = 320;
|
||||
config.allowSoftwareMode = true;
|
||||
core = new RhythmBullet();
|
||||
core.setup(new SplashScreen(), new DesktopAssetPack(), screenConfig);
|
||||
|
@@ -73,9 +73,7 @@ public class DesktopScreenConfiguration implements ScreenConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWindowBorderless(boolean borderless) {
|
||||
if (borderless) {
|
||||
System.setProperty("org.lwjgl.opengl.Window.undecorated", String.valueOf(borderless));
|
||||
}
|
||||
public void queueBorderless(boolean borderless) {
|
||||
System.setProperty("org.lwjgl.opengl.Window.undecorated", String.valueOf(borderless));
|
||||
}
|
||||
}
|
||||
|
@@ -119,8 +119,9 @@ public class PCMObtainer implements Observer, PCMSystem {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setMusic() {
|
||||
|
||||
@Override
|
||||
public void updateMusic() {
|
||||
Gdx.app.debug("PCMObtainer", "music set.");
|
||||
sourceID = -1;
|
||||
|
||||
@@ -128,6 +129,8 @@ public class PCMObtainer implements Observer, PCMSystem {
|
||||
sampleRate = mc.getCurrentMusicHeader().getSampleRate();
|
||||
String millisPerWindowF = df.format(windowSize/(float) sampleRate);
|
||||
millisPerWindow = (long) (Float.valueOf(millisPerWindowF)*1000);
|
||||
|
||||
attemptToSync();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -223,22 +226,28 @@ public class PCMObtainer implements Observer, PCMSystem {
|
||||
public void update(Observable o, Object arg) {
|
||||
if (o == mc) {
|
||||
if (arg == mc.states.LOADED) {
|
||||
setMusic();
|
||||
updateMusic();
|
||||
} else if (arg == mc.states.PLAYING) {
|
||||
if (sourceID == -1) {
|
||||
try {
|
||||
Field sourceIDField = ClassReflection.getDeclaredField(OpenALMusic.class, "sourceID");
|
||||
sourceIDField.setAccessible(true);
|
||||
sourceID = (int) sourceIDField.get(mc.getCurrentMusic());
|
||||
} catch (ReflectionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
streamReadThread.start();
|
||||
attemptToSync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void attemptToSync() {
|
||||
if (mc.isPlaying()) {
|
||||
if (sourceID == -1) {
|
||||
try {
|
||||
Field sourceIDField = ClassReflection.getDeclaredField(OpenALMusic.class, "sourceID");
|
||||
sourceIDField.setAccessible(true);
|
||||
sourceID = (int) sourceIDField.get(mc.getCurrentMusic());
|
||||
} catch (ReflectionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
streamReadThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
streamReadThread.stop();
|
||||
|
@@ -3,10 +3,8 @@ package zero1hd.rhythmbullet.desktop.screens;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.ScreenAdapter;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
@@ -14,18 +12,13 @@ import zero1hd.rhythmbullet.desktop.screens.main.MainScreen;
|
||||
import zero1hd.rhythmbullet.util.InitialScreen;
|
||||
|
||||
public class SplashScreen extends ScreenAdapter implements InitialScreen {
|
||||
private Sprite splashSprite;
|
||||
private Texture splashTexture;
|
||||
private SpriteBatch batch;
|
||||
private Color color = new Color(1f, 1f, 1f, 1f);
|
||||
private float fadeTime = 1.5f;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
batch = new SpriteBatch();
|
||||
splashSprite = new Sprite(new Texture(Gdx.files.internal("splashlogo.png")));
|
||||
float scale = (Gdx.graphics.getHeight()/3f)/splashSprite.getHeight();
|
||||
splashSprite.setSize(scale*splashSprite.getWidth(), scale*splashSprite.getHeight());
|
||||
splashSprite.setPosition((Gdx.graphics.getWidth()-splashSprite.getWidth())/2f, (Gdx.graphics.getHeight()-splashSprite.getHeight())/2f);
|
||||
splashTexture = new Texture(Gdx.files.internal("splash_texture.png"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,10 +26,7 @@ public class SplashScreen extends ScreenAdapter implements InitialScreen {
|
||||
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
batch.begin();
|
||||
float change = delta/fadeTime;
|
||||
color.a -= change;
|
||||
splashSprite.setColor(color);
|
||||
splashSprite.draw(batch);
|
||||
batch.draw(splashTexture, 0, 0);
|
||||
batch.end();
|
||||
|
||||
super.render(delta);
|
||||
@@ -44,7 +34,7 @@ public class SplashScreen extends ScreenAdapter implements InitialScreen {
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
splashSprite.getTexture().dispose();
|
||||
splashTexture.dispose();
|
||||
super.hide();
|
||||
}
|
||||
|
||||
@@ -62,7 +52,7 @@ public class SplashScreen extends ScreenAdapter implements InitialScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Screen createMainScreen(RhythmBullet game) {
|
||||
public Screen advance(RhythmBullet game) {
|
||||
return new MainScreen(game);
|
||||
}
|
||||
}
|
||||
|
@@ -101,6 +101,12 @@ public class MainPage extends Page implements Observer {
|
||||
scrollText.setWidth(0.5f*getWidth());
|
||||
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-30f);
|
||||
addActor(scrollText);
|
||||
|
||||
if (mc.getMusicList().isSearched() && amc.isSameSizeMusicList()) {
|
||||
scrollText.setText("Currently playing: " + amc.getAudioMetadata(mc.getCurrentMusicFileHandle()).getTitle(), null);
|
||||
dhv.updateMusic();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,7 +151,7 @@ public class MainPage extends Page implements Observer {
|
||||
}
|
||||
}
|
||||
} else if (o == amc) {
|
||||
if (amc.size() != 0) {
|
||||
if (amc.isSameSizeMusicList()) {
|
||||
scrollText.setText("Currently playing: " + amc.getAudioMetadata(mc.getCurrentMusicFileHandle()).getTitle(), null);
|
||||
}
|
||||
} else if (o == mc.getMusicList()) {
|
||||
|
@@ -44,6 +44,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
private Texture background;
|
||||
|
||||
private Batch screenBatch;
|
||||
private boolean resizing;
|
||||
|
||||
public MainScreen(RhythmBullet core) {
|
||||
this.rhythmBullet = core;
|
||||
@@ -64,19 +65,22 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.act(delta);
|
||||
if (bloomShader != null) {
|
||||
bloomShader.begin();
|
||||
draw();
|
||||
bloomShader.end(stage.getWidth(), stage.getHeight());
|
||||
} else {
|
||||
draw();
|
||||
}
|
||||
|
||||
if (!resizing) {
|
||||
stage.act(delta);
|
||||
if (bloomShader != null) {
|
||||
bloomShader.begin();
|
||||
draw();
|
||||
bloomShader.end(stage.getWidth(), stage.getHeight());
|
||||
} else {
|
||||
draw();
|
||||
}
|
||||
|
||||
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
||||
stage.getCamera().position.lerp(cameraPosition, 0.15f);
|
||||
stage.getViewport().apply();
|
||||
}
|
||||
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
||||
stage.getCamera().position.lerp(cameraPosition, 0.15f);
|
||||
stage.getViewport().apply();
|
||||
}
|
||||
}
|
||||
|
||||
super.render(delta);
|
||||
}
|
||||
@@ -91,6 +95,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
|
||||
@Override
|
||||
public void preAssetLoad() {
|
||||
resizing = true;
|
||||
stage.clear();
|
||||
if (bloomShader != null) {
|
||||
bloomShader.dispose();
|
||||
@@ -103,7 +108,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
|
||||
@Override
|
||||
public void postAssetLoad() {
|
||||
|
||||
resizing = false;
|
||||
bloomShader = new BloomShader(screenBatch);
|
||||
|
||||
background = rhythmBullet.getAssetManager().get("backgrounds/mainBG.png", Texture.class);
|
||||
@@ -130,7 +135,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
analysisPage = new AnalysisPage(rhythmBullet.getSkin(), listeners.returnToMainPageListener, listeners.confirmedSongListener);
|
||||
stage.addActor(analysisPage);
|
||||
|
||||
musicController.getMusicList().asyncSearch(false);
|
||||
musicController.getMusicList().attemptAsyncSearch(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -124,6 +124,8 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
mc.addObserver(this);
|
||||
mc.getMusicList().addObserver(this);
|
||||
selectionLoaderThread = new musicSelectionLoaderThread();
|
||||
|
||||
musicInfoTable.setToDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -93,7 +93,7 @@ public class OptionsPage extends Page {
|
||||
musicSearchTimer -= delta;
|
||||
if (musicSearchTimer <= 0) {
|
||||
musicController.getMusicList().setSearchPath(directoryField.getText());
|
||||
musicController.getMusicList().asyncSearch(false);
|
||||
musicController.getMusicList().attemptAsyncSearch(false);
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
|
Reference in New Issue
Block a user