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


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

本文整理汇总了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);
}
开发者ID:aTom3333,项目名称:tiled,代码行数:30,代码来源:tilesetdocument.cpp

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

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

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


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