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();
}
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();
}
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);
}
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();
}
Aggregations