예제 #1
0
파일: Splash.java 프로젝트: adfuhr/JPokemon
    @Override
    public void actionPerformed(ActionEvent arg0) {

      // Get the file
      JFileChooser fc = new JFileChooser(Driver.prefs.get("save_location", ""));
      File f;
      FileNameExtensionFilter filter = new FileNameExtensionFilter("JPokemon Files", "jpkmn");

      fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
      fc.addChoosableFileFilter(filter);

      if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        f = fc.getSelectedFile();
        try {
          // Make sure the file is of type .jpkmn
          if (!f.getName()
              .substring(f.getName().lastIndexOf('.'), f.getName().length())
              .equalsIgnoreCase(".jpkmn")) {
            showFatalErrorMessage("not type .jpkmn");
          }

          // Store the default save location
          Driver.prefs.put("save_location", f.getAbsolutePath());
          Driver.prefs.flush();

          // Load game
          Scanner scan = new Scanner(f);
          player = Player.fromFile(scan);
          splash.dispose();
          new GameWindow(player);
        } catch (Exception e) {
          e.printStackTrace();
          showFatalErrorMessage("General Error");
        }
      } // End if
    }
예제 #2
0
파일: Splash.java 프로젝트: adfuhr/JPokemon
 @Override
 public void actionPerformed(ActionEvent arg0) {
   splash.dispose();
 }
예제 #3
0
파일: Splash.java 프로젝트: adfuhr/JPokemon
 @Override
 public void actionPerformed(ActionEvent arg0) {
   splash.dispose();
   player.createNew();
   new GameWindow(player);
 }