Search in sources :

Example 1 with Widget

use of net.minecraft.client.gui.widget.Widget in project iChunUtil by iChun.

the class EventHandlerClient method onGuiInit.

@SubscribeEvent
public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
    if ((iChunUtil.configClient.buttonOptionsShiftOpensMods || ObfHelper.isDevEnvironment()) && event.getGui() instanceof IngameMenuScreen) {
        for (Widget widget : event.getWidgetList()) {
            if (widget instanceof Button && widget.getMessage() instanceof TranslationTextComponent && ((TranslationTextComponent) widget.getMessage()).getKey().equals("menu.options")) {
                Button.IPressable oriPress = ((Button) widget).onPress;
                ((Button) widget).onPress = button -> {
                    if (ObfHelper.isDevEnvironment() && !Screen.hasControlDown()) {
                        if (Screen.hasShiftDown()) {
                            oriPress.onPress(button);
                        } else {
                            Minecraft.getInstance().displayGuiScreen(getConfigGui(Minecraft.getInstance(), Minecraft.getInstance().currentScreen));
                        }
                    } else if (iChunUtil.configClient.buttonOptionsShiftOpensMods) {
                        if (Screen.hasShiftDown()) {
                            Minecraft.getInstance().displayGuiScreen(new net.minecraftforge.fml.client.gui.screen.ModListScreen(Minecraft.getInstance().currentScreen));
                        } else {
                            oriPress.onPress(button);
                        }
                    }
                };
                break;
            }
        }
    }
}
Also used : Button(net.minecraft.client.gui.widget.button.Button) Widget(net.minecraft.client.gui.widget.Widget) IngameMenuScreen(net.minecraft.client.gui.screen.IngameMenuScreen) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with Widget

use of net.minecraft.client.gui.widget.Widget in project Random-Things by lumien231.

the class AdvancedRedstoneTorchScreen method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    RenderHelper.disableStandardItemLighting();
    this.font.drawString(I18n.format("gui.randomthings.advanced_redstone_torch.gs"), 8, 5, 0);
    this.font.drawString(I18n.format("gui.randomthings.advanced_redstone_torch.rs"), 13, 29, 0);
    String signalStrengthOffString = this.container.strengthGreen.get() + "";
    this.font.drawString(signalStrengthOffString, xSize / 2 - this.font.getStringWidth(signalStrengthOffString) / 2, 16, DyeColor.GREEN.getFireworkColor());
    String signalStrengthOnString = this.container.strengthRed.get() + "";
    this.font.drawString(signalStrengthOnString, xSize / 2 - this.font.getStringWidth(signalStrengthOnString) / 2, 40, DyeColor.RED.getFireworkColor());
    for (Widget widget : this.buttons) {
        if (widget.isHovered()) {
            widget.renderToolTip(mouseX - this.guiLeft, mouseY - this.guiTop);
            break;
        }
    }
    RenderHelper.enableGUIStandardItemLighting();
}
Also used : Widget(net.minecraft.client.gui.widget.Widget)

Example 3 with Widget

use of net.minecraft.client.gui.widget.Widget in project simple-voice-chat by henkelmax.

the class CreateGroupScreen method render.

@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) {
    RenderSystem.color4f(1F, 1F, 1F, 1F);
    minecraft.getTextureManager().bind(TEXTURE);
    blit(matrixStack, guiLeft, guiTop, 0, 0, xSize, ySize, 512, 512);
    playerList.drawGuiContainerBackgroundLayer(matrixStack, delta, mouseX, mouseY);
    playerList.drawGuiContainerForegroundLayer(matrixStack, mouseX, mouseY);
    for (Widget widget : buttons) {
        widget.render(matrixStack, mouseX, mouseY, delta);
    }
    font.draw(matrixStack, new TranslationTextComponent("message.voicechat.join_create_group"), guiLeft + 8, guiTop + 5, FONT_COLOR);
    font.draw(matrixStack, new TranslationTextComponent("message.voicechat.group_name"), guiLeft + 8, guiTop + 21, FONT_COLOR);
    font.draw(matrixStack, new TranslationTextComponent("message.voicechat.join_group"), guiLeft + 8, guiTop + 38, FONT_COLOR);
}
Also used : Widget(net.minecraft.client.gui.widget.Widget) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 4 with Widget

