use of com.ray3k.skincomposer.data.FreeTypeFontData 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.FreeTypeFontData 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