本文整理汇总了C++中TilesetManager类的典型用法代码示例。如果您正苦于以下问题:C++ TilesetManager类的具体用法?C++ TilesetManager怎么用?C++ TilesetManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TilesetManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: mFileName
MapDocument::MapDocument(Map *map, const QString &fileName):
mFileName(fileName),
mMap(map),
mLayerModel(new LayerModel(this)),
mUndoStack(new QUndoStack(this))
{
switch (map->orientation()) {
case Map::Isometric:
mRenderer = new IsometricRenderer(map);
break;
case Map::Hexagonal:
mRenderer = new HexagonalRenderer(map);
break;
default:
mRenderer = new OrthogonalRenderer(map);
break;
}
mCurrentLayerIndex = (map->layerCount() == 0) ? -1 : 0;
mLayerModel->setMapDocument(this);
// Forward signals emitted from the layer model
connect(mLayerModel, SIGNAL(layerAdded(int)), SLOT(onLayerAdded(int)));
connect(mLayerModel, SIGNAL(layerAboutToBeRemoved(int)),
SLOT(onLayerAboutToBeRemoved(int)));
connect(mLayerModel, SIGNAL(layerRemoved(int)), SLOT(onLayerRemoved(int)));
connect(mLayerModel, SIGNAL(layerChanged(int)), SIGNAL(layerChanged(int)));
connect(mUndoStack, SIGNAL(cleanChanged(bool)), SIGNAL(modifiedChanged()));
// Register tileset references
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->addReferences(mMap->tilesets());
}
示例4: tilesetAboutToBeAdded
/**
* 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());
}
示例5:
MapDocument::~MapDocument()
{
// Unregister tileset references
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->removeReferences(mMap->tilesets());
delete mRenderer;
delete mMap;
}
示例6: mFileName
MapDocument::MapDocument(Map *map, const QString &fileName):
mFileName(fileName),
mMap(map),
mLayerModel(new LayerModel(this)),
mCurrentObject(map),
mMapObjectModel(new MapObjectModel(this)),
mTerrainModel(new TerrainModel(this, this)),
mUndoStack(new QUndoStack(this))
{
switch (map->orientation()) {
case Map::Isometric:
mRenderer = new IsometricRenderer(map);
break;
case Map::Staggered:
mRenderer = new StaggeredRenderer(map);
break;
default:
mRenderer = new OrthogonalRenderer(map);
break;
}
mCurrentLayerIndex = (map->layerCount() == 0) ? -1 : 0;
mLayerModel->setMapDocument(this);
// Forward signals emitted from the layer model
connect(mLayerModel, SIGNAL(layerAdded(int)), SLOT(onLayerAdded(int)));
connect(mLayerModel, SIGNAL(layerAboutToBeRemoved(int)),
SLOT(onLayerAboutToBeRemoved(int)));
connect(mLayerModel, SIGNAL(layerRemoved(int)), SLOT(onLayerRemoved(int)));
connect(mLayerModel, SIGNAL(layerChanged(int)), SIGNAL(layerChanged(int)));
// Forward signals emitted from the map object model
mMapObjectModel->setMapDocument(this);
connect(mMapObjectModel, SIGNAL(objectsAdded(QList<MapObject*>)),
SIGNAL(objectsAdded(QList<MapObject*>)));
connect(mMapObjectModel, SIGNAL(objectsChanged(QList<MapObject*>)),
SIGNAL(objectsChanged(QList<MapObject*>)));
connect(mMapObjectModel, SIGNAL(objectsRemoved(QList<MapObject*>)),
SLOT(onObjectsRemoved(QList<MapObject*>)));
connect(mMapObjectModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
SLOT(onMapObjectModelRowsInserted(QModelIndex,int,int)));
connect(mMapObjectModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
SLOT(onMapObjectModelRowsInsertedOrRemoved(QModelIndex,int,int)));
connect(mMapObjectModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
SLOT(onObjectsMoved(QModelIndex,int,int,QModelIndex,int)));
connect(mTerrainModel, SIGNAL(terrainRemoved(Terrain*)),
SLOT(onTerrainRemoved(Terrain*)));
connect(mUndoStack, SIGNAL(cleanChanged(bool)), SIGNAL(modifiedChanged()));
// Register tileset references
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->addReferences(mMap->tilesets());
}
示例7:
TileStampData::~TileStampData()
{
TilesetManager *tilesetManager = TilesetManager::instance();
// decrease reference to tilesets and delete maps
for (const TileStampVariation &variation : variations) {
tilesetManager->removeReferences(variation.map->tilesets());
delete variation.map;
}
}
示例8: tilesetAboutToBeRemoved
/**
* 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);
}
示例9: mSettings
Preferences::Preferences()
: mSettings(new QSettings)
{
// Retrieve storage settings
mSettings->beginGroup(QLatin1String("Storage"));
mLayerDataFormat = (MapWriter::LayerDataFormat)
mSettings->value(QLatin1String("LayerDataFormat"),
MapWriter::Base64Zlib).toInt();
mDtdEnabled = mSettings->value(QLatin1String("DtdEnabled")).toBool();
mReloadTilesetsOnChange =
mSettings->value(QLatin1String("ReloadTilesets"), true).toBool();
mSettings->endGroup();
// Retrieve interface settings
mSettings->beginGroup(QLatin1String("Interface"));
mShowGrid = mSettings->value(QLatin1String("ShowGrid"), false).toBool();
mSnapToGrid = mSettings->value(QLatin1String("SnapToGrid"),
false).toBool();
mGridColor = QColor(mSettings->value(QLatin1String("GridColor"),
QColor(Qt::black).name()).toString());
mHighlightCurrentLayer = mSettings->value(QLatin1String("HighlightCurrentLayer"),
false).toBool();
mShowTilesetGrid = mSettings->value(QLatin1String("ShowTilesetGrid"),
true).toBool();
mLanguage = mSettings->value(QLatin1String("Language"),
QString()).toString();
mUseOpenGL = mSettings->value(QLatin1String("OpenGL"), false).toBool();
mSettings->endGroup();
// Retrieve defined object types
mSettings->beginGroup(QLatin1String("ObjectTypes"));
const QStringList names =
mSettings->value(QLatin1String("Names")).toStringList();
const QStringList colors =
mSettings->value(QLatin1String("Colors")).toStringList();
mSettings->endGroup();
const int count = qMin(names.size(), colors.size());
for (int i = 0; i < count; ++i)
mObjectTypes.append(ObjectType(names.at(i), QColor(colors.at(i))));
mSettings->beginGroup(QLatin1String("Automapping"));
mAutoMapDrawing = mSettings->value(QLatin1String("WhileDrawing"),
false).toBool();
mSettings->endGroup();
mSettings->beginGroup(QLatin1String("MapsDirectory"));
mMapsDirectory = mSettings->value(QLatin1String("Current"), QString()).toString();
mSettings->endGroup();
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->setReloadTilesetsOnChange(mReloadTilesetsOnChange);
}
示例10: setReloadTilesetsOnChanged
void Preferences::setReloadTilesetsOnChanged(bool value)
{
if (mReloadTilesetsOnChange == value)
return;
mReloadTilesetsOnChange = value;
mSettings->setValue(QLatin1String("Storage/ReloadTilesets"),
mReloadTilesetsOnChange);
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->setReloadTilesetsOnChange(mReloadTilesetsOnChange);
}
示例11: mSettings
Preferences::Preferences()
: mSettings(new QSettings(this))
{
// Retrieve storage settings
mSettings->beginGroup(QLatin1String("Storage"));
mLayerDataFormat = (Map::LayerDataFormat)
mSettings->value(QLatin1String("LayerDataFormat"),
Map::Base64Zlib).toInt();
mDtdEnabled = boolValue("DtdEnabled");
mReloadTilesetsOnChange = boolValue("ReloadTilesets", true);
mSettings->endGroup();
// Retrieve interface settings
mSettings->beginGroup(QLatin1String("Interface"));
mShowGrid = boolValue("ShowGrid");
mShowTileObjectOutlines = boolValue("ShowTileObjectOutlines");
mShowTileAnimations = boolValue("ShowTileAnimations", true);
mSnapToGrid = boolValue("SnapToGrid");
mSnapToFineGrid = boolValue("SnapToFineGrid");
mGridColor = colorValue("GridColor", Qt::black);
mGridFine = intValue("GridFine", 4);
mObjectLineWidth = realValue("ObjectLineWidth", 2);
mHighlightCurrentLayer = boolValue("HighlightCurrentLayer");
mShowTilesetGrid = boolValue("ShowTilesetGrid", true);
mLanguage = stringValue("Language");
mUseOpenGL = boolValue("OpenGL");
mSettings->endGroup();
// Retrieve defined object types
mSettings->beginGroup(QLatin1String("ObjectTypes"));
const QStringList names =
mSettings->value(QLatin1String("Names")).toStringList();
const QStringList colors =
mSettings->value(QLatin1String("Colors")).toStringList();
mSettings->endGroup();
const int count = qMin(names.size(), colors.size());
for (int i = 0; i < count; ++i)
mObjectTypes.append(ObjectType(names.at(i), QColor(colors.at(i))));
mSettings->beginGroup(QLatin1String("Automapping"));
mAutoMapDrawing = boolValue("WhileDrawing");
mSettings->endGroup();
mSettings->beginGroup(QLatin1String("MapsDirectory"));
mMapsDirectory = stringValue("Current");
mSettings->endGroup();
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->setReloadTilesetsOnChange(mReloadTilesetsOnChange);
tilesetManager->setAnimateTiles(mShowTileAnimations);
}
示例12: setShowTileAnimations
void Preferences::setShowTileAnimations(bool enabled)
{
if (mShowTileAnimations == enabled)
return;
mShowTileAnimations = enabled;
mSettings->setValue(QLatin1String("Interface/ShowTileAnimations"),
mShowTileAnimations);
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->setAnimateTiles(mShowTileAnimations);
emit showTileAnimationsChanged(mShowTileAnimations);
}
示例13: QSharedData
TileStampData::TileStampData(const TileStampData &other)
: QSharedData(other)
, name(other.name)
, fileName() // not copied
, variations(other.variations)
, quickStampIndex(-1)
{
TilesetManager *tilesetManager = TilesetManager::instance();
// deep-copy the map data
for (TileStampVariation &variation : variations) {
variation.map = new Map(*variation.map);
tilesetManager->addReferences(variation.map->tilesets());
}
}
示例14: Document
MapDocument::MapDocument(Map *map, const QString &fileName)
: Document(MapDocumentType, fileName)
, mMap(map)
, mLayerModel(new LayerModel(this))
, mHoveredMapObject(nullptr)
, mRenderer(nullptr)
, mMapObjectModel(new MapObjectModel(this))
{
mCurrentObject = map;
createRenderer();
mCurrentLayer = (map->layerCount() == 0) ? nullptr : map->layerAt(0);
mLayerModel->setMapDocument(this);
// Forward signals emitted from the layer model
connect(mLayerModel, &LayerModel::layerAdded,
this, &MapDocument::onLayerAdded);
connect(mLayerModel, &LayerModel::layerAboutToBeRemoved,
this, &MapDocument::onLayerAboutToBeRemoved);
connect(mLayerModel, &LayerModel::layerRemoved,
this, &MapDocument::onLayerRemoved);
connect(mLayerModel, &LayerModel::layerChanged,
this, &MapDocument::layerChanged);
// Forward signals emitted from the map object model
mMapObjectModel->setMapDocument(this);
connect(mMapObjectModel, SIGNAL(objectsAdded(QList<MapObject*>)),
SIGNAL(objectsAdded(QList<MapObject*>)));
connect(mMapObjectModel, SIGNAL(objectsChanged(QList<MapObject*>)),
SIGNAL(objectsChanged(QList<MapObject*>)));
connect(mMapObjectModel, SIGNAL(objectsTypeChanged(QList<MapObject*>)),
SIGNAL(objectsTypeChanged(QList<MapObject*>)));
connect(mMapObjectModel, SIGNAL(objectsRemoved(QList<MapObject*>)),
SLOT(onObjectsRemoved(QList<MapObject*>)));
connect(mMapObjectModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
SLOT(onMapObjectModelRowsInserted(QModelIndex,int,int)));
connect(mMapObjectModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
SLOT(onMapObjectModelRowsInsertedOrRemoved(QModelIndex,int,int)));
connect(mMapObjectModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
SLOT(onObjectsMoved(QModelIndex,int,int,QModelIndex,int)));
// Register tileset references
TilesetManager *tilesetManager = TilesetManager::instance();
tilesetManager->addReferences(mMap->tilesets());
}
示例15: 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;
}