Skip to content

Commit 43a91e0

Browse files
committed
add TileLayer::setTilesetSmooth()
1 parent a2b8ee3 commit 43a91e0

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

include/gf/TileLayer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ inline namespace v1 {
133133
*/
134134
const Tileset& getTileset(std::size_t id) const;
135135

136+
/**
137+
* @brief Enable or disable the smooth filter on the texture of tilesets
138+
*
139+
* @param smooth True to enable smoothing, false to disable it
140+
*
141+
* @see Tileset::setSmooth()
142+
*/
143+
void setTilesetSmooth(bool smooth = true);
136144

137145
/** @} */
138146

include/gf/Tileset.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ inline namespace v1 {
6161
* @param texture New texture
6262
* @sa getTexture()
6363
*/
64-
void setTexture(const Texture& texture);
64+
void setTexture(Texture& texture);
6565

6666
/**
6767
* @brief Get the source texture of the tileset
@@ -76,6 +76,17 @@ inline namespace v1 {
7676
return *m_texture;
7777
}
7878

79+
/**
80+
* @brief Enable or disable the smooth filter on the texture
81+
*
82+
* @param smooth True to enable smoothing, false to disable it
83+
*
84+
* @see BareTexture::setSmooth()
85+
*/
86+
void setSmooth(bool smooth = true) {
87+
m_texture->setSmooth(smooth);
88+
}
89+
7990
/**
8091
* @brief Check if a texture is set
8192
*
@@ -217,7 +228,7 @@ inline namespace v1 {
217228
void updateSize();
218229

219230
private:
220-
const Texture *m_texture;
231+
Texture *m_texture;
221232
Vector2i m_tileSize;
222233
Vector2i m_margin;
223234
Vector2i m_spacing;

library/graphics/TileLayer.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ inline namespace v1 {
8484
return m_sheets[id].tileset;
8585
}
8686

87+
void TileLayer::setTilesetSmooth(bool smooth) {
88+
for (auto & sheet : m_sheets) {
89+
sheet.tileset.setSmooth(smooth);
90+
}
91+
}
92+
93+
8794
void TileLayer::setTile(Vector2i position, std::size_t tileset, int tile, Flags<Flip> flip) {
8895
assert(m_tiles.isValid(position));
8996
m_tiles(position) = { tileset, tile, flip };

library/graphics/Tileset.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ inline namespace v1 {
3737
{
3838
}
3939

40-
void Tileset::setTexture(const Texture& texture) {
40+
void Tileset::setTexture(Texture& texture) {
4141
m_texture = &texture;
4242
updateSize();
4343
}

library/graphics/TmxOps.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ inline namespace v1 {
6868
mapping.emplace(tileset, id);
6969

7070
assert(tileset->image);
71-
const gf::Texture& texture = resources.getTexture(tileset->image->source);
71+
gf::Texture& texture = resources.getTexture(tileset->image->source);
7272

7373
Tileset& ts = tiles.getTileset(id);
7474
ts.setTexture(texture);

0 commit comments

Comments
 (0)