Ejemplo n.º 1
0
void RenameListener::action(const ActionEvent &event)
{
    if (event.getId() == "ok" && viewport && mDialog)
    {
        const Map *const map = viewport->getMap();
        if (!map)
            return;

        const SpecialLayer *const sl = map->getSpecialLayer();
        MapItem *item = nullptr;
        if (sl)
        {
            item = sl->getTile(mMapItemX, mMapItemY);
            if (item)
                item->setComment(mDialog->getText());
        }
        item = map->findPortalXY(mMapItemX, mMapItemY);
        if (item)
            item->setComment(mDialog->getText());

        if (socialWindow)
            socialWindow->updatePortalNames();
    }
    mDialog = nullptr;
}
Ejemplo n.º 2
0
void OperatorOverloadingTest::check_map_item_default_constructor() {
  print_header( "map_item default constructor initializes to E" );

  MapItem item;

  print_test( item.getType() == 'E' );
}
Ejemplo n.º 3
0
MapItem Rotation30::getATVPosition(Vector<float> position, int rotation){
   MapItem mi;
   for(int i = 0; i < 4; i++){
      mi.addPoint(position + atvRotations[rotation][i]);
   }
   return mi;
}
Ejemplo n.º 4
0
void MapView::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton) {
        MapItem *item = dynamic_cast<MapItem *>(itemAt(event->pos()));
        if (item) {
            if (qApp->keyboardModifiers() & (Qt::ControlModifier | Qt::ShiftModifier)) {
                item->setSelected(!item->selected());
                mapScene()->setSelectedLevelObject(nullptr);
            } else {
                if (!item->selected())
                    mapScene()->selectSingleItem(item);
            }
            startPos_ = event->pos();
            prevPos_ = event->pos();
            draggedItems_ = mapScene()->selectedItems();
            dragInitialBounds_ = mapScene()->itemsBoundingRect(draggedItems_);
            dragPrevBounds_ = dragInitialBounds_;
            dragState_ = AboutToDrag;
            if (macroStarted_) {
                qerr << "Unterminated macro" << endl;
                mapScene()->undoStack()->endMacro();
            }
        } else {
            if (!(qApp->keyboardModifiers() & Qt::ShiftModifier))
                mapScene()->selectSingleItem(nullptr);
            startPos_ = event->pos();
            selecting_ = true;
        }
    } else if (event->button() == Qt::RightButton) {
        prevPos_ = event->pos();
        scrolling_ = true;
    }
}
Ejemplo n.º 5
0
void OperatorOverloadingTest::check_map_item_get_type() {
  print_header( "map_item sets type correctly" );

  MapItem item;
  item.setType( 'Z' );

  print_test( item.getType() == 'Z' );
}
Ejemplo n.º 6
0
void MapView::DrawMap()
{
     Width = (dm->mapset->Max_XLine - dm->mapset->Min_XLine) + 60;
     Height= (dm->mapset->Max_YLine - dm->mapset->Min_YLine) + 60;
     scene->setSceneRect(-Width/2.0,-Height/2.0,Width,Height);
     MapItem *item = new MapItem(dm);
     scene->addItem(item);
     item->setPos(0,0);
}
Ejemplo n.º 7
0
MapItem* MapView::createMapItem(const AIStateWorld& state) {
	MapItem* item = new MapItem(nullptr, state, _debugger);
	item->setPos((qreal)state.getPosition().x, (qreal)state.getPosition().z);
	if (_debugger.isSelected(state)) {
		item->setZValue(std::numeric_limits<qreal>::max());
	} else {
		item->setZValue((qreal)state.getPosition().y);
	}
	return item;
}
Ejemplo n.º 8
0
MapItem* MapItem::createWall()
{
	MapItem* mapItem = new MapItem();
	if (mapItem && mapItem->init())
	{
		mapItem->autorelease();
		return mapItem;
	}
	CC_SAFE_DELETE(mapItem);
	return NULL;
}
Ejemplo n.º 9
0
QJsonArray MapScene::toJsonArray(bool selectedOnly) const
{
    QJsonArray objects;
    foreach (QGraphicsItem *item, items()) {
        MapItem *mapItem = dynamic_cast<MapItem *>(item);
        if (!mapItem)
            continue;
        if (selectedOnly &&!mapItem->selected())
            continue;
        LevelObject *obj = mapItem->levelObject();
        if (!obj)
            continue;

        QJsonObject json = obj->toJsonObject();
        objects.append(json);
    }
Ejemplo n.º 10
0
void Map::get_map_items_by_coordinates(int x, int y, std::list<MapItem*>* out_list)
{
	if (this->_map_items == nullptr || this->_map_items->size() == 0)
	{
		//return nullptr; -> nothing
	}
	else
	{
		for (std::list<MapItem*>::iterator iterator = this->_map_items->begin(), end = this->_map_items->end(); iterator != end; ++iterator)
		{
			MapItem* it = *iterator;
			Vec* position = it->get_position();
			if (position->get_x() == x && position->get_y() == y)
				out_list->push_back(it);
		}
	}
}
Ejemplo n.º 11
0
void MapView::mouseMoveEvent(QMouseEvent *event)
{
    if (selecting_) {
        // FIXME: optimize
        //QRect rect = selectionRect().normalized();
        //foreach (QGraphicsItem *item, scene()->items(mapToScene(rect))) {
        QRectF rect = selectionRect();
        foreach (QGraphicsItem *item, scene()->items()) {
            QPolygonF itemViewportBounds = mapFromScene(item->sceneBoundingRect());
            bool intersects = !itemViewportBounds.intersected(rect).isEmpty();
            MapItem *mapItem = dynamic_cast<MapItem *>(item);
            if (mapItem)
                mapItem->setActive(intersects);
        }
        scene()->update();
        return;
    }
Ejemplo n.º 12
0
MapItem* Map::get_map_item_by_coordinates(int x, int y) const
{
	if (this->_map_items == nullptr || this->_map_items->size() == 0)
	{
		return nullptr;
	}
	else
	{
		for (std::list<MapItem*>::iterator iterator = this->_map_items->begin(), end = this->_map_items->end(); iterator != end; ++iterator)
		{
			MapItem* it = *iterator;

			Vec* position = it->get_position();
			if (position->get_x() == x && position->get_y() == y)
				return it;
		}
		return nullptr;
	}
}
Ejemplo n.º 13
0
 bool operator()( MapItem& item, PyObject* key )
 {
     return item.key_lessthan( key );
 }