use of com.badlogic.gdx.scenes.scene2d.ui.Dialog in project gdx-skineditor by cobolfoo.
the class OptionsPane method showFloatInputDialog.
/**
*
* Display a input dialog asking for a float value
*
*/
public void showFloatInputDialog(final Field field) {
try {
final TextField textValue = new TextField(String.valueOf((Float) field.get(currentStyle)), game.skin);
Dialog dlg = new Dialog("Change Value", game.skin) {
@Override
protected void result(Object object) {
if ((Boolean) object == false) {
return;
}
float value = 0;
String text = textValue.getText();
if (text.isEmpty() == false) {
value = Float.valueOf(text);
}
try {
field.set(currentStyle, value);
} catch (Exception e) {
e.printStackTrace();
}
game.screenMain.saveToSkin();
refresh();
game.screenMain.paneOptions.updateSelectedTableFields();
game.screenMain.panePreview.refresh();
}
};
dlg.pad(20);
dlg.getContentTable().add("Float Value:");
dlg.getContentTable().add(textValue).pad(20);
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());
getStage().setKeyboardFocus(textValue);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.badlogic.gdx.scenes.scene2d.ui.Dialog in project gdx-skineditor by cobolfoo.
the class ColorPickerDialog method updateTable.
/**
* Refresh table content with colors from the skin
*/
public void updateTable() {
tableColors.clear();
tableColors.add(new Label("Color Name", game.skin, "title")).left().width(170);
tableColors.add(new Label("Value", game.skin, "title")).colspan(2).left().width(60).padRight(50);
tableColors.row();
Iterator<String> it = colors.keys().iterator();
while (it.hasNext()) {
final String key = it.next();
final Color color = colors.get(key);
tableColors.add(key).left();
// Create drawable on the fly
Pixmap pixmap = new Pixmap(18, 18, Pixmap.Format.RGBA8888);
pixmap.setColor(color);
pixmap.fill();
pixmap.setColor(Color.BLACK);
pixmap.drawRectangle(0, 0, 18, 18);
Texture texture = new Texture(pixmap);
pixmap.dispose();
tableColors.add(new Image(texture));
tableColors.add(color.toString()).left();
TextButton buttonSelect = new TextButton("Select", game.skin);
buttonSelect.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
try {
field.set(game.screenMain.paneOptions.currentStyle, color);
} 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 Style", game.skin) {
@Override
protected void result(Object object) {
if ((Boolean) object == false) {
return;
}
if (isColorInUse(color) == true) {
game.showNotice("Error", "Color already in use!", game.screenMain.stage);
} else {
colors.remove(key);
// update table
updateTable();
game.screenMain.saveToSkin();
}
}
};
dlg.pad(20);
dlg.getContentTable().add("You are sure you want to delete this color?");
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(game.screenMain.stage);
}
});
if (field != null) {
tableColors.add(buttonSelect).padRight(5);
}
tableColors.add(buttonRemove);
tableColors.row();
}
}
use of com.badlogic.gdx.scenes.scene2d.ui.Dialog in project gdx-skineditor by cobolfoo.
the class OptionsPane method createNewStyle.
/**
*
*/
protected void createNewStyle() {
final TextField textStyleName = new TextField("", game.skin);
Dialog dlgStyle = new Dialog("New Style", game.skin) {
@Override
protected void result(Object object) {
if ((Boolean) object == false) {
return;
}
String styleName = textStyleName.getText();
if (styleName.length() == 0) {
game.showNotice("Warning", "No style name entered!", game.screenMain.stage);
return;
}
// Check if the style name is already in use
if (listItems.contains(styleName, false)) {
game.showNotice("Warning", "Style name already in use!", game.screenMain.stage);
return;
}
try {
game.skinProject.add(styleName, currentStyle.getClass().newInstance());
} catch (Exception e) {
e.printStackTrace();
}
//game.skinProject.add(text, game.skin.get("default", currentStyle.getClass()), currentStyle.getClass());
game.screenMain.saveToSkin();
refresh();
game.screenMain.panePreview.refresh();
}
};
dlgStyle.pad(20);
dlgStyle.getContentTable().add("Style Name:");
dlgStyle.getContentTable().add(textStyleName).pad(20);
dlgStyle.button("OK", true);
dlgStyle.button("Cancel", false);
dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true);
dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
dlgStyle.show(getStage());
getStage().setKeyboardFocus(textStyleName);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Dialog in project gdx-skineditor by cobolfoo.
the class OptionsPane method showDeleteDialog.
/**
*
*/
protected void showDeleteDialog() {
// Check if it used by other style prior to delete it
// FIXME: TODO
Dialog dlgStyle = new Dialog("Delete Style", game.skin) {
@Override
protected void result(Object object) {
if ((Boolean) object == false) {
return;
}
// Now we really add it!
game.skinProject.remove((String) listStyles.getSelected(), currentStyle.getClass());
refresh();
game.screenMain.saveToSkin();
game.screenMain.panePreview.refresh();
}
};
dlgStyle.pad(20);
dlgStyle.getContentTable().add("You are sure you want to delete this style?");
dlgStyle.button("OK", true);
dlgStyle.button("Cancel", false);
dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true);
dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
dlgStyle.show(getStage());
}
use of com.badlogic.gdx.scenes.scene2d.ui.Dialog in project gdx-skineditor by cobolfoo.
the class DrawablePickerDialog method show.
@Override
public Dialog show(Stage stage) {
refresh();
Dialog d = super.show(stage);
getStage().setScrollFocus(scrollPane);
return d;
}
Aggregations