Call on_block_changed from more places
This commit is contained in:
parent
0ef3c6a898
commit
434bafe0b2
5 changed files with 13 additions and 33 deletions
|
@ -55,7 +55,7 @@ public:
|
|||
QList<uint16_t> *selectedMetatiles,
|
||||
QList<QPair<uint16_t, uint16_t>> *selectedCollisions,
|
||||
bool fromScriptCall = false);
|
||||
void floodFillSmartPath(int initialX, int initialY);
|
||||
void floodFillSmartPath(int initialX, int initialY, bool fromScriptCall = false);
|
||||
virtual void pick(QGraphicsSceneMouseEvent*);
|
||||
virtual void select(QGraphicsSceneMouseEvent*);
|
||||
virtual void shift(QGraphicsSceneMouseEvent*);
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
void paintNormal(int x, int y, bool fromScriptCall = false);
|
||||
|
||||
private:
|
||||
void paintSmartPath(int x, int y);
|
||||
void paintSmartPath(int x, int y, bool fromScriptCall = false);
|
||||
static QList<int> smartPathTable;
|
||||
|
||||
signals:
|
||||
|
|
|
@ -395,7 +395,7 @@ void Map::_floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_
|
|||
|
||||
block->collision = collision;
|
||||
block->elevation = elevation;
|
||||
setBlock(x, y, *block);
|
||||
setBlock(x, y, *block, true);
|
||||
if ((block = getBlock(x + 1, y)) && block->collision == old_coll && block->elevation == old_elev) {
|
||||
todo.append(QPoint(x + 1, y));
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ void Map::magicFillCollisionElevation(int initialX, int initialY, uint16_t colli
|
|||
if (block && block->collision == old_coll && block->elevation == old_elev) {
|
||||
block->collision = collision;
|
||||
block->elevation = elevation;
|
||||
setBlock(x, y, *block);
|
||||
setBlock(x, y, *block, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
|||
if (block) {
|
||||
block->collision = this->movementPermissionsSelector->getSelectedCollision();
|
||||
block->elevation = this->movementPermissionsSelector->getSelectedElevation();
|
||||
map->setBlock(x, y, *block);
|
||||
map->setBlock(x, y, *block, true);
|
||||
}
|
||||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||
map->commit();
|
||||
|
|
|
@ -131,7 +131,7 @@ QList<int> MapPixmapItem::smartPathTable = QList<int>({
|
|||
|
||||
#define IS_SMART_PATH_TILE(block) (selectedMetatiles->contains(block->tile))
|
||||
|
||||
void MapPixmapItem::paintSmartPath(int x, int y) {
|
||||
void MapPixmapItem::paintSmartPath(int x, int y, bool fromScriptCall) {
|
||||
QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions();
|
||||
QList<uint16_t> *selectedMetatiles = this->metatileSelector->getSelectedMetatiles();
|
||||
QList<QPair<uint16_t, uint16_t>> *selectedCollisions = this->metatileSelector->getSelectedCollisions();
|
||||
|
@ -165,7 +165,7 @@ void MapPixmapItem::paintSmartPath(int x, int y) {
|
|||
block->collision = openTileCollision;
|
||||
block->elevation = openTileElevation;
|
||||
}
|
||||
map->setBlock(actualX, actualY, *block);
|
||||
map->setBlock(actualX, actualY, *block, !fromScriptCall);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ void MapPixmapItem::paintSmartPath(int x, int y) {
|
|||
block->collision = selectedCollisions->at(smartPathTable[id]).first;
|
||||
block->elevation = selectedCollisions->at(smartPathTable[id]).second;
|
||||
}
|
||||
map->setBlock(actualX, actualY, *block);
|
||||
map->setBlock(actualX, actualY, *block, !fromScriptCall);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ void MapPixmapItem::floodFill(
|
|||
delete[] visited;
|
||||
}
|
||||
|
||||
void MapPixmapItem::floodFillSmartPath(int initialX, int initialY) {
|
||||
void MapPixmapItem::floodFillSmartPath(int initialX, int initialY, bool fromScriptCall) {
|
||||
QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions();
|
||||
QList<uint16_t> *selectedMetatiles = this->metatileSelector->getSelectedMetatiles();
|
||||
QList<QPair<uint16_t, uint16_t>> *selectedCollisions = this->metatileSelector->getSelectedCollisions();
|
||||
|
@ -467,7 +467,7 @@ void MapPixmapItem::floodFillSmartPath(int initialX, int initialY) {
|
|||
block->collision = openTileCollision;
|
||||
block->elevation = openTileElevation;
|
||||
}
|
||||
map->setBlock(x, y, *block);
|
||||
map->setBlock(x, y, *block, !fromScriptCall);
|
||||
if ((block = map->getBlock(x + 1, y)) && block->tile == old_tile) {
|
||||
todo.append(QPoint(x + 1, y));
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ void MapPixmapItem::floodFillSmartPath(int initialX, int initialY) {
|
|||
block->collision = selectedCollisions->at(smartPathTable[id]).first;
|
||||
block->elevation = selectedCollisions->at(smartPathTable[id]).second;
|
||||
}
|
||||
map->setBlock(x, y, *block);
|
||||
map->setBlock(x, y, *block, !fromScriptCall);
|
||||
|
||||
// Visit neighbors if they are smart-path tiles, and don't revisit any.
|
||||
if (!visited[x + 1 + y * map->getWidth()] && (block = map->getBlock(x + 1, y)) && IS_SMART_PATH_TILE(block)) {
|
||||
|
|
|
@ -1,26 +1,6 @@
|
|||
const morningTint = [0.8, 0.7, 0.9];
|
||||
const nightTint = [0.6, 0.55, 1.0];
|
||||
|
||||
function applyTint(palette, tint) {
|
||||
for (let i = 0; i < palette.length; i++) {
|
||||
const color = palette[i];
|
||||
for (let j = 0; j < tint.length; j++) {
|
||||
color[j] = Math.floor(color[j] * tint[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Porymap callback when a map is opened.
|
||||
export function on_map_opened(mapName) {
|
||||
export function on_block_changed(x, y, prevBlock, newBlock) {
|
||||
try {
|
||||
for (let i = 0; i < 13; i++) {
|
||||
const primaryPalette = map.getPrimaryTilesetPalette(i)
|
||||
applyTint(primaryPalette, morningTint)
|
||||
map.setPrimaryTilesetPalettePreview(i, primaryPalette)
|
||||
const secondaryPalette = map.getSecondaryTilesetPalette(i)
|
||||
applyTint(secondaryPalette, morningTint)
|
||||
map.setSecondaryTilesetPalettePreview(i, secondaryPalette)
|
||||
}
|
||||
console.log("on_block_changed", x, y)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue