Add zoom sliders to the Tileset Editor
This commit is contained in:
parent
3d3811f3b1
commit
bcba146be9
5 changed files with 642 additions and 509 deletions
File diff suppressed because it is too large
Load diff
|
@ -58,6 +58,8 @@ public:
|
||||||
this->collisionOpacity = 50;
|
this->collisionOpacity = 50;
|
||||||
this->collisionZoom = 30;
|
this->collisionZoom = 30;
|
||||||
this->metatilesZoom = 30;
|
this->metatilesZoom = 30;
|
||||||
|
this->tilesetEditorMetatilesZoom = 30;
|
||||||
|
this->tilesetEditorTilesZoom = 30;
|
||||||
this->showPlayerView = false;
|
this->showPlayerView = false;
|
||||||
this->showCursorTile = true;
|
this->showCursorTile = true;
|
||||||
this->showBorder = true;
|
this->showBorder = true;
|
||||||
|
@ -87,6 +89,8 @@ public:
|
||||||
void setCollisionOpacity(int opacity);
|
void setCollisionOpacity(int opacity);
|
||||||
void setCollisionZoom(int zoom);
|
void setCollisionZoom(int zoom);
|
||||||
void setMetatilesZoom(int zoom);
|
void setMetatilesZoom(int zoom);
|
||||||
|
void setTilesetEditorMetatilesZoom(int zoom);
|
||||||
|
void setTilesetEditorTilesZoom(int zoom);
|
||||||
void setShowPlayerView(bool enabled);
|
void setShowPlayerView(bool enabled);
|
||||||
void setShowCursorTile(bool enabled);
|
void setShowCursorTile(bool enabled);
|
||||||
void setShowBorder(bool enabled);
|
void setShowBorder(bool enabled);
|
||||||
|
@ -115,6 +119,8 @@ public:
|
||||||
int getCollisionOpacity();
|
int getCollisionOpacity();
|
||||||
int getCollisionZoom();
|
int getCollisionZoom();
|
||||||
int getMetatilesZoom();
|
int getMetatilesZoom();
|
||||||
|
int getTilesetEditorMetatilesZoom();
|
||||||
|
int getTilesetEditorTilesZoom();
|
||||||
bool getShowPlayerView();
|
bool getShowPlayerView();
|
||||||
bool getShowCursorTile();
|
bool getShowCursorTile();
|
||||||
bool getShowBorder();
|
bool getShowBorder();
|
||||||
|
@ -160,6 +166,8 @@ private:
|
||||||
int collisionOpacity;
|
int collisionOpacity;
|
||||||
int collisionZoom;
|
int collisionZoom;
|
||||||
int metatilesZoom;
|
int metatilesZoom;
|
||||||
|
int tilesetEditorMetatilesZoom;
|
||||||
|
int tilesetEditorTilesZoom;
|
||||||
bool showPlayerView;
|
bool showPlayerView;
|
||||||
bool showCursorTile;
|
bool showCursorTile;
|
||||||
bool showBorder;
|
bool showBorder;
|
||||||
|
|
|
@ -115,6 +115,8 @@ private slots:
|
||||||
void on_actionCut_triggered();
|
void on_actionCut_triggered();
|
||||||
void on_actionCopy_triggered();
|
void on_actionCopy_triggered();
|
||||||
void on_actionPaste_triggered();
|
void on_actionPaste_triggered();
|
||||||
|
void on_horizontalSlider_MetatilesZoom_valueChanged(int value);
|
||||||
|
void on_horizontalSlider_TilesZoom_valueChanged(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initUi();
|
void initUi();
|
||||||
|
|
|
@ -367,6 +367,10 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
this->metatilesZoom = getConfigInteger(key, value, 10, 100, 30);
|
this->metatilesZoom = getConfigInteger(key, value, 10, 100, 30);
|
||||||
} else if (key == "collision_zoom") {
|
} else if (key == "collision_zoom") {
|
||||||
this->collisionZoom = getConfigInteger(key, value, 10, 100, 30);
|
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") {
|
} else if (key == "show_player_view") {
|
||||||
this->showPlayerView = getConfigBool(key, value);
|
this->showPlayerView = getConfigBool(key, value);
|
||||||
} else if (key == "show_cursor_tile") {
|
} else if (key == "show_cursor_tile") {
|
||||||
|
@ -426,6 +430,8 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
||||||
map.insert("collision_opacity", QString::number(this->collisionOpacity));
|
map.insert("collision_opacity", QString::number(this->collisionOpacity));
|
||||||
map.insert("collision_zoom", QString::number(this->collisionZoom));
|
map.insert("collision_zoom", QString::number(this->collisionZoom));
|
||||||
map.insert("metatiles_zoom", QString::number(this->metatilesZoom));
|
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_player_view", this->showPlayerView ? "1" : "0");
|
||||||
map.insert("show_cursor_tile", this->showCursorTile ? "1" : "0");
|
map.insert("show_cursor_tile", this->showCursorTile ? "1" : "0");
|
||||||
map.insert("show_border", this->showBorder ? "1" : "0");
|
map.insert("show_border", this->showBorder ? "1" : "0");
|
||||||
|
@ -551,6 +557,16 @@ void PorymapConfig::setMetatilesZoom(int zoom) {
|
||||||
// don't auto-save here because this can be called very frequently.
|
// 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) {
|
void PorymapConfig::setShowPlayerView(bool enabled) {
|
||||||
this->showPlayerView = enabled;
|
this->showPlayerView = enabled;
|
||||||
this->save();
|
this->save();
|
||||||
|
@ -693,6 +709,14 @@ int PorymapConfig::getMetatilesZoom() {
|
||||||
return this->metatilesZoom;
|
return this->metatilesZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PorymapConfig::getTilesetEditorMetatilesZoom() {
|
||||||
|
return this->tilesetEditorMetatilesZoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PorymapConfig::getTilesetEditorTilesZoom() {
|
||||||
|
return this->tilesetEditorTilesZoom;
|
||||||
|
}
|
||||||
|
|
||||||
bool PorymapConfig::getShowPlayerView() {
|
bool PorymapConfig::getShowPlayerView() {
|
||||||
return this->showPlayerView;
|
return this->showPlayerView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ void TilesetEditor::initMetatileSelector()
|
||||||
this->metatileSelector->draw();
|
this->metatileSelector->draw();
|
||||||
|
|
||||||
this->ui->graphicsView_Metatiles->setScene(this->metatilesScene);
|
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() {
|
void TilesetEditor::initMetatileLayersItem() {
|
||||||
|
@ -232,7 +232,7 @@ void TilesetEditor::initTileSelector()
|
||||||
this->tileSelector->draw();
|
this->tileSelector->draw();
|
||||||
|
|
||||||
this->ui->graphicsView_Tiles->setScene(this->tilesScene);
|
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() {
|
void TilesetEditor::initSelectedTileItem() {
|
||||||
|
@ -1177,3 +1177,31 @@ void TilesetEditor::on_copyButton_metatileLabel_clicked() {
|
||||||
QGuiApplication::clipboard()->setText(label);
|
QGuiApplication::clipboard()->setText(label);
|
||||||
QToolTip::showText(this->ui->copyButton_metatileLabel->mapToGlobal(QPoint(0, 0)), "Copied!");
|
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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue