Merge pull request #582 from GriffinRichards/tileset-zoom

Add zoom sliders to the Tileset Editor
This commit is contained in:
GriffinR 2024-01-11 23:11:00 -05:00 committed by GitHub
commit 1428b250e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 642 additions and 509 deletions

View file

@ -19,35 +19,54 @@
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QScrollArea" name="scrollArea_Metatiles">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<widget class="QFrame" name="frame_Metatiles">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>1</horstretch>
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>274</width>
<height>0</height>
</size>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="maximumSize">
<size>
<width>274</width>
<height>16777215</height>
</size>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<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>
<item>
<widget class="QScrollArea" name="scrollArea_Metatiles">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>272</width>
<height>625</height>
<width>223</width>
<height>593</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
@ -66,33 +85,7 @@
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="1" 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>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<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">
<item row="1" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -105,7 +98,7 @@
</property>
</spacer>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="QGraphicsView" name="graphicsView_Metatiles">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
@ -115,15 +108,28 @@
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_2">
<item row="0" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>40</width>
<height>20</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>
</property>
</spacer>
@ -133,7 +139,21 @@
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<widget class="QSlider" name="horizontalSlider_MetatilesZoom">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QFrame" name="frame_Editing">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
@ -153,8 +173,14 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="QFrame" name="frame_4">
<item>
<widget class="QFrame" name="frame_Properties">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
@ -184,13 +210,7 @@
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QGroupBox" name="groupBox_MetatileProperties">
<property name="title">
<string>Metatile Properties</string>
</property>
@ -201,33 +221,6 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1" colspan="3">
<widget class="NoScrollComboBox" name="comboBox_layerType"/>
</item>
<item row="7" column="0" colspan="4">
<widget class="NoScrollComboBox" name="comboBox_metatileBehaviors"/>
</item>
<item row="13" column="0" colspan="3">
<widget class="QLineEdit" name="lineEdit_metatileLabel">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="0" colspan="3">
<widget class="QLabel" name="label_metatileLabel">
<property name="text">
<string>Metatile Label (Optional)</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="label_metatileBehavior">
<property name="text">
<string>Metatile Behavior</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGraphicsView" name="graphicsView_metatileLayers">
<property name="sizePolicy">
@ -244,7 +237,7 @@
</property>
<property name="maximumSize">
<size>
<width>66</width>
<width>96</width>
<height>34</height>
</size>
</property>
@ -256,38 +249,47 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_BottomTop">
<property name="text">
<string>Bottom/Top</string>
<item row="11" column="0" colspan="5">
<widget class="NoScrollComboBox" name="comboBox_terrainType">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_encounterType">
<property name="text">
<string>Encounter Type</string>
<item row="14" column="0">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0" colspan="5">
<widget class="NoScrollComboBox" name="comboBox_encounterType">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_terrainType">
<item row="12" column="0" colspan="5">
<widget class="QLabel" name="label_metatileLabel">
<property name="text">
<string>Terrain Type</string>
<string>Metatile Label (Optional)</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="NoScrollComboBox" name="comboBox_terrainType"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_layerType">
<property name="text">
<string>Layer Type</string>
</property>
</widget>
</item>
<item row="13" column="3">
<item row="13" column="4">
<widget class="QToolButton" name="copyButton_metatileLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Copies the full metatile label to the clipboard.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -301,14 +303,95 @@
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="NoScrollComboBox" name="comboBox_encounterType"/>
<item row="1" column="2" colspan="3">
<widget class="NoScrollComboBox" name="comboBox_layerType">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>185</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="7" column="0" colspan="5">
<widget class="NoScrollComboBox" name="comboBox_metatileBehaviors">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2" colspan="3">
<widget class="QLabel" name="label_layerType">
<property name="text">
<string>Layer Type</string>
</property>
</widget>
</item>
<item row="13" column="0" colspan="4">
<widget class="QLineEdit" name="lineEdit_metatileLabel">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="5">
<widget class="QLabel" name="label_metatileBehavior">
<property name="text">
<string>Metatile Behavior</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="0" colspan="5">
<widget class="QLabel" name="label_encounterType">
<property name="text">
<string>Encounter Type</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="5">
<widget class="QLabel" name="label_terrainType">
<property name="text">
<string>Terrain Type</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_BottomTop">
<property name="text">
<string>Bottom/Top</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="groupBox_TileProperties">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -330,14 +413,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBox_paletteSelector">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QSpinBox" name="spinBox_paletteSelector"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
@ -370,8 +446,24 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="2">
<widget class="QFrame" name="frame">
<widget class="QFrame" name="frame_SelectedTile">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -380,7 +472,7 @@
</property>
<property name="minimumSize">
<size>
<width>0</width>
<width>98</width>
<height>62</height>
</size>
</property>
@ -426,7 +518,7 @@
</property>
<property name="maximumSize">
<size>
<width>66</width>
<width>98</width>
<height>34</height>
</size>
</property>
@ -444,19 +536,6 @@
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0" colspan="2">
<spacer name="verticalSpacer_6">
<property name="orientation">
@ -478,22 +557,19 @@
</item>
<item>
<widget class="QScrollArea" name="scrollArea_Tiles">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>272</height>
<width>455</width>
<height>232</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@ -509,33 +585,7 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<spacer name="verticalSpacer_3">
<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="2" column="1">
<spacer name="verticalSpacer_4">
<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="2">
<item row="0" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -548,7 +598,7 @@
</property>
</spacer>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="QGraphicsView" name="graphicsView_Tiles">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
@ -558,7 +608,20 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="1">
<spacer name="verticalSpacer_4">
<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="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -575,8 +638,16 @@
</widget>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider_TilesZoom">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>

