Search in sources :

Example 1 with ConfirmPopup

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));
}
Also used : ConfirmPopup(org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup) DependencyResolutionFailedException(org.terasology.engine.core.module.DependencyResolutionFailedException) MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup) Module(org.terasology.gestalt.module.Module)

Example 2 with ConfirmPopup

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));
}
Also used : ConfirmPopup(org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup) DependencyResolutionFailedException(org.terasology.engine.core.module.DependencyResolutionFailedException) MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup) Module(org.terasology.gestalt.module.Module)

Example 3 with ConfirmPopup

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);
    }
}
Also used : ConfirmPopup(org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup)

Example 4 with ConfirmPopup

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();
        }
    });
}
Also used : ConfirmPopup(org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup) MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup) FilePickerPopup(org.terasology.engine.rendering.nui.layers.mainMenu.FilePickerPopup) Map(java.util.Map) BufferedWriter(java.io.BufferedWriter)

Aggregations

ConfirmPopup (org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup)4 MessagePopup (org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup)3 DependencyResolutionFailedException (org.terasology.engine.core.module.DependencyResolutionFailedException)2 Module (org.terasology.gestalt.module.Module)2 BufferedWriter (java.io.BufferedWriter)1 Map (java.util.Map)1 FilePickerPopup (org.terasology.engine.rendering.nui.layers.mainMenu.FilePickerPopup)1