Search in sources :

Example 11 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project Hypnotic-Client by Hypnotic-Development.

the class EditAltScreen method render.

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    this.renderBackground(matrices);
    usernameField.render(matrices, mouseX, mouseY, delta);
    passwordField.render(matrices, mouseX, mouseY, delta);
    RenderUtils.drawCenteredStringWithShadow(matrices, textRenderer, status, this.width / 2, this.height / 2 - 100, -1);
    if (usernameField.getText().isEmpty() && !usernameField.isFocused())
        RenderUtils.drawCenteredStringWithShadow(matrices, textRenderer, "Username", this.width / 2 - 70, this.height / 2 + 6, new Color(100, 100, 100).getRGB());
    if (passwordField.getText().isEmpty() && !passwordField.isFocused())
        RenderUtils.drawCenteredStringWithShadow(matrices, textRenderer, "Password", this.width / 2 - 70, this.height / 2 + 36, new Color(100, 100, 100).getRGB());
    ((ButtonWidget) this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, height / 2 + 60, 200, 20, new LiteralText("Confirm"), (button) -> {
        this.status = "Edited alt";
        alt.setEmail(usernameField.getText());
        alt.setPassword(passwordField.getText());
    }))).active = true;
    ((ButtonWidget) this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, height / 2 + 85, 200, 20, new LiteralText("Back"), (button) -> {
        MinecraftClient.getInstance().setScreen(previousScreen);
    }))).active = true;
    super.render(matrices, mouseX, mouseY, delta);
}
Also used : Color(java.awt.Color) LiteralText(net.minecraft.text.LiteralText) Screen(net.minecraft.client.gui.screen.Screen) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) MatrixStack(net.minecraft.client.util.math.MatrixStack) MinecraftClient(net.minecraft.client.MinecraftClient) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) RenderUtils(dev.hypnotic.utils.render.RenderUtils) Color(java.awt.Color) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) LiteralText(net.minecraft.text.LiteralText)

Example 12 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project Hypnotic-Client by Hypnotic-Development.

the class AddAltScreen method init.

@Override
protected void init() {
    usernameField = new TextFieldWidget(textRenderer, width / 2 - 100, height / 2, 200, 20, new LiteralText("Username"));
    passwordField = new TextFieldWidget(textRenderer, width / 2 - 100, height / 2 + 30, 200, 20, new LiteralText("Password"));
    this.addSelectableChild(usernameField);
    this.addSelectableChild(passwordField);
    ((ButtonWidget) this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, height / 2 + 60, 200, 20, new LiteralText("Login"), (button) -> {
        this.status = "Trying alt...";
        if (accountType == true) {
            PremiumAccount alt = new PremiumAccount(usernameField.getText(), passwordField.getText());
            Accounts.get().add(alt);
            AltsFile.INSTANCE.saveAlts();
            this.status = "Added alt " + ColorUtils.green + "\"" + alt.getUsername() + "\"";
        } else {
            AltsFile.INSTANCE.saveAlts();
        // this.status = "Added alt " + ColorUtils.green + "\"" + alt.getUsername() + "\"";
        }
    }))).active = true;
    ((ButtonWidget) this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, height / 2 + 85, 200, 20, new LiteralText("Back"), (button) -> {
        MinecraftClient.getInstance().setScreen(previousScreen);
    }))).active = true;
    ((ButtonWidget) this.addDrawableChild(new ButtonWidget(this.width / 2 - 350, height / 2 + 85, 50, 20, new LiteralText("Add Microsoft"), (button) -> {
        MicrosoftLogin.getRefreshToken(refreshToken -> {
            if (refreshToken != null) {
                MicrosoftAccount account = new MicrosoftAccount(refreshToken);
                account.login();
                addAccount(account);
            }
        });
        accountType = false;
    }))).active = true;
    status = "Idle...";
    super.init();
}
Also used : Color(java.awt.Color) PremiumAccount(dev.hypnotic.ui.altmanager.account.types.PremiumAccount) LiteralText(net.minecraft.text.LiteralText) ColorUtils(dev.hypnotic.utils.ColorUtils) MatrixStack(net.minecraft.client.util.math.MatrixStack) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) RenderUtils(dev.hypnotic.utils.render.RenderUtils) Executors(java.util.concurrent.Executors) Account(dev.hypnotic.ui.altmanager.account.Account) MicrosoftAccount(dev.hypnotic.ui.altmanager.account.types.MicrosoftAccount) Screen(net.minecraft.client.gui.screen.Screen) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) MicrosoftLogin(dev.hypnotic.ui.altmanager.account.MicrosoftLogin) MinecraftClient(net.minecraft.client.MinecraftClient) Accounts(dev.hypnotic.ui.altmanager.account.Accounts) MicrosoftAccount(dev.hypnotic.ui.altmanager.account.types.MicrosoftAccount) PremiumAccount(dev.hypnotic.ui.altmanager.account.types.PremiumAccount) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) LiteralText(net.minecraft.text.LiteralText)

