Search in sources :

Example 1 with CustomFontUndoable

use of com.ray3k.skincomposer.UndoableManager.CustomFontUndoable in project skin-composer by raeleus.

the class DialogFonts method result.

@Override
protected void result(Object object) {
    if (styleProperty != null) {
        if (object instanceof FontData) {
            main.getProjectData().setChangesSaved(false);
            FontData font = (FontData) object;
            FontUndoable undoable = new FontUndoable(main.getRootTable(), main.getJsonData(), styleProperty, styleProperty.value, font.getName());
            main.getUndoableManager().addUndoable(undoable, true);
        } else if (object instanceof FreeTypeFontData) {
            main.getProjectData().setChangesSaved(false);
            FreeTypeFontData font = (FreeTypeFontData) object;
            FontUndoable undoable = new FontUndoable(main.getRootTable(), main.getJsonData(), styleProperty, styleProperty.value, font.name);
            main.getUndoableManager().addUndoable(undoable, true);
        } else if (object instanceof Boolean) {
            if ((boolean) object) {
                FontUndoable undoable = new FontUndoable(main.getRootTable(), main.getJsonData(), styleProperty, styleProperty.value, null);
                main.getUndoableManager().addUndoable(undoable, true);
                main.getProjectData().setChangesSaved(false);
                main.getRootTable().setStatusBarMessage("Drawable emptied for \"" + styleProperty.name + "\"");
                main.getRootTable().refreshStyleProperties(true);
            } else {
                boolean hasFont = false;
                for (FontData font : main.getJsonData().getFonts()) {
                    if (font.getName().equals(styleProperty.value)) {
                        hasFont = true;
                        break;
                    }
                }
                for (FreeTypeFontData font : main.getJsonData().getFreeTypeFonts()) {
                    if (font.name.equals(styleProperty.value)) {
                        hasFont = true;
                        break;
                    }
                }
                if (!hasFont) {
                    styleProperty.value = null;
                    main.getProjectData().setChangesSaved(false);
                    main.getRootTable().setStatusBarMessage("Drawable deleted for \"" + styleProperty.name + "\"");
                    main.getRootTable().refreshStyleProperties(true);
                }
            }
        }
    } else if (customProperty != null) {
        if (object instanceof FontData) {
            main.getProjectData().setChangesSaved(false);
            FontData font = (FontData) object;
            CustomFontUndoable undoable = new CustomFontUndoable(main, customProperty, font.getName());
            main.getUndoableManager().addUndoable(undoable, true);
        } else if (object instanceof FreeTypeFontData) {
            main.getProjectData().setChangesSaved(false);
            FreeTypeFontData font = (FreeTypeFontData) object;
            CustomFontUndoable undoable = new CustomFontUndoable(main, customProperty, font.name);
            main.getUndoableManager().addUndoable(undoable, true);
        } else if (object instanceof Boolean) {
            if ((boolean) object) {
                CustomFontUndoable undoable = new CustomFontUndoable(main, customProperty, null);
                main.getUndoableManager().addUndoable(undoable, true);
                main.getProjectData().setChangesSaved(false);
                main.getRootTable().setStatusBarMessage("Drawable emptied for \"" + customProperty.getName() + "\"");
                main.getRootTable().refreshStyleProperties(true);
            } else {
                boolean hasFont = false;
                for (FontData font : main.getJsonData().getFonts()) {
                    if (font.getName().equals(customProperty.getValue())) {
                        hasFont = true;
                        break;
                    }
                }
                if (!hasFont) {
                    customProperty.setValue(null);
                    main.getProjectData().setChangesSaved(false);
                    main.getRootTable().setStatusBarMessage("Drawable deleted for \"" + customProperty.getName() + "\"");
                    main.getRootTable().refreshStyleProperties(true);
                }
            }
        }
    }
    if (listener != null) {
        listener.handle(null);
    }
    main.getRootTable().refreshPreview();
}
Also used : CustomFontUndoable(com.ray3k.skincomposer.UndoableManager.CustomFontUndoable) FontUndoable(com.ray3k.skincomposer.UndoableManager.FontUndoable) FreeTypeFontData(com.ray3k.skincomposer.data.FreeTypeFontData) FreeTypeFontData(com.ray3k.skincomposer.data.FreeTypeFontData) FontData(com.ray3k.skincomposer.data.FontData) BitmapFontData(com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData) CustomFontUndoable(com.ray3k.skincomposer.UndoableManager.CustomFontUndoable)

Aggregations

BitmapFontData (com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData)1 CustomFontUndoable (com.ray3k.skincomposer.UndoableManager.CustomFontUndoable)1 FontUndoable (com.ray3k.skincomposer.UndoableManager.FontUndoable)1 FontData (com.ray3k.skincomposer.data.FontData)1 FreeTypeFontData (com.ray3k.skincomposer.data.FreeTypeFontData)1