static BodyDef() { m_Entries = new Dictionary <int, BodyTableEntry>(); string filePath = FileManager.GetFilePath("body.def"); if (filePath == null) { return; } StreamReader def = new StreamReader(filePath); string line; int totalDataRead = 0; while ((line = def.ReadLine()) != null) { totalDataRead += line.Length; if ((line = line.Trim()).Length == 0 || line.StartsWith("#")) { continue; } try { int index1 = line.IndexOf("{"); int index2 = line.IndexOf("}"); string origBody = line.Substring(0, index1); string newBody = line.Substring(index1 + 1, index2 - index1 - 1); string newHue = line.Substring(index2 + 1); int indexOf = newBody.IndexOf(','); if (indexOf > -1) { newBody = newBody.Substring(0, indexOf).Trim(); } int iParam1 = Convert.ToInt32(origBody); int iParam2 = Convert.ToInt32(newBody); int iParam3 = Convert.ToInt32(newHue); m_Entries[iParam1] = new BodyTableEntry(iParam1, iParam2, iParam3); } catch { } } Metrics.ReportDataRead(totalDataRead); }
public static void TranslateBodyAndHue(ref int body, ref int hue) { BodyTableEntry bte = null; if (_entries.TryGetValue(body, out bte)) { body = bte.NewBody; if (hue == 0) { hue = bte.NewHue; } } }
static BodyDef() { m_Entries = new Dictionary<int, BodyTableEntry>(); string filePath = FileManager.GetFilePath("body.def"); if (filePath == null) return; StreamReader def = new StreamReader(filePath); string line; int totalDataRead = 0; while ((line = def.ReadLine()) != null) { totalDataRead += line.Length; if ((line = line.Trim()).Length == 0 || line.StartsWith("#")) continue; try { int index1 = line.IndexOf("{"); int index2 = line.IndexOf("}"); string origBody = line.Substring(0, index1); string newBody = line.Substring(index1 + 1, index2 - index1 - 1); string newHue = line.Substring(index2 + 1); int indexOf = newBody.IndexOf(','); if (indexOf > -1) newBody = newBody.Substring(0, indexOf).Trim(); int iParam1 = Convert.ToInt32(origBody); int iParam2 = Convert.ToInt32(newBody); int iParam3 = Convert.ToInt32(newHue); m_Entries[iParam1] = new BodyTableEntry(iParam1, iParam2, iParam3); } catch { } } Metrics.ReportDataRead(totalDataRead); }
private void OnLoad(object sender, EventArgs e) { facingbar.Value = (facing + 3) & 7; treeView1.BeginUpdate(); treeView1.Nodes.Clear(); treeView1.TreeViewNodeSorter = new AnimNewListGraphicSorter(); MobTypes(); TreeNode node; foreach (DictionaryEntry key in BodyTable.m_Entries) //body.def { BodyTableEntry entry = (BodyTableEntry)key.Value; if (!AlreadyFound(entry.NewID)) { if (!Form.IsAlreadyDefinied(entry.NewID)) { node = new TreeNode(entry.NewID.ToString()); node.Tag = entry.NewID; node.ToolTipText = String.Format("Found in body.def {0}", Animations.GetFileName(entry.NewID)); node.Tag = new int[] { entry.NewID, 0 }; treeView1.Nodes.Add(node); SetActionType(node, entry.NewID, 0); } } } if (BodyConverter.Table1 != null) { foreach (int entry in BodyConverter.Table1) //bodyconv.def { if (entry != -1) { if (!AlreadyFound(entry)) { if (!Form.IsAlreadyDefinied(entry)) { node = new TreeNode(entry.ToString()); node.ToolTipText = String.Format("Found in bodyconv.def {0}", Animations.GetFileName(entry)); node.Tag = entry; node.Tag = new int[] { entry, 0 }; treeView1.Nodes.Add(node); SetActionType(node, entry, 0); } } } } } if (BodyConverter.Table2 != null) { foreach (int entry in BodyConverter.Table2) { if (entry != -1) { if (!AlreadyFound(entry)) { if (!Form.IsAlreadyDefinied(entry)) { node = new TreeNode(entry.ToString()); node.ToolTipText = String.Format("Found in bodyconv.def {0}", Animations.GetFileName(entry)); node.Tag = entry; node.Tag = new int[] { entry, 0 }; treeView1.Nodes.Add(node); SetActionType(node, entry, 0); } } } } } if (BodyConverter.Table3 != null) { foreach (int entry in BodyConverter.Table3) { if (entry != -1) { if (!AlreadyFound(entry)) { if (!Form.IsAlreadyDefinied(entry)) { node = new TreeNode(entry.ToString()); node.ToolTipText = String.Format("Found in bodyconv.def {0}", Animations.GetFileName(entry)); node.Tag = entry; node.Tag = new int[] { entry, 0 }; treeView1.Nodes.Add(node); SetActionType(node, entry, 0); } } } } } if (BodyConverter.Table4 != null) { foreach (int entry in BodyConverter.Table4) { if (entry != -1) { if (!AlreadyFound(entry)) { if (!Form.IsAlreadyDefinied(entry)) { node = new TreeNode(entry.ToString()); node.ToolTipText = String.Format("Found in bodyconv.def {0}", Animations.GetFileName(entry)); node.Tag = entry; node.Tag = new int[] { entry, 0 }; treeView1.Nodes.Add(node); SetActionType(node, entry, 0); } } } } } treeView1.EndUpdate(); }