Ejemplo n.º 1
0
        static void SetBaseOptions(BaseOptions args)
        {
            BaseOptions = args;

            var vpkNames = args.Packages.Split(new [] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
                           .Select(x => Path.IsPathRooted(x) ? x.Trim() : Path.Combine(args.GameDir, x.Trim()))
                           .ToArray();

            if (vpkNames.Length == 1)
            {
                Resources = new ValvePackage(vpkNames[0]);
            }
            else
            {
                var loader = new ResourceLoader();

                foreach (var path in vpkNames)
                {
                    loader.AddResourceProvider(new ValvePackage(path));
                }

                Resources = loader;
            }

            if (string.IsNullOrEmpty(args.ResourcesDir))
            {
                args.ResourcesDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..", "..", "Resources");
            }

            if (!Directory.Exists(args.ResourcesDir))
            {
                args.ResourcesDir = null;
            }

            if (string.IsNullOrEmpty(args.MapsDir))
            {
                args.MapsDir = "maps";
            }

            if (!Path.IsPathRooted(args.MapsDir))
            {
                args.MapsDir = Path.Combine(args.GameDir, args.MapsDir);
            }

            ValveBspFile.PakFileLump.DebugContents = args.DebugPakFile;
        }
Ejemplo n.º 2
0
        static void SetBaseOptions(BaseOptions args)
        {
            BaseOptions = args;

            var vpkNames = args.Packages.Split(new [] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
                           .Select(x => Path.IsPathRooted(x) ? x.Trim() : Path.Combine(args.GameDir, x.Trim()))
                           .ToArray();

            var loader = new ResourceLoader();

            if (!string.IsNullOrEmpty(args.LooseDir))
            {
                loader.AddResourceProvider(new FSLoader(args.LooseDir));
            }

            foreach (var path in vpkNames)
            {
                if (path.Contains("*"))
                {
                    var wildcardPath = path.Replace('/', '\\');
                    var parts        = wildcardPath.Split('\\');

                    var file   = parts.Last();
                    var folder = @"";
                    for (int i = 0; i < parts.Length - 1; i++)
                    {
                        folder += parts[i] + "\\";
                    }

                    var paths = Directory.GetFiles(folder, file);
                    foreach (var p in paths)
                    {
                        loader.AddResourceProvider(new ValvePackage(p));
                    }

                    continue;
                }
                loader.AddResourceProvider(new ValvePackage(path));
            }

            Resources = loader;

            if (string.IsNullOrEmpty(args.ResourcesDir))
            {
                args.ResourcesDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..", "..", "Resources");
            }

            if (!Directory.Exists(args.ResourcesDir))
            {
                args.ResourcesDir = null;
            }

            if (string.IsNullOrEmpty(args.MapsDir))
            {
                args.MapsDir = "maps";
            }

            if (!Path.IsPathRooted(args.MapsDir))
            {
                args.MapsDir = Path.Combine(args.GameDir, args.MapsDir);
            }

            ValveBspFile.PakFileLump.DebugContents = args.DebugPakFile;
        }