View file

@ -58,6 +58,8 @@ public:
this->collisionOpacity = 50;
this->collisionZoom = 30;
this->metatilesZoom = 30;
this->tilesetEditorMetatilesZoom = 30;
this->tilesetEditorTilesZoom = 30;
this->showPlayerView = false;
this->showCursorTile = true;
this->showBorder = true;
@ -87,6 +89,8 @@ public:
void setCollisionOpacity(int opacity);
void setCollisionZoom(int zoom);
void setMetatilesZoom(int zoom);
void setTilesetEditorMetatilesZoom(int zoom);
void setTilesetEditorTilesZoom(int zoom);
void setShowPlayerView(bool enabled);
void setShowCursorTile(bool enabled);
void setShowBorder(bool enabled);
@ -115,6 +119,8 @@ public:
int getCollisionOpacity();
int getCollisionZoom();
int getMetatilesZoom();
int getTilesetEditorMetatilesZoom();
int getTilesetEditorTilesZoom();
bool getShowPlayerView();
bool getShowCursorTile();
bool getShowBorder();
@ -160,6 +166,8 @@ private:
int collisionOpacity;
int collisionZoom;
int metatilesZoom;
int tilesetEditorMetatilesZoom;
int tilesetEditorTilesZoom;
bool showPlayerView;
bool showCursorTile;
bool showBorder;

View file

@ -115,6 +115,8 @@ private slots:
void on_actionCut_triggered();
void on_actionCopy_triggered();
void on_actionPaste_triggered();
void on_horizontalSlider_MetatilesZoom_valueChanged(int value);
void on_horizontalSlider_TilesZoom_valueChanged(int value);
private:
void initUi();

View file

