Search in sources :

Example 1 with MessagePopup

use of org.terasology.rendering.nui.layers.mainMenu.MessagePopup in project Terasology by MovingBlocks.

the class CoreCommands method join.

/**
 * Join a game
 * @param address String containing address of game server
 * @param portParam Integer containing game server port
 */
@Command(shortDescription = "Join a game", requiredPermission = PermissionManager.NO_PERMISSION)
public void join(@CommandParam("address") final String address, @CommandParam(value = "port", required = false) Integer portParam) {
    final int port = portParam != null ? portParam : TerasologyConstants.DEFAULT_PORT;
    Callable<JoinStatus> operation = () -> networkSystem.join(address, port);
    final WaitPopup<JoinStatus> popup = nuiManager.pushScreen(WaitPopup.ASSET_URI, WaitPopup.class);
    popup.setMessage("Join Game", "Connecting to '" + address + ":" + port + "' - please wait ...");
    popup.onSuccess(result -> {
        if (result.getStatus() != JoinStatus.Status.FAILED) {
            gameEngine.changeState(new StateLoading(result));
        } else {
            MessagePopup screen = nuiManager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
            screen.setMessage("Failed to Join", "Could not connect to server - " + result.getErrorMessage());
        }
    });
    popup.startOperation(operation, true);
}
Also used : StateLoading(org.terasology.engine.modes.StateLoading) MessagePopup(org.terasology.rendering.nui.layers.mainMenu.MessagePopup) JoinStatus(org.terasology.network.JoinStatus) Command(org.terasology.logic.console.commandSystem.annotations.Command) ConsoleCommand(org.terasology.logic.console.commandSystem.ConsoleCommand)

Example 2 with MessagePopup

use of org.terasology.rendering.nui.layers.mainMenu.MessagePopup in project Terasology by MovingBlocks.

the class SelectModulesScreen 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.rendering.nui.layers.mainMenu.ConfirmPopup) DependencyResolutionFailedException(org.terasology.engine.module.DependencyResolutionFailedException) MessagePopup(org.terasology.rendering.nui.layers.mainMenu.MessagePopup) Module(org.terasology.module.Module)

Aggregations

MessagePopup (org.terasology.rendering.nui.layers.mainMenu.MessagePopup)2 StateLoading (org.terasology.engine.modes.StateLoading)1 DependencyResolutionFailedException (org.terasology.engine.module.DependencyResolutionFailedException)1 ConsoleCommand (org.terasology.logic.console.commandSystem.ConsoleCommand)1 Command (org.terasology.logic.console.commandSystem.annotations.Command)1 Module (org.terasology.module.Module)1 JoinStatus (org.terasology.network.JoinStatus)1 ConfirmPopup (org.terasology.rendering.nui.layers.mainMenu.ConfirmPopup)1