Example 13 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project Hypnotic-Client by Hypnotic-Development.

the class AltManagerScreen method render.

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    this.renderBackground(matrices);
    fill(matrices, 100, 70, width - 100, height - 70, new Color(0, 0, 0, 100).getRGB());
    drawStringWithShadow(matrices, textRenderer, MinecraftClient.getInstance().getSession().getProfile().getName(), 20, 20, -1);
    RenderUtils.drawCenteredStringWithShadow(matrices, textRenderer, status, width / 2, 20, -1);
    ((ButtonWidget) this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, height - 50, 200, 20, new LiteralText("Add alt"), (button) -> {
        MinecraftClient.getInstance().setScreen(new AddAltScreen(this));
    }))).active = true;
    int offset = 0;
    RenderSystem.enableScissor(10, 10, 1000, 1000);
    // GL11.glScissor(10, 10, 100000, 10000);
    for (Account<?> alt : Accounts.get()) {
        ((ButtonWidget) this.addDrawableChild(new ButtonWidget(100, height - 50 + offset, 200, 20, new LiteralText("Login"), (button) -> {
            MinecraftClient.getInstance().setScreen(new AddAltScreen(this));
        }))).active = true;
        drawStringWithShadow(matrices, textRenderer, alt.getUsername(), 100 + 5, offset, -1);
        drawStringWithShadow(matrices, textRenderer, alt.getType().name(), 100 + 5, offset + 20, -1);
        offset += 50;
    }
    RenderSystem.disableScissor();
    super.render(matrices, mouseX, mouseY, delta);
}
Also used : Color(java.awt.Color) LiteralText(net.minecraft.text.LiteralText) Screen(net.minecraft.client.gui.screen.Screen) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) MatrixStack(net.minecraft.client.util.math.MatrixStack) MinecraftClient(net.minecraft.client.MinecraftClient) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) Hypnotic(dev.hypnotic.Hypnotic) RenderUtils(dev.hypnotic.utils.render.RenderUtils) File(java.io.File) Account(dev.hypnotic.ui.altmanager.account.Account) Accounts(dev.hypnotic.ui.altmanager.account.Accounts) Color(java.awt.Color) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) LiteralText(net.minecraft.text.LiteralText)

Example 14 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project AurorasDecorations by LambdAurora.

the class SignPostEditScreen method init.

