本文整理汇总了C++中TilesetView类的典型用法代码示例。如果您正苦于以下问题:C++ TilesetView类的具体用法?C++ TilesetView怎么用?C++ TilesetView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TilesetView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tilesetViewAt
void TilesetDock::deleteTilesetView(int index)
{
TilesetDocument *tilesetDocument = mTilesetDocuments.at(index);
tilesetDocument->disconnect(this);
Tileset *tileset = tilesetDocument->tileset().data();
TilesetView *view = tilesetViewAt(index);
QString path = QLatin1String("TilesetDock/TilesetScale/") + tileset->name();
QSettings *settings = Preferences::instance()->settings();
if (view->scale() != 1.0)
settings->setValue(path, view->scale());
else
settings->remove(path);
mTilesets.remove(index);
mTilesetDocuments.removeAt(index);
delete view; // view needs to go before the tab
mTabBar->removeTab(index);
// Make sure we don't reference this tileset anymore
if (mCurrentTiles && mCurrentTiles->referencesTileset(tileset)) {
TileLayer *cleaned = mCurrentTiles->clone();
cleaned->removeReferencesToTileset(tileset);
setCurrentTiles(cleaned);
}
if (mCurrentTile && mCurrentTile->tileset() == tileset)
setCurrentTile(nullptr);
}
示例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: createTilesetView
void TilesetDock::createTilesetView(int index, TilesetDocument *tilesetDocument)
{
auto tileset = tilesetDocument->tileset();
mTilesets.insert(index, tileset);
mTilesetDocuments.insert(index, tilesetDocument);
TilesetView *view = new TilesetView;
view->setZoomable(mZoomable);
// Insert view before the tab to make sure it is there when the tab index
// changes (happens when first tab is inserted).
mViewStack->insertWidget(index, view);
mTabBar->insertTab(index, tileset->name());
connect(tilesetDocument, &TilesetDocument::tilesetNameChanged,
this, &TilesetDock::tilesetNameChanged);
connect(tilesetDocument, &TilesetDocument::fileNameChanged,
this, &TilesetDock::updateActions);
connect(tilesetDocument, &TilesetDocument::tilesetChanged,
this, &TilesetDock::tilesetChanged);
connect(tilesetDocument, &TilesetDocument::tileImageSourceChanged,
this, &TilesetDock::tileImageSourceChanged);
connect(tilesetDocument, &TilesetDocument::tileAnimationChanged,
this, &TilesetDock::tileAnimationChanged);
}
示例4: tilesetViewAt
/**
* Synchronizes the selection with the given stamp. Ignored when the stamp is
* changing because of a selection change in the TilesetDock.
*/
void TilesetDock::selectTilesInStamp(const TileStamp &stamp)
{
if (mEmittingStampCaptured)
return;
QSet<Tile*> processed;
QMap<QItemSelectionModel*, QItemSelection> selections;
for (const TileStampVariation &variation : stamp.variations()) {
const TileLayer &tileLayer = *variation.tileLayer();
for (const Cell &cell : tileLayer) {
if (Tile *tile = cell.tile) {
if (processed.contains(tile))
continue;
processed.insert(tile); // avoid spending time on duplicates
Tileset *tileset = tile->tileset();
int tilesetIndex = mTilesets.indexOf(tileset->sharedPointer());
if (tilesetIndex != -1) {
TilesetView *view = tilesetViewAt(tilesetIndex);
if (!view->model()) // Lazily set up the model
setupTilesetModel(view, tileset);
const TilesetModel *model = view->tilesetModel();
const QModelIndex modelIndex = model->tileIndex(tile);
QItemSelectionModel *selectionModel = view->selectionModel();
selections[selectionModel].select(modelIndex, modelIndex);
}
}
}
}
if (!selections.isEmpty()) {
mSynchronizingSelection = true;
// Mark captured tiles as selected
for (auto i = selections.constBegin(); i != selections.constEnd(); ++i) {
QItemSelectionModel *selectionModel = i.key();
const QItemSelection &selection = i.value();
selectionModel->select(selection, QItemSelectionModel::SelectCurrent);
}
// Show/edit properties of all captured tiles
mMapDocument->setSelectedTiles(processed.toList());
// Update the current tile (useful for animation and collision editors)
auto first = selections.begin();
QItemSelectionModel *selectionModel = first.key();
const QItemSelection &selection = first.value();
const QModelIndex currentIndex = selection.first().topLeft();
if (selectionModel->currentIndex() != currentIndex)
selectionModel->setCurrentIndex(currentIndex, QItemSelectionModel::NoUpdate);
else
currentChanged(currentIndex);
mSynchronizingSelection = false;
}
}
示例5: currentTilesetView
void TilesetEditor::currentWangSetChanged(WangSet *wangSet)
{
TilesetView *view = currentTilesetView();
if (!view)
return;
view->setWangSet(wangSet);
}
示例6: GetExecutor
void BrushState::OnTilesetViewRender() {
TilesetView* tsv = GetExecutor()->GetTilesetView();
Tileset* ts = GetExecutor()->GetTileset();
int tileWidth = ts->Width() + (tsv->IsPadded() ? 1 : 0);
int tileHeight = ts->Height() + (tsv->IsPadded() ? 1 : 0);
Rect selected = tsv->GetBrushSelection();
int ywin = tsv->GetYWin();
tsv->DrawSelectRect(selected.left * tileWidth, selected.top * tileHeight - ywin, tileWidth * (selected.Width() + 1), tileHeight * (selected.Height() + 1), RGBA(127, 255, 255));
}
示例7: getSelectedTileset
TileSet* TilesetDock::getSelectedTileset() {
TilesetView *currentView;
TilesetScene *currentScene;
currentView = (TilesetView*) tabWidget->currentWidget();
if(currentView == NULL) return NULL;
currentScene = (TilesetScene*) currentView->scene();
return currentScene->tileSet;
}
示例8: TilesetView
void TilesetDock::insertTilesetView(int index, Tileset *tileset)
{
TilesetView *view = new TilesetView(mMapDocument);
view->setModel(new TilesetModel(tileset, view));
connect(view->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
SLOT(updateCurrentTiles()));
mTabBar->insertTab(index, tileset->name());
mViewStack->insertWidget(index, view);
}
示例9: currentTilesetView
void TilesetDock::removeTiles()
{
TilesetView *view = currentTilesetView();
if (!view)
return;
if (!view->selectionModel()->hasSelection())
return;
const QModelIndexList indexes = view->selectionModel()->selectedIndexes();
const TilesetModel *model = view->tilesetModel();
QList<Tile*> tiles;
for (const QModelIndex &index : indexes)
if (Tile *tile = model->tileAt(index))
tiles.append(tile);
auto matchesAnyTile = [&tiles] (const Cell &cell) {
if (Tile *tile = cell.tile)
return tiles.contains(tile);
return false;
};
const bool inUse = hasTileReferences(mMapDocument, matchesAnyTile);
// If the tileset is in use, warn the user and confirm removal
if (inUse) {
QMessageBox warning(QMessageBox::Warning,
tr("Remove Tiles"),
tr("One or more of the tiles to be removed are "
"still in use by the map!"),
QMessageBox::Yes | QMessageBox::No,
this);
warning.setDefaultButton(QMessageBox::Yes);
warning.setInformativeText(tr("Remove all references to these tiles?"));
if (warning.exec() != QMessageBox::Yes)
return;
}
QUndoStack *undoStack = mMapDocument->undoStack();
undoStack->beginMacro(tr("Remove Tiles"));
if (inUse)
removeTileReferences(mMapDocument, matchesAnyTile);
Tileset *tileset = view->tilesetModel()->tileset();
undoStack->push(new RemoveTiles(mMapDocument, tileset, tiles));
undoStack->endMacro();
// Clear the current tiles, will be referencing the removed tiles
setCurrentTiles(nullptr);
setCurrentTile(nullptr);
}
示例10: tilesetAdded
void TilesetDock::tilesetAdded(int index, Tileset *tileset)
{
TilesetView *view = new TilesetView;
view->setMapDocument(mMapDocument);
view->setZoomable(mZoomable);
mTilesets.insert(index, tileset->sharedPointer());
mTabBar->insertTab(index, tileset->name());
mViewStack->insertWidget(index, view);
updateActions();
}
示例11: indexOf
void TilesetDock::tilesetChanged(Tileset *tileset)
{
// Update the affected tileset model, if it exists
const int index = indexOf(mTilesets, tileset);
if (index < 0)
return;
TilesetView *view = tilesetViewAt(index);
if (TilesetModel *model = view->tilesetModel()) {
view->updateBackgroundColor();
model->tilesetChanged();
}
}
示例12: TilesetView
void TilesetDock::insertTilesetView(int index, Tileset *tileset)
{
TilesetView *view = new TilesetView(mMapDocument);
view->setModel(new TilesetModel(tileset, view));
connect(view->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
SLOT(updateCurrentTiles()));
mViewStack->insertWidget(index, view);
QVariant userdata = QVariant::fromValue(view);
mDropDown->addItem(tileset->name(), userdata);
mDropDown->model()->sort(0);
mDropDown->setCurrentIndex(mDropDown->findData(userdata));
}
示例13: TilesetView
void TilesetDock::insertTilesetView(int index, Tileset *tileset)
{
TilesetView *view = new TilesetView(mMapDocument);
view->setModel(new TilesetModel(tileset, view));
connect(view->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
SLOT(updateCurrentTiles()));
connect(view, SIGNAL(deleteRequested(TilesetView*)),
SLOT(deleteRequested(TilesetView*)));
mViewStack->insertWidget(index, view);
mDropDown->insertItem(index, QIcon(), tileset->name());
mDropDown->setCurrentIndex(index);
}
示例14: updateActions
void TilesetDock::updateActions()
{
bool external = false;
TilesetView *view = 0;
const int index = mTabBar->currentIndex();
if (index > -1) {
view = tilesetViewAt(index);
if (view) {
mViewStack->setCurrentWidget(view);
external = view->tilesetModel()->tileset()->isExternal();
}
}
mRenameTileset->setEnabled(view && !external);
mImportTileset->setEnabled(view && external);
mExportTileset->setEnabled(view && !external);
mPropertiesTileset->setEnabled(view && !external);
mDeleteTileset->setEnabled(view);
}
示例15: Q_ASSERT
void TilesetEditor::removeDocument(Document *document)
{
TilesetDocument *tilesetDocument = qobject_cast<TilesetDocument*>(document);
Q_ASSERT(tilesetDocument);
Q_ASSERT(mViewForTileset.contains(tilesetDocument));
tilesetDocument->disconnect(this);
TilesetView *view = mViewForTileset.take(tilesetDocument);
QString path = QLatin1String("TilesetEditor/TilesetScale/") +
tilesetDocument->tileset()->name();
QSettings *settings = Preferences::instance()->settings();
if (view->scale() != 1.0)
settings->setValue(path, view->scale());
else
settings->remove(path);
// remove first, to keep it valid while the current widget changes
mWidgetStack->removeWidget(view);
delete view;
}