Search in sources :

Example 1 with BlockSelectorWidget

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

the class PredicateBlocks method addBlockSelectorWidget.

private void addBlockSelectorWidget(List<BlockState> blockList, DraggableScrollableWidgetGroup container, BlockState blockState) {
    BlockSelectorWidget bsw = new BlockSelectorWidget(0, container.widgets.size() * 21 + 1, false);
    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 2 with BlockSelectorWidget

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

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

the class MBDBlockStateRenderer method createConfigurator.

@Override
public Supplier<IMultiblockedRenderer> createConfigurator(WidgetGroup parent, DraggableScrollableWidgetGroup group, IMultiblockedRenderer current) {
    BlockSelectorWidget blockSelectorWidget = new BlockSelectorWidget(0, 1, true);
    if (current instanceof BlockStateRenderer) {
        blockSelectorWidget.setBlock(((BlockStateRenderer) current).blockInfo.getBlockState());
    }
    group.addWidget(blockSelectorWidget);
    return () -> {
        if (blockSelectorWidget.getBlock() == null) {
            return null;
        } else {
            return new MBDBlockStateRenderer(blockSelectorWidget.getBlock());
        }
    };
}
Also used : BlockStateRenderer(com.lowdragmc.lowdraglib.client.renderer.impl.BlockStateRenderer) BlockSelectorWidget(com.lowdragmc.lowdraglib.gui.widget.BlockSelectorWidget)

Aggregations

BlockSelectorWidget (com.lowdragmc.lowdraglib.gui.widget.BlockSelectorWidget)3 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)2 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)2 BlockStateRenderer (com.lowdragmc.lowdraglib.client.renderer.impl.BlockStateRenderer)1