use of com.ray3k.skincomposer.data.StyleData in project skin-composer by raeleus.
the class DialogFactory method showDeleteStyleDialog.
public void showDeleteStyleDialog(Skin skin, Stage stage) {
StyleData styleData = main.getRootTable().getSelectedStyle();
Dialog dialog = new Dialog("Delete Style", skin, "bg") {
@Override
protected void result(Object object) {
if ((Boolean) object) {
main.getUndoableManager().addUndoable(new DeleteStyleUndoable(styleData, main), true);
}
}
};
dialog.getTitleLabel().setAlignment(Align.center);
dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
dialog.text("Are you sure you want to delete style " + styleData.name + "?");
dialog.getContentTable().getCells().first().pad(10.0f);
dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
dialog.button("Yes, delete the style", true).button("No", false);
dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
dialog.key(Input.Keys.ENTER, true).key(Input.Keys.ESCAPE, false);
dialog.show(stage);
}
use of com.ray3k.skincomposer.data.StyleData in project skin-composer by raeleus.
the class DialogFactory method showDuplicateStyleDialog.
public void showDuplicateStyleDialog(Skin skin, Stage stage) {
Class selectedClass = main.getRootTable().getSelectedClass();
StyleData originalStyle = main.getRootTable().getSelectedStyle();
final TextField textField = new TextField("", skin);
Dialog dialog = new Dialog("Duplicate Style", skin, "bg") {
@Override
protected void result(Object object) {
if ((Boolean) object) {
main.getUndoableManager().addUndoable(new DuplicateStyleUndoable(originalStyle, textField.getText(), main), true);
}
}
};
dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
dialog.button("OK", true).button("Cancel", false);
final TextButton okButton = (TextButton) dialog.getButtonTable().getCells().get(0).getActor();
okButton.addListener(main.getHandListener());
dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
textField.setTextFieldListener((TextField textField1, char c) -> {
if (c == '\n') {
if (!okButton.isDisabled()) {
main.getUndoableManager().addUndoable(new DuplicateStyleUndoable(originalStyle, textField.getText(), main), true);
dialog.hide();
}
main.getStage().setKeyboardFocus(textField1);
}
});
textField.addListener(main.getIbeamListener());
dialog.getTitleLabel().setAlignment(Align.center);
dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
dialog.text("What is the name of the new, duplicated style?");
dialog.getContentTable().getCells().first().pad(10.0f);
dialog.getContentTable().row();
dialog.getContentTable().add(textField).growX();
okButton.setDisabled(true);
Array<StyleData> currentStyles = main.getProjectData().getJsonData().getClassStyleMap().get(selectedClass);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
boolean disable = !StyleData.validate(textField.getText());
if (!disable) {
for (StyleData data : currentStyles) {
if (data.name.equals(textField.getText())) {
disable = true;
break;
}
}
}
okButton.setDisabled(disable);
}
});
dialog.key(Input.Keys.ESCAPE, false);
dialog.show(stage);
stage.setKeyboardFocus(textField);
textField.setFocusTraversal(false);
}
use of com.ray3k.skincomposer.data.StyleData in project skin-composer by raeleus.
the class DialogFonts method renameFont.
private void renameFont(FontData font, String newName) {
for (Array<StyleData> datas : main.getJsonData().getClassStyleMap().values()) {
for (StyleData data : datas) {
for (StyleProperty property : data.properties.values()) {
if (property != null && property.type.equals(BitmapFont.class) && property.value != null && property.value.equals(font.getName())) {
property.value = newName;
}
}
}
}
try {
font.setName(newName);
} catch (FontData.NameFormatException ex) {
Gdx.app.error(getClass().getName(), "Error trying to rename a font.", ex);
main.getDialogFactory().showDialogError("Rename Font Error...", "Error trying to rename a font.\n\nOpen log?");
}
main.getUndoableManager().clearUndoables();
main.getRootTable().refreshStyleProperties(true);
main.getRootTable().refreshPreview();
main.getProjectData().setChangesSaved(false);
refreshTable();
}
use of com.ray3k.skincomposer.data.StyleData in project skin-composer by raeleus.
the class DialogFreeTypeFont method result.
@Override
protected void result(Object object) {
if ((Boolean) object) {
if (mode == Mode.EDIT) {
if (!originalData.name.equals(data.name)) {
for (Array<StyleData> styleDatas : main.getJsonData().getClassStyleMap().values()) {
for (StyleData styleData : styleDatas) {
for (StyleProperty property : styleData.properties.values()) {
if (property != null && property.type.equals(BitmapFont.class) && property.value != null && property.value.equals(originalData.name)) {
property.value = data.name;
}
}
}
}
}
originalData.bitmapFont.dispose();
main.getJsonData().getFreeTypeFonts().removeValue(originalData, false);
main.getUndoableManager().clearUndoables();
main.getRootTable().refreshStyleProperties(true);
main.getProjectData().setChangesSaved(false);
}
data.createBitmapFont(main);
main.getJsonData().getFreeTypeFonts().add(data);
for (DialogFreeTypeFontListener listener : listeners) {
listener.fontAdded(data);
}
}
}
use of com.ray3k.skincomposer.data.StyleData in project skin-composer by raeleus.
the class DialogColors method renameColor.
private void renameColor(ColorData color, String newName) {
// style properties
for (Array<StyleData> datas : main.getJsonData().getClassStyleMap().values()) {
for (StyleData data : datas) {
for (StyleProperty property : data.properties.values()) {
if (property != null && property.type.equals(Color.class) && property.value != null && property.value.equals(color.getName())) {
property.value = newName;
}
}
}
}
// tinted drawables
for (DrawableData drawableData : main.getAtlasData().getDrawables()) {
if (drawableData.tintName != null && drawableData.tintName.equals(color.getName())) {
drawableData.tintName = newName;
}
}
try {
color.setName(newName);
} catch (ColorData.NameFormatException ex) {
Gdx.app.error(getClass().getName(), "Error trying to rename a color.", ex);
main.getDialogFactory().showDialogError("Name Error...", "Error while naming a color.\\nPlease ensure name is formatted appropriately:\\nNo spaces, don't start with a number, - and _ acceptable.\n\nOpen log?");
}
main.getUndoableManager().clearUndoables();
main.getRootTable().refreshStyleProperties(true);
main.getRootTable().refreshPreview();
main.getProjectData().setChangesSaved(false);
refreshTable();
}
Aggregations