|
@@ -6,7 +6,20 @@ public class Main
|
|
|
public static void main(String[] args)
|
|
|
{
|
|
|
JFrame window = new JFrame("Fotag!");
|
|
|
- Model model = new Model();
|
|
|
+ Model model;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ FileInputStream file = new FileInputStream("savestate.shit");
|
|
|
+ ObjectInputStream object = new ObjectInputStream(file);
|
|
|
+ model = object.readObject();
|
|
|
+ object.close();
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ model = new Model();
|
|
|
+ }
|
|
|
+
|
|
|
Gallery gallery = new Gallery(model);
|
|
|
Controls controls = new Controls(model);
|
|
|
model.notifyObservers();
|
|
@@ -24,7 +37,31 @@ public class Main
|
|
|
window.setPreferredSize(new Dimension(1280,720));
|
|
|
window.setMinimumSize(new Dimension(320, 180));
|
|
|
window.pack();
|
|
|
- window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
+ //window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
+
|
|
|
+ window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
|
|
+ window.addWindowListener(new WindowAdapter()
|
|
|
+ {
|
|
|
+ public void windowClosing(WindowEvent we)
|
|
|
+ {
|
|
|
+ String ObjButtons[] = {"Yes","No"};
|
|
|
+ int PromptResult = JOptionPane.showOptionDialog(null,"Do you want to save your files?","",JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE,null,ObjButtons,ObjButtons[1]);
|
|
|
+
|
|
|
+ if(PromptResult==JOptionPane.YES_OPTION)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ FileOutputStream file = new FileOutputStream("savestate.shit");
|
|
|
+ ObjectOutputStream object = new ObjectOutputStream(file);
|
|
|
+ object.writeObject(model);
|
|
|
+ object.close();
|
|
|
+ } catch(Exception e) {System.out.println("Screw you ankil");}
|
|
|
+ }
|
|
|
+
|
|
|
+ System.exit(0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
window.setVisible(true);
|
|
|
}
|
|
|
}
|