Exemple #1
0
        public void LoadConfig()
        {
            if (File.Exists(ConfigName))
            {
                XmlSerializer s = new XmlSerializer(config.GetType());
                StreamReader  r = File.OpenText(ConfigName);
                config = (AutoHostConfig)s.Deserialize(r);
                r.Close();
                config.AddMissingCommands();
            }
            else
            {
                config.Defaults();
            }

            if (File.Exists(PresetsName))
            {
                XmlSerializer s = new XmlSerializer(presets.GetType());
                StreamReader  r = File.OpenText(PresetsName);
                presets = (List <Preset>)s.Deserialize(r);
                r.Close();
            }

            banList.Load();
        }
    public AutoHost(TasClient tas, Spring spring, AutoHostConfig conf)
    {
      if (conf == null) LoadConfig(); else config = conf;
      SaveConfig();

      this.tas = tas;
      this.spring = spring;

      tas.Said += new EventHandler<TasSayEventArgs>(tas_Said);

      pollTimer = new Timer(PollTimeout * 1000);
      pollTimer.Enabled = false;
      pollTimer.AutoReset = false;
      pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed);

      spring.SpringExited += new EventHandler(spring_SpringExited);
      spring.GameOver += new EventHandler<SpringLogEventArgs>(spring_GameOver);

      tas.BattleUserLeft += new EventHandler<TasEventArgs>(tas_BattleUserLeft);
      tas.UserRemoved += new EventHandler<TasEventArgs>(tas_UserRemoved);
      tas.UserStatusChanged += new EventHandler<TasEventArgs>(tas_UserStatusChanged);
      tas.BattleUserJoined += new EventHandler<TasEventArgs>(tas_BattleUserJoined);
      tas.BattleMapChanged += new EventHandler<TasEventArgs>(tas_BattleMapChanged);
      tas.BattleUserStatusChanged += new EventHandler<TasEventArgs>(tas_BattleUserStatusChanged);
      tas.BattleLockChanged += new EventHandler<TasEventArgs>(tas_BattleLockChanged);

      mapLinker = new MapLinker(spring);
      mapDownloader = new MapDownloader(spring);
      mapDownloader.DownloadCompleted += new EventHandler<TasEventArgs>(mapDownloader_DownloadCompleted);
      mapDownloader.DownloadProgressChanged += new EventHandler<TasEventArgs>(mapDownloader_DownloadProgressChanged);

      tas.BattleFound += new EventHandler<TasEventArgs>(tas_BattleFound);
    }
Exemple #3
0
        public AutoHost(TasClient tas, Spring spring, AutoHostConfig conf)
        {
            banList = new BanList(this, tas);

            if (conf == null)
            {
                LoadConfig();
            }
            else
            {
                config = conf;
            }
            SaveConfig();

            this.tas    = tas;
            this.spring = spring;

            tas.Said += new EventHandler <TasSayEventArgs>(tas_Said);

            pollTimer           = new Timer(PollTimeout * 1000);
            pollTimer.Enabled   = false;
            pollTimer.AutoReset = false;
            pollTimer.Elapsed  += new ElapsedEventHandler(pollTimer_Elapsed);

            spring.SpringExited += new EventHandler(spring_SpringExited);
            spring.GameOver     += new EventHandler <SpringLogEventArgs>(spring_GameOver);

            tas.BattleUserLeft          += new EventHandler <TasEventArgs>(tas_BattleUserLeft);
            tas.UserStatusChanged       += new EventHandler <TasEventArgs>(tas_UserStatusChanged);
            tas.BattleUserJoined        += new EventHandler <TasEventArgs>(tas_BattleUserJoined);
            tas.BattleMapChanged        += new EventHandler <TasEventArgs>(tas_BattleMapChanged);
            tas.BattleUserStatusChanged += new EventHandler <TasEventArgs>(tas_BattleUserStatusChanged);
            tas.BattleLockChanged       += new EventHandler <TasEventArgs>(tas_BattleLockChanged);
            tas.BattleOpened            += new EventHandler <TasEventArgs>(tas_BattleOpened);

            linker        = new UnknownFilesLinker(spring);
            mapDownloader = new MapDownloader(spring);
            mapDownloader.DownloadCompleted       += new EventHandler <TasEventArgs>(mapDownloader_DownloadCompleted);
            mapDownloader.DownloadProgressChanged += new EventHandler <TasEventArgs>(mapDownloader_DownloadProgressChanged);

            modDownloader = new ModDownloader(spring);
            modDownloader.DownloadCompleted       += new EventHandler <TasEventArgs>(modDownloader_DownloadCompleted);
            modDownloader.DownloadProgressChanged += new EventHandler <TasEventArgs>(mapDownloader_DownloadProgressChanged);


            tas.BattleFound += new EventHandler <TasEventArgs>(tas_BattleFound);
        }
    public AutoHost(TasClient tas, Spring spring, AutoHostConfig conf)
    {
      banList = new BanList(this, tas);

      if (conf == null) LoadConfig(); else config = conf;
      SaveConfig();

      this.tas = tas;
      this.spring = spring;

      tas.Said += new EventHandler<TasSayEventArgs>(tas_Said);

      pollTimer = new System.Timers.Timer(PollTimeout * 1000);
      pollTimer.Enabled = false;
      pollTimer.AutoReset = false;
      pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed);

      spring.SpringExited += new EventHandler(spring_SpringExited);
      spring.GameOver += new EventHandler<SpringLogEventArgs>(spring_GameOver);

      tas.BattleUserLeft += new EventHandler<TasEventArgs>(tas_BattleUserLeft);
      tas.UserStatusChanged += new EventHandler<TasEventArgs>(tas_UserStatusChanged);
      tas.BattleUserJoined += new EventHandler<TasEventArgs>(tas_BattleUserJoined);
      tas.BattleMapChanged += new EventHandler<TasEventArgs>(tas_BattleMapChanged);
      tas.BattleUserStatusChanged += new EventHandler<TasEventArgs>(tas_BattleUserStatusChanged);
      tas.BattleLockChanged += new EventHandler<TasEventArgs>(tas_BattleLockChanged);
      tas.BattleOpened += new EventHandler<TasEventArgs>(tas_BattleOpened);

      linker = new UnknownFilesLinker(spring);
      fileDownloader = new FileDownloader(spring);
      fileDownloader.DownloadCompleted += new EventHandler<FileDownloader.DownloadEventArgs>(fileDownloader_DownloadCompleted);
      //fileDownloader.DownloadProgressChanged += new EventHandler<TasEventArgs>(fileDownloader_DownloadProgressChanged);

      tas.BattleFound += new EventHandler<TasEventArgs>(tas_BattleFound);

    }
    public void LoadConfig()
    {
      if (File.Exists(Application.StartupPath + '/' + ConfigName)) {
        XmlSerializer s = new XmlSerializer(config.GetType());
        StreamReader r = File.OpenText(Application.StartupPath + '/' + ConfigName);
        config = (AutoHostConfig)s.Deserialize(r);
        r.Close();
        config.AddMissingCommands();
      } else config.Defaults();

      if (File.Exists(Application.StartupPath + '/' + PresetsName)) {
        XmlSerializer s = new XmlSerializer(presets.GetType());
        StreamReader r = File.OpenText(Application.StartupPath + '/' + PresetsName);
        presets = (List<Preset>)s.Deserialize(r);
        r.Close();
      }

      banList.Load();
    }
 public void LoadConfig()
 {
   if (File.Exists(ConfigName)) {
     XmlSerializer s = new XmlSerializer(config.GetType());
     StreamReader r = File.OpenText(ConfigName);
     config = (AutoHostConfig)s.Deserialize(r);
     r.Close();
     config.AddMissingCommands();
   } else config.Defaults();
 }