@Override
protected void init() {
    this.client.keyboard.setRepeatEvents(true);
    this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 4 + 120, 200, 20, ScreenTexts.DONE, button -> this.finishEditing()));
    this.selectionManager = new SelectionManager(() -> this.text[this.currentRow], text -> this.text[this.currentRow] = text, SelectionManager.makeClipboardGetter(this.client), SelectionManager.makeClipboardSetter(this.client), text -> this.client.textRenderer.getWidth(text) <= 90);
}
Also used : OrderedText(net.minecraft.text.OrderedText) SignPostBlockEntity(dev.lambdaurora.aurorasdeco.block.entity.SignPostBlockEntity) AurorasDecoPackets(dev.lambdaurora.aurorasdeco.registry.AurorasDecoPackets) GlStateManager(com.mojang.blaze3d.platform.GlStateManager) ColorUtil(dev.lambdaurora.aurorasdeco.util.ColorUtil) ClientPlayNetworking(net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking) ScreenTexts(net.minecraft.client.gui.screen.ScreenTexts) net.minecraft.client.render(net.minecraft.client.render) Environment(net.fabricmc.api.Environment) MatrixStack(net.minecraft.client.util.math.MatrixStack) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) GLFW(org.lwjgl.glfw.GLFW) ModelTransformation(net.minecraft.client.render.model.json.ModelTransformation) ItemStack(net.minecraft.item.ItemStack) Style(net.minecraft.text.Style) Screen(net.minecraft.client.gui.screen.Screen) SelectionManager(net.minecraft.client.util.SelectionManager) MathHelper(net.minecraft.util.math.MathHelper) Vec3f(net.minecraft.util.math.Vec3f) SignPostBlockEntityRenderer(dev.lambdaurora.aurorasdeco.client.renderer.SignPostBlockEntityRenderer) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) EnvType(net.fabricmc.api.EnvType) PacketByteBufs(net.fabricmc.fabric.api.networking.v1.PacketByteBufs) SelectionManager(net.minecraft.client.util.SelectionManager) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

Example 15 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project LittleMaidReBirth-Fabric by SistrScarlet.

the class LittleMaidScreen method init.

