Search in sources :

Example 1 with GuiImage

use of org.asassecreations.engine.gui.GuiImage in project Voxel_Game by ASasseCreations.

the class MenuGuiSystem method init.

public static final void init(final MenuState state) {
    menuContainer = new GuiPanel(0f, 0f, .8f, .8f, new Color(0f, 0f, 0f, .75f));
    startButton = new GuiButton(0f, .5f, .5f, .1f, data -> state.manager().push(new GameState(100)), menuContainer);
    settingsButton = new GuiButton(0f, 0f, .5f, .1f, data -> {
    }, menuContainer);
    quitButton = new GuiButton(0f, -.5f, .5f, .1f, data -> state.manager().pop(), menuContainer);
    text = new SoftwareImage((int) startButton.getScreenWidth(), (int) startButton.getScreenHeight());
    text.clear();
    text.graphics().setFont(new Font("Arial", Font.PLAIN, 32));
    text.centerString("Start", Color.WHITE, null);
    startImage = new GuiImage(0f, 0f, 1f, 1f, text.toTexture(null), startButton);
    text.clear();
    text.graphics().setFont(new Font("Arial", Font.PLAIN, 32));
    text.centerString("Settings", Color.WHITE, null);
    settingsImage = new GuiImage(0f, 0f, 1f, 1f, text.toTexture(null), settingsButton);
    text.clear();
    text.graphics().setFont(new Font("Arial", Font.PLAIN, 32));
    text.centerString("Quit", Color.WHITE, null);
    quitImage = new GuiImage(0f, 0f, 1f, 1f, text.toTexture(null), quitButton);
    menuContainer.add();
}
Also used : GuiImage(org.asassecreations.engine.gui.GuiImage) Color(org.asassecreations.engine.render.Color) GuiButton(org.asassecreations.engine.gui.GuiButton) MenuState(org.asassecreations.voxelgame.state.MenuState) Font(java.awt.Font) SoftwareImage(org.asassecreations.engine.tools.SoftwareImage) GuiPanel(org.asassecreations.engine.gui.GuiPanel) GameState(org.asassecreations.voxelgame.state.GameState) GuiImage(org.asassecreations.engine.gui.GuiImage) GuiButton(org.asassecreations.engine.gui.GuiButton) SoftwareImage(org.asassecreations.engine.tools.SoftwareImage) GuiPanel(org.asassecreations.engine.gui.GuiPanel) Color(org.asassecreations.engine.render.Color) GameState(org.asassecreations.voxelgame.state.GameState) Font(java.awt.Font)

Example 2 with GuiImage

use of org.asassecreations.engine.gui.GuiImage in project Voxel_Game by ASasseCreations.

the class GameStateGuis method init.

public static final void init(final TextureProperties properties) {
    minimapImage = new GuiImage(-.75f, .55f, 0f, .4f, new Texture(Minimap.texture));
    minimapImage.flipYAxis = true;
    mouseTexture = TextureLoader.getTexture("/textures/crosshair.png", properties);
    mouseImage = new GuiImage(0f, 0f, 0f, .075f, mouseTexture);
    pointTexture = TextureLoader.getTexture("/textures/player.png", properties);
    pointImage = new GuiImage(0f, 0f, 0f, .1f, pointTexture, minimapImage);
    inventory = new GuiImage(0, 0, (float) Inventory.background.getWidth() / (float) Display.getWidth(), (float) Inventory.background.getHeight() / (float) Display.getHeight(), null);
    minimapImage.add();
    mouseImage.add();
    pointImage.add();
    inventory.add();
}
Also used : GuiImage(org.asassecreations.engine.gui.GuiImage) Texture(org.asassecreations.engine.texture.Texture)

Example 3 with GuiImage

use of org.asassecreations.engine.gui.GuiImage in project Voxel_Game by ASasseCreations.

the class GuiSystem method render.

public static final void render() {
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    Renderer.blendFunction(BlendFunction.NORMAL);
    GL11.glDepthMask(false);
    PANEL_SHADER.start();
    GL30.glBindVertexArray(model.id);
    GL20.glEnableVertexAttribArray(0);
    IMAGE_SHADER.start();
    for (final GuiImage image : GuiStorage.getImages()) if (image.isGlobalEnabled() && image.background) {
        IMAGE_SHADER.setTransformation(MatrixCreation.createTransformationMatrix(new Vec2(image.getGlobalX(), image.getGlobalY()), new Vec2(image.getGlobalWidth(), image.getGlobalHeight())));
        IMAGE_SHADER.setFlipYAxis(image.flipYAxis);
        image.texture.bind(0);
        GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, model.vertexCount);
    }
    PANEL_SHADER.start();
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    for (final GuiPanel panel : GuiStorage.getPanels()) if (panel.isGlobalEnabled()) {
        GL11.glScissor((int) panel.getScreenX(), (int) panel.getScreenY(), (int) panel.getScreenWidth(), (int) panel.getScreenHeight());
        PANEL_SHADER.setTransformation(MatrixCreation.createTransformationMatrix(new Vec2(panel.getGlobalX(), panel.getGlobalY()), new Vec2(panel.getGlobalWidth(), panel.getGlobalHeight())));
        PANEL_SHADER.setColor(panel.color);
        GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, model.vertexCount);
    }
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    IMAGE_SHADER.start();
    for (final GuiImage image : GuiStorage.getImages()) if (image.isGlobalEnabled() && !image.background) {
        if (image.texture == null)
            continue;
        IMAGE_SHADER.setTransformation(MatrixCreation.createTransformationMatrix(new Vec2(image.getGlobalX(), image.getGlobalY()), new Vec2(image.getGlobalWidth(), image.getGlobalHeight())));
        IMAGE_SHADER.setFlipYAxis(image.flipYAxis);
        image.texture.bind(0);
        GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, model.vertexCount);
    }
    IMAGE_SHADER.stop();
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);
    Renderer.blendFunction(null);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
}
Also used : GuiImage(org.asassecreations.engine.gui.GuiImage) Vec2(org.asassecreations.engine.math.vector.Vec2) GuiPanel(org.asassecreations.engine.gui.GuiPanel)

