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); 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()); using (StreamReader r = File.OpenText(Application.StartupPath + '/' + PresetsName)) { presets = (List<Preset>)s.Deserialize(r); r.Close(); } } if (File.Exists(Application.StartupPath + '/' + BoxesName)) { BinaryFormatter frm = new BinaryFormatter(); using (FileStream r = new FileStream(Application.StartupPath + '/' + BoxesName, FileMode.Open)) { MapBoxes = (Dictionary<string, Dictionary<int, BattleRect>>)frm.Deserialize(r); r.Close(); } } banList.Load(); }
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 += tas_Said; pollTimer = new Timer(PollTimeout*1000); pollTimer.Enabled = false; pollTimer.AutoReset = false; pollTimer.Elapsed += pollTimer_Elapsed; spring.SpringExited += spring_SpringExited; spring.GameOver += spring_GameOver; spring.NotifyModsChanged += spring_NotifyModsChanged; tas.BattleUserLeft += tas_BattleUserLeft; tas.UserStatusChanged += tas_UserStatusChanged; tas.BattleUserJoined += tas_BattleUserJoined; tas.BattleMapChanged += tas_BattleMapChanged; tas.BattleUserStatusChanged += tas_BattleUserStatusChanged; tas.BattleLockChanged += tas_BattleLockChanged; tas.BattleOpened += tas_BattleOpened; linkProvider = new ResourceLinkProvider(); spring.UnitSyncWrapper.Downloader.LinksRecieved += linkProvider.Downloader_LinksRecieved; }