Search in sources :

Example 1 with RecentFile

use of com.ray3k.skincomposer.data.ProjectData.RecentFile in project skin-composer by raeleus.

the class DialogFactory method recentFiles.

public void recentFiles() {
    SelectBox<RecentFile> selectBox = new SelectBox(main.getSkin());
    Dialog dialog = new Dialog("Recent Files...", main.getSkin(), "bg") {

        @Override
        protected void result(Object object) {
            super.result(object);
            if ((boolean) object) {
                if (selectBox.getSelected() != null) {
                    FileHandle file = selectBox.getSelected().getFileHandle();
                    if (file.exists()) {
                        main.getProjectData().load(file);
                        Array<DrawableData> drawableErrors = main.getProjectData().verifyDrawablePaths();
                        Array<FontData> fontErrors = main.getProjectData().verifyFontPaths();
                        if (drawableErrors.size > 0 || fontErrors.size > 0) {
                            main.getDialogFactory().showDialogPathErrors(drawableErrors, fontErrors);
                        }
                    }
                }
            }
        }
    };
    dialog.getTitleTable().getCells().first().padLeft(5.0f);
    Array<RecentFile> recentFiles = main.getProjectData().getRecentFiles();
    recentFiles.reverse();
    selectBox.setItems(recentFiles);
    selectBox.addListener(main.getHandListener());
    selectBox.getList().addListener(main.getHandListener());
    dialog.text("Select a file to open");
    dialog.getContentTable().row();
    dialog.getContentTable().add(selectBox).padLeft(10.0f).padRight(10.0f).growX();
    dialog.getContentTable().getCells().first().pad(10.0f);
    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("OK", true).key(Input.Keys.ENTER, true);
    dialog.button("Cancel", false).key(Input.Keys.ESCAPE, false);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    dialog.show(main.getStage());
}
Also used : DrawableData(com.ray3k.skincomposer.data.DrawableData) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) Dialog(com.badlogic.gdx.scenes.scene2d.ui.Dialog) FileHandle(com.badlogic.gdx.files.FileHandle) FreeTypeFontData(com.ray3k.skincomposer.data.FreeTypeFontData) FontData(com.ray3k.skincomposer.data.FontData) RecentFile(com.ray3k.skincomposer.data.ProjectData.RecentFile)

Aggregations

FileHandle (com.badlogic.gdx.files.FileHandle)1 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)1 SelectBox (com.badlogic.gdx.scenes.scene2d.ui.SelectBox)1 DrawableData (com.ray3k.skincomposer.data.DrawableData)1 FontData (com.ray3k.skincomposer.data.FontData)1 FreeTypeFontData (com.ray3k.skincomposer.data.FreeTypeFontData)1 RecentFile (com.ray3k.skincomposer.data.ProjectData.RecentFile)1