Search in sources :

Example 6 with LabelWidget

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

the class PredicateStates method getConfigWidget.

@Override
public List<WidgetGroup> getConfigWidget(List<WidgetGroup> groups) {
    super.getConfigWidget(groups);
    WidgetGroup group = new WidgetGroup(0, 0, 182, 100);
    groups.add(group);
    DraggableScrollableWidgetGroup container = new DraggableScrollableWidgetGroup(0, 25, 182, 80).setBackground(new ColorRectTexture(0xffaaaaaa));
    group.addWidget(container);
    List<BlockState> blockList = new ArrayList<>(Arrays.asList(states));
    for (BlockState blockState : blockList) {
        addBlockSelectorWidget(blockList, container, blockState);
    }
    group.addWidget(new LabelWidget(0, 6, "multiblocked.gui.label.block_settings"));
    group.addWidget(new ButtonWidget(162, 0, 20, 20, cd -> {
        blockList.add(null);
        addBlockSelectorWidget(blockList, container, null);
    }).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/add.png")).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.predicate.states.add"));
    return groups;
}
Also used : BlockState(net.minecraft.block.BlockState) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) ArrayList(java.util.ArrayList) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)

Example 7 with LabelWidget

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

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

the class IMultiblockedRenderer method createBoolSwitch.

default WidgetGroup createBoolSwitch(int x, int y, String text, String tips, boolean init, Consumer<Boolean> onPressed) {
    WidgetGroup widgetGroup = new WidgetGroup(x, y, 100, 15);
    widgetGroup.addWidget(new SwitchWidget(0, 0, 15, 15, (cd, r) -> onPressed.accept(r)).setBaseTexture(new ResourceTexture("multiblocked:textures/gui/boolean.png").getSubTexture(0, 0, 1, 0.5)).setPressedTexture(new ResourceTexture("multiblocked:textures/gui/boolean.png").getSubTexture(0, 0.5, 1, 0.5)).setHoverTexture(new ColorBorderTexture(1, 0xff545757)).setPressed(init).setHoverTooltips(tips));
    widgetGroup.addWidget(new LabelWidget(20, 3, () -> text).setTextColor(-1).setDrop(true));
    return widgetGroup;
}
Also used : ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) SwitchWidget(com.lowdragmc.lowdraglib.gui.widget.SwitchWidget)

Example 9 with LabelWidget

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

the class ItemsContentWidget method openConfigurator.

@Override
public void openConfigurator(WidgetGroup dialog) {
    super.openConfigurator(dialog);
    int x = 5;
    int y = 25;
    dialog.addWidget(new LabelWidget(5, y + 3, "multiblocked.gui.label.amount"));
    dialog.addWidget(new TextFieldWidget(125 - 60, y, 60, 15, null, number -> {
        content = content.isTag() ? new ItemsIngredient(content.getTag(), Integer.parseInt(number)) : new ItemsIngredient(content.ingredient, Integer.parseInt(number));
        onContentUpdate();
    }).setNumbersOnly(1, Integer.MAX_VALUE).setCurrentString(content.getAmount() + ""));
    TextFieldWidget tag;
    WidgetGroup groupOre = new WidgetGroup(x, y + 40, 120, 80);
    WidgetGroup groupIngredient = new WidgetGroup(x, y + 20, 120, 80);
    DraggableScrollableWidgetGroup container = new DraggableScrollableWidgetGroup(0, 20, 120, 50).setBackground(new ColorRectTexture(0xffaaaaaa));
    groupIngredient.addWidget(container);
    dialog.addWidget(groupIngredient);
    dialog.addWidget(groupOre);
    groupOre.addWidget(tag = new TextFieldWidget(30, 3, 90, 15, () -> content.isTag() ? content.getTag() : "", null).setResourceLocationOnly());
    IItemHandlerModifiable handler;
    PhantomSlotWidget phantomSlotWidget = new PhantomSlotWidget(handler = new ItemStackHandler(1), 0, 0, 1).setClearSlotOnRightClick(false);
    groupOre.addWidget(phantomSlotWidget);
    phantomSlotWidget.setChangeListener(() -> {
        ItemStack newStack = handler.getStackInSlot(0);
        if (newStack.isEmpty())
            return;
        ITagCollection<Item> tags = TagCollectionManager.getInstance().getItems();
        Collection<ResourceLocation> ids = tags.getMatchingTags(newStack.getItem());
        if (ids.size() > 0) {
            String tagString = ids.stream().findAny().get().toString();
            content = new ItemsIngredient(tagString, content.getAmount());
            tag.setCurrentString(tagString);
            phantomSlotWidget.setHoverTooltips(LocalizationUtils.format("multiblocked.gui.trait.item.ore_dict") + ": " + ids.stream().map(ResourceLocation::toString).reduce("", (a, b) -> a + "\n" + b));
        } else {
            content = new ItemsIngredient("", content.getAmount());
            tag.setCurrentString("");
            handler.setStackInSlot(0, ItemStack.EMPTY);
        }
        onContentUpdate();
    }).setBackgroundTexture(new ColorRectTexture(0xaf444444));
    tag.setTextResponder(tagS -> {
        content = new ItemsIngredient(tagS, content.getAmount());
        ItemStack[] matches = content.ingredient.getItems();
        handler.setStackInSlot(0, matches.length > 0 ? matches[0] : ItemStack.EMPTY);
        phantomSlotWidget.setHoverTooltips(LocalizationUtils.format("multiblocked.gui.trait.item.ore_dict") + ":\n" + content.getTag());
        onContentUpdate();
    });
    tag.setHoverTooltips("multiblocked.gui.trait.item.ore_dic");
    dialog.addWidget(new SwitchWidget(x, y + 22, 50, 15, (cd, r) -> {
        groupOre.setVisible(r);
        content = r ? new ItemsIngredient(tag.getCurrentString(), content.getAmount()) : new ItemsIngredient(content.ingredient, content.getAmount());
        groupIngredient.setVisible(!r);
        if (r) {
            ItemStack[] matches = content.ingredient.getItems();
            handler.setStackInSlot(0, matches.length > 0 ? matches[0] : ItemStack.EMPTY);
            phantomSlotWidget.setHoverTooltips("oreDict: \n" + content.getTag());
        } else {
            updateIngredientWidget(container);
        }
        onContentUpdate();
    }).setPressed(content.isTag()).setHoverBorderTexture(1, -1).setBaseTexture(ResourceBorderTexture.BUTTON_COMMON, new TextTexture("tag (N)")).setPressedTexture(ResourceBorderTexture.BUTTON_COMMON, new TextTexture("tag (Y)")).setHoverTooltips("using tag dictionary"));
    groupIngredient.setVisible(!content.isTag());
    groupOre.setVisible(content.isTag());
    if (content.isTag()) {
        ItemStack[] matches = content.ingredient.getItems();
        handler.setStackInSlot(0, matches.length > 0 ? matches[0] : ItemStack.EMPTY);
        phantomSlotWidget.setHoverTooltips(LocalizationUtils.format("multiblocked.gui.trait.item.ore_dict") + ":\n" + content.getTag());
    } else {
        updateIngredientWidget(container);
    }
    groupIngredient.addWidget(new LabelWidget(x + 50, 5, "multiblocked.gui.tips.settings"));
    groupIngredient.addWidget(new ButtonWidget(100, 0, 20, 20, cd -> {
        ItemStack[] stacks = content.ingredient.getItems();
        content = new ItemsIngredient(Ingredient.of(ArrayUtils.add(stacks, new ItemStack(Items.IRON_INGOT))), content.getAmount());
        updateIngredientWidget(container);
        onContentUpdate();
    }).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/add.png")).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.trait.item.add"));
}
Also used : Ingredient(net.minecraft.item.crafting.Ingredient) Arrays(java.util.Arrays) TagCollectionManager(net.minecraft.tags.TagCollectionManager) LocalizationUtils(com.lowdragmc.lowdraglib.utils.LocalizationUtils) Item(net.minecraft.item.Item) ItemsIngredient(com.lowdragmc.multiblocked.api.recipe.ItemsIngredient) ArrayUtils(org.apache.commons.lang3.ArrayUtils) PhantomSlotWidget(com.lowdragmc.lowdraglib.gui.widget.PhantomSlotWidget) SlotWidget(com.lowdragmc.lowdraglib.gui.widget.SlotWidget) ResourceBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ItemStack(net.minecraft.item.ItemStack) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) CycleItemStackHandler(com.lowdragmc.lowdraglib.utils.CycleItemStackHandler) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ContentWidget(com.lowdragmc.multiblocked.api.gui.recipe.ContentWidget) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) Collection(java.util.Collection) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) SwitchWidget(com.lowdragmc.lowdraglib.gui.widget.SwitchWidget) Items(net.minecraft.item.Items) Collectors(java.util.stream.Collectors) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) List(java.util.List) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ITagCollection(net.minecraft.tags.ITagCollection) ItemStackHandler(net.minecraftforge.items.ItemStackHandler) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) Collections(java.util.Collections) CycleItemStackHandler(com.lowdragmc.lowdraglib.utils.CycleItemStackHandler) ItemStackHandler(net.minecraftforge.items.ItemStackHandler) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) SwitchWidget(com.lowdragmc.lowdraglib.gui.widget.SwitchWidget) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) PhantomSlotWidget(com.lowdragmc.lowdraglib.gui.widget.PhantomSlotWidget) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) ItemsIngredient(com.lowdragmc.multiblocked.api.recipe.ItemsIngredient) ResourceLocation(net.minecraft.util.ResourceLocation) ITagCollection(net.minecraft.tags.ITagCollection) Collection(java.util.Collection) ITagCollection(net.minecraft.tags.ITagCollection) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) ItemStack(net.minecraft.item.ItemStack)

Example 10 with LabelWidget

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

the class NumberContentWidget method openConfigurator.

@Override
public void openConfigurator(WidgetGroup dialog) {
    super.openConfigurator(dialog);
    TextFieldWidget textFieldWidget;
    int x = 5;
    int y = 25;
    dialog.addWidget(new LabelWidget(5, y + 3, "multiblocked.gui.label.number"));
    dialog.addWidget(textFieldWidget = new TextFieldWidget(125 - 60, y, 60, 15, null, number -> {
        if (content instanceof Float) {
            content = Float.parseFloat(number);
        } else if (content instanceof Double) {
            content = Double.parseDouble(number);
        } else if (content instanceof Integer) {
            content = Integer.parseInt(number);
        } else if (content instanceof Long) {
            content = Long.parseLong(number);
        }
        onContentUpdate();
    }).setCurrentString(content.toString()));
    if (isDecimal) {
        textFieldWidget.setNumbersOnly(0f, Integer.MAX_VALUE);
    } else {
        if (content instanceof Long) {
            textFieldWidget.setNumbersOnly(0, Long.MAX_VALUE);
        } else {
            textFieldWidget.setNumbersOnly(0, Integer.MAX_VALUE);
        }
    }
    dialog.addWidget(createButton(textFieldWidget, -10000, x, y + 66));
    dialog.addWidget(createButton(textFieldWidget, -100, x, y + 44));
    dialog.addWidget(createButton(textFieldWidget, -1, x, y + 22));
    dialog.addWidget(createButton(textFieldWidget, 1, x + 75, y + 22));
    dialog.addWidget(createButton(textFieldWidget, 100, x + 75, y + 44));
    dialog.addWidget(createButton(textFieldWidget, 10000, x + 75, y + 66));
}
Also used : ContentWidget(com.lowdragmc.multiblocked.api.gui.recipe.ContentWidget) Position(com.lowdragmc.lowdraglib.utils.Position) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) LocalizationUtils(com.lowdragmc.lowdraglib.utils.LocalizationUtils) Size(com.lowdragmc.lowdraglib.utils.Size) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) ResourceBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture) IGuiTexture(com.lowdragmc.lowdraglib.gui.texture.IGuiTexture) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) TextFormattingUtil(com.lowdragmc.lowdraglib.gui.util.TextFormattingUtil) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) Nullable(javax.annotation.Nullable) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)

Aggregations

LabelWidget (com.lowdragmc.lowdraglib.gui.widget.LabelWidget)13 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)13 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)8 TextFieldWidget (com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)8 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)6 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)6 SwitchWidget (com.lowdragmc.lowdraglib.gui.widget.SwitchWidget)6 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)5 IO (com.lowdragmc.multiblocked.api.capability.IO)5 List (java.util.List)5 JsonObject (com.google.gson.JsonObject)4 ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)4 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)4 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)4 LocalizationUtils (com.lowdragmc.lowdraglib.utils.LocalizationUtils)4 Collections (java.util.Collections)4 Nullable (javax.annotation.Nullable)4 JSONUtils (net.minecraft.util.JSONUtils)4 ArrayUtils (org.apache.commons.lang3.ArrayUtils)4 Nonnull (javax.annotation.Nonnull)3