Search in sources :

Example 1 with MessagePopup

use of org.terasology.engine.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.core.modes.StateLoading) MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup) JoinStatus(org.terasology.engine.network.JoinStatus) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command) ConsoleCommand(org.terasology.engine.logic.console.commandSystem.ConsoleCommand)

Example 2 with MessagePopup

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

the class ModuleDetailsScreen method onOpened.

@Override
public void onOpened() {
    super.onOpened();
    if (!isScreenValid()) {
        final MessagePopup popup = getManager().createScreen(MessagePopup.ASSET_URI, MessagePopup.class);
        popup.setMessage(translationSystem.translate("${engine:menu#game-details-errors-message-title}"), translationSystem.translate("${engine:menu#game-details-errors-message-body}"));
        popup.subscribeButton(e -> triggerBackAnimation());
        getManager().pushScreen(popup);
        // disable child widgets
        setEnabled(false);
    }
}
Also used : MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup)

Example 3 with MessagePopup

use of org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup 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 4 with MessagePopup

use of org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup 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 5 with MessagePopup

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

the class StateMainMenu method init.

@Override
public void init(GameEngine gameEngine) {
    context = gameEngine.createChildContext();
    headless = context.get(DisplayDevice.class).isHeadless();
    initEntityAndComponentManagers(headless);
    createLocalPlayer(context);
    if (!headless) {
        // TODO: REMOVE this and handle refreshing of core game state at the engine level - see Issue #1127
        new RegisterInputSystem(context).step();
        nuiManager = context.get(NUIManager.class);
        eventSystem.registerEventHandler(nuiManager);
        NUIEditorSystem nuiEditorSystem = new NUIEditorSystem();
        context.put(NUIEditorSystem.class, nuiEditorSystem);
        componentSystemManager.register(nuiEditorSystem, "engine:NUIEditorSystem");
        NUISkinEditorSystem nuiSkinEditorSystem = new NUISkinEditorSystem();
        context.put(NUISkinEditorSystem.class, nuiSkinEditorSystem);
        componentSystemManager.register(nuiSkinEditorSystem, "engine:NUISkinEditorSystem");
        inputSystem = context.get(InputSystem.class);
    }
    componentSystemManager.initialise();
    console = context.get(Console.class);
    storageServiceWorker = context.get(StorageServiceWorker.class);
    playBackgroundMusic();
    if (!headless) {
        // guiManager.openWindow("main");
        context.get(NUIManager.class).pushScreen("engine:mainMenuScreen");
    }
    if (!messageOnLoad.isEmpty()) {
        TranslationSystem translationSystem = context.get(TranslationSystem.class);
        if (headless) {
            throw new RuntimeException(String.format("Game could not be started, server attempted to return to main menu: [%s]. See logs before", translationSystem.translate(messageOnLoad)));
        } else {
            MessagePopup popup = nuiManager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
            popup.setMessage("Error", translationSystem.translate(messageOnLoad));
        }
    }
// TODO: enable it when exposing the telemetry to users
// pushLaunchPopup();
}
Also used : NUIEditorSystem(org.terasology.engine.rendering.nui.editor.systems.NUIEditorSystem) TranslationSystem(org.terasology.engine.i18n.TranslationSystem) Console(org.terasology.engine.logic.console.Console) MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup) RegisterInputSystem(org.terasology.engine.core.modes.loadProcesses.RegisterInputSystem) NUISkinEditorSystem(org.terasology.engine.rendering.nui.editor.systems.NUISkinEditorSystem) RegisterInputSystem(org.terasology.engine.core.modes.loadProcesses.RegisterInputSystem) InputSystem(org.terasology.engine.input.InputSystem) NUIManager(org.terasology.engine.rendering.nui.NUIManager) StorageServiceWorker(org.terasology.engine.identity.storageServiceClient.StorageServiceWorker)

Aggregations

MessagePopup (org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup)6 DependencyResolutionFailedException (org.terasology.engine.core.module.DependencyResolutionFailedException)2 ConfirmPopup (org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup)2 Module (org.terasology.gestalt.module.Module)2 StateLoading (org.terasology.engine.core.modes.StateLoading)1 RegisterInputSystem (org.terasology.engine.core.modes.loadProcesses.RegisterInputSystem)1 TranslationSystem (org.terasology.engine.i18n.TranslationSystem)1 StorageServiceWorker (org.terasology.engine.identity.storageServiceClient.StorageServiceWorker)1 InputSystem (org.terasology.engine.input.InputSystem)1 Console (org.terasology.engine.logic.console.Console)1 ConsoleCommand (org.terasology.engine.logic.console.commandSystem.ConsoleCommand)1 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)1 JoinStatus (org.terasology.engine.network.JoinStatus)1 NUIManager (org.terasology.engine.rendering.nui.NUIManager)1 NUIEditorSystem (org.terasology.engine.rendering.nui.editor.systems.NUIEditorSystem)1 NUISkinEditorSystem (org.terasology.engine.rendering.nui.editor.systems.NUISkinEditorSystem)1