Search in sources :

Example 6 with Widget

use of net.minecraft.client.gui.widget.Widget in project Chisel by Chisel-Team.

the class GuiChisel method drawButtonTooltips.

protected void drawButtonTooltips(MatrixStack matrixStack, int mx, int my) {
    for (Widget button : buttons) {
        if (button.isMouseOver(mx, my) && button instanceof ButtonChiselMode) {
            String unloc = ((ButtonChiselMode) button).getMode().getUnlocName();
            List<ITextComponent> ttLines = Lists.newArrayList(new TranslationTextComponent(unloc), new TranslationTextComponent(unloc + ".desc").mergeStyle(TextFormatting.GRAY));
            GuiUtils.drawHoveringText(matrixStack, ttLines, mx - guiLeft, my - guiTop, width - guiLeft, height - guiTop, -1, font);
        }
    }
}
Also used : Widget(net.minecraft.client.gui.widget.Widget) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 7 with Widget

use of net.minecraft.client.gui.widget.Widget in project pufferfish-minecraft-mod by Jacob1225.

the class ArcadeMachineScreen method render.

@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
    this.renderBackground(matrixStack);
    super.render(matrixStack, mouseX, mouseY, partialTicks);
    this.renderTooltip(matrixStack, mouseX, mouseY);
    for (Widget button : buttons) {
        button.render(matrixStack, mouseX, mouseY, partialTicks);
    }
}
Also used : Widget(net.minecraft.client.gui.widget.Widget)

Example 8 with Widget

use of net.minecraft.client.gui.widget.Widget in project Telepads2016 by ArtixAllMighty.

the class TeleportScreen method mouseScrolled.

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double mouseScroll) {
    int index = buttons.size() > 0 ? buttons.size() - 1 : 0;
    Widget last = buttons.get(index);
    Widget first = buttons.get(0);
    int forsee_bottom_limit = (int) (last.y + last.getHeight() + (mouseScroll * 16));
    int bottom_limit = height - START_Y - last.getHeight();
    int forsee_top_limit = (int) (first.y - 15 + mouseScroll * 16);
    int top_limit = GAP + START_Y;
    // scrolling up
    if (mouseScroll < 0.0 && forsee_bottom_limit < bottom_limit)
        return super.mouseScrolled(mouseX, mouseY, mouseScroll);
    // down
    if (mouseScroll > 0.0 && forsee_top_limit > top_limit)
        return super.mouseScrolled(mouseX, mouseY, mouseScroll);
    move(mouseScroll);
    return super.mouseScrolled(mouseX, mouseY, mouseScroll);
}
Also used : TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) Widget(net.minecraft.client.gui.widget.Widget)

Example 9 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 10 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)18 GuiElement (mekanism.client.gui.element.GuiElement)4 TextFieldWidget (net.minecraft.client.gui.widget.TextFieldWidget)4 ArrayList (java.util.ArrayList)3 Nullable (javax.annotation.Nullable)3 IGuiEventListener (net.minecraft.client.gui.IGuiEventListener)3 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)3 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)2 List (java.util.List)2 Button (net.minecraft.client.gui.widget.button.Button)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 Pair (org.apache.commons.lang3.tuple.Pair)2 SettingsScreenButton (com.irtimaled.bbor.client.gui.SettingsScreenButton)1 InventoryHelper (de.teamlapen.lib.lib.inventory.InventoryHelper)1 UtilLib (de.teamlapen.lib.lib.util.UtilLib)1 REFERENCE (de.teamlapen.vampirism.REFERENCE)1 VampirismMod (de.teamlapen.vampirism.VampirismMod)1 IPlayableFaction (de.teamlapen.vampirism.api.entity.factions.IPlayableFaction)1 ISkill (de.teamlapen.vampirism.api.entity.player.skills.ISkill)1