Search in sources :

Example 6 with SelectableWidgetGroup

use of com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup in project Multiblocked by Low-Drag-MC.

the class PartScriptWidget method updateList.

private void updateList() {
    jsonList.clearAllWidgets();
    selected = null;
    File path = new File(Multiblocked.location, "definition/part");
    if (!path.isDirectory()) {
        if (!path.mkdirs()) {
            return;
        }
    }
    for (File file : Optional.ofNullable(path.listFiles()).orElse(new File[0])) {
        if (file.isFile() && file.getName().endsWith(".json")) {
            jsonList.addWidget(new SelectableWidgetGroup(0, 1 + jsonList.widgets.size() * 11, jsonList.getSize().width, 10).setSelectedTexture(-1, -1).setOnSelected(W -> selected = file).addWidget(new ImageWidget(0, 0, jsonList.getSize().width, 10, new ColorRectTexture(0xff000000))).addWidget(new ImageWidget(0, 0, jsonList.getSize().width, 10, new TextTexture(file.getName().replace(".json", "")).setWidth(jsonList.getSize().width).setType(TextTexture.TextType.ROLL))));
        }
    }
}
Also used : ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) ResourceBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture) TabContainer(com.lowdragmc.lowdraglib.gui.widget.TabContainer) JsonElement(com.google.gson.JsonElement) ClickData(com.lowdragmc.lowdraglib.gui.util.ClickData) TextBoxWidget(com.lowdragmc.lowdraglib.gui.widget.TextBoxWidget) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) SelectableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup) Desktop(java.awt.Desktop) MbdComponents(com.lowdragmc.multiblocked.api.registry.MbdComponents) PartDefinition(com.lowdragmc.multiblocked.api.definition.PartDefinition) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) PartTileTesterEntity(com.lowdragmc.multiblocked.api.tile.part.PartTileTesterEntity) IOException(java.io.IOException) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) File(java.io.File) PageWidget(com.lowdragmc.multiblocked.api.gui.controller.PageWidget) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) Optional(java.util.Optional) FileUtility(com.lowdragmc.lowdraglib.utils.FileUtility) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) Collections(java.util.Collections) PacketBuffer(net.minecraft.network.PacketBuffer) SelectableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) File(java.io.File)

Aggregations

ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)6 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)6 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)6 SelectableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup)6 JsonElement (com.google.gson.JsonElement)5 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)5 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)5 File (java.io.File)5 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)4 FileUtility (com.lowdragmc.lowdraglib.utils.FileUtility)4 Multiblocked (com.lowdragmc.multiblocked.Multiblocked)4 Desktop (java.awt.Desktop)4 Optional (java.util.Optional)4 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)3 ClickData (com.lowdragmc.lowdraglib.gui.util.ClickData)3 MbdComponents (com.lowdragmc.multiblocked.api.registry.MbdComponents)3 IOException (java.io.IOException)3 PacketBuffer (net.minecraft.network.PacketBuffer)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 ItemStackTexture (com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture)2