use of com.lowdragmc.lowdraglib.gui.widget.WidgetGroup 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"));
}
use of com.lowdragmc.lowdraglib.gui.widget.WidgetGroup 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));
}
use of com.lowdragmc.lowdraglib.gui.widget.WidgetGroup in project Multiblocked by Low-Drag-MC.
the class MBDIModelRenderer method createConfigurator.
@Override
public Supplier<IMultiblockedRenderer> createConfigurator(WidgetGroup parent, DraggableScrollableWidgetGroup group, IMultiblockedRenderer current) {
TextFieldWidget tfw = new TextFieldWidget(1, 1, 150, 20, null, null);
group.addWidget(tfw);
File path = new File(Multiblocked.location, "assets/multiblocked/models");
group.addWidget(new ButtonWidget(155, 1, 20, 20, cd -> DialogWidget.showFileDialog(parent, "select a java model", path, true, DialogWidget.suffixFilter(".json"), r -> {
if (r != null && r.isFile()) {
tfw.setCurrentString("multiblocked:" + r.getPath().replace(path.getPath(), "").substring(1).replace(".json", "").replace('\\', '/'));
}
})).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/darkened_slot.png"), new TextTexture("F", -1)).setHoverTooltips("multiblocked.gui.tips.file_selector"));
if (current instanceof IModelRenderer && ((IModelRenderer) current).modelLocation != null) {
tfw.setCurrentString(((IModelRenderer) current).modelLocation.toString());
}
return () -> {
if (tfw.getCurrentString().isEmpty()) {
return null;
} else {
return new MBDIModelRenderer(new ResourceLocation(tfw.getCurrentString()));
}
};
}
use of com.lowdragmc.lowdraglib.gui.widget.WidgetGroup in project Multiblocked by Low-Drag-MC.
the class BlueprintTableWidget method recipeMapBuilder.
private void recipeMapBuilder(ClickData clickData) {
widgets.forEach(this::waitToRemoved);
WidgetGroup group = new WidgetGroup(0, 0, getSize().width, getSize().height).setClientSideWidget();
this.addWidget(0, group);
if (clickData.isRemote) {
group.addWidget(0, new ImageWidget(0, 0, getSize().width, getSize().height, new ResourceTexture("multiblocked:textures/gui/blueprint_page.png")));
group.addWidget(new RecipeMapBuilderWidget(this, 200, 31, 150, 188));
}
}
use of com.lowdragmc.lowdraglib.gui.widget.WidgetGroup in project Multiblocked by Low-Drag-MC.
the class ComponentWidget method createScene.
@OnlyIn(Dist.CLIENT)
protected WidgetGroup createScene(int x, int y, String text, String tips, IMultiblockedRenderer init, Consumer<IMultiblockedRenderer> onUpdate) {
TrackedDummyWorld world = new TrackedDummyWorld();
world.addBlock(BlockPos.ZERO, BlockInfo.fromBlockState(MbdComponents.DummyComponentBlock.defaultBlockState()));
DummyComponentTileEntity tileEntity = (DummyComponentTileEntity) world.getBlockEntity(BlockPos.ZERO);
tileEntity.setDefinition(new PartDefinition(new ResourceLocation(Multiblocked.MODID, "component_widget")));
tileEntity.getDefinition().baseRenderer = init;
WidgetGroup widgetGroup = new WidgetGroup(x, y, 90, 90);
widgetGroup.addWidget(new LabelWidget(0, 0, text));
widgetGroup.addWidget(new ImageWidget(0, 12, 90, 80, new ColorBorderTexture(2, 0xff4A82F7)));
widgetGroup.addWidget(new SceneWidget(0, 12, 90, 80, world).setRenderedCore(Collections.singleton(BlockPos.ZERO), null).setRenderSelect(false).setRenderFacing(false));
widgetGroup.addWidget(new ButtonWidget(90 - 15, 12, 15, 15, new ResourceTexture("multiblocked:textures/gui/option.png"), (cd) -> new IRendererWidget(this, tileEntity.getRenderer(), r -> {
tileEntity.getDefinition().baseRenderer = r;
onUpdate.accept(r);
})).setHoverBorderTexture(1, -1).setHoverTooltips(tips));
return widgetGroup;
}
Aggregations