public UnitGroupsForm(LevelDoc lvld, UnitGroupManager ugm) { // // Required for Windows Form Designer support // InitializeComponent(); // m_ugm = ugm; m_lvld = lvld; m_ugm.ClearModified(); InitUnitGroupsListBox(); InitSideComboBox(); InitAggressivenessComboBox(); InitSpawnAreaComboBox(); }
// ISerializable implemented to prevent events from being serialized public LevelDoc(SerializationInfo info, StreamingContext ctx) : base((DocTemplate)(((Hashtable)ctx.Context)["DocTemplate"]), (string)(((Hashtable)ctx.Context)["Filename"])) { s_fLoading = true; CaTypeSwitch.InitFixupList(); Title = info.GetString("Title"); m_trcBounds.X = info.GetInt32("BoundsX"); m_trcBounds.Y = info.GetInt32("BoundsY"); m_trcBounds.Width = info.GetInt32("BoundsWidth"); m_trcBounds.Height = info.GetInt32("BoundsHeight"); try { // These were introduced at the same time so either they're both present or they both aren't m_ctx = info.GetInt32("Width"); m_cty = info.GetInt32("Height"); } catch (SerializationException) { } // Default values in case they aren't present m_nPlayersMin = 1; m_nPlayersMax = 1; try { // These were introduced at the same time so either they're both present or they both aren't m_nPlayersMin = info.GetInt32("MinPlayers"); m_nPlayersMax = info.GetInt32("MaxPlayers"); } catch (SerializationException) { } // Side info try { m_asidiDeserializationTemp = (SideInfo[])info.GetValue("SideInfos", typeof(SideInfo[])); } catch (SerializationException) { } // TriggerManager try { m_tgrm = (TriggerManager)info.GetValue("TriggerManager", typeof(TriggerManager)); } catch (SerializationException) { m_tgrm = new TriggerManager(); } // UnitGroupManager try { m_ugm = (UnitGroupManager)info.GetValue("UnitGroupManager", typeof(UnitGroupManager)); } catch (SerializationException) { m_ugm = new UnitGroupManager(); } // SwitchManager try { m_swm = (SwitchManager)info.GetValue("SwitchManager", typeof(SwitchManager)); } catch (SerializationException) { m_swm = new SwitchManager(); } // CounterManager try { m_ctrm = (CounterManager)info.GetValue("CounterManager", typeof(CounterManager)); } catch (SerializationException) { m_ctrm = new CounterManager(); } // Comment string try { m_strComment = info.GetString("Comment"); } catch (SerializationException) { } // Support old .ld's that have separate .map files string strTemplatesFileName = null; try { string strFile = info.GetString("MapFileName"); if (strFile != null) { Stream stm = null; try { IFormatter fmtr = new BinaryFormatter(); stm = new FileStream(m_strDir + Path.DirectorySeparatorChar + strFile, FileMode.Open, FileAccess.Read, FileShare.Read); strTemplatesFileName = (string)fmtr.Deserialize(stm); SetTemplateDoc((TemplateDoc)DocManager.OpenDocument(m_strDir + Path.DirectorySeparatorChar + strTemplatesFileName)); m_alsmi.AddRange((IMapItem[])fmtr.Deserialize(stm)); stm.Close(); } catch { if (stm != null) stm.Close(); } } } catch(SerializationException) { } // Load the desired template set if (m_tmpd == null) { try { strTemplatesFileName = info.GetString("TemplatesFileName"); SetTemplateDoc((TemplateDoc)DocManager.OpenDocument(m_strDir + Path.DirectorySeparatorChar + strTemplatesFileName)); } catch (SerializationException) { // If couldn't load it, use the active one SetTemplateDoc(null); string strT = "Couldn't load " + strTemplatesFileName; if (m_tmpd != null) strT += " - Using " + m_tmpd.GetName(); MessageBox.Show(strT); } } // Load the map items m_amiDeserializationTemp = (IMapItem[])info.GetValue("MapItems", typeof(IMapItem[])); }