mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Add Save As support to mobile app
This commit is contained in:
@@ -328,6 +328,20 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
||||
setSelectedPage(getMainDeckPage()); //select main deck page if needed so main deck if visible below dialog
|
||||
}
|
||||
}));
|
||||
addItem(new FMenuItem("Save As...", FSkinImage.SAVEAS, new FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
String defaultName = editorType.getController().getNextAvailableName();
|
||||
FOptionPane.showInputDialog("Enter name for new copy of deck", defaultName, new Callback<String>() {
|
||||
@Override
|
||||
public void run(String result) {
|
||||
if (!StringUtils.isEmpty(result)) {
|
||||
editorType.getController().saveAs(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
}
|
||||
if (allowRename()) {
|
||||
addItem(new FMenuItem("Rename Deck", FSkinImage.EDIT, new FEventHandler() {
|
||||
@@ -1483,6 +1497,23 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
||||
currentFolder.delete(oldName); //delete deck with old name
|
||||
}
|
||||
|
||||
public String getNextAvailableName() {
|
||||
String name = model.getName();
|
||||
int idx = name.lastIndexOf('(');
|
||||
if (idx != -1) {
|
||||
name = name.substring(0, idx).trim(); //strip old number
|
||||
}
|
||||
|
||||
String baseName = name;
|
||||
int number = 2;
|
||||
do {
|
||||
name = baseName + " (" + number + ")";
|
||||
number++;
|
||||
} while (fileExists(name));
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isSaved() {
|
||||
return saved;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user