Skip to content

Commit

Permalink
Maps: Enable changing map panorama
Browse files Browse the repository at this point in the history
The map panorama can be changed now.
  • Loading branch information
rueter37 committed Nov 30, 2021
1 parent c39d400 commit 399dddb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/ui/maptree/map_properties_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "common/dbstring.h"
#include "ui/picker/picker_audio_widget.h"
#include "ui/picker/picker_backdrop_widget.h"
#include "ui/picker/picker_panorama_widget.h"
#include "ui/picker/picker_dialog.h"

MapPropertiesDialog::MapPropertiesDialog(ProjectData& project, lcf::rpg::MapInfo &info, lcf::rpg::Map &map, QWidget *parent) :
Expand Down Expand Up @@ -211,6 +212,7 @@ MapPropertiesDialog::MapPropertiesDialog(ProjectData& project, lcf::rpg::MapInfo
ui->radioEscapeParent->setEnabled(false);
}

new_panorama = map.parallax_name;
new_music = info.music;
}

Expand All @@ -236,6 +238,25 @@ void MapPropertiesDialog::ok() {
m_map.width = ui->spinWidth->value();
m_map.height = ui->spinHeight->value();
m_map.scroll_type = ui->comboWrapping->currentIndex();
if (ui->groupPanorama->isChecked()) {
m_map.parallax_flag = true;
m_map.parallax_name = new_panorama;
m_map.parallax_loop_x = ui->groupHorizontalScroll->isChecked();
m_map.parallax_loop_y = ui->groupVerticalScroll->isChecked();
m_map.parallax_auto_loop_x = ui->checkHorizontalAutoscroll->isChecked();
m_map.parallax_auto_loop_y = ui->checkVerticalAutoscroll->isChecked();
m_map.parallax_sx = ui->spinHorizontalScrollSpeed->value();
m_map.parallax_sy = ui->spinVerticalScrollSpeed->value();
} else {
m_map.parallax_flag = false;
m_map.parallax_name = ToDBString("");
m_map.parallax_loop_x = false;
m_map.parallax_loop_y = false;
m_map.parallax_auto_loop_x = false;
m_map.parallax_auto_loop_y = false;
m_map.parallax_sx = 0;
m_map.parallax_sy = 0;
}
if (ui->radioBGMparent->isChecked()) {
m_info.music_type = 0;
} else if (ui->radioBGMevent->isChecked()) {
Expand Down Expand Up @@ -343,6 +364,24 @@ void MapPropertiesDialog::on_tableEncounters_itemChanged(QTableWidgetItem *item)
}
}

void MapPropertiesDialog::on_pushSetPanorama_clicked() {
auto* widget = new PickerPanoramaWidget(this);
PickerDialog dialog(m_project, FileFinder::FileType::Image, widget, this);
QObject::connect(&dialog, &PickerDialog::fileSelected, [&](const QString& baseName) {
new_panorama = ToDBString(baseName);
});
dialog.setDirectoryAndFile(PANORAMA, ToQString(new_panorama));
dialog.exec();

if (!new_panorama.empty()) {
QPixmap pix = QPixmap(m_project.project().findFile(PANORAMA, ToQString(new_panorama), FileFinder::FileType::Image));
if (!pix) {
pix = QPixmap(core().rtpPath(PANORAMA, ToQString(new_panorama)));
}
m_panoramaItem->setPixmap(pix);
}
}

void MapPropertiesDialog::on_toolSetBGM_clicked() {
auto* widget = new PickerAudioWidget(new_music, this);
PickerDialog dialog(m_project, FileFinder::FileType::Music, widget, this);
Expand Down
3 changes: 3 additions & 0 deletions src/ui/maptree/map_properties_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ private slots:

void on_tableEncounters_itemChanged(QTableWidgetItem *item);

void on_pushSetPanorama_clicked();

void on_toolSetBGM_clicked();

void on_toolSetBackdrop_clicked();
Expand Down Expand Up @@ -85,6 +87,7 @@ private slots:

ProjectData& m_project;

lcf::DBString new_panorama;
lcf::rpg::Music new_music;
};

0 comments on commit 399dddb

Please sign in to comment.