Merge pull request #316 from BigBahss/better-map-zoom
Focus map zooming on the cursor
This commit is contained in:
commit
530ff4ce88
6 changed files with 199 additions and 348 deletions
|
@ -25,6 +25,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
|||
- Fix bug preventing the status bar from updating the current position while dragging events.
|
||||
- Fix porymap icon not showing on window or panel on Linux.
|
||||
- The main window can now be resized to fit on lower resolution displays.
|
||||
- Zooming the map in/out will now focus on the cursor.
|
||||
|
||||
## [4.3.1] - 2020-07-17
|
||||
### Added
|
||||
|
|
|
@ -344,117 +344,37 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<widget class="GraphicsView" name="graphicsView_Map">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
<property name="mouseTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="dragMode">
|
||||
<enum>QGraphicsView::NoDrag</enum>
|
||||
</property>
|
||||
<property name="transformationAnchor">
|
||||
<enum>QGraphicsView::AnchorUnderMouse</enum>
|
||||
</property>
|
||||
<property name="resizeAnchor">
|
||||
<enum>QGraphicsView::AnchorUnderMouse</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>543</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>166</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="GraphicsView" name="graphicsView_Map">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="dragMode">
|
||||
<enum>QGraphicsView::NoDrag</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>166</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -2197,7 +2117,7 @@
|
|||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QFrame" name="horizontalFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
|
@ -2321,7 +2241,41 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QGraphicsView" name="graphicsView_Connections">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="dragMode">
|
||||
<enum>QGraphicsView::NoDrag</enum>
|
||||
</property>
|
||||
<property name="transformationAnchor">
|
||||
<enum>QGraphicsView::AnchorUnderMouse</enum>
|
||||
</property>
|
||||
<property name="resizeAnchor">
|
||||
<enum>QGraphicsView::AnchorUnderMouse</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QFrame" name="horizontalFrame2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
|
@ -2437,200 +2391,83 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QFrame" name="gridFrame1">
|
||||
<item row="5" column="0">
|
||||
<widget class="QFrame" name="horizontalFrame3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_13">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Dive Map</string>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>118</width>
|
||||
<height>118</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_14">
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGraphicsView" name="graphicsView_Connections">
|
||||
<property name="backgroundBrush">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="horizontalFrame3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item>
|
||||
<widget class="NoScrollComboBox" name="comboBox_DiveMap">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Destination map name when using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html></string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Dive Map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NoScrollComboBox" name="comboBox_DiveMap">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Destination map name when using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Emerge Map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NoScrollComboBox" name="comboBox_EmergeMap">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Destination map name when emerging using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_10">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Emerge Map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NoScrollComboBox" name="comboBox_EmergeMap">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Destination map name when emerging using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_10">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
void displayMapBorder();
|
||||
void displayMapGrid();
|
||||
void displayWildMonTables();
|
||||
void maskNonVisibleConnectionTiles();
|
||||
|
||||
void updateMapBorder();
|
||||
void updateMapConnections();
|
||||
|
@ -109,6 +110,7 @@ public:
|
|||
ConnectionPixmapItem* selected_connection_item = nullptr;
|
||||
QList<QGraphicsPixmapItem*> connection_items;
|
||||
QList<ConnectionPixmapItem*> connection_edit_items;
|
||||
QGraphicsPathItem *connection_mask = nullptr;
|
||||
CollisionPixmapItem *collision_item = nullptr;
|
||||
QGraphicsItemGroup *events_group = nullptr;
|
||||
QList<QGraphicsPixmapItem*> borderItems;
|
||||
|
@ -148,6 +150,7 @@ public:
|
|||
bool selectingEvent = false;
|
||||
|
||||
void shouldReselectEvents();
|
||||
void scaleMapView(int);
|
||||
|
||||
private:
|
||||
void setConnectionItemsVisible(bool);
|
||||
|
@ -198,6 +201,7 @@ private slots:
|
|||
void onHoveredMapMovementPermissionChanged(int, int);
|
||||
void onHoveredMapMovementPermissionCleared();
|
||||
void onSelectedMetatilesChanged();
|
||||
void onWheelZoom(int);
|
||||
|
||||
signals:
|
||||
void objectsChanged();
|
||||
|
@ -206,7 +210,6 @@ signals:
|
|||
void wildMonDataChanged();
|
||||
void warpEventDoubleClicked(QString mapName, QString warpNum);
|
||||
void currentMetatilesSelectionChanged();
|
||||
void wheelZoom(int delta);
|
||||
};
|
||||
|
||||
#endif // EDITOR_H
|
||||
|
|
|
@ -109,11 +109,6 @@ public:
|
|||
Q_INVOKABLE QList<float> getMetatileLayerOpacity();
|
||||
Q_INVOKABLE void setMetatileLayerOpacity(QList<float> order);
|
||||
|
||||
|
||||
public slots:
|
||||
void scaleMapView(int);
|
||||
void onWheelZoom(int);
|
||||
|
||||
private slots:
|
||||
void on_action_Open_Project_triggered();
|
||||
void on_action_Reload_Project_triggered();
|
||||
|
|
|
@ -759,11 +759,13 @@ void Editor::updateCurrentConnectionDirection(QString curDirection) {
|
|||
QString originalDirection = selected_connection_item->connection->direction;
|
||||
setCurrentConnectionDirection(curDirection);
|
||||
updateMirroredConnectionDirection(selected_connection_item->connection, originalDirection);
|
||||
maskNonVisibleConnectionTiles();
|
||||
}
|
||||
|
||||
void Editor::onConnectionMoved(MapConnection* connection) {
|
||||
updateMirroredConnectionOffset(connection);
|
||||
onConnectionOffsetChanged(connection->offset.toInt());
|
||||
maskNonVisibleConnectionTiles();
|
||||
}
|
||||
|
||||
void Editor::onConnectionOffsetChanged(int newOffset) {
|
||||
|
@ -887,6 +889,27 @@ void Editor::onSelectedMetatilesChanged() {
|
|||
this->redrawCurrentMetatilesSelection();
|
||||
}
|
||||
|
||||
void Editor::onWheelZoom(int s) {
|
||||
// Don't zoom the map when the user accidentally scrolls while performing a magic fill. (ctrl + middle button click)
|
||||
if (!(QApplication::mouseButtons() & Qt::MiddleButton)) {
|
||||
scaleMapView(s);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::scaleMapView(int s) {
|
||||
if ((scale_exp + s) <= 5 && (scale_exp + s) >= -2) // sane limits
|
||||
{
|
||||
if (s == 0)
|
||||
scale_exp = 0;
|
||||
else
|
||||
scale_exp += s;
|
||||
|
||||
double sfactor = pow(scale_base, s);
|
||||
ui->graphicsView_Map->scale(sfactor, sfactor);
|
||||
ui->graphicsView_Connections->scale(sfactor, sfactor);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::onHoveredMapMetatileChanged(int x, int y) {
|
||||
this->playerViewRect->updateLocation(x, y);
|
||||
this->cursorMapTileRect->updateLocation(x, y);
|
||||
|
@ -1209,7 +1232,7 @@ bool Editor::displayMap() {
|
|||
scene = new QGraphicsScene;
|
||||
MapSceneEventFilter *filter = new MapSceneEventFilter();
|
||||
scene->installEventFilter(filter);
|
||||
connect(filter, &MapSceneEventFilter::wheelZoom, this, &Editor::wheelZoom);
|
||||
connect(filter, &MapSceneEventFilter::wheelZoom, this, &Editor::onWheelZoom);
|
||||
}
|
||||
|
||||
if (map_item && scene) {
|
||||
|
@ -1437,6 +1460,8 @@ void Editor::displayMapConnections() {
|
|||
if (!connection_edit_items.empty()) {
|
||||
onConnectionItemSelected(connection_edit_items.first());
|
||||
}
|
||||
|
||||
maskNonVisibleConnectionTiles();
|
||||
}
|
||||
|
||||
void Editor::createConnectionItem(MapConnection* connection, bool hide) {
|
||||
|
@ -1481,6 +1506,31 @@ void Editor::createConnectionItem(MapConnection* connection, bool hide) {
|
|||
connection_edit_items.append(connection_edit_item);
|
||||
}
|
||||
|
||||
// Hides connected map tiles that cannot be seen from the current map (beyond BORDER_DISTANCE).
|
||||
void Editor::maskNonVisibleConnectionTiles() {
|
||||
if (connection_mask) {
|
||||
if (connection_mask->scene()) {
|
||||
connection_mask->scene()->removeItem(connection_mask);
|
||||
}
|
||||
delete connection_mask;
|
||||
}
|
||||
|
||||
QPainterPath mask;
|
||||
mask.addRect(scene->itemsBoundingRect().toRect());
|
||||
mask.addRect(
|
||||
-BORDER_DISTANCE * 16,
|
||||
-BORDER_DISTANCE * 16,
|
||||
(map->getWidth() + BORDER_DISTANCE * 2) * 16,
|
||||
(map->getHeight() + BORDER_DISTANCE * 2) * 16
|
||||
);
|
||||
|
||||
// Mask the tiles with the current theme's background color.
|
||||
QPen pen(ui->graphicsView_Map->palette().color(QPalette::Active, QPalette::Base));
|
||||
QBrush brush(ui->graphicsView_Map->palette().color(QPalette::Active, QPalette::Base));
|
||||
|
||||
connection_mask = scene->addPath(mask, pen, brush);
|
||||
}
|
||||
|
||||
void Editor::displayMapBorder() {
|
||||
for (QGraphicsPixmapItem* item : borderItems) {
|
||||
if (item->scene()) {
|
||||
|
@ -1527,6 +1577,8 @@ void Editor::updateMapConnections() {
|
|||
connection_edit_items[i]->basePixmap = pixmap;
|
||||
connection_edit_items[i]->setPixmap(pixmap);
|
||||
}
|
||||
|
||||
maskNonVisibleConnectionTiles();
|
||||
}
|
||||
|
||||
int Editor::getBorderDrawDistance(int dimension) {
|
||||
|
@ -1583,6 +1635,7 @@ void Editor::updateConnectionOffset(int offset) {
|
|||
}
|
||||
selected_connection_item->blockSignals(false);
|
||||
updateMirroredConnectionOffset(selected_connection_item->connection);
|
||||
maskNonVisibleConnectionTiles();
|
||||
}
|
||||
|
||||
void Editor::setConnectionMap(QString mapName) {
|
||||
|
@ -1603,6 +1656,7 @@ void Editor::setConnectionMap(QString mapName) {
|
|||
selected_connection_item->connection->map_name = mapName;
|
||||
setCurrentConnectionDirection(selected_connection_item->connection->direction);
|
||||
updateMirroredConnectionMap(selected_connection_item->connection, originalMapName);
|
||||
maskNonVisibleConnectionTiles();
|
||||
}
|
||||
|
||||
void Editor::addNewConnection() {
|
||||
|
|
|
@ -164,7 +164,6 @@ void MainWindow::initEditor() {
|
|||
connect(this->editor, SIGNAL(warpEventDoubleClicked(QString,QString)), this, SLOT(openWarpMap(QString,QString)));
|
||||
connect(this->editor, SIGNAL(currentMetatilesSelectionChanged()), this, SLOT(currentMetatilesSelectionChanged()));
|
||||
connect(this->editor, SIGNAL(wildMonDataChanged()), this, SLOT(onWildMonDataChanged()));
|
||||
connect(this->editor, &Editor::wheelZoom, this, &MainWindow::onWheelZoom);
|
||||
|
||||
this->loadUserSettings();
|
||||
|
||||
|
@ -572,20 +571,12 @@ void MainWindow::refreshMapScene()
|
|||
{
|
||||
on_mainTabBar_tabBarClicked(ui->mainTabBar->currentIndex());
|
||||
|
||||
double base = editor->scale_base;
|
||||
double exp = editor->scale_exp;
|
||||
|
||||
int width = static_cast<int>(ceil((editor->scene->width()) * pow(base,exp))) + 2;
|
||||
int height = static_cast<int>(ceil((editor->scene->height()) * pow(base,exp))) + 2;
|
||||
|
||||
ui->graphicsView_Map->setScene(editor->scene);
|
||||
ui->graphicsView_Map->setSceneRect(editor->scene->sceneRect());
|
||||
ui->graphicsView_Map->setFixedSize(width, height);
|
||||
ui->graphicsView_Map->editor = editor;
|
||||
|
||||
ui->graphicsView_Connections->setScene(editor->scene);
|
||||
ui->graphicsView_Connections->setSceneRect(editor->scene->sceneRect());
|
||||
ui->graphicsView_Connections->setFixedSize(width, height);
|
||||
|
||||
ui->graphicsView_Metatiles->setScene(editor->scene_metatiles);
|
||||
//ui->graphicsView_Metatiles->setSceneRect(editor->scene_metatiles->sceneRect());
|
||||
|
@ -1368,11 +1359,11 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index)
|
|||
}
|
||||
|
||||
void MainWindow::on_actionZoom_In_triggered() {
|
||||
scaleMapView(1);
|
||||
editor->scaleMapView(1);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionZoom_Out_triggered() {
|
||||
scaleMapView(-1);
|
||||
editor->scaleMapView(-1);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionBetter_Cursors_triggered() {
|
||||
|
@ -1449,39 +1440,8 @@ void MainWindow::on_actionMap_Shift_triggered()
|
|||
on_toolButton_Shift_clicked();
|
||||
}
|
||||
|
||||
void MainWindow::onWheelZoom(int s) {
|
||||
// Don't zoom the map when the user accidentally scrolls while performing a magic fill. (ctrl + middle button click)
|
||||
if (!(QApplication::mouseButtons() & Qt::MiddleButton)) {
|
||||
scaleMapView(s);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::scaleMapView(int s) {
|
||||
if ((editor->scale_exp + s) <= 5 && (editor->scale_exp + s) >= -2) // sane limits
|
||||
{
|
||||
if (s == 0)
|
||||
{
|
||||
s = -editor->scale_exp;
|
||||
}
|
||||
|
||||
editor->scale_exp += s;
|
||||
|
||||
double base = editor->scale_base;
|
||||
double exp = editor->scale_exp;
|
||||
double sfactor = pow(base,s);
|
||||
|
||||
ui->graphicsView_Map->scale(sfactor,sfactor);
|
||||
ui->graphicsView_Connections->scale(sfactor,sfactor);
|
||||
|
||||
int width = static_cast<int>(ceil((editor->scene->width()) * pow(base,exp))) + 2;
|
||||
int height = static_cast<int>(ceil((editor->scene->height()) * pow(base,exp))) + 2;
|
||||
ui->graphicsView_Map->setFixedSize(width, height);
|
||||
ui->graphicsView_Connections->setFixedSize(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::resetMapViewScale() {
|
||||
scaleMapView(0);
|
||||
editor->scaleMapView(0);
|
||||
}
|
||||
|
||||
void MainWindow::addNewEvent(QString event_type)
|
||||
|
@ -2158,9 +2118,9 @@ void MainWindow::on_toolButton_Paint_clicked()
|
|||
if (ui->tabWidget_2->currentIndex() == 0)
|
||||
editor->cursorMapTileRect->stopSingleTileMode();
|
||||
|
||||
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->scrollArea);
|
||||
ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->graphicsView_Map);
|
||||
|
||||
checkToolButtons();
|
||||
}
|
||||
|
@ -2175,9 +2135,9 @@ void MainWindow::on_toolButton_Select_clicked()
|
|||
editor->settings->mapCursor = QCursor();
|
||||
editor->cursorMapTileRect->setSingleTileMode();
|
||||
|
||||
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->scrollArea);
|
||||
ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->graphicsView_Map);
|
||||
|
||||
checkToolButtons();
|
||||
}
|
||||
|
@ -2192,9 +2152,9 @@ void MainWindow::on_toolButton_Fill_clicked()
|
|||
editor->settings->mapCursor = QCursor(QPixmap(":/icons/fill_color_cursor.ico"), 10, 10);
|
||||
editor->cursorMapTileRect->setSingleTileMode();
|
||||
|
||||
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->scrollArea);
|
||||
ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->graphicsView_Map);
|
||||
|
||||
checkToolButtons();
|
||||
}
|
||||
|
@ -2209,9 +2169,9 @@ void MainWindow::on_toolButton_Dropper_clicked()
|
|||
editor->settings->mapCursor = QCursor(QPixmap(":/icons/pipette_cursor.ico"), 10, 10);
|
||||
editor->cursorMapTileRect->setSingleTileMode();
|
||||
|
||||
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->scrollArea);
|
||||
ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->graphicsView_Map);
|
||||
|
||||
checkToolButtons();
|
||||
}
|
||||
|
@ -2226,9 +2186,9 @@ void MainWindow::on_toolButton_Move_clicked()
|
|||
editor->settings->mapCursor = QCursor(QPixmap(":/icons/move.ico"), 7, 7);
|
||||
editor->cursorMapTileRect->setSingleTileMode();
|
||||
|
||||
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
QScroller::grabGesture(ui->scrollArea, QScroller::LeftMouseButtonGesture);
|
||||
ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
QScroller::grabGesture(ui->graphicsView_Map, QScroller::LeftMouseButtonGesture);
|
||||
|
||||
checkToolButtons();
|
||||
}
|
||||
|
@ -2243,9 +2203,9 @@ void MainWindow::on_toolButton_Shift_clicked()
|
|||
editor->settings->mapCursor = QCursor(QPixmap(":/icons/shift_cursor.ico"), 10, 10);
|
||||
editor->cursorMapTileRect->setSingleTileMode();
|
||||
|
||||
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->scrollArea);
|
||||
ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
QScroller::ungrabGesture(ui->graphicsView_Map);
|
||||
|
||||
checkToolButtons();
|
||||
}
|
||||
|
@ -2594,6 +2554,7 @@ void MainWindow::on_actionThemes_triggered()
|
|||
QString theme = themeSelector->currentText();
|
||||
porymapConfig.setTheme(theme);
|
||||
this->setTheme(theme);
|
||||
editor->maskNonVisibleConnectionTiles();
|
||||
}
|
||||
});
|
||||
connect(&buttonBox, SIGNAL(rejected()), &themeSelectorWindow, SLOT(reject()));
|
||||
|
|
Loading…
Reference in a new issue