Represents a set of qualifiers and rules for resolving paths to assets, used in conjunction with CYIAssetLocator.
A set of default configurations are created and added to the CYIAssetLocator by default.
Custom configurations can be created by deriving from this class. Qualifier values must be distinct across all configurations, both system defined and user defined.
As a simple example, the ScreenOrientation configuration defines two qualifiers where only one can be valid for the current device orientation.
{
public:
ScreenOrientation()
{
}
virtual std::unique_ptr<CYIAbstractAssetConfiguration>
Clone()
const override {
return std::make_unique<ScreenOrientation>(*this);
}
{
if ( ((nHeight < nWidth) && (name == "land")) ||
((nHeight > nWidth) && (name == "port")) )
{
return 1;
}
return 0;
}
};
Configuration qualifiers do not need to be a list of distinct values, strings that belong to this property can be defined by overriding CYIAssetConfiguration::IsQualifier as shown in this example.
{
public:
SurfaceWidth()
{
}
virtual std::unique_ptr<CYIAbstractAssetConfiguration>
Clone()
const override {
return std::make_unique<SurfaceWidth>(*this);
}
{
return (name[0] ==
'w') && name.
SubStr(name.
GetLength() - 1, 1).IsNumeric();
}
{
float fQualifierWidth = number.
To<
float>();
if (fQualifierWidth <= fScreenWidth)
{
return static_cast<uint32_t>(fScreenWidth - fQualifierWidth) + 1;
}
return 0;
}
};
To make use of the new configuration, it must be added to the CYIAssetLocator used by the CYIAssetLoader.
- See also
- CYIAssetLocator
-
CYIAssetLoader::GetAssetLocator
| virtual bool CYIAbstractAssetConfiguration::IsQualifier |
( |
const CYIString & |
name | ) |
const |
|
inlinevirtual |
Returns true if name is a qualifier for this configuration.
By default this function will test for a match if a list of qualifiers is provided in the constructor. Override this function if different behaviour is required such as regex matching.
Since qualifiers are used to create directory names, they must contain only characters valid in creating directories. Additionally, the "dash" character is reserved as a separator between qualifiers and should not be used.
| virtual uint32_t CYIAbstractAssetConfiguration::Test |
( |
const CYIString & |
name | ) |
const |
|
pure virtual |
Returns a number used to disqualify qualifiers and compare them to each other against the current device configuration.
Returning 0 indicates name is not valid for the current device configuration and should be disqualified.
Returning a positive number indicates name is valid for the current device configuration. Smaller numbers indicate name is higher priority.
The default implementation returns 0.