use of com.lowdragmc.lowdraglib.gui.texture.ResourceTexture in project Multiblocked by Low-Drag-MC.
the class PartBuilderWidget method walkFile.
private void walkFile(String type, IGuiTexture icon, File path, BiConsumer<JsonElement, File> consumer) {
if (!path.isDirectory()) {
if (!path.mkdirs()) {
return;
}
}
for (File file : Optional.ofNullable(path.listFiles((s, name) -> name.endsWith(".json"))).orElse(new File[0])) {
SelectableWidgetGroup widgetGroup = (SelectableWidgetGroup) new SelectableWidgetGroup(0, files.size() * 22, containers.getSize().width, 20).setOnSelected(group -> {
JsonElement jsonElement = FileUtility.loadJson(file);
if (jsonElement != null && jsonElement.isJsonObject()) {
try {
setNewRenderer(Multiblocked.GSON.fromJson(jsonElement, PartDefinition.class).baseRenderer, type);
} catch (Exception ignored) {
}
}
}).setSelectedTexture(-2, 0xff00aa00).addWidget(new ImageWidget(0, 0, 150, 20, new ColorRectTexture(0x4faaaaaa))).addWidget(new ButtonWidget(134, 4, 12, 12, new ResourceTexture("multiblocked:textures/gui/option.png"), cd -> {
JsonElement jsonElement = FileUtility.loadJson(file);
if (jsonElement != null && jsonElement.isJsonObject()) {
try {
consumer.accept(jsonElement, file);
} catch (Exception ignored) {
}
}
}).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.tips.settings")).addWidget(new ImageWidget(32, 0, 100, 20, new TextTexture(file.getName().replace(".json", "")).setWidth(100).setType(TextTexture.TextType.ROLL))).addWidget(new ImageWidget(4, 2, 18, 18, icon));
files.add(widgetGroup);
containers.addWidget(widgetGroup);
}
}
use of com.lowdragmc.lowdraglib.gui.texture.ResourceTexture in project Multiblocked by Low-Drag-MC.
the class ComponentWidget method createBoolSwitch.
protected WidgetGroup createBoolSwitch(int x, int y, String text, String tips, boolean init, Consumer<Boolean> onPressed) {
WidgetGroup widgetGroup = new WidgetGroup(x, y, 100, 15);
widgetGroup.addWidget(new SwitchWidget(0, 0, 15, 15, (cd, r) -> onPressed.accept(r)).setBaseTexture(new ResourceTexture("multiblocked:textures/gui/boolean.png").getSubTexture(0, 0, 1, 0.5)).setPressedTexture(new ResourceTexture("multiblocked:textures/gui/boolean.png").getSubTexture(0, 0.5, 1, 0.5)).setHoverTexture(new ColorBorderTexture(1, 0xff545757)).setPressed(init).setHoverTooltips(tips));
widgetGroup.addWidget(new LabelWidget(20, 3, text));
return widgetGroup;
}
use of com.lowdragmc.lowdraglib.gui.texture.ResourceTexture in project Multiblocked by Low-Drag-MC.
the class PlayerCapabilityTrait method refreshSlots.
protected void refreshSlots(DraggableScrollableWidgetGroup dragGroup) {
dragGroup.widgets.forEach(dragGroup::waitToRemoved);
ButtonWidget setting = (ButtonWidget) new ButtonWidget(width - 8, 0, 8, 8, new ResourceTexture("multiblocked:textures/gui/option.png"), null).setHoverBorderTexture(1, -1).setHoverTooltips("settings");
ImageWidget imageWidget = new ImageWidget(0, 0, width, height, new TextTexture("Player Name").setWidth(width).setType(textType).setBackgroundColor(0xff000000));
setting.setVisible(false);
DraggableWidgetGroup slot = new DraggableWidgetGroup(x, y, width, height);
slot.setOnSelected(w -> setting.setVisible(true));
slot.setOnUnSelected(w -> setting.setVisible(false));
slot.addWidget(imageWidget);
slot.addWidget(setting);
slot.setOnEndDrag(b -> {
x = b.getSelfPosition().x;
y = b.getSelfPosition().y;
});
dragGroup.addWidget(slot);
setting.setOnPressCallback(cd2 -> {
DialogWidget dialog = new DialogWidget(dragGroup, true);
dialog.addWidget(new ImageWidget(0, 0, 176, 256, new ColorRectTexture(0xaf000000)));
initSettingDialog(dialog, slot);
});
}
use of com.lowdragmc.lowdraglib.gui.texture.ResourceTexture in project Multiblocked by Low-Drag-MC.
the class ProgressCapabilityTrait method createUI.
@Override
public void createUI(ComponentTileEntity<?> component, WidgetGroup group, PlayerEntity player) {
super.createUI(component, group, player);
group.addWidget(new ProgressWidget(this::getProgress, x, y, width, height, new ResourceTexture(texture)).setDynamicHoverTips(this::dynamicHoverTips));
}
use of com.lowdragmc.lowdraglib.gui.texture.ResourceTexture in project Multiblocked by Low-Drag-MC.
the class ItemsContentWidget method updateIngredientWidget.
private void updateIngredientWidget(DraggableScrollableWidgetGroup container) {
container.widgets.forEach(container::waitToRemoved);
ItemStack[] matchingStacks = ArrayUtils.clone(content.ingredient.getItems());
for (int i = 0; i < matchingStacks.length; i++) {
ItemStack stack = matchingStacks[i];
IItemHandlerModifiable handler;
int finalI = i;
int x = (i % 4) * 30;
int y = (i / 4) * 20;
container.addWidget(new PhantomSlotWidget(handler = new ItemStackHandler(1), 0, x + 1, y + 1).setClearSlotOnRightClick(false).setChangeListener(() -> {
ItemStack newStack = handler.getStackInSlot(0);
matchingStacks[finalI] = newStack;
content = new ItemsIngredient(Ingredient.of(matchingStacks), content.getAmount());
onContentUpdate();
}).setBackgroundTexture(new ColorRectTexture(0xaf444444)));
handler.setStackInSlot(0, stack);
container.addWidget(new ButtonWidget(x + 21, y + 1, 9, 9, cd -> {
content = new ItemsIngredient(Ingredient.of(ArrayUtils.remove(matchingStacks, finalI)), content.getAmount());
updateIngredientWidget(container);
onContentUpdate();
}).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/remove.png")).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.tips.remove"));
}
}
Aggregations