Java 类com.badlogic.gdx.scenes.scene2d.ui.Dialog 实例源码

项目:gdx-controllerutils    文件:ControllerMenuDialog.java   
@Override
public Dialog show(Stage stage, Action action) {
    previousFocussedActor = null;
    previousEscapeActor = null;

    super.show(stage, action);

    if (stage instanceof ControllerMenuStage) {
        previousFocussedActor = ((ControllerMenuStage) stage).getFocussedActor();
        previousEscapeActor = ((ControllerMenuStage) stage).getEscapeActor();

        if (buttonsToAdd.size >= 1)
            ((ControllerMenuStage) stage).setFocussedActor(buttonsToAdd.get(0));

        if (buttonsToAdd.size == 1)
            ((ControllerMenuStage) stage).setEscapeActor(buttonsToAdd.get(0));
    }

    return this;

}
项目:cll1-gdx    文件:SelectSession.java   
protected ClickListener deleteSessionConfirm(final int session, final Image btnTrashcan,
        final TextButton btnSession) {
    return new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Dialog confirmDelete = new Dialog("ᎯᎠᏍ ᏣᏚᎵᎭ?", skin) {
                protected void result(Object object) {
                    if ("YES".equals(object)) {
                        SlotFolder.getSlotFolder(session).deleteDirectory();
                        btnSession.setText(EMPTY_SLOT+"\n"+nextSessionIndicationText(0l, 0));
                        btnTrashcan.setColor(Color.LIGHT_GRAY);
                        btnTrashcan.clearListeners();
                    }
                };
            };
            confirmDelete.button("ᎥᎥ - YES", "YES");
            confirmDelete.button("ᎥᏝ - NO", "NO");
            confirmDelete.text("Are you sure you want\n" + "to delete this session?\n" + "This cannot be undone!");
            confirmDelete.setModal(true);
            confirmDelete.pack();
            confirmDelete.show(stage);
        }
    };
}
项目:cll1-gdx    文件:LearningSession.java   
@Override
protected boolean onBack() {
    userPause();
    pausedStage.getRoot().clearChildren();
    Dialog cancelSession = new Dialog("[PAUSED] CANCEL SESSION?", skin) {
        @Override
        protected void result(Object object) {
            if ("YES".equals(object)) {
                game.previousScreen();
            }
            userResume();
        }
    };
    cancelSession.setModal(true);
    cancelSession.getTitleLabel().setAlignment(Align.center);
    cancelSession.button("ᎥᎥ - YES", "YES");
    cancelSession.button("ᎥᏝ - NO", "NO");
    cancelSession.getContentTable().row();
    cancelSession.text("Are you sure you want to cancel?");
    cancelSession.getContentTable().row();
    cancelSession.text("You will lose all of your");
    cancelSession.getContentTable().row();
    cancelSession.text("progress if you choose ᎥᎥ!");
    cancelSession.show(pausedStage);
    return true;
}
项目:skin-composer    文件:DialogWelcome.java   
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);

    if (getWidth() > Gdx.graphics.getWidth()) {
        setWidth(Gdx.graphics.getWidth());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }

    if (getHeight() > Gdx.graphics.getHeight()) {
        setHeight(Gdx.graphics.getHeight());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }

    resetWidth = getWidth();
    resetHeight = getHeight();
    main.getStage().setScrollFocus(scrollPane);
    return dialog;
}
项目:skin-composer    文件:DialogWelcome.java   
@Override
public Dialog show(Stage stage, Action action) {
    Dialog dialog = super.show(stage, action);

    if (getWidth() > Gdx.graphics.getWidth()) {
        setWidth(Gdx.graphics.getWidth());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }

    if (getHeight() > Gdx.graphics.getHeight()) {
        setHeight(Gdx.graphics.getHeight());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }

    resetWidth = getWidth();
    resetHeight = getHeight();
    main.getStage().setScrollFocus(scrollPane);
    return dialog;
}
项目:skin-composer    文件:DialogWarnings.java   
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);
    if (getWidth() > Gdx.graphics.getWidth()) {
        setWidth(Gdx.graphics.getWidth());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }

    if (getHeight() > Gdx.graphics.getHeight()) {
        setHeight(Gdx.graphics.getHeight());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }

    resetWidth = getWidth();
    resetHeight = getHeight();
    main.getStage().setScrollFocus(scrollPane);
    return dialog;
}
项目:skin-composer    文件:DialogWarnings.java   
@Override
public Dialog show(Stage stage, Action action) {
    Dialog dialog = super.show(stage, action);

    if (getWidth() > Gdx.graphics.getWidth()) {
        setWidth(Gdx.graphics.getWidth());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }

    if (getHeight() > Gdx.graphics.getHeight()) {
        setHeight(Gdx.graphics.getHeight());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }

    resetWidth = getWidth();
    resetHeight = getHeight();
    main.getStage().setScrollFocus(scrollPane);
    return dialog;
}
项目:skin-composer    文件:DialogFonts.java   
private void showAddFontSizeError(String name) {
    Dialog dialog = new Dialog("", getSkin(), "bg");

    dialog.getContentTable().defaults().pad(10.0f);
    Label label = new Label("Error adding font...", getSkin(), "title");
    dialog.getContentTable().add(label);

    dialog.getContentTable().row();
    dialog.text("Unable to add font \"" + name +
            "\". Ensure image dimensions\nare less than max texture dimensions (" +
            maxTextureWidth + "x" + 
            maxTextureHeight + ").\nSee project settings.");

    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("Ok");
    dialog.key(Keys.ENTER, null).key(Keys.ESCAPE, null);
    dialog.show(getStage());
}
项目:skin-composer    文件:DialogFactory.java   
public void showDeleteStyleDialog(Skin skin, Stage stage) {
    StyleData styleData = main.getRootTable().getSelectedStyle();

    Dialog dialog = new Dialog("Delete Style", skin, "bg") {
        @Override
        protected void result(Object object) {
            if ((Boolean) object) {
                main.getUndoableManager().addUndoable(new DeleteStyleUndoable(styleData, main), true);
            }
        }
    };
    dialog.getTitleLabel().setAlignment(Align.center);
    dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
    dialog.text("Are you sure you want to delete style " + styleData.name + "?");
    dialog.getContentTable().getCells().first().pad(10.0f);

    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("Yes, delete the style", true).button("No", false);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());

    dialog.key(Input.Keys.ENTER, true).key(Input.Keys.ESCAPE, false);

    dialog.show(stage);
}
项目:skin-composer    文件:DialogFactory.java   
public void yesNoDialog(String title, String text,
        ConfirmationListener listener) {
    Dialog dialog = new Dialog(title, main.getSkin(), "bg") {
        @Override
        protected void result(Object object) {
            listener.selected((int) object);
        }
    };
    dialog.getTitleTable().getCells().first().padLeft(5.0f);
    Label label = new Label(text, main.getSkin());
    label.setAlignment(Align.center);
    dialog.text(label);
    dialog.getContentTable().getCells().first().pad(10.0f);
    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("Yes", 0);
    dialog.button("No", 1);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    dialog.key(Input.Keys.ESCAPE, 1);
    dialog.show(main.getStage());
}
项目:skin-composer    文件:DialogFactory.java   
public void yesNoCancelDialog(String title, String text,
        ConfirmationListener listener) {
    Dialog dialog = new Dialog(title, main.getSkin(), "bg") {
        @Override
        protected void result(Object object) {
            listener.selected((int) object);
        }
    };
    dialog.getTitleTable().getCells().first().padLeft(5.0f);
    Label label = new Label(text, main.getSkin());
    label.setAlignment(Align.center);
    dialog.text(label);
    dialog.getContentTable().getCells().first().pad(10.0f);
    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("Yes", 0);
    dialog.button("No", 1);
    dialog.button("Cancel", 2);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(2).getActor().addListener(main.getHandListener());
    dialog.key(Input.Keys.ESCAPE, 2);
    dialog.show(main.getStage());
}
项目:skin-composer    文件:DialogFactory.java   
public void showDialogError(String title, String message, Runnable runnable) {
    Dialog dialog = new Dialog(title, main.getSkin(), "bg") {
        @Override
        public boolean remove() {
            if (runnable != null) {
                runnable.run();
            }
            return super.remove();
        }

    };

    dialog.text(message);
    dialog.button("OK");
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.show(main.getStage());
}
项目:Opus-Prototype    文件:Editor.java   
private void setExitDialog() {
    if (settings.showExitDialog && !Config.DEBUG) {
        Dialog exitDialog = new Dialog("Confirm Exit", Styles.UI_SKIN)  {
            @Override
            protected void result(Object object)
            {
                if (object.equals(true))
                {
                    ((ExitDialogInterface) Gdx.app).exitConfirmed();
                } else
                {
                    ((ExitDialogInterface) Gdx.app).exitCanceled();
                }
            }
        };
        exitDialog.button("Yes", true);
        exitDialog.button("Cancel", false);
        ((ExitDialogInterface) Gdx.app).setExitDialog(exitDialog, STAGE);
    }
}
项目:gdx-lml    文件:OnResultLmlAttribute.java   
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    final Dialog dialog = getDialogParent(tag);
    if (dialog != null) {
        dialog.setObject(actor, parser.parseAction(rawAttributeData, dialog));
    } else {
        final VisDialog visDialog = getVisDialogParent(tag);
        if (visDialog == null) {
            parser.throwErrorIfStrict(
                    "On result actions can be attached only to children of dialogs. Received on result action: "
                            + rawAttributeData + " on a tag without dialog parent: " + tag.getTagName());
            return;
        }
        visDialog.setObject(actor, parser.parseAction(rawAttributeData, dialog));
    }
}
项目:gdx-lml-vis    文件:OnResultLmlAttribute.java   
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    final Dialog dialog = getDialogParent(tag);
    if (dialog != null) {
        dialog.setObject(actor, parser.parseAction(rawAttributeData, dialog));
    } else {
        final VisDialog visDialog = getVisDialogParent(tag);
        if (visDialog == null) {
            parser.throwErrorIfStrict(
                    "On result actions can be attached only to children of dialogs. Received on result action: "
                            + rawAttributeData + " on a tag without dialog parent: " + tag.getTagName());
            return;
        }
        visDialog.setObject(actor, parser.parseAction(rawAttributeData, dialog));
    }
}
项目:ShapeOfThingsThatWere    文件:FramedDialog.java   
public FramedDialog(Skin skin, String title, String message) {
  this.skin = skin;

  frame = new Image(skin.getPatch("frame"));

  // TODO find why title is outside the box
  dialog = new Dialog(title, skin) {
    @Override
    protected void result(Object object) {
      fadeOut();
    }
  };
  dialog.setBackground(skin.getTiledDrawable("menuTexture"));
  dialog.getContentTable().defaults().expandX().fillX();
  dialog.getButtonTable().defaults().expandX().fillX();

  Label label = new Label(message, skin);
  label.setAlignment(Align.center);
  label.setWrap(true);

  dialog.text(label);
}
项目:tafl    文件:HudFactory.java   
private static void addButton(TaflGame game, Object text, Skin skin, LocaleService ls, ChangeListener listener, Dialog dialog) {

        Sprite up = game.graphicsService.getSprite(Assets.GraphicFiles.ATLAS_PIECES, Assets.ButtonGraphics.BLANK);
        Sprite down = game.graphicsService.getSprite(Assets.GraphicFiles.ATLAS_PIECES, Assets.ButtonGraphics.BLANK_PRESSED);

        TextButtonStyle style = new TextButtonStyle();
        style.fontColor = Constants.ScreenConstants.TEXT_COLOR;
        style.font = game.graphicsService.getFont(game.deviceSettings.hudFont);
        style.up = new TextureRegionDrawable(new TextureRegion(up));
        style.down = new TextureRegionDrawable(new TextureRegion(down));

        TextButton button = new TextButton(ls.get(text), style);

        button.addListener(listener);
        dialog.button(button);
        dialog.getButtonTable().row();
    }
