Search in sources :

Example 6 with Vector4f

use of org.joml.Vector4f in project chunkstories-api by Hugobros3.

the class BaseButton method render.

@Override
public void render(RenderingInterface renderer) {
    float width = getWidth();
    String localizedText = layer.getGameWindow().getClient().getContent().localization().localize(text);
    Texture2D buttonTexture = renderer.textures().getTexture("./textures/gui/scalableButton2.png");
    if (isFocused() || isMouseOver())
        buttonTexture = renderer.textures().getTexture("./textures/gui/scalableButtonOver2.png");
    buttonTexture.setLinearFiltering(false);
    renderer.getGuiRenderer().drawCorneredBoxTiled(xPosition, yPosition, width, getHeight(), 4 * scale(), buttonTexture, 32, scale());
    // new Vector4f(76/255f, 76/255f, 76/255f, 1));
    renderer.getFontRenderer().drawString(font, xPosition + 4 * scale(), yPosition, localizedText, fontScaler * scale(), new Vector4f(0, 0, 0, 1));
}
Also used : Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Vector4f(org.joml.Vector4f)

Example 7 with Vector4f

use of org.joml.Vector4f in project chunkstories-api by Hugobros3.

the class InputText method render.

@Override
public void render(RenderingInterface renderer) {
    String text = this.text;
    if (password) {
        String passworded = "";
        for (@SuppressWarnings("unused") char c : text.toCharArray()) passworded += "*";
        text = passworded;
    }
    Texture2D backgroundTexture = renderer.textures().getTexture(isFocused() ? "./textures/gui/textbox.png" : "./textures/gui/textboxnofocus.png");
    if (this.isTransparent)
        backgroundTexture = renderer.textures().getTexture(isFocused() ? "./textures/gui/textboxnofocustransp.png" : "./textures/gui/textboxtransp.png");
    backgroundTexture.setLinearFiltering(false);
    renderer.getGuiRenderer().drawCorneredBoxTiled(xPosition - 0 * scale(), yPosition - 0 * scale(), getWidth() + 0 * scale(), getHeight() + 0 * scale(), 4, backgroundTexture, 32, scale());
    renderer.getFontRenderer().drawStringWithShadow(ttfFont, xPosition + 4 * scale(), yPosition + 1 * scale(), text + ((isFocused() && System.currentTimeMillis() % 1000 > 500) ? "|" : ""), scale(), scale(), new Vector4f(1.0f));
}
Also used : Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Vector4f(org.joml.Vector4f)

Example 8 with Vector4f

use of org.joml.Vector4f in project chunkstories-api by Hugobros3.

the class LargeButtonIcon method render.

@Override
public void render(RenderingInterface renderer) {
    String localizedText = layer.getGameWindow().getClient().getContent().localization().localize(text);
    Texture2D buttonTexture = renderer.textures().getTexture("./textures/gui/mainMenu.png");
    if (isFocused() || isMouseOver())
        buttonTexture = renderer.textures().getTexture("./textures/gui/mainMenuOver.png");
    buttonTexture.setLinearFiltering(false);
    renderer.getGuiRenderer().drawCorneredBoxTiled(xPosition, yPosition, getWidth(), getHeight(), 4 * scale(), buttonTexture, 32, scale());
    Font font = layer.getGameWindow().getFontRenderer().getFont("LiberationSansNarrow-Bold__aa", 32f);
    float a = 0.5f;
    // a = 1;
    float yPositionText = yPosition + 26 * scale();
    float centering = getWidth() / 2 - font.getWidth(localizedText) * a * scale() / 2;
    renderer.getFontRenderer().drawString(font, xPosition + centering + scale(), yPositionText - scale(), localizedText, a * scale(), new Vector4f(161 / 255f, 161 / 255f, 161 / 255f, 1));
    renderer.getFontRenderer().drawString(font, xPosition + centering, yPositionText, localizedText, a * scale(), new Vector4f(38 / 255f, 38 / 255f, 38 / 255f, 1));
    renderer.textures().getTexture("./textures/gui/icons/" + iconName + ".png").setLinearFiltering(false);
    renderer.getGuiRenderer().drawBoxWindowsSpaceWithSize(xPosition + getWidth() / 2 - 16 * scale(), yPosition + getHeight() / 2 - 26 * scale(), 32 * scale(), 32 * scale(), 0, 1, 1, 0, renderer.textures().getTexture("./textures/gui/icons/" + iconName + ".png"), false, true, null);
}
Also used : Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Vector4f(org.joml.Vector4f) Font(io.xol.chunkstories.api.rendering.text.FontRenderer.Font)

Example 9 with Vector4f

use of org.joml.Vector4f in project chunkstories by Hugobros3.

the class KeyBindSelectionOverlay method render.

