Search in sources :

Example 11 with ColorRectTexture

use of com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture in project Multiblocked by Low-Drag-MC.

the class PredicateStates method getConfigWidget.

@Override
public List<WidgetGroup> getConfigWidget(List<WidgetGroup> groups) {
    super.getConfigWidget(groups);
    WidgetGroup group = new WidgetGroup(0, 0, 182, 100);
    groups.add(group);
    DraggableScrollableWidgetGroup container = new DraggableScrollableWidgetGroup(0, 25, 182, 80).setBackground(new ColorRectTexture(0xffaaaaaa));
    group.addWidget(container);
    List<BlockState> blockList = new ArrayList<>(Arrays.asList(states));
    for (BlockState blockState : blockList) {
        addBlockSelectorWidget(blockList, container, blockState);
    }
    group.addWidget(new LabelWidget(0, 6, "multiblocked.gui.label.block_settings"));
    group.addWidget(new ButtonWidget(162, 0, 20, 20, cd -> {
        blockList.add(null);
        addBlockSelectorWidget(blockList, container, null);
    }).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/add.png")).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.predicate.states.add"));
    return groups;
}
Also used : BlockState(net.minecraft.block.BlockState) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) ArrayList(java.util.ArrayList) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)

Example 12 with ColorRectTexture

use of com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture 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)));
}
Also used : JsonObject(com.google.gson.JsonObject) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) CustomBakedModel(com.lowdragmc.lowdraglib.client.model.custommodel.CustomBakedModel) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) Random(java.util.Random) Direction(net.minecraft.util.Direction) Supplier(java.util.function.Supplier) BlockModel(net.minecraft.client.renderer.model.BlockModel) Dist(net.minecraftforge.api.distmarker.Dist) Minecraft(net.minecraft.client.Minecraft) Gson(com.google.gson.Gson) IBlockDisplayReader(net.minecraft.world.IBlockDisplayReader) BlockState(net.minecraft.block.BlockState) ModelLoader(net.minecraftforge.client.model.ModelLoader) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) Nonnull(javax.annotation.Nonnull) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) EnumMap(java.util.EnumMap) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) IPartComponent(com.lowdragmc.multiblocked.api.tile.part.IPartComponent) IModelData(net.minecraftforge.client.model.data.IModelData) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) AtlasTexture(net.minecraft.client.renderer.texture.AtlasTexture) ModelFactory(com.lowdragmc.lowdraglib.client.model.ModelFactory) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) IControllerComponent(com.lowdragmc.multiblocked.api.tile.IControllerComponent) BlockPos(net.minecraft.util.math.BlockPos) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) BakedQuad(net.minecraft.client.renderer.model.BakedQuad) Consumer(java.util.function.Consumer) List(java.util.List) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) IUnbakedModel(net.minecraft.client.renderer.model.IUnbakedModel) TileEntity(net.minecraft.tileentity.TileEntity) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) Collections(java.util.Collections) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)

Example 13 with ColorRectTexture

use of com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture 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"));
}
Also used : Ingredient(net.minecraft.item.crafting.Ingredient) Arrays(java.util.Arrays) TagCollectionManager(net.minecraft.tags.TagCollectionManager) LocalizationUtils(com.lowdragmc.lowdraglib.utils.LocalizationUtils) Item(net.minecraft.item.Item) ItemsIngredient(com.lowdragmc.multiblocked.api.recipe.ItemsIngredient) ArrayUtils(org.apache.commons.lang3.ArrayUtils) PhantomSlotWidget(com.lowdragmc.lowdraglib.gui.widget.PhantomSlotWidget) SlotWidget(com.lowdragmc.lowdraglib.gui.widget.SlotWidget) ResourceBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ItemStack(net.minecraft.item.ItemStack) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) CycleItemStackHandler(com.lowdragmc.lowdraglib.utils.CycleItemStackHandler) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ContentWidget(com.lowdragmc.multiblocked.api.gui.recipe.ContentWidget) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) Collection(java.util.Collection) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) SwitchWidget(com.lowdragmc.lowdraglib.gui.widget.SwitchWidget) Items(net.minecraft.item.Items) Collectors(java.util.stream.Collectors) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) List(java.util.List) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ITagCollection(net.minecraft.tags.ITagCollection) ItemStackHandler(net.minecraftforge.items.ItemStackHandler) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) Collections(java.util.Collections) CycleItemStackHandler(com.lowdragmc.lowdraglib.utils.CycleItemStackHandler) ItemStackHandler(net.minecraftforge.items.ItemStackHandler) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) SwitchWidget(com.lowdragmc.lowdraglib.gui.widget.SwitchWidget) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) PhantomSlotWidget(com.lowdragmc.lowdraglib.gui.widget.PhantomSlotWidget) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) ItemsIngredient(com.lowdragmc.multiblocked.api.recipe.ItemsIngredient) ResourceLocation(net.minecraft.util.ResourceLocation) ITagCollection(net.minecraft.tags.ITagCollection) Collection(java.util.Collection) ITagCollection(net.minecraft.tags.ITagCollection) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) ItemStack(net.minecraft.item.ItemStack)

