Package org.terasology.engine.modes

Examples of org.terasology.engine.modes.StateMainMenu


    @Command(shortDescription = "Leaves the current game and returns to main menu")
    public String leave() {
        NetworkSystem networkSystem = CoreRegistry.get(NetworkSystem.class);
        if (networkSystem.getMode() != NetworkMode.NONE) {
            CoreRegistry.get(GameEngine.class).changeState(new StateMainMenu());
            return "Leaving..";
        } else {
            return "Not connected";
        }
    }
View Full Code Here


        });
        WidgetUtil.trySubscribe(this, "mainMenu", new ActivateEventListener() {
            @Override
            public void onActivated(UIWidget widget) {
                CoreRegistry.get(LocalPlayer.class).getClientEntity().send(new RespawnRequestEvent());
                CoreRegistry.get(GameEngine.class).changeState(new StateMainMenu());
            }
        });
        WidgetUtil.trySubscribe(this, "exitGame", new ActivateEventListener() {
            @Override
            public void onActivated(UIWidget widget) {
View Full Code Here

            }
        });
        WidgetUtil.trySubscribe(this, "mainMenu", new ActivateEventListener() {
            @Override
            public void onActivated(UIWidget widget) {
                CoreRegistry.get(GameEngine.class).changeState(new StateMainMenu());
            }
        });
        WidgetUtil.trySubscribe(this, "exit", new ActivateEventListener() {
            @Override
            public void onActivated(UIWidget widget) {
View Full Code Here

    @Override
    public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
        GameEngine gameEngine = CoreRegistry.get(GameEngine.class);
        if (gameEngine != null) {
            gameEngine.changeState(new StateMainMenu("Disconnected From Server"));
        }
    }
View Full Code Here

            engine.setHibernationAllowed(false);
            engine.subscribeToStateChange(mainWindow);
            engine.init();

            engine.run(new StateMainMenu());
            engine.dispose();
        } catch (Throwable t) {
            logger.error("Uncaught Exception", t);
        }
    }
View Full Code Here

        ResolutionResult result = resolver.resolve(moduleIds);
        if (result.isSuccess()) {
            moduleManager.loadEnvironment(result.getModules(), true);
            ApplyModulesUtil.applyModules();
        } else {
            CoreRegistry.get(GameEngine.class).changeState(new StateMainMenu("Missing required module or dependency"));
        }
        return true;
    }
View Full Code Here

                                }
                            }
                        });
                    }

                    engine.run(new StateMainMenu());
                }
            } finally {
                engine.dispose();
            }
        } catch (RuntimeException | IOException e) {
View Full Code Here

            worldGenerator.setWorldSeed(worldInfo.getSeed());
            CoreRegistry.put(WorldGenerator.class, worldGenerator);
        } catch (UnresolvedWorldGeneratorException e) {
            logger.error("Unable to load world generator {}. Available world generators: {}",
                    worldInfo.getWorldGenerator(), worldGeneratorManager.getWorldGenerators());
            CoreRegistry.get(GameEngine.class).changeState(new StateMainMenu("Failed to resolve world generator."));
            return true; // We need to return true, otherwise the loading state will just call us again immediately
        }

        // Init. a new world
        EngineEntityManager entityManager = (EngineEntityManager) CoreRegistry.get(EntityManager.class);
View Full Code Here

            Set<Module> moduleSet = Sets.newLinkedHashSet();
            for (NameVersion moduleInfo : networkSystem.getServer().getInfo().getModuleList()) {
                Module module = moduleManager.getRegistry().getModule(moduleInfo.getName(), moduleInfo.getVersion());
                if (module == null) {
                    StateMainMenu mainMenu = new StateMainMenu("Missing required module: " + moduleInfo);
                    CoreRegistry.get(GameEngine.class).changeState(mainMenu);
                    return false;
                } else {
                    logger.debug("Activating module: {}:{}", moduleInfo.getName(), moduleInfo.getVersion());
                    gameManifest.addModule(module.getId(), module.getVersion());
                    moduleSet.add(module);
                }
            }
            moduleManager.loadEnvironment(moduleSet, true);

            CoreRegistry.get(Game.class).load(gameManifest);
            ApplyModulesUtil.applyModules();

            return true;
        } else if (joinStatus.getStatus() == JoinStatus.Status.FAILED) {
            StateMainMenu mainMenu = new StateMainMenu("Failed to connect to server: " + joinStatus.getErrorMessage());
            CoreRegistry.get(GameEngine.class).changeState(mainMenu);
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of org.terasology.engine.modes.StateMainMenu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.