Beispiel #1
0
        private void FindAssemblySFsInRaw(string rawFullPath, List <string> folders, ref List <ScriptFile> files)
        {
            foreach (string curFolder in folders)
            {
                string fullFolderPath = Path.Combine(rawFullPath, curFolder);

                List <string> sfFiles = new List <string>(Directory.GetFiles(fullFolderPath, "*.gsx", SearchOption.TopDirectoryOnly));
                sfFiles.AddRange(Directory.GetFiles(fullFolderPath, "*.gsc", SearchOption.TopDirectoryOnly));
                foreach (string sfFile in sfFiles)
                {
                    string file   = Path.GetFileNameWithoutExtension(sfFile);
                    string sfPath = Path.Combine(curFolder, file);

                    ScriptFile.Extension ext = ScriptFile.Extension.GSX;
                    if (Path.GetExtension(sfFile).ToUpperInvariant() == ".GSC")
                    {
                        ext = ScriptFile.Extension.GSC;
                    }

                    ScriptFile sf = GetSF(sfPath, ext);
                    if (sf != null)
                    {
                        files.Add(sf);
                    }
                }
            }
        }
Beispiel #2
0
        private void ReadExternSFs()
        {
            string path = Path.Combine(_settings.SIsPath, "Extern");

            string[] files = Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories);

            string fileNameWithoutXML;
            string relativePath;
            string extStr;
            string fileName;
            string fullPath;

            foreach (string filePath in files)
            {
                // blabla\Extern\maps\_utility.gsc.xml
                fileNameWithoutXML = Path.GetFileNameWithoutExtension(filePath);
                extStr             = Path.GetExtension(fileNameWithoutXML); // .gsc or .gsx
                if (!String.IsNullOrEmpty(extStr))
                {
                    extStr = extStr.Substring(1).ToUpperInvariant();
                    ScriptFile.Extension ext = (ScriptFile.Extension)Enum.Parse(typeof(ScriptFile.Extension), extStr);

                    fileName     = Path.GetFileNameWithoutExtension(fileNameWithoutXML);
                    fullPath     = Path.Combine(Path.GetDirectoryName(filePath), fileName);
                    relativePath = fullPath.Remove(0, path.Length + 1); // delete path and separator
                    ScriptFile sf = CreateSF(relativePath, ext, true);
                    sf.ReadSI();
                }
            }
        }
Beispiel #3
0
        private ScriptFile CreateSF(string filePath, ScriptFile.Extension ext, bool isExtern)
        {
            ScriptFile script = ScriptFile.Create(this, filePath, ext, isExtern);

            if (script != null)
            {
                _files.Add(script);
            }

            return(script);
        }
Beispiel #4
0
        public ScriptFile GetSF(string filePath, ScriptFile.Extension ext)
        {
            PrintDebug("GetSF(string filePath, ScriptFile.Extension ext)", true);
            lock (lockerSF)
            {
                ScriptFile file = _files.Find(a => a.SFPath.EqualCode(filePath) && a.FileExt == ext);
                if (file == null)
                {
                    file = CreateSF(filePath, ext, false);
                }

                PrintDebug("GetSF(string filePath, ScriptFile.Extension ext)", false);
                return(file);
            }
        }
Beispiel #5
0
        public ScriptFile GetSFFromFullPath(string fullPath)
        {
            RawType rawType = RawType.None;
            string  sfPath  = string.Empty;

            if (String.IsNullOrEmpty(fullPath))
            {
                return(null);
            }

            string ext = Path.GetExtension(fullPath);

            if (String.IsNullOrEmpty(ext))
            {
                return(null);
            }

            ext = ext.Substring(1).ToUpperInvariant(); // '.gsc' to 'GSC'

            string[] extensions = Enum.GetNames(typeof(ScriptFile.Extension));
            if (!extensions.Contains(ext))
            {
                return(null);
            }

            string dir      = Path.GetDirectoryName(fullPath);
            string fileName = Path.GetFileNameWithoutExtension(fullPath);

            if (_settings.SourceFSGame != null &&
                fullPath.Length > _settings.SourceFSGame.Length &&
                fullPath.Substring(0, _settings.SourceFSGame.Length).ToUpperInvariant() == _settings.SourceFSGame.ToUpperInvariant())
            {
                string relativeDir = dir.Substring(_settings.SourceFSGame.Length + 1);
                if (_settings.SourceFSGameFolders.Contains(relativeDir))
                {
                    rawType = RawType.FSGame;
                    sfPath  = Path.Combine(relativeDir, fileName);
                }
            }
            else if (_settings.SourceRaw != null &&
                     fullPath.Length > _settings.SourceRaw.Length &&
                     fullPath.Substring(0, _settings.SourceRaw.Length).ToUpperInvariant() == _settings.SourceRaw.ToUpperInvariant())
            {
                string relativeDir = dir.Substring(_settings.SourceRaw.Length + 1);
                if (_settings.SourceRawFolders.Contains(relativeDir))
                {
                    rawType = RawType.Raw;
                    sfPath  = Path.Combine(relativeDir, fileName);
                }
            }

            if (!String.IsNullOrEmpty(sfPath))
            {
                ScriptFile.Extension extension = (ScriptFile.Extension)Enum.Parse(typeof(ScriptFile.Extension), ext);
                ScriptFile           sf        = GetSF(sfPath, extension);
                if (sf.RawType == rawType)
                {
                    return(sf);
                }
            }

            return(null);
        }