项目:tafl    文件:HudFactory.java   
private static Dialog createDialog(TaflGame game, Object title, Skin skin, LocaleService ls, DeviceSettings deviceSettings) {

        String localTitle = ls.get(title);
        if (localTitle == null) {
            localTitle = Constants.HudConstants.DEFAULT_DIALOG_TITLE;
        }

        Dialog dialog = new Dialog(localTitle, skin, Assets.Skin.SKIN_STYLE_DIALOG);
        dialog.setMovable(false);
        dialog.setModal(true);

        dialog.padTop(50);

        dialog.getCell(dialog.getButtonTable()).pad(deviceSettings.dialogSpacing);
        dialog.getContentTable().defaults().padTop(deviceSettings.dialogSpacing);
        dialog.getContentTable().defaults().padLeft(deviceSettings.dialogSpacing);
        dialog.getContentTable().defaults().padRight(deviceSettings.dialogSpacing);
        dialog.getButtonTable().defaults().spaceTop(deviceSettings.dialogSpacing);
        dialog.getButtonTable().defaults().spaceBottom(deviceSettings.dialogSpacing);
        dialog.getButtonTable().defaults().padLeft(deviceSettings.dialogSpacing);
        dialog.getButtonTable().defaults().padRight(deviceSettings.dialogSpacing);
        dialog.getButtonTable().defaults().size(deviceSettings.dialogButtonWidth,
                deviceSettings.dialogButtonHeight);

        return dialog;
    }
