本文整理汇总了C++中Tileset::isExternal方法的典型用法代码示例。如果您正苦于以下问题:C++ Tileset::isExternal方法的具体用法?C++ Tileset::isExternal怎么用?C++ Tileset::isExternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tileset
的用法示例。
在下文中一共展示了Tileset::isExternal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: embedTileset
void TilesetDock::embedTileset()
{
Tileset *tileset = currentTileset();
if (!tileset)
return;
if (!tileset->isExternal())
return;
// To embed a tileset we clone it, since further changes to that tileset
// should not affect the exteral tileset.
SharedTileset embeddedTileset = tileset->clone();
QUndoStack *undoStack = mMapDocument->undoStack();
int mapTilesetIndex = mMapDocument->map()->tilesets().indexOf(tileset->sharedPointer());
// Tileset may not be part of the map yet
if (mapTilesetIndex == -1)
undoStack->push(new AddTileset(mMapDocument, embeddedTileset));
else
undoStack->push(new ReplaceTileset(mMapDocument, mapTilesetIndex, embeddedTileset));
// Make sure the embedded tileset is selected
int embeddedTilesetIndex = mTilesets.indexOf(embeddedTileset);
if (embeddedTilesetIndex != -1)
mTabBar->setCurrentIndex(embeddedTilesetIndex);
}
示例2: updateActions
void TilesetDock::updateActions()
{
bool external = false;
TilesetView *view = nullptr;
Tileset *tileset = nullptr;
const int index = mTabBar->currentIndex();
if (index > -1) {
view = tilesetViewAt(index);
tileset = mTilesets.at(index).data();
if (view) {
if (!view->model()) // Lazily set up the model
setupTilesetModel(view, tileset);
mViewStack->setCurrentIndex(index);
external = tileset->isExternal();
}
}
const bool tilesetIsDisplayed = view != nullptr;
const auto map = mMapDocument ? mMapDocument->map() : nullptr;
mEmbedTileset->setEnabled(tilesetIsDisplayed && external);
mExportTileset->setEnabled(tilesetIsDisplayed && !external);
mEditTileset->setEnabled(tilesetIsDisplayed);
mDeleteTileset->setEnabled(tilesetIsDisplayed && map && contains(map->tilesets(), tileset));
}
示例3: updateActions
void TilesetDock::updateActions()
{
bool external = false;
bool isCollection = false;
bool hasSelection = false;
TilesetView *view = nullptr;
const int index = mTabBar->currentIndex();
if (index > -1) {
view = tilesetViewAt(index);
if (view) {
Tileset *tileset = mTilesets.at(index).data();
if (!view->model()) // Lazily set up the model
setupTilesetModel(view, tileset);
mViewStack->setCurrentIndex(index);
external = tileset->isExternal();
isCollection = tileset->isCollection();
hasSelection = view->selectionModel()->hasSelection();
}
}
const bool tilesetIsDisplayed = view != nullptr;
const bool mapIsDisplayed = mMapDocument != nullptr;
mNewTileset->setEnabled(mapIsDisplayed);
mImportTileset->setEnabled(tilesetIsDisplayed && external);
mExportTileset->setEnabled(tilesetIsDisplayed && !external);
mPropertiesTileset->setEnabled(tilesetIsDisplayed);
mDeleteTileset->setEnabled(tilesetIsDisplayed);
mEditTerrain->setEnabled(tilesetIsDisplayed && !external);
mAddTiles->setEnabled(tilesetIsDisplayed && isCollection && !external);
mRemoveTiles->setEnabled(tilesetIsDisplayed && isCollection
&& hasSelection && !external);
}
示例4: exportTileset
void TilesetDock::exportTileset()
{
Tileset *tileset = currentTileset();
if (!tileset)
return;
if (tileset->isExternal())
return;
int mapTilesetIndex = mMapDocument->map()->tilesets().indexOf(tileset->sharedPointer());
if (mapTilesetIndex == -1)
return;
// To export a tileset we clone it, since the tileset could now be used by
// other maps. This ensures undo can take the map back to using an embedded
// tileset, without affecting those other maps.
SharedTileset externalTileset = tileset->clone();
FormatHelper<TilesetFormat> helper(FileFormat::ReadWrite);
Preferences *prefs = Preferences::instance();
QString suggestedFileName = prefs->lastPath(Preferences::ExternalTileset);
suggestedFileName += QLatin1Char('/');
suggestedFileName += externalTileset->name();
const QLatin1String extension(".tsx");
if (!suggestedFileName.endsWith(extension))
suggestedFileName.append(extension);
// todo: remember last used filter
QString selectedFilter = TsxTilesetFormat().nameFilter();
const QString fileName =
QFileDialog::getSaveFileName(this, tr("Export Tileset"),
suggestedFileName,
helper.filter(), &selectedFilter);
if (fileName.isEmpty())
return;
prefs->setLastPath(Preferences::ExternalTileset,
QFileInfo(fileName).path());
TilesetFormat *format = helper.formatByNameFilter(selectedFilter);
if (!format)
return; // can't happen
if (!format->write(*externalTileset, fileName)) {
QString error = format->errorString();
QMessageBox::critical(window(),
tr("Export Tileset"),
tr("Error saving tileset: %1").arg(error));
return;
}
externalTileset->setFileName(fileName);
externalTileset->setFormat(format);
QUndoCommand *command = new ReplaceTileset(mMapDocument,
mapTilesetIndex,
externalTileset);
mMapDocument->undoStack()->push(command);
// Make sure the external tileset is selected
int externalTilesetIndex = mTilesets.indexOf(externalTileset);
if (externalTilesetIndex != -1)
mTabBar->setCurrentIndex(externalTilesetIndex);
}