Search in sources :

Example 1 with SliderWidget

use of net.minecraft.client.gui.widget.SliderWidget in project SpeedRunIGT by RedLime.

the class TimerCustomizeScreen method initIGTButtons.

public void initIGTButtons() {
    igtOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 - 16, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_red", "IGT").append(" : ").append(String.valueOf(ColorMixer.getRed(drawer.getIGTColor()))), ColorMixer.getRed(drawer.getIGTColor()) / 255.0f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_red", "IGT").append(" : ").append(String.valueOf(ColorMixer.getRed(drawer.getIGTColor()))));
        }

        @Override
        protected void applyValue() {
            int color = drawer.getIGTColor();
            drawer.setIGTColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), (int) (this.value * 255), ColorMixer.getGreen(color), ColorMixer.getBlue(color)));
            changed = true;
        }
    }));
    igtOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 + 6, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_green", "IGT").append(" : ").append(String.valueOf(ColorMixer.getGreen(drawer.getIGTColor()))), ColorMixer.getGreen(drawer.getIGTColor()) / 255.0f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_green", "IGT").append(" : ").append(String.valueOf(ColorMixer.getGreen(drawer.getIGTColor()))));
        }

        @Override
        protected void applyValue() {
            int color = drawer.getIGTColor();
            drawer.setIGTColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), ColorMixer.getRed(color), (int) (this.value * 255), ColorMixer.getBlue(color)));
            changed = true;
        }
    }));
    igtOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 + 28, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_blue", "IGT").append(" : ").append(String.valueOf(ColorMixer.getBlue(drawer.getIGTColor()))), ColorMixer.getBlue(drawer.getIGTColor()) / 255.0f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_blue", "IGT").append(" : ").append(String.valueOf(ColorMixer.getBlue(drawer.getIGTColor()))));
        }

        @Override
        protected void applyValue() {
            int color = drawer.getIGTColor();
            drawer.setIGTColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), ColorMixer.getRed(color), ColorMixer.getGreen(color), (int) (this.value * 255)));
            changed = true;
        }
    }));
    igtOptions.add(addButton(new SliderWidget(width / 2 + 6, height / 2 - 16, 120, 20, new TranslatableText("speedrunigt.option.timer_position.scale", "IGT").append(" : ").append(((int) (drawer.getIGTScale() * 100)) + "%"), drawer.getIGTScale() / 3f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.scale", "IGT").append(" : ").append(((int) (drawer.getIGTScale() * 100)) + "%"));
        }

        @Override
        protected void applyValue() {
            drawer.setIGTScale(Math.round((float) this.value * 3f * 20f) / 20f);
            changed = true;
        }
    }));
    igtOptions.add(addButton(new ButtonWidget(width / 2 + 6, height / 2 + 6, 120, 20, new TranslatableText("speedrunigt.option.timer_position.text_decorate", "IGT").append(" : ").append(new TranslatableText("speedrunigt.option.timer_position.text_decorate." + drawer.getIGTDecoration().name().toLowerCase(Locale.ROOT))), (ButtonWidget button) -> {
        int order = drawer.getIGTDecoration().ordinal();
        drawer.setIGTDecoration(TimerDecoration.values()[(++order) % TimerDecoration.values().length]);
        changed = true;
        button.setMessage(new TranslatableText("speedrunigt.option.timer_position.text_decorate", "IGT").append(" : ").append(new TranslatableText("speedrunigt.option.timer_position.text_decorate." + drawer.getIGTDecoration().name().toLowerCase(Locale.ROOT))));
    })));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) SliderWidget(net.minecraft.client.gui.widget.SliderWidget) AbstractButtonWidget(net.minecraft.client.gui.widget.AbstractButtonWidget) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

Example 2 with SliderWidget

use of net.minecraft.client.gui.widget.SliderWidget in project SpeedRunIGT by RedLime.

the class TimerCustomizeScreen method initBackgroundButtons.

public void initBackgroundButtons() {
    backgroundOptions.add(addButton(new SliderWidget(width / 2 - 80, height / 2 - 16, 160, 20, new TranslatableText("speedrunigt.option.timer_position.background_opacity").append(" : ").append((int) (drawer.getBGOpacity() * 100) + "%"), drawer.getBGOpacity()) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.background_opacity").append(" : ").append((int) (drawer.getBGOpacity() * 100) + "%"));
        }

        @Override
        protected void applyValue() {
            drawer.setBGOpacity((float) this.value);
            changed = true;
        }
    }));
    backgroundOptions.add(addButton(new SliderWidget(width / 2 - 80, height / 2 + 6, 160, 20, new TranslatableText("speedrunigt.option.timer_position.background_padding", "RTA").append(" : ").append(String.valueOf(drawer.getRTAPadding())), (drawer.getRTAPadding() - 1) / 24f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.background_padding", "RTA").append(" : ").append(String.valueOf(drawer.getRTAPadding())));
        }

        @Override
        protected void applyValue() {
            drawer.setRTAPadding((int) (this.value * 24) + 1);
            changed = true;
        }
    }));
    backgroundOptions.add(addButton(new SliderWidget(width / 2 - 80, height / 2 + 28, 160, 20, new TranslatableText("speedrunigt.option.timer_position.background_padding", "IGT").append(" : ").append(String.valueOf(drawer.getIGTPadding())), (drawer.getIGTPadding() - 1) / 24f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.background_padding", "IGT").append(" : ").append(String.valueOf(drawer.getIGTPadding())));
        }

        @Override
        protected void applyValue() {
            drawer.setIGTPadding((int) (this.value * 24) + 1);
            changed = true;
        }
    }));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) SliderWidget(net.minecraft.client.gui.widget.SliderWidget)

