use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.
the class MainListener method newFile.
public void newFile() {
if (!projectData.areChangesSaved() && !projectData.isNewProject()) {
var dialog = dialogFactory.yesNoCancelDialog("Save Changes?", "Do you want to save changes to the existing project?" + "\nAll unsaved changes will be lost.", (int selection) -> {
if (selection == 0) {
saveFile(() -> {
Gdx.app.postRunnable(() -> {
projectData.clear();
});
});
} else if (selection == 1) {
projectData.clear();
}
}, dialogListener);
dialog.addListener(new DialogListener() {
@Override
public void opened() {
desktopWorker.removeFilesDroppedListener(rootTable.getFilesDroppedListener());
}
@Override
public void closed() {
desktopWorker.addFilesDroppedListener(rootTable.getFilesDroppedListener());
}
});
} else {
projectData.clear();
}
}
use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.
the class MainListener method openFile.
public void openFile(FileHandle fileHandle) {
Runnable runnable = () -> {
if (fileHandle != null) {
Gdx.app.postRunnable(() -> {
projectData.load(fileHandle);
Array<DrawableData> drawableErrors = projectData.verifyDrawablePaths();
Array<FontData> fontErrors = projectData.verifyFontPaths();
var freeTypeFontErrors = projectData.verifyFreeTypeFontPaths();
if (drawableErrors.size > 0 || fontErrors.size > 0 || freeTypeFontErrors.size > 0) {
dialogFactory.showDialogPathErrors(drawableErrors, fontErrors, freeTypeFontErrors);
}
if (projectData.checkForInvalidMinWidthHeight()) {
projectData.setLoadedVersion(Main.VERSION);
dialogFactory.yesNoDialog("Fix minWidth and minHeight errors?", "Old project (< v.30) detected.\nResolve minWidth and minHeight errors?", new DialogFactory.ConfirmationListener() {
@Override
public void selected(int selection) {
if (selection == 0) {
projectData.fixInvalidMinWidthHeight();
refreshTextureAtlas();
}
}
}, null);
}
projectData.setLastOpenSavePath(fileHandle.parent().path() + "/");
rootTable.populate();
rootTable.updateRecentFiles();
});
}
};
if (!projectData.areChangesSaved() && !projectData.isNewProject()) {
var dialog = dialogFactory.yesNoCancelDialog("Save Changes?", "Do you want to save changes to the existing project?" + "\nAll unsaved changes will be lost.", (int selection) -> {
if (selection == 0) {
saveFile(runnable);
} else if (selection == 1) {
dialogFactory.showDialogLoading(runnable);
}
}, dialogListener);
dialog.addListener(new DialogListener() {
@Override
public void opened() {
desktopWorker.removeFilesDroppedListener(rootTable.getFilesDroppedListener());
}
@Override
public void closed() {
desktopWorker.addFilesDroppedListener(rootTable.getFilesDroppedListener());
}
});
} else {
dialogFactory.showDialogLoading(runnable);
}
}
use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.
the class TableListeners method tableColorListener.
public static EventListener tableColorListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTable = (DialogSceneComposerModel.SimTable) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Color:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var imageButton = new ImageButton(skin, "scene-color");
imageButton.getImage().setColor(simTable.color == null ? Color.WHITE : simTable.color.color);
popTable.add(imageButton).minWidth(100);
imageButton.addListener(handListener);
imageButton.addListener(new TextTooltip("Select the color of the table background and of the table contents.", tooltipManager, skin, "scene"));
popTable.row();
var colorLabel = new Label(simTable.color == null ? "No Color" : simTable.color.getName(), skin, "scene-label-colored");
popTable.add(colorLabel);
imageButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
popTable.hide();
dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
if (!pressedCancel) {
events.tableColor(colorData);
imageButton.getImage().setColor(colorData == null ? Color.WHITE : colorData.color);
colorLabel.setText(colorData == null ? "No Color" : colorData.getName());
}
}, new DialogListener() {
@Override
public void opened() {
}
@Override
public void closed() {
}
});
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.
the class TextButtonListeners method textButtonColorListener.
public static EventListener textButtonColorListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTextButton = (DialogSceneComposerModel.SimTextButton) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Color:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var imageButton = new ImageButton(skin, "scene-color");
imageButton.getImage().setColor(simTextButton.color == null ? Color.WHITE : simTextButton.color.color);
popTable.add(imageButton).minWidth(100);
imageButton.addListener(handListener);
imageButton.addListener(new TextTooltip("Select the color of the button.", tooltipManager, skin, "scene"));
imageButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
popTable.hide();
dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
if (!pressedCancel) {
events.textButtonColor(colorData);
}
}, new DialogListener() {
@Override
public void opened() {
}
@Override
public void closed() {
}
});
}
});
popTable.row();
label = new Label(simTextButton.color == null ? "white" : simTextButton.color.getName(), skin, "scene-label-colored");
popTable.add(label);
}
};
popTableClickListener.update();
return popTableClickListener;
}
Aggregations