Example #1
0
        private void SetupFileSystem()
        {
            //Note: the engine has no-Steam directory paths used for testing, but since this is Steam-only, we won't add those
            FileSystem.RemoveAllSearchPaths();

            var cmdLineArgs = Environment.GetCommandLineArgs();

            //Strip off the exe name
            var baseDir = Path.GetDirectoryName(cmdLineArgs[0]);

            const string defaultGame = Framework.DefaultGame;

            var gameDir = EngineShared.GameDirectory;

            //TODO: get language from SteamWorks
            var language = Framework.DefaultLanguage;

            var addLanguage = language != Framework.DefaultLanguage;

            //TODO: get from SteamWorks
            const bool lowViolence = false;

            var hdModels = !cmdLineArgs.Any(s => s == "-nohdmodels") && Registry.ReadInt("hdmodels", 1) > 0;

            var addons = cmdLineArgs.Any(s => s == "-addons") || Registry.ReadInt("addons_folder", 0) > 0;

            if (lowViolence)
            {
                FileSystem.AddSearchPath($"{baseDir}/{gameDir}{FileSystemConstants.Suffixes.LowViolence}", FileSystemConstants.PathID.Game, false);
            }

            if (addons)
            {
                FileSystem.AddSearchPath($"{baseDir}/{gameDir}{FileSystemConstants.Suffixes.Addon}", FileSystemConstants.PathID.Game, false);
            }

            if (addLanguage)
            {
                FileSystem.AddSearchPath($"{baseDir}/{gameDir}_{language}", FileSystemConstants.PathID.Game, false);
            }

            if (hdModels)
            {
                FileSystem.AddSearchPath($"{baseDir}/{gameDir}{FileSystemConstants.Suffixes.HD}", FileSystemConstants.PathID.Game, false);
            }

            FileSystem.AddSearchPath($"{baseDir}/{gameDir}", FileSystemConstants.PathID.Game);
            FileSystem.AddSearchPath($"{baseDir}/{gameDir}", FileSystemConstants.PathID.GameConfig);

            FileSystem.AddSearchPath($"{baseDir}/{gameDir}{FileSystemConstants.Suffixes.Downloads}", FileSystemConstants.PathID.GameDownload);

            if (lowViolence)
            {
                FileSystem.AddSearchPath($"{baseDir}/{defaultGame}{FileSystemConstants.Suffixes.LowViolence}", FileSystemConstants.PathID.DefaultGame, false);
            }

            if (addons)
            {
                FileSystem.AddSearchPath($"{baseDir}/{defaultGame}{FileSystemConstants.Suffixes.Addon}", FileSystemConstants.PathID.DefaultGame, false);
            }

            if (addLanguage)
            {
                FileSystem.AddSearchPath($"{baseDir}/{defaultGame}_{language}", FileSystemConstants.PathID.DefaultGame, false);
            }

            if (hdModels)
            {
                FileSystem.AddSearchPath($"{baseDir}/{defaultGame}{FileSystemConstants.Suffixes.HD}", FileSystemConstants.PathID.DefaultGame, false);
            }

            FileSystem.AddSearchPath(baseDir, FileSystemConstants.PathID.Base);

            FileSystem.AddSearchPath($"{baseDir}/{defaultGame}", FileSystemConstants.PathID.Game, false);

            FileSystem.AddSearchPath($"{baseDir}/{FileSystemConstants.PlatformDirectory}", FileSystemConstants.PathID.Platform);
        }