Search in sources :

Example 1 with WorldGeneratorDefinition

use of io.xol.chunkstories.api.content.Content.WorldGenerators.WorldGeneratorDefinition in project chunkstories by Hugobros3.

the class LevelCreation method render.

@Override
public void render(RenderingInterface renderer) {
    if (parentLayer != null)
        this.parentLayer.render(renderer);
    int scale = gameWindow.getGuiScale();
    renderer.getGuiRenderer().drawBox(-1.0f, -1.0f, 1.0f, 1.0f, 0, 0, 0, 0, null, true, false, new Vector4f(0.0f, 0.0f, 0.0f, 0.25f));
    // int frame_border_size = 64;
    // + frame_border_size;
    float positionStartX = xPosition;
    // + frame_border_size;
    float positionStartY = yPosition;
    // width -= frame_border_size * 2;
    // height -= frame_border_size * 2;
    float x = positionStartX + 20;
    // int y = 48;
    renderer.getGuiRenderer().drawCorneredBoxTiled(positionStartX, positionStartY, width, height, 8, renderer.textures().getTexture("./textures/gui/scalableButton.png"), 32, 2);
    renderer.getFontRenderer().drawStringWithShadow(renderer.getFontRenderer().getFont("LiberationSans-Regular", 12), x, positionStartY + height - 64, "Create a new World", 3, 3, new Vector4f(1));
    renderer.getFontRenderer().drawStringWithShadow(renderer.getFontRenderer().getFont("LiberationSans-Regular", 12), x, positionStartY + height - 64 - 32, "For use in singleplayer", 2, 2, width, new Vector4f(1));
    renderer.getFontRenderer().drawStringWithShadow(renderer.getFontRenderer().getFont("LiberationSans-Regular", 12), x, positionStartY + height - 64 - 96 - 4, "Level name", 2, 2, width, new Vector4f(1));
    int lvlnm_l = renderer.getFontRenderer().getFont("LiberationSans-Regular", 12).getWidth("Level name") * 2;
    levelName.setPosition(x + lvlnm_l + 20, positionStartY + height - 64 - 96);
    levelName.setWidth((width - (x + lvlnm_l + 20) - 20) / 2);
    levelName.render(renderer);
    String wg_string = "World generator to use";
    renderer.getFontRenderer().drawStringWithShadow(renderer.getFontRenderer().getFont("LiberationSans-Regular", 12), x, positionStartY + height - 64 - 148 - 4, wg_string, 2, 2, width, new Vector4f(1));
    int wg_sl = renderer.getFontRenderer().getFont("LiberationSans-Regular", 12).getWidth(wg_string) * 2;
    worldGenName.setPosition(x + wg_sl + 20, positionStartY + height - 64 - 148);
    worldGenName.setWidth((width - (x + wg_sl + 20) - 20) / 2);
    worldGenName.render(renderer);
    WorldGeneratorDefinition wg = Client.getInstance().getContent().generators().getWorldGeneratorUnsafe(worldGenName.getText());
    String wg_validity_string;
    if (wg == null) {
        wg_validity_string = "#FF0000'" + worldGenName.getText() + "' wasnt found in the list of loaded world generators.";
    } else {
        wg_validity_string = "#00FF00'" + worldGenName.getText() + "' is a valid world generator !";
    }
    String wg_list = "Available world generators: ";
    Iterator<WorldGeneratorDefinition> iwg = Client.getInstance().getContent().generators().all();
    while (iwg != null && iwg.hasNext()) {
        WorldGeneratorDefinition wgt = iwg.next();
        wg_list += wgt.getName();
        if (iwg.hasNext())
            wg_list += ", ";
    }
    renderer.getFontRenderer().drawStringWithShadow(renderer.getFontRenderer().getFont("LiberationSans-Regular", 12), x, positionStartY + height - 64 - 196 - 4, wg_validity_string, 2, 2, width, new Vector4f(1));
    renderer.getFontRenderer().drawStringWithShadow(renderer.getFontRenderer().getFont("LiberationSans-Regular", 12), x, positionStartY + height - 64 - 196 - 4 - 32, wg_list, 2, 2, width, new Vector4f(1));
    cancelOption.setPosition(positionStartX + 20 * scale, positionStartY + 20 * scale);
    cancelOption.render(renderer);
    createOption.setPosition(positionStartX + width - createOption.getWidth() - 20 * scale, positionStartY + 20 * scale);
    createOption.render(renderer);
}
Also used : WorldGeneratorDefinition(io.xol.chunkstories.api.content.Content.WorldGenerators.WorldGeneratorDefinition) Vector4f(org.joml.Vector4f)

Aggregations

WorldGeneratorDefinition (io.xol.chunkstories.api.content.Content.WorldGenerators.WorldGeneratorDefinition)1 Vector4f (org.joml.Vector4f)1