use of com.ray3k.skincomposer.DesktopWorker 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();
}
}
}
Aggregations