Save metatile zoom in config

This commit is contained in:
Marcus Huderle 2019-02-16 14:32:19 -06:00 committed by huderlem
parent f587e03a49
commit b2742498d1
3 changed files with 27 additions and 0 deletions

View file

@ -33,6 +33,7 @@ public:
this->mapSortOrder = MapSortOrder::Group;
this->prettyCursors = true;
this->collisionOpacity = 50;
this->metatilesZoom = 30;
this->showPlayerView = false;
this->showCursorTile = true;
}
@ -42,6 +43,7 @@ public:
void setPrettyCursors(bool enabled);
void setGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray);
void setCollisionOpacity(int opacity);
void setMetatilesZoom(int zoom);
void setShowPlayerView(bool enabled);
void setShowCursorTile(bool enabled);
QString getRecentProject();
@ -50,6 +52,7 @@ public:
bool getPrettyCursors();
QMap<QString, QByteArray> getGeometry();
int getCollisionOpacity();
int getMetatilesZoom();
bool getShowPlayerView();
bool getShowCursorTile();
protected:
@ -70,6 +73,7 @@ private:
QByteArray eventsSlpitterState;
QByteArray mainSplitterState;
int collisionOpacity;
int metatilesZoom;
bool showPlayerView;
bool showCursorTile;
};

View file

@ -137,6 +137,13 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
logWarn(QString("Invalid config value for collision_opacity: '%1'. Must be an integer.").arg(value));
this->collisionOpacity = 50;
}
} else if (key == "metatiles_zoom") {
bool ok;
this->metatilesZoom = qMax(10, qMin(100, value.toInt(&ok)));
if (!ok) {
logWarn(QString("Invalid config value for metatiles_zoom: '%1'. Must be an integer.").arg(value));
this->metatilesZoom = 30;
}
} else if (key == "show_player_view") {
bool ok;
this->showPlayerView = value.toInt(&ok);
@ -166,6 +173,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
map.insert("events_splitter_state", stringFromByteArray(this->eventsSlpitterState));
map.insert("main_splitter_state", stringFromByteArray(this->mainSplitterState));
map.insert("collision_opacity", QString("%1").arg(this->collisionOpacity));
map.insert("metatiles_zoom", QString("%1").arg(this->metatilesZoom));
map.insert("show_player_view", this->showPlayerView ? "1" : "0");
map.insert("show_cursor_tile", this->showCursorTile ? "1" : "0");
return map;
@ -223,6 +231,11 @@ void PorymapConfig::setCollisionOpacity(int opacity) {
// don't auto-save here because this can be called very frequently.
}
void PorymapConfig::setMetatilesZoom(int zoom) {
this->metatilesZoom = zoom;
// don't auto-save here because this can be called very frequently.
}
void PorymapConfig::setShowPlayerView(bool enabled) {
this->showPlayerView = enabled;
this->save();
@ -265,6 +278,10 @@ int PorymapConfig::getCollisionOpacity() {
return this->collisionOpacity;
}
int PorymapConfig::getMetatilesZoom() {
return this->metatilesZoom;
}
bool PorymapConfig::getShowPlayerView() {
return this->showPlayerView;
}

View file

@ -216,6 +216,9 @@ void MainWindow::loadUserSettings() {
this->editor->collisionOpacity = static_cast<qreal>(porymapConfig.getCollisionOpacity()) / 100;
ui->horizontalSlider_CollisionTransparency->setValue(porymapConfig.getCollisionOpacity());
ui->horizontalSlider_CollisionTransparency->blockSignals(false);
ui->horizontalSlider_MetatileZoom->blockSignals(true);
ui->horizontalSlider_MetatileZoom->setValue(porymapConfig.getMetatilesZoom());
ui->horizontalSlider_MetatileZoom->blockSignals(false);
}
void MainWindow::restoreWindowState() {
@ -397,6 +400,8 @@ void MainWindow::redrawMapScene()
ui->graphicsView_Collision->setScene(editor->scene_collision_metatiles);
//ui->graphicsView_Collision->setSceneRect(editor->scene_collision_metatiles->sceneRect());
ui->graphicsView_Collision->setFixedSize(editor->movement_permissions_selector_item->pixmap().width() + 2, editor->movement_permissions_selector_item->pixmap().height() + 2);
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
}
void MainWindow::openWarpMap(QString map_name, QString warp_num) {
@ -1960,6 +1965,7 @@ void MainWindow::on_tableWidget_CustomHeaderFields_cellChanged(int row, int colu
}
void MainWindow::on_horizontalSlider_MetatileZoom_valueChanged(int value) {
porymapConfig.setMetatilesZoom(value);
double scale = pow(3.0, static_cast<double>(value - 30) / 30.0);
QMatrix matrix;