本文整理汇总了C++中Tileset::setProperties方法的典型用法代码示例。如果您正苦于以下问题:C++ Tileset::setProperties方法的具体用法?C++ Tileset::setProperties怎么用?C++ Tileset::setProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tileset
的用法示例。
在下文中一共展示了Tileset::setProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tr
Tileset *VariantToMapConverter::toTileset(const QVariant &variant)
{
const QVariantMap variantMap = variant.toMap();
const int firstGid = variantMap["firstgid"].toInt();
const QString name = variantMap["name"].toString();
const int tileWidth = variantMap["tilewidth"].toInt();
const int tileHeight = variantMap["tileheight"].toInt();
const int spacing = variantMap["spacing"].toInt();
const int margin = variantMap["margin"].toInt();
const QVariantMap tileOffset = variantMap["tileoffset"].toMap();
const int tileOffsetX = tileOffset["x"].toInt();
const int tileOffsetY = tileOffset["y"].toInt();
if (tileWidth <= 0 || tileHeight <= 0 || firstGid == 0) {
mError = tr("Invalid tileset parameters for tileset '%1'").arg(name);
return 0;
}
Tileset *tileset = new Tileset(name,
tileWidth, tileHeight,
spacing, margin);
tileset->setTileOffset(QPoint(tileOffsetX, tileOffsetY));
const QString trans = variantMap["transparentcolor"].toString();
if (!trans.isEmpty())
#if QT_VERSION >= 0x040700
if (QColor::isValidColor(trans))
#endif
tileset->setTransparentColor(QColor(trans));
QString imageSource = variantMap["image"].toString();
if (QDir::isRelativePath(imageSource))
imageSource = mMapDir.path() + QLatin1Char('/') + imageSource;
if (!tileset->loadFromImage(QImage(imageSource), imageSource)) {
mError = tr("Error loading tileset image:\n'%1'").arg(imageSource);
delete tileset;
return 0;
}
tileset->setProperties(toProperties(variantMap["properties"]));
QVariantMap propertiesVariantMap = variantMap["tileproperties"].toMap();
QVariantMap::const_iterator it = propertiesVariantMap.constBegin();
for (; it != propertiesVariantMap.constEnd(); ++it) {
const int tileIndex = it.key().toInt();
const QVariant propertiesVar = it.value();
if (tileIndex >= 0 && tileIndex < tileset->tileCount()) {
const Properties properties = toProperties(propertiesVar);
tileset->tileAt(tileIndex)->setProperties(properties);
}
}
mGidMapper.insert(firstGid, tileset);
return tileset;
}
示例2: swap
void Tileset::swap(Tileset &other)
{
const Properties p = properties();
setProperties(other.properties());
other.setProperties(p);
std::swap(mFileName, other.mFileName);
std::swap(mImageReference, other.mImageReference);
std::swap(mTileWidth, other.mTileWidth);
std::swap(mTileHeight, other.mTileHeight);
std::swap(mTileSpacing, other.mTileSpacing);
std::swap(mMargin, other.mMargin);
std::swap(mTileOffset, other.mTileOffset);
std::swap(mOrientation, other.mOrientation);
std::swap(mGridSize, other.mGridSize);
std::swap(mColumnCount, other.mColumnCount);
std::swap(mExpectedColumnCount, other.mExpectedColumnCount);
std::swap(mExpectedRowCount, other.mExpectedRowCount);
std::swap(mTiles, other.mTiles);
std::swap(mNextTileId, other.mNextTileId);
std::swap(mTerrainTypes, other.mTerrainTypes);
std::swap(mWangSets, other.mWangSets);
std::swap(mTerrainDistancesDirty, other.mTerrainDistancesDirty);
std::swap(mStatus, other.mStatus);
std::swap(mBackgroundColor, other.mBackgroundColor);
std::swap(mFormat, other.mFormat);
// Don't swap mWeakPointer, since it's a reference to this.
// Update back references from tiles and terrains
for (auto tile : mTiles)
tile->mTileset = this;
for (auto terrain : mTerrainTypes)
terrain->mTileset = this;
for (auto wangSet : mWangSets)
wangSet->setTileset(this);
for (auto tile : other.mTiles)
tile->mTileset = &other;
for (auto terrain : other.mTerrainTypes)
terrain->mTileset = &other;
for (auto wangSet : other.mWangSets)
wangSet->setTileset(&other);
}