Search in sources :

Example 1 with Size

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

the class PlayerCapabilityTrait method initSettingDialog.

protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot) {
    ImageWidget imageWidget = (ImageWidget) slot.widgets.get(0);
    ButtonWidget setting = (ButtonWidget) slot.widgets.get(1);
    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);
        ((TextTexture) imageWidget.getImage()).setWidth(width);
        setting.setSelfPosition(new Position(width - 8, 0));
    }).setCurrentString(width + "").setNumbersOnly(10, 180).setHoverTooltips("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);
        setting.setSelfPosition(new Position(width - 8, 0));
    }).setCurrentString(height + "").setNumbersOnly(10, 180).setHoverTooltips("set height"));
    dialog.addWidget(new SelectorWidget(5, 5, 50, 15, Arrays.stream(TextTexture.TextType.values()).map(Enum::name).collect(Collectors.toList()), -1).setValue(textType.name()).setOnChanged(io -> {
        textType = TextTexture.TextType.valueOf(io);
        ((TextTexture) imageWidget.getImage()).setType(textType);
    }).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("TextType"));
}
Also used : Position(com.lowdragmc.lowdraglib.utils.Position) Size(com.lowdragmc.lowdraglib.utils.Size) SelectorWidget(com.lowdragmc.lowdraglib.gui.widget.SelectorWidget) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)

Example 2 with Size

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

the class ContentWidget method drawInBackground.

@Override
@OnlyIn(Dist.CLIENT)
public final void drawInBackground(@Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
    Position position = getPosition();
    Size size = getSize();
    if (background != null) {
        background.draw(stack, mouseX, mouseY, position.x, position.y, size.width, size.height);
    }
    drawHookBackground(stack, mouseX, mouseY, partialTicks);
    super.drawInBackground(stack, mouseX, mouseY, partialTicks);
    drawChance(stack);
    drawTick(stack);
    drawHoverOverlay(stack, mouseX, mouseY);
    if (isSelected) {
        DrawerHelper.drawBorder(stack, getPosition().x, getPosition().y, getSize().width, getSize().height, 0xff00aa00, 1);
    }
}
Also used : Position(com.lowdragmc.lowdraglib.utils.Position) Size(com.lowdragmc.lowdraglib.utils.Size) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with Size

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

the class ContentWidget method drawChance.

@OnlyIn(Dist.CLIENT)
public void drawChance(MatrixStack matrixStack) {
    if (chance == 1)
        return;
    Position pos = getPosition();
    Size size = getSize();
    matrixStack.pushPose();
    matrixStack.translate(0, 0, 170);
    matrixStack.scale(0.5f, 0.5f, 1);
    String s = chance == 0 ? LocalizationUtils.format("multiblocked.gui.content.chance_0_short") : String.format("%.1f", chance * 100) + "%";
    int color = chance == 0 ? 0xff0000 : 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, 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 4 with Size

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

the class ChemicalStackWidget method drawHookBackground.

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

Example 5 with Size

use of com.lowdragmc.lowdraglib.utils.Size 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)

Aggregations

Position (com.lowdragmc.lowdraglib.utils.Position)8 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