Search in sources :

Example 6 with Position

use of com.lowdragmc.lowdraglib.utils.Position in project Multiblocked by Low-Drag-MC.

the class NumberContentWidget method drawHookBackground.

@Override
public void drawHookBackground(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
    Position position = getPosition();
    Size size = getSize();
    if (contentTexture != null) {
        contentTexture.draw(matrixStack, mouseX, mouseY, position.x + 1, position.y + 1, size.width - 2, size.height - 2);
    }
    matrixStack.pushPose();
    matrixStack.scale(0.5f, 0.5f, 1);
    RenderSystem.disableDepthTest();
    String s = TextFormattingUtil.formatLongToCompactString(content.intValue(), 4);
    FontRenderer fontRenderer = Minecraft.getInstance().font;
    fontRenderer.drawShadow(matrixStack, s, (position.x + (size.width / 3f)) * 2 - fontRenderer.width(s) + 21, (position.y + (size.height / 3f) + 6) * 2, 0xFFFFFF);
    matrixStack.popPose();
}
Also used : Position(com.lowdragmc.lowdraglib.utils.Position) Size(com.lowdragmc.lowdraglib.utils.Size) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 7 with Position

use of com.lowdragmc.lowdraglib.utils.Position in project Multiblocked by Low-Drag-MC.

the class ContentWidget method drawTick.

@OnlyIn(Dist.CLIENT)
public void drawTick(MatrixStack matrixStack) {
    if (perTick) {
        Position pos = getPosition();
        Size size = getSize();
        matrixStack.pushPose();
        RenderSystem.disableDepthTest();
        matrixStack.translate(0, 0, 400);
        matrixStack.scale(0.5f, 0.5f, 1);
        String s = LocalizationUtils.format("multiblocked.gui.content.tips.per_tick_short");
        int color = 0xFFFF00;
        FontRenderer fontRenderer = Minecraft.getInstance().font;
        fontRenderer.drawShadow(matrixStack, s, (pos.x + (size.width / 3f)) * 2 - fontRenderer.width(s) + 23, (pos.y + (size.height / 3f) + 6) * 2 - size.height + (chance == 1 ? 0 : 10), color);
        matrixStack.popPose();
    }
}
Also used : Position(com.lowdragmc.lowdraglib.utils.Position) Size(com.lowdragmc.lowdraglib.utils.Size) FontRenderer(net.minecraft.client.gui.FontRenderer) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 8 with Position

use of com.lowdragmc.lowdraglib.utils.Position in project Multiblocked by Low-Drag-MC.

the class ProgressWidget method drawInBackground.

@Override
@OnlyIn(Dist.CLIENT)
public void drawInBackground(@Nonnull MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
    Position pos = getPosition();
    Size size = getSize();
    if (emptyBarArea != null) {
        emptyBarArea.draw(matrixStack, mouseX, mouseY, pos.x, pos.y, size.width, size.height);
    }
    if (filledBarArea != null) {
        if (progressSupplier == JEIProgress) {
            lastProgressValue = progressSupplier.getAsDouble();
            if (dynamicHoverTips != null) {
                setHoverTooltips(dynamicHoverTips.apply(lastProgressValue));
            }
        }
        filledBarArea.drawSubArea(matrixStack, pos.x, pos.y, (int) (size.width * (lastProgressValue < 0 ? 0 : lastProgressValue)), size.height, 0, 0, ((int) (size.width * (lastProgressValue < 0 ? 0 : lastProgressValue))) / (size.width * 1f), 1);
    }
}
Also used : Position(com.lowdragmc.lowdraglib.utils.Position) Size(com.lowdragmc.lowdraglib.utils.Size) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 9 with Position

use of com.lowdragmc.lowdraglib.utils.Position in project Multiblocked by Low-Drag-MC.

the class ProgressCapabilityTrait method initSettingDialog.

