Search in sources :

Example 1 with DraggableWidgetGroup

use of com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup in project Multiblocked by Low-Drag-MC.

the class PlayerCapabilityTrait method refreshSlots.

protected void refreshSlots(DraggableScrollableWidgetGroup dragGroup) {
    dragGroup.widgets.forEach(dragGroup::waitToRemoved);
    ButtonWidget setting = (ButtonWidget) new ButtonWidget(width - 8, 0, 8, 8, new ResourceTexture("multiblocked:textures/gui/option.png"), null).setHoverBorderTexture(1, -1).setHoverTooltips("settings");
    ImageWidget imageWidget = new ImageWidget(0, 0, width, height, new TextTexture("Player Name").setWidth(width).setType(textType).setBackgroundColor(0xff000000));
    setting.setVisible(false);
    DraggableWidgetGroup slot = new DraggableWidgetGroup(x, y, width, height);
    slot.setOnSelected(w -> setting.setVisible(true));
    slot.setOnUnSelected(w -> setting.setVisible(false));
    slot.addWidget(imageWidget);
    slot.addWidget(setting);
    slot.setOnEndDrag(b -> {
        x = b.getSelfPosition().x;
        y = 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)));
        initSettingDialog(dialog, slot);
    });
}
Also used : ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) 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)

Example 2 with DraggableWidgetGroup

use of com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup in project Multiblocked by Low-Drag-MC.

the class FluidCapabilityTrait method initSettingDialog.

@Override
protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot, int index) {
    super.initSettingDialog(dialog, slot, index);
    dialog.addWidget(new LabelWidget(5, 60, "multiblocked.gui.label.tank_capability"));
    dialog.addWidget(new TextFieldWidget(5, 70, 100, 15, null, s -> tankCapability[index] = Integer.parseInt(s)).setNumbersOnly(1, Integer.MAX_VALUE).setCurrentString(tankCapability[index] + ""));
}
Also used : JSONUtils(net.minecraft.util.JSONUtils) JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ComponentTileEntity(com.lowdragmc.multiblocked.api.tile.ComponentTileEntity) Constants(net.minecraftforge.common.util.Constants) CompoundNBT(net.minecraft.nbt.CompoundNBT) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArrayUtils(org.apache.commons.lang3.ArrayUtils) Direction(net.minecraft.util.Direction) FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) LazyOptional(net.minecraftforge.common.util.LazyOptional) JsonElement(com.google.gson.JsonElement) MultiCapabilityTrait(com.lowdragmc.multiblocked.api.capability.trait.MultiCapabilityTrait) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) TankWidget(com.lowdragmc.lowdraglib.gui.widget.TankWidget) IO(com.lowdragmc.multiblocked.api.capability.IO) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) Nonnull(javax.annotation.Nonnull) INBT(net.minecraft.nbt.INBT) Nullable(javax.annotation.Nullable) ListNBT(net.minecraft.nbt.ListNBT) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) PlayerEntity(net.minecraft.entity.player.PlayerEntity) CapabilityFluidHandler(net.minecraftforge.fluids.capability.CapabilityFluidHandler) Capability(net.minecraftforge.common.capabilities.Capability) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) DraggableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup) JsonArray(com.google.gson.JsonArray) List(java.util.List) TileEntity(net.minecraft.tileentity.TileEntity) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidTank(net.minecraftforge.fluids.IFluidTank) FluidMultiblockCapability(com.lowdragmc.multiblocked.common.capability.FluidMultiblockCapability) INBTSerializable(net.minecraftforge.common.util.INBTSerializable) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)

Example 3 with DraggableWidgetGroup

use of com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup in project Multiblocked by Low-Drag-MC.

the class ChemicalCapabilityTrait method initSettingDialog.

