Skip to content

Commit 585144d

Browse files
committed
Merge pull request #1 from bjorn/master
Get latest changes from bjorn/tiled
2 parents 9c2be76 + b69e4e0 commit 585144d

24 files changed

+6582
-1362
lines changed

AUTHORS

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Hiroki Utsunomiya (Japanese)
126126
Jonatas de Moraes Junior (Portuguese, Brazil)
127127
jurkan (German)
128128
Jānis Kiršteins (Latvian)
129+
Laete Meireles (Portuguese, Brazil)
129130
Lyubomir Vasilev (Bulgarian)
130131
Mauricio Muñoz Lucero (Spanish)
131132
Petr Viktorin (Czech)
@@ -135,6 +136,7 @@ Sébastien Burillard (French)
135136
seeseekey (German)
136137
Tamir Atias (KonoM) (Hebrew)
137138
Thorbjørn Lindeijer (Dutch)
139+
Tomasz Kubiak (Polish)
138140
Yohann Ferreira (French)
139141
Zhao Sting (Chinese)
140142

NEWS

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
0.14.2 (12 October 2015)
2+
* Added Polish translation
3+
* Fixed layer offsets missing in the Lua export
4+
* Fixed JSON tileset format missing in 'Add External Tileset' action
5+
* Fixed language selection entries for Portuguese
6+
* Fixed an issue with copy/pasting when using image collection tilesets
7+
* Updated Brazilian Portuguese translation
8+
19
0.14.1 (28 September 2015)
210
* Added missing 'renderorder' property to the Lua export
311
* Fixed editing of properties of tiles captured from the map

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Compiling
2828

2929
Make sure the Qt (>= 5.1) development libraries are installed:
3030

31-
* In Ubuntu/Debian: `apt-get install qt5-default qttools5-dev-tools zlib1g-dev`
31+
* In Ubuntu/Debian: `apt-get install qt5-default qttools5-dev-tools zlib1g-dev libqt5opengl5-dev`
3232
* In Fedora: `yum install qt-devel`
3333
* In Arch Linux: `pacman -S qt`
3434
* In Mac OS X with [Homebrew](http://brew.sh/): `brew install qt`

src/libtiled/mapformat.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class FormatHelper
171171
QString initialFilter)
172172
: mFilter(std::move(initialFilter))
173173
{
174-
for (Format *format : PluginManager::objects<Format>()) {
174+
PluginManager::each<Format>([this,capabilities](Format *format) {
175175
if (format->hasCapabilities(capabilities)) {
176176
const QString nameFilter = format->nameFilter();
177177

@@ -181,7 +181,7 @@ class FormatHelper
181181
mFormats.append(format);
182182
mFormatByNameFilter.insert(nameFilter, format);
183183
}
184-
}
184+
});
185185
}
186186

187187
const QString &filter() const

src/libtiled/pluginmanager.h

+13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include <QObject>
3636
#include <QString>
3737

38+
#include <functional>
39+
3840
namespace Tiled {
3941

4042
struct LoadedPlugin
@@ -97,6 +99,17 @@ class TILEDSHARED_EXPORT PluginManager : public QObject
9799
return results;
98100
}
99101

102+
/**
103+
* Calls the given function for each object implementing a given interface.
104+
*/
105+
template<typename T>
106+
static void each(std::function<void(T*)> function)
107+
{
108+
for (QObject *object : mInstance->mObjects)
109+
if (T *result = qobject_cast<T*>(object))
110+
function(result);
111+
}
112+
100113
const LoadedPlugin *pluginByFileName(const QString &pluginFileName) const;
101114

102115
signals:

src/libtiled/tile.h

+23
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ class ObjectGroup;
4141
class Terrain;
4242
class Tileset;
4343

44+
/**
45+
* Convenience function for creating tile terrain information.
46+
*/
47+
inline unsigned makeTerrain(int id)
48+
{
49+
id &= 0xFF;
50+
return id << 24 | id << 16 | id << 8 | id;
51+
}
52+
53+
/**
54+
* Convenience function for creating tile terrain information.
55+
*/
56+
inline unsigned makeTerrain(int topLeft,
57+
int topRight,
58+
int bottomLeft,
59+
int bottomRight)
60+
{
61+
return (topLeft & 0xFF) << 24 |
62+
(topRight & 0xFF) << 16 |
63+
(bottomLeft & 0xFF) << 8 |
64+
(bottomRight & 0xFF);
65+
}
66+
4467
/**
4568
* Returns the given \a terrain with the \a corner modified to \a terrainId.
4669
*/

src/libtiled/tileset.cpp

+46-8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ Tile *Tileset::tileAt(int id) const
4646
return (id < mTiles.size()) ? mTiles.at(id) : nullptr;
4747
}
4848

