mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-30 20:06:56 -05:00
fix the scripting api and many other changes
- remove obsolete Map::commit() - add ScriptEditMap command - reorganize metatile history - fix next selected event for multi event deletion
This commit is contained in:
@@ -38,6 +38,8 @@ void PaintMetatile::redo() {
|
||||
map->layout->blockdata->copyFrom(newMetatiles);
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
|
||||
renderMapBlocks(map);
|
||||
}
|
||||
|
||||
@@ -48,6 +50,8 @@ void PaintMetatile::undo() {
|
||||
map->layout->blockdata->copyFrom(oldMetatiles);
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
|
||||
renderMapBlocks(map);
|
||||
|
||||
QUndoCommand::undo();
|
||||
@@ -172,6 +176,8 @@ void ShiftMetatiles::redo() {
|
||||
map->layout->blockdata->copyFrom(newMetatiles);
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
|
||||
renderMapBlocks(map, true);
|
||||
}
|
||||
|
||||
@@ -182,6 +188,8 @@ void ShiftMetatiles::undo() {
|
||||
map->layout->blockdata->copyFrom(oldMetatiles);
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
|
||||
renderMapBlocks(map, true);
|
||||
|
||||
QUndoCommand::undo();
|
||||
@@ -253,6 +261,8 @@ void ResizeMap::redo() {
|
||||
map->setBorderDimensions(newBorderWidth, newBorderHeight, false);
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(map->getWidth(), map->getHeight());
|
||||
|
||||
map->mapNeedsRedrawing();
|
||||
}
|
||||
|
||||
@@ -269,6 +279,8 @@ void ResizeMap::undo() {
|
||||
map->setBorderDimensions(oldBorderWidth, oldBorderHeight, false);
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(map->getWidth(), map->getHeight());
|
||||
|
||||
map->mapNeedsRedrawing();
|
||||
|
||||
QUndoCommand::undo();
|
||||
@@ -420,7 +432,8 @@ void EventDelete::redo() {
|
||||
map->objectsChanged();
|
||||
|
||||
editor->selected_events->clear();
|
||||
editor->selected_events->append(nextSelectedEvent->pixmapItem);
|
||||
if (nextSelectedEvent)
|
||||
editor->selected_events->append(nextSelectedEvent->pixmapItem);
|
||||
editor->updateSelectedEvents();
|
||||
}
|
||||
|
||||
@@ -499,3 +512,65 @@ void EventDuplicate::undo() {
|
||||
|
||||
QUndoCommand::undo();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
ScriptEditMap::ScriptEditMap(Map *map,
|
||||
QSize oldMapDimensions, QSize newMapDimensions,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
QUndoCommand *parent) : QUndoCommand(parent) {
|
||||
setText("Script Edit Map");
|
||||
|
||||
this->map = map;
|
||||
|
||||
this->newMetatiles = newMetatiles;
|
||||
this->oldMetatiles = oldMetatiles;
|
||||
|
||||
this->oldMapWidth = oldMapWidth;
|
||||
this->oldMapHeight = oldMapHeight;
|
||||
this->newMapWidth = newMapWidth;
|
||||
this->newMapHeight = newMapHeight;
|
||||
}
|
||||
|
||||
ScriptEditMap::~ScriptEditMap() {
|
||||
if (newMetatiles) delete newMetatiles;
|
||||
if (oldMetatiles) delete oldMetatiles;
|
||||
}
|
||||
|
||||
void ScriptEditMap::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(newMetatiles);
|
||||
if (newMapWidth != map->getWidth() || newMapHeight != map->getHeight()) {
|
||||
map->setDimensions(newMapWidth, newMapHeight);
|
||||
}
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(newMetatiles);
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(newMapWidth, newMapHeight);
|
||||
|
||||
renderMapBlocks(map);
|
||||
}
|
||||
|
||||
void ScriptEditMap::undo() {
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(oldMetatiles);
|
||||
if (oldMapWidth != map->getWidth() || oldMapHeight != map->getHeight()) {
|
||||
map->setDimensions(oldMapWidth, oldMapHeight);
|
||||
}
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(oldMetatiles);
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(oldMapWidth, oldMapHeight);
|
||||
|
||||
renderMapBlocks(map);
|
||||
|
||||
QUndoCommand::undo();
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#include "history.h"
|
||||
#include "historyitem.h"
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "historyitem.h"
|
||||
|
||||
HistoryItem::HistoryItem(Blockdata *metatiles, Blockdata *border, int layoutWidth, int layoutHeight, int borderWidth, int borderHeight) {
|
||||
this->metatiles = metatiles;
|
||||
this->border = border;
|
||||
this->layoutWidth = layoutWidth;
|
||||
this->layoutHeight = layoutHeight;
|
||||
this->borderWidth = borderWidth;
|
||||
this->borderHeight = borderHeight;
|
||||
}
|
||||
|
||||
HistoryItem::~HistoryItem() {
|
||||
if (this->metatiles) delete this->metatiles;
|
||||
if (this->border) delete this->border;
|
||||
}
|
||||
|
||||
RegionMapHistoryItem::RegionMapHistoryItem(int which, QVector<uint8_t> tiles, QString cityMap) {
|
||||
this->which = which;
|
||||
this->tiles = tiles;
|
||||
this->cityMap = cityMap;
|
||||
}
|
||||
|
||||
RegionMapHistoryItem::RegionMapHistoryItem(int which, QVector<uint8_t> tiles, int width, int height) {
|
||||
this->which = which;
|
||||
this->tiles = tiles;
|
||||
this->mapWidth = width;
|
||||
this->mapHeight = height;
|
||||
}
|
||||
|
||||
RegionMapHistoryItem::~RegionMapHistoryItem() {}
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "history.h"
|
||||
#include "historyitem.h"
|
||||
#include "map.h"
|
||||
#include "imageproviders.h"
|
||||
#include "scripting.h"
|
||||
@@ -416,15 +415,10 @@ void Map::_floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_
|
||||
}
|
||||
}
|
||||
|
||||
void Map::commit() {
|
||||
return;
|
||||
}
|
||||
|
||||
void Map::floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation) {
|
||||
Block *block = getBlock(x, y);
|
||||
if (block && (block->collision != collision || block->elevation != elevation)) {
|
||||
_floodFillCollisionElevation(x, y, collision, elevation);
|
||||
commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +438,6 @@ void Map::magicFillCollisionElevation(int initialX, int initialY, uint16_t colli
|
||||
}
|
||||
}
|
||||
}
|
||||
commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "regionmap.h"
|
||||
#include "regionmapeditor.h"
|
||||
#include "paletteutil.h"
|
||||
#include "log.h"
|
||||
#include "config.h"
|
||||
|
||||
Reference in New Issue
Block a user