コード例 #1
0
ファイル: TngInfo.cs プロジェクト: oomek/Ego-Engine-Modding
        public TngInfo(TngBinaryReader reader, TngFile file)
        {
            Id = (int)reader.BaseStream.Position - 12;
            Name = reader.ReadTerminatedString(0x00);
            IsParent = Name.Contains('/');

            file.TngInfo.Add(Id, this);
        }
コード例 #2
0
        public TngInfo(TngBinaryReader reader, TngFile file)
        {
            Id       = (int)reader.BaseStream.Position - 12;
            Name     = reader.ReadTerminatedString(0x00);
            IsParent = Name.Contains('/');

            file.TngInfo.Add(Id, this);
        }
コード例 #3
0
ファイル: TngEntry.cs プロジェクト: Tarec/Ego-Engine-Modding
        public TngEntry(TngBinaryReader reader, TngFile file, bool isParent = true)
        {
            File   = file;
            InfoId = reader.ReadInt32();
            Data   = new Dictionary <string, object>();

            if (isParent)
            {
                Id = reader.ReadInt16();
                Data.Add("InstructionCode", reader.ReadInt32());
                switch ((int)Data["InstructionCode"])
                {
                case 0:
                    Data.Add("Val", reader.ReadSingle());
                    break;

                case 1:
                    Data.Add("LinkedInfoId", reader.ReadInt32());
                    Data.Add("Val", reader.ReadSingle());
                    break;

                default:
                    throw new Exception("Invalid instruction code!");
                }

                Data.Add("InstructionCode2", reader.ReadInt32());
                switch ((int)Data["InstructionCode2"])
                {
                case 4:
                case 1:
                case 0:
                    Data.Add("Val2", reader.ReadSingle());
                    Data.Add("Val3", reader.ReadSingle());
                    break;

                case 3:
                    Data.Add("LinkedInfoId2", reader.ReadInt32());
                    break;

                default:
                    throw new Exception("Invalid instruction code 2! " + reader.BaseStream.Position);
                }

                ChildEntry = new TngEntry[reader.ReadInt32()];
                for (int i = 0; i < ChildEntry.Length; i++)
                {
                    ChildEntry[i] = new TngEntry(reader, file, false);
                }
            }
            else
            {
                Id = -1;
                Data.Add("Val", reader.ReadSingle());
                Data.Add("Val2", reader.ReadSingle());
                Data.Add("Num", reader.ReadInt32());
                ChildEntry = new TngEntry[0];
            }
        }
コード例 #4
0
        public TngEntry(TngBinaryReader reader, TngFile file, bool isParent = true)
        {
            File = file;
            InfoId = reader.ReadInt32();
            Data = new Dictionary<string, object>();

            if (isParent)
            {
                Id = reader.ReadInt16();
                Data.Add("InstructionCode", reader.ReadInt32());
                switch ((int)Data["InstructionCode"])
                {
                    case 0:
                        Data.Add("Val", reader.ReadSingle());
                        break;
                    case 1:
                        Data.Add("LinkedInfoId", reader.ReadInt32());
                        Data.Add("Val", reader.ReadSingle());
                        break;
                    default:
                        throw new Exception("Invalid instruction code!");
                }

                Data.Add("InstructionCode2", reader.ReadInt32());
                switch ((int)Data["InstructionCode2"])
                {
                    case 4:
                    case 1:
                    case 0:
                        Data.Add("Val2", reader.ReadSingle());
                        Data.Add("Val3", reader.ReadSingle());
                        break;
                    case 3:
                        Data.Add("LinkedInfoId2", reader.ReadInt32());
                        break;
                    default:
                        throw new Exception("Invalid instruction code 2! " + reader.BaseStream.Position);
                }

                ChildEntry = new TngEntry[reader.ReadInt32()];
                for (int i = 0; i < ChildEntry.Length; i++)
                {
                    ChildEntry[i] = new TngEntry(reader, file, false);
                }
            }
            else
            {
                Id = -1;
                Data.Add("Val", reader.ReadSingle());
                Data.Add("Val2", reader.ReadSingle());
                Data.Add("Num", reader.ReadInt32());
                ChildEntry = new TngEntry[0];
            }
        }
コード例 #5
0
 private void Open(string fileName)
 {
     try
     {
         treeView.Nodes.Clear();
         dataGridView.Rows.Clear();
         this.Text = fileName + " - Ego TNG Editor";
         file = new TngFile(File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read));
         file.CreateTreeViewList(treeView);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to open the file: " + Environment.NewLine + Environment.NewLine + ex.Message,
             "Tng Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Text = "Ego TNG Editor";
     }
 }