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;
}
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);
});
}
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;
}
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)));
}
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());
}
};
}
Aggregations