Search in sources :

Example 1 with ThreeButtonPopup

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

the class IdentityIOHelper method checkNextConflict.

private void checkNextConflict(Iterator<Map.Entry<PublicIdentityCertificate, ClientIdentity>> newIdentities, Runnable onCompletion) {
    Runnable next = () -> checkNextConflict(newIdentities, onCompletion);
    if (newIdentities.hasNext()) {
        Map.Entry<PublicIdentityCertificate, ClientIdentity> entry = newIdentities.next();
        PublicIdentityCertificate server = entry.getKey();
        ClientIdentity newClient = entry.getValue();
        ClientIdentity oldClient = securityConfig.getIdentity(server);
        if (oldClient != null) {
            Runnable skip = () -> {
                newIdentities.remove();
                next.run();
            };
            if (newClient.getPlayerPublicCertificate().equals(oldClient.getPlayerPublicCertificate())) {
                skip.run();
            } else {
                ThreeButtonPopup popup = nuiManager.pushScreen(ThreeButtonPopup.ASSET_URI, ThreeButtonPopup.class);
                popup.setMessage(importPopupTitle, String.format(translationSystem.translate("${engine:menu#identity-import-conflict}"), server.getId(), oldClient.getPlayerPublicCertificate().getId(), newClient.getPlayerPublicCertificate().getId()));
                popup.setLeftButton(translationSystem.translate("${engine:menu#identity-import-overwrite}"), next);
                popup.setCenterButton(translationSystem.translate("${engine:menu#identity-import-skip}"), skip);
                popup.setRightButton(translationSystem.translate("${engine:menu#identity-import-cancel}"), () -> nuiManager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage(importPopupTitle, translationSystem.translate("${engine:menu#identity-import-cancelled}")));
            }
        } else {
            next.run();
        }
    } else {
        onCompletion.run();
    }
}
Also used : ClientIdentity(org.terasology.engine.identity.ClientIdentity) Map(java.util.Map) ThreeButtonPopup(org.terasology.engine.rendering.nui.layers.mainMenu.ThreeButtonPopup) PublicIdentityCertificate(org.terasology.engine.identity.PublicIdentityCertificate)

Example 2 with ThreeButtonPopup

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

the class PlayerSettingsScreen method initialise.

@Override
public void initialise() {
    setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
    storageServiceStatus = find("storageServiceStatus", UILabel.class);
    storageServiceAction = find("storageServiceAction", UIButton.class);
    updateStorageServiceStatus();
    WidgetUtil.trySubscribe(this, "close", button -> triggerBackAnimation());
    IdentityIOHelper identityIOHelper = new IdentityIOHelper(context);
    WidgetUtil.trySubscribe(this, "importIdentities", button -> identityIOHelper.importIdentities());
    WidgetUtil.trySubscribe(this, "exportIdentities", button -> identityIOHelper.exportIdentities());
    WidgetUtil.trySubscribe(this, "storageServiceAction", widget -> {
        if (storageService.getStatus() == StorageServiceWorkerStatus.LOGGED_IN) {
            ThreeButtonPopup logoutPopup = getManager().pushScreen(ThreeButtonPopup.ASSET_URI, ThreeButtonPopup.class);
            logoutPopup.setMessage(translationSystem.translate("${engine:menu#storage-service-log-out}"), translationSystem.translate("${engine:menu#storage-service-log-out-popup}"));
            logoutPopup.setLeftButton(translationSystem.translate("${engine:menu#dialog-yes}"), () -> storageService.logout(true));
            logoutPopup.setCenterButton(translationSystem.translate("${engine:menu#dialog-no}"), () -> storageService.logout(false));
            logoutPopup.setRightButton(translationSystem.translate("${engine:menu#dialog-cancel}"), () -> {
            });
        } else if (storageService.getStatus() == StorageServiceWorkerStatus.LOGGED_OUT) {
            getManager().pushScreen(StorageServiceLoginPopup.ASSET_URI, StorageServiceLoginPopup.class);
        }
    });
}
Also used : UILabel(org.terasology.nui.widgets.UILabel) StorageServiceLoginPopup(org.terasology.engine.rendering.nui.layers.mainMenu.StorageServiceLoginPopup) UIButton(org.terasology.nui.widgets.UIButton) ThreeButtonPopup(org.terasology.engine.rendering.nui.layers.mainMenu.ThreeButtonPopup)

Aggregations

ThreeButtonPopup (org.terasology.engine.rendering.nui.layers.mainMenu.ThreeButtonPopup)2 Map (java.util.Map)1 ClientIdentity (org.terasology.engine.identity.ClientIdentity)1 PublicIdentityCertificate (org.terasology.engine.identity.PublicIdentityCertificate)1 StorageServiceLoginPopup (org.terasology.engine.rendering.nui.layers.mainMenu.StorageServiceLoginPopup)1 UIButton (org.terasology.nui.widgets.UIButton)1 UILabel (org.terasology.nui.widgets.UILabel)1