예제 #1
0
 public TDFDictionaryConverter(TDF file)
 {
     using (var reader = new BinaryReaderExt(new MemoryStream(file.ResTable)))
     {
         for (var row = 0; row < file.Header.Row; row++)
         {
             var columns = new List <string>();
             for (var col = 0; col < file.Header.Col; col++)
             {
                 var colText = reader.ReadUnicode();
                 columns.Add(colText.Trim());
             }
             Rows.Add(row, columns);
         }
     }
 }
예제 #2
0
        // TODO: move to XiQuestTable?
        public static Dictionary <uint, XiStrQuest> LoadFromTdf(TdfReader tdfReader)
        {
            var questList = new Dictionary <uint, XiStrQuest>();

            using (var reader = new BinaryReaderExt(new MemoryStream(tdfReader.ResTable)))
            {
                for (var row = 0; row < tdfReader.Header.Row; row++)
                {
                    var quest = new XiStrQuest();
                    quest.QuestId = reader.ReadUnicode();

                    /*quest.QuestIdN = Convert.ToUInt32(reader.ReadUnicode());
                     * quest.PrevQuestIdN = Convert.ToUInt32(reader.ReadUnicode());*/
                    quest.QuestIdN =
                        Convert.ToUInt32(reader.ReadUnicode()) -
                        1; // -1 since the request the client sents us are 0 based
                    quest.PrevQuestIdN =
                        Convert.ToUInt32(reader.ReadUnicode()) -
                        1; // -1 since the request the client sents us are 0 based
                    quest.Event            = (uint)QuestEventStrToVar(reader.ReadUnicode());
                    quest.NeedLevel        = Convert.ToUInt32(reader.ReadUnicode());
                    quest.NeedLevelPercent = Convert.ToUInt32(reader.ReadUnicode());
                    quest.GivePost         = reader.ReadUnicode();
                    quest.Title            = reader.ReadUnicode();
                    quest.EndPost          = reader.ReadUnicode();

                    quest.Place = new string[5];
                    for (var i = 0; i < 5; i++)
                    {
                        quest.Place[i] = reader.ReadUnicode();
                    }

                    quest.CrashTime = new int[5];
                    for (var i = 0; i < 5; i++)
                    {
                        quest.CrashTime[i] = Convert.ToInt32(reader.ReadUnicode());
                    }

                    quest.TimeLimit = new int[5];
                    for (var i = 0; i < 5; i++)
                    {
                        quest.TimeLimit[i] = Convert.ToInt32(reader.ReadUnicode());
                    }

                    quest.MinSpeed = new int[5];
                    for (var i = 0; i < 5; i++)
                    {
                        quest.MinSpeed[i] = Convert.ToInt32(reader.ReadUnicode());
                    }

                    quest.MaxSpeed = new int[5];
                    for (var i = 0; i < 5; i++)
                    {
                        quest.MaxSpeed[i] = Convert.ToInt32(reader.ReadUnicode());
                    }

                    quest.MinLadius = new int[5];
                    for (var i = 0; i < 5; i++)
                    {
                        quest.MinLadius[i] = Convert.ToInt32(reader.ReadUnicode());
                    }

                    quest.MaxLadius = new int[5];
                    for (var i = 0; i < 5; i++)
                    {
                        quest.MaxLadius[i] = Convert.ToInt32(reader.ReadUnicode());
                    }

                    quest.QuestPath_01  = Convert.ToUInt32(reader.ReadUnicode());
                    quest.QuestPath_02  = Convert.ToUInt32(reader.ReadUnicode());
                    quest.Car_01        = Convert.ToUInt32(reader.ReadUnicode());
                    quest.Car_02        = Convert.ToUInt32(reader.ReadUnicode());
                    quest.ClearQuestIdN = Convert.ToUInt32(reader.ReadUnicode());
                    quest.Count         = Convert.ToInt32(reader.ReadUnicode());
                    quest.RewardExp     = Convert.ToInt32(reader.ReadUnicode());
                    quest.RewardMoney   = Convert.ToInt32(reader.ReadUnicode());

                    quest.Item01 = reader.ReadUnicode();
                    quest.Item02 = reader.ReadUnicode();
                    quest.Item03 = reader.ReadUnicode();

                    // TODO: Get Icon by Index
                    //quest.GivePostPtr = GetIconByIndex(quest.GivePost);
                    //quest.EndPostPtr = GetIconByIndex(quest.EndPost);

                    /*
                     * v4 = BS_SingletonHeap < XiIconTable,5 >::GetInstance();
                     * v28.GivePostPtr = XiIconTable::GetIconByIndex(v4, v28.GivePost);
                     * v5 = BS_SingletonHeap < XiIconTable,5 >::GetInstance();
                     * v28.EndPostPtr = XiIconTable::GetIconByIndex(v5, v28.EndPost);
                     */

                    // TODO: Get Item by Id

                    /*
                     * v6 = BS_SingletonHeap < XiItemTable,5 >::GetInstance();
                     * v28.Item01Ptr = XiItemTable::GetItemByID(v6, v28.Item01);
                     * v7 = BS_SingletonHeap < XiItemTable,5 >::GetInstance();
                     * v28.Item02Ptr = XiItemTable::GetItemByID(v7, v28.Item02);
                     * v8 = BS_SingletonHeap < XiItemTable,5 >::GetInstance();
                     * v28.Item03Ptr = XiItemTable::GetItemByID(v8, v28.Item03);
                     * v9 = BS_SingletonHeap < XiVisualItemTable,5 >::GetInstance();
                     * v29 = XiVisualItemTable::GetVisualItemInfo(v9, v28.Item01);
                     * if (v29)
                     *  v28.VSItemPtr = v29;
                     * if (v28.Item01Ptr)
                     ++v28.RewardItemNum;
                     * if (v28.Item02Ptr)
                     ++v28.RewardItemNum;
                     * if (v28.Item03Ptr)
                     ++v28.RewardItemNum;
                     */

                    questList.Add(quest.QuestIdN, quest);
                }
            }

            return(questList);
        }
