Shift tool, shift+click for smart paths, middle button click for fill, and toggle border/connections visibility
This commit is contained in:
parent
6d19da8d88
commit
ab0eff8c20
7 changed files with 157 additions and 34 deletions
130
editor.cpp
130
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);
|
||||
|
|
2
editor.h
2
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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -231,7 +231,7 @@
|
|||
<item>
|
||||
<widget class="QToolButton" name="toolButton_Dropper">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Eye Dropper</p><p>Click to select a metatile or collision attribute.</p></body></html></string>
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dropper</string>
|
||||
|
@ -256,6 +256,23 @@
|
|||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<normaloff>:/icons/move.ico</normaloff>:/icons/move.ico</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_Shift">
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Shift</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<normaloff>:/icons/shift.ico</normaloff>:/icons/shift.ico</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
|
@ -265,7 +282,7 @@
|
|||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_smartPaths">
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">margin-left: 10px</string>
|
||||
|
@ -284,7 +301,17 @@
|
|||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Grid</string>
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_ToggleBorder">
|
||||
<property name="text">
|
||||
<string>Border</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -351,7 +378,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>429</width>
|
||||
<width>442</width>
|
||||
<height>620</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -734,7 +761,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>315</width>
|
||||
<width>302</width>
|
||||
<height>86</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -840,7 +867,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>365</width>
|
||||
<width>352</width>
|
||||
<height>405</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
BIN
resources/icons/shift.ico
Normal file
BIN
resources/icons/shift.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -20,5 +20,6 @@
|
|||
<file>icons/fill_color_cursor.ico</file>
|
||||
<file>icons/pencil_cursor.ico</file>
|
||||
<file>icons/pipette_cursor.ico</file>
|
||||
<file>icons/shift.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Loading…
Reference in a new issue