Package com.google.code.timetrail.backend

Examples of com.google.code.timetrail.backend.GameSave


    private Control gameControl;
    private JPanel myCD;
    GameSave saveGame;
    JList list;
    public SaveGameFrame(Control myControl, JPanel cd) throws ClassNotFoundException, IOException {
        saveGame = new GameSave();
        this.gameControl = myControl;
        this.myCD = cd;
        setLayout(null);
       
       
        list = new JList(saveGame.listOfEntries());
        list.setBounds(121, 80, 201, 155);
        list.setVisibleRowCount(4);
        JScrollPane scrollBar = new JScrollPane(list);
        scrollBar.setBounds(77, 80, 279, 155);
        add(scrollBar);
       
        JButton btnBack = new JButton("Back");
        btnBack.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                myCD.add(new InventoryFrame(gameControl, myCD), "TakeMove");
                CardLayout cd = (CardLayout) myCD.getLayout();
                cd.last(myCD);
            }
        });
        btnBack.setBounds(77, 266, 89, 23);
        add(btnBack);
       
        JButton btnLoad = new JButton("New Save");
        btnLoad.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    GameSave saveGame = new GameSave();
                    saveGame.saveGame(gameControl, gameControl.getPlayer().getName());
                } catch (ClassNotFoundException s) {
                   
                    s.printStackTrace();
                } catch (IOException s) {
                   
                    s.printStackTrace();
                }
                try {
          myCD.add(new SaveGameFrame(gameControl, myCD), "TakeMove");
        } catch (ClassNotFoundException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        } catch (IOException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
                CardLayout cd = (CardLayout) myCD.getLayout();
                cd.last(myCD);
            }
        });
        btnLoad.setBounds(176, 266, 89, 23);
        add(btnLoad);
       
        JButton btnNewButton = new JButton("Overwrite");
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
               
                //Control loadedGame = new Control();
                int selectedIndex = list.getSelectedIndex();
                String[] saveFile = new String[2];
                try {
                    if(selectedIndex >= 0){
                        saveFile = saveGame.listOfEntries()[selectedIndex].split(" ");
                        String saveName = "";
                        String saveDate = "";
                        int count = 0;
                        for(String word: saveFile){
                            if(count < saveFile.length - 2){
                                saveName += word;
                                if(count < saveFile.length - 3){
                                    saveName += " ";
                                }
                            } else {
                                saveDate += word;
                                if(count < saveFile.length - 1){
                                    saveDate += " ";
                                }
                            }
                            count++;
                        }
                        saveFile[0] = saveName;
                        saveFile[1] = saveDate;
                    }
                            //This assumes the name is not two words
                } catch (ClassNotFoundException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                try {
                    if(selectedIndex >= 0){
                        saveGame.overwriteGame(saveFile[0], gameControl, saveFile[1]);
                    }
                } catch (ClassNotFoundException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IOException e1) {
View Full Code Here


    private Control gameControl;
    private JPanel myCD;
    GameSave saveGame;
    JList list;
    public LoadGameFrame(Control myControl, JPanel cd) throws ClassNotFoundException, IOException {
        saveGame = new GameSave();
        this.gameControl = myControl;
        this.myCD = cd;
        setLayout(null);
       
       
View Full Code Here

TOP

Related Classes of com.google.code.timetrail.backend.GameSave

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.