Example #1
0
 /**
  * Replay the current action as it was when it has been suspended.
  *
  * @param context is the context attached to this action.
  * @param ability is the ability owning this test. The card component of this ability should
  *     correspond to the card owning this test too.
  * @param wizard the hidden wizard frame
  */
 public void replayAction(ContextEventListener context, Ability ability, Wizard wizard) {
   wizard.setVisible(true);
   if (Wizard.optionAnswer != Wizard.BACKGROUND_OPTION) {
     // valid answer
     final int res = Wizard.optionAnswer * 256 + Wizard.indexAnswer;
     Log.debug("answer was " + res);
     ConnectionManager.send(CoreMessageType.TRIGGERED_CARD_CHOICE, (byte) Wizard.indexAnswer);
     setAnswer(Wizard.indexAnswer);
   }
 }
Example #2
0
  /** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */
  public void actionPerformed(ActionEvent e) {
    if ("menu_options_tbs_more".equals(e.getActionCommand())) {
      // goto "more TBS" page
      try {
        WebBrowser.launchBrowser(
            "http://sourceforge.net/project/showfiles.php?group_id="
                + IdConst.PROJECT_ID
                + "&package_id=107882");
      } catch (Exception e1) {
        JOptionPane.showOptionDialog(
            MagicUIComponents.magicForm,
            LanguageManager.getString("error") + " : " + e1.getMessage(),
            LanguageManager.getString("web-pb"),
            JOptionPane.OK_OPTION,
            JOptionPane.INFORMATION_MESSAGE,
            UIHelper.getIcon("wiz_update_error.gif"),
            null,
            null);
      }
      return;
    }
    if ("menu_options_tbs_update".equals(e.getActionCommand())) {
      // update the current TBS
      XmlConfiguration.main(new String[] {"-g", MToolKit.tbsName});
      return;
    }
    if ("menu_options_tbs_rebuild".equals(e.getActionCommand())) {
      /*
       * rebuild completely the current TBS
       */
      XmlConfiguration.main(new String[] {"-f", "-g", MToolKit.tbsName});
      return;
    }

    // We change the TBS

    // Wait for confirmation
    if (JOptionPane.YES_OPTION
        == JOptionPane.showOptionDialog(
            MagicUIComponents.magicForm,
            LanguageManager.getString("warn-disconnect"),
            LanguageManager.getString("disconnect"),
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            UIHelper.getIcon("wiz_update.gif"),
            null,
            null)) {

      // Save the current settings before changing TBS
      Magic.saveSettings();

      // Copy this settings file to the profile directory of this TBS
      final File propertyFile = MToolKit.getFile(IdConst.FILE_SETTINGS);
      try {
        FileUtils.copyFile(propertyFile, MToolKit.getTbsFile(IdConst.FILE_SETTINGS_SAVED, false));

        // Delete the current settings file of old TBS
        propertyFile.delete();

        // Load the one of the new TBS
        abstractMainForm.setMdb(e.getActionCommand());
        Configuration.loadTemplateFile(
            MToolKit.getTbsFile(IdConst.FILE_SETTINGS_SAVED, false).getAbsolutePath());

        // Copy the saved configuration of new TBS
        FileUtils.copyFile(MToolKit.getTbsFile(IdConst.FILE_SETTINGS_SAVED, false), propertyFile);
        Log.info("Successful TBS swith to " + MToolKit.tbsName);

        // Restart the game
        System.exit(IdConst.EXIT_CODE_RESTART);
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    }
  }