Esempio n. 1
0
        private void RefreshTreeview()
        {
            treeView1.Nodes.Clear();
            if (_scmFile == null)
            {
                return;
            }

            TreeNode parentTreeNode = treeView1.Nodes.Add(Path.GetFileName(_scmFile.FileName));

            string[] allFiles = _scmFile.GetAllFiles();

            foreach (string f in allFiles)
            {
                TreeNode treeNode = parentTreeNode.Nodes.Add(f);
                if (!SCMFile.IsSupportedFile(f))
                {
                    treeNode.ForeColor = Color.LightGray;
                }
            }

            treeView1.ExpandAll();
            if (parentTreeNode.Nodes.Count > 0)
            {
                treeView1.SelectedNode = parentTreeNode.Nodes[0];
            }
            else
            {
                CloseAll();
            }
        }
Esempio n. 2
0
 private void CloseAll()
 {
     if (_scmFile != null)
     {
         _scmFile.Close();
         _scmFile = null;
     }
     _currentFilename = "";
     statusLabel.Text = "";
 }
Esempio n. 3
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if ((treeView1.Nodes.Count <= 0) || (e.Node == treeView1.Nodes[0]))
            {
                return;
            }

            _currentFilename = e.Node.Text;

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                // Reorder current map file if its loaded
                if (_mapFile != null)
                {
                    ucSingleEdit1.SaveState();
                }

                ucSingleEdit1.Clear();

                _mapFile   = null;
                _otherFile = null;

                if (SCMFile.IsSupportedFile(_currentFilename))
                {
                    if (SCMFile.IsChannelMapFile(_currentFilename))
                    {
                        WriteStatus("Reading channels...");
                        if (OpenMapFile(_currentFilename))
                        {
                            WriteChanels();
                        }
                    }
                    else
                    {
                        WriteStatus("Reading file...");
                        if (OpenOtherFile(_currentFilename))
                        {
                            WriteOtherFile();
                        }
                    }
                }
                else
                {
                    WriteStatus("File not supported.");
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new ScriptMachine instance.
        /// TODO: Pass a GameState instance to this constructor.
        /// </summary>
        /// <param name="File">The SCMFile to interpret.</param>
        /// <param name="Module">A ScriptModule instance.</param>
        public ScriptMachine(SCMFile File, ScriptModule Module)
        {
            file      = File;
            module    = Module;
            debugFlag = false;

            uint Size = file.GlobalsSize;

            globalData = new List <char>((int)Size);
            uint Offset = file.GlobalSection;

            var GlobalDataCopy = globalData.ToArray();

            Array.Copy(file.Data.ToArray(), (int)file.GlobalSection, GlobalDataCopy, 0, (int)file.GlobalsSize);
            globalData = new List <char>(GlobalDataCopy);
        }
Esempio n. 5
0
        private void mnLoad_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog
            {
                Filter      = SCM_FILTER + "|" + ALL_FILTER,
                FilterIndex = 0,
                Multiselect = false
            };

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            CloseAll();

            _currentFilename = ofd.FileName;
            ucSingleEdit1.Clear();

            WriteStatus("Loading file...");

            if (SCMFile.IsSCMFile(ofd.FileName))
            {
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    _scmFile       = new SCMFile(ofd.FileName);
                    RefreshTreeview();
                    WriteStatus(ofd.FileName);
                }
                catch (Exception ex)
                {
                    Cursor.Current = Cursors.Default;
                    ShowError(ex, "Open file");
                    CloseAll();
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
            else
            {
                ShowInfo("Incorrect File extension : " + _currentFilename, "Open file");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Open GTA_VC.dat and default.dat<para/>
        /// Чтение GTA_VC.dat и default.dat
        /// </summary>
        static void ReadDataFiles()
        {
            List <string> ide = new List <string>(), ipl = new List <string>(), col = new List <string>(), tex = new List <string>(), mod = new List <string>(), img = new List <string>();

            MainScript = new SCMFile(PathManager.GetAbsolute("data/main.scm"));

            TextFile d;

            for (int i = 0; i < 2; i++)
            {
                // First gta_vc, then default
                // Сначала gta_vc, потом default
                if (i == 0)
                {
                    d = new TextFile(PathManager.GetAbsolute("data/gta_vc.dat"), false, false);
                }
                else
                {
                    d = new TextFile(PathManager.GetAbsolute("data/default.dat"), false, false);
                }

                // Parsing directives
                // Обработка директив
                foreach (TextFile.Line l in d.Lines)
                {
                    switch (l.Text[0].ToLower())
                    {
                    // Item Definition
                    // Файл IDE
                    case "ide":
                        ide.Add(l.Text[1]);
                        col.Add(System.IO.Path.ChangeExtension(l.Text[1], ".col"));
                        break;

                    // Item placement
                    // Файл IPL
                    case "ipl":
                        ipl.Add(l.Text[1]);
                        break;

                    // Collision files
                    // Файлы коллизий
                    case "colfile":
                        col.Add(l.Text[2]);
                        break;

                    // Texture dictionary
                    // Тектстурный архив
                    case "texdiction":
                        tex.Add(l.Text[1]);
                        break;

                    // Generic DFF file
                    // DFF файл
                    case "modelfile":
                        mod.Add(l.Text[1]);
                        break;

                    // Additive IMG archive
                    // Дополнительный IMG-архив
                    case "cdimage":
                        img.Add(l.Text[1]);
                        break;

                    // Splash image (skip)
                    // Сплэш (пропускаем)
                    case "splash":
                        break;

                    default:
                        throw new Exception("[FileManager] Unknown directive in data file: " + l.Text[0]);
                    }
                }
            }

            // Saving data
            // Сохранение данных
            DefinitionFiles = ide.ToArray();
            PlacementFiles  = ipl.ToArray();
            CollisionFiles  = col.ToArray();
            ModelFiles      = mod.ToArray();
            TextureFiles    = tex.ToArray();
            ArchiveFiles    = img.ToArray();
        }
Esempio n. 7
0
 public ScriptMachine(SCMFile File, ScriptModule Module)
 {
 }