当前位置: 首页>>代码示例>>C++>>正文


C++ TilesetManager::removeReference方法代码示例

本文整理汇总了C++中TilesetManager::removeReference方法的典型用法代码示例。如果您正苦于以下问题:C++ TilesetManager::removeReference方法的具体用法?C++ TilesetManager::removeReference怎么用?C++ TilesetManager::removeReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TilesetManager的用法示例。


在下文中一共展示了TilesetManager::removeReference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
    }
}
开发者ID:stt,项目名称:tiled,代码行数:39,代码来源:mapdocument.cpp

示例2: removeTilesetAt

/**
 * Removes the tileset at the given \a index from this map. Emits the
 * appropriate signal.
 *
 * \warning Does not make sure that any references to tiles in the removed
 *          tileset are cleared.
 */
void MapDocument::removeTilesetAt(int index)
{
    emit tilesetAboutToBeRemoved(index);

    SharedTileset tileset = mMap->tilesets().at(index);
    mMap->removeTilesetAt(index);
    emit tilesetRemoved(tileset.data());

    TilesetManager *tilesetManager = TilesetManager::instance();
    tilesetManager->removeReference(tileset);
}
开发者ID:stt,项目名称:tiled,代码行数:18,代码来源:mapdocument.cpp

示例3: 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;
}
开发者ID:stt,项目名称:tiled,代码行数:24,代码来源:mapdocument.cpp

示例4:

TilesetDocument::~TilesetDocument()
{
    TilesetManager *tilesetManager = TilesetManager::instance();
    tilesetManager->removeReference(mTileset);
}
开发者ID:aTom3333,项目名称:tiled,代码行数:5,代码来源:tilesetdocument.cpp


注:本文中的TilesetManager::removeReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。