-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added saving and loading complex scenes
- Loading branch information
1 parent
bc5b821
commit 084bf55
Showing
15 changed files
with
172 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/com/marginallyclever/ro3/actions/ExportScene.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.marginallyclever.ro3.actions; | ||
|
||
import com.marginallyclever.robotoverlord.RobotOverlord; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.io.File; | ||
|
||
/** | ||
* Export the scene to a file for sharing on another computer. This is not the same as saving the scene. | ||
* Exporting the scene will save the scene and all the assets it uses to a single file. | ||
*/ | ||
public class ExportScene extends AbstractAction { | ||
private static final Logger logger = LoggerFactory.getLogger(SaveScene.class); | ||
private static final JFileChooser chooser = new JFileChooser(); | ||
|
||
public ExportScene() { | ||
super("Export Scene"); | ||
} | ||
|
||
/** | ||
* Invoked when an action occurs. | ||
* | ||
* @param e the event to be processed | ||
*/ | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
chooser.setFileFilter(RobotOverlord.FILE_FILTER); | ||
Component source = (Component) e.getSource(); | ||
JFrame parentFrame = (JFrame)SwingUtilities.getWindowAncestor(source); | ||
|
||
if (chooser.showSaveDialog(parentFrame) == JFileChooser.APPROVE_OPTION) { | ||
// check before overwriting. | ||
File selectedFile = chooser.getSelectedFile(); | ||
if (selectedFile.exists()) { | ||
int response = JOptionPane.showConfirmDialog(null, | ||
"Do you want to replace the existing file?", | ||
"Confirm Overwrite", | ||
JOptionPane.YES_NO_OPTION, | ||
JOptionPane.QUESTION_MESSAGE); | ||
if (response == JOptionPane.NO_OPTION) { | ||
return; | ||
} | ||
} | ||
|
||
String absolutePath = chooser.getSelectedFile().getAbsolutePath(); | ||
exportScene(absolutePath); | ||
} | ||
} | ||
|
||
private void exportScene(String absolutePath) { | ||
logger.info("Export scene to {}", absolutePath); | ||
logger.error("Not implemented yet."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.