Example 4 with GuiImage

use of org.asassecreations.engine.gui.GuiImage in project Voxel_Game by ASasseCreations.

the class MenuState method init.

public final void init() {
    MouseSystem.enable();
    // Setup background image
    backgroundTexture = TextureLoader.getTexture("/textures/background.png", null);
    backgroundImage = new GuiImage(0f, 0f, 1f, 1f, backgroundTexture);
    backgroundImage.background = true;
    backgroundImage.add();
    // Setup container
    container = new GuiPanel(0f, 0f, .75f, .75f, new Color(0f, 0f, 0f, .75f));
    container.add();
    // Setup start button
    startButton = new GuiButton(0f, .5f, 0f, .1f, data -> {
        if (MouseInput.isButtonJustPressed(0)) {
            manager.pop();
            manager.push(new GameState(100f));
        }
    }, container);
    startButton.setLocalWidth(startButton.getLocalWidth() * 2f);
    startButton.add();
    // Setup software image
    final SoftwareImage image = new SoftwareImage(startButton.getScreenWidth(), startButton.getScreenHeight());
    image.graphics().setFont(new Font("Arial", Font.PLAIN, 32));
    image.clear();
    image.centerString("Start", new Color(1f, 1f, 1f), null);
    startText = image.toTexture(null);
    startImage = new GuiImage(0, 0, 1, 1, startText, startButton);
    startImage.add();
    // Setup options button
    optionsButton = new GuiButton(0f, 0f, 0f, .1f, data -> {
    }, container);
    optionsButton.setLocalWidth(optionsButton.getLocalWidth() * 2f);
    optionsButton.add();
    image.clear();
    image.centerString("Options", new Color(1f, 1f, 1f), null);
    optionsText = image.toTexture(null);
    optionsImage = new GuiImage(0, 0, 1, 1, optionsText, optionsButton);
    optionsImage.add();
    // Setup quit button
    quitButton = new GuiButton(0f, -.5f, 0f, .1f, data -> {
        if (MouseInput.isButtonJustPressed(0))
            VoxelGame.loop.stop();
    }, container);
    quitButton.setLocalWidth(quitButton.getLocalWidth() * 2f);
    quitButton.add();
    image.clear();
    image.centerString("Quit", new Color(1f, 1f, 1f), null);
    quitText = image.toTexture(null);
    quitImage = new GuiImage(0, 0, 1, 1, quitText, quitButton);
    quitImage.add();
    image.destroy();
}
Also used : Color(org.asassecreations.engine.render.Color) Font(java.awt.Font) Texture(org.asassecreations.engine.texture.Texture) MouseSystem(org.asassecreations.voxelgame.input.MouseSystem) VoxelGame(org.asassecreations.voxelgame.VoxelGame) StateManager(org.asassecreations.engine.state.StateManager) SoftwareImage(org.asassecreations.engine.tools.SoftwareImage) GuiImage(org.asassecreations.engine.gui.GuiImage) TextureLoader(org.asassecreations.engine.texture.TextureLoader) GuiButton(org.asassecreations.engine.gui.GuiButton) State(org.asassecreations.engine.state.State) MouseInput(org.asassecreations.engine.input.MouseInput) GuiSystem(org.asassecreations.voxelgame.gui.GuiSystem) GuiPanel(org.asassecreations.engine.gui.GuiPanel) GuiImage(org.asassecreations.engine.gui.GuiImage) GuiButton(org.asassecreations.engine.gui.GuiButton) SoftwareImage(org.asassecreations.engine.tools.SoftwareImage) GuiPanel(org.asassecreations.engine.gui.GuiPanel) Color(org.asassecreations.engine.render.Color) Font(java.awt.Font)

Aggregations

GuiImage (org.asassecreations.engine.gui.GuiImage)4 GuiPanel (org.asassecreations.engine.gui.GuiPanel)3 Font (java.awt.Font)2 GuiButton (org.asassecreations.engine.gui.GuiButton)2 Color (org.asassecreations.engine.render.Color)2 Texture (org.asassecreations.engine.texture.Texture)2 SoftwareImage (org.asassecreations.engine.tools.SoftwareImage)2 MouseInput (org.asassecreations.engine.input.MouseInput)1 Vec2 (org.asassecreations.engine.math.vector.Vec2)1 State (org.asassecreations.engine.state.State)1 StateManager (org.asassecreations.engine.state.StateManager)1 TextureLoader (org.asassecreations.engine.texture.TextureLoader)1 VoxelGame (org.asassecreations.voxelgame.VoxelGame)1 GuiSystem (org.asassecreations.voxelgame.gui.GuiSystem)1 MouseSystem (org.asassecreations.voxelgame.input.MouseSystem)1 GameState (org.asassecreations.voxelgame.state.GameState)1 MenuState (org.asassecreations.voxelgame.state.MenuState)1