Ejemplo n.º 1
0
		internal string GetDesc(SubrecordStructure[] sss, dFormIDLookupI formIDLookup)
		{
			string start = "[Record]" + Environment.NewLine + GetBaseDesc();
			string end;
			try
			{
				end = GetExtendedDesc(sss, formIDLookup);
			}
			catch
			{
				end = "Warning: An error occured while processing the record. It may not conform to the strucure defined in RecordStructure.xml";
			}
			if (end == null) return start;
			else return start + Environment.NewLine + Environment.NewLine + "[Formatted information]" + Environment.NewLine + end;
		}
Ejemplo n.º 2
0
		internal string GetFormattedData(SubrecordStructure ss, dFormIDLookupI formIDLookup)
		{
			int offset = 0;
			string s = ss.name + " (" + ss.desc + ")" + Environment.NewLine;
			try
			{
				for (int j = 0; j < ss.elements.Length; j++)
				{
					if (offset == Data.Length && j == ss.elements.Length - 1 && ss.elements[j].optional) break;
					string s2 = "";
					if (!ss.elements[j].notininfo) s2 += ss.elements[j].name + ": ";
					switch (ss.elements[j].type)
					{
						case ElementValueType.Int:
							string tmps = TypeConverter.h2si(Data[offset], Data[offset + 1], Data[offset + 2], Data[offset + 3]).ToString();
							if (!ss.elements[j].notininfo)
							{
								if (ss.elements[j].hexview) s2 += TypeConverter.h2i(Data[offset], Data[offset + 1], Data[offset + 2], Data[offset + 3]).ToString("X8");
								else s2 += tmps;
								if (ss.elements[j].options != null)
								{
									for (int k = 0; k < ss.elements[j].options.Length; k += 2)
									{
										if (tmps == ss.elements[j].options[k + 1]) s2 += " (" + ss.elements[j].options[k] + ")";
									}
								}
								else if (ss.elements[j].flags != null)
								{
									uint val = TypeConverter.h2i(Data[offset], Data[offset + 1], Data[offset + 2], Data[offset + 3]);
									string tmp2 = "";
									for (int k = 0; k < ss.elements[j].flags.Length; k++)
									{
										if ((val & (1 << k)) != 0)
										{
											if (tmp2.Length > 0) tmp2 += ", ";
											tmp2 += ss.elements[j].flags[k];
										}
									}
									if (tmp2.Length > 0) s2 += " (" + tmp2 + ")";
								}
							}
							offset += 4;
							break;
						case ElementValueType.Short:
							tmps = TypeConverter.h2ss(Data[offset], Data[offset + 1]).ToString();
							if (!ss.elements[j].notininfo)
							{
								if (ss.elements[j].hexview) s2 += TypeConverter.h2ss(Data[offset], Data[offset + 1]).ToString("X4");
								else s2 += tmps;
								if (ss.elements[j].options != null)
								{
									for (int k = 0; k < ss.elements[j].options.Length; k += 2)
									{
										if (tmps == ss.elements[j].options[k + 1]) s2 += " (" + ss.elements[j].options[k] + ")";
									}
								}
								else if (ss.elements[j].flags != null)
								{
									uint val = TypeConverter.h2s(Data[offset], Data[offset + 1]);
									string tmp2 = "";
									for (int k = 0; k < ss.elements[j].flags.Length; k++)
									{
										if ((val & (1 << k)) != 0)
										{
											if (tmp2.Length > 0) tmp2 += ", ";
											tmp2 += ss.elements[j].flags[k];
										}
									}
									if (tmp2.Length > 0) s2 += " (" + tmp2 + ")";
								}
							}
							offset += 2;
							break;
						case ElementValueType.Byte:
							tmps = Data[offset].ToString();
							if (!ss.elements[j].notininfo)
							{
								if (ss.elements[j].hexview) s2 += Data[offset].ToString("X2");
								else s2 += tmps;
								if (ss.elements[j].options != null)
								{
									for (int k = 0; k < ss.elements[j].options.Length; k += 2)
									{
										if (tmps == ss.elements[j].options[k + 1]) s2 += " (" + ss.elements[j].options[k] + ")";
									}
								}
								else if (ss.elements[j].flags != null)
								{
									int val = Data[offset];
									string tmp2 = "";
									for (int k = 0; k < ss.elements[j].flags.Length; k++)
									{
										if ((val & (1 << k)) != 0)
										{
											if (tmp2.Length > 0) tmp2 += ", ";
											tmp2 += ss.elements[j].flags[k];
										}
									}
									if (tmp2.Length > 0) s2 += " (" + tmp2 + ")";
								}
							}
							offset++;
							break;
						case ElementValueType.FormID:
							uint id = TypeConverter.h2i(Data[offset], Data[offset + 1], Data[offset + 2], Data[offset + 3]);
							if (!ss.elements[j].notininfo) s2 += id.ToString("X8");
							if (formIDLookup != null) s2 += ": " + formIDLookup(id);
							offset += 4;
							break;
						case ElementValueType.Float:
							if (!ss.elements[j].notininfo) s2 += TypeConverter.h2f(Data[offset], Data[offset + 1], Data[offset + 2], Data[offset + 3]).ToString();
							offset += 4;
							break;
						case ElementValueType.String:
							if (!ss.elements[j].notininfo)
							{
								while (Data[offset] != 0) s2 += (char)Data[offset++];
							}
							else
							{
								while (Data[offset] != 0) offset++;
							}
							offset++;
							break;
						case ElementValueType.fstring:
							s2 += GetStrData();
							break;
						case ElementValueType.Blob:
							s2 += GetHexData();
							break;
						default:
							throw new ApplicationException();
					}
					if (!ss.elements[j].notininfo) s2 += Environment.NewLine;
					if (offset < Data.Length && j == ss.elements.Length - 1 && ss.elements[j].repeat) j--;
					s += s2;
				}
			}
			catch
			{
				s += "Warning: Subrecord doesn't seem to match the expected structure" + Environment.NewLine;
			}
			return s;
		}
Ejemplo n.º 3
0
		private string GetExtendedDesc(SubrecordStructure[] sss, dFormIDLookupI formIDLookup)
		{
			if (sss == null) return null;
			string s = RecordStructure.Records[Name].description + Environment.NewLine;
			for (int i = 0; i < sss.Length; i++)
			{
				if (sss[i].elements == null) return s;
				if (sss[i].notininfo) continue;
				s += Environment.NewLine + SubRecords[i].GetFormattedData(sss[i], formIDLookup);
			}
			return s;
		}