use of com.ray3k.skincomposer.data.FontData in project skin-composer by raeleus.
the class DialogFreeTypeFont method updateDisabledFields.
private void updateDisabledFields() {
CheckBox checkBox = findActor("serializerCheckBox");
SelectBox selectBox = findActor("previewSelectBox");
selectBox.setDisabled(checkBox.isChecked());
boolean notValid = false;
if (checkBox.isChecked()) {
if (data.color == null)
notValid = true;
else if (data.file == null || !data.file.exists())
notValid = true;
else if (!MathUtils.isZero(data.borderWidth) && data.borderColor == null)
notValid = true;
else if ((data.shadowOffsetX != 0 || data.shadowOffsetY != 0) && data.shadowColor == null)
notValid = true;
}
if (notValid) {
TextField textField = findActor("previewField");
Cell cell = ((Table) textField.getParent()).getCell(textField);
previewStyle.font = skin.get("free-type-preview", TextFieldStyle.class).font;
textField = new TextField(previewText, previewStyle);
textField.setName("previewField");
textField.setAlignment(Align.center);
cell.setActor(textField);
} else {
data.createBitmapFont(main);
if (data.bitmapFont != null) {
TextField textField = findActor("previewField");
Cell cell = ((Table) textField.getParent()).getCell(textField);
previewStyle.font = data.bitmapFont;
textField = new TextField(previewText, previewStyle);
textField.setName("previewField");
textField.setAlignment(Align.center);
cell.setActor(textField);
}
}
if (!StyleData.validate(((TextField) findActor("fontName")).getText()))
notValid = true;
for (FontData font : main.getJsonData().getFonts()) {
if (font.getName().equals(data.name)) {
notValid = true;
break;
}
}
for (FreeTypeFontData font : main.getJsonData().getFreeTypeFonts()) {
if (font.name.equals(data.name) && (mode == Mode.NEW || !font.name.equals(originalData.name))) {
notValid = true;
break;
}
}
TextButton textButton = findActor("okButton");
textButton.setDisabled(notValid);
}
use of com.ray3k.skincomposer.data.FontData in project skin-composer by raeleus.
the class DialogPathErrors method resolveAssetsFromFolder.
private void resolveAssetsFromFolder(FileHandle folder, Array<DrawableData> drawables, Array<FontData> fonts) {
if (folder.isDirectory()) {
for (DrawableData drawable : drawables) {
if (!foundDrawables.contains(drawable, true)) {
FileHandle file = folder.child(drawable.file.name());
if (file.exists()) {
drawable.file = file;
foundDrawables.add(drawable);
}
}
}
for (FontData font : fonts) {
if (!foundFonts.contains(font, true)) {
FileHandle file = folder.child(font.file.name());
if (file.exists()) {
font.file = file;
foundFonts.add(font);
}
}
}
}
applyButton.setDisabled(foundDrawables.size != drawables.size || foundFonts.size != fonts.size);
}
use of com.ray3k.skincomposer.data.FontData in project skin-composer by raeleus.
the class DialogPathErrors method resetDrawableTable.
private void resetDrawableTable(Main main, Skin skin, Array<DrawableData> drawables, Array<FontData> fonts) {
dataTable.clear();
if (drawables.size > 0) {
Label label = new Label("Drawable Name", skin, "black");
dataTable.add(label);
label = new Label("Path", skin, "black");
dataTable.add(label);
dataTable.add();
label = new Label("Found?", skin, "black");
dataTable.add(label);
dataTable.row();
Image image = new Image(skin, "welcome-separator");
dataTable.add(image).colspan(4).pad(5.0f).padLeft(0.0f).padRight(0.0f).growX();
for (DrawableData drawable : drawables) {
dataTable.row();
label = new Label(drawable.name, skin);
dataTable.add(label);
label = new Label(drawable.file.path(), skin);
label.setWrap(true);
label.setAlignment(Align.left);
dataTable.add(label).growX();
TextButton textButton = new TextButton("browse...", skin);
textButton.addListener(main.getHandListener());
dataTable.add(textButton).padLeft(10.0f);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
DesktopWorker desktopWorker = main.getDesktopWorker();
String[] filterPatterns = null;
if (!Utils.isMac()) {
filterPatterns = new String[] { "*.png", "*.jpg", "*.jpeg", "*.bmp", "*.gif" };
}
File file = desktopWorker.openDialog("Locate " + drawable.file.name() + "...", drawable.file.path(), filterPatterns, "Image files");
if (file != null) {
FileHandle fileHandle = new FileHandle(file);
drawable.file = fileHandle;
if (!foundDrawables.contains(drawable, true)) {
foundDrawables.add(drawable);
}
resolveAssetsFromFolder(fileHandle.parent(), drawables, fonts);
resetDrawableTable(main, skin, drawables, fonts);
}
}
});
if (foundDrawables.contains(drawable, true)) {
label = new Label("YES", skin, "white");
label.setColor(Color.GREEN);
dataTable.add(label);
} else {
label = new Label("NO", skin, "white");
label.setColor(Color.RED);
dataTable.add(label);
}
dataTable.row();
image = new Image(skin, "welcome-separator");
dataTable.add(image).colspan(4).pad(5.0f).padLeft(0.0f).padRight(0.0f).growX();
}
}
if (fonts.size > 0) {
dataTable.row();
dataTable.defaults().padTop(20.0f);
Label label = new Label("Font Name", skin, "black");
dataTable.add(label);
label = new Label("Path", skin, "black");
dataTable.add(label);
dataTable.add();
label = new Label("Found?", skin, "black");
dataTable.add(label);
dataTable.defaults().reset();
dataTable.row();
Image image = new Image(skin, "welcome-separator");
dataTable.add(image).colspan(4).pad(5.0f).padLeft(0.0f).padRight(0.0f).growX();
for (FontData font : fonts) {
dataTable.row();
label = new Label(font.getName(), skin);
dataTable.add(label);
label = new Label(font.file.path(), skin);
label.setWrap(true);
label.setAlignment(Align.left);
dataTable.add(label).growX();
TextButton textButton = new TextButton("browse...", skin);
textButton.addListener(main.getHandListener());
dataTable.add(textButton);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
DesktopWorker desktopWorker = main.getDesktopWorker();
String[] filterPatterns = null;
if (!Utils.isMac()) {
filterPatterns = new String[] { "*.fnt" };
}
File file = desktopWorker.openDialog("Locate " + font.file.name() + "...", font.file.path(), filterPatterns, "Font files");
if (file != null) {
FileHandle fileHandle = new FileHandle(file);
font.file = fileHandle;
if (!foundFonts.contains(font, true)) {
foundFonts.add(font);
}
resolveAssetsFromFolder(fileHandle.parent(), drawables, fonts);
resetDrawableTable(main, skin, drawables, fonts);
}
}
});
if (foundFonts.contains(font, true)) {
label = new Label("YES", skin, "white");
label.setColor(Color.GREEN);
dataTable.add(label);
} else {
label = new Label("NO", skin, "white");
label.setColor(Color.RED);
dataTable.add(label);
}
dataTable.row();
image = new Image(skin, "welcome-separator");
dataTable.add(image).colspan(4).pad(5.0f).padLeft(0.0f).padRight(0.0f).growX();
}
}
}
use of com.ray3k.skincomposer.data.FontData in project skin-composer by raeleus.
the class MainListener method exportFile.
public void exportFile() {
dialogFactory.showDialogLoading(() -> {
Array<String> warnings = new Array<>();
String defaultPath = projectData.getLastImportExportPath();
String[] filterPatterns = { "*.json" };
File file = desktopWorker.saveDialog("Export skin...", defaultPath, filterPatterns, "Json files");
if (file != null) {
FileHandle fileHandle = new FileHandle(file);
if (fileHandle.extension() == null || !fileHandle.extension().equals(".json")) {
fileHandle = fileHandle.sibling(fileHandle.nameWithoutExtension() + ".json");
}
projectData.setLastImportExportPath(fileHandle.parent().path() + "/");
Array<String> newWarnings = main.getProjectData().getJsonData().writeFile(fileHandle);
warnings.addAll(newWarnings);
try {
newWarnings = main.getProjectData().getAtlasData().writeAtlas(fileHandle.parent().child(fileHandle.nameWithoutExtension() + ".atlas"));
warnings.addAll(newWarnings);
} catch (Exception ex) {
Gdx.app.error(getClass().getName(), "Error while writing texture atlas", ex);
dialogFactory.showDialogError("Atlas Error...", "Error while writing texture atlas.\n\nOpen log?");
}
for (FontData font : main.getProjectData().getJsonData().getFonts()) {
if (!font.file.parent().equals(fileHandle.parent())) {
font.file.copyTo(fileHandle.parent());
}
}
for (FreeTypeFontData font : main.getProjectData().getJsonData().getFreeTypeFonts()) {
if (font.useCustomSerializer && !font.file.parent().equals(fileHandle.parent())) {
font.file.copyTo(fileHandle.parent());
}
}
}
if (warnings.size > 0) {
main.getDialogFactory().showWarningDialog(warnings);
}
});
}
Aggregations