Merge pull request #592 from GriffinRichards/fix-zoom
Misc fixes for selection images
This commit is contained in:
commit
142b5de5af
9 changed files with 121 additions and 112 deletions
|
@ -10,9 +10,11 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
||||||
### Changed
|
### Changed
|
||||||
- If Wild Encounters fail to load they are now only disabled for that session, and the settings remain unchanged.
|
- If Wild Encounters fail to load they are now only disabled for that session, and the settings remain unchanged.
|
||||||
- Defaults are used if project constants are missing, rather than failing to open the project or changing settings.
|
- Defaults are used if project constants are missing, rather than failing to open the project or changing settings.
|
||||||
|
- Selector images now center on the selection when eyedropping or zooming.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix the Tileset Editor selectors scrolling to the wrong selection when zoomed.
|
- Fix some minor visual issues with the various zoom sliders.
|
||||||
|
- Smooth out scrolling when mouse is over tile/metatile images.
|
||||||
- Fix the Tileset Editor selectors getting extra white space when changing tilesets.
|
- Fix the Tileset Editor selectors getting extra white space when changing tilesets.
|
||||||
- Fix a crash when adding disabled events with the Pencil tool.
|
- Fix a crash when adding disabled events with the Pencil tool.
|
||||||
- Fix error log about failing to find the scripts file when a new map is created.
|
- Fix error log about failing to find the scripts file when a new map is created.
|
||||||
|
|
|
@ -764,7 +764,7 @@
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents_3">
|
<widget class="QWidget" name="scrollAreaWidgetContents_BorderMetatiles">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -803,7 +803,7 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGraphicsView" name="graphicsView_BorderMetatile">
|
<widget class="NoScrollGraphicsView" name="graphicsView_BorderMetatile">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -883,7 +883,7 @@
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents_6">
|
<widget class="QWidget" name="scrollAreaWidgetContents_SelectedMetatiles">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -922,7 +922,7 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGraphicsView" name="graphicsView_currentMetatileSelection">
|
<widget class="NoScrollGraphicsView" name="graphicsView_currentMetatileSelection">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -984,7 +984,7 @@
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
<widget class="QWidget" name="scrollAreaWidgetContents_MetatileSelector">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1032,7 +1032,7 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QGraphicsView" name="graphicsView_Metatiles">
|
<widget class="NoScrollGraphicsView" name="graphicsView_Metatiles">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1184,11 +1184,11 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="3">
|
<item row="5" column="0" colspan="3">
|
||||||
<widget class="QScrollArea" name="scrollArea_1">
|
<widget class="QScrollArea" name="scrollArea_Collision">
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
<widget class="QWidget" name="scrollAreaWidgetContents_Collision">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -1227,7 +1227,7 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QGraphicsView" name="graphicsView_Collision">
|
<widget class="NoScrollGraphicsView" name="graphicsView_Collision">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -3435,6 +3435,11 @@
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>mapview.h</header>
|
<header>mapview.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>NoScrollGraphicsView</class>
|
||||||
|
<extends>QGraphicsView</extends>
|
||||||
|
<header>mapview.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../resources/images.qrc"/>
|
<include location="../resources/images.qrc"/>
|
||||||
|
|
|
@ -58,9 +58,9 @@
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents_2">
|
<widget class="QWidget" name="scrollAreaWidgetContents_Metatiles">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -85,21 +85,8 @@
|
||||||
<property name="horizontalSpacing">
|
<property name="horizontalSpacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="1">
|
<item row="0" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<widget class="NoScrollGraphicsView" name="graphicsView_Metatiles">
|
||||||
<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">
|
|
||||||
<widget class="QGraphicsView" name="graphicsView_Metatiles">
|
|
||||||
<property name="verticalScrollBarPolicy">
|
<property name="verticalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -108,28 +95,15 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>40</height>
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
@ -561,9 +535,9 @@
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
<widget class="QWidget" name="scrollAreaWidgetContents_Tiles">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -585,21 +559,8 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="2">
|
<item row="0" column="0">
|
||||||
<spacer name="horizontalSpacer_4">
|
<widget class="NoScrollGraphicsView" name="graphicsView_Tiles">
|
||||||
<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="0" column="1">
|
|
||||||
<widget class="QGraphicsView" name="graphicsView_Tiles">
|
|
||||||
<property name="verticalScrollBarPolicy">
|
<property name="verticalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -608,8 +569,8 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="0">
|
||||||
<spacer name="verticalSpacer_4">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -621,19 +582,6 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -858,6 +806,11 @@
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
<header>noscrollcombobox.h</header>
|
<header>noscrollcombobox.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>NoScrollGraphicsView</class>
|
||||||
|
<extends>QGraphicsView</extends>
|
||||||
|
<header>mapview.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../resources/images.qrc"/>
|
<include location="../resources/images.qrc"/>
|
||||||
|
|
|
@ -390,7 +390,9 @@ private:
|
||||||
void openProjectSettingsEditor(int tab);
|
void openProjectSettingsEditor(int tab);
|
||||||
bool isProjectOpen();
|
bool isProjectOpen();
|
||||||
void showExportMapImageWindow(ImageExporterMode mode);
|
void showExportMapImageWindow(ImageExporterMode mode);
|
||||||
|
double getMetatilesZoomScale();
|
||||||
void redrawMetatileSelection();
|
void redrawMetatileSelection();
|
||||||
|
void scrollMetatileSelectorToSelection();
|
||||||
|
|
||||||
QObjectList shortcutableObjects() const;
|
QObjectList shortcutableObjects() const;
|
||||||
void addCustomHeaderValue(QString key, QJsonValue value, bool isNew = false);
|
void addCustomHeaderValue(QString key, QJsonValue value, bool isNew = false);
|
||||||
|
|
|
@ -4,12 +4,23 @@
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
class ClickableGraphicsView : public QGraphicsView
|
class NoScrollGraphicsView : public QGraphicsView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ClickableGraphicsView() : QGraphicsView() {}
|
NoScrollGraphicsView(QWidget *parent = nullptr) : QGraphicsView(parent) {}
|
||||||
ClickableGraphicsView(QWidget *parent) : QGraphicsView(parent) {}
|
|
||||||
|
protected:
|
||||||
|
void wheelEvent(QWheelEvent *event) {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ClickableGraphicsView : public NoScrollGraphicsView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ClickableGraphicsView(QWidget *parent = nullptr) : NoScrollGraphicsView(parent) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void mouseReleaseEvent(QMouseEvent *event) override {
|
void mouseReleaseEvent(QMouseEvent *event) override {
|
||||||
|
|
|
@ -45,13 +45,14 @@ public:
|
||||||
QPoint getSelectionDimensions();
|
QPoint getSelectionDimensions();
|
||||||
void draw();
|
void draw();
|
||||||
bool select(uint16_t metatile);
|
bool select(uint16_t metatile);
|
||||||
bool selectFromMap(uint16_t metatileId, uint16_t collision, uint16_t elevation);
|
void selectFromMap(uint16_t metatileId, uint16_t collision, uint16_t elevation);
|
||||||
void setTilesets(Tileset*, Tileset*);
|
void setTilesets(Tileset*, Tileset*);
|
||||||
MetatileSelection getMetatileSelection();
|
MetatileSelection getMetatileSelection();
|
||||||
void setPrefabSelection(MetatileSelection selection);
|
void setPrefabSelection(MetatileSelection selection);
|
||||||
void setExternalSelection(int, int, QList<uint16_t>, QList<QPair<uint16_t, uint16_t>>);
|
void setExternalSelection(int, int, QList<uint16_t>, QList<QPair<uint16_t, uint16_t>>);
|
||||||
QPoint getMetatileIdCoordsOnWidget(uint16_t);
|
QPoint getMetatileIdCoordsOnWidget(uint16_t);
|
||||||
void setMap(Map*);
|
void setMap(Map*);
|
||||||
|
bool isInternalSelection() const { return (!this->externalSelection && !this->prefabSelection); }
|
||||||
Tileset *primaryTileset;
|
Tileset *primaryTileset;
|
||||||
Tileset *secondaryTileset;
|
Tileset *secondaryTileset;
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -1366,31 +1366,52 @@ void MainWindow::updateTilesetEditor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::redrawMetatileSelection()
|
double MainWindow::getMetatilesZoomScale() {
|
||||||
{
|
return pow(3.0, static_cast<double>(porymapConfig.getMetatilesZoom() - 30) / 30.0);
|
||||||
double scale = pow(3.0, static_cast<double>(porymapConfig.getMetatilesZoom() - 30) / 30.0);
|
|
||||||
QTransform transform;
|
|
||||||
transform.scale(scale, scale);
|
|
||||||
|
|
||||||
ui->graphicsView_currentMetatileSelection->setTransform(transform);
|
|
||||||
ui->graphicsView_currentMetatileSelection->setFixedSize(editor->current_metatile_selection_item->pixmap().width() * scale + 2, editor->current_metatile_selection_item->pixmap().height() * scale + 2);
|
|
||||||
|
|
||||||
QPoint size = editor->metatile_selector_item->getSelectionDimensions();
|
|
||||||
if (size.x() == 1 && size.y() == 1) {
|
|
||||||
MetatileSelection selection = editor->metatile_selector_item->getMetatileSelection();
|
|
||||||
QPoint pos = editor->metatile_selector_item->getMetatileIdCoordsOnWidget(selection.metatileItems.first().metatileId);
|
|
||||||
pos *= scale;
|
|
||||||
ui->scrollArea_MetatileSelector->ensureVisible(pos.x(), pos.y(), 8 * scale, 8 * scale);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::currentMetatilesSelectionChanged()
|
void MainWindow::redrawMetatileSelection() {
|
||||||
{
|
QSize size(editor->current_metatile_selection_item->pixmap().width(), editor->current_metatile_selection_item->pixmap().height());
|
||||||
|
ui->graphicsView_currentMetatileSelection->setSceneRect(0, 0, size.width(), size.height());
|
||||||
|
|
||||||
|
auto scale = getMetatilesZoomScale();
|
||||||
|
QTransform transform;
|
||||||
|
transform.scale(scale, scale);
|
||||||
|
size *= scale;
|
||||||
|
|
||||||
|
ui->graphicsView_currentMetatileSelection->setTransform(transform);
|
||||||
|
ui->graphicsView_currentMetatileSelection->setFixedSize(size.width() + 2, size.height() + 2);
|
||||||
|
ui->scrollAreaWidgetContents_SelectedMetatiles->adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::scrollMetatileSelectorToSelection() {
|
||||||
|
// Internal selections or 1x1 external selections can be scrolled to
|
||||||
|
if (!editor->metatile_selector_item->isInternalSelection() && editor->metatile_selector_item->getSelectionDimensions() != QPoint(1, 1))
|
||||||
|
return;
|
||||||
|
|
||||||
|
MetatileSelection selection = editor->metatile_selector_item->getMetatileSelection();
|
||||||
|
if (selection.metatileItems.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QPoint pos = editor->metatile_selector_item->getMetatileIdCoordsOnWidget(selection.metatileItems.first().metatileId);
|
||||||
|
QPoint size = editor->metatile_selector_item->getSelectionDimensions();
|
||||||
|
pos += QPoint(size.x() - 1, size.y() - 1) * 16 / 2; // We want to focus on the center of the whole selection
|
||||||
|
pos *= getMetatilesZoomScale();
|
||||||
|
|
||||||
|
auto viewport = ui->scrollArea_MetatileSelector->viewport();
|
||||||
|
ui->scrollArea_MetatileSelector->ensureVisible(pos.x(), pos.y(), viewport->width() / 2, viewport->height() / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::currentMetatilesSelectionChanged() {
|
||||||
redrawMetatileSelection();
|
redrawMetatileSelection();
|
||||||
if (this->tilesetEditor) {
|
if (this->tilesetEditor) {
|
||||||
MetatileSelection selection = editor->metatile_selector_item->getMetatileSelection();
|
MetatileSelection selection = editor->metatile_selector_item->getMetatileSelection();
|
||||||
this->tilesetEditor->selectMetatile(selection.metatileItems.first().metatileId);
|
this->tilesetEditor->selectMetatile(selection.metatileItems.first().metatileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't scroll to internal selections here, it will disrupt the user while they make their selection.
|
||||||
|
if (!editor->metatile_selector_item->isInternalSelection())
|
||||||
|
scrollMetatileSelectorToSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_mapList_activated(const QModelIndex &index)
|
void MainWindow::on_mapList_activated(const QModelIndex &index)
|
||||||
|
@ -2831,7 +2852,11 @@ void MainWindow::on_horizontalSlider_MetatileZoom_valueChanged(int value) {
|
||||||
ui->graphicsView_BorderMetatile->setFixedSize(ceil(static_cast<double>(editor->selected_border_metatiles_item->pixmap().width()) * scale) + 2,
|
ui->graphicsView_BorderMetatile->setFixedSize(ceil(static_cast<double>(editor->selected_border_metatiles_item->pixmap().width()) * scale) + 2,
|
||||||
ceil(static_cast<double>(editor->selected_border_metatiles_item->pixmap().height()) * scale) + 2);
|
ceil(static_cast<double>(editor->selected_border_metatiles_item->pixmap().height()) * scale) + 2);
|
||||||
|
|
||||||
|
ui->scrollAreaWidgetContents_MetatileSelector->adjustSize();
|
||||||
|
ui->scrollAreaWidgetContents_BorderMetatiles->adjustSize();
|
||||||
|
|
||||||
redrawMetatileSelection();
|
redrawMetatileSelection();
|
||||||
|
scrollMetatileSelectorToSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_horizontalSlider_CollisionZoom_valueChanged(int value) {
|
void MainWindow::on_horizontalSlider_CollisionZoom_valueChanged(int value) {
|
||||||
|
@ -2847,6 +2872,7 @@ void MainWindow::on_horizontalSlider_CollisionZoom_valueChanged(int value) {
|
||||||
ui->graphicsView_Collision->setResizeAnchor(QGraphicsView::NoAnchor);
|
ui->graphicsView_Collision->setResizeAnchor(QGraphicsView::NoAnchor);
|
||||||
ui->graphicsView_Collision->setTransform(transform);
|
ui->graphicsView_Collision->setTransform(transform);
|
||||||
ui->graphicsView_Collision->setFixedSize(size.width() + 2, size.height() + 2);
|
ui->graphicsView_Collision->setFixedSize(size.width() + 2, size.height() + 2);
|
||||||
|
ui->scrollAreaWidgetContents_Collision->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_spinBox_SelectedCollision_valueChanged(int collision) {
|
void MainWindow::on_spinBox_SelectedCollision_valueChanged(int collision) {
|
||||||
|
|
|
@ -59,12 +59,9 @@ bool MetatileSelector::select(uint16_t metatileId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MetatileSelector::selectFromMap(uint16_t metatileId, uint16_t collision, uint16_t elevation) {
|
void MetatileSelector::selectFromMap(uint16_t metatileId, uint16_t collision, uint16_t elevation) {
|
||||||
if (!Tileset::metatileIsValid(metatileId, this->primaryTileset, this->secondaryTileset)) return false;
|
QPair<uint16_t, uint16_t> movePermissions(collision, elevation);
|
||||||
this->select(metatileId);
|
this->setExternalSelection(1, 1, {metatileId}, {movePermissions});
|
||||||
this->selection.collisionItems.append(CollisionSelectionItem{true, collision, elevation});
|
|
||||||
this->selection.hasCollision = true;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetatileSelector::setTilesets(Tileset *primaryTileset, Tileset *secondaryTileset) {
|
void MetatileSelector::setTilesets(Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||||
|
@ -100,6 +97,10 @@ void MetatileSelector::setExternalSelection(int width, int height, QList<uint16_
|
||||||
metatileId = 0;
|
metatileId = 0;
|
||||||
this->selection.metatileItems.append(MetatileSelectionItem{true, metatileId});
|
this->selection.metatileItems.append(MetatileSelectionItem{true, metatileId});
|
||||||
}
|
}
|
||||||
|
if (this->selection.metatileItems.length() == 1) {
|
||||||
|
QPoint coords = this->getMetatileIdCoords(this->selection.metatileItems.first().metatileId);
|
||||||
|
SelectablePixmapItem::select(coords.x(), coords.y(), 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
this->draw();
|
this->draw();
|
||||||
emit selectedMetatilesChanged();
|
emit selectedMetatilesChanged();
|
||||||
|
|
|
@ -317,7 +317,6 @@ void TilesetEditor::refresh() {
|
||||||
this->tileSelector->setTilesets(this->primaryTileset, this->secondaryTileset);
|
this->tileSelector->setTilesets(this->primaryTileset, this->secondaryTileset);
|
||||||
this->metatileSelector->setTilesets(this->primaryTileset, this->secondaryTileset);
|
this->metatileSelector->setTilesets(this->primaryTileset, this->secondaryTileset);
|
||||||
this->metatileSelector->select(this->getSelectedMetatileId());
|
this->metatileSelector->select(this->getSelectedMetatileId());
|
||||||
this->drawSelectedTiles();
|
|
||||||
|
|
||||||
if (metatileSelector) {
|
if (metatileSelector) {
|
||||||
if (metatileSelector->selectorShowUnused || metatileSelector->selectorShowCounts) {
|
if (metatileSelector->selectorShowUnused || metatileSelector->selectorShowCounts) {
|
||||||
|
@ -335,7 +334,7 @@ void TilesetEditor::refresh() {
|
||||||
|
|
||||||
this->redrawTileSelector();
|
this->redrawTileSelector();
|
||||||
this->redrawMetatileSelector();
|
this->redrawMetatileSelector();
|
||||||
this->ui->graphicsView_selectedTile->setFixedSize(this->selectedTilePixmapItem->pixmap().width() + 2, this->selectedTilePixmapItem->pixmap().height() + 2);
|
this->drawSelectedTiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditor::drawSelectedTiles() {
|
void TilesetEditor::drawSelectedTiles() {
|
||||||
|
@ -361,7 +360,10 @@ void TilesetEditor::drawSelectedTiles() {
|
||||||
|
|
||||||
this->selectedTilePixmapItem = new QGraphicsPixmapItem(QPixmap::fromImage(selectionImage));
|
this->selectedTilePixmapItem = new QGraphicsPixmapItem(QPixmap::fromImage(selectionImage));
|
||||||
this->selectedTileScene->addItem(this->selectedTilePixmapItem);
|
this->selectedTileScene->addItem(this->selectedTilePixmapItem);
|
||||||
this->ui->graphicsView_selectedTile->setFixedSize(this->selectedTilePixmapItem->pixmap().width() + 2, this->selectedTilePixmapItem->pixmap().height() + 2);
|
|
||||||
|
QSize size(this->selectedTilePixmapItem->pixmap().width(), this->selectedTilePixmapItem->pixmap().height());
|
||||||
|
this->ui->graphicsView_selectedTile->setSceneRect(0, 0, size.width(), size.height());
|
||||||
|
this->ui->graphicsView_selectedTile->setFixedSize(size.width() + 2, size.height() + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditor::onHoveredMetatileChanged(uint16_t metatileId) {
|
void TilesetEditor::onHoveredMetatileChanged(uint16_t metatileId) {
|
||||||
|
@ -1191,7 +1193,7 @@ void TilesetEditor::on_horizontalSlider_MetatilesZoom_valueChanged(int value) {
|
||||||
|
|
||||||
void TilesetEditor::redrawMetatileSelector() {
|
void TilesetEditor::redrawMetatileSelector() {
|
||||||
QSize size(this->metatileSelector->pixmap().width(), this->metatileSelector->pixmap().height());
|
QSize size(this->metatileSelector->pixmap().width(), this->metatileSelector->pixmap().height());
|
||||||
this->ui->graphicsView_Metatiles->setSceneRect(0, 0, size.width() + 2, size.height() + 2);
|
this->ui->graphicsView_Metatiles->setSceneRect(0, 0, size.width(), size.height());
|
||||||
|
|
||||||
double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorMetatilesZoom() - 30) / 30.0);
|
double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorMetatilesZoom() - 30) / 30.0);
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
|
@ -1203,7 +1205,10 @@ void TilesetEditor::redrawMetatileSelector() {
|
||||||
|
|
||||||
QPoint pos = this->metatileSelector->getMetatileIdCoordsOnWidget(this->getSelectedMetatileId());
|
QPoint pos = this->metatileSelector->getMetatileIdCoordsOnWidget(this->getSelectedMetatileId());
|
||||||
pos *= scale;
|
pos *= scale;
|
||||||
this->ui->scrollArea_Metatiles->ensureVisible(pos.x(), pos.y(), 8 * scale, 8 * scale);
|
|
||||||
|
this->ui->scrollAreaWidgetContents_Metatiles->adjustSize();
|
||||||
|
auto viewport = this->ui->scrollArea_Metatiles->viewport();
|
||||||
|
this->ui->scrollArea_Metatiles->ensureVisible(pos.x(), pos.y(), viewport->width() / 2, viewport->height() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditor::on_horizontalSlider_TilesZoom_valueChanged(int value) {
|
void TilesetEditor::on_horizontalSlider_TilesZoom_valueChanged(int value) {
|
||||||
|
@ -1213,7 +1218,7 @@ void TilesetEditor::on_horizontalSlider_TilesZoom_valueChanged(int value) {
|
||||||
|
|
||||||
void TilesetEditor::redrawTileSelector() {
|
void TilesetEditor::redrawTileSelector() {
|
||||||
QSize size(this->tileSelector->pixmap().width(), this->tileSelector->pixmap().height());
|
QSize size(this->tileSelector->pixmap().width(), this->tileSelector->pixmap().height());
|
||||||
this->ui->graphicsView_Tiles->setSceneRect(0, 0, size.width() + 2, size.height() + 2);
|
this->ui->graphicsView_Tiles->setSceneRect(0, 0, size.width(), size.height());
|
||||||
|
|
||||||
double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorTilesZoom() - 30) / 30.0);
|
double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorTilesZoom() - 30) / 30.0);
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
|
@ -1223,10 +1228,13 @@ void TilesetEditor::redrawTileSelector() {
|
||||||
this->ui->graphicsView_Tiles->setTransform(transform);
|
this->ui->graphicsView_Tiles->setTransform(transform);
|
||||||
this->ui->graphicsView_Tiles->setFixedSize(size.width() + 2, size.height() + 2);
|
this->ui->graphicsView_Tiles->setFixedSize(size.width() + 2, size.height() + 2);
|
||||||
|
|
||||||
|
this->ui->scrollAreaWidgetContents_Tiles->adjustSize();
|
||||||
|
|
||||||
auto tiles = this->tileSelector->getSelectedTiles();
|
auto tiles = this->tileSelector->getSelectedTiles();
|
||||||
if (!tiles.isEmpty()) {
|
if (!tiles.isEmpty()) {
|
||||||
QPoint pos = this->tileSelector->getTileCoordsOnWidget(tiles[0].tileId);
|
QPoint pos = this->tileSelector->getTileCoordsOnWidget(tiles[0].tileId);
|
||||||
pos *= scale;
|
pos *= scale;
|
||||||
this->ui->scrollArea_Tiles->ensureVisible(pos.x(), pos.y(), 8 * scale, 8 * scale);
|
auto viewport = this->ui->scrollArea_Tiles->viewport();
|
||||||
|
this->ui->scrollArea_Tiles->ensureVisible(pos.x(), pos.y(), viewport->width() / 2, viewport->height() / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue