Search in sources :

Example 1 with TextFieldWidget

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

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

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

the class ChemicalStackWidget 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 = CAP.copyInner(content);
        content.setAmount(Long.parseLong(number));
        onContentUpdate();
    }).setNumbersOnly(1L, Long.MAX_VALUE).setCurrentString(content.getAmount() + ""));
}
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) ChemicalStack(mekanism.api.chemical.ChemicalStack) Size(com.lowdragmc.lowdraglib.utils.Size) TextFormatting(net.minecraft.util.text.TextFormatting) ChemicalMekanismCapability(com.lowdragmc.multiblocked.common.capability.ChemicalMekanismCapability) IChemicalHandler(mekanism.api.chemical.IChemicalHandler) GuiUtils(mekanism.client.gui.GuiUtils) MathUtils(mekanism.api.math.MathUtils) I18n(net.minecraft.client.resources.I18n) FontRenderer(net.minecraft.client.gui.FontRenderer) MekanismRenderer(mekanism.client.render.MekanismRenderer) Minecraft(net.minecraft.client.Minecraft) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) Chemical(mekanism.api.chemical.Chemical) TextFormattingUtil(com.lowdragmc.lowdraglib.gui.util.TextFormattingUtil) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) IO(com.lowdragmc.multiblocked.api.capability.IO) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) Nonnull(javax.annotation.Nonnull) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) PacketBuffer(net.minecraft.network.PacketBuffer) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)

Example 4 with TextFieldWidget

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

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

the class GeoComponentRenderer method createConfigurator.

@Override
public Supplier<IMultiblockedRenderer> createConfigurator(WidgetGroup parent, DraggableScrollableWidgetGroup group, IMultiblockedRenderer current) {
    TextFieldWidget tfw = new TextFieldWidget(1, 1, 150, 20, null, null);
    File path = new File(Multiblocked.location, "assets/multiblocked/geo");
    AtomicBoolean isGlobal = new AtomicBoolean(false);
    if (current instanceof GeoComponentRenderer) {
        tfw.setCurrentString(((GeoComponentRenderer) current).modelName);
        isGlobal.set(((GeoComponentRenderer) current).isGlobal);
    }
    group.addWidget(new ButtonWidget(155, 1, 20, 20, cd -> DialogWidget.showFileDialog(parent, "select a geo file", path, true, DialogWidget.suffixFilter(".geo.json"), r -> {
        if (r != null && r.isFile()) {
            tfw.setCurrentString(r.getName().replace(".geo.json", ""));
        }
    })).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/darkened_slot.png"), new TextTexture("F", -1)).setHoverTooltips("multiblocked.gui.tips.file_selector"));
    group.addWidget(tfw);
    group.addWidget(createBoolSwitch(1, 25, "isGlobal", "multiblocked.gui.predicate.geo.0", isGlobal.get(), isGlobal::set));
    return () -> {
        if (tfw.getCurrentString().isEmpty()) {
            return null;
        } else {
            return new GeoComponentRenderer(tfw.getCurrentString(), isGlobal.get());
        }
    };
}
Also used : JSONUtils(net.minecraft.util.JSONUtils) AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder) JsonObject(com.google.gson.JsonObject) GeoBone(software.bernie.geckolib3.geo.render.built.GeoBone) Random(java.util.Random) Direction(net.minecraft.util.Direction) Dist(net.minecraftforge.api.distmarker.Dist) Gson(com.google.gson.Gson) IBlockDisplayReader(net.minecraft.world.IBlockDisplayReader) AnimationData(software.bernie.geckolib3.core.manager.AnimationData) BlockState(net.minecraft.block.BlockState) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) PlayState(software.bernie.geckolib3.core.PlayState) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) IAnimatable(software.bernie.geckolib3.core.IAnimatable) IModelData(net.minecraftforge.client.model.data.IModelData) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) AtlasTexture(net.minecraft.client.renderer.texture.AtlasTexture) Animation(software.bernie.geckolib3.core.builder.Animation) Set(java.util.Set) AnimationFile(software.bernie.geckolib3.file.AnimationFile) Objects(java.util.Objects) IGeoRenderer(software.bernie.geckolib3.renderers.geo.IGeoRenderer) List(java.util.List) Vector3f(net.minecraft.util.math.vector.Vector3f) AnimatedGeoModel(software.bernie.geckolib3.model.AnimatedGeoModel) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) GeoModelProvider(software.bernie.geckolib3.model.provider.GeoModelProvider) RenderUtils(software.bernie.geckolib3.util.RenderUtils) OverlayTexture(net.minecraft.client.renderer.texture.OverlayTexture) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) AnimationController(software.bernie.geckolib3.core.controller.AnimationController) ItemCameraTransforms(net.minecraft.client.renderer.model.ItemCameraTransforms) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) IRenderTypeBuffer(net.minecraft.client.renderer.IRenderTypeBuffer) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Supplier(java.util.function.Supplier) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) Nonnull(javax.annotation.Nonnull) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) GeoModel(software.bernie.geckolib3.geo.render.built.GeoModel) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) RenderType(net.minecraft.client.renderer.RenderType) BlockPos(net.minecraft.util.math.BlockPos) AnimationFactory(software.bernie.geckolib3.core.manager.AnimationFactory) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) File(java.io.File) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) IComponent(com.lowdragmc.multiblocked.api.tile.IComponent) BakedQuad(net.minecraft.client.renderer.model.BakedQuad) GeoCube(software.bernie.geckolib3.geo.render.built.GeoCube) ResourceLocation(net.minecraft.util.ResourceLocation) IAnimatableModel(software.bernie.geckolib3.core.IAnimatableModel) GeckoLibCache(software.bernie.geckolib3.resource.GeckoLibCache) AnimationEvent(software.bernie.geckolib3.core.event.predicate.AnimationEvent) TileEntity(net.minecraft.tileentity.TileEntity) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) Collections(java.util.Collections) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) AnimationFile(software.bernie.geckolib3.file.AnimationFile) File(java.io.File) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)

Aggregations

TextFieldWidget (com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)11 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)10 LabelWidget (com.lowdragmc.lowdraglib.gui.widget.LabelWidget)7 JsonObject (com.google.gson.JsonObject)6 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)6 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)6 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)6 IO (com.lowdragmc.multiblocked.api.capability.IO)6 List (java.util.List)6 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)5 Position (com.lowdragmc.lowdraglib.utils.Position)5 Size (com.lowdragmc.lowdraglib.utils.Size)5 Nullable (javax.annotation.Nullable)5 JSONUtils (net.minecraft.util.JSONUtils)5 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)4 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)4 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)4 LocalizationUtils (com.lowdragmc.lowdraglib.utils.LocalizationUtils)4 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)4 Nonnull (javax.annotation.Nonnull)4