Skip to content

Commit

Permalink
Maps: Enable changing map BGM
Browse files Browse the repository at this point in the history
The map BGM can be changed now.
  • Loading branch information
rueter37 committed Nov 30, 2021
1 parent 4f87062 commit a90d338
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/ui/maptree/map_properties_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "ui_map_properties_dialog.h"
#include "core.h"
#include "common/dbstring.h"
#include "ui/picker/picker_audio_widget.h"
#include "ui/picker/picker_dialog.h"

MapPropertiesDialog::MapPropertiesDialog(ProjectData& project, lcf::rpg::MapInfo &info, lcf::rpg::Map &map, QWidget *parent) :
QDialog(parent),
Expand Down Expand Up @@ -207,6 +209,8 @@ MapPropertiesDialog::MapPropertiesDialog(ProjectData& project, lcf::rpg::MapInfo
ui->radioSaveParent->setEnabled(false);
ui->radioEscapeParent->setEnabled(false);
}

new_music = info.music;
}

MapPropertiesDialog::~MapPropertiesDialog()
Expand All @@ -231,6 +235,15 @@ void MapPropertiesDialog::ok() {
m_map.width = ui->spinWidth->value();
m_map.height = ui->spinHeight->value();
m_map.scroll_type = ui->comboWrapping->currentIndex();
if (ui->radioBGMparent->isChecked()) {
m_info.music_type = 0;
} else if (ui->radioBGMevent->isChecked()) {
m_info.music_type = 1;
} else {
m_info.music_type = 2;
}
new_music.name = ui->lineBGMname->text().toStdString();
m_info.music = new_music;
if (ui->radioTeleportParent->isChecked()) {
m_info.teleport = 0;
} else if (ui->radioTeleportAllow->isChecked()) {
Expand Down Expand Up @@ -320,3 +333,18 @@ void MapPropertiesDialog::on_tableEncounters_itemChanged(QTableWidgetItem *item)
item->setData(Qt::DisplayRole, "<Add Encounter>");
}
}

void MapPropertiesDialog::on_toolSetBGM_clicked() {
auto* widget = new PickerAudioWidget(new_music, this);
PickerDialog dialog(m_project, FileFinder::FileType::Music, widget, this);
QObject::connect(&dialog, &PickerDialog::fileSelected, [&](const QString& baseName) {
ui->lineBGMname->setText(baseName);
new_music.name = baseName.toStdString();
new_music.fadein = widget->fadeInTime();
new_music.volume = widget->volume();
new_music.tempo = widget->tempo();
new_music.balance = widget->balance();
});
dialog.setDirectoryAndFile(MUSIC, ui->lineBGMname->text());
dialog.exec();
}
4 changes: 4 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_toolSetBGM_clicked();

private:
Ui::MapPropertiesDialog *ui;

Expand All @@ -80,5 +82,7 @@ private slots:
std::vector<short> m_generatorUpperLayer;

ProjectData& m_project;

lcf::rpg::Music new_music;
};

0 comments on commit a90d338

Please sign in to comment.