예제 #3
0
        //std::vector<AssistGroup *,std::allocator<AssistGroup *> > AssistList;

        public static Dictionary <uint, XiStrItem> LoadFromTdf(TdfReader tdfReader)
        {
            var itemList = new Dictionary <uint, XiStrItem>();

            using (var reader = new BinaryReaderExt(new MemoryStream(tdfReader.ResTable)))
            {
                for (var row = 0; row < tdfReader.Header.Row; row++)
                {
                    var item = new XiStrItem();
                    reader.ReadUnicode();                                     // Empty
                    item.Type    = ItemTypeStringToVar(reader.ReadUnicode()); // Type
                    item.SetType = ItemSetTypeStrToVar(reader.ReadUnicode()); // SetType
                    item.ID      = reader.ReadUnicode();                      // Id Name
                    item.GroupID = reader.ReadUnicode();
                    item.Name    = reader.ReadUnicode();
                    reader.ReadUnicode(); // ????
                    item.Grade    = ItemGradeCharToVar(reader.ReadUnicode());
                    item.ReqLevel = Convert.ToUInt16(reader.ReadUnicode());
                    reader.ReadUnicode(); // ????
                    item.Value   = Convert.ToUInt16(reader.ReadUnicode());
                    item.Min     = Convert.ToUInt16(reader.ReadUnicode());
                    item.Max     = Convert.ToUInt16(reader.ReadUnicode());
                    item.Cost    = Convert.ToInt64(reader.ReadUnicode());
                    item.Sell    = Convert.ToUInt16(reader.ReadUnicode());
                    item.NextID  = reader.ReadUnicode();
                    item.Shop    = reader.ReadUnicode().ToLower() == "true";
                    item.Trade   = reader.ReadUnicode().ToLower() == "true";
                    item.Auction = reader.ReadUnicode().ToLower() == "true";
                    var setRate = reader.ReadUnicode();
                    if (setRate != "n/a")
                    {
                        item.SetRate = Convert.ToUInt16(setRate);
                    }
                    else
                    {
                        item.SetRate = 0;
                    }

                    item.SetDesc = reader.ReadUnicode();
                    reader.ReadUnicode(); // SetAssist
                    //__that.SetAssist = XiAssistTable::GetAssistByID(v6, v12);

                    item.Time = Convert.ToUInt16(reader.ReadUnicode());
                    itemList.Add((uint)row, item);
                }
            }
            return(itemList);
        }
