/*
 * Decompiled with CFR 0_132.
 */
package save;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import main.ChronoPanel;
import main.ChronoWindow;
import main.Main;
import signals.AdaptSignals;
import signals.Signals;
import tools.Arrow;

public class Slot {
    public static void save(File saveDir) {
        try {
            ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(saveDir)));
            oos.writeObject(ChronoWindow.chrono.get((int)ChronoWindow.active).signals.size());
            int i = 0;
            while (i < ChronoWindow.chrono.get((int)ChronoWindow.active).signals.size()) {
                oos.writeObject(ChronoWindow.chrono.get((int)ChronoWindow.active).signals.get(i));
                ++i;
            }
            oos.writeObject(ChronoWindow.chrono.get((int)ChronoWindow.active).nbrTimeLapse);
            oos.writeObject(ChronoWindow.chrono.get((int)ChronoWindow.active).timeLapse);
            oos.writeObject(ChronoWindow.chrono.get((int)ChronoWindow.active).displayBackLines);
            oos.writeObject(Main.version);
            oos.writeObject(ChronoWindow.chrono.get((int)ChronoWindow.active).antialiasing);
            oos.writeObject(ChronoWindow.chrono.get((int)ChronoWindow.active).arrows.size());
            i = 0;
            while (i < ChronoWindow.chrono.get((int)ChronoWindow.active).arrows.size()) {
                oos.writeObject(ChronoWindow.chrono.get((int)ChronoWindow.active).arrows.get(i));
                ++i;
            }
            oos.close();
        }
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void load(File openDir) {
        int size = 0;
        try {
            ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(openDir)));
            try {
                size = (Integer)ois.readObject();
                int i = 0;
                while (i < size) {
                    ChronoWindow.chrono.get((int)ChronoWindow.active).signals.add(new AdaptSignals((Signals)ois.readObject()));
                    ++i;
                }
                ChronoWindow.chrono.get((int)ChronoWindow.active).nbrTimeLapse = (Integer)ois.readObject();
                ChronoWindow.chrono.get((int)ChronoWindow.active).timeLapse = (int[][])ois.readObject();
                ChronoWindow.chrono.get((int)ChronoWindow.active).displayBackLines = (Boolean)ois.readObject();
                String version = (String)ois.readObject();
                ChronoWindow.chrono.get((int)ChronoWindow.active).antialiasing = (Boolean)ois.readObject();
                int arrowSize = (Integer)ois.readObject();
                int i2 = 0;
                while (i2 < arrowSize) {
                    ChronoWindow.chrono.get((int)ChronoWindow.active).arrows.add((Arrow)ois.readObject());
                    ++i2;
                }
            }
            catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            ois.close();
        }
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
}

