Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripting: Added MapEditor.currentBrushChanged signal #4005

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Unreleased

* Scripting: Added `FileFormat.nameFilter`
* Scripting: Added `MapEditor.currentBrushChanged` signal

### Tiled 1.11.0 (27 June 2024)

Expand Down
24 changes: 17 additions & 7 deletions docs/scripting-doc/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ declare class Asset extends TiledObject {
/**
* The signal emitted when {@link modified} changes.
*/
readonly modifiedChanged: Signal<null>;
readonly modifiedChanged: Signal<void>;

/**
* Whether the asset is a {@link TileMap}.
Expand Down Expand Up @@ -2369,6 +2369,16 @@ interface MapEditor {
*/
currentBrush : TileMap

/**
* Signal emitted when the current brush has changed.
*
* This signal is also emitted when assigning to {@link currentBrush}, so be
* careful not to cause an infinite loop.
*
* @since 1.11.1
*/
currentBrushChanged : Signal<void>;

/**
* Gets the currently selected {@link WangSet} in the "Terrain Sets" view.
*
Expand All @@ -2383,7 +2393,7 @@ interface MapEditor {
*
* @since 1.8
*/
readonly currentWangSetChanged: Signal<null>;
readonly currentWangSetChanged: Signal<void>;

/**
* Gets the currently selected Wang color index in the "Terrain Sets" view.
Expand Down Expand Up @@ -2430,7 +2440,7 @@ interface TilesetsView {
*
* @since 1.9.1
*/
readonly currentTilesetChanged: Signal<null>;
readonly currentTilesetChanged: Signal<void>;

/**
* A list of the tiles that are selected in the current tileset.
Expand Down Expand Up @@ -2876,7 +2886,7 @@ declare class TileMap extends Asset {
/**
* The signal emitted when {@link currentLayer} changes.
*/
readonly currentLayerChanged: Signal<null>;
readonly currentLayerChanged: Signal<void>;

/**
* Selected layers.
Expand All @@ -2889,7 +2899,7 @@ declare class TileMap extends Asset {
/**
* The signal emitted when {@link selectedLayers} changes.
*/
readonly selectedLayersChanged: Signal<null>;
readonly selectedLayersChanged: Signal<void>;

/**
* Selected objects.
Expand All @@ -2902,7 +2912,7 @@ declare class TileMap extends Asset {
/**
* The signal emitted when {@link selectedObjects} changes.
*/
readonly selectedObjectsChanged: Signal<null>;
readonly selectedObjectsChanged: Signal<void>;

/**
* Constructs a new map.
Expand Down Expand Up @@ -3880,7 +3890,7 @@ interface TilesetEditor {
*
* @since 1.9
*/
readonly currentWangSetChanged: Signal<null>;
readonly currentWangSetChanged: Signal<void>;

/**
* Gets the currently selected Wang color index in the "Terrain Sets" view.
Expand Down
2 changes: 2 additions & 0 deletions src/tiled/mapeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ void MapEditor::setStamp(const TileStamp &stamp)
mToolManager->selectTool(mStampBrush);

mTilesetDock->selectTilesInStamp(stamp);

emit currentBrushChanged();
}

void MapEditor::selectWangBrush()
Expand Down
3 changes: 2 additions & 1 deletion src/tiled/mapeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MapEditor final : public Editor
Q_OBJECT

Q_PROPERTY(Tiled::TilesetDock *tilesetsView READ tilesetDock CONSTANT)
Q_PROPERTY(Tiled::EditableMap *currentBrush READ currentBrush WRITE setCurrentBrush)
Q_PROPERTY(Tiled::EditableMap *currentBrush READ currentBrush WRITE setCurrentBrush NOTIFY currentBrushChanged)
Q_PROPERTY(Tiled::EditableWangSet *currentWangSet READ currentWangSet NOTIFY currentWangSetChanged)
Q_PROPERTY(int currentWangColorIndex READ currentWangColorIndex NOTIFY currentWangColorIndexChanged)
Q_PROPERTY(Tiled::MapView *currentMapView READ currentMapView CONSTANT)
Expand Down Expand Up @@ -130,6 +130,7 @@ class MapEditor final : public Editor
AbstractTool *selectedTool() const;

signals:
void currentBrushChanged();
void currentWangSetChanged();
void currentWangColorIndexChanged(int colorIndex);

Expand Down