use of com.lowdragmc.lowdraglib.gui.texture.TextTexture in project Multiblocked by Low-Drag-MC.
the class PartBuilderWidget method initScene.
@OnlyIn(Dist.CLIENT)
private void initScene() {
TrackedDummyWorld world = new TrackedDummyWorld();
world.addBlock(BlockPos.ZERO, BlockInfo.fromBlockState(MbdComponents.DummyComponentBlock.defaultBlockState()));
tileEntity = (DummyComponentTileEntity) world.getBlockEntity(BlockPos.ZERO);
this.addWidget(new ImageWidget(30, 59, 138, 138, new GuiTextureGroup(new ColorBorderTexture(3, -1), new ColorRectTexture(0xaf444444))));
this.addWidget(new SceneWidget(30, 59, 138, 138, world).setRenderedCore(Collections.singleton(BlockPos.ZERO), null).setRenderSelect(false).setRenderFacing(false));
this.addWidget(new ImageWidget(30, 65, 138, 15, textTexture = new TextTexture("", 0xff00ff00).setDropShadow(true).setWidth(138).setType(TextTexture.TextType.ROLL)));
}
use of com.lowdragmc.lowdraglib.gui.texture.TextTexture 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.TextTexture in project Multiblocked by Low-Drag-MC.
the class PlayerCapabilityTrait method initSettingDialog.
protected void initSettingDialog(DialogWidget dialog, DraggableWidgetGroup slot) {
ImageWidget imageWidget = (ImageWidget) slot.widgets.get(0);
ButtonWidget setting = (ButtonWidget) slot.widgets.get(1);
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);
((TextTexture) imageWidget.getImage()).setWidth(width);
setting.setSelfPosition(new Position(width - 8, 0));
}).setCurrentString(width + "").setNumbersOnly(10, 180).setHoverTooltips("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);
setting.setSelfPosition(new Position(width - 8, 0));
}).setCurrentString(height + "").setNumbersOnly(10, 180).setHoverTooltips("set height"));
dialog.addWidget(new SelectorWidget(5, 5, 50, 15, Arrays.stream(TextTexture.TextType.values()).map(Enum::name).collect(Collectors.toList()), -1).setValue(textType.name()).setOnChanged(io -> {
textType = TextTexture.TextType.valueOf(io);
((TextTexture) imageWidget.getImage()).setType(textType);
}).setButtonBackground(ResourceBorderTexture.BUTTON_COMMON).setBackground(new ColorRectTexture(0xffaaaaaa)).setHoverTooltips("TextType"));
}
use of com.lowdragmc.lowdraglib.gui.texture.TextTexture 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.TextTexture 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