@Override
protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot) {
    ImageWidget imageWidget = (ImageWidget) slot.widgets.get(0);
    ButtonWidget setting = (ButtonWidget) slot.widgets.get(1);
    ButtonWidget imageSelector = (ButtonWidget) new ButtonWidget(5, 65, width, height, new GuiTextureGroup(new ColorBorderTexture(1, -1), new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5)), null).setHoverTooltips("multiblocked.gui.tips.select_image");
    dialog.addWidget(new TextFieldWidget(5, 25, 50, 15, null, s -> {
        width = Integer.parseInt(s);
        Size size = new Size(width, height);
        slot.setSize(size);
        imageWidget.setSize(size);
        imageSelector.setSize(size);
        setting.setSelfPosition(new Position(width - 8, 0));
    }).setCurrentString(width + "").setNumbersOnly(1, 180).setHoverTooltips("multiblocked.gui.trait.set_width"));
    dialog.addWidget(new TextFieldWidget(5, 45, 50, 15, null, s -> {
        height = Integer.parseInt(s);
        Size size = new Size(width, height);
        slot.setSize(size);
        imageWidget.setSize(size);
        imageSelector.setSize(size);
        setting.setSelfPosition(new Position(width - 8, 0));
    }).setCurrentString(height + "").setNumbersOnly(1, 180).setHoverTooltips("multiblocked.gui.trait.set_height"));
    dialog.addWidget(new SelectorWidget(5, 5, 50, 15, Arrays.stream(IO.VALUES).map(Enum::name).collect(Collectors.toList()), -1).setValue(capabilityIO.name()).setOnChanged(io -> {
        capabilityIO = IO.valueOf(io);
        imageWidget.setImage(new GuiTextureGroup(new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5), new ColorBorderTexture(1, getColorByIO(capabilityIO))));
    }).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("multiblocked.gui.trait.capability_io"));
    dialog.addWidget(imageSelector);
    imageSelector.setOnPressCallback(cd -> new ResourceTextureWidget(dialog.getParent().getGui().mainGroup, texture1 -> {
        if (texture1 != null) {
            texture = texture1.imageLocation.toString();
            ResourceTexture resourceTexture = new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5);
            imageSelector.setButtonTexture(new GuiTextureGroup(new ColorBorderTexture(1, -1), resourceTexture));
            imageWidget.setImage(new GuiTextureGroup(resourceTexture, new ColorBorderTexture(1, getColorByIO(capabilityIO))));
        }
    }));
}
Also used : JSONUtils(net.minecraft.util.JSONUtils) JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ComponentTileEntity(com.lowdragmc.multiblocked.api.tile.ComponentTileEntity) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) MultiblockCapability(com.lowdragmc.multiblocked.api.capability.MultiblockCapability) ResourceBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture) JsonElement(com.google.gson.JsonElement) SelectorWidget(com.lowdragmc.lowdraglib.gui.widget.SelectorWidget) IO(com.lowdragmc.multiblocked.api.capability.IO) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) Nullable(javax.annotation.Nullable) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) Position(com.lowdragmc.lowdraglib.utils.Position) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) Size(com.lowdragmc.lowdraglib.utils.Size) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) ProgressWidget(com.lowdragmc.multiblocked.api.gui.recipe.ProgressWidget) Collectors(java.util.stream.Collectors) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) DraggableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) Position(com.lowdragmc.lowdraglib.utils.Position) Size(com.lowdragmc.lowdraglib.utils.Size) SelectorWidget(com.lowdragmc.lowdraglib.gui.widget.SelectorWidget) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget)

Aggregations

Position (com.lowdragmc.lowdraglib.utils.Position)9 Size (com.lowdragmc.lowdraglib.utils.Size)8 FontRenderer (net.minecraft.client.gui.FontRenderer)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)2 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)2 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)2 SelectorWidget (com.lowdragmc.lowdraglib.gui.widget.SelectorWidget)2 TextFieldWidget (com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)1 GuiTextureGroup (com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)1 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)1 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)1 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)1 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)1 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)1 DraggableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup)1 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)1