Move status bar messages out of Map class
This commit is contained in:
parent
06720258f9
commit
ecf9e533d4
7 changed files with 126 additions and 166 deletions
121
editor.cpp
121
editor.cpp
|
@ -317,25 +317,72 @@ void Editor::onBorderMetatilesChanged() {
|
|||
}
|
||||
|
||||
void Editor::onHoveredMovementPermissionChanged(uint16_t collision, uint16_t elevation) {
|
||||
map->hoveredMovementPermissionTileChanged(collision, elevation);
|
||||
this->ui->statusBar->showMessage(this->getMovementPermissionText(collision, elevation));
|
||||
}
|
||||
|
||||
void Editor::onHoveredMovementPermissionCleared() {
|
||||
map->clearHoveredMovementPermissionTile();
|
||||
this->ui->statusBar->clearMessage();
|
||||
}
|
||||
|
||||
void Editor::onHoveredMetatileSelectionChanged(uint16_t metatileId) {
|
||||
map->hoveredMetatileSelectionChanged(metatileId);
|
||||
QString message = QString("Metatile: 0x%1")
|
||||
.arg(QString("%1").arg(metatileId, 3, 16, QChar('0')).toUpper());
|
||||
this->ui->statusBar->showMessage(message);
|
||||
}
|
||||
|
||||
void Editor::onHoveredMetatileSelectionCleared() {
|
||||
map->clearHoveredMetatileSelection();
|
||||
this->ui->statusBar->clearMessage();
|
||||
}
|
||||
|
||||
void Editor::onSelectedMetatilesChanged() {
|
||||
this->redrawCurrentMetatilesSelection();
|
||||
}
|
||||
|
||||
void Editor::onHoveredMapMetatileChanged(int x, int y) {
|
||||
int blockIndex = y * map->getWidth() + x;
|
||||
int tile = map->layout->blockdata->blocks->at(blockIndex).tile;
|
||||
this->ui->statusBar->showMessage(QString("X: %1, Y: %2, Metatile: 0x%3, Scale = %4x")
|
||||
.arg(x)
|
||||
.arg(y)
|
||||
.arg(QString("%1").arg(tile, 3, 16, QChar('0')).toUpper())
|
||||
.arg(QString::number(pow(map->scale_base, map->scale_exp))));
|
||||
}
|
||||
|
||||
void Editor::onHoveredMapMetatileCleared() {
|
||||
this->ui->statusBar->clearMessage();
|
||||
}
|
||||
|
||||
void Editor::onHoveredMapMovementPermissionChanged(int x, int y) {
|
||||
int blockIndex = y * map->getWidth() + x;
|
||||
uint16_t collision = map->layout->blockdata->blocks->at(blockIndex).collision;
|
||||
uint16_t elevation = map->layout->blockdata->blocks->at(blockIndex).elevation;
|
||||
QString message = QString("X: %1, Y: %2, %3")
|
||||
.arg(x)
|
||||
.arg(y)
|
||||
.arg(this->getMovementPermissionText(collision, elevation));
|
||||
this->ui->statusBar->showMessage(message);
|
||||
}
|
||||
|
||||
void Editor::onHoveredMapMovementPermissionCleared() {
|
||||
this->ui->statusBar->clearMessage();
|
||||
}
|
||||
|
||||
QString Editor::getMovementPermissionText(uint16_t collision, uint16_t elevation){
|
||||
QString message;
|
||||
if (collision == 0 && elevation == 0) {
|
||||
message = "Collision: Transition between elevations";
|
||||
} else if (collision == 0 && elevation == 15) {
|
||||
message = "Collision: Multi-Level (Bridge)";
|
||||
} else if (collision == 0 && elevation == 1) {
|
||||
message = "Collision: Surf";
|
||||
} else if (collision == 0) {
|
||||
message = QString("Collision: Passable, Elevation: %1").arg(elevation);
|
||||
} else {
|
||||
message = QString("Collision: Impassable, Elevation: %1").arg(elevation);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
void Editor::setConnectionsVisibility(bool visible) {
|
||||
for (QGraphicsPixmapItem* item : connection_items) {
|
||||
item->setVisible(visible);
|
||||
|
@ -418,6 +465,10 @@ void Editor::displayMap() {
|
|||
map_item = new MapPixmapItem(map, this);
|
||||
connect(map_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,MapPixmapItem*)),
|
||||
this, SLOT(mouseEvent_map(QGraphicsSceneMouseEvent*,MapPixmapItem*)));
|
||||
connect(map_item, SIGNAL(hoveredMapMetatileChanged(int, int)),
|
||||
this, SLOT(onHoveredMapMetatileChanged(int, int)));
|
||||
connect(map_item, SIGNAL(hoveredMapMetatileCleared()),
|
||||
this, SLOT(onHoveredMapMetatileCleared()));
|
||||
|
||||
map_item->draw(true);
|
||||
scene->addItem(map_item);
|
||||
|
@ -429,6 +480,10 @@ void Editor::displayMap() {
|
|||
collision_item = new CollisionPixmapItem(map, this);
|
||||
connect(collision_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)),
|
||||
this, SLOT(mouseEvent_collision(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)));
|
||||
connect(collision_item, SIGNAL(hoveredMapMovementPermissionChanged(int, int)),
|
||||
this, SLOT(onHoveredMapMovementPermissionChanged(int, int)));
|
||||
connect(collision_item, SIGNAL(hoveredMapMovementPermissionCleared()),
|
||||
this, SLOT(onHoveredMapMovementPermissionCleared()));
|
||||
|
||||
collision_item->draw(true);
|
||||
scene->addItem(collision_item);
|
||||
|
@ -1044,7 +1099,7 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
|||
// Paint onto the map.
|
||||
bool smartPathsEnabled = event->modifiers() & Qt::ShiftModifier;
|
||||
QPoint selectionDimensions = editor->metatile_selector_item->getSelectionDimensions();
|
||||
if ((map->smart_paths_enabled || smartPathsEnabled) && selectionDimensions.x() == 3 && selectionDimensions.y() == 3) {
|
||||
if ((editor->smart_paths_enabled || smartPathsEnabled) && selectionDimensions.x() == 3 && selectionDimensions.y() == 3) {
|
||||
paintSmartPath(x, y);
|
||||
} else {
|
||||
paintNormal(x, y);
|
||||
|
@ -1104,13 +1159,13 @@ void MapPixmapItem::paintNormal(int x, int y) {
|
|||
|
||||
// Snap the selected position to the top-left of the block boundary.
|
||||
// This allows painting via dragging the mouse to tile the painted region.
|
||||
int xDiff = x - map->paint_tile_initial_x;
|
||||
int yDiff = y - map->paint_tile_initial_y;
|
||||
int xDiff = x - this->paint_tile_initial_x;
|
||||
int yDiff = y - this->paint_tile_initial_y;
|
||||
if (xDiff < 0 && xDiff % selectionDimensions.x() != 0) xDiff -= selectionDimensions.x();
|
||||
if (yDiff < 0 && yDiff % selectionDimensions.y() != 0) yDiff -= selectionDimensions.y();
|
||||
|
||||
x = map->paint_tile_initial_x + (xDiff / selectionDimensions.x()) * selectionDimensions.x();
|
||||
y = map->paint_tile_initial_y + (yDiff / selectionDimensions.y()) * selectionDimensions.y();
|
||||
x = this->paint_tile_initial_x + (xDiff / selectionDimensions.x()) * selectionDimensions.x();
|
||||
y = this->paint_tile_initial_y + (yDiff / selectionDimensions.y()) * selectionDimensions.y();
|
||||
|
||||
for (int i = 0; i < selectionDimensions.x() && i + x < map->getWidth(); i++)
|
||||
for (int j = 0; j < selectionDimensions.y() && j + y < map->getHeight(); j++) {
|
||||
|
@ -1269,7 +1324,7 @@ void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
|||
int tile = selectedMetatiles->first();
|
||||
if (block && block->tile != tile) {
|
||||
bool smartPathsEnabled = event->modifiers() & Qt::ShiftModifier;
|
||||
if ((map->smart_paths_enabled || smartPathsEnabled) && selectionDimensions.x() == 3 && selectionDimensions.y() == 3)
|
||||
if ((editor->smart_paths_enabled || smartPathsEnabled) && selectionDimensions.x() == 3 && selectionDimensions.y() == 3)
|
||||
this->_floodFillSmartPath(x, y);
|
||||
else
|
||||
this->_floodFill(x, y);
|
||||
|
@ -1477,32 +1532,16 @@ void MapPixmapItem::draw(bool ignoreCache) {
|
|||
}
|
||||
}
|
||||
|
||||
void MapPixmapItem::updateCurHoveredTile(QPointF pos) {
|
||||
int x = static_cast<int>(pos.x()) / 16;
|
||||
int y = static_cast<int>(pos.y()) / 16;
|
||||
int blockIndex = y * map->getWidth() + x;
|
||||
if (x < 0 || x >= map->getWidth() || y < 0 || y >= map->getHeight()) {
|
||||
map->clearHoveredTile();
|
||||
} else {
|
||||
if (editor->current_view == editor->map_item) {
|
||||
int tile = map->layout->blockdata->blocks->at(blockIndex).tile;
|
||||
map->hoveredTileChanged(x, y, tile);
|
||||
} else if (editor->current_view == editor->collision_item) {
|
||||
int collision = map->layout->blockdata->blocks->at(blockIndex).collision;
|
||||
int elevation = map->layout->blockdata->blocks->at(blockIndex).elevation;
|
||||
map->hoveredMovementPermissionTileChanged(collision, elevation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MapPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
updateCurHoveredTile(event->pos());
|
||||
int x = static_cast<int>(event->pos().x()) / 16;
|
||||
int y = static_cast<int>(event->pos().y()) / 16;
|
||||
emit this->hoveredMapMetatileChanged(x, y);
|
||||
if (editor->ui->actionBetter_Cursors->isChecked()){
|
||||
setCursor(editor->cursor);
|
||||
}
|
||||
}
|
||||
void MapPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||
map->clearHoveredTile();
|
||||
emit this->hoveredMapMetatileCleared();
|
||||
if (editor->ui->actionBetter_Cursors->isChecked()){
|
||||
unsetCursor();
|
||||
}
|
||||
|
@ -1511,18 +1550,34 @@ void MapPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
|||
QPointF pos = event->pos();
|
||||
int x = static_cast<int>(pos.x()) / 16;
|
||||
int y = static_cast<int>(pos.y()) / 16;
|
||||
map->paint_tile_initial_x = x;
|
||||
map->paint_tile_initial_y = y;
|
||||
this->paint_tile_initial_x = x;
|
||||
this->paint_tile_initial_y = y;
|
||||
emit mouseEvent(event, this);
|
||||
}
|
||||
void MapPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||
updateCurHoveredTile(event->pos());
|
||||
int x = static_cast<int>(event->pos().x()) / 16;
|
||||
int y = static_cast<int>(event->pos().y()) / 16;
|
||||
emit this->hoveredMapMetatileChanged(x, y);
|
||||
emit mouseEvent(event, this);
|
||||
}
|
||||
void MapPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||
emit mouseEvent(event, this);
|
||||
}
|
||||
|
||||
void CollisionPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
int x = static_cast<int>(event->pos().x()) / 16;
|
||||
int y = static_cast<int>(event->pos().y()) / 16;
|
||||
emit this->hoveredMapMovementPermissionChanged(x, y);
|
||||
if (editor->ui->actionBetter_Cursors->isChecked()){
|
||||
setCursor(editor->cursor);
|
||||
}
|
||||
}
|
||||
void CollisionPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||
emit this->hoveredMapMovementPermissionCleared();
|
||||
if (editor->ui->actionBetter_Cursors->isChecked()){
|
||||
unsetCursor();
|
||||
}
|
||||
}
|
||||
void CollisionPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||
emit mouseEvent(event, this);
|
||||
}
|
||||
|
|
15
editor.h
15
editor.h
|
@ -108,6 +108,7 @@ public:
|
|||
QString map_edit_mode;
|
||||
QString prev_edit_mode;
|
||||
QCursor cursor;
|
||||
bool smart_paths_enabled = false;
|
||||
|
||||
void objectsView_onMousePress(QMouseEvent *event);
|
||||
void objectsView_onMouseMove(QMouseEvent *event);
|
||||
|
@ -136,6 +137,7 @@ private:
|
|||
Event* createNewSignEvent();
|
||||
Event* createNewHiddenItemEvent();
|
||||
Event* createNewSecretBaseEvent();
|
||||
QString getMovementPermissionText(uint16_t collision, uint16_t elevation);
|
||||
|
||||
private slots:
|
||||
void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
|
||||
|
@ -149,6 +151,10 @@ private slots:
|
|||
void onHoveredMovementPermissionCleared();
|
||||
void onHoveredMetatileSelectionChanged(uint16_t);
|
||||
void onHoveredMetatileSelectionCleared();
|
||||
void onHoveredMapMetatileChanged(int, int);
|
||||
void onHoveredMapMetatileCleared();
|
||||
void onHoveredMapMovementPermissionChanged(int, int);
|
||||
void onHoveredMapMovementPermissionCleared();
|
||||
void onSelectedMetatilesChanged();
|
||||
|
||||
signals:
|
||||
|
@ -267,6 +273,8 @@ public:
|
|||
}
|
||||
bool active;
|
||||
bool right_click;
|
||||
int paint_tile_initial_x;
|
||||
int paint_tile_initial_y;
|
||||
QPoint selection_origin;
|
||||
QList<QPoint> selection;
|
||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||
|
@ -280,13 +288,14 @@ public:
|
|||
void updateMetatileSelection(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
private:
|
||||
void updateCurHoveredTile(QPointF pos);
|
||||
void paintNormal(int x, int y);
|
||||
void paintSmartPath(int x, int y);
|
||||
static QList<int> smartPathTable;
|
||||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
||||
void hoveredMapMetatileChanged(int x, int y);
|
||||
void hoveredMapMetatileCleared();
|
||||
|
||||
protected:
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
||||
|
@ -311,8 +320,12 @@ public:
|
|||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *);
|
||||
void hoveredMapMovementPermissionChanged(int, int);
|
||||
void hoveredMapMovementPermissionCleared();
|
||||
|
||||
protected:
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
|
|
|
@ -84,16 +84,12 @@ void MainWindow::openRecentProject() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::setStatusBarMessage(QString message, int timeout/* = 0*/) {
|
||||
statusBar()->showMessage(message, timeout);
|
||||
}
|
||||
|
||||
void MainWindow::openProject(QString dir) {
|
||||
if (dir.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setStatusBarMessage(QString("Opening project %1").arg(dir));
|
||||
this->statusBar()->showMessage(QString("Opening project %1").arg(dir));
|
||||
|
||||
bool already_open = (
|
||||
(editor && editor != nullptr)
|
||||
|
@ -113,7 +109,7 @@ void MainWindow::openProject(QString dir) {
|
|||
populateMapList();
|
||||
}
|
||||
|
||||
setStatusBarMessage(QString("Opened project %1").arg(dir));
|
||||
this->statusBar()->showMessage(QString("Opened project %1").arg(dir));
|
||||
}
|
||||
|
||||
QString MainWindow::getDefaultMap() {
|
||||
|
@ -184,7 +180,6 @@ void MainWindow::setMap(QString map_name) {
|
|||
|
||||
connect(editor->map, SIGNAL(mapChanged(Map*)), this, SLOT(onMapChanged(Map *)));
|
||||
connect(editor->map, SIGNAL(mapNeedsRedrawing()), this, SLOT(onMapNeedsRedrawing()));
|
||||
connect(editor->map, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusBarMessage(QString)));
|
||||
|
||||
setRecentMap(map_name);
|
||||
updateMapList();
|
||||
|
@ -1188,7 +1183,7 @@ void MainWindow::on_pushButton_clicked()
|
|||
|
||||
void MainWindow::on_checkBox_smartPaths_stateChanged(int selected)
|
||||
{
|
||||
editor->map->smart_paths_enabled = selected == Qt::Checked;
|
||||
editor->smart_paths_enabled = selected == Qt::Checked;
|
||||
}
|
||||
|
||||
void MainWindow::on_checkBox_ToggleBorder_stateChanged(int selected)
|
||||
|
|
|
@ -25,9 +25,6 @@ public:
|
|||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void setStatusBarMessage(QString message, int timeout = 0);
|
||||
|
||||
private slots:
|
||||
void on_action_Open_Project_triggered();
|
||||
void on_mapList_activated(const QModelIndex &index);
|
||||
|
|
83
map.cpp
83
map.cpp
|
@ -61,22 +61,6 @@ int Map::getHeight() {
|
|||
return layout->height.toInt(nullptr, 0);
|
||||
}
|
||||
|
||||
uint16_t Map::getSelectedBlockIndex(int index) {
|
||||
if (index < layout->tileset_primary->metatiles->length()) {
|
||||
return static_cast<uint16_t>(index);
|
||||
} else {
|
||||
return static_cast<uint16_t>(Project::getNumMetatilesPrimary() + index - layout->tileset_primary->metatiles->length());
|
||||
}
|
||||
}
|
||||
|
||||
int Map::getDisplayedBlockIndex(int index) {
|
||||
if (index < layout->tileset_primary->metatiles->length()) {
|
||||
return index;
|
||||
} else {
|
||||
return index - Project::getNumMetatilesPrimary() + layout->tileset_primary->metatiles->length();
|
||||
}
|
||||
}
|
||||
|
||||
bool Map::blockChanged(int i, Blockdata *cache) {
|
||||
if (!cache)
|
||||
return true;
|
||||
|
@ -276,22 +260,6 @@ QPixmap Map::renderConnection(MapConnection connection) {
|
|||
return QPixmap::fromImage(connection_image);
|
||||
}
|
||||
|
||||
void Map::drawSelection(int i, int w, int selectionWidth, int selectionHeight, QPainter *painter, int gridWidth) {
|
||||
int x = i % w;
|
||||
int y = i / w;
|
||||
painter->save();
|
||||
|
||||
QColor penColor = QColor(0xff, 0xff, 0xff);
|
||||
painter->setPen(penColor);
|
||||
int rectWidth = selectionWidth * gridWidth;
|
||||
int rectHeight = selectionHeight * gridWidth;
|
||||
painter->drawRect(x * gridWidth, y * gridWidth, rectWidth - 1, rectHeight -1);
|
||||
painter->setPen(QColor(0, 0, 0));
|
||||
painter->drawRect(x * gridWidth - 1, y * gridWidth - 1, rectWidth + 1, rectHeight + 1);
|
||||
painter->drawRect(x * gridWidth + 1, y * gridWidth + 1, rectWidth - 3, rectHeight - 3);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void Map::setNewDimensionsBlockdata(int newWidth, int newHeight) {
|
||||
int oldWidth = getWidth();
|
||||
int oldHeight = getHeight();
|
||||
|
@ -377,7 +345,7 @@ void Map::_floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_
|
|||
|
||||
|
||||
void Map::undo() {
|
||||
HistoryItem *commit = history.back();
|
||||
HistoryItem *commit = metatileHistory.back();
|
||||
if (!commit)
|
||||
return;
|
||||
|
||||
|
@ -394,7 +362,7 @@ void Map::undo() {
|
|||
}
|
||||
|
||||
void Map::redo() {
|
||||
HistoryItem *commit = history.next();
|
||||
HistoryItem *commit = metatileHistory.next();
|
||||
if (!commit)
|
||||
return;
|
||||
|
||||
|
@ -412,14 +380,14 @@ void Map::redo() {
|
|||
|
||||
void Map::commit() {
|
||||
if (layout->blockdata) {
|
||||
HistoryItem *item = history.current();
|
||||
HistoryItem *item = metatileHistory.current();
|
||||
bool atCurrentHistory = item
|
||||
&& layout->blockdata->equals(item->metatiles)
|
||||
&& this->getWidth() == item->layoutWidth
|
||||
&& this->getHeight() == item->layoutHeight;
|
||||
if (!atCurrentHistory) {
|
||||
HistoryItem *commit = new HistoryItem(layout->blockdata->copy(), this->getWidth(), this->getHeight());
|
||||
history.push(commit);
|
||||
metatileHistory.push(commit);
|
||||
emit mapChanged(this);
|
||||
}
|
||||
}
|
||||
|
@ -460,46 +428,5 @@ void Map::addEvent(Event *event) {
|
|||
}
|
||||
|
||||
bool Map::hasUnsavedChanges() {
|
||||
return !history.isSaved() || !isPersistedToFile || layout->has_unsaved_changes;
|
||||
}
|
||||
|
||||
void Map::hoveredTileChanged(int x, int y, int block) {
|
||||
emit statusBarMessage(QString("X: %1, Y: %2, Metatile: 0x%3, Scale = %4x")
|
||||
.arg(x)
|
||||
.arg(y)
|
||||
.arg(QString("%1").arg(block, 3, 16, QChar('0')).toUpper())
|
||||
.arg(QString::number(pow(this->scale_base,this->scale_exp))));
|
||||
}
|
||||
|
||||
void Map::clearHoveredTile() {
|
||||
emit statusBarMessage(QString(""));
|
||||
}
|
||||
|
||||
void Map::hoveredMetatileSelectionChanged(uint16_t metatileId) {
|
||||
emit statusBarMessage(QString("Metatile: 0x%1")
|
||||
.arg(QString("%1").arg(metatileId, 3, 16, QChar('0')).toUpper()));
|
||||
}
|
||||
|
||||
void Map::clearHoveredMetatileSelection() {
|
||||
emit statusBarMessage(QString(""));
|
||||
}
|
||||
|
||||
void Map::hoveredMovementPermissionTileChanged(int collision, int elevation) {
|
||||
QString message;
|
||||
if (collision == 0 && elevation == 0) {
|
||||
message = "Collision: Transition between elevations";
|
||||
} else if (collision == 0 && elevation == 15) {
|
||||
message = "Collision: Multi-Level (Bridge)";
|
||||
} else if (collision == 0 && elevation == 1) {
|
||||
message = "Collision: Surf";
|
||||
} else if (collision == 0) {
|
||||
message = QString("Collision: Passable, Elevation: %1").arg(elevation);
|
||||
} else {
|
||||
message = QString("Collision: Impassable, Elevation: %1").arg(elevation);
|
||||
}
|
||||
emit statusBarMessage(message);
|
||||
}
|
||||
|
||||
void Map::clearHoveredMovementPermissionTile() {
|
||||
emit statusBarMessage(QString(""));
|
||||
return !metatileHistory.isSaved() || !isPersistedToFile || layout->has_unsaved_changes;
|
||||
}
|
||||
|
|
53
map.h
53
map.h
|
@ -42,10 +42,14 @@ public:
|
|||
MapLayout *layout;
|
||||
int scale_exp = 0;
|
||||
double scale_base = sqrt(2); // adjust scale factor with this
|
||||
|
||||
bool isPersistedToFile = true;
|
||||
|
||||
public:
|
||||
QImage collision_image;
|
||||
QPixmap collision_pixmap;
|
||||
QImage image;
|
||||
QPixmap pixmap;
|
||||
History<HistoryItem*> metatileHistory;
|
||||
QMap<QString, QList<Event*>> events;
|
||||
QList<MapConnection*> connections;
|
||||
void setName(QString mapName);
|
||||
static QString mapConstantFromName(QString mapName);
|
||||
static QString objectEventsLabelFromName(QString mapName);
|
||||
|
@ -54,65 +58,34 @@ public:
|
|||
static QString bgEventsLabelFromName(QString mapName);
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
uint16_t getSelectedBlockIndex(int);
|
||||
int getDisplayedBlockIndex(int);
|
||||
QPixmap render(bool ignoreCache);
|
||||
QPixmap renderCollision(bool ignoreCache);
|
||||
|
||||
QImage collision_image;
|
||||
QPixmap collision_pixmap;
|
||||
|
||||
void drawSelection(int i, int w, int selectionWidth, int selectionHeight, QPainter *painter, int gridWidth);
|
||||
|
||||
bool blockChanged(int, Blockdata*);
|
||||
void cacheBlockdata();
|
||||
void cacheCollision();
|
||||
QImage image;
|
||||
QPixmap pixmap;
|
||||
QList<QImage> metatile_images;
|
||||
bool smart_paths_enabled = false;
|
||||
int paint_tile_initial_x;
|
||||
int paint_tile_initial_y;
|
||||
|
||||
Block *getBlock(int x, int y);
|
||||
void setBlock(int x, int y, Block block);
|
||||
void _setBlock(int x, int y, Block block);
|
||||
|
||||
void floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation);
|
||||
void _floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation);
|
||||
|
||||
History<HistoryItem*> history;
|
||||
void undo();
|
||||
void redo();
|
||||
void commit();
|
||||
|
||||
QList<Event*> getAllEvents();
|
||||
void removeEvent(Event *event);
|
||||
void addEvent(Event *event);
|
||||
QMap<QString, QList<Event*>> events;
|
||||
|
||||
QList<MapConnection*> connections;
|
||||
void removeEvent(Event*);
|
||||
void addEvent(Event*);
|
||||
QPixmap renderConnection(MapConnection);
|
||||
void setNewDimensionsBlockdata(int newWidth, int newHeight);
|
||||
void setDimensions(int newWidth, int newHeight, bool setNewBlockData = true);
|
||||
|
||||
QPixmap renderBorder();
|
||||
void setDimensions(int newWidth, int newHeight, bool setNewBlockData = true);
|
||||
void cacheBorder();
|
||||
|
||||
bool hasUnsavedChanges();
|
||||
void hoveredTileChanged(int x, int y, int block);
|
||||
void clearHoveredTile();
|
||||
void hoveredMetatileSelectionChanged(uint16_t);
|
||||
void clearHoveredMetatileSelection();
|
||||
void clearHoveredMovementPermissionTile();
|
||||
|
||||
private:
|
||||
void setNewDimensionsBlockdata(int newWidth, int newHeight);
|
||||
|
||||
signals:
|
||||
void mapChanged(Map *map);
|
||||
void mapNeedsRedrawing();
|
||||
void statusBarMessage(QString);
|
||||
|
||||
public slots:
|
||||
void hoveredMovementPermissionTileChanged(int collision, int elevation);
|
||||
};
|
||||
|
||||
#endif // MAP_H
|
||||
|
|
|
@ -69,7 +69,7 @@ Map* Project::loadMap(QString map_name) {
|
|||
readMapEvents(map);
|
||||
loadMapConnections(map);
|
||||
map->commit();
|
||||
map->history.save();
|
||||
map->metatileHistory.save();
|
||||
|
||||
map_cache->insert(map_name, map);
|
||||
return map;
|
||||
|
@ -650,7 +650,7 @@ void Project::saveMapBorder(Map *map) {
|
|||
void Project::saveBlockdata(Map* map) {
|
||||
QString path = QString("%1/%2").arg(root).arg(map->layout->blockdata_path);
|
||||
writeBlockdata(path, map->layout->blockdata);
|
||||
map->history.save();
|
||||
map->metatileHistory.save();
|
||||
}
|
||||
|
||||
void Project::writeBlockdata(QString path, Blockdata *blockdata) {
|
||||
|
@ -1053,7 +1053,7 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum) {
|
|||
setNewMapEvents(map);
|
||||
setNewMapConnections(map);
|
||||
map->commit();
|
||||
map->history.save();
|
||||
map->metatileHistory.save();
|
||||
map_cache->insert(mapName, map);
|
||||
|
||||
return map;
|
||||
|
|
Loading…
Reference in a new issue