예제 #4
0
        private void LoadFile(string filePath)
        {
            saveToolStripMenuItem.Enabled   = true;
            saveAsToolStripMenuItem.Enabled = true;
            closeToolStripMenuItem.Enabled  = true;

            _openFileInfo = new FileInfo(filePath);
            Text          = $@"TDF Viewer ({_openFileInfo.Name})";

            listView1.Columns.Clear();
            listView1.Columns.Add("Row");
            listView1.Items.Clear();

            statusStripLabel1.Text          = $@"Loading file {_openFileInfo.Name}";
            statusStripProgressBar1.Visible = true;

            _tdfFile = new TDF();
            _tdfFile.Load(filePath);

            listView1.BeginUpdate();
            var columnDefFile = "ColumnDefinitions/ColumnDef_" + Path.GetFileNameWithoutExtension(_openFileInfo.Name) +
                                ".txt";

            if (File.Exists(columnDefFile))
            {
                var colNames = File.ReadLines(columnDefFile).ToList();
                if (colNames.Count != _tdfFile.Header.Col)
                {
                    Debug.WriteLine("Definition column size mismatch");
                    columnDefFile = "ColumnDefinitions/ColumnDef_" +
                                    Path.GetFileNameWithoutExtension(_openFileInfo.Name) + "KR.txt";
                    if (File.Exists(columnDefFile))
                    {
                        colNames = File.ReadLines(columnDefFile).ToList();
                        if (colNames.Count != _tdfFile.Header.Col)
                        {
                            if (colNames.Count > _tdfFile.Header.Col)
                            {
                                MessageBox.Show(@"Column Definition file contains more columns than file itself!",
                                                @"Column Definition size mismatch", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                            Debug.WriteLine("Definition (KR) column size mismatch");
                        }
                        else
                        {
                            Text = $@"TDF Viewer (KR: {_openFileInfo.Name})";
                        }
                    }
                    else
                    {
                        if (colNames.Count > _tdfFile.Header.Col)
                        {
                            MessageBox.Show(@"Column Definition file contains more columns than file itself!",
                                            @"Column Definition size mismatch", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                    }
                }
                else
                {
                    Text = $@"TDF Viewer (US: {_openFileInfo.Name})";
                }

                for (var col = 0; col < _tdfFile.Header.Col; col++)
                {
                    listView1.Columns.Add(col < colNames.Count ? colNames[col] : col.ToString());
                }
            }
            else
            {
                for (var col = 0; col < _tdfFile.Header.Col; col++)
                {
                    listView1.Columns.Add(col.ToString());
                }
            }

            // TODO: Async loading :)?
            using (var reader = new BinaryReaderExt(new MemoryStream(_tdfFile.ResTable)))
            {
                for (var row = 0; row < _tdfFile.Header.Row; row++)
                {
                    var lvi = new ListViewItem
                    {
                        Text = row.ToString()
                    };

                    for (var col = 0; col < _tdfFile.Header.Col; col++)
                    {
                        lvi.SubItems.Add(reader.ReadUnicode());
                    }
                    listView1.Items.Add(lvi);
                }
            }
            listView1.EndUpdate();

            statusStripLabel1.Text =
                $@"File (v{_tdfFile.Version.Major}.{_tdfFile.Version.Minor} - {(int) _tdfFile.Header.Date.Month}/{
                        (int) _tdfFile.Header.Date.Day
                    }/{_tdfFile.Header.Date.Year}) loaded with {_tdfFile.Header.Row} rows and {
                        _tdfFile.Header.Col
                    } cols!";
            statusStripProgressBar1.Visible = false;
        }