[nostalgia/core/studio] Add command sequence grouping to tile sheet editor

This commit is contained in:
2019-12-06 00:50:32 -06:00
parent 1edd322352
commit 37b6095e13
3 changed files with 53 additions and 30 deletions
+24 -13
View File
@@ -17,22 +17,19 @@ Rectangle {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onPositionChanged: {
var gridX = mouseX - tileGrid.x;
var gridY = mouseY - tileGrid.y;
var tile = tileGrid.childAt(gridX, gridY);
if (tile === null) {
return;
onPressed: {
var pixel = pixelAt(mouseX, mouseY);
if (pixel) {
sheetData.beginCmd()
sheetData.updatePixel(pixel)
}
var tileX = gridX - tile.x;
var tileY = gridY - tile.y;
var pixel = tile.pixelAt(tileX, tileY);
if (pixel === null) {
return;
}
sheetData.updatePixels([pixel]);
}
onPositionChanged: sheetData.updatePixel(pixelAt(mouseX, mouseY))
onReleased: sheetData.endCmd();
onCanceled: sheetData.endCmd();
Grid {
id: tileGrid
property int baseTileSize: Math.min(parent.width / tileGrid.columns, parent.height / tileGrid.rows)
@@ -51,6 +48,20 @@ Rectangle {
}
}
}
function pixelAt(x, y) {
var gridX = x - tileGrid.x;
var gridY = y - tileGrid.y;
var tile = tileGrid.childAt(gridX, gridY);
if (tile === null) {
return null;
}
var tileX = gridX - tile.x;
var tileY = gridY - tile.y;
var pixel = tile.pixelAt(tileX, tileY);
return pixel;
}
}
}