use of com.lowdragmc.multiblocked.api.gui.dialogs.RecipeMapWidget 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))));
}
}
}
Aggregations