2017-01-22 13:46:38 +01:00
|
|
|
package org.warp.picalculator.gui.screens;
|
2016-10-02 16:01:41 +02:00
|
|
|
|
2017-10-17 22:49:21 +02:00
|
|
|
import org.warp.picalculator.StaticVars;
|
2018-06-30 18:46:53 +02:00
|
|
|
import org.warp.picalculator.device.HardwareDevice;
|
2017-01-31 22:29:49 +01:00
|
|
|
import org.warp.picalculator.gui.GraphicUtils;
|
2016-10-02 16:01:41 +02:00
|
|
|
|
|
|
|
public class LoadingScreen extends Screen {
|
|
|
|
|
|
|
|
public float endLoading;
|
|
|
|
boolean mustRefresh = true;
|
|
|
|
public float loadingTextTranslation = 0.0f;
|
2017-12-23 15:20:42 +01:00
|
|
|
public boolean loaded = false;
|
2018-03-31 18:02:36 +02:00
|
|
|
private float previousZoomValue = 1;
|
2016-10-02 16:01:41 +02:00
|
|
|
|
|
|
|
public LoadingScreen() {
|
|
|
|
super();
|
|
|
|
canBeInHistory = false;
|
|
|
|
}
|
2017-01-31 22:29:49 +01:00
|
|
|
|
2016-10-02 16:01:41 +02:00
|
|
|
@Override
|
|
|
|
public void created() throws InterruptedException {
|
|
|
|
endLoading = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-03-31 18:02:36 +02:00
|
|
|
public void initialized() throws InterruptedException {
|
2018-09-02 03:47:24 +02:00
|
|
|
previousZoomValue = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue());
|
2018-08-29 00:07:45 +02:00
|
|
|
StaticVars.windowZoom.onNext(1f);
|
2018-03-31 18:02:36 +02:00
|
|
|
}
|
2017-01-31 22:29:49 +01:00
|
|
|
|
2016-10-02 16:01:41 +02:00
|
|
|
@Override
|
|
|
|
public void beforeRender(float dt) {
|
2017-01-31 22:29:49 +01:00
|
|
|
loadingTextTranslation = GraphicUtils.sinDeg(endLoading * 90f) * 10f;
|
2016-10-02 16:01:41 +02:00
|
|
|
|
|
|
|
endLoading += dt;
|
2017-12-23 15:20:42 +01:00
|
|
|
if (loaded && (StaticVars.debugOn || endLoading >= 3.5f)) {
|
2018-08-29 00:07:45 +02:00
|
|
|
StaticVars.windowZoom.onNext(previousZoomValue);
|
2018-06-30 18:46:53 +02:00
|
|
|
HardwareDevice.INSTANCE.getDisplayManager().setScreen(new MathInputScreen());
|
2016-10-02 16:01:41 +02:00
|
|
|
}
|
|
|
|
mustRefresh = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render() {
|
2018-06-30 18:46:53 +02:00
|
|
|
HardwareDevice.INSTANCE.getDisplayManager().guiSkin.use(HardwareDevice.INSTANCE.getDisplayManager().engine);
|
|
|
|
HardwareDevice.INSTANCE.getDisplayManager().renderer.glColor3i(255, 255, 255);
|
|
|
|
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 80, StaticVars.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
|
|
|
|
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
|
2017-02-02 10:30:45 +01:00
|
|
|
|
2018-06-30 18:46:53 +02:00
|
|
|
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 224, StaticVars.screenSize[1] - 48, 224, 48, 0, 80, 224, 48);
|
|
|
|
HardwareDevice.INSTANCE.getDisplayManager().renderer.glFillRect(StaticVars.screenSize[0] - 160 - 24 - 224, StaticVars.screenSize[1] - 48, 160, 48, 224, 80, 160, 48);
|
2017-01-31 22:29:49 +01:00
|
|
|
|
2016-10-02 16:01:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean mustBeRefreshed() {
|
|
|
|
if (mustRefresh) {
|
|
|
|
mustRefresh = false;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|