예제 #1
0
 static CarTexture LoadFromGameFile(string filename)
 {
     using (var file = new FileStream(filename, FileMode.Open, FileAccess.Read))
     {
         var texture = new CarTexture();
         texture.LoadFromGameFile(file, Path.GetExtension(filename) == ".tex" ? (GameFileLayout) new TEXFileLayout() : new CDPFileLayout());
         return(texture);
     }
 }
예제 #2
0
파일: Program.cs 프로젝트: pez2k/gt2tools
        static void WriteToDumpedFiles(string filename, CarTexture texture)
        {
            bool   isNight    = Path.GetExtension(filename) == ".cnp";
            string outputName = Path.GetFileNameWithoutExtension(filename);
            string outputPath = Path.Combine(Path.GetDirectoryName(filename), outputName + (isNight ? "_night" : "") + "_dumped");

            Directory.CreateDirectory(outputPath);
            texture.WriteToDumpedFiles(outputPath);
        }
예제 #3
0
        static void WriteToGameFile(string directory, CarTexture texture, OutputType outputType)
        {
            GameFileLayout layout = outputType == OutputType.GT2 ? (GameFileLayout) new CDPFileLayout() : new TEXFileLayout();

            using (var file = new FileStream(CreateFilename(Path.GetFileNameWithoutExtension(directory), outputType), FileMode.Create, FileAccess.Write))
            {
                file.Write(layout.HeaderData);
                texture.WriteToGameFile(file, layout);
            }
        }
예제 #4
0
        static CarTexture LoadFromEditableFiles(string directory)
        {
            string carName         = Path.GetFileName(directory);
            string carNameNoSuffix = carName.Replace("_night", "");
            var    texture         = new CarTexture();

            using (var bitmap = new FileStream(Path.Combine(carName, $"{carNameNoSuffix}.bmp"), FileMode.Open, FileAccess.Read))
            {
                texture.LoadFromEditableFiles(directory, bitmap);
            }
            return(texture);
        }
예제 #5
0
        static void WriteToEditableFiles(string filename, CarTexture texture)
        {
            bool   isNight    = Path.GetExtension(filename) == ".cnp";
            string outputName = Path.GetFileNameWithoutExtension(filename);
            string outputPath = Path.Combine(Path.GetDirectoryName(filename), outputName + (isNight ? "_night" : ""));

            Directory.CreateDirectory(outputPath);
            using (var bitmap = new FileStream(Path.Combine(outputPath, $"{outputName}.bmp"), FileMode.Create, FileAccess.Write))
            {
                texture.WriteToEditableFiles(outputPath, bitmap);
            }
        }
예제 #6
0
파일: Program.cs 프로젝트: pez2k/gt2tools
        static void Main(string[] args)
        {
            if (args.Length < 1 || args.Length > 2)
            {
                return;
            }

            string     path        = args.Last();
            bool       isDirectory = File.GetAttributes(path).HasFlag(FileAttributes.Directory);
            OutputType outputType  = isDirectory ? OutputType.GT2 : OutputType.EditableFiles;

            if (args.Length == 2)
            {
                switch (args[0])
                {
                case "-o1":
                    outputType = OutputType.GT1;
                    break;

                case "-o2":
                    outputType = OutputType.GT2;
                    break;

                case "-oe":
                    outputType = OutputType.EditableFiles;
                    break;

                case "-od":
                    outputType = OutputType.DumpedFiles;
                    break;

                default:
                    return;
                }
            }

            CarTexture texture = isDirectory ? LoadFromEditableFiles(path) : LoadFromGameFile(path);

            switch (outputType)
            {
            case OutputType.EditableFiles:
                WriteToEditableFiles(path, texture);
                break;

            case OutputType.DumpedFiles:
                WriteToDumpedFiles(path, texture);
                break;

            default:
                WriteToGameFile(path, texture, outputType);
                break;
            }
        }