Example 14 with ColorRectTexture

use of com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture in project Multiblocked by Low-Drag-MC.

the class ControllerBuilderWidget method updateList.

protected void updateList() {
    int size = files.size();
    files.forEach(containers::waitToRemoved);
    files.clear();
    File path = new File(Multiblocked.location, "definition/controller");
    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, (containers.widgets.size() - size) * 22, containers.getSize().width, 20).setSelectedTexture(-2, 0xff00aa00).setOnSelected(W -> {
            templateButton.setVisible(false);
            selected = null;
            onJsonSelected(file);
        }).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) {
                try {
                    String recipeMap = jsonElement.getAsJsonObject().get("recipeMap").getAsString();
                    JsonBlockPattern pattern = Multiblocked.GSON.fromJson(jsonElement.getAsJsonObject().get("basePattern"), JsonBlockPattern.class);
                    ControllerDefinition definition = Multiblocked.GSON.fromJson(jsonElement, ControllerDefinition.class);
                    new ControllerWidget(this, definition, pattern, recipeMap, jsonObject -> {
                        if (jsonObject != null) {
                            FileUtility.saveJson(file, jsonObject);
                        }
                    });
                } 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, new ItemStackTexture(Items.PAPER)));
        files.add(widgetGroup);
        containers.addWidget(widgetGroup);
    }
}
Also used : Arrays(java.util.Arrays) PredicateComponent(com.lowdragmc.multiblocked.api.pattern.predicates.PredicateComponent) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) AtomicDouble(com.google.common.util.concurrent.AtomicDouble) JsonBlockPattern(com.lowdragmc.multiblocked.api.pattern.JsonBlockPattern) Direction(net.minecraft.util.Direction) ItemBlueprint(com.lowdragmc.multiblocked.api.item.ItemBlueprint) BlueprintTableTileEntity(com.lowdragmc.multiblocked.api.tile.BlueprintTableTileEntity) Dist(net.minecraftforge.api.distmarker.Dist) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) ClickData(com.lowdragmc.lowdraglib.gui.util.ClickData) MBDBlockStateRenderer(com.lowdragmc.multiblocked.client.renderer.impl.MBDBlockStateRenderer) I18n(net.minecraft.client.resources.I18n) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) BlockInfo(com.lowdragmc.lowdraglib.utils.BlockInfo) Minecraft(net.minecraft.client.Minecraft) Map(java.util.Map) DummyComponentTileEntity(com.lowdragmc.multiblocked.api.tile.DummyComponentTileEntity) 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) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) ItemStackTexture(com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture) TrackedDummyWorld(com.lowdragmc.lowdraglib.utils.TrackedDummyWorld) World(net.minecraft.world.World) Set(java.util.Set) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) ControllerWidget(com.lowdragmc.multiblocked.api.gui.blueprint_table.components.ControllerWidget) File(java.io.File) List(java.util.List) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ControllerDefinition(com.lowdragmc.multiblocked.api.definition.ControllerDefinition) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) ResourceLocation(net.minecraft.util.ResourceLocation) SimplePredicate(com.lowdragmc.multiblocked.api.pattern.predicates.SimplePredicate) Optional(java.util.Optional) FileUtility(com.lowdragmc.lowdraglib.utils.FileUtility) TileEntity(net.minecraft.tileentity.TileEntity) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) PacketBuffer(net.minecraft.network.PacketBuffer) ItemStackTexture(com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ControllerWidget(com.lowdragmc.multiblocked.api.gui.blueprint_table.components.ControllerWidget) SelectableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ItemBlueprint(com.lowdragmc.multiblocked.api.item.ItemBlueprint) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) JsonBlockPattern(com.lowdragmc.multiblocked.api.pattern.JsonBlockPattern) ControllerDefinition(com.lowdragmc.multiblocked.api.definition.ControllerDefinition) JsonElement(com.google.gson.JsonElement) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) File(java.io.File)

Example 15 with ColorRectTexture

use of com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture in project Multiblocked by Low-Drag-MC.

the class RecipeMapBuilderWidget method updateRecipeMapList.

private void updateRecipeMapList() {
    recipeMapList.clearAllWidgets();
    if (onRecipeMapSelected != null) {
        onRecipeMapSelected.accept(RecipeMap.EMPTY);
    }
    selected = null;
    File path = new File(Multiblocked.location, "recipe_map");
    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")) {
            recipeMapList.addWidget(new SelectableWidgetGroup(5, 1 + recipeMapList.widgets.size() * 22, getSize().width - 30, 20).setSelectedTexture(-2, 0xff00aa00).setOnSelected(W -> {
                selected = file;
                if (onRecipeMapSelected != null) {
                    onRecipeMapSelected.accept(Multiblocked.GSON.fromJson(FileUtility.loadJson(file), RecipeMap.class));
                }
            }).addWidget(new ImageWidget(0, 0, 120, 20, new ColorRectTexture(0x4faaaaaa))).addWidget(new ButtonWidget(104, 4, 12, 12, new ResourceTexture("multiblocked:textures/gui/option.png"), cd -> new RecipeMapWidget(parent, Multiblocked.GSON.fromJson(FileUtility.loadJson(file), RecipeMap.class), recipeMap -> {
                if (recipeMap != null) {
                    if (selected == file) {
                        if (onRecipeMapSelected != null) {
                            onRecipeMapSelected.accept(recipeMap);
                        }
                    }
                    JsonElement element = Multiblocked.GSON.toJsonTree(recipeMap);
                    FileUtility.saveJson(file, element);
                }
            })).setHoverBorderTexture(1, -1).setHoverTooltips("multiblocked.gui.tips.settings")).addWidget(new ImageWidget(2, 0, 96, 20, new TextTexture(file.getName().replace(".json", "")).setWidth(96).setType(TextTexture.TextType.ROLL))));
        }
    }
}
Also used : SelectableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup) RecipeMap(com.lowdragmc.multiblocked.api.recipe.RecipeMap) Desktop(java.awt.Desktop) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) RecipeMapWidget(com.lowdragmc.multiblocked.api.gui.dialogs.RecipeMapWidget) IOException(java.io.IOException) UUID(java.util.UUID) ResourceBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) File(java.io.File) JsonElement(com.google.gson.JsonElement) Consumer(java.util.function.Consumer) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) Optional(java.util.Optional) FileUtility(com.lowdragmc.lowdraglib.utils.FileUtility) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) RecipeMapWidget(com.lowdragmc.multiblocked.api.gui.dialogs.RecipeMapWidget) SelectableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup) JsonElement(com.google.gson.JsonElement) 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) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) RecipeMap(com.lowdragmc.multiblocked.api.recipe.RecipeMap)

Aggregations

ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)24 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)18 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)17 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)17 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)13 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)10 ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)9 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)9 GuiTextureGroup (com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)8 SelectorWidget (com.lowdragmc.lowdraglib.gui.widget.SelectorWidget)7 JsonElement (com.google.gson.JsonElement)6 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)6 SelectableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup)6 Multiblocked (com.lowdragmc.multiblocked.Multiblocked)6 ItemStack (net.minecraft.item.ItemStack)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)5 DraggableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableWidgetGroup)5 LabelWidget (com.lowdragmc.lowdraglib.gui.widget.LabelWidget)5 List (java.util.List)5