VoltAir
|
Frequently used static utility functions. More...
Classes | |
class | QQmlListPropertyOnQList |
Helper class which creates QQmlListProperty objects directly on QList members fields. More... | |
Functions | |
template<typename T > | |
QVariantList | toVariantList (const QList< T > &list) |
Returns list converted to a QVariantList. More... | |
template<typename T > | |
QList< T > | toList (const QVariantList &list) |
Returns list converted to a QList. More... | |
template<typename T > | |
QVariantMap | toVariantMap (const QMap< QString, T > map) |
Returns map converted to a QVariantMap. More... | |
template<typename T > | |
QMap< QString, T > | toMap (const QVariantMap &map) |
Returns map converted to a QMap. More... | |
template<typename T > | |
const T & | clamp (const T &a, const T &min, const T &max) |
Returns the value a clamped between min and max . More... | |
static float | smoothstep (float t) |
Computes the value of a smoothed interpolation curve between 0.0f and 1.0f . More... | |
static float | qrandF () |
Returns a pseudo-random number in the range [0, 1) . More... | |
template<typename TObject > | |
TObject * | findParentOfType (QObject *node) |
Returns our closest ancestor which is of type TObject . More... | |
QString | getPathToAsset (const QString &assetPath) |
Returns the platform dependent path to assetPath . More... | |
QUrl | getUrlPathToAsset (const QString &assetPath) |
Returns platform dependent path URL to assetPath . More... | |
QString | getPathToFont (const QString &fontPath) |
Returns the platform dependent path to the font in fontPath . More... | |
QString | getPathToImage (const QString &imagePath) |
Returns the platform dependent path to the image in imagePath . More... | |
QString | getPathToMovie (const QString &moviePath) |
Returns the platform dependent path to the movie in moviePath . More... | |
QString | getPathToLevel (const QString &levelPath) |
Returns the platform dependent path to the level in levelPath . More... | |
QString | getPathToSound (const QString &soundPath) |
Returns the platform dependent path to the sound in soundPath . More... | |
QString | getPathToData (const QString &dataPath) |
Returns the platform dependent path to the data file in dataPath . More... | |
QString | readFileAsQString (const QString &path) |
Returns the entire contents of a text file as a QString . More... | |
std::string | readFileAsStdString (const QString &path) |
Returns the entire contents of a text file as a std::string . More... | |
QRectF | united (const QRectF &rect, const QPointF &point) |
Expands a QRectF's span to include a point. More... | |
bool | javaScriptFuncExists (QObject *object, const char *method) |
Checks if a javascript function exists. More... | |
bool | deviceHasTouchScreen () |
Returns true if the device on which the game is running has a touch screen. More... | |
int | getDeviceTouchScreenDeviceId () |
Returns the device id of the touch screen on the device, or -1 if none exists. More... | |
Frequently used static utility functions.
|
inline |
Returns the value a
clamped between min
and max
.
a | Value to clamp |
min | Minimum value to return |
max | Maximum value to return |
bool Util::deviceHasTouchScreen | ( | ) |
Returns true
if the device on which the game is running has a touch screen.
TObject* Util::findParentOfType | ( | QObject * | node | ) |
Returns our closest ancestor which is of type TObject
.
node | Node to search |
int Util::getDeviceTouchScreenDeviceId | ( | ) |
Returns the device id of the touch screen on the device, or -1 if none exists.
Returns the platform dependent path to assetPath
.
assetPath | Path of asset to resolve. |
Returns the platform dependent path to the data file in dataPath
.
dataPath | Path of data file to resolve |
Returns the platform dependent path to the font in fontPath
.
fontPath | Path of font to resolve |
Returns the platform dependent path to the image in imagePath
.
imagePath | Path of image to resolve |
Returns the platform dependent path to the level in levelPath
.
levelPath | Path of level to resolve |
Returns the platform dependent path to the movie in moviePath
.
moviePath | Path of movie to resolve |
Returns the platform dependent path to the sound in soundPath
.
soundPath | Path of sound to resolve |
Returns platform dependent path URL to assetPath
.
assetPath | Path of asset to resolve. |
bool Util::javaScriptFuncExists | ( | QObject * | object, |
const char * | method | ||
) |
Checks if a javascript function exists.
object | Object to check for method |
method | Name of method to check |
|
inlinestatic |
Returns a pseudo-random number in the range [0, 1)
.
Returns the entire contents of a text file as a QString
.
path | Path to file to read |
std::string Util::readFileAsStdString | ( | const QString & | path | ) |
Returns the entire contents of a text file as a std::string
.
path | Path to file to read |
|
inlinestatic |
Computes the value of a smoothed interpolation curve between 0.0f
and 1.0f
.
t | Parametric value |
QList<T> Util::toList | ( | const QVariantList & | list | ) |
Returns list
converted to a QList.
T
must have a valid VariantConverter specialization. Type | for conversion |
list | QVariantList to convert |
Returns map
converted to a QMap.
T
must have a valid VariantConverter specialization. Type | for conversion |
map | QVariantMap to convert |
QVariantList Util::toVariantList | ( | const QList< T > & | list | ) |
Returns list
converted to a QVariantList.
T
must have a valid VariantConverter specialization. Type | for conversion |
list | QList to convert |
Returns map
converted to a QVariantMap.
T
must have a valid VariantConverter specialization. Type | for conversion |
map | QMap to convert |