use of org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup in project Terasology by MovingBlocks.
the class ModuleDetailsScreen method startDownloadingNewestModulesRequiredFor.
private void startDownloadingNewestModulesRequiredFor(final DependencyInfo dependencyInfo) {
final Set<Module> modulesToDownload;
try {
modulesToDownload = moduleManager.getInstallManager().getAllModulesToDownloadFor(dependencyInfo.getId());
} catch (DependencyResolutionFailedException ex) {
MessagePopup messagePopup = getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
messagePopup.setMessage("Error", ex.getMessage());
return;
}
final ConfirmPopup confirmPopup = getManager().pushScreen(ConfirmPopup.ASSET_URI, ConfirmPopup.class);
confirmPopup.setMessage("Confirm Download", modulesToDownload.size() + " modules will be downloaded");
confirmPopup.setOkHandler(() -> downloadModules(modulesToDownload));
}
use of org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup in project Terasology by MovingBlocks.
the class AdvancedGameSetupScreen method startDownloadingNewestModulesRequiredFor.
private void startDownloadingNewestModulesRequiredFor(ModuleSelectionInfo moduleMetadata) {
Set<Module> modulesToDownload;
try {
modulesToDownload = moduleManager.getInstallManager().getAllModulesToDownloadFor(moduleMetadata.getMetadata().getId());
} catch (DependencyResolutionFailedException ex) {
MessagePopup messagePopup = getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
messagePopup.setMessage("Error", ex.getMessage());
return;
}
ConfirmPopup confirmPopup = getManager().pushScreen(ConfirmPopup.ASSET_URI, ConfirmPopup.class);
confirmPopup.setMessage("Confirm Download", modulesToDownload.size() + " modules will be downloaded");
confirmPopup.setOkHandler(() -> downloadModules(modulesToDownload));
}
use of org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup in project Terasology by MovingBlocks.
the class AbstractEditorScreen method resetState.
/**
* Resets the editor's state based on a specified {@link JsonTree}.
*
* @param node The {@link JsonTree} to reset the state from.
*/
protected void resetState(JsonTree node) {
if (unsavedChangesPresent) {
ConfirmPopup confirmPopup = getManager().pushScreen(ConfirmPopup.ASSET_URI, ConfirmPopup.class);
confirmPopup.setMessage("Unsaved changes!", "It looks like you've been editing something!" + "\r\nAll unsaved changes will be lost. Continue anyway?");
confirmPopup.setOkHandler(() -> {
setUnsavedChangesPresent(false);
deleteAutosave();
resetStateInternal(node);
});
} else {
resetStateInternal(node);
}
}
use of org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup in project Terasology by MovingBlocks.
the class IdentityIOHelper method exportIdentities.
public void exportIdentities() {
FilePickerPopup filePicker = nuiManager.pushScreen(FilePickerPopup.ASSET_URI, FilePickerPopup.class);
filePicker.setTitle(exportPopupTitle);
filePicker.setOkHandler(path -> {
Runnable action = () -> {
Map<PublicIdentityCertificate, ClientIdentity> identities = securityConfig.getAllIdentities();
try (BufferedWriter writer = Files.newBufferedWriter(path, StandardOpenOption.CREATE)) {
GSON.toJson(identities, MAP_TYPE, writer);
nuiManager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage(exportPopupTitle, String.format(translationSystem.translate("${engine:menu#identity-export-ok}"), identities.size(), path.toString()));
} catch (IOException | JsonIOException ex) {
nuiManager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage(translationSystem.translate("${engine:menu#identity-export-fail}"), ex.toString());
}
};
if (Files.exists(path)) {
ConfirmPopup confirm = nuiManager.pushScreen(ConfirmPopup.ASSET_URI, ConfirmPopup.class);
confirm.setMessage(exportPopupTitle, String.format(translationSystem.translate("${engine:menu#existing-file-warning}"), path.toString()));
confirm.setOkHandler(action);
} else {
action.run();
}
});
}
Aggregations