2017-01-22 13:46:38 +01:00
|
|
|
package org.warp.picalculator.gui.screens;
|
2016-10-02 16:01:41 +02:00
|
|
|
|
2017-01-22 13:46:38 +01:00
|
|
|
import static org.warp.picalculator.gui.PIDisplay.colore;
|
|
|
|
import static org.warp.picalculator.gui.PIDisplay.fonts;
|
2016-10-02 16:01:41 +02:00
|
|
|
|
|
|
|
import org.warp.picalculator.Main;
|
|
|
|
import org.warp.picalculator.device.Keyboard.Key;
|
2017-01-22 13:46:38 +01:00
|
|
|
import org.warp.picalculator.gui.PIDisplay;
|
2016-10-02 16:01:41 +02:00
|
|
|
|
|
|
|
public class LoadingScreen extends Screen {
|
|
|
|
|
|
|
|
public float endLoading;
|
|
|
|
boolean mustRefresh = true;
|
|
|
|
public float loadingTextTranslation = 0.0f;
|
|
|
|
public boolean loadingTextTranslationTopToBottom = true;
|
|
|
|
private boolean loading;
|
2016-11-25 22:40:43 +01:00
|
|
|
private static final String titleString = "PICalculator by Andrea Cavalli";
|
2016-10-02 16:01:41 +02:00
|
|
|
|
|
|
|
public LoadingScreen() {
|
|
|
|
super();
|
|
|
|
canBeInHistory = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void created() throws InterruptedException {
|
|
|
|
endLoading = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init() throws InterruptedException {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeRender(float dt) {
|
|
|
|
if (loadingTextTranslation >= 10.0f) {
|
|
|
|
loadingTextTranslation = 10.0f;
|
|
|
|
loadingTextTranslationTopToBottom = false;
|
|
|
|
} else if (loadingTextTranslation <= -10.0f) {
|
|
|
|
loadingTextTranslation = -10.0f;
|
|
|
|
loadingTextTranslationTopToBottom = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loadingTextTranslationTopToBottom) {
|
|
|
|
loadingTextTranslation += dt * 15;
|
|
|
|
} else {
|
|
|
|
loadingTextTranslation -= dt * 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
endLoading += dt;
|
2016-11-25 22:40:43 +01:00
|
|
|
if (endLoading >= 2) {
|
2016-10-02 16:01:41 +02:00
|
|
|
loading = false;
|
2016-12-04 22:22:16 +01:00
|
|
|
PIDisplay.INSTANCE.setScreen(new MathInputScreen());
|
2016-10-02 16:01:41 +02:00
|
|
|
}
|
|
|
|
mustRefresh = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render() {
|
2017-01-22 13:46:38 +01:00
|
|
|
PIDisplay.renderer.glSetFont(fonts[2]);
|
2016-10-02 16:01:41 +02:00
|
|
|
colore(1.0f, 1.0f, 1.0f, 1.0f);
|
2017-01-22 13:46:38 +01:00
|
|
|
PIDisplay.renderer.glDrawStringCenter((Main.screenSize[0] / 2) - 1,(int) ((Main.screenSize[1]/ 2) - 25 + loadingTextTranslation), titleString);
|
2016-10-02 16:01:41 +02:00
|
|
|
colore(1.0f, 1.0f, 1.0f, 1.0f);
|
2017-01-22 13:46:38 +01:00
|
|
|
PIDisplay.renderer.glDrawStringCenter((Main.screenSize[0] / 2) + 1,(int) ((Main.screenSize[1]/ 2) - 25 + loadingTextTranslation), titleString);
|
2016-10-02 16:01:41 +02:00
|
|
|
colore(1.0f, 1.0f, 1.0f, 1.0f);
|
2017-01-22 13:46:38 +01:00
|
|
|
PIDisplay.renderer.glDrawStringCenter((Main.screenSize[0] / 2), (int) ((Main.screenSize[1]/ 2) - 25 - 1 + loadingTextTranslation), titleString);
|
2016-10-02 16:01:41 +02:00
|
|
|
colore(1.0f, 1.0f, 1.0f, 1.0f);
|
2017-01-22 13:46:38 +01:00
|
|
|
PIDisplay.renderer.glDrawStringCenter((Main.screenSize[0] / 2), (int) ((Main.screenSize[1]/ 2) - 25 + 1 + loadingTextTranslation), titleString);
|
2016-10-02 16:01:41 +02:00
|
|
|
colore(1.0f, 0.5f, 0.0f, 1.0f);
|
2017-01-22 13:46:38 +01:00
|
|
|
PIDisplay.renderer.glDrawStringCenter((Main.screenSize[0] / 2), (int) ((Main.screenSize[1]/ 2) - 25 + loadingTextTranslation), titleString);
|
2016-10-02 16:01:41 +02:00
|
|
|
colore(0.0f, 0.0f, 0.0f, 0.75f);
|
2017-01-22 13:46:38 +01:00
|
|
|
PIDisplay.renderer.glSetFont(fonts[0]);
|
|
|
|
PIDisplay.renderer.glDrawStringCenter((Main.screenSize[0] / 2), (Main.screenSize[1]/ 2) + 11, "LOADING");
|
|
|
|
PIDisplay.renderer.glSetFont(fonts[1]);
|
2016-10-02 16:01:41 +02:00
|
|
|
colore(0.0f, 0.0f, 0.0f, 0.5f);
|
2017-01-22 13:46:38 +01:00
|
|
|
PIDisplay.renderer.glDrawStringCenter((Main.screenSize[0] / 2), (Main.screenSize[1]/ 2) + 22, "PLEASE WAIT...");
|
2016-10-02 16:01:41 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean mustBeRefreshed() {
|
|
|
|
if (mustRefresh) {
|
|
|
|
mustRefresh = false;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean keyPressed(Key k) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean keyReleased(Key k) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|