use of com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget 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.multiblocked.api.gui.dialogs.ResourceTextureWidget in project Multiblocked by Low-Drag-MC.
the class ProgressCapabilityTrait method initSettingDialog.
@Override
protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot) {
ImageWidget imageWidget = (ImageWidget) slot.widgets.get(0);
ButtonWidget setting = (ButtonWidget) slot.widgets.get(1);
ButtonWidget imageSelector = (ButtonWidget) new ButtonWidget(5, 65, width, height, new GuiTextureGroup(new ColorBorderTexture(1, -1), new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5)), null).setHoverTooltips("multiblocked.gui.tips.select_image");
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);
imageSelector.setSize(size);
setting.setSelfPosition(new Position(width - 8, 0));
}).setCurrentString(width + "").setNumbersOnly(1, 180).setHoverTooltips("multiblocked.gui.trait.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);
imageSelector.setSize(size);
setting.setSelfPosition(new Position(width - 8, 0));
}).setCurrentString(height + "").setNumbersOnly(1, 180).setHoverTooltips("multiblocked.gui.trait.set_height"));
dialog.addWidget(new SelectorWidget(5, 5, 50, 15, Arrays.stream(IO.VALUES).map(Enum::name).collect(Collectors.toList()), -1).setValue(capabilityIO.name()).setOnChanged(io -> {
capabilityIO = IO.valueOf(io);
imageWidget.setImage(new GuiTextureGroup(new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5), new ColorBorderTexture(1, getColorByIO(capabilityIO))));
}).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("multiblocked.gui.trait.capability_io"));
dialog.addWidget(imageSelector);
imageSelector.setOnPressCallback(cd -> new ResourceTextureWidget(dialog.getParent().getGui().mainGroup, texture1 -> {
if (texture1 != null) {
texture = texture1.imageLocation.toString();
ResourceTexture resourceTexture = new ResourceTexture(texture).getSubTexture(0, 0, 1, 0.5);
imageSelector.setButtonTexture(new GuiTextureGroup(new ColorBorderTexture(1, -1), resourceTexture));
imageWidget.setImage(new GuiTextureGroup(resourceTexture, new ColorBorderTexture(1, getColorByIO(capabilityIO))));
}
}));
}
Aggregations