use of gregtech.common.terminal.app.guide.GuideApp in project GregTech by GregTechCEu.
the class GuideConfigEditor method loadJson.
public void loadJson() {
if (pageEditor != null) {
File file = new File(TerminalRegistry.TERMINAL_PATH, "guide");
TerminalDialogWidget.showFileDialog(app.getOs(), "terminal.component.load_file", file, true, result -> {
if (result != null && result.isFile()) {
try {
JsonObject config = Objects.requireNonNull(FileUtility.loadJson(result)).getAsJsonObject();
pageEditor.loadJsonConfig(config);
getPageEditor().setSection(config.get("section").getAsString());
updateTitle(config.get("title").getAsString());
for (AbstractApplication app : TerminalRegistry.getAllApps()) {
if (app instanceof GuideApp) {
Object object = ((GuideApp<?>) app).ofJson(config);
if (object != null) {
type = app.getUnlocalizedName();
if (object instanceof ItemGuideApp.GuideItem) {
handler.setStackInSlot(0, ((ItemGuideApp.GuideItem) object).stack.copy());
} else if (object instanceof MetaTileEntity) {
handler.setStackInSlot(0, ((MetaTileEntity) object).getStackForm());
} else if (object instanceof ItemStack) {
handler.setStackInSlot(0, ((ItemStack) object).copy());
} else {
handler.setStackInSlot(0, ItemStack.EMPTY);
}
break;
}
}
}
} catch (Exception e) {
TerminalDialogWidget.showInfoDialog(app.getOs(), "terminal.component.error", "terminal.component.load_file.error").setClientSide().open();
}
}
}).setClientSide().open();
}
}
Aggregations