@Override
protected void init() {
    super.init();
    if (openAt == null) {
        client.openScreen(null);
        return;
    }
    int left = (int) ((this.width - backgroundWidth) / 2F) - 5;
    int top = (int) ((this.height - backgroundHeight) / 2F);
    int size = 20;
    int layer = -1;
    this.addButton(new ButtonWidget(left - size, top + size * ++layer, size, size, new LiteralText(""), button -> OpenIFFScreenPacket.sendC2SPacket(openAt)) {

        @Override
        public void renderButton(MatrixStack matrices, int p_renderButton_1_, int p_renderButton_2_, float p_renderButton_3_) {
            super.renderButton(matrices, p_renderButton_1_, p_renderButton_2_, p_renderButton_3_);
            itemRenderer.renderGuiItemIcon(BOOK, this.x - 8 + this.width / 2, this.y - 8 + this.height / 2);
        }
    });
    this.addButton(new ButtonWidget(left - size, top + size * ++layer, size, size, new LiteralText(""), button -> {
        openAt.setConfigHolder(LMConfigManager.INSTANCE.getAnyConfig());
        SyncSoundConfigPacket.sendC2SPacket(openAt, openAt.getConfigHolder().getName());
    }, (button, matrices, x, y) -> {
        String text = openAt.getConfigHolder().getName();
        float renderX = Math.max(0, x - textRenderer.getWidth(text) / 2F);
        textRenderer.drawWithShadow(matrices, text, renderX, y - textRenderer.fontHeight / 2F, 0xFFFFFF);
    }) {

        @Override
        public void renderButton(MatrixStack matrices, int x, int y, float delta) {
            super.renderButton(matrices, x, y, delta);
            itemRenderer.renderGuiItemIcon(NOTE, this.x - 8 + this.width / 2, this.y - 8 + this.height / 2);
        }
    });
    this.addButton(new ButtonWidget(left - size, top + size * ++layer, size, size, new LiteralText(""), button -> client.openScreen(new ModelSelectScreen(title, openAt.world, openAt))) {

        @Override
        public void renderButton(MatrixStack matrices, int p_renderButton_1_, int p_renderButton_2_, float p_renderButton_3_) {
            super.renderButton(matrices, p_renderButton_1_, p_renderButton_2_, p_renderButton_3_);
            itemRenderer.renderGuiItemIcon(ARMOR, this.x - 8 + this.width / 2, this.y - 8 + this.height / 2);
        }
    });
    this.addButton(new ButtonWidget(left - size, top + size * ++layer, size, size, new LiteralText(""), button -> {
        openAt.setMovingState(openAt.getMovingState() == Tameable.MovingState.FREEDOM ? Tameable.MovingState.WAIT : Tameable.MovingState.FREEDOM);
        stateText = getStateText();
    }) {

        @Override
        public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
            super.renderButton(matrices, mouseX, mouseY, delta);
            itemRenderer.renderGuiItemIcon(FEATHER, this.x - 8 + this.width / 2, this.y - 8 + this.height / 2);
        }
    });
    stateText = getStateText();
}
Also used : LiteralText(net.minecraft.text.LiteralText) InventoryScreen(net.minecraft.client.gui.screen.ingame.InventoryScreen) Environment(net.fabricmc.api.Environment) TranslatableText(net.minecraft.text.TranslatableText) OpenIFFScreenPacket(net.sistr.littlemaidrebirth.network.OpenIFFScreenPacket) ItemStack(net.minecraft.item.ItemStack) MutableText(net.minecraft.text.MutableText) EnvType(net.fabricmc.api.EnvType) LMConfigManager(net.sistr.lmml.resource.manager.LMConfigManager) SyncSoundConfigPacket(net.sistr.littlemaidrebirth.network.SyncSoundConfigPacket) Tameable(net.sistr.littlemaidrebirth.entity.Tameable) LittleMaidScreenHandler(net.sistr.littlemaidrebirth.entity.LittleMaidScreenHandler) PlayerInventory(net.minecraft.entity.player.PlayerInventory) LittleMaidEntity(net.sistr.littlemaidrebirth.entity.LittleMaidEntity) ModelSelectScreen(net.sistr.lmml.client.ModelSelectScreen) MatrixStack(net.minecraft.client.util.math.MatrixStack) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) Items(net.minecraft.item.Items) LittleMaidReBirthMod(net.sistr.littlemaidrebirth.LittleMaidReBirthMod) MathHelper(net.minecraft.util.math.MathHelper) SyncMovingStatePacket(net.sistr.littlemaidrebirth.network.SyncMovingStatePacket) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) Identifier(net.minecraft.util.Identifier) Text(net.minecraft.text.Text) HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) ModelSelectScreen(net.sistr.lmml.client.ModelSelectScreen) MatrixStack(net.minecraft.client.util.math.MatrixStack) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) LiteralText(net.minecraft.text.LiteralText)

Aggregations

ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)83 Screen (net.minecraft.client.gui.screen.Screen)62 TranslatableText (net.minecraft.text.TranslatableText)49 MatrixStack (net.minecraft.client.util.math.MatrixStack)48 LiteralText (net.minecraft.text.LiteralText)41 MinecraftClient (net.minecraft.client.MinecraftClient)35 TextFieldWidget (net.minecraft.client.gui.widget.TextFieldWidget)32 Text (net.minecraft.text.Text)21 EnvType (net.fabricmc.api.EnvType)19 Environment (net.fabricmc.api.Environment)19 Inject (org.spongepowered.asm.mixin.injection.Inject)19 ScreenTexts (net.minecraft.client.gui.screen.ScreenTexts)18 Wrapper (me.dustin.jex.helper.misc.Wrapper)17 ConfirmScreen (net.minecraft.client.gui.screen.ConfirmScreen)15 AbstractViaConfigScreen (com.viaversion.fabric.common.config.AbstractViaConfigScreen)14 ProtocolUtils (com.viaversion.fabric.common.util.ProtocolUtils)14 CompletableFuture (java.util.concurrent.CompletableFuture)14 Identifier (net.minecraft.util.Identifier)14 Mixin (org.spongepowered.asm.mixin.Mixin)14 At (org.spongepowered.asm.mixin.injection.At)14