Exemple #1
0
        public static void SaveGame(int SlotID)
        {
            var playerComp = GetComponent().player.GetComponent <Player>();

            Slots[SlotID] = TDF.SaveValueInBlock(Slots[SlotID], "Game", "PlayerPos", GetComponent().player.position.x + "," + GetComponent().player.position.y + "," + GetComponent().player.position.z);
            Slots[SlotID] = TDF.SaveValueInBlock(Slots[SlotID], "Game", "PlayerRot", playerComp.rotation.x + "," + playerComp.rotation.y + "," + playerComp.rotation.z);
            Slots[SlotID] = TDF.SaveValueInBlock(Slots[SlotID], "Game", "PlayerHealth", GetComponent().Health.ToString());
            TDF.Save("Data/SaveData/Slot_" + (SlotID + 1) + ".tdf", Slots[SlotID]);//TDF.SaveGZ
        }
Exemple #2
0
 void Awake()
 {
     p = this.transform;
     net.TBMSP.Lib.Program.Init(Application.persistentDataPath + "/", true);
     Debug.Log("En esta carpeta se guardan los archivos: \"" + net.TBMSP.Lib.Program.RootDirectory + "\"");
     FileBase.CreateDirectory("Data/SaveData");
     for (int i = 0; i < Slots.Length; i++)
     {
         Slots[i] = TDF.CreateString();
     }
 }
 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);
         }
     }
 }
Exemple #4
0
        private void LoadFile(string filePath)
        {
            var tdf = new TDF();

            tdf.Load(filePath);
            _tdfConverter = new TDFDictionaryConverter(tdf);
            try
            {
                _tdfConverter.GetColumnDefinitions(filePath);
            }
            catch (Exception)
            {
                /* ignored */
            }
            _openFileInfo = new FileInfo(filePath);
            Text          = $@"{_openFileInfo.Name} - TDF Viewer";

            LoadFile();
        }
Exemple #5
0
        private void fileTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            SelectedNode = e.Node;

            bool isTDF = SelectedNode.Tag is AGTFile && (SelectedNode.Tag as AGTFile).Name.Contains(".tdf");

            tdfToolStripMenuItem.Enabled = isTDF;

            tdfGridView.Rows.Clear();
            tdfGridView.Columns.Clear();
            ActiveTDF = null;

            if (!(SelectedNode.Tag is ArchiveFile))
            {
                return;
            }

            SelectedFile = SelectedNode.Tag as ArchiveFile;
            ActiveTDF    = isTDF ? TDF.Load((SelectedFile as AGTFile).Decompress(), tdfGridView) : null;
        }
Exemple #6
0
 public void loadGame(int SlotID)
 {
     if (FileBase.FileExist("Data/SaveData/Slot_" + (SlotID + 1) + ".tdf"))
     {
         Slots[SlotID] = TDF.Load("Data/SaveData/Slot_" + (SlotID + 1) + ".tdf");//TDF.LoadGZ
         var playerComp = GetComponent().player.GetComponent <Player>();
         var pos        = TDF.GetValueOfBlock(Slots[SlotID], "Game", "PlayerPos").Split(","[0]);
         var posX       = float.Parse(pos[0]);
         var posY       = float.Parse(pos[1]);
         var posZ       = float.Parse(pos[2]);
         player.position = new Vector3(posX, posY, posZ);
         var rot  = TDF.GetValueOfBlock(Slots[SlotID], "Game", "PlayerRot").Split(","[0]);
         var rotX = float.Parse(rot[0]);
         var rotY = float.Parse(rot[1]);
         var rotZ = float.Parse(rot[2]);
         playerComp.rotation = new Vector3(rotX, rotY, rotZ);
         player.rotation     = Quaternion.Euler(new Vector3(0, rotY, 0));
         Health = int.Parse(TDF.GetValueOfBlock(Slots[SlotID], "Game", "PlayerHealth"));
     }
     player.GetComponent <Player>().Move = true;
     SaveMenu.gameObject.SetActive(false);
     LoadMenu.gameObject.SetActive(false);
 }
Exemple #7
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;
        }