diff --git a/editor.cpp b/editor.cpp
index 8bafbb4d..17909121 100755
--- a/editor.cpp
+++ b/editor.cpp
@@ -50,7 +50,7 @@ void Editor::setEditingMap() {
map_item->draw();
map_item->setVisible(true);
map_item->setEnabled(true);
- setConnectionsVisibility(true);
+ setConnectionsVisibility(ui->checkBox_ToggleBorder->isChecked());
}
if (collision_item) {
collision_item->setVisible(false);
@@ -58,7 +58,7 @@ void Editor::setEditingMap() {
if (events_group) {
events_group->setVisible(false);
}
- setBorderItemsVisible(true);
+ setBorderItemsVisible(ui->checkBox_ToggleBorder->isChecked());
setConnectionItemsVisible(false);
}
@@ -68,7 +68,7 @@ void Editor::setEditingCollision() {
displayMapConnections();
collision_item->draw();
collision_item->setVisible(true);
- setConnectionsVisibility(true);
+ setConnectionsVisibility(ui->checkBox_ToggleBorder->isChecked());
}
if (map_item) {
map_item->setVisible(false);
@@ -76,7 +76,7 @@ void Editor::setEditingCollision() {
if (events_group) {
events_group->setVisible(false);
}
- setBorderItemsVisible(true);
+ setBorderItemsVisible(ui->checkBox_ToggleBorder->isChecked());
setConnectionItemsVisible(false);
}
@@ -88,12 +88,12 @@ void Editor::setEditingObjects() {
if (map_item) {
map_item->setVisible(true);
map_item->setEnabled(false);
- setConnectionsVisibility(true);
+ setConnectionsVisibility(ui->checkBox_ToggleBorder->isChecked());
}
if (collision_item) {
collision_item->setVisible(false);
}
- setBorderItemsVisible(true);
+ setBorderItemsVisible(ui->checkBox_ToggleBorder->isChecked());
setConnectionItemsVisible(false);
}
@@ -338,33 +338,54 @@ void Editor::setMap(QString map_name) {
}
void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item) {
- if (event->buttons() & Qt::RightButton) {
- item->updateMetatileSelection(event);
- } else {
- if (map_edit_mode == "paint") {
- item->paint(event);
- } else if (map_edit_mode == "fill") {
+ if (map_edit_mode == "paint") {
+ if (event->buttons() & Qt::RightButton) {
+ item->updateMetatileSelection(event);
+ } else if (event->buttons() & Qt::MiddleButton) {
item->floodFill(event);
- } else if (map_edit_mode == "pick") {
- item->pick(event);
- } else if (map_edit_mode == "select") {
- item->select(event);
+ } else {
+ item->paint(event);
}
+ } else if (map_edit_mode == "select") {
+ item->select(event);
+ } else if (map_edit_mode == "fill") {
+ if (event->buttons() & Qt::RightButton) {
+ item->updateMetatileSelection(event);
+ } else {
+ item->floodFill(event);
+ }
+ } else if (map_edit_mode == "pick") {
+
+ if (event->buttons() & Qt::RightButton) {
+ item->updateMetatileSelection(event);
+ } else {
+ item->pick(event);
+ }
+ } else if (map_edit_mode == "shift") {
+ item->shift(event);
}
}
void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item) {
- if (event->buttons() & Qt::RightButton) {
- item->updateMovementPermissionSelection(event);
- } else {
- if (map_edit_mode == "paint") {
- item->paint(event);
- } else if (map_edit_mode == "fill") {
+ if (map_edit_mode == "paint") {
+ if (event->buttons() & Qt::RightButton) {
+ item->updateMovementPermissionSelection(event);
+ } else if (event->buttons() & Qt::MiddleButton) {
item->floodFill(event);
- } else if (map_edit_mode == "pick") {
- item->pick(event);
- } else if (map_edit_mode == "select") {
- item->select(event);
+ } else {
+ item->paint(event);
}
+ } else if (map_edit_mode == "select") {
+ item->select(event);
+ } else if (map_edit_mode == "fill") {
+ if (event->buttons() & Qt::RightButton) {
+ item->pick(event);
+ } else {
+ item->floodFill(event);
+ }
+ } else if (map_edit_mode == "pick") {
+ item->pick(event);
+ } else if (map_edit_mode == "shift") {
+ item->shift(event);
}
}
@@ -861,6 +882,12 @@ void Editor::updateSecondaryTileset(QString tilesetLabel)
}
}
+void Editor::toggleBorderVisibility(bool visible)
+{
+ this->setBorderItemsVisible(visible);
+ this->setConnectionsVisibility(visible);
+}
+
void MetatilesPixmapItem::paintTileChanged(Map *map) {
draw();
}
@@ -1080,7 +1107,8 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
int y = (int)(pos.y()) / 16;
// Paint onto the map.
- if (map->smart_paths_enabled && map->selected_metatiles_width == 3 && map->selected_metatiles_height == 3) {
+ bool smartPathsEnabled = event->modifiers() & Qt::ShiftModifier;
+ if ((map->smart_paths_enabled || smartPathsEnabled) && map->selected_metatiles_width == 3 && map->selected_metatiles_height == 3) {
paintSmartPath(x, y);
} else {
paintNormal(x, y);
@@ -1091,6 +1119,51 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
}
}
+void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) {
+ if (map) {
+ if (event->type() == QEvent::GraphicsSceneMouseRelease) {
+ map->commit();
+ } else {
+ QPointF pos = event->pos();
+ int x = (int)(pos.x()) / 16;
+ int y = (int)(pos.y()) / 16;
+
+ if (event->type() == QEvent::GraphicsSceneMousePress) {
+ selection_origin = QPoint(x, y);
+ selection.clear();
+ } else if (event->type() == QEvent::GraphicsSceneMouseMove) {
+ if (x != selection_origin.x() || y != selection_origin.y()) {
+ int xDelta = x - selection_origin.x();
+ int yDelta = y - selection_origin.y();
+ Blockdata *backupBlockdata = map->layout->blockdata->copy();
+ for (int i = 0; i < map->getWidth(); i++)
+ for (int j = 0; j < map->getHeight(); j++) {
+ int srcX = i;
+ int srcY = j;
+ int destX = i + xDelta;
+ int destY = j + yDelta;
+ if (destX < 0)
+ do { destX += map->getWidth(); } while (destX < 0);
+ if (destY < 0)
+ do { destY += map->getHeight(); } while (destY < 0);
+ destX %= map->getWidth();
+ destY %= map->getHeight();
+
+ int blockIndex = j * map->getWidth() + i;
+ Block srcBlock = backupBlockdata->blocks->at(blockIndex);
+ map->_setBlock(destX, destY, srcBlock);
+ }
+
+ delete backupBlockdata;
+ selection_origin = QPoint(x, y);
+ selection.clear();
+ draw();
+ }
+ }
+ }
+ }
+}
+
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.
@@ -1260,7 +1333,8 @@ void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
Block *block = map->getBlock(x, y);
int tile = map->selected_metatiles->first();
if (block && block->tile != tile) {
- if (map->smart_paths_enabled && map->selected_metatiles_width == 3 && map->selected_metatiles_height == 3)
+ bool smartPathsEnabled = event->modifiers() & Qt::ShiftModifier;
+ if ((map->smart_paths_enabled || smartPathsEnabled) && map->selected_metatiles_width == 3 && map->selected_metatiles_height == 3)
this->_floodFillSmartPath(x, y);
else
this->_floodFill(x, y);
diff --git a/editor.h b/editor.h
index 4bfbfb23..ab09c365 100755
--- a/editor.h
+++ b/editor.h
@@ -67,6 +67,7 @@ public:
void setSelectedConnectionFromMap(QString mapName);
void updatePrimaryTileset(QString tilesetLabel);
void updateSecondaryTileset(QString tilesetLabel);
+ void toggleBorderVisibility(bool visible);
DraggablePixmapItem *addMapEvent(Event *event);
void selectMapEvent(DraggablePixmapItem *object);
@@ -273,6 +274,7 @@ public:
void _floodFillSmartPath(int initialX, int initialY);
virtual void pick(QGraphicsSceneMouseEvent*);
virtual void select(QGraphicsSceneMouseEvent*);
+ virtual void shift(QGraphicsSceneMouseEvent*);
virtual void draw(bool ignoreCache = false);
void updateMetatileSelection(QGraphicsSceneMouseEvent *event);
diff --git a/mainwindow.cpp b/mainwindow.cpp
index daf19ceb..7ffac85c 100755
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -993,12 +993,19 @@ void MainWindow::on_toolButton_Move_clicked()
checkToolButtons();
}
+void MainWindow::on_toolButton_Shift_clicked()
+{
+ editor->map_edit_mode = "shift";
+ checkToolButtons();
+}
+
void MainWindow::checkToolButtons() {
ui->toolButton_Paint->setChecked(editor->map_edit_mode == "paint");
ui->toolButton_Select->setChecked(editor->map_edit_mode == "select");
ui->toolButton_Fill->setChecked(editor->map_edit_mode == "fill");
ui->toolButton_Dropper->setChecked(editor->map_edit_mode == "pick");
ui->toolButton_Move->setChecked(editor->map_edit_mode == "move");
+ ui->toolButton_Shift->setChecked(editor->map_edit_mode == "shift");
}
void MainWindow::toggleEditModeMove() {
@@ -1011,6 +1018,8 @@ void MainWindow::toggleEditModeMove() {
on_toolButton_Dropper_clicked();
} else if (editor->prev_edit_mode == "select") {
on_toolButton_Select_clicked();
+ } else if (editor->prev_edit_mode == "shift") {
+ on_toolButton_Shift_clicked();
}
}
else {
@@ -1151,3 +1160,9 @@ void MainWindow::on_checkBox_smartPaths_stateChanged(int selected)
{
editor->map->smart_paths_enabled = selected == Qt::Checked;
}
+
+void MainWindow::on_checkBox_ToggleBorder_stateChanged(int selected)
+{
+ bool visible = selected != 0;
+ editor->toggleBorderVisibility(visible);
+}
diff --git a/mainwindow.h b/mainwindow.h
index b2c74610..a9f9bf99 100755
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -81,6 +81,8 @@ private slots:
void on_toolButton_Move_clicked();
+ void on_toolButton_Shift_clicked();
+
void onOpenMapListContextMenu(const QPoint &point);
void onAddNewMapToGroupClick(QAction* triggeredAction);
void onTilesetChanged(QString);
@@ -112,6 +114,8 @@ private slots:
void on_checkBox_Visibility_clicked(bool checked);
+ void on_checkBox_ToggleBorder_stateChanged(int arg1);
+
private:
Ui::MainWindow *ui;
QStandardItemModel *mapListModel;
diff --git a/mainwindow.ui b/mainwindow.ui
index 09e9f9d1..6b4ce23d 100755
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -231,7 +231,7 @@
-
- <html><head/><body><p>Eye Dropper</p><p>Click to select a metatile or collision attribute.</p></body></html>
+ <html><head/><body><p>Eye Dropper</p><p><span style=" font-weight:600;">Click</span> to select a metatile or collision attribute.</p></body></html>
Dropper
@@ -256,6 +256,23 @@
:/icons/move.ico:/icons/move.ico
+
+
+ true
+
+
+
+ -
+
+
+ <html><head/><body><p>Map Shift</p><p><span style=" font-weight:600;">Click and drag</span> on the map to shift the positions all metatiles at once. This is useful after resizing a map.</p></body></html>
+
+
+ Shift
+
+
+
+ :/icons/shift.ico:/icons/shift.ico
true
@@ -265,7 +282,7 @@
-
- <html><head/><body><p>Smart-path mode allows easier drawing of paths. If a 3x3 metatile block is selcted in the right panel, then smart path mode will automatically form a pathway using those selected blocks.</p><p>When smart-path mode is <span style=" font-weight:600;">not</span> enabled, clicking and dragging a selection will tile it in a grid.</p></body></html>
+ <html><head/><body><p>Smart-path mode allows easier drawing of paths. If a 3x3 metatile block is selcted in the right panel, then smart path mode will automatically form a pathway using those selected blocks.</p><p>When smart-path mode is <span style=" font-weight:600;">not</span> enabled, clicking and dragging a selection will tile it in a grid.</p><p>Hold down the <span style=" font-weight:600;">shift</span> key while editing to quickly enable smart-path mode.</p></body></html>
margin-left: 10px
@@ -284,7 +301,17 @@
- Show Grid
+ Grid
+
+
+
+ -
+
+
+ Border
+
+
+ true
@@ -351,7 +378,7 @@
0
0
- 429
+ 442
620
@@ -734,7 +761,7 @@
0
0
- 315
+ 302
86
@@ -840,7 +867,7 @@
0
0
- 365
+ 352
405
diff --git a/resources/icons/shift.ico b/resources/icons/shift.ico
new file mode 100644
index 00000000..dab33a4e
Binary files /dev/null and b/resources/icons/shift.ico differ
diff --git a/resources/images.qrc b/resources/images.qrc
index fcee557f..2c0cf39d 100755
--- a/resources/images.qrc
+++ b/resources/images.qrc
@@ -20,5 +20,6 @@
icons/fill_color_cursor.ico
icons/pencil_cursor.ico
icons/pipette_cursor.ico
+ icons/shift.ico