项目:GdxStudio    文件:Serializer.java   
public static void setup(){
    registerSerializer(Actor.class, new ActorSerializer());
    registerSerializer(Scene.class, new SceneSerializer());
    registerSerializer(ImageJson.class, new ImageJson());
    registerSerializer(Label.class, new LabelSerializer());
    registerSerializer(Button.class, new ButtonSerializer());
    registerSerializer(TextButton.class, new TextButtonSerializer());
    registerSerializer(Table.class, new TableSerializer());
    registerSerializer(CheckBox.class, new CheckBoxSerializer());
    registerSerializer(SelectBox.class, new SelectBoxSerializer());
    registerSerializer(List.class, new ListSerializer());
    registerSerializer(Slider.class, new SliderSerializer());
    registerSerializer(TextField.class, new TextFieldSerializer());
    registerSerializer(Touchpad.class, new TouchpadSerializer());
    registerSerializer(Sprite.class, new SpriteSerializer());

    registerSerializer(Dialog.class, new DialogSerializer());
    registerSerializer(SplitPane.class, new SplitPaneSerializer());
    registerSerializer(ScrollPane.class, new ScrollPaneSerializer());
    registerSerializer(Stack.class, new StackSerializer());
    registerSerializer(Tree.class, new TreeSerializer());
    registerSerializer(Table.class, new TableSerializer());
    registerSerializer(ButtonGroup.class, new ButtonGroupSerializer());
    registerSerializer(HorizontalGroup.class, new HorizontalGroupSerializer());
    registerSerializer(VerticalGroup.class, new VerticalGroupSerializer());
}
项目:bladecoder-adventure-engine    文件:Editor.java   
public void exit() {
    if (Ctx.project.getProjectDir() != null && Ctx.project.isModified()) {
        new Dialog("Save Project", skin) {
            protected void result(Object object) {
                if (((Boolean) object).booleanValue()) {
                    try {
                        Ctx.project.saveProject();
                    } catch (IOException e1) {
                        String msg = "Something went wrong while saving the actor.\n\n"
                                + e1.getClass().getSimpleName() + " - " + e1.getMessage();
                        Message.showMsgDialog(getStage(), "Error", msg);

                        EditorLogger.printStackTrace(e1);
                    }
                }

                ((Main) Gdx.app).exitSaved();
            }
        }.text("Save changes to project?").button("Yes", true).button("No", false).key(Keys.ENTER, true)
                .key(Keys.ESCAPE, false).show(stage);

    } else {
        ((Main) Gdx.app).exitSaved();
    }

}
项目:bladecoder-adventure-engine    文件:ProjectToolbar.java   
private void saveProjectAndExecute(final Runnable task) {
    if (Ctx.project.getProjectDir() != null && Ctx.project.isModified()) {
        new Dialog("Save Project", skin) {
            protected void result(Object object) {
                if (((Boolean) object).booleanValue()) {
                    try {
                        Ctx.project.saveProject();
                    } catch (IOException e1) {
                        String msg = "Something went wrong while saving the actor.\n\n"
                                + e1.getClass().getSimpleName() + " - " + e1.getMessage();
                        Message.showMsgDialog(getStage(), "Error", msg);

                        EditorLogger.printStackTrace(e1);
                    }
                }

                task.run();
            }
        }.text("Save current project changes?").button("Yes", true).button("No", false).key(Keys.ENTER, true)
                .key(Keys.ESCAPE, false).show(getStage());
    } else {
        task.run();
    }
}
项目:Cardshifter    文件:UsersList.java   
public void inviteSelected(String[] availableMods, Stage stage, final CardshifterClient client) {
    if (selected == null) {
        return;
    }

    Dialog dialog = new Dialog("Invite " + selected.getName(), skin) {
        @Override
        protected void result(Object object) {
            if (object != null) {
                client.send(new StartGameRequest(selected.getId(), (String) object));
                callback.callback((String) object);
            }
        }
    };
    dialog.text("Which mod do you want to play?");
    for (String mod : availableMods) {
        dialog.button(mod, mod);
    }
    dialog.button("Cancel");
    dialog.show(stage);
}
项目:ProjektGG    文件:ServerBrowserScreen.java   
@Override
public void onClientConnected(IOException e) {
    connectingDialog.setVisible(false);
    if (e == null) {
        game.pushScreen("lobby");
    } else {
        game.setCurrentSession(null);

        Dialog dialog = new Dialog("Fehler", skin);
        dialog.text(e.getMessage());
        dialog.button("Ok", true);
        dialog.key(Keys.ENTER, true);
        dialog.show(stage);
    }
}
项目:ProjektGG    文件:LobbyCreationScreen.java   
@Override
public void onHostStarted(IOException e) {
    connectingDialog.setVisible(false);
    if (e == null) {
        game.pushScreen("lobby");
    } else {
        game.setCurrentSession(null);
        Dialog dialog = new Dialog("Fehler", skin);
        dialog.text(e.getMessage());
        dialog.button("Ok", true);
        dialog.key(Keys.ENTER, true);
        dialog.show(stage);
    }
}
项目:NoRiskNoFun    文件:AssetModalDialogImpl.java   
AssetModalDialogImpl(LibGdxAssetCache cache, String dialogText, ModalDialogDescriptor modalDialogDescriptor) {

        this.cache = cache;
        this.modalDialogDescriptor = modalDialogDescriptor;
        titleFont = cache.getFont(modalDialogDescriptor.getTitleFont());
        backgroundTexture = cache.getPixMapTexture(modalDialogDescriptor.getBackgroundColor());
        stageBackgroundTexture = createStageBackgroundTexture();
        textLabel = new AssetLabelImpl(cache, dialogText, modalDialogDescriptor.getMessageFont());
        textButton = new AssetTextButtonImpl(cache, BUTTON_TEXT, modalDialogDescriptor.getTextButtonDescriptor());

        dialog = new Dialog(modalDialogDescriptor.getTitle(), createWindowStyle())
                .text(textLabel.getLabel())
                .button(textButton.getTextButton());
    }
