*
* Because of using ItemIgnoresTransformations, and not scaling the item, the default
* sceneBoundingRect does always return the lowest map tile level scene bounding rect which
- * must be scaled to current zoom level.
+ * is scaled to current zoom level.
+ *
+ * Left side of the returned rect is always inside the world coordinates, so collision
+ * detection based on this rect does work also when items are spanned outside the
+ * world coordinates.
*
* @param zoomLevel Zoom level for which the sceneBoundingRect should be transformed
* @return sceneBoundingRect transformed to given zoom level
*/
void init();
+ /**
+ * @brief Return given value translated between min and max
+ *
+ * If given value is not inside the given range (min <= value <= max), then the allowed range
+ * is adder or subtracted until the value does fit in the range.
+ *
+ * @param value Value to be normalized
+ * @param min Minimum allowed value
+ * @param max Maximum allowed value
+ * @return value which is moved to be inside the given limits
+ */
static int normalize(int value, int min, int max);
/**
*/
void updateViewTilesSceneRect();
+ /**
+ * @brief This method is ran always when the map is zoomed
+ *
+ * This method is the right place for all actions which must be done when ever map is zoomed.
+ */
void zoomed();
private slots:
+ /**
+ * @brief This slot is called after friend items position have been updated
+ *
+ * Does run MapScene::spanItems()
+ */
void friendsPositionsUpdated();
/**
* If there is a tile with same parameter already in the scene, it will be removed
* before adding the new tile.
*
- * @param mapTile Map tile item to be added
- * @param hashKey Hash key for the tile
+ * @param zoomLevel Zoom level of the new tile
+ * @param tileNumber X & Y indexes of the tile
+ * @param image Map tile picture
+ * @param viewZoomLevel Current view zoom level (for setting the zValue)
*/
void addTile(int zoomLevel, QPoint tileNumber, const QPixmap &image, int viewZoomLevel);
*/
void removeTile(MapTile *tile);
+ /**
+ * @brief Set allowed amount of exceeding the world vertical limits
+ *
+ * Limit is set so that vertical limits of the world can be scrolled to middle of
+ * the view.
+ *
+ * @param viewHeight Height of the view
+ * @param zoomLevel Current zoom level
+ */
void setSceneVerticalOverlap(int viewHeight, int zoomLevel);
/**
void tilesSceneRectUpdated(QRect tilesSceneRect);
private:
+ /**
+ * @brief Move map items horizontally in the scene (not MapTile items)
+ *
+ * MapTile items are not moved!
+ *
+ * Move items which intersect the given rect.
+ *
+ * @param from Items colliding given rect are moved
+ * @param distance How much to move each item
+ */
void moveIntersectingItemsHorizontally(QRect from, int distance);
private slots: