Static class to manage resources.
More...
|
static Font | LoadFont (string name, string file, int size, bool dropShadow=false, FontType type=FontType.TTF) |
| Loads a font file from the default resources path into the resources. More...
|
|
static Font | LoadFont (string name, string file, int size, FontType type, FontConstructionConfig config) |
| Loads a font file from the default resources path into the resources. More...
|
|
static Shader | LoadShader (string name, string file, ShaderType type) |
| Loads a shader file from the default resources path into the resources. More...
|
|
static ISound | LoadSound (string name, string file, AudioFormat format=AudioFormat.Wav) |
| Loads a sound file from the default resources path into the resources. More...
|
|
static ISong | LoadSong (string name, string file, AudioFormat format=AudioFormat.Ogg) |
| Loads a song file from the default resources path into the resources. More...
|
|
static bool | Has (string name) |
| Checks if the resource with the specified name has been added to the resource collection. More...
|
|
static bool | Has< T > (string name) |
| Checks if the resource with the specified name and type has been added to the resource collection. More...
|
|
static IResource | Get (string name) |
| Gets the resource with the specified name. More...
|
|
static T | Get< T > (string name) |
| Gets the resource with the specified name and casts it to the specified type. More...
|
|
static IEnumerable< T > | GetAll< T > () |
| Gets all resources of the specified type. More...
|
|
static void | Add (IResource resource) |
| Adds a resource to the resource collection. More...
|
|
Static class to manage resources.
static void TriDevs.TriEngine.Resources.ResourceManager.Add |
( |
IResource |
resource | ) |
|
|
static |
Adds a resource to the resource collection.
- Parameters
-
- Exceptions
-
ResourceException | Thrown if the collection already contains a resource with the same name. |
260 if (
Has(resource.Name))
261 throw new ResourceException(
"Attempted to add resource that already exists: " + resource.Name);
263 Resources.Add(resource.Name, resource);
static IResource TriDevs.TriEngine.Resources.ResourceManager.Get |
( |
string |
name | ) |
|
|
static |
Gets the resource with the specified name.
- Parameters
-
name | Name of resource to get. |
- Exceptions
-
- Returns
- The IResource object with the specified name.
214 throw new ResourceException(
"Attempted to get non-existing resource \"" + name +
"\"!");
216 return Resources[name];
Gets the resource with the specified name and casts it to the specified type.
- Template Parameters
-
- Parameters
-
name | Name of resource to get. |
- Exceptions
-
- Returns
- The resource object of type T with the specified name.
230 throw new ResourceException(
"Attempted to get non-existing resource \"" + name +
"\"!");
232 T resource =
Get(name) as T;
234 if (resource == null)
235 throw new ResourceException("Resource with name \"" + name +
236 "\" is not of the requested type: " + typeof (T));
static IEnumerable<T> TriDevs.TriEngine.Resources.ResourceManager.GetAll< T > |
( |
| ) |
|
|
static |
Gets all resources of the specified type.
- Template Parameters
-
T | Type of resource to get. |
- Returns
- An IEnumerable containing the relevant resources.
Returned collection will be empty if no matching resources were found.
249 return Resources.Values.Where(r => r is T).Cast<T>();
static bool TriDevs.TriEngine.Resources.ResourceManager.Has |
( |
string |
name | ) |
|
|
static |
Checks if the resource with the specified name has been added to the resource collection.
- Parameters
-
- Returns
- True if the resource has been added, false otherwise.
191 return Resources.ContainsKey(name);
Checks if the resource with the specified name and type has been added to the resource collection.
- Template Parameters
-
T | Type of resource to search for. |
- Parameters
-
- Returns
- True if the resource has been added, false otherwise.
202 return Has(name) && Resources[name].GetType() == typeof (T);
static Font TriDevs.TriEngine.Resources.ResourceManager.LoadFont |
( |
string |
name, |
|
|
string |
file, |
|
|
int |
size, |
|
|
bool |
dropShadow = false , |
|
|
FontType |
type = FontType.TTF |
|
) |
| |
|
static |
Loads a font file from the default resources path into the resources.
- Parameters
-
name | Name to assign the font, or null to auto-generate one. |
file | Font file to load. |
size | Size (in points) to use for the font. |
dropShadow | Whether or not the font should have shadows. |
type | The font filetype. |
- Returns
- The newly loaded font object, or existing font object if one with matching name was found.
85 return LoadFont(name, file, size, type,
87 new QFontLoaderConfiguration(dropShadow)));
Loads a font file from the default resources path into the resources.
- Parameters
-
name | Name to assign the font, or null to auto-generate one. |
file | Font file to load. |
size | Size (in points) to use for the font. |
type | The font filetype. |
config | The relevant font construction configs. |
- Returns
- The newly loaded font object, or existing font object if one with matching name was found.
102 return Get<Font>(name);
106 var font =
new Font(name, file, size, type, config);
static Shader TriDevs.TriEngine.Resources.ResourceManager.LoadShader |
( |
string |
name, |
|
|
string |
file, |
|
|
ShaderType |
type |
|
) |
| |
|
static |
Loads a shader file from the default resources path into the resources.
- Parameters
-
name | Name to assign the shader, or null to auto-generate one. |
file | File to load shader code from. |
type | The type of shader. |
- Returns
- The newly loaded shader object, or existing shader object if one with matching name was found.
124 if (Has<Shader>(name))
125 return Get<Shader>(name);
129 var shader =
new Shader(name, file, type);
static ISong TriDevs.TriEngine.Resources.ResourceManager.LoadSong |
( |
string |
name, |
|
|
string |
file, |
|
|
AudioFormat |
format = AudioFormat.Ogg |
|
) |
| |
|
static |
Loads a song file from the default resources path into the resources.
- Parameters
-
name | Name to assign the song. |
file | File to load song from. |
format | The audio format of the song. |
- Returns
- The newly loaded song object, or existing song object if one with matching name was found.
170 if (Has<ISong>(name))
171 return Get<ISong>(name);
175 var song =
new Song(name, file, format);
static ISound TriDevs.TriEngine.Resources.ResourceManager.LoadSound |
( |
string |
name, |
|
|
string |
file, |
|
|
AudioFormat |
format = AudioFormat.Wav |
|
) |
| |
|
static |
Loads a sound file from the default resources path into the resources.
- Parameters
-
name | Name to assign the sound. |
file | File to load sound from. |
format | The audio format of the sound. |
- Returns
- The newly loaded sound object, or existing sound object if one with matching name was found.
147 if (Has<ISound>(name))
148 return Get<ISound>(name);
152 var sound =
new Sound(name, file, format);
string TriDevs.TriEngine.Resources.ResourceManager.BasePath = "Resources" |
|
static |
Base path to the resources directory, relative to the current working directory.
string TriDevs.TriEngine.Resources.ResourceManager.FontPath = "Fonts" |
|
static |
Path to the fonts directory, relative to BasePath.
string TriDevs.TriEngine.Resources.ResourceManager.ShaderPath = "Shaders" |
|
static |
Path to the shaders directory, relative to BasePath.
string TriDevs.TriEngine.Resources.ResourceManager.SongPath = "Songs" |
|
static |
Path to the songs directory, relative to BasePath.
string TriDevs.TriEngine.Resources.ResourceManager.SoundPath = "Sounds" |
|
static |
Path to the sounds directory, relative to BasePath.
The documentation for this class was generated from the following file: