예제 #1
0
        private void DiscoverModLevelObjects(string modName, string modPath)
        {
            var levelsPath = modPath + @"\Levels";

            if (!Directory.Exists(levelsPath))
            {
                return;
            }

            List <string> levelFiles = new List <string>();

            EnumerateFiles(levelFiles, levelsPath, levelsPath, "*.lsf");

            var levelObjectsRe = new Regex("^(Characters|Items|Triggers)/.*\\.lsf$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

            foreach (var levelFile in levelFiles)
            {
                var fileInfo = new FilesystemFileInfo
                {
                    FilesystemPath = levelsPath + "\\" + levelFile,
                    Name           = levelFile
                };
                AddLevelObjectsToMod(modName, levelFile, fileInfo);
            }
        }
예제 #2
0
        public void DiscoverModDirectory(string modName, string modPath, string publicPath)
        {
            // Trigger mod entry creation even if there are no resources
            GetMod(modName);

            if (CollectStoryGoals)
            {
                DiscoverModGoals(modName, modPath);

                var headerPath = modPath + @"\Story\RawFiles\story_header.div";
                if (File.Exists(headerPath))
                {
                    var fileInfo = new FilesystemFileInfo
                    {
                        FilesystemPath = headerPath,
                        Name           = headerPath
                    };
                    GetMod(modName).StoryHeaderFile = fileInfo;
                }

                var orphanQueryIgnoresPath = modPath + @"\Story\story_orphanqueries_ignore_local.txt";
                if (File.Exists(orphanQueryIgnoresPath))
                {
                    var fileInfo = new FilesystemFileInfo
                    {
                        FilesystemPath = orphanQueryIgnoresPath,
                        Name           = orphanQueryIgnoresPath
                    };
                    GetMod(modName).OrphanQueryIgnoreList = fileInfo;
                }

                var typeCoercionWhitelistPath = modPath + @"\Story\RawFiles\TypeCoercionWhitelist.txt";
                if (File.Exists(typeCoercionWhitelistPath))
                {
                    var fileInfo = new FilesystemFileInfo
                    {
                        FilesystemPath = typeCoercionWhitelistPath,
                        Name           = typeCoercionWhitelistPath
                    };
                    GetMod(modName).TypeCoercionWhitelistFile = fileInfo;
                }
            }

            if (CollectStats)
            {
                DiscoverModStats(modName, publicPath);
            }

            if (CollectGlobals)
            {
                DiscoverModGlobals(modName, modPath);
            }

            if (CollectLevels)
            {
                DiscoverModLevelObjects(modName, modPath);
            }
        }
예제 #3
0
        public static FilesystemFileInfo CreateFromEntry(string filesystemPath, string name)
        {
            var info = new FilesystemFileInfo();

            info.Name           = name;
            info.FilesystemPath = filesystemPath;

            var fsInfo = new System.IO.FileInfo(filesystemPath);

            info.CachedSize = fsInfo.Length;
            return(info);
        }
예제 #4
0
        public void EnumerateFiles(Package package, string rootPath, string currentPath)
        {
            foreach (string filePath in Directory.GetFiles(currentPath))
            {
                var relativePath = filePath.Substring(rootPath.Length);
                if (relativePath[0] == '/' || relativePath[0] == '\\')
                {
                    relativePath = relativePath.Substring(1);
                }

                var fileInfo = FilesystemFileInfo.CreateFromEntry(filePath, relativePath);
                package.Files.Add(fileInfo);
            }

            foreach (string directoryPath in Directory.GetDirectories(currentPath))
            {
                EnumerateFiles(package, rootPath, directoryPath);
            }
        }
예제 #5
0
        private static Package CreatePackageFromPath(string path)
        {
            var package = new Package();

            if (!path.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                path += Path.DirectorySeparatorChar;
            }

            Dictionary <string, string> files = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories)
                                                .ToDictionary(k => k.Replace(path, String.Empty), v => v);

            foreach (KeyValuePair <string, string> file in files)
            {
                FilesystemFileInfo fileInfo = FilesystemFileInfo.CreateFromEntry(file.Value, file.Key);
                package.Files.Add(fileInfo);
            }

            return(package);
        }
예제 #6
0
        private void DiscoverModGlobals(string modName, string modPath)
        {
            var globalsPath = modPath + @"\Globals";

            if (!Directory.Exists(globalsPath))
            {
                return;
            }

            List <string> globalFiles = new List <string>();

            EnumerateFiles(globalFiles, globalsPath, globalsPath, "*.lsf");

            foreach (var globalFile in globalFiles)
            {
                var fileInfo = new FilesystemFileInfo
                {
                    FilesystemPath = globalsPath + "\\" + globalFile,
                    Name           = globalFile
                };
                AddGlobalsToMod(modName, globalFile, fileInfo);
            }
        }
예제 #7
0
        private void DiscoverModStats(string modName, string modPublicPath)
        {
            var statsPath = modPublicPath + @"\Stats\Generated\Data";

            if (!Directory.Exists(statsPath))
            {
                return;
            }

            List <string> statFiles = new List <string>();

            EnumerateFiles(statFiles, statsPath, statsPath, "*.txt");

            foreach (var statFile in statFiles)
            {
                var fileInfo = new FilesystemFileInfo
                {
                    FilesystemPath = statsPath + "\\" + statFile,
                    Name           = statFile
                };
                AddStatToMod(modName, statFile, fileInfo);
            }
        }
예제 #8
0
        private void DiscoverModGoals(string modName, string modPath)
        {
            var goalPath = modPath + @"\Story\RawFiles\Goals";

            if (!Directory.Exists(goalPath))
            {
                return;
            }

            List <string> goalFiles = new List <string>();

            EnumerateFiles(goalFiles, goalPath, goalPath, "*.txt");

            foreach (var goalFile in goalFiles)
            {
                var fileInfo = new FilesystemFileInfo
                {
                    FilesystemPath = goalPath + "\\" + goalFile,
                    Name           = goalFile
                };
                AddScriptToMod(modName, goalFile, fileInfo);
            }
        }
예제 #9
0
        public static FilesystemFileInfo CreateFromEntry(string filesystemPath, string name)
        {
            var info = new FilesystemFileInfo();
            info.Name = name;
            info.FilesystemPath = filesystemPath;

            var fsInfo = new System.IO.FileInfo(filesystemPath);
            info.CachedSize = fsInfo.Length;
            return info;
        }