Search in sources :

Example 1 with Color

use of me.shedaniel.math.Color in project BlockMeter by ModProg.

the class ColorButton method init.

@Override
protected void init() {
    ModConfig config = BlockMeterClient.getConfigManager().getConfig();
    // Create Color Selector
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            final int colorIndex = i * 4 + j;
            this.addDrawableChild(new ColorButton(this.width / 2 - 44 + j * 22, this.height / 2 - 88 + i * 22, 20, 20, null, DyeColor.byId(colorIndex).getColorComponents(), config.colorIndex == colorIndex, false, button -> {
                ClientMeasureBox.setColorIndex(colorIndex);
                final ClientMeasureBox currentBox = BlockMeterClient.getInstance().getCurrentBox();
                if (currentBox != null)
                    currentBox.setColor(DyeColor.byId(colorIndex));
                MinecraftClient.getInstance().setScreen((Screen) null);
            }));
        }
    }
    this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 10, BUTTONWIDTH, 20, new TranslatableText("blockmeter.keepColor", new Object[] { new TranslatableText(config.incrementColor ? "options.off" : "options.on") }), button -> {
        config.incrementColor = !config.incrementColor;
        MinecraftClient.getInstance().setScreen((Screen) null);
        // Todo find a way to increment to a new Color if a box was created while
        // incrementColor was disabled
        BlockMeterClient.getConfigManager().save();
    }));
    this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 32, BUTTONWIDTH, 20, new TranslatableText("blockmeter.diagonal", new Object[] { new TranslatableText(config.innerDiagonal ? "options.on" : "options.off") }), button -> {
        System.err.println("IDK WHAT YOU ARE DOING");
        config.innerDiagonal = !config.innerDiagonal;
        MinecraftClient.getInstance().setScreen((Screen) null);
        BlockMeterClient.getConfigManager().save();
    }));
    this.addDrawableChild(new ButtonWidget(this.width / 2 - BUTTONWIDTH / 2, this.height / 2 + 54, BUTTONWIDTH, 20, new TranslatableText("blockmeter.showOthers", new Object[] { new TranslatableText(config.showOtherUsersBoxes ? "options.on" : "options.off") }), button -> {
        System.err.println("IDK WHAT YOU ARE DOING");
        config.showOtherUsersBoxes = !config.showOtherUsersBoxes;
        MinecraftClient.getInstance().setScreen((Screen) null);
        BlockMeterClient.getConfigManager().save();
    }));
}
Also used : LiteralText(net.minecraft.text.LiteralText) Tessellator(net.minecraft.client.render.Tessellator) Color(me.shedaniel.math.Color) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) GameRenderer(net.minecraft.client.render.GameRenderer) MatrixStack(net.minecraft.client.util.math.MatrixStack) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) ModConfig(win.baruna.blockmeter.ModConfig) NarratorManager(net.minecraft.client.util.NarratorManager) Screen(net.minecraft.client.gui.screen.Screen) DrawMode(net.minecraft.client.render.VertexFormat.DrawMode) DyeColor(net.minecraft.util.DyeColor) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) BufferBuilder(net.minecraft.client.render.BufferBuilder) MutableText(net.minecraft.text.MutableText) MinecraftClient(net.minecraft.client.MinecraftClient) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) TextRenderer(net.minecraft.client.font.TextRenderer) VertexFormats(net.minecraft.client.render.VertexFormats) TranslatableText(net.minecraft.text.TranslatableText) Screen(net.minecraft.client.gui.screen.Screen) ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) ModConfig(win.baruna.blockmeter.ModConfig)

Aggregations

RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 Color (me.shedaniel.math.Color)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 TextRenderer (net.minecraft.client.font.TextRenderer)1 Screen (net.minecraft.client.gui.screen.Screen)1 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)1 BufferBuilder (net.minecraft.client.render.BufferBuilder)1 GameRenderer (net.minecraft.client.render.GameRenderer)1 Tessellator (net.minecraft.client.render.Tessellator)1 DrawMode (net.minecraft.client.render.VertexFormat.DrawMode)1 VertexFormats (net.minecraft.client.render.VertexFormats)1 NarratorManager (net.minecraft.client.util.NarratorManager)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1 LiteralText (net.minecraft.text.LiteralText)1 MutableText (net.minecraft.text.MutableText)1 TranslatableText (net.minecraft.text.TranslatableText)1 DyeColor (net.minecraft.util.DyeColor)1 BlockMeterClient (win.baruna.blockmeter.BlockMeterClient)1 ModConfig (win.baruna.blockmeter.ModConfig)1 ClientMeasureBox (win.baruna.blockmeter.measurebox.ClientMeasureBox)1