@Override
protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot, int index) {
    super.initSettingDialog(dialog, slot, index);
    dialog.addWidget(new LabelWidget(5, 60, "multiblocked.gui.label.tank_capability"));
    dialog.addWidget(new TextFieldWidget(5, 70, 100, 15, null, s -> tankCapability[index] = Integer.parseInt(s)).setNumbersOnly(1, Integer.MAX_VALUE).setCurrentString(tankCapability[index] + ""));
}
Also used : JSONUtils(net.minecraft.util.JSONUtils) JsonObject(com.google.gson.JsonObject) ComponentTileEntity(com.lowdragmc.multiblocked.api.tile.ComponentTileEntity) ChemicalStack(mekanism.api.chemical.ChemicalStack) Constants(net.minecraftforge.common.util.Constants) ChemicalStackWidget(com.lowdragmc.multiblocked.common.capability.widget.ChemicalStackWidget) AutomationType(mekanism.api.inventory.AutomationType) CompoundNBT(net.minecraft.nbt.CompoundNBT) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ChemicalMekanismCapability(com.lowdragmc.multiblocked.common.capability.ChemicalMekanismCapability) ArrayUtils(org.apache.commons.lang3.ArrayUtils) Direction(net.minecraft.util.Direction) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) LazyOptional(net.minecraftforge.common.util.LazyOptional) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) MultiCapabilityTrait(com.lowdragmc.multiblocked.api.capability.trait.MultiCapabilityTrait) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) Chemical(mekanism.api.chemical.Chemical) ChemicalTankBuilder(mekanism.api.chemical.ChemicalTankBuilder) IO(com.lowdragmc.multiblocked.api.capability.IO) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) ListNBT(net.minecraft.nbt.ListNBT) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) MethodsReturnNonnullByDefault(mcp.MethodsReturnNonnullByDefault) PlayerEntity(net.minecraft.entity.player.PlayerEntity) IChemicalHandler(mekanism.api.chemical.IChemicalHandler) Capability(net.minecraftforge.common.capabilities.Capability) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) DraggableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup) JsonArray(com.google.gson.JsonArray) List(java.util.List) TileEntity(net.minecraft.tileentity.TileEntity) Action(mekanism.api.Action) IChemicalTank(mekanism.api.chemical.IChemicalTank) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)

Example 4 with DraggableWidgetGroup

use of com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup 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 5 with DraggableWidgetGroup

use of com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup in project Multiblocked by Low-Drag-MC.

the class ProgressCapabilityTrait method refreshSlots.

protected void refreshSlots(DraggableScrollableWidgetGroup dragGroup) {
    dragGroup.widgets.forEach(dragGroup::waitToRemoved);
    ButtonWidget setting = (ButtonWidget) new ButtonWidget(width - 8, 0, 8, 8, new ResourceTexture("multiblocked:textures/gui/option.png"), null).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.tips.settings");
    ImageWidget imageWidget = new ImageWidget(0, 0, width, height, new GuiTextureGroup(new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5), new ColorBorderTexture(1, getColorByIO(capabilityIO))));
    setting.setVisible(false);
    DraggableWidgetGroup slot = new DraggableWidgetGroup(x, y, width, height);
    slot.setOnSelected(w -> setting.setVisible(true));
    slot.setOnUnSelected(w -> setting.setVisible(false));
    slot.addWidget(imageWidget);
    slot.addWidget(setting);
    slot.setOnEndDrag(b -> {
        x = b.getSelfPosition().x;
        y = 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)));
        initSettingDialog(dialog, slot);
    });
}
Also used : ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) 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)

Aggregations

DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)7 DraggableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup)7 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)5 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)5 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)5 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)5 ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)4 GuiTextureGroup (com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)4 JsonElement (com.google.gson.JsonElement)3 JsonObject (com.google.gson.JsonObject)3 TextFieldWidget (com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)3 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)3 IO (com.lowdragmc.multiblocked.api.capability.IO)3 ComponentTileEntity (com.lowdragmc.multiblocked.api.tile.ComponentTileEntity)3 Nullable (javax.annotation.Nullable)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 JSONUtils (net.minecraft.util.JSONUtils)3 JsonArray (com.google.gson.JsonArray)2 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)2 LabelWidget (com.lowdragmc.lowdraglib.gui.widget.LabelWidget)2