Search in sources :

Example 16 with TextTexture

use of com.lowdragmc.lowdraglib.gui.texture.TextTexture in project Multiblocked by Low-Drag-MC.

the class MultiCapabilityTrait method refreshSlots.

protected void refreshSlots(DraggableScrollableWidgetGroup dragGroup) {
    dragGroup.widgets.forEach(dragGroup::waitToRemoved);
    for (int i = 0; i < guiIO.length; i++) {
        int finalI = i;
        ButtonWidget setting = (ButtonWidget) new ButtonWidget(10, 0, 8, 8, new ResourceTexture("multiblocked:textures/gui/option.png"), null).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.tips.settings");
        ImageWidget imageWidget = new ImageWidget(1, 1, 16, 16, new GuiTextureGroup(new ColorRectTexture(getColorByIO(guiIO[finalI])), new ColorBorderTexture(1, getColorByIO(capabilityIO[finalI]))));
        setting.setVisible(false);
        DraggableWidgetGroup slot = new DraggableWidgetGroup(x[finalI], y[finalI], 18, 18);
        slot.setOnSelected(w -> setting.setVisible(true));
        slot.setOnUnSelected(w -> setting.setVisible(false));
        slot.addWidget(imageWidget);
        slot.addWidget(setting);
        slot.setOnEndDrag(b -> {
            x[finalI] = b.getSelfPosition().x;
            y[finalI] = b.getSelfPosition().y;
        });
        dragGroup.addWidget(slot);
        setting.setOnPressCallback(cd2 -> {
            DialogWidget dialog = new DialogWidget(dragGroup, true);
            dialog.addWidget(new ImageWidget(0, 0, 176, 256, new ColorRectTexture(0xaf000000)));
            dialog.addWidget(new ButtonWidget(5, 5, 85, 20, new GuiTextureGroup(ResourceBorderTexture.BUTTON_COMMON, new TextTexture("multiblocked.gui.trait.remove_slot")), cd3 -> {
                removeSlot(finalI);
                refreshSlots(dragGroup);
                dialog.close();
            }).setHoverBorderTexture(1, -1));
            initSettingDialog(dialog, slot, finalI);
        });
    }
}
Also used : ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) DraggableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)

Example 17 with TextTexture

use of com.lowdragmc.lowdraglib.gui.texture.TextTexture in project Multiblocked by Low-Drag-MC.

the class PlayerCapabilityTrait method createUI.

@Override
public void createUI(ComponentTileEntity<?> component, WidgetGroup group, PlayerEntity player) {
    super.createUI(component, group, player);
    group.addWidget(new ImageWidget(x, y, width, height, new TextTexture("").setSupplier(() -> playerName).setWidth(width).setType(textType)) {

        @Override
        public void writeInitialData(PacketBuffer buffer) {
            super.writeInitialData(buffer);
            buffer.writeUtf(getPlayerName());
        }

        @Override
        public void readInitialData(PacketBuffer buffer) {
            super.readInitialData(buffer);
            playerName = buffer.readUtf(Short.MAX_VALUE);
        }
    });
}
Also used : TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) PacketBuffer(net.minecraft.network.PacketBuffer)

Aggregations

TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)17 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)14 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)12 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)11 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)11 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)7 File (java.io.File)7 SelectableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup)6 Multiblocked (com.lowdragmc.multiblocked.Multiblocked)6 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)6 JsonElement (com.google.gson.JsonElement)5 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)5 TextFieldWidget (com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)5 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)5 Collections (java.util.Collections)5 List (java.util.List)5 ResourceLocation (net.minecraft.util.ResourceLocation)5 JsonObject (com.google.gson.JsonObject)4 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)4 FileUtility (com.lowdragmc.lowdraglib.utils.FileUtility)4