Class GameFileLoader
- Namespace
- ValveResourceFormat.IO
- Assembly
- ValveResourceFormat.dll
Loads game files from VPK packages and disk with automatic path resolution.
public class GameFileLoader : IFileLoader, IDisposableInheritance
Implements
Inherited Members
Constructors
GameFileLoader(Package?, string?)
Initializes a new instance of the ValveResourceFormat.IO.GameFileLoader class.
public GameFileLoader(Package? currentPackage, string? currentFileName)Parameters
currentPackagePackage?-
The current package to search for files in.
currentFileNamestring?-
The path on disk to the current file that is being opened.
Remarks
fileName is needed when used by GUI when package has not yet been resolved.
Fields
CompiledFileSuffix
The suffix added to compiled file names.
public const string CompiledFileSuffix = "_c"Field Value
Properties
CurrentPackage
Gets or sets the current package being processed.
public Package? CurrentPackage { get; set; }Property Value
- Package?
Methods
AddDiskPathToSearch(string)
Adds a disk path to the search paths.
public bool AddDiskPathToSearch(string searchPath)Parameters
searchPathstring
Returns
AddPackageToSearch(string)
Loads and adds a VPK package to the search paths.
public Package AddPackageToSearch(string searchPath)Parameters
searchPathstring
Returns
- Package
AddPackageToSearch(Package)
Adds an already loaded package to the search paths.
public void AddPackageToSearch(Package package)Parameters
packagePackage
Dispose(bool)
Releases resources used by this instance.
protected virtual void Dispose(bool disposing)Parameters
disposingbool
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()EnsureStringTokenGameKeys()
Ensures surface property string tokens are loaded and stored.
public void EnsureStringTokenGameKeys()FindAndLoadSearchPaths(string?)
Finds and loads search paths from gameinfo.gi files.
protected void FindAndLoadSearchPaths(string? modIdentifierPath = null)Parameters
modIdentifierPathstring?
FindFile(string, bool)
Finds a file in packages or on disk.
public virtual (string? PathOnDisk, Package? Package, PackageEntry? PackageEntry) FindFile(string file, bool logNotFound = true)Parameters
Returns
- (string? PathOnDisk, Package? Package, PackageEntry? PackageEntry)
-
A tuple containing the path on disk, package, and package entry if found.
GetFileStream(string)
Gets a stream for reading a file.
public Stream? GetFileStream(string file)Parameters
filestring
Returns
GetPackageEntryStream(Package, PackageEntry)
Gets a stream for reading a package entry.
public static Stream GetPackageEntryStream(Package package, PackageEntry entry)Parameters
packagePackageentryPackageEntry
Returns
Remarks
Do not use this method, it will be removed in the future in favor of a method in the ValvePak library.
LoadFile(string)
Loads a resource file.
public virtual Resource? LoadFile(string file)Parameters
filestring-
Path to the file to load.
Returns
- Resource?
-
Loaded resource, or null if not found.
LoadFileCompiled(string)
Same as ValveResourceFormat.IO.IFileLoader.LoadFile(System.String) but appends "_c" to the end of the string.
public virtual Resource? LoadFileCompiled(string file)Parameters
filestring-
Path to the file to load (without _c suffix).
Returns
- Resource?
-
Loaded compiled resource, or null if not found.
LoadShader(string)
Loads a shader collection by name.
public ShaderCollection LoadShader(string shaderName)Parameters
shaderNamestring-
Name of the shader to load.
Returns
- ShaderCollection
-
Loaded shader collection, or null if not found.
LoadShaderFromDisk(string)
Loads a shader from disk by finding all its program files.
protected virtual ShaderCollection LoadShaderFromDisk(string shaderName)Parameters
shaderNamestring
Returns
RemoveDiskPathFromSearch(string)
Removes a disk path from the search paths.
public bool RemoveDiskPathFromSearch(string searchPath)Parameters
searchPathstring
Returns
RemovePackageFromSearch(Package)
Removes a package from the search paths.
public bool RemovePackageFromSearch(Package package)Parameters
packagePackage