项目:MMORPG_Prototype    文件:UserInterface.java   
private void createAndOpenContainerDialog(CharacterItemDataPacket[] contentItems, int gold, long containerId)
{
    ItemPositionSupplier desiredItemPositionSupplier = inventoryDialog::getDesiredItemPositionFor;
    Dialog containerDialog = new ContainerDialog(contentItems, gold, "Container", dialogs,
            (PacketsSender) linkedState, containerId, desiredItemPositionSupplier);
    positionDialogNearMouse(containerDialog);
    stage.addActor(containerDialog);
    dialogs.add(containerDialog);
}
项目:retro-reversi    文件:GameStage.java   
private void initExitDialog(){
    exitDialog = new Dialog("Exit game confirmation", game.getSkin()) {
        @Override
        protected void result(Object object) {
            if ((Boolean) object)
                game.setScreen(new feup.lpoo.reversi.view.menus.MainMenuView(game));
            else
                hide(null); //Do NOT remove null argument
        }
    };
    //exitDialog.text("Are you sure you want to quit? You will lose current game progress");
    exitDialog.button("Yes", true).button("No", false);
}
项目:cll1-gdx    文件:LearningSession.java   
protected void firstTime() {
    log("SHOWING FIRST TIME DIALOG");
    userPause();
    pausedStage.getRoot().clearChildren();
    Dialog firstTimeNotice = new Dialog("HOW THIS WORKS", skin) {
        @Override
        protected void result(Object object) {
            userResume();
            stage.addAction(actionLoadNextChallengeQuick());
        }
    };
    firstTimeNotice.setModal(true);
    firstTimeNotice.setFillParent(true);
    firstTimeNotice.getTitleLabel().setAlignment(Align.center);
    firstTimeNotice.button("ᎰᏩ");

    Table contentTable = firstTimeNotice.getContentTable();
    contentTable.row();
    Table noticeTable = new Table(skin);
    noticeTable.defaults().expand().fill();
    contentTable.add(noticeTable).expand().fill();
    String txt = Gdx.files.internal("text/how-this-works.txt").readString(UTF_8.name());
    Label message = new Label(txt, skin);
    message.setFontScale(.8f);
    message.setWrap(true);
    noticeTable.add(message);
    firstTimeNotice.show(pausedStage);
}
项目:skin-composer    文件:DialogLoading.java   
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);
    RunnableAction runnableAction = new RunnableAction();
    runnableAction.setRunnable(() -> {
        if (runnable != null) {
            runnable.run();
        }
        hide();
    });
    Action action = new SequenceAction(new DelayAction(.5f), runnableAction);
    addAction(action);

    return dialog;
}
项目:skin-composer    文件:DialogCustomProperty.java   
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);

    stage.setKeyboardFocus(nameField);

    return dialog;
}
项目:skin-composer    文件:DialogPathErrors.java   
@Override
public Dialog show(Stage stage) {
    super.show(stage);

    Gdx.app.postRunnable(new Runnable() {
        @Override
        public void run() {
            stage.setScrollFocus(scrollPane);
        }
    });

    return this;
}
项目:skin-composer    文件:DialogCustomStyle.java   
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);

    stage.setKeyboardFocus(nameField);
    nameField.selectAll();

    return dialog;
}
项目:skin-composer    文件:DialogDrawables.java   
@Override
public Dialog show(Stage stage, Action action) {
    Dialog dialog = super.show(stage, action);
    stage.setScrollFocus(scrollPane);
    validate();
    scrollPane.setScrollY(scrollPosition);
    return dialog;
}
项目:skin-composer    文件:DialogDrawables.java   
/**
 * Shows a dialog to confirm deletion of all TintedDrawables based on the
 * provided drawable data. This is called when the delete button is pressed
 * on a drawable in the drawable list.
 * @param drawable 
 */
private void showConfirmDeleteDialog(DrawableData drawable) {
    Dialog dialog = new Dialog("Delete duplicates?", getSkin(), "bg"){
        @Override
        protected void result(Object object) {
            if ((boolean) object) {
                main.getProjectData().setChangesSaved(false);
                removeDuplicateDrawables(drawable.file);
                gatherDrawables();
                sortBySelectedMode();
            }
        }
    };

    dialog.getTitleTable().padLeft(5.0f);
    dialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f);
    dialog.getButtonTable().padBottom(15.0f);

    dialog.text("Deleting this drawable will also delete one or more tinted drawables.\n"
            + "Delete duplicates?");
    dialog.button("OK", true);
    dialog.button("Cancel", false);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    dialog.key(Input.Keys.ENTER, true);
    dialog.key(Input.Keys.ESCAPE, false);
    dialog.show(getStage());
}
项目:skin-composer    文件:DialogDrawables.java   
/**
 * Show an setStatusBarError indicating a drawable that exceeds project specifications
 */
private void showDrawableError() {
    Dialog dialog = new Dialog("Error...", getSkin(), "bg");

    dialog.getTitleTable().padLeft(5.0f);
    dialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f);
    dialog.getButtonTable().padBottom(15.0f);

    Label label = new Label("Error while adding new drawables.\nEnsure that image dimensions are\nless than maximums specified in project.\nRolling back changes...", getSkin());
    label.setAlignment(Align.center);
    dialog.text(label);
    dialog.button("OK");
    dialog.show(getStage());
}
项目:skin-composer    文件:DialogDrawables.java   
/**
 * Shows a dialog to confirm removal of duplicate drawables that have the
 * same name without extension. This is called after selecting new drawables.
 * @param unhandledFiles
 * @param backup
 * @param filesToProcess 
 */
private void showRemoveDuplicatesDialog(Array<FileHandle> unhandledFiles, Array<DrawableData> backup, Array<FileHandle> filesToProcess) {
    Dialog dialog = new Dialog("Delete duplicates?", getSkin(), "bg"){
        @Override
        protected void result(Object object) {
            if ((boolean) object) {
                for (FileHandle fileHandle : unhandledFiles) {
                    removeDuplicateDrawables(fileHandle);
                    filesToProcess.add(fileHandle);
                }
            }
            finalizeDrawables(backup, filesToProcess);
        }
    };

    dialog.getTitleTable().padLeft(5.0f);
    dialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f);
    dialog.getButtonTable().padBottom(15.0f);

    dialog.text("Adding this drawable will overwrite one or more drawables\n"
            + "Delete duplicates?");
    dialog.button("OK", true);
    dialog.button("Cancel", false);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    dialog.key(Input.Keys.ENTER, true);
    dialog.key(Input.Keys.ESCAPE, false);
    dialog.show(getStage());
}
项目:skin-composer    文件:DialogCustomClass.java   
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);

    stage.setKeyboardFocus(classField);

    return dialog;
}
项目:skin-composer    文件:DialogFactory.java   
public void showCloseDialog() {
    if (main.getProjectData().areChangesSaved() || main.getProjectData().isNewProject()) {
        Gdx.app.exit();
    } else {
        if (!showingCloseDialog) {
            showingCloseDialog = true;
            Dialog dialog = new Dialog("Save Changes?", main.getSkin(), "bg") {
                @Override
                protected void result(Object object) {
                    if ((int) object == 0) {
                        main.getMainListener().saveFile(() -> {
                            if (main.getProjectData().areChangesSaved()) {
                                Gdx.app.exit();
                            }
                        });
                    } else if ((int) object == 1) {
                        Gdx.app.exit();
                    }

                    showingCloseDialog = false;
                }
            };
            dialog.getTitleTable().getCells().first().padLeft(5.0f);
            Label label = new Label("Do you want to save\nyour changes before you quit?", main.getSkin());
            label.setAlignment(Align.center);
            dialog.text(label);
            dialog.getContentTable().getCells().first().pad(10.0f);
            dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
            dialog.button("Yes", 0).button("No", 1).button("Cancel", 2);
            dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
            dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
            dialog.getButtonTable().getCells().get(2).getActor().addListener(main.getHandListener());
            java.awt.Toolkit.getDefaultToolkit().beep();
            dialog.show(main.getStage());
        }
    }
}
项目:skin-composer    文件:DialogColorPicker.java   
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);

    stage.setKeyboardFocus(redSpinner.getTextField());
    redSpinner.getTextField().selectAll();

    return dialog;
}
项目:skin-composer    文件:RootTable.java   
@Override
public boolean keyDown(InputEvent event, int keycode) {
    if (Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Input.Keys.CONTROL_RIGHT)) {
        //trigger shortcuts only if no dialogs are open.
        boolean listenForShortcuts = true;
        for (Actor actor : rootTable.getStage().getActors()) {
            if (actor instanceof Dialog) {
                listenForShortcuts = false;
                break;
            }
        }
        if (listenForShortcuts) {
            switch (keycode) {
                case Input.Keys.Z:
                    rootTable.fire(new RootTable.RootTableEvent(RootTable.RootTableEnum.UNDO));
                    break;
                case Input.Keys.Y:
                    rootTable.fire(new RootTable.RootTableEvent(RootTable.RootTableEnum.REDO));
                    break;
                case Input.Keys.N:
                    rootTable.fire(new RootTable.RootTableEvent(RootTable.RootTableEnum.NEW));
                    break;
                case Input.Keys.O:
                    rootTable.fire(new RootTable.RootTableEvent(RootTable.RootTableEnum.OPEN));
                    break;
                case Input.Keys.S:
                    if (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.SHIFT_RIGHT)) {
                        rootTable.fire(new RootTable.RootTableEvent(RootTable.RootTableEnum.SAVE_AS));
                    } else {
                        rootTable.fire(new RootTable.RootTableEvent(RootTable.RootTableEnum.SAVE));
                    }
                    break;
                default:
                    break;
            }
        }
    }
    return false;
}