Search in sources :

Example 6 with ButtonWidget

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

the class PredicateBlocks 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 = Arrays.stream(blocks).map(Block::defaultBlockState).collect(Collectors.toList());
    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.blocks.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) 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 ButtonWidget

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

the class PredicateStates method addBlockSelectorWidget.

private void addBlockSelectorWidget(List<BlockState> blockList, DraggableScrollableWidgetGroup container, BlockState blockState) {
    BlockSelectorWidget bsw = new BlockSelectorWidget(0, container.widgets.size() * 21 + 1, true);
    container.addWidget(bsw);
    bsw.addWidget(new ButtonWidget(163, 1, 18, 18, cd -> {
        int index = (bsw.getSelfPosition().y - 1) / 21;
        blockList.remove(index);
        updateStates(blockList);
        for (int i = index + 1; i < container.widgets.size(); i++) {
            container.widgets.get(i).addSelfPosition(0, -21);
        }
        container.waitToRemoved(bsw);
    }).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/remove.png")).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.tips.remove"));
    if (blockState != null) {
        bsw.setBlock(blockState);
    }
    bsw.setOnBlockStateUpdate(state -> {
        int index = (bsw.getSelfPosition().y - 1) / 21;
        blockList.set(index, state);
        updateStates(blockList);
    });
}
Also used : BlockSelectorWidget(com.lowdragmc.lowdraglib.gui.widget.BlockSelectorWidget) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)

Example 8 with ButtonWidget

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

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

the class GTRenderer method addTextureSelector.

protected void addTextureSelector(int x, int y, int width, int height, String text, WidgetGroup parent, WidgetGroup group, ResourceLocation init, Consumer<ResourceLocation> newTexture) {
    ImageWidget imageWidget;
    if (init != null) {
        imageWidget = new ImageWidget(x, y, width, height, new GuiTextureGroup(new ColorBorderTexture(1, -1), new ResourceTexture(init.getNamespace() + ":textures/" + init.getPath() + ".png")));
    } else {
        imageWidget = new ImageWidget(x, y, width, height, new ColorBorderTexture(1, -1));
    }
    group.addWidget(imageWidget);
    group.addWidget(new ButtonWidget(x, y, width, height, null, cd -> new ResourceTextureWidget(parent, texture -> {
        if (texture != null) {
            imageWidget.setImage(new GuiTextureGroup(new ColorBorderTexture(1, -1), texture));
            newTexture.accept(new ResourceLocation(texture.imageLocation.toString().replace("textures/", "").replace(".png", "")));
        }
    })).setHoverTexture(new ColorRectTexture(0x4faaaaaa)).setHoverTooltips(String.format("select the %s texture", text)));
}
Also used : JsonObject(com.google.gson.JsonObject) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) CustomBakedModel(com.lowdragmc.lowdraglib.client.model.custommodel.CustomBakedModel) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) Random(java.util.Random) Direction(net.minecraft.util.Direction) Supplier(java.util.function.Supplier) BlockModel(net.minecraft.client.renderer.model.BlockModel) Dist(net.minecraftforge.api.distmarker.Dist) Minecraft(net.minecraft.client.Minecraft) Gson(com.google.gson.Gson) IBlockDisplayReader(net.minecraft.world.IBlockDisplayReader) BlockState(net.minecraft.block.BlockState) ModelLoader(net.minecraftforge.client.model.ModelLoader) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) Nonnull(javax.annotation.Nonnull) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) EnumMap(java.util.EnumMap) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) IPartComponent(com.lowdragmc.multiblocked.api.tile.part.IPartComponent) IModelData(net.minecraftforge.client.model.data.IModelData) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) AtlasTexture(net.minecraft.client.renderer.texture.AtlasTexture) ModelFactory(com.lowdragmc.lowdraglib.client.model.ModelFactory) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) IControllerComponent(com.lowdragmc.multiblocked.api.tile.IControllerComponent) BlockPos(net.minecraft.util.math.BlockPos) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) BakedQuad(net.minecraft.client.renderer.model.BakedQuad) Consumer(java.util.function.Consumer) List(java.util.List) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) IUnbakedModel(net.minecraft.client.renderer.model.IUnbakedModel) TileEntity(net.minecraft.tileentity.TileEntity) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) Collections(java.util.Collections) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)

Example 10 with ButtonWidget

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

ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)20 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)19 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)15 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)11 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)10 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)10 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)9 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)8 ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)6 TextFieldWidget (com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)6 Multiblocked (com.lowdragmc.multiblocked.Multiblocked)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 JsonObject (com.google.gson.JsonObject)5 File (java.io.File)5 JsonElement (com.google.gson.JsonElement)4 GuiTextureGroup (com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)4 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)4 DraggableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup)4 LabelWidget (com.lowdragmc.lowdraglib.gui.widget.LabelWidget)4 IMultiblockedRenderer (com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer)4