@ -368,6 +368,10 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
this->metatilesZoom = getConfigInteger(key, value, 10, 100, 30);
} else if (key == "collision_zoom") {
this->collisionZoom = getConfigInteger(key, value, 10, 100, 30);
} else if (key == "tileset_editor_metatiles_zoom") {
this->tilesetEditorMetatilesZoom = getConfigInteger(key, value, 10, 100, 30);
} else if (key == "tileset_editor_tiles_zoom") {
this->tilesetEditorTilesZoom = getConfigInteger(key, value, 10, 100, 30);
} else if (key == "show_player_view") {
this->showPlayerView = getConfigBool(key, value);
} else if (key == "show_cursor_tile") {
@ -427,6 +431,8 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
map.insert("collision_opacity", QString::number(this->collisionOpacity));
map.insert("collision_zoom", QString::number(this->collisionZoom));
map.insert("metatiles_zoom", QString::number(this->metatilesZoom));
map.insert("tileset_editor_metatiles_zoom", QString::number(this->tilesetEditorMetatilesZoom));
map.insert("tileset_editor_tiles_zoom", QString::number(this->tilesetEditorTilesZoom));
map.insert("show_player_view", this->showPlayerView ? "1" : "0");
map.insert("show_cursor_tile", this->showCursorTile ? "1" : "0");
map.insert("show_border", this->showBorder ? "1" : "0");
@ -552,6 +558,16 @@ void PorymapConfig::setMetatilesZoom(int zoom) {
// don't auto-save here because this can be called very frequently.
}
void PorymapConfig::setTilesetEditorMetatilesZoom(int zoom) {
this->tilesetEditorMetatilesZoom = zoom;
// don't auto-save here because this can be called very frequently.
}
void PorymapConfig::setTilesetEditorTilesZoom(int zoom) {
this->tilesetEditorTilesZoom = zoom;
// don't auto-save here because this can be called very frequently.
}
void PorymapConfig::setShowPlayerView(bool enabled) {
this->showPlayerView = enabled;
this->save();
@ -694,6 +710,14 @@ int PorymapConfig::getMetatilesZoom() {
return this->metatilesZoom;
}
int PorymapConfig::getTilesetEditorMetatilesZoom() {
return this->tilesetEditorMetatilesZoom;
}
int PorymapConfig::getTilesetEditorTilesZoom() {
return this->tilesetEditorTilesZoom;
}
bool PorymapConfig::getShowPlayerView() {
return this->showPlayerView;
}

View file

@ -196,7 +196,7 @@ void TilesetEditor::initMetatileSelector()
this->metatileSelector->draw();
this->ui->graphicsView_Metatiles->setScene(this->metatilesScene);
this->ui->graphicsView_Metatiles->setFixedSize(this->metatileSelector->pixmap().width() + 2, this->metatileSelector->pixmap().height() + 2);
this->ui->horizontalSlider_MetatilesZoom->setValue(porymapConfig.getTilesetEditorMetatilesZoom());
}
void TilesetEditor::initMetatileLayersItem() {
@ -236,7 +236,7 @@ void TilesetEditor::initTileSelector()
this->tileSelector->draw();
this->ui->graphicsView_Tiles->setScene(this->tilesScene);
this->ui->graphicsView_Tiles->setFixedSize(this->tileSelector->pixmap().width() + 2, this->tileSelector->pixmap().height() + 2);
this->ui->horizontalSlider_TilesZoom->setValue(porymapConfig.getTilesetEditorTilesZoom());
}
void TilesetEditor::initSelectedTileItem() {
@ -1182,3 +1182,31 @@ void TilesetEditor::on_copyButton_metatileLabel_clicked() {
QGuiApplication::clipboard()->setText(label);
QToolTip::showText(this->ui->copyButton_metatileLabel->mapToGlobal(QPoint(0, 0)), "Copied!");
}
void TilesetEditor::on_horizontalSlider_MetatilesZoom_valueChanged(int value) {
porymapConfig.setTilesetEditorMetatilesZoom(value);
double scale = pow(3.0, static_cast<double>(value - 30) / 30.0);
QTransform transform;
transform.scale(scale, scale);
QSize size(this->metatileSelector->pixmap().width(), this->metatileSelector->pixmap().height());
size *= scale;
this->ui->graphicsView_Metatiles->setResizeAnchor(QGraphicsView::NoAnchor);
this->ui->graphicsView_Metatiles->setTransform(transform);
this->ui->graphicsView_Metatiles->setFixedSize(size.width() + 2, size.height() + 2);
}
void TilesetEditor::on_horizontalSlider_TilesZoom_valueChanged(int value) {
porymapConfig.setTilesetEditorTilesZoom(value);
double scale = pow(3.0, static_cast<double>(value - 30) / 30.0);
QTransform transform;
transform.scale(scale, scale);
QSize size(this->tileSelector->pixmap().width(), this->tileSelector->pixmap().height());
size *= scale;
this->ui->graphicsView_Tiles->setResizeAnchor(QGraphicsView::NoAnchor);
this->ui->graphicsView_Tiles->setTransform(transform);
this->ui->graphicsView_Tiles->setFixedSize(size.width() + 2, size.height() + 2);
}