/// <summary> /// Loads a texture file. /// </summary> /// <param name="filePath">Absolute path to TEXTURE.* file</param> /// <param name="usage">Specify if file will be accessed from disk, or loaded into RAM.</param> /// <param name="readOnly">File will be read-only if true, read-write if false.</param> /// <returns>True if successful, otherwise false.</returns> public override bool Load(string filePath, FileUsage usage, bool readOnly) { // Exit if this file already loaded if (managedFile.FilePath == filePath) return true; // Validate filename filePath = filePath.ToUpper(); string fn = Path.GetFileName(filePath); if (!fn.StartsWith("TEXTURE.")) return false; // Handle unsupported files if (!IsFilenameSupported(fn)) { Console.WriteLine(string.Format("{0} is unsupported.", fn)); return false; } // Handle solid types if (fn == "TEXTURE.000") solidType = SolidTypes.SolidColoursA; else if (fn == "TEXTURE.001") solidType = SolidTypes.SolidColoursB; else solidType = SolidTypes.None; // Handle spectral types if (fn == "TEXTURE.273" || fn == "TEXTURE.278") spectralType = SpectralTypes.Spectral; else spectralType = SpectralTypes.None; // Load file if (!managedFile.Load(filePath, usage, readOnly)) return false; // Attempt to load palette file from same path string arena2Path = Path.GetDirectoryName(filePath); LoadPalette(Path.Combine(arena2Path, PaletteName)); // Read file if (!Read()) return false; return true; }
/// <summary> /// Loads a texture file. /// </summary> /// <param name="filePath">Absolute path to TEXTURE.* file</param> /// <param name="usage">Specify if file will be accessed from disk, or loaded into RAM.</param> /// <param name="readOnly">File will be read-only if true, read-write if false.</param> /// <returns>True if successful, otherwise false.</returns> public override bool Load(string filePath, FileUsage usage, bool readOnly) { // Exit if this file already loaded if (managedFile.FilePath == filePath) { return(true); } // Validate filename filePath = filePath.ToUpper(); string fn = Path.GetFileName(filePath); if (!fn.StartsWith("TEXTURE.")) { return(false); } // Handle unsupported files if (!IsFilenameSupported(fn)) { Console.WriteLine(string.Format("{0} is unsupported.", fn)); return(false); } // Handle solid types if (fn == "TEXTURE.000") { solidType = SolidTypes.SolidColoursA; } else if (fn == "TEXTURE.001") { solidType = SolidTypes.SolidColoursB; } else { solidType = SolidTypes.None; } // Handle spectral types if (fn == "TEXTURE.273" || fn == "TEXTURE.278") { spectralType = SpectralTypes.Spectral; } else { spectralType = SpectralTypes.None; } // Load file if (!managedFile.Load(filePath, usage, readOnly)) { return(false); } // Read file if (!Read()) { return(false); } return(true); }
/// <summary> /// Loads a texture file. /// </summary> /// <param name="filePath">Absolute path to TEXTURE.* file</param> /// <param name="usage">Specify if file will be accessed from disk, or loaded into RAM.</param> /// <param name="readOnly">File will be read-only if true, read-write if false.</param> /// <returns>True if successful, otherwise false.</returns> public override bool Load(string filePath, FileUsage usage, bool readOnly) { // Exit if this file already loaded if (managedFile.FilePath == filePath) { return(true); } // Validate filename string fn = Path.GetFileName(filePath); if (!fn.StartsWith("TEXTURE.", StringComparison.InvariantCultureIgnoreCase)) { return(false); } // Handle unsupported files if (!IsFilenameSupported(fn)) { Console.WriteLine(string.Format("{0} is unsupported.", fn)); return(false); } // Handle solid types if (fn == "TEXTURE.000") { solidType = SolidTypes.SolidColoursA; } else if (fn == "TEXTURE.001") { solidType = SolidTypes.SolidColoursB; } else { solidType = SolidTypes.None; } // Handle spectral types if (fn == "TEXTURE.273" || fn == "TEXTURE.278") { spectralType = SpectralTypes.Spectral; } else { spectralType = SpectralTypes.None; } // Load file if (!managedFile.Load(filePath, usage, readOnly)) { return(false); } // Attempt to load palette file from same path string arena2Path = Path.GetDirectoryName(filePath); LoadPalette(Path.Combine(arena2Path, PaletteName)); // Read file if (!Read()) { return(false); } return(true); }