/*
 * $Id$
 *
 * Copyright (c) 2000-2007 by Rodney Kinney
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASSAL.launch;

import java.awt.Component;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import javax.swing.JFrame;

import VASSAL.build.GameModule;
import VASSAL.build.module.ExtensionsLoader;
import VASSAL.i18n.Localization;
import VASSAL.i18n.Resources;
import VASSAL.tools.DataArchive;
import VASSAL.tools.FileChooser;

/**
 * Loads a module in play mode
 * 
 * @author rodneykinney
 */
public class LoadModuleAction extends GameModuleAction {
  private static final long serialVersionUID = 1L;
  private File moduleFile;

  public LoadModuleAction(Component comp) {
    super(Resources.getString("Main.play_module"), comp);
  }

  public LoadModuleAction(File moduleFile) {
    super(Resources.getString("Main.play_module"), null);
    this.moduleFile = moduleFile;
  }

  public void performAction(ActionEvent e) throws IOException {
    actionCancelled = true;
    File target = moduleFile;
    if (target == null) {
      if (fc.showOpenDialog() == FileChooser.APPROVE_OPTION) {
        File f = fc.getSelectedFile();
        if (f != null && f.exists()) {
          target = f;
        }
      }

      // bail out if still no target
      if (target == null) return;
    }
 
    loadModule(target);
    actionCancelled = false;
  }

  protected void loadModule(File f) throws IOException {
    final JFrame frame = ModuleManager.getInstance().getFrame();
    frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    GameModule.init(new BasicModule(new DataArchive(f.getPath())));
    ModuleManager.getInstance().addModule(f);
    Localization.getInstance().translate();
    new ExtensionsLoader().addTo(GameModule.getGameModule());
    GameModule.getGameModule().getWizardSupport().showWelcomeWizard();
    
    frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    frame.setVisible(false);
  }
}

@@ -2182,16 +2182,28 @@
 SOR));%0A%0A
+    try %7B%0A  
     Game
@@ -2266,16 +2266,18 @@
 ));%0A    
+ 
+ 
 ModuleMa
@@ -2310,16 +2310,18 @@
 ule(f);%0A
+  
     Loca
@@ -2360,16 +2360,18 @@
 ();%0A    
+  
 new Exte
@@ -2420,24 +2420,26 @@
 ule());%0A    
+ 
+ 
 GameModule.g
@@ -2498,16 +2498,69 @@
 );%0A    %0A
+      frame.setVisible(false);%0A    %7D%0A    finally %7B%0A  
     fram
@@ -2631,32 +2631,9 @@
     
-frame.setVisible(false);
+%7D
 %0A  %7D

Reset the cursor in a finally block, in case there's an exception thrown.