use of org.asassecreations.engine.gui.GuiButton 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.GuiButton in project Voxel_Game by ASasseCreations.
the class GuiSystem method input.
public static final boolean input() {
final float x = MouseInput.getX();
final float y = MouseInput.getY();
boolean hit = false;
for (int i = 0; i < GuiStorage.getPanels().size(); i++) if (square(GuiStorage.getPanels().get(i)).contains(x, y))
hit = true;
for (int i = 0; i < GuiStorage.getButtons().size(); i++) {
final GuiButton button = GuiStorage.getButtons().get(i);
if (square(button).contains(x, y) && button.operation != null)
button.operation.operation(new Object[] { button, x, y });
}
return hit;
}
use of org.asassecreations.engine.gui.GuiButton 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