use of com.badlogic.gdx.scenes.scene2d.ui.Label in project gdx-skineditor by cobolfoo.
the class DrawablePickerDialog method updateTable.
/**
*
*/
public void updateTable() {
tableDrawables.clear();
Iterator<String> keys = items.keys().iterator();
int count = 0;
while (keys.hasNext()) {
final String key = keys.next();
if (key.startsWith("widgets/")) {
continue;
}
Button buttonItem = new Button(game.skin);
Image img = null;
if (items.get(key) instanceof Drawable) {
img = new Image((Drawable) items.get(key));
} else {
img = new Image((TextureRegion) items.get(key));
}
if (zoom == true) {
buttonItem.add(img).expand().fill().pad(5);
} else {
buttonItem.add(img).expand().pad(5);
}
buttonItem.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (field == null) {
return;
}
try {
// game.screenMain.paneOptions.refreshSelection();
if (items.get(key) instanceof Drawable) {
field.set(game.screenMain.paneOptions.currentStyle, items.get(key));
} else {
boolean ninepatch = false;
FileHandle test = new FileHandle("projects/" + game.screenMain.getcurrentProject() + "/assets/" + key + ".9.png");
if (test.exists() == true) {
ninepatch = true;
}
if (ninepatch == true) {
game.skinProject.add(key, new NinePatchDrawable(new NinePatch((TextureRegion) items.get(key))));
field.set(game.screenMain.paneOptions.currentStyle, game.skinProject.getDrawable(key));
} else {
game.skinProject.add(key, new SpriteDrawable(new Sprite((TextureRegion) items.get(key))));
field.set(game.screenMain.paneOptions.currentStyle, game.skinProject.getDrawable(key));
}
}
game.screenMain.saveToSkin();
hide();
game.screenMain.panePreview.refresh();
game.screenMain.paneOptions.updateSelectedTableFields();
} catch (Exception e) {
e.printStackTrace();
}
}
});
String objectType = items.get(key).getClass().getSimpleName();
objectType = objectType.replace("Drawable", "");
buttonItem.row();
buttonItem.add(new Label(key, game.skin));
buttonItem.row();
buttonItem.add(new Label(objectType, game.skin, "title"));
buttonItem.row();
buttonItem.setClip(true);
tableDrawables.add(buttonItem).width(160).height(184).pad(5);
if (count == 4) {
count = 0;
tableDrawables.row();
continue;
}
count++;
}
}
use of com.badlogic.gdx.scenes.scene2d.ui.Label in project gdx-skineditor by cobolfoo.
the class FontPickerDialog method updateTable.
/**
*
*/
public void updateTable() {
fonts = game.skinProject.getAll(BitmapFont.class);
tableFonts.clear();
tableFonts.add(new Label("Font Name", game.skin, "title")).left().width(170);
tableFonts.add(new Label("Value", game.skin, "title")).colspan(3).left().width(60).padRight(50).expandX().fillX();
tableFonts.row();
Iterator<String> it = fonts.keys().iterator();
while (it.hasNext()) {
final String key = it.next();
final BitmapFont font = fonts.get(key);
tableFonts.add(key).left();
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = font;
labelStyle.fontColor = Color.WHITE;
tableFonts.add(new Label("Sample Text", labelStyle)).left();
TextButton buttonSelect = new TextButton("Select", game.skin);
buttonSelect.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
try {
// Since we have reloaded everything we have to get
// field back
game.screenMain.paneOptions.refreshSelection();
field.set(game.screenMain.paneOptions.currentStyle, font);
} catch (Exception e) {
e.printStackTrace();
}
hide();
game.screenMain.panePreview.refresh();
game.screenMain.paneOptions.updateSelectedTableFields();
game.screenMain.saveToSkin();
}
});
TextButton buttonRemove = new TextButton("Remove", game.skin);
buttonRemove.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Dialog dlg = new Dialog("Delete Font", game.skin) {
@Override
protected void result(Object object) {
if ((Boolean) object == false) {
return;
}
if (isFontInUse(font) == true) {
game.showNotice("Error", "Bitmap font already in use!", getStage());
} else {
// Remove files from disk (fnt and png)
FileHandle targetFont = new FileHandle("projects/" + game.screenMain.getcurrentProject() + "/" + key + ".fnt");
FileHandle targetImage = new FileHandle("projects/" + game.screenMain.getcurrentProject() + "/assets/" + key + ".png");
targetFont.delete();
targetImage.delete();
fonts.remove(key);
// update table
updateTable();
game.screenMain.saveToSkin();
}
}
};
dlg.pad(20);
dlg.getContentTable().add("You are sure you want to delete this bitmap font?");
dlg.button("OK", true);
dlg.button("Cancel", false);
dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true);
dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
dlg.show(getStage());
}
});
if (field != null) {
tableFonts.add(buttonSelect).left();
}
tableFonts.add(buttonRemove).left().expandX();
tableFonts.row();
}
}
use of com.badlogic.gdx.scenes.scene2d.ui.Label in project gdx-skineditor by cobolfoo.
the class WelcomeScreen method show.
@Override
public void show() {
Table table = new Table(game.skin);
table.setFillParent(true);
table.setBackground(game.skin.getDrawable("dialogDim"));
stage.addActor(table);
Table tableContent = new Table(game.skin);
tableContent.left();
tableContent.add(new Label("Project List", game.skin, "title")).left().row();
listProjects = new List<String>(game.skin);
ScrollPane scrollPane = new ScrollPane(listProjects, game.skin);
tableContent.add(scrollPane).width(320).height(200).row();
Table tableButtons = new Table(game.skin);
TextButton buttonNewProject = new TextButton("New Project", game.skin);
final TextButton buttonOpen = new TextButton("Open", game.skin);
final TextButton buttonDelete = new TextButton("Delete", game.skin);
buttonOpen.setDisabled(true);
buttonDelete.setDisabled(true);
tableButtons.add(buttonNewProject).pad(5).expandX().fillX();
tableButtons.add(buttonOpen).pad(5).width(92);
tableButtons.add(buttonDelete).pad(5).width(92);
tableContent.add(tableButtons).expandX().fillX();
table.add(tableContent);
Gdx.input.setInputProcessor(stage);
listProjects.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (listProjects.getSelected() != null) {
buttonOpen.setDisabled(false);
buttonDelete.setDisabled(false);
} else {
buttonOpen.setDisabled(true);
buttonDelete.setDisabled(true);
}
}
});
buttonNewProject.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
showNewProjectDialog();
}
});
buttonOpen.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
game.screenMain.setCurrentProject((String) listProjects.getSelected());
game.setScreen(game.screenMain);
}
});
buttonDelete.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
showDeleteDialog();
}
});
refreshProjects();
// NinePatchEditorDialog dlg = new NinePatchEditorDialog(game);
// dlg.show(stage);
}
Aggregations