Search in sources :

Example 26 with TranslatableText

use of net.minecraft.text.TranslatableText 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 27 with TranslatableText

use of net.minecraft.text.TranslatableText 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 28 with TranslatableText

use of net.minecraft.text.TranslatableText 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)

Example 29 with TranslatableText

use of net.minecraft.text.TranslatableText in project SpeedRunIGT by RedLime.

the class TimerCustomizeScreen method render.

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    saveButton.active = changed;
    this.renderBackground(matrices);
    drawer.draw();
    this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215);
    if (!hide) {
        if (!igtButton.active || !rtaButton.active) {
            if (drawer.isLocked()) {
                drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.option.timer_position.description.lock"), this.width / 2, this.height / 2 - 80, 16777215);
            } else {
                drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.option.timer_position.description"), this.width / 2, this.height / 2 - 80, 16777215);
                drawCenteredText(matrices, this.textRenderer, new TranslatableText("speedrunigt.option.timer_position.description.move"), this.width / 2, this.height / 2 - 69, 16777215);
            }
        }
        if (!fontButton.active && client != null) {
            int c = fontPage * 3;
            FontManagerAccessor fontManager = (FontManagerAccessor) ((MinecraftClientAccessor) client).getFontManager();
            for (int i = 0; i < fontSelectButtons.size(); i++) {
                if (c + i < availableFonts.size()) {
                    Identifier fontIdentifier = availableFonts.get(c + i);
                    LiteralText text = new LiteralText(fontIdentifier.getPath());
                    if (client != null && fontManager.getFontStorages().containsKey(fontIdentifier)) {
                        text.setStyle(text.getStyle().withFont(fontIdentifier));
                    } else {
                        text.append(new LiteralText(" (Unavailable)")).formatted(Formatting.RED);
                    }
                    if (fontIdentifier.toString().equals(drawer.getTimerFont().toString())) {
                        text.append(" [Selected]").formatted(Formatting.ITALIC);
                    }
                    drawCenteredText(matrices, this.textRenderer, text, this.width / 2 - 30, this.height / 2 - 11 + (i * 22), 16777215);
                }
            }
        }
    }
    super.render(matrices, mouseX, mouseY, delta);
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Identifier(net.minecraft.util.Identifier) FontManagerAccessor(com.redlimerl.speedrunigt.mixins.access.FontManagerAccessor) LiteralText(net.minecraft.text.LiteralText)

Example 30 with TranslatableText

use of net.minecraft.text.TranslatableText in project Blockus by Brandcraf06.

the class SpeedBlockItem method appendTooltip.

@Override
@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext context) {
    super.appendTooltip(stack, world, tooltip, context);
    this.getBlock().appendTooltip(stack, world, tooltip, context);
    tooltip.add((new TranslatableText(Blockus.MOD_ID + ".blockitem.givespeed")).formatted(Formatting.DARK_PURPLE));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Environment(net.fabricmc.api.Environment)

Aggregations

TranslatableText (net.minecraft.text.TranslatableText)161 LiteralText (net.minecraft.text.LiteralText)30 Text (net.minecraft.text.Text)19 ItemStack (net.minecraft.item.ItemStack)16 ArrayList (java.util.ArrayList)15 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)14 List (java.util.List)12 MinecraftClient (net.minecraft.client.MinecraftClient)12 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)12 SPEInterface (eu.pb4.armorstandeditor.helpers.SPEInterface)9 LivingEntity (net.minecraft.entity.LivingEntity)9 PlayerEntity (net.minecraft.entity.player.PlayerEntity)8 ListTag (net.minecraft.nbt.ListTag)8 Formatting (net.minecraft.util.Formatting)8 BlockPos (net.minecraft.util.math.BlockPos)8 Environment (net.fabricmc.api.Environment)7 AbstractButtonWidget (net.minecraft.client.gui.widget.AbstractButtonWidget)7 Entity (net.minecraft.entity.Entity)7 Collection (java.util.Collection)6 ArmorStandPreset (eu.pb4.armorstandeditor.config.ArmorStandPreset)5