Example 3 with SliderWidget

use of net.minecraft.client.gui.widget.SliderWidget in project SpeedRunIGT by RedLime.

the class TimerCustomizeScreen method initRTAButtons.

public void initRTAButtons() {
    rtaOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 - 16, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_red", "RTA").append(" : ").append(String.valueOf(ColorMixer.getRed(drawer.getRTAColor()))), ColorMixer.getRed(drawer.getRTAColor()) / 255.0f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_red", "RTA").append(" : ").append(String.valueOf(ColorMixer.getRed(drawer.getRTAColor()))));
        }

        @Override
        protected void applyValue() {
            int color = drawer.getRTAColor();
            drawer.setRTAColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), (int) (this.value * 255), ColorMixer.getGreen(color), ColorMixer.getBlue(color)));
            changed = true;
        }
    }));
    rtaOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 + 6, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_green", "RTA").append(" : ").append(String.valueOf(ColorMixer.getGreen(drawer.getRTAColor()))), ColorMixer.getGreen(drawer.getRTAColor()) / 255.0f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_green", "RTA").append(" : ").append(String.valueOf(ColorMixer.getGreen(drawer.getRTAColor()))));
        }

        @Override
        protected void applyValue() {
            int color = drawer.getRTAColor();
            drawer.setRTAColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), ColorMixer.getRed(color), (int) (this.value * 255), ColorMixer.getBlue(color)));
            changed = true;
        }
    }));
    rtaOptions.add(addButton(new SliderWidget(width / 2 - 127, height / 2 + 28, 120, 20, new TranslatableText("speedrunigt.option.timer_position.color_blue", "RTA").append(" : ").append(String.valueOf(ColorMixer.getBlue(drawer.getRTAColor()))), ColorMixer.getBlue(drawer.getRTAColor()) / 255.0f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.color_blue", "RTA").append(" : ").append(String.valueOf(ColorMixer.getBlue(drawer.getRTAColor()))));
        }

        @Override
        protected void applyValue() {
            int color = drawer.getRTAColor();
            drawer.setRTAColor(ColorMixer.getArgb(ColorMixer.getAlpha(color), ColorMixer.getRed(color), ColorMixer.getGreen(color), (int) (this.value * 255)));
            changed = true;
        }
    }));
    rtaOptions.add(addButton(new SliderWidget(width / 2 + 6, height / 2 - 16, 120, 20, new TranslatableText("speedrunigt.option.timer_position.scale", "RTA").append(" : ").append(((int) (drawer.getRTAScale() * 100)) + "%"), drawer.getRTAScale() / 3f) {

        @Override
        protected void updateMessage() {
            this.setMessage(new TranslatableText("speedrunigt.option.timer_position.scale", "RTA").append(" : ").append(((int) (drawer.getRTAScale() * 100)) + "%"));
        }

        @Override
        protected void applyValue() {
            drawer.setRTAScale(Math.round((float) this.value * 3f * 20f) / 20f);
            changed = true;
        }
    }));
    rtaOptions.add(addButton(new ButtonWidget(width / 2 + 6, height / 2 + 6, 120, 20, new TranslatableText("speedrunigt.option.timer_position.text_decorate", "RTA").append(" : ").append(new TranslatableText("speedrunigt.option.timer_position.text_decorate." + drawer.getRTADecoration().name().toLowerCase(Locale.ROOT))), (ButtonWidget button) -> {
        int order = drawer.getRTADecoration().ordinal();
        drawer.setRTADecoration(TimerDecoration.values()[(++order) % TimerDecoration.values().length]);
        changed = true;
        button.setMessage(new TranslatableText("speedrunigt.option.timer_position.text_decorate", "RTA").append(" : ").append(new TranslatableText("speedrunigt.option.timer_position.text_decorate." + drawer.getRTADecoration().name().toLowerCase(Locale.ROOT))));
    })));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) SliderWidget(net.minecraft.client.gui.widget.SliderWidget) AbstractButtonWidget(net.minecraft.client.gui.widget.AbstractButtonWidget) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

Aggregations

SliderWidget (net.minecraft.client.gui.widget.SliderWidget)3 TranslatableText (net.minecraft.text.TranslatableText)3 AbstractButtonWidget (net.minecraft.client.gui.widget.AbstractButtonWidget)2 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)2