@Override
public void render(RenderingInterface renderer) {
    this.parentLayer.render(renderer);
    renderer.getGuiRenderer().drawBoxWindowsSpace(0, 0, renderer.getWindow().getWidth(), renderer.getWindow().getHeight(), 0, 0, 0, 0, null, false, true, new Vector4f(0.0f, 0.0f, 0.0f, 0.5f));
    String plz = "Please press a key";
    Font font = renderer.getFontRenderer().getFont("LiberationSans-Regular", 11);
    renderer.getFontRenderer().drawStringWithShadow(font, renderer.getWindow().getWidth() / 2 - font.getWidth(plz) * 1.5f, renderer.getWindow().getHeight() / 2, plz, 3, 3, new Vector4f(1));
}
Also used : Vector4f(org.joml.Vector4f) Font(io.xol.chunkstories.api.rendering.text.FontRenderer.Font)

Example 10 with Vector4f

use of org.joml.Vector4f in project chunkstories by Hugobros3.

the class OptionsScreen method render.

@Override
public void render(RenderingInterface renderer) {
    // this.renderer = renderer;
    parentLayer.getRootLayer().render(renderer);
    int optionsPanelSize = (160 * 2 + 16 + 32) * this.getGuiScale();
    // Shades the BG
    renderer.getGuiRenderer().drawBoxWindowsSpace(0, 0, renderer.getWindow().getWidth(), renderer.getWindow().getHeight(), 0, 0, 0, 0, null, false, true, new Vector4f(0.0f, 0.0f, 0.0f, 0.5f));
    renderer.getGuiRenderer().drawBoxWindowsSpace(renderer.getWindow().getWidth() / 2.0f - optionsPanelSize / 2, 0, renderer.getWindow().getWidth() / 2 + optionsPanelSize / 2, renderer.getWindow().getHeight(), 0, 0, 0, 0, null, false, true, new Vector4f(0.0f, 0.0f, 0.0f, 0.5f));
    // Render the tabs buttons
    float dekal = 16 * this.getGuiScale();
    for (TabButton b : tabsButtons) {
        b.setPosition(renderer.getWindow().getWidth() / 2 - optionsPanelSize / 2 + dekal, renderer.getWindow().getHeight() - 64 * this.getGuiScale());
        b.render(renderer);
        dekal += b.getWidth() / 2f;
        dekal += b.getWidth() / 2f;
    }
    // Display the current tab
    ConfigTab currentConfigTab = configTabs.get(selectedConfigTab);
    int a = 0, b = 0;
    int startPosX = renderer.getWindow().getWidth() / 2 - optionsPanelSize / 2 + 0 + 16 * this.getGuiScale();
    int startPosY = renderer.getWindow().getHeight() - (64 + 32) * this.getGuiScale();
    Mouse mouse = gameWindow.getInputsManager().getMouse();
    for (ConfigButton c : currentConfigTab.configButtons) {
        c.setPosition(startPosX + b * (160 + 16) * this.getGuiScale(), startPosY - (float) Math.floor(a / 2) * 32 * this.getGuiScale());
        c.updateText();
        c.render(renderer);
        // Scale buttons work a bit hackyshly
        if (c instanceof ConfigButtonScale && c.isMouseOver() && mouse.getMainButton().isPressed()) {
            ConfigButtonScale cs = (ConfigButtonScale) c;
            cs.onClick((float) mouse.getCursorX(), (float) mouse.getCursorY(), 0);
            cs.apply();
        }
        a++;
        b = a % 2;
    }
    renderer.getFontRenderer().drawStringWithShadow(renderer.getFontRenderer().getFont("LiberationSans-Regular", 11), renderer.getWindow().getWidth() / 2 - optionsPanelSize / 2 + 16 * this.getGuiScale(), renderer.getWindow().getHeight() - 32 * this.getGuiScale(), Client.getInstance().getContent().localization().getLocalizedString("options.title"), 3, 3, new Vector4f(1));
    exitButton.setPosition(8, 8);
    exitButton.render(renderer);
}
Also used : Vector4f(org.joml.Vector4f) Mouse(io.xol.chunkstories.api.input.Mouse)

Aggregations

Vector4f (org.joml.Vector4f)68 Vector3f (org.joml.Vector3f)13 Font (io.xol.chunkstories.api.rendering.text.FontRenderer.Font)12 Texture2D (io.xol.chunkstories.api.rendering.textures.Texture2D)6 Vector3d (org.joml.Vector3d)6 Shader (io.xol.chunkstories.api.rendering.shader.Shader)5 CellData (io.xol.chunkstories.api.world.cell.CellData)5 Vector2f (org.joml.Vector2f)5 Mouse (io.xol.chunkstories.api.input.Mouse)4 Texture2DGL (io.xol.chunkstories.renderer.opengl.texture.Texture2DGL)4 ByteBuffer (java.nio.ByteBuffer)4 Matrix4f (org.joml.Matrix4f)4 ItemPile (io.xol.chunkstories.api.item.inventory.ItemPile)3 STBEasyFont.stb_easy_font_print (org.lwjgl.stb.STBEasyFont.stb_easy_font_print)3 Location (io.xol.chunkstories.api.Location)2 Entity (io.xol.chunkstories.api.entity.Entity)2 EntityLiving (io.xol.chunkstories.api.entity.EntityLiving)2 GuiRenderer (io.xol.chunkstories.api.gui.GuiRenderer)2 CollisionBox (io.xol.chunkstories.api.physics.CollisionBox)2 Voxel (io.xol.chunkstories.api.voxel.Voxel)2