Remove straight paths checkbox and refactor
This commit is contained in:
parent
de2246e2fd
commit
2fd3df9734
10 changed files with 19 additions and 66 deletions
|
@ -626,22 +626,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_straightPaths">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Straight Paths</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_ToggleGrid">
|
||||
<property name="toolTip">
|
||||
|
|
|
@ -100,8 +100,6 @@ public:
|
|||
Q_INVOKABLE bool getBorderVisibility();
|
||||
Q_INVOKABLE void setSmartPathsEnabled(bool visible);
|
||||
Q_INVOKABLE bool getSmartPathsEnabled();
|
||||
Q_INVOKABLE void setStraightPathsEnabled(bool visible);
|
||||
Q_INVOKABLE bool getStraightPathsEnabled();
|
||||
Q_INVOKABLE void registerAction(QString functionName, QString actionName, QString shortcut = "");
|
||||
Q_INVOKABLE void setTimeout(QJSValue callback, int milliseconds);
|
||||
void invokeCallback(QJSValue callback);
|
||||
|
@ -203,7 +201,6 @@ private slots:
|
|||
void on_comboBox_SecondaryTileset_currentTextChanged(const QString &arg1);
|
||||
void on_pushButton_ChangeDimensions_clicked();
|
||||
void on_checkBox_smartPaths_stateChanged(int selected);
|
||||
void on_checkBox_straightPaths_stateChanged(int selected);
|
||||
void on_checkBox_Visibility_clicked(bool checked);
|
||||
void on_checkBox_ToggleBorder_stateChanged(int arg1);
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ class Settings
|
|||
public:
|
||||
Settings();
|
||||
bool smartPathsEnabled;
|
||||
bool straightPathsEnabled;
|
||||
bool betterCursors;
|
||||
QCursor mapCursor;
|
||||
bool playerViewRectEnabled;
|
||||
|
|
|
@ -50,13 +50,12 @@ public:
|
|||
void stopAnchor();
|
||||
void initRightClickSelectionAnchor(int coordX, int coordY);
|
||||
void stopRightClickSelectionAnchor();
|
||||
void setSmartPathMode();
|
||||
void setSmartPathMode(bool enable);
|
||||
bool getSmartPathMode() { return this->smartPathMode; }
|
||||
void setStraightPathMode();
|
||||
void setStraightPathMode(bool enable);
|
||||
bool getStraightPathMode() { return this->straightPathMode; }
|
||||
void setSingleTileMode();
|
||||
void stopSingleTileMode();
|
||||
void setNormalPathMode();
|
||||
void updateLocation(int x, int y);
|
||||
void updateSelectionSize(int width, int height);
|
||||
void setVisibility(bool visible);
|
||||
|
@ -76,7 +75,6 @@ private:
|
|||
int selectionHeight;
|
||||
QRgb color;
|
||||
bool smartPathInEffect();
|
||||
bool straightPathInEffect();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1009,7 +1009,8 @@ void Editor::onMapEndPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *item) {
|
|||
this->cursorMapTileRect->stopAnchor();
|
||||
}
|
||||
|
||||
void Editor::setSmartPathCursorMode(QGraphicsSceneMouseEvent *event) {
|
||||
void Editor::setSmartPathCursorMode(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
bool shiftPressed = event->modifiers() & Qt::ShiftModifier;
|
||||
if (settings->smartPathsEnabled) {
|
||||
if (!shiftPressed) {
|
||||
|
@ -1055,13 +1056,13 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
|
|||
item->floodFill(event);
|
||||
}
|
||||
} else {
|
||||
this->setSmartPathCursorMode(event);
|
||||
this->setStraightPathCursorMode(event);
|
||||
if (this->cursorMapTileRect->getStraightPathMode()) {
|
||||
item->lockNondominantAxis(event);
|
||||
x = item->adjustCoord(x, MapPixmapItem::Axis::X);
|
||||
y = item->adjustCoord(y, MapPixmapItem::Axis::Y);
|
||||
}
|
||||
this->setSmartPathCursorMode(event);
|
||||
item->paint(event);
|
||||
}
|
||||
} else if (map_edit_mode == "select") {
|
||||
|
|
|
@ -2492,18 +2492,12 @@ void MainWindow::on_checkBox_smartPaths_stateChanged(int selected)
|
|||
bool enabled = selected == Qt::Checked;
|
||||
editor->settings->smartPathsEnabled = enabled;
|
||||
if (enabled) {
|
||||
editor->cursorMapTileRect->setSmartPathMode();
|
||||
editor->cursorMapTileRect->setSmartPathMode(true);
|
||||
} else {
|
||||
editor->cursorMapTileRect->setNormalPathMode();
|
||||
editor->cursorMapTileRect->setSmartPathMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_checkBox_straightPaths_stateChanged(int selected)
|
||||
{
|
||||
bool enabled = selected == Qt::Checked;
|
||||
editor->settings->straightPathsEnabled = enabled;
|
||||
}
|
||||
|
||||
void MainWindow::on_checkBox_ToggleBorder_stateChanged(int selected)
|
||||
{
|
||||
bool visible = selected != 0;
|
||||
|
|
|
@ -476,14 +476,6 @@ bool MainWindow::getSmartPathsEnabled() {
|
|||
return this->ui->checkBox_smartPaths->isChecked();
|
||||
}
|
||||
|
||||
void MainWindow::setStraightPathsEnabled(bool visible) {
|
||||
this->ui->checkBox_straightPaths->setChecked(visible);
|
||||
}
|
||||
|
||||
bool MainWindow::getStraightPathsEnabled() {
|
||||
return this->ui->checkBox_straightPaths->isChecked();
|
||||
}
|
||||
|
||||
void MainWindow::registerAction(QString functionName, QString actionName, QString shortcut) {
|
||||
if (!this->ui || !this->ui->menuTools)
|
||||
return;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
Settings::Settings()
|
||||
{
|
||||
this->smartPathsEnabled = false;
|
||||
this->straightPathsEnabled = false;
|
||||
this->betterCursors = true;
|
||||
this->playerViewRectEnabled = false;
|
||||
this->cursorTileRectEnabled = true;
|
||||
|
|
|
@ -58,14 +58,14 @@ void CursorTileRect::updateSelectionSize(int width, int height)
|
|||
this->update();
|
||||
}
|
||||
|
||||
void CursorTileRect::setSmartPathMode()
|
||||
void CursorTileRect::setSmartPathMode(bool enable)
|
||||
{
|
||||
this->smartPathMode = true;
|
||||
this->smartPathMode = enable;
|
||||
}
|
||||
|
||||
void CursorTileRect::setStraightPathMode()
|
||||
void CursorTileRect::setStraightPathMode(bool enable)
|
||||
{
|
||||
this->straightPathMode = true;
|
||||
this->straightPathMode = enable;
|
||||
}
|
||||
|
||||
void CursorTileRect::setSingleTileMode()
|
||||
|
@ -78,22 +78,11 @@ void CursorTileRect::stopSingleTileMode()
|
|||
this->singleTileMode = false;
|
||||
}
|
||||
|
||||
void CursorTileRect::setNormalPathMode()
|
||||
{
|
||||
this->smartPathMode = false;
|
||||
this->straightPathMode = false;
|
||||
}
|
||||
|
||||
bool CursorTileRect::smartPathInEffect()
|
||||
{
|
||||
return !this->rightClickSelectionAnchored && this->smartPathMode && this->selectionHeight == 3 && this->selectionWidth == 3;
|
||||
}
|
||||
|
||||
bool CursorTileRect::straightPathInEffect()
|
||||
{
|
||||
return !this->rightClickSelectionAnchored && this->straightPathMode;
|
||||
}
|
||||
|
||||
void CursorTileRect::updateLocation(int coordX, int coordY)
|
||||
{
|
||||
if (!this->singleTileMode) {
|
||||
|
|
|
@ -15,8 +15,7 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
|||
int y = static_cast<int>(pos.y()) / 16;
|
||||
|
||||
// Set straight paths on/off and snap to the dominant axis when on
|
||||
bool straightPathsEnabled = event->modifiers() & Qt::ControlModifier;
|
||||
if (this->settings->straightPathsEnabled || straightPathsEnabled) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
this->lockNondominantAxis(event);
|
||||
x = this->adjustCoord(x, MapPixmapItem::Axis::X);
|
||||
y = this->adjustCoord(y, MapPixmapItem::Axis::Y);
|
||||
|
@ -55,8 +54,7 @@ void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) {
|
|||
int y = static_cast<int>(pos.y()) / 16;
|
||||
|
||||
// Set straight paths on/off and snap to the dominant axis when on
|
||||
bool straightPathsEnabled = event->modifiers() & Qt::ControlModifier;
|
||||
if (this->settings->straightPathsEnabled || straightPathsEnabled) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
this->lockNondominantAxis(event);
|
||||
x = this->adjustCoord(x, MapPixmapItem::Axis::X);
|
||||
y = this->adjustCoord(y, MapPixmapItem::Axis::Y);
|
||||
|
@ -302,19 +300,21 @@ void MapPixmapItem::lockNondominantAxis(QGraphicsSceneMouseEvent *event) {
|
|||
int xDiff = x - this->straight_path_initial_x;
|
||||
int yDiff = y - this->straight_path_initial_y;
|
||||
if ((xDiff || yDiff) && event->type() != QEvent::GraphicsSceneMouseRelease) {
|
||||
if (abs(xDiff) < abs(yDiff))
|
||||
if (abs(xDiff) < abs(yDiff)) {
|
||||
this->lockedAxis = MapPixmapItem::Axis::X;
|
||||
else
|
||||
} else {
|
||||
this->lockedAxis = MapPixmapItem::Axis::Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust the cooresponding coordinate when it is locked
|
||||
int MapPixmapItem::adjustCoord(int coord, MapPixmapItem::Axis axis) {
|
||||
if (axis == MapPixmapItem::Axis::X && this->lockedAxis == MapPixmapItem::Axis::X)
|
||||
if (axis == MapPixmapItem::Axis::X && this->lockedAxis == MapPixmapItem::Axis::X) {
|
||||
coord = this->straight_path_initial_x;
|
||||
else if (axis == MapPixmapItem::Axis::Y && this->lockedAxis == MapPixmapItem::Axis::Y)
|
||||
} else if (axis == MapPixmapItem::Axis::Y && this->lockedAxis == MapPixmapItem::Axis::Y) {
|
||||
coord = this->straight_path_initial_y;
|
||||
}
|
||||
return coord;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue