Search in sources :

Example 1 with ConnectionOverlay

use of io.xol.chunkstories.gui.layer.ingame.ConnectionOverlay in project chunkstories by Hugobros3.

the class ServerSelection method login.

// Takes care of connecting to a server
private void login() {
    String ip = ipForm.getText();
    int port = 30410;
    if (ip.length() == 0)
        return;
    Client.getInstance().getConfiguration().getOption("client.game.last-server").trySetting(ip);
    Client.getInstance().getConfiguration().save();
    if (ip.contains(":")) {
        port = Integer.parseInt(ip.split(":")[1]);
        ip = ip.split(":")[0];
    }
    // Client.world = null;
    gameWindow.setLayer(new ConnectionOverlay(gameWindow, this, ip, port));
}
Also used : ConnectionOverlay(io.xol.chunkstories.gui.layer.ingame.ConnectionOverlay)

Example 2 with ConnectionOverlay

use of io.xol.chunkstories.gui.layer.ingame.ConnectionOverlay in project chunkstories by Hugobros3.

the class Client method changeWorld.

@Override
public void changeWorld(WorldClient world2) {
    WorldClientCommon world = (WorldClientCommon) world2;
    Runnable job = new Runnable() {

        @Override
        public void run() {
            // Setup the new world and make a controller for it
            Client.this.world = world;
            player = new PlayerClientImplementation(Client.this, world);
            // Change the scene
            Ingame ingameScene = new Ingame(gameWindow, world);
            // We want to keep the connection overlay when getting into a server
            if (gameWindow.getLayer() instanceof ConnectionOverlay) {
                ConnectionOverlay overlay = (ConnectionOverlay) gameWindow.getLayer();
                // If that happen, we want this connection overlay to forget he was originated from a server browser or whatever
                overlay.setParentScene(ingameScene);
            } else
                gameWindow.setLayer(ingameScene);
            // Switch scene but keep the overlay
            // ingameScene.changeOverlay(overlay);
            // Start only the logic after all that
            world.startLogic();
        }
    };
    if (gameWindow.isInstanceMainGLWindow())
        job.run();
    else {
        Fence fence = gameWindow.queueSynchronousTask(job);
        fence.traverse();
    }
}
Also used : ConnectionOverlay(io.xol.chunkstories.gui.layer.ingame.ConnectionOverlay) WorldClientCommon(io.xol.chunkstories.world.WorldClientCommon) Ingame(io.xol.chunkstories.gui.layer.ingame.Ingame) SimpleFence(io.xol.chunkstories.util.concurrency.SimpleFence) Fence(io.xol.chunkstories.api.util.concurrency.Fence)

Aggregations

ConnectionOverlay (io.xol.chunkstories.gui.layer.ingame.ConnectionOverlay)2 Fence (io.xol.chunkstories.api.util.concurrency.Fence)1 Ingame (io.xol.chunkstories.gui.layer.ingame.Ingame)1 SimpleFence (io.xol.chunkstories.util.concurrency.SimpleFence)1 WorldClientCommon (io.xol.chunkstories.world.WorldClientCommon)1