49+
void Tileset::removeLastTile()
50+
{
51+
delete mTiles.takeLast();
52+
}
53+
4954
/**
5055
* Load this tileset from the given tileset \a image. This will replace
5156
* existing tile images in this tileset with new ones. If the new image
@@ -113,21 +118,54 @@ bool Tileset::loadFromImage(const QImage &image,
113118
return true;
114119
}
115120

121+
static bool sameTileImages(const Tileset &a, const Tileset &b)
122+
{
123+
Q_ASSERT(a.tileCount() == b.tileCount());
124+
125+
for (int i = 0; i < a.tileCount(); ++i) {
126+
const Tile *tileA = a.tileAt(i);
127+
const Tile *tileB = b.tileAt(i);
128+
if (tileA->imageSource() != tileB->imageSource())
129+
return false;
130+
}
131+
132+
return true;
133+
}
134+
116135
SharedTileset Tileset::findSimilarTileset(const QVector<SharedTileset> &tilesets) const
117136
{
118137
foreach (const SharedTileset &candidate, tilesets) {
119-
if (candidate != this
120-
&& candidate->imageSource() == imageSource()
121-
&& candidate->tileWidth() == tileWidth()
122-
&& candidate->tileHeight() == tileHeight()
123-
&& candidate->tileSpacing() == tileSpacing()
124-
&& candidate->margin() == margin()) {
125-
return candidate;
126-
}
138+
Q_ASSERT(candidate != this);
139+
140+
if (candidate->tileCount() != tileCount())
141+
continue;
142+
if (candidate->imageSource() != imageSource())
143+
continue;
144+
if (candidate->tileSize() != tileSize())
145+
continue;
146+
if (candidate->tileSpacing() != tileSpacing())
147+
continue;
148+
if (candidate->margin() != margin())
149+
continue;
150+
if (candidate->tileOffset() != tileOffset())
151+
continue;
152+
153+
// For an image collection tileset, check the image sources
154+
if (imageSource().isEmpty())
155+
if (!sameTileImages(*this, *candidate))
156+
continue;
157+
158+
return candidate;
127159
}
160+
128161
return SharedTileset();
129162
}
130163

164+
void Tileset::setImageSource(const QString &imageSource)
165+
{
166+
mImageSource = imageSource;
167+
}
168+
131169
int Tileset::columnCountForWidth(int width) const
132170
{
133171
Q_ASSERT(mTileWidth > 0);

src/libtiled/tileset.h

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <QPixmap>
4242

4343
class QImage;
44+
class QPixmap;
4445

4546
namespace Tiled {
4647

@@ -190,6 +191,11 @@ class TILEDSHARED_EXPORT Tileset : public Object
190191
*/
191192
int tileCount() const { return mTiles.size(); }
192193

194+
/**
195+
* Removes (and deletes) the last tile from this set.
196+
*/
197+
void removeLastTile();
198+
193199
/**
194200
* Returns the number of tile columns in the tileset image.
195201
*/
@@ -233,6 +239,11 @@ class TILEDSHARED_EXPORT Tileset : public Object
233239
*/
234240
const QString &imageSource() const { return mImageSource; }
235241

242+
/**
243+
* Sets the image source of this tileset. Does not reload any tiles!
244+
*/
245+
void setImageSource(const QString &imageSource);
246+
236247
/**
237248
* Returns the column count that this tileset would have if the tileset
238249
* image would have the given \a width. This takes into account the tile

src/plugins/lua/luaplugin.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ void LuaPlugin::writeTileLayer(LuaTableWriter &writer,
327327
writer.writeKeyAndValue("height", tileLayer->height());
328328
writer.writeKeyAndValue("visible", tileLayer->isVisible());
329329
writer.writeKeyAndValue("opacity", tileLayer->opacity());
330+
331+
const QPointF offset = tileLayer->offset();
332+
writer.writeKeyAndValue("offsetx", offset.x());
333+
writer.writeKeyAndValue("offsety", offset.y());
334+
330335
writeProperties(writer, tileLayer->properties());
331336

332337
switch (format) {
@@ -376,6 +381,11 @@ void LuaPlugin::writeObjectGroup(LuaTableWriter &writer,
376381
writer.writeKeyAndValue("name", objectGroup->name());
377382
writer.writeKeyAndValue("visible", objectGroup->isVisible());
378383
writer.writeKeyAndValue("opacity", objectGroup->opacity());
384+
385+
const QPointF offset = objectGroup->offset();
386+
writer.writeKeyAndValue("offsetx", offset.x());
387+
writer.writeKeyAndValue("offsety", offset.y());
388+
379389
writeProperties(writer, objectGroup->properties());
380390

381391
writer.writeStartTable("objects");

src/src.pro

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ CONFIG += ordered
44
SUBDIRS = libtiled tiled plugins \
55
tmxviewer \
66
tmxrasterizer \
7-
automappingconverter
7+
automappingconverter \
8+
terraingenerator

0 commit comments

Comments
 (0)