use of com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable in project Eidolons by IDemiurge.
the class ActionTooltip method afterUpdateAct.
@Override
public void afterUpdateAct(float delta) {
super.afterUpdateAct(delta);
setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
}
use of com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable in project gdx-skineditor by cobolfoo.
the class NinePatchEditorDialog method refreshPreview.
public void refreshPreview() {
Gdx.app.log("NinePatchEditorDialog", "refresh preview.");
Pixmap pixmapImage = new Pixmap(Gdx.files.internal(textSourceImage.getText()));
Pixmap pixmap = new Pixmap((int) (pixmapImage.getWidth() + 2), (int) (pixmapImage.getHeight() + 2), Pixmap.Format.RGBA8888);
pixmap.drawPixmap(pixmapImage, 1, 1);
pixmap.setColor(Color.BLACK);
// Range left
int h = pixmapImage.getHeight() + 1;
pixmap.drawLine(0, (int) (h * rangeLeft.rangeStart), 0, (int) (h * rangeLeft.rangeStop));
// Range top
int w = pixmapImage.getWidth() + 1;
pixmap.drawLine((int) (w * rangeTop.rangeStart), 0, (int) (w * rangeTop.rangeStop), 0);
// Range right
h = pixmapImage.getHeight() + 1;
pixmap.drawLine(pixmapImage.getWidth() + 1, (int) (h * rangeRight.rangeStart), pixmapImage.getWidth() + 1, (int) (h * rangeRight.rangeStop));
// Range bottom
w = pixmapImage.getWidth() + 1;
pixmap.drawLine((int) (w * rangeBottom.rangeStart), pixmap.getHeight() - 1, (int) (w * rangeBottom.rangeStop), pixmap.getHeight() - 1);
PixmapIO.writePNG(tmpFile, pixmap);
pixmapImage.dispose();
pixmap.dispose();
FileHandle fh = new FileHandle(System.getProperty("java.io.tmpdir")).child("skin_ninepatch");
TexturePacker.Settings settings = new TexturePacker.Settings();
TexturePacker.process(settings, fh.path(), fh.path(), "pack");
TextureAtlas ta = new TextureAtlas(fh.child("pack.atlas"));
NinePatch np = ta.createPatch("button");
NinePatchDrawable drawable = new NinePatchDrawable(np);
reviewTablePreview();
buttonPreview1.getStyle().up = drawable;
}
use of com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable 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++;
}
}
Aggregations