Search in sources :

Example 1 with ActivateEventListener

use of org.terasology.rendering.nui.widgets.ActivateEventListener in project Terasology by MovingBlocks.

the class JoinGameScreen method initialise.

@Override
public void initialise() {
    setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
    downloader = new ServerListDownloader(config.getNetwork().getMasterServer());
    CardLayout cards = find("cards", CardLayout.class);
    UIList<ServerInfo> customServerList = find("customServerList", UIList.class);
    if (customServerList != null) {
        customServerList.setList(config.getNetwork().getServerInfos());
        configureServerList(customServerList);
    }
    UIList<ServerInfo> onlineServerList = find("onlineServerList", UIList.class);
    if (onlineServerList != null) {
        onlineServerList.setList(listedServers);
        configureServerList(onlineServerList);
    }
    ActivateEventListener activateCustom = e -> {
        cards.setDisplayedCard("customServerListScrollArea");
        find("customButton", UIButton.class).setFamily("highlight");
        find("onlineButton", UIButton.class).setFamily("default");
        visibleList = customServerList;
    };
    WidgetUtil.trySubscribe(this, "customButton", activateCustom);
    ActivateEventListener activateOnline = e -> {
        cards.setDisplayedCard("onlineServerListScrollArea");
        find("customButton", UIButton.class).setFamily("default");
        find("onlineButton", UIButton.class).setFamily("highlight");
        visibleList = onlineServerList;
    };
    WidgetUtil.trySubscribe(this, "onlineButton", activateOnline);
    bindCustomButtons();
    bindInfoLabels();
    WidgetUtil.trySubscribe(this, "close", button -> {
        config.save();
        triggerBackAnimation();
    });
    activateOnline.onActivated(null);
}
Also used : CoreScreenLayer(org.terasology.rendering.nui.CoreScreenLayer) BindHelper(org.terasology.rendering.nui.databinding.BindHelper) CardLayout(org.terasology.rendering.nui.layouts.CardLayout) LoggerFactory(org.slf4j.LoggerFactory) ServerInfoMessage(org.terasology.network.ServerInfoMessage) IntToStringBinding(org.terasology.rendering.nui.databinding.IntToStringBinding) StringTextRenderer(org.terasology.rendering.nui.itemRendering.StringTextRenderer) Collections2(com.google.common.collect.Collections2) Config(org.terasology.config.Config) WorldTime(org.terasology.world.time.WorldTime) StateLoading(org.terasology.engine.modes.StateLoading) Future(java.util.concurrent.Future) PingService(org.terasology.network.PingService) Map(java.util.Map) WidgetUtil(org.terasology.rendering.nui.WidgetUtil) ServerInfo(org.terasology.config.ServerInfo) FontColor(org.terasology.rendering.FontColor) List(java.util.List) Predicate(com.google.common.base.Predicate) ResourceUrn(org.terasology.assets.ResourceUrn) In(org.terasology.registry.In) Joiner(com.google.common.base.Joiner) ReadOnlyBinding(org.terasology.rendering.nui.databinding.ReadOnlyBinding) MenuAnimationSystems(org.terasology.rendering.nui.animation.MenuAnimationSystems) GameEngine(org.terasology.engine.GameEngine) GameThread(org.terasology.engine.GameThread) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) ArrayList(java.util.ArrayList) ServerInfoService(org.terasology.network.ServerInfoService) ModuleRegistry(org.terasology.module.ModuleRegistry) TranslationSystem(org.terasology.i18n.TranslationSystem) NameVersion(org.terasology.naming.NameVersion) UIList(org.terasology.rendering.nui.widgets.UIList) ModuleManager(org.terasology.engine.module.ModuleManager) Logger(org.slf4j.Logger) JoinStatus(org.terasology.network.JoinStatus) Keyboard(org.terasology.input.Keyboard) IOException(java.io.IOException) UILabel(org.terasology.rendering.nui.widgets.UILabel) ExecutionException(java.util.concurrent.ExecutionException) ActivateEventListener(org.terasology.rendering.nui.widgets.ActivateEventListener) NUIKeyEvent(org.terasology.rendering.nui.events.NUIKeyEvent) StorageServiceWorker(org.terasology.identity.storageServiceClient.StorageServiceWorker) Color(org.terasology.rendering.nui.Color) UIButton(org.terasology.rendering.nui.widgets.UIButton) WorldInfo(org.terasology.world.internal.WorldInfo) NetworkSystem(org.terasology.network.NetworkSystem) Collections(java.util.Collections) CardLayout(org.terasology.rendering.nui.layouts.CardLayout) ActivateEventListener(org.terasology.rendering.nui.widgets.ActivateEventListener) ServerInfo(org.terasology.config.ServerInfo)

Aggregations

Joiner (com.google.common.base.Joiner)1 Predicate (com.google.common.base.Predicate)1 Collections2 (com.google.common.collect.Collections2)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 ResourceUrn (org.terasology.assets.ResourceUrn)1 Config (org.terasology.config.Config)1 ServerInfo (org.terasology.config.ServerInfo)1 GameEngine (org.terasology.engine.GameEngine)1 GameThread (org.terasology.engine.GameThread)1 StateLoading (org.terasology.engine.modes.StateLoading)1