use of net.minecraft.client.gui.widget.Widget in project BoundingBoxOutlineReloaded by irtimaled.

the class MixinOptionsScreen method initGui.

@Inject(method = "init", at = @At("RETURN"))
private void initGui(CallbackInfo ci) {
    // shuffle middle buttons up by 12 px to make space
    int top = this.height / 6 + 42;
    int bottom = this.height / 6 + 168;
    for (Widget button : buttons) {
        if (button.y >= top && button.y < bottom)
            button.y -= 12;
    }
    SettingsScreenButton button = new SettingsScreenButton(this.width / 2 - 155, top + 84, 150, "BBOR", this);
    this.buttons.add(this.buttons.size() - 1, button);
    this.children.add(this.children.size() - 1, button);
}
Also used : SettingsScreenButton(com.irtimaled.bbor.client.gui.SettingsScreenButton) Widget(net.minecraft.client.gui.widget.Widget) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with Widget

use of net.minecraft.client.gui.widget.Widget in project Mekanism by mekanism.

the class GuiMekanism method renderLabels.

@Override
protected void renderLabels(@Nonnull MatrixStack matrix, int mouseX, int mouseY) {
    matrix.translate(0, 0, 300);
    RenderSystem.translatef(-leftPos, -topPos, 0);
    children().stream().filter(c -> c instanceof GuiElement).forEach(c -> ((GuiElement) c).onDrawBackground(matrix, mouseX, mouseY, MekanismRenderer.getPartialTick()));
    RenderSystem.translatef(leftPos, topPos, 0);
    drawForegroundText(matrix, mouseX, mouseY);
    int xAxis = mouseX - leftPos;
    int yAxis = mouseY - topPos;
    // first render general foregrounds
    maxZOffset = 200;
    int zOffset = 200;
    for (Widget widget : this.buttons) {
        if (widget instanceof GuiElement) {
            matrix.pushPose();
            ((GuiElement) widget).onRenderForeground(matrix, mouseX, mouseY, zOffset, zOffset);
            matrix.popPose();
        }
    }
    // now render overlays in reverse-order (i.e. back to front)
    zOffset = maxZOffset;
    for (LRU<GuiWindow>.LRUIterator iter = getWindowsDescendingIterator(); iter.hasNext(); ) {
        GuiWindow overlay = iter.next();
        zOffset += 150;
        matrix.pushPose();
        overlay.onRenderForeground(matrix, mouseX, mouseY, zOffset, zOffset);
        if (iter.hasNext()) {
            // if this isn't the focused window, render a 'blur' effect over it
            overlay.renderBlur(matrix);
        }
        matrix.popPose();
    }
    // then render tooltips, translating above max z offset to prevent clashing
    GuiElement tooltipElement = getWindowHovering(mouseX, mouseY);
    if (tooltipElement == null) {
        for (int i = buttons.size() - 1; i >= 0; i--) {
            Widget widget = buttons.get(i);
            if (widget instanceof GuiElement && widget.isMouseOver(mouseX, mouseY)) {
                tooltipElement = (GuiElement) widget;
                break;
            }
        }
    }
    // translate forwards using RenderSystem. this should never have to happen as we do all the necessary translations with MatrixStacks,
    // but Minecraft has decided to not fully adopt MatrixStacks for many crucial ContainerScreen render operations. should be re-evaluated
    // when mc updates related logic on their end (IMPORTANT)
    RenderSystem.translatef(0, 0, maxZOffset);
    if (tooltipElement != null) {
        tooltipElement.renderToolTip(matrix, xAxis, yAxis);
    }
    // render item tooltips
    RenderSystem.translatef(-leftPos, -topPos, 0);
    renderTooltip(matrix, mouseX, mouseY);
    RenderSystem.translatef(leftPos, topPos, 0);
    // IMPORTANT: additional hacky translation so held items render okay. re-evaluate as discussed above
    RenderSystem.translatef(0, 0, 200);
}
Also used : GuiElement(mekanism.client.gui.element.GuiElement) LRU(mekanism.common.lib.collection.LRU) ResourceType(mekanism.common.util.MekanismUtils.ResourceType) SelectedWindowData(mekanism.common.inventory.container.SelectedWindowData) BooleanSupplier(java.util.function.BooleanSupplier) ISideConfiguration(mekanism.common.tile.interfaces.ISideConfiguration) Pair(org.apache.commons.lang3.tuple.Pair) SlotOverlay(mekanism.common.inventory.container.slot.SlotOverlay) GuiWindow(mekanism.client.gui.element.window.GuiWindow) Collection(java.util.Collection) SlotType(mekanism.client.gui.element.slot.SlotType) MekanismUtils(mekanism.common.util.MekanismUtils) WarningTracker(mekanism.client.gui.warning.WarningTracker) List(java.util.List) IWarningTracker(mekanism.client.gui.warning.IWarningTracker) MekanismRenderer(mekanism.client.render.MekanismRenderer) Optional(java.util.Optional) MekanismContainer(mekanism.common.inventory.container.MekanismContainer) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) GuiWarningTab(mekanism.client.gui.element.tab.GuiWarningTab) Container(net.minecraft.inventory.container.Container) IGuiEventListener(net.minecraft.client.gui.IGuiEventListener) IVirtualSlot(mekanism.common.inventory.container.slot.IVirtualSlot) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ITextComponent(net.minecraft.util.text.ITextComponent) WarningType(mekanism.client.gui.warning.WarningTracker.WarningType) ItemStack(net.minecraft.item.ItemStack) ItemRenderer(net.minecraft.client.renderer.ItemRenderer) Minecraft(net.minecraft.client.Minecraft) Slot(net.minecraft.inventory.container.Slot) ILangEntry(mekanism.api.text.ILangEntry) Nonnull(javax.annotation.Nonnull) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) Nullable(javax.annotation.Nullable) TileEntityMekanism(mekanism.common.tile.base.TileEntityMekanism) Mekanism(mekanism.common.Mekanism) PlayerInventory(net.minecraft.entity.player.PlayerInventory) Widget(net.minecraft.client.gui.widget.Widget) DataType(mekanism.common.tile.component.config.DataType) InventoryContainerSlot(mekanism.common.inventory.container.slot.InventoryContainerSlot) IFancyFontRenderer(mekanism.client.render.IFancyFontRenderer) ContainerSlotType(mekanism.common.inventory.container.slot.ContainerSlotType) FontRenderer(net.minecraft.client.gui.FontRenderer) IHoverable(mekanism.client.gui.element.GuiElement.IHoverable) MekanismTileContainer(mekanism.common.inventory.container.tile.MekanismTileContainer) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) ResourceLocation(net.minecraft.util.ResourceLocation) GuiVirtualSlot(mekanism.client.gui.element.slot.GuiVirtualSlot) Widget(net.minecraft.client.gui.widget.Widget) GuiWindow(mekanism.client.gui.element.window.GuiWindow) GuiElement(mekanism.client.gui.element.GuiElement) LRU(mekanism.common.lib.collection.LRU)

Aggregations

Widget (net.minecraft.client.gui.widget.Widget)9 GuiElement (mekanism.client.gui.element.GuiElement)4 ArrayList (java.util.ArrayList)3 IGuiEventListener (net.minecraft.client.gui.IGuiEventListener)3 Nullable (javax.annotation.Nullable)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 Pair (org.apache.commons.lang3.tuple.Pair)2 SettingsScreenButton (com.irtimaled.bbor.client.gui.SettingsScreenButton)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 Collection (java.util.Collection)1 List (java.util.List)1 Optional (java.util.Optional)1 BooleanSupplier (java.util.function.BooleanSupplier)1 Supplier (java.util.function.Supplier)1 Nonnull (javax.annotation.Nonnull)1 ILangEntry (mekanism.api.text.ILangEntry)1 IHoverable (mekanism.client.gui.element.GuiElement.IHoverable)1 GuiSlot (mekanism.client.gui.element.slot.GuiSlot)1 GuiVirtualSlot (mekanism.client.gui.element.slot.GuiVirtualSlot)1