internal override bool Reconstruct(Blam.CacheFile c) { bool result = true; if (c.EngineVersion == BlamVersion.Halo2_Alpha) { return(result); } // remove 'geometry postprocessed' Flags.Value = 0; // recreate the section data if (SectionData.Count != 1) { render_model_section_data_block section_data; SectionData.Add(out section_data); result = section_data.Reconstruct(c, SectionInfo.Value, GeometryBlockInfo.Value); } GeometryBlockInfo.Value.ClearPostReconstruction(); return(result); }
public void SetSectionData(MapSection section) { if (!SectionData.ContainsKey(section.Id)) { DrawMapSection drawMapSection = new DrawMapSection(); drawMapSection.X1 = TransferX(section.FromAddress.AGVPosition.Position.X); drawMapSection.Y1 = TransferY(section.FromAddress.AGVPosition.Position.Y); drawMapSection.X2 = TransferX(section.ToAddress.AGVPosition.Position.X); drawMapSection.Y2 = TransferY(section.ToAddress.AGVPosition.Position.Y); SectionData.Add(section.Id, drawMapSection); } }
/// <summary> /// 從DataString字串轉SectionData物件 /// </summary> /// <param name="DataString">DataString字串</param> /// <returns>SectionData物件</returns> protected SectionData GetDataFromString(string DataString) { SectionData sectionData = new SectionData(); string[] data = DataString.Split(spiltCharArray, StringSplitOptions.RemoveEmptyEntries); foreach (string item in data) { string[] KeyValue = item.Split(spiltCharArray_Equal, StringSplitOptions.RemoveEmptyEntries); if (KeyValue.Length > 1) { sectionData.Add(KeyValue[0], KeyValue[1]); } } return(sectionData); }
/// <summary> /// Parses the ledcontrol.ini file. /// </summary> /// <param name="LedControlIniFile">The ledcontrol.ini FileInfo object.</param> /// <param name="ThrowExceptions">if set to <c>true</c> [throw exceptions].</param> /// <exception cref="System.Exception"> /// File {0} does not contain data. /// or /// Could not find {0} section in file {1}. /// or /// File {1} does not contain data in the {0} section. /// or /// Section {0} of file {1} does not have the same number of columns in all lines. /// </exception> private void ParseLedControlIni(FileInfo LedControlIniFile, bool ThrowExceptions = false) { string[] ColorStartStrings = { "[Colors DOF]", "[Colors LedWiz]" }; string[] OutStartStrings = { "[Config DOF]", "[Config outs]" }; string[] VariableStartStrings = { "[Variables DOF]" }; string[] VersionStartStrings = { "[version]" }; string[] TableVariableStartStrings = { "[TableVariables]" };; string FileData = ""; #region Read file try { FileData = General.FileReader.ReadFileToString(LedControlIniFile); } catch (Exception E) { Log.Exception("Could not read file {0}.".Build(LedControlIniFile), E); if (ThrowExceptions) { throw new Exception("Could not read file {0}.".Build(LedControlIniFile), E); } } if (FileData.IsNullOrWhiteSpace()) { Log.Warning("File {0} does not contain data.".Build(LedControlIniFile)); if (ThrowExceptions) { throw new Exception("File {0} does not contain data.".Build(LedControlIniFile)); } } #endregion Dictionary <string, List <string> > Sections = new Dictionary <string, List <String> >(); #region Read sections List <string> SectionData = new List <string>(); String SectionHeader = null; foreach (string RawIniLine in FileData.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)) { string IniLine = RawIniLine.Trim(); if (IniLine.Length > 0 && !IniLine.StartsWith("#")) { if (IniLine.StartsWith("[") && IniLine.EndsWith("]") && IniLine.Length > 2) { //This is a section header if (!SectionHeader.IsNullOrWhiteSpace()) { if (Sections.ContainsKey(SectionHeader)) { int Cnt = 2; while (Sections.ContainsKey("{0} {1}".Build(SectionHeader, Cnt))) { Cnt++; if (Cnt > 999) { throw new Exception("Section header {0} exists to many times.".Build(SectionHeader)); } } SectionHeader = "{0} {1}".Build(SectionHeader, Cnt); } Sections.Add(SectionHeader, SectionData); SectionData = new List <string>(); } SectionHeader = IniLine; } else { //Its a data line SectionData.Add(IniLine); } } } if (!SectionHeader.IsNullOrWhiteSpace()) { if (Sections.ContainsKey(SectionHeader)) { int Cnt = 2; while (Sections.ContainsKey("{0} {1}".Build(SectionHeader, Cnt))) { Cnt++; if (Cnt > 999) { throw new Exception("Section header {0} exists to many times.".Build(SectionHeader)); } } SectionHeader = "{0} {1}".Build(SectionHeader, Cnt); } Sections.Add(SectionHeader, SectionData); SectionData = new List <string>(); } SectionData = null; #endregion FileData = null; List <string> ColorData = GetSection(Sections, ColorStartStrings); List <string> OutData = GetSection(Sections, OutStartStrings); List <string> VariableData = GetSection(Sections, VariableStartStrings); List <string> VersionData = GetSection(Sections, VersionStartStrings); List <string> TableVariableData = GetSection(Sections, TableVariableStartStrings); if (VersionData != null && VersionData.Count > 0) { MinDOFVersion = null; string MinDofVersionLine = VersionData.FirstOrDefault(S => S.ToLowerInvariant().StartsWith("mindofversion=")); if (MinDofVersionLine != null) { string MinDofVersionString = MinDofVersionLine.Substring("mindofversion=".Length); try { MinDOFVersion = new Version(MinDofVersionString); } catch (Exception E) { Log.Exception("Could not parse line {1} from file {0}".Build(LedControlIniFile, MinDofVersionLine)); MinDOFVersion = null; } if (MinDOFVersion != null) { Log.Write("Min DOF Version is {0} for file {1}".Build(MinDOFVersion.ToString(), LedControlIniFile.Name)); } } else { Log.Warning("No DOF version information found in file {0}.".Build(LedControlIniFile)); } } else { Log.Warning("No version section found in file {0}.".Build(LedControlIniFile)); } if (ColorData == null) { Log.Warning("Could not find color definition section in file {0}.".Build(LedControlIniFile)); if (ThrowExceptions) { throw new Exception("Could not find color definition section in file {0}.".Build(LedControlIniFile)); } return; } else if (ColorData.Count < 1) { Log.Warning("File {0} does not contain data in the color definition section.".Build(LedControlIniFile)); if (ThrowExceptions) { throw new Exception("File {0} does not contain data in the color definition section.".Build(LedControlIniFile)); } return; } if (OutData == null) { Log.Warning("Could not find table config section in file {0}.".Build(LedControlIniFile)); if (ThrowExceptions) { throw new Exception("Could not find table config section section in file {1}.".Build(LedControlIniFile)); } return; } else if (OutData.Count < 1) { Log.Warning("File {0} does not contain data in the table config section.".Build(LedControlIniFile)); if (ThrowExceptions) { throw new Exception("File {0} does not contain data in the table config section".Build(LedControlIniFile)); } return; } if (VariableData != null) { ResolveVariables(OutData, VariableData); } if (TableVariableData != null) { ResolveTableVariables(OutData, TableVariableData); } ColorConfigurations.ParseLedControlData(ColorData, ThrowExceptions); TableConfigurations.ParseLedcontrolData(OutData, ThrowExceptions); //ResolveOutputNumbers(); ResolveRGBColors(); this.LedControlIniFile = LedControlIniFile; }