Search in sources :

Example 1 with AnimatedBoxRow

use of org.terasology.splash.glfw.widgets.AnimatedBoxRow in project Terasology by MovingBlocks.

the class GLFWSplashScreen method run.

@Override
public void run() {
    if (!GLFW.glfwInit()) {
        throw new RuntimeException("Cannot init GLFW!");
    }
    int width = 800;
    int height = 289;
    window = new Window(width, height, "", false);
    pixel = new Texture();
    ByteBuffer bytes = BufferUtils.createByteBuffer(4);
    bytes.put((byte) -1).put((byte) -1).put((byte) -1).put((byte) -1);
    bytes.flip();
    pixel.bind();
    pixel.uploadData(1, 1, bytes);
    try {
        widgets.add(new Image(GLFWSplashScreen.class.getResource("/splash/splash.png"), 0, 0));
        widgets.add(new ActivatableImage(GLFWSplashScreen.class.getResource("/splash/splash_1.png"), 0, 0, TerasologyEngineStatus.PREPARING_SUBSYSTEMS.getDescription()));
        widgets.add(new ActivatableImage(GLFWSplashScreen.class.getResource("/splash/splash_2.png"), 150, 0, TerasologyEngineStatus.INITIALIZING_MODULE_MANAGER.getDescription()));
        widgets.add(new ActivatableImage(GLFWSplashScreen.class.getResource("/splash/splash_3.png"), 300, 0, TerasologyEngineStatus.INITIALIZING_ASSET_TYPES.getDescription()));
        widgets.add(new ActivatableImage(GLFWSplashScreen.class.getResource("/splash/splash_4.png"), 450, 0, TerasologyEngineStatus.INITIALIZING_SUBSYSTEMS.getDescription()));
        widgets.add(new ActivatableImage(GLFWSplashScreen.class.getResource("/splash/splash_5.png"), 630, 0, TerasologyEngineStatus.INITIALIZING_ASSET_MANAGEMENT.getDescription()));
        widgets.add(new Image(GLFWSplashScreen.class.getResource("/splash/splash_text.png"), 0, 0));
        widgets.add(new BorderedRectangle(pixel, 20, 20, 600, 30));
        widgets.add(new AnimatedBoxRow(pixel, 20 + 450 + 10, 20, 600 - 450 - 20, 30));
    } catch (IOException e) {
        throw new RuntimeException("Cannot load splash image resources");
    }
    Renderer renderer = new Renderer();
    renderer.init();
    countDownLatch.countDown();
    GL11.glClearColor(0f, 0f, 0f, 0f);
    double last = GLFW.glfwGetTime();
    try {
        while (!isClosing && !window.isClosing()) {
            double dTime = GLFW.glfwGetTime() - last;
            last = GLFW.glfwGetTime();
            renderer.clear();
            widgets.forEach(widget -> widget.update(dTime));
            widgets.forEach(i -> i.render(renderer));
            renderer.drawText(message, 30, 25, Color.BLACK);
            window.update();
        }
    } finally {
        widgets.stream().filter(w -> w instanceof Image).map(w -> (Image) w).forEach(Image::delete);
        pixel.delete();
        renderer.dispose();
        window.destroy();
    }
}
Also used : Window(org.terasology.splash.glfw.graphics.Window) ActivatableImage(org.terasology.splash.glfw.widgets.ActivatableImage) Image(org.terasology.splash.glfw.widgets.Image) Renderer(org.terasology.splash.glfw.graphics.Renderer) IOException(java.io.IOException) TerasologyEngineStatus(org.terasology.engine.core.TerasologyEngineStatus) GLFW(org.lwjgl.glfw.GLFW) Widget(org.terasology.splash.glfw.widgets.Widget) ByteBuffer(java.nio.ByteBuffer) BufferUtils(org.lwjgl.BufferUtils) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Window(org.terasology.splash.glfw.graphics.Window) AnimatedBoxRow(org.terasology.splash.glfw.widgets.AnimatedBoxRow) BorderedRectangle(org.terasology.splash.glfw.widgets.BorderedRectangle) GL11(org.lwjgl.opengl.GL11) Texture(org.terasology.splash.glfw.graphics.Texture) LinkedList(java.util.LinkedList) SplashScreen(org.terasology.splash.SplashScreen) Color(org.terasology.splash.glfw.graphics.Color) BorderedRectangle(org.terasology.splash.glfw.widgets.BorderedRectangle) ActivatableImage(org.terasology.splash.glfw.widgets.ActivatableImage) IOException(java.io.IOException) ActivatableImage(org.terasology.splash.glfw.widgets.ActivatableImage) Image(org.terasology.splash.glfw.widgets.Image) Texture(org.terasology.splash.glfw.graphics.Texture) ByteBuffer(java.nio.ByteBuffer) Renderer(org.terasology.splash.glfw.graphics.Renderer) AnimatedBoxRow(org.terasology.splash.glfw.widgets.AnimatedBoxRow)

Aggregations

IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 BufferUtils (org.lwjgl.BufferUtils)1 GLFW (org.lwjgl.glfw.GLFW)1 GL11 (org.lwjgl.opengl.GL11)1 TerasologyEngineStatus (org.terasology.engine.core.TerasologyEngineStatus)1 SplashScreen (org.terasology.splash.SplashScreen)1 Color (org.terasology.splash.glfw.graphics.Color)1 Renderer (org.terasology.splash.glfw.graphics.Renderer)1 Texture (org.terasology.splash.glfw.graphics.Texture)1 Window (org.terasology.splash.glfw.graphics.Window)1 ActivatableImage (org.terasology.splash.glfw.widgets.ActivatableImage)1 AnimatedBoxRow (org.terasology.splash.glfw.widgets.AnimatedBoxRow)1 BorderedRectangle (org.terasology.splash.glfw.widgets.BorderedRectangle)1 Image (org.terasology.splash.glfw.widgets.Image)1 Widget (org.terasology.splash.glfw.widgets.Widget)1