本文整理汇总了C++中ObjectGroup::name方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGroup::name方法的具体用法?C++ ObjectGroup::name怎么用?C++ ObjectGroup::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectGroup
的用法示例。
在下文中一共展示了ObjectGroup::name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMap
void test_MapReader::loadMap()
{
MapReader reader;
Map *map = reader.readMap("../data/mapobject.tmx");
// TODO: Also test tilesets (internal and external), properties and tile
// layer data.
QVERIFY(map);
QCOMPARE(map->layerCount(), 2);
QCOMPARE(map->width(), 100);
QCOMPARE(map->height(), 80);
QCOMPARE(map->tileWidth(), 32);
QCOMPARE(map->tileHeight(), 32);
TileLayer *tileLayer = dynamic_cast<TileLayer*>(map->layerAt(0));
QVERIFY(tileLayer);
QCOMPARE(tileLayer->width(), 100);
QCOMPARE(tileLayer->height(), 80);
ObjectGroup *objectGroup = dynamic_cast<ObjectGroup*>(map->layerAt(1));
QVERIFY(objectGroup);
QCOMPARE(objectGroup->name(), QLatin1String("Objects"));
QCOMPARE(objectGroup->objects().count(), 1);
MapObject *mapObject = objectGroup->objects().at(0);
QCOMPARE(mapObject->name(), QLatin1String("Some object"));
QCOMPARE(mapObject->type(), QLatin1String("WARP"));
QCOMPARE(mapObject->x(), qreal(200));
QCOMPARE(mapObject->y(), qreal(200));
QCOMPARE(mapObject->width(), qreal(128));
QCOMPARE(mapObject->height(), qreal(64));
}
示例2: showContextMenu
/**
* Shows the context menu for map objects. The menu allows you to duplicate and
* remove the map objects, or to edit their properties.
*/
void AbstractObjectTool::showContextMenu(MapObjectItem *clickedObjectItem,
QPoint screenPos)
{
QSet<MapObjectItem *> selection = mMapScene->selectedObjectItems();
if (clickedObjectItem && !selection.contains(clickedObjectItem)) {
selection.clear();
selection.insert(clickedObjectItem);
mMapScene->setSelectedObjectItems(selection);
}
if (selection.isEmpty())
return;
const QList<MapObject*> &selectedObjects = mapDocument()->selectedObjects();
const QList<ObjectGroup*> objectGroups = mapDocument()->map()->objectGroups();
QMenu menu;
QAction *duplicateAction = menu.addAction(tr("Duplicate %n Object(s)", "", selection.size()),
this, SLOT(duplicateObjects()));
QAction *removeAction = menu.addAction(tr("Remove %n Object(s)", "", selection.size()),
this, SLOT(removeObjects()));
duplicateAction->setIcon(QIcon(QLatin1String(":/images/16x16/stock-duplicate-16.png")));
removeAction->setIcon(QIcon(QLatin1String(":/images/16x16/edit-delete.png")));
bool anyTileObjectSelected = std::any_of(selectedObjects.begin(),
selectedObjects.end(),
isTileObject);
if (anyTileObjectSelected) {
auto resetTileSizeAction = menu.addAction(tr("Reset Tile Size"), this, SLOT(resetTileSize()));
resetTileSizeAction->setEnabled(std::any_of(selectedObjects.begin(),
selectedObjects.end(),
isResizedTileObject));
auto changeTileAction = menu.addAction(tr("Replace Tile"), this, SLOT(changeTile()));
changeTileAction->setEnabled(tile());
}
// Create action for replacing an object with a template
auto selectedTemplate = objectTemplate();
auto replaceTemplateAction = menu.addAction(tr("Replace With Template"), this, SLOT(replaceObjectsWithTemplate()));
if (selectedTemplate) {
QString name = QFileInfo(selectedTemplate->fileName()).fileName();
replaceTemplateAction->setText(tr("Replace With Template \"%1\"").arg(name));
} else {
replaceTemplateAction->setEnabled(false);
}
if (selectedObjects.size() == 1) {
MapObject *currentObject = selectedObjects.first();
if (!(currentObject->isTemplateBase() || currentObject->isTemplateInstance())) {
const Cell cell = selectedObjects.first()->cell();
// Saving objects with embedded tilesets is disabled
if (cell.isEmpty() || cell.tileset()->isExternal())
menu.addAction(tr("Save As Template"), this, SLOT(saveSelectedObject()));
}
if (currentObject->isTemplateBase()) { // Hide this operations for template base
duplicateAction->setVisible(false);
removeAction->setVisible(false);
replaceTemplateAction->setVisible(false);
}
}
bool anyIsTemplateInstance = std::any_of(selectedObjects.begin(),
selectedObjects.end(),
[](MapObject *object) { return object->isTemplateInstance(); });
if (anyIsTemplateInstance) {
menu.addAction(tr("Detach"), this, SLOT(detachSelectedObjects()));
auto resetToTemplateAction = menu.addAction(tr("Reset Template Instance(s)"), this, SLOT(resetInstances()));
resetToTemplateAction->setEnabled(std::any_of(selectedObjects.begin(),
selectedObjects.end(),
isChangedTemplateInstance));
}
menu.addSeparator();
menu.addAction(tr("Flip Horizontally"), this, SLOT(flipHorizontally()), QKeySequence(tr("X")));
menu.addAction(tr("Flip Vertically"), this, SLOT(flipVertically()), QKeySequence(tr("Y")));
ObjectGroup *objectGroup = RaiseLowerHelper::sameObjectGroup(selection);
if (objectGroup && objectGroup->drawOrder() == ObjectGroup::IndexOrder) {
menu.addSeparator();
menu.addAction(tr("Raise Object"), this, SLOT(raise()), QKeySequence(tr("PgUp")));
menu.addAction(tr("Lower Object"), this, SLOT(lower()), QKeySequence(tr("PgDown")));
menu.addAction(tr("Raise Object to Top"), this, SLOT(raiseToTop()), QKeySequence(tr("Home")));
menu.addAction(tr("Lower Object to Bottom"), this, SLOT(lowerToBottom()), QKeySequence(tr("End")));
}
if (objectGroups.size() > 1) {
menu.addSeparator();
QMenu *moveToLayerMenu = menu.addMenu(tr("Move %n Object(s) to Layer",
"", selectedObjects.size()));
//.........这里部分代码省略.........
示例3: showContextMenu
/**
* Shows the context menu for map objects. The menu allows you to duplicate and
* remove the map objects, or to edit their properties.
*/
void AbstractObjectTool::showContextMenu(MapObjectItem *clickedObjectItem,
QPoint screenPos)
{
QSet<MapObjectItem *> selection = mMapScene->selectedObjectItems();
if (clickedObjectItem && !selection.contains(clickedObjectItem)) {
selection.clear();
selection.insert(clickedObjectItem);
mMapScene->setSelectedObjectItems(selection);
}
if (selection.isEmpty())
return;
const QList<MapObject*> &selectedObjects = mapDocument()->selectedObjects();
const QList<ObjectGroup*> objectGroups = mapDocument()->map()->objectGroups();
QMenu menu;
QAction *duplicateAction = menu.addAction(tr("Duplicate %n Object(s)", "", selection.size()),
this, SLOT(duplicateObjects()));
QAction *removeAction = menu.addAction(tr("Remove %n Object(s)", "", selection.size()),
this, SLOT(removeObjects()));
duplicateAction->setIcon(QIcon(QLatin1String(":/images/16x16/stock-duplicate-16.png")));
removeAction->setIcon(QIcon(QLatin1String(":/images/16x16/edit-delete.png")));
menu.addSeparator();
menu.addAction(tr("Flip Horizontally"), this, SLOT(flipHorizontally()), QKeySequence(tr("X")));
menu.addAction(tr("Flip Vertically"), this, SLOT(flipVertically()), QKeySequence(tr("Y")));
ObjectGroup *objectGroup = RaiseLowerHelper::sameObjectGroup(selection);
if (objectGroup && objectGroup->drawOrder() == ObjectGroup::IndexOrder) {
menu.addSeparator();
menu.addAction(tr("Raise Object"), this, SLOT(raise()), QKeySequence(tr("PgUp")));
menu.addAction(tr("Lower Object"), this, SLOT(lower()), QKeySequence(tr("PgDown")));
menu.addAction(tr("Raise Object to Top"), this, SLOT(raiseToTop()), QKeySequence(tr("Home")));
menu.addAction(tr("Lower Object to Bottom"), this, SLOT(lowerToBottom()), QKeySequence(tr("End")));
}
if (objectGroups.size() > 1) {
menu.addSeparator();
QMenu *moveToLayerMenu = menu.addMenu(tr("Move %n Object(s) to Layer",
"", selectedObjects.size()));
for (ObjectGroup *objectGroup : objectGroups) {
QAction *action = moveToLayerMenu->addAction(objectGroup->name());
action->setData(QVariant::fromValue(objectGroup));
}
}
menu.addSeparator();
QIcon propIcon(QLatin1String(":images/16x16/document-properties.png"));
QAction *propertiesAction = menu.addAction(propIcon,
tr("Object &Properties..."));
// TODO: Implement editing of properties for multiple objects
propertiesAction->setEnabled(selectedObjects.size() == 1);
Utils::setThemeIcon(removeAction, "edit-delete");
Utils::setThemeIcon(propertiesAction, "document-properties");
QAction *action = menu.exec(screenPos);
if (!action)
return;
if (action == propertiesAction) {
MapObject *mapObject = selectedObjects.first();
mapDocument()->setCurrentObject(mapObject);
mapDocument()->emitEditCurrentObject();
return;
}
if (ObjectGroup *objectGroup = action->data().value<ObjectGroup*>()) {
mapDocument()->moveObjectsToGroup(mapDocument()->selectedObjects(),
objectGroup);
}
}