本文整理汇总了C++中TilesetManager::addReference方法的典型用法代码示例。如果您正苦于以下问题:C++ TilesetManager::addReference方法的具体用法?C++ TilesetManager::addReference怎么用?C++ TilesetManager::addReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TilesetManager
的用法示例。
在下文中一共展示了TilesetManager::addReference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Document
TilesetDocument::TilesetDocument(const SharedTileset &tileset, const QString &fileName)
: Document(TilesetDocumentType, fileName)
, mTileset(tileset)
, mTerrainModel(new TilesetTerrainModel(this, this))
, mWangSetModel(new TilesetWangSetModel(this, this))
, mWangColorModel(nullptr)
{
mCurrentObject = tileset.data();
// warning: will need to be kept up-to-date
mFileName = tileset->fileName();
connect(this, &TilesetDocument::propertyAdded,
this, &TilesetDocument::onPropertyAdded);
connect(this, &TilesetDocument::propertyRemoved,
this, &TilesetDocument::onPropertyRemoved);
connect(this, &TilesetDocument::propertyChanged,
this, &TilesetDocument::onPropertyChanged);
connect(this, &TilesetDocument::propertiesChanged,
this, &TilesetDocument::onPropertiesChanged);
connect(mTerrainModel, &TilesetTerrainModel::terrainRemoved,
this, &TilesetDocument::onTerrainRemoved);
connect(mWangSetModel, &TilesetWangSetModel::wangSetRemoved,
this, &TilesetDocument::onWangSetRemoved);
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->addReference(tileset);
}
示例2: unifyTilesets
/**
* Replaces tilesets in \a map by similar tilesets in this map when possible,
* and adds tilesets to \a missingTilesets whenever there is a tileset without
* replacement in this map.
*
* \warning This method assumes that the tilesets in \a map are managed by
* the TilesetManager!
*/
void MapDocument::unifyTilesets(Map *map, QVector<SharedTileset> &missingTilesets)
{
QVector<SharedTileset> availableTilesets = mMap->tilesets();
for (const SharedTileset &tileset : qAsConst(missingTilesets))
if (!availableTilesets.contains(tileset))
availableTilesets.append(tileset);
TilesetManager *tilesetManager = TilesetManager::instance();
// Iterate over a copy because map->replaceTileset may invalidate iterator
const QVector<SharedTileset> tilesets = map->tilesets();
for (const SharedTileset &tileset : tilesets) {
// tileset already added
if (availableTilesets.contains(tileset))
continue;
SharedTileset replacement = tileset->findSimilarTileset(availableTilesets);
// tileset not present and no replacement tileset found
if (!replacement) {
missingTilesets.append(tileset);
availableTilesets.append(tileset);
continue;
}
// replacement tileset found, change given map
if (map->replaceTileset(tileset, replacement))
tilesetManager->addReference(replacement);
tilesetManager->removeReference(tileset);
}
}
示例3: insertTileset
/**
* Adds a tileset to this map at the given \a index. Emits the appropriate
* signal.
*/
void MapDocument::insertTileset(int index, const SharedTileset &tileset)
{
emit tilesetAboutToBeAdded(index);
mMap->insertTileset(index, tileset);
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->addReference(tileset);
emit tilesetAdded(index, tileset.data());
}
示例4: replaceTileset
/**
* Replaces the tileset at the given \a index with the new \a tileset. Replaces
* all tiles from the replaced tileset with tiles from the new tileset.
*
* @return The replaced tileset.
*/
SharedTileset MapDocument::replaceTileset(int index, const SharedTileset &tileset)
{
SharedTileset oldTileset = mMap->tilesetAt(index);
bool added = mMap->replaceTileset(oldTileset, tileset);
TilesetManager *tilesetManager = TilesetManager::instance();
if (added)
tilesetManager->addReference(tileset);
tilesetManager->removeReference(oldTileset);
if (added)
emit tilesetReplaced(index, tileset.data(), oldTileset.data());
else
emit tilesetRemoved(oldTileset.data());
return oldTileset;
}