Skip to content

Commit

Permalink
Update forked repo (#1)
Browse files Browse the repository at this point in the history
* Fixed crash when editing collision when tile image wasn't loaded

When opening a tileset it can happen that the tileset image fails to
load. In this case, opening the tile collision editor could lead to a
crash.

* GmxPlugin: Fixed tile type inheritance for tile objects

Now tile objects of which the tile has a type defined are exported as
instances of this type of object in the GameMaker room file.

* Added toolbar for stamp brush and bucket fill tool (mapeditor#1586)

This adds a new tool-specific toolbar that can be used by tools.

Currently contains actions for rotating/flipping stamp and toggling random mode.

Closes mapeditor#1084

* docs: Fixed link to other page

* QtPropertyBrowser: Removed deprecation warnings

The classes were deprecated in Qt 5.0 and warnings have been added in Qt
5.7.

* Fixed rendering of tile object outlines for resized objects

They were taking the size of the image instead of the size of the
object, which means this was broken since Tiled 0.12.

* Fixed rendering of tile objects when the image couldn't be loaded

If the tile was found but its image failed to load, tile objects would
not render at all and due to a broken boundingRect be also impossible to
interact with.

Now they render as the special "missing image marker" and can be
interacted with.

* More fixes for labels of objects nested in a group layer

* Fixed labels shown on objects hidden via a group layer
* Fixed updating of label visibility when toggling group layer visibility

* Fixed updating of label positions when moving a group layer

When moving a group layer, any labels present for objects nested within
that group layer need to be synchronized.

* GmxPlugin: Added support for defining views with objects (mapeditor#1621)

* Fixed hang when trying to fill with a pasted stamp

Since 688ec7d the size of a copied map
is set to 0x0 instead of matching the tile layer's size. It was supposed
to be irrelevant, but as it turns out TileStamp::maxSize was based on
the size of the map instead of the size of the tile layer. This could
lead to an infinite loop in fillWithStamp in bucketfilltool.cpp.

Closes mapeditor#1617
Closes mapeditor#1624

* Restored Ctrl+N shortcut on "New Map" action

There isn't really a good reason not to have this shortcut. Eventually
it may pop up a dialog where you can pick what you want to create, but
since it's more common to create new maps than new tilesets we can just
do that for now.

* Use initializer list for quick-stamp keys

* Introduced TilesetDocumentsModel and its sort-filter model companion

This model lists the tileset documents that are currently open, and the
sort-filter version sorts them by name and filters out tilesets that are
embedded in other maps than the current one.

This model extracts part of the logic from TilesetDock, so that it could
be reused by an updated TerrainModel. The TerrainModel currently only
lists terrains from tilesets that are already part of the map, but it
should display all loaded external tilesets.

* libtiled-java: Fixed wrong exception being caught in TileSet (mapeditor#1629)

* Display all tilesets with terrain in the Terrains view

Except for tilesets that are embedded into another map than the current
one, the Terrains view now displays all tilesets that have terrains
defined.

The Terrain Brush will now automatically add the tileset of the
currently selected terrain to the map when it isn't already present.

* Show custom properties on tiles and terrains in the map editor

While still not editable, this change shows these properties in a
read-only fashion. It is often useful to see them, as indicated by
multiple users on the forum.

* Bumped version to 1.0.2 and updated NEWS file

* Adds option to lock/unlock layer (mapeditor#1627)

Locking a layer prevents modifications to the layer by the tools, as
well as by some actions like cut and delete. Modifications to objects
are prevented by making them not selectable.

Closes mapeditor#734

* Fixed tool tips on flipping and rotating stamp actions
  • Loading branch information
boaromayo committed Jun 28, 2017
1 parent a3d1605 commit f76b918
Show file tree
Hide file tree
Showing 82 changed files with 1,321 additions and 498 deletions.
13 changes: 13 additions & 0 deletions NEWS.md
@@ -1,3 +1,16 @@
### 1.0.2 (27 June 2017)

* Added read-only tile and terrain properties in map editor
* Fixed Terrains view to display all tilesets with terrain
* Fixed hang when trying to fill with a pasted stamp (#1617, #1624)
* Fixed crash when editing collision when tile image wasn't loaded
* Fixed rendering of tile objects when the image couldn't be loaded
* Fixed rendering of tile object outlines for resized objects
* Fixed labels shown on objects hidden via a group layer
* Fixed updating of label positions when moving a group layer
* GmxPlugin: Fixed tile type inheritance for tile objects
* Restored Ctrl+N shortcut on "New Map" action

### 1.0.1 (13 June 2017)

* Made the zoom level used in Tilesets view persistent
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/tmx-changelog.md
Expand Up @@ -8,7 +8,7 @@ Below are described the changes/additions that were made to the [TMX format](tmx

* A new [`group`](tmx-map-format.md#group) element was added which is a group layer that can have other layers as child elements. This means layers now form a hierarchy.
* Added Text objects, identified by a new [`text`](tmx-map-format.md#text) element which is used as a child of the [`object`](tmx-map-format.md#object) element.
* Added a [`tile.type`](tmx-map-format.md#tile) attribute for supporting [typed tiles](custom-properties.md#typed-tiles).
* Added a [`tile.type`](tmx-map-format.md#tile) attribute for supporting [typed tiles](../manual/custom-properties.md#typed-tiles).

## Tiled 0.18 ##

Expand Down
22 changes: 10 additions & 12 deletions src/libtiled/isometricrenderer.cpp
Expand Up @@ -76,8 +76,10 @@ QRectF IsometricRenderer::boundingRect(const MapObject *object) const

if (const Tile *tile = object->cell().tile()) {
QSize imgSize = tile->size();
scale = QSizeF(objectSize.width() / imgSize.width(),
objectSize.height() / imgSize.height());
if (!imgSize.isNull()) {
scale = QSizeF(objectSize.width() / imgSize.width(),
objectSize.height() / imgSize.height());
}
tileOffset = tile->offset();
}

Expand Down Expand Up @@ -295,25 +297,21 @@ void IsometricRenderer::drawMapObject(QPainter *painter,
const Cell &cell = object->cell();

if (!cell.isEmpty()) {
const QSizeF size = object->size();
const QPointF pos = pixelToScreenCoords(object->position());

CellRenderer(painter).render(cell, pos, object->size(),
CellRenderer(painter).render(cell, pos, size,
CellRenderer::BottomCenter);

if (testFlag(ShowTileObjectOutlines)) {
QSizeF imgSize;
QPointF tileOffset;

if (const Tile *tile = cell.tile()) {
imgSize = tile->size();
if (const Tile *tile = cell.tile())
tileOffset = tile->offset();
} else {
imgSize = object->size();
}

QRectF rect(QPointF(pos.x() - imgSize.width() / 2 + tileOffset.x(),
pos.y() - imgSize.height() + tileOffset.y()),
imgSize);
QRectF rect(QPointF(pos.x() - size.width() / 2 + tileOffset.x(),
pos.y() - size.height() + tileOffset.y()),
size);

pen.setStyle(Qt::SolidLine);
painter->setPen(pen);
Expand Down
11 changes: 10 additions & 1 deletion src/libtiled/layer.cpp
Expand Up @@ -46,7 +46,8 @@ Layer::Layer(TypeFlag type, const QString &name, int x, int y) :
mOpacity(1.0f),
mVisible(true),
mMap(nullptr),
mParentLayer(nullptr)
mParentLayer(nullptr),
mLocked(false)
{
}

Expand Down Expand Up @@ -75,6 +76,14 @@ bool Layer::isHidden() const
return layer; // encountered an invisible layer
}

bool Layer::isUnlocked() const
{
const Layer *layer = this;
while (layer && !layer->isLocked())
layer = layer->parentLayer();
return !layer;
}

/**
* Returns whether the given \a candidate is this layer or one of its parents.
*/
Expand Down
13 changes: 13 additions & 0 deletions src/libtiled/layer.h
Expand Up @@ -98,13 +98,25 @@ class TILEDSHARED_EXPORT Layer : public Object
*/
bool isVisible() const { return mVisible; }

/**
* Returns the lock status of current layer.
*/
bool isLocked() const { return mLocked; }

/**
* Returns the lock status of layer including parent layers.
*/
bool isUnlocked() const;

bool isHidden() const;

/**
* Sets the visibility of this layer.
*/
void setVisible(bool visible) { mVisible = visible; }

void setLocked(bool locked) { mLocked = locked; }

/**
* Returns the map this layer is part of.
*/
Expand Down Expand Up @@ -227,6 +239,7 @@ class TILEDSHARED_EXPORT Layer : public Object
bool mVisible;
Map *mMap;
GroupLayer *mParentLayer;
bool mLocked;

friend class Map;
friend class GroupLayer;
Expand Down
5 changes: 5 additions & 0 deletions src/libtiled/mapreader.cpp
Expand Up @@ -569,6 +569,7 @@ static void readLayerAttributes(Layer &layer,
{
const QStringRef opacityRef = atts.value(QLatin1String("opacity"));
const QStringRef visibleRef = atts.value(QLatin1String("visible"));
const QStringRef lockedRef = atts.value(QLatin1String("locked"));

bool ok;
const float opacity = opacityRef.toFloat(&ok);
Expand All @@ -579,6 +580,10 @@ static void readLayerAttributes(Layer &layer,
if (ok)
layer.setVisible(visible);

const int locked = lockedRef.toInt(&ok);
if (ok)
layer.setLocked(locked);

const QPointF offset(atts.value(QLatin1String("offsetx")).toDouble(),
atts.value(QLatin1String("offsety")).toDouble());

Expand Down
13 changes: 8 additions & 5 deletions src/libtiled/maprenderer.cpp
Expand Up @@ -152,23 +152,26 @@ CellRenderer::CellRenderer(QPainter *painter, const CellType cellType)
void CellRenderer::render(const Cell &cell, const QPointF &pos, const QSizeF &size, Origin origin)
{
const Tile *tile = cell.tile();
if (!tile) {

if (tile)
tile = tile->currentFrameTile();

if (!tile || tile->image().isNull()) {
QRectF target { pos - QPointF(0, size.height()), size };
if (origin == BottomCenter)
target.moveLeft(target.left() - size.width() / 2);
renderMissingImageMarker(*mPainter, target);
return;
}

tile = tile->currentFrameTile();
if (!tile)
return;

if (mTile != tile)
flush();

const QPixmap &image = tile->image();
const QSizeF imageSize = image.size();
if (imageSize.isEmpty())
return;

const QSizeF scale(size.width() / imageSize.width(), size.height() / imageSize.height());
const QPoint offset = tile->offset();
const QPointF sizeHalf = QPointF(size.width() / 2, size.height() / 2);
Expand Down
2 changes: 2 additions & 0 deletions src/libtiled/mapwriter.cpp
Expand Up @@ -541,6 +541,8 @@ void MapWriterPrivate::writeLayerAttributes(QXmlStreamWriter &w,

if (!layer.isVisible())
w.writeAttribute(QLatin1String("visible"), QLatin1String("0"));
if (layer.isLocked())
w.writeAttribute(QLatin1String("locked"), QLatin1String("1"));
if (opacity != qreal(1))
w.writeAttribute(QLatin1String("opacity"), QString::number(opacity));

Expand Down
18 changes: 18 additions & 0 deletions src/libtiled/object.h
Expand Up @@ -118,9 +118,27 @@ class TILEDSHARED_EXPORT Object
void removeProperty(const QString &name)
{ mProperties.remove(name); }

bool isPartOfTileset() const;

private:
const TypeId mTypeId;
Properties mProperties;
};


/**
* Returns whether this object is stored as part of a tileset.
*/
inline bool Object::isPartOfTileset() const
{
switch (mTypeId) {
case Object::TilesetType:
case Object::TileType:
case Object::TerrainType:
return true;
default:
return false;
}
}

} // namespace Tiled
23 changes: 12 additions & 11 deletions src/libtiled/orthogonalrenderer.cpp
Expand Up @@ -69,8 +69,10 @@ QRectF OrthogonalRenderer::boundingRect(const MapObject *object) const

if (const Tile *tile = object->cell().tile()) {
QSize imgSize = tile->size();
scale = QSizeF(objectSize.width() / imgSize.width(),
objectSize.height() / imgSize.height());
if (!imgSize.isNull()) {
scale = QSizeF(objectSize.width() / imgSize.width(),
objectSize.height() / imgSize.height());
}
tileOffset = tile->offset();
}

Expand Down Expand Up @@ -217,6 +219,9 @@ void OrthogonalRenderer::drawTileLayer(QPainter *painter,

const int tileWidth = map()->tileWidth();
const int tileHeight = map()->tileHeight();
if (tileWidth <= 0 || tileHeight <= 0)
return;

const QPointF layerPos(layer->x() * tileWidth,
layer->y() * tileHeight);

Expand Down Expand Up @@ -325,23 +330,19 @@ void OrthogonalRenderer::drawMapObject(QPainter *painter,
const Cell &cell = object->cell();

if (!cell.isEmpty()) {
CellRenderer(painter).render(cell, QPointF(), object->size(),
const QSizeF size = object->size();
CellRenderer(painter).render(cell, QPointF(), size,
CellRenderer::BottomLeft);

if (testFlag(ShowTileObjectOutlines)) {
QSizeF imgSize;
QPointF tileOffset;

if (const Tile *tile = cell.tile()) {
imgSize = tile->size();
if (const Tile *tile = cell.tile())
tileOffset = tile->offset();
} else {
imgSize = object->size();
}

QRectF rect(QPointF(tileOffset.x(),
tileOffset.y() - imgSize.height()),
imgSize);
tileOffset.y() - size.height()),
size);

QPen pen(Qt::SolidLine);
pen.setCosmetic(true);
Expand Down
2 changes: 2 additions & 0 deletions src/libtiled/tileset.h
Expand Up @@ -620,3 +620,5 @@ inline bool Tileset::imageLoaded() const
}

} // namespace Tiled

Q_DECLARE_METATYPE(Tiled::SharedTileset)

0 comments on commit f76b918

Please sign in to comment.