Search in sources :

Example 1 with CheckboxWidget

use of net.minecraft.client.gui.widget.CheckboxWidget in project databreaker by SuperCoder7979.

the class MixinBackupPromptScreen method init.

/**
 * @reason Stop users from loading old worlds. They're better off this way.
 * @author SuperCoder79
 */
@Overwrite
public void init() {
    if (!dontStop) {
        super.init();
        this.wrappedText = MultilineText.create(this.textRenderer, this.subtitle, this.width - 50);
        int var10000 = this.wrappedText.count() + 1;
        this.textRenderer.getClass();
        int i = var10000 * 9;
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + 80, 124 + i, 150, 20, ScreenTexts.CANCEL, (buttonWidget) -> {
            this.client.setScreen(this.parent);
        }));
    } else {
        this.wrappedText = MultilineText.create(this.textRenderer, this.subtitle, this.width - 50);
        int var10000 = this.wrappedText.count() + 1;
        this.textRenderer.getClass();
        int i = var10000 * 9;
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, 100 + i, 150, 20, new TranslatableText("selectWorld.backupJoinConfirmButton"), (buttonWidget) -> {
            this.callback.proceed(true, this.eraseCacheCheckbox.isChecked());
        }));
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + 160, 100 + i, 150, 20, new TranslatableText("selectWorld.backupJoinSkipButton"), (buttonWidget) -> {
            this.callback.proceed(false, this.eraseCacheCheckbox.isChecked());
        }));
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + 80, 124 + i, 150, 20, ScreenTexts.CANCEL, (buttonWidget) -> {
            this.client.setScreen(this.parent);
        }));
        this.eraseCacheCheckbox = new CheckboxWidget(this.width / 2 - 155 + 80, 76 + i, 150, 20, new TranslatableText("selectWorld.backupEraseCache"), false);
        if (this.showEraseCacheCheckbox) {
            this.addDrawableChild(this.eraseCacheCheckbox);
        }
    }
}
Also used : LiteralText(net.minecraft.text.LiteralText) ScreenTexts(net.minecraft.client.gui.screen.ScreenTexts) Inject(org.spongepowered.asm.mixin.injection.Inject) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) BackupPromptScreen(net.minecraft.client.gui.screen.BackupPromptScreen) CheckboxWidget(net.minecraft.client.gui.widget.CheckboxWidget) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) org.spongepowered.asm.mixin(org.spongepowered.asm.mixin) MultilineText(net.minecraft.client.font.MultilineText) Text(net.minecraft.text.Text) At(org.spongepowered.asm.mixin.injection.At) TranslatableText(net.minecraft.text.TranslatableText) CheckboxWidget(net.minecraft.client.gui.widget.CheckboxWidget) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

Example 2 with CheckboxWidget

use of net.minecraft.client.gui.widget.CheckboxWidget in project isometric-renders by gliscowo.

the class RenderScreen method init.

@Override
protected void init() {
    super.init();
    viewportBeginX = (int) ((this.width - this.height) * 0.5);
    viewportEndX = (int) (this.width - (this.width - this.height) * 0.5) + 1;
    ((ParticleManagerAccessor) client.particleManager).getParticles().clear();
    IsometricRenderHelper.allowParticles = false;
    buttons.clear();
    buildGuiElements();
    TextFieldWidget colorField = new TextFieldWidget(client.textRenderer, viewportEndX + 10, 38, 50, 20, Text.of("#0000ff"));
    colorField.setTextPredicate(s -> s.matches("^#([A-Fa-f0-9]{0,6})$"));
    colorField.setText("#" + String.format("%02X", backgroundColor >> 16) + String.format("%02X", backgroundColor >> 8 & 0xFF) + String.format("%02X", backgroundColor & 0xFF));
    colorField.setChangedListener(s -> {
        if (s.substring(1).length() < 6)
            return;
        backgroundColor = Integer.parseInt(s.substring(1), 16);
    });
    CheckboxWidget playAnimationsCheckbox = new CallbackCheckboxWidget(viewportEndX + 10, 68, Text.of("Animations"), playAnimations, aBoolean -> {
        playAnimations = aBoolean;
    });
    CheckboxWidget playParticlesCheckbox = new CallbackCheckboxWidget(viewportEndX + 10, 93, Text.of("Particles (requires animations)"), tickParticles, aBoolean -> {
        tickParticles = aBoolean;
    });
    CheckboxWidget doHiResCheckbox = new CallbackCheckboxWidget(viewportEndX + 10, 183, Text.of("Use External Renderer"), useExternalRenderer, aBoolean -> {
        useExternalRenderer = aBoolean;
    });
    CheckboxWidget allowMultipleRendersCheckbox = new CallbackCheckboxWidget(viewportEndX + 10, 208, Text.of("Allow Multiple Export Jobs"), allowMultipleNonThreadedJobs, aBoolean -> {
        allowMultipleNonThreadedJobs = aBoolean;
    });
    CheckboxWidget dumpIntoRootCheckbox = new CallbackCheckboxWidget(viewportEndX + 10, 233, Text.of("Dump into root"), dumpIntoRoot, aBoolean -> {
        dumpIntoRoot = aBoolean;
    });
    ButtonWidget clearQueueButton = new ButtonWidget(viewportEndX + 80, 260, 75, 20, Text.of("Clear Queue"), button -> {
        ImageExporter.clearQueue();
    });
    exportButton = new ButtonWidget(viewportEndX + 10, 260, 65, 20, Text.of("Export"), button -> {
        if ((ImageExporter.getJobCount() < 1 || allowMultipleNonThreadedJobs)) {
            captureScheduled = true;
        }
    });
    TextFieldWidget resolutionField = new TextFieldWidget(client.textRenderer, viewportEndX + 10, 153, 50, 20, Text.of("2048"));
    resolutionField.setEditableColor(0x00FF00);
    resolutionField.setText(String.valueOf(exportResolution));
    resolutionField.setTextPredicate(s -> s.matches("[0-9]{0,5}"));
    resolutionField.setChangedListener(s -> {
        if (s.length() < 1)
            return;
        int resolution = Integer.parseInt(s);
        if (((resolution != 0) && ((resolution & (resolution - 1)) != 0) || resolution < 16 || resolution > 16384) && !allowInsaneResolutions) {
            resolutionField.setEditableColor(0xFF0000);
            exportButton.active = false;
        } else {
            resolutionField.setEditableColor(0x00FF00);
            exportResolution = resolution;
            exportButton.active = true;
        }
    });
    addButton(colorField);
    addButton(playAnimationsCheckbox);
    addButton(doHiResCheckbox);
    addButton(allowMultipleRendersCheckbox);
    addButton(playParticlesCheckbox);
    addButton(dumpIntoRootCheckbox);
    addButton(resolutionField);
    addButton(exportButton);
    addButton(clearQueueButton);
}
Also used : RuntimeConfig(com.glisco.isometricrenders.client.RuntimeConfig) MatrixStack(net.minecraft.client.util.math.MatrixStack) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) GL_DEPTH_BUFFER_BIT(org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT) SliderWidgetInvoker(com.glisco.isometricrenders.mixin.SliderWidgetInvoker) ImageExporter(com.glisco.isometricrenders.client.ImageExporter) CheckboxWidget(net.minecraft.client.gui.widget.CheckboxWidget) GLFW(org.lwjgl.glfw.GLFW) Consumer(java.util.function.Consumer) Screen(net.minecraft.client.gui.screen.Screen) NativeImage(net.minecraft.client.texture.NativeImage) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) MinecraftClient(net.minecraft.client.MinecraftClient) Text(net.minecraft.text.Text) ParticleManagerAccessor(com.glisco.isometricrenders.mixin.ParticleManagerAccessor) SliderWidget(net.minecraft.client.gui.widget.SliderWidget) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) CheckboxWidget(net.minecraft.client.gui.widget.CheckboxWidget) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

Aggregations

Screen (net.minecraft.client.gui.screen.Screen)2 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)2 CheckboxWidget (net.minecraft.client.gui.widget.CheckboxWidget)2 Text (net.minecraft.text.Text)2 ImageExporter (com.glisco.isometricrenders.client.ImageExporter)1 RuntimeConfig (com.glisco.isometricrenders.client.RuntimeConfig)1 ParticleManagerAccessor (com.glisco.isometricrenders.mixin.ParticleManagerAccessor)1 SliderWidgetInvoker (com.glisco.isometricrenders.mixin.SliderWidgetInvoker)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 MultilineText (net.minecraft.client.font.MultilineText)1 BackupPromptScreen (net.minecraft.client.gui.screen.BackupPromptScreen)1 ScreenTexts (net.minecraft.client.gui.screen.ScreenTexts)1 SliderWidget (net.minecraft.client.gui.widget.SliderWidget)1 TextFieldWidget (net.minecraft.client.gui.widget.TextFieldWidget)1 NativeImage (net.minecraft.client.texture.NativeImage)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1 LiteralText (net.minecraft.text.LiteralText)1