mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-07 15:46:01 +00:00
Add volume slider for title/background music (#1130)
* add volume slider * add translations * stop music when checkbox unchecked * remove GUI build command args * combine functions * add accidentaly removed copyright and licencing information (thanks QT Designer)
This commit is contained in:
parent
9be3355d11
commit
242e4a0117
|
@ -32,6 +32,7 @@ namespace Config {
|
|||
static bool isNeo = false;
|
||||
static bool isFullscreen = false;
|
||||
static bool playBGM = false;
|
||||
static int BGMvolume = 50;
|
||||
static u32 screenWidth = 1280;
|
||||
static u32 screenHeight = 720;
|
||||
static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto select
|
||||
|
@ -89,6 +90,10 @@ bool getPlayBGM() {
|
|||
return playBGM;
|
||||
}
|
||||
|
||||
int getBGMvolume() {
|
||||
return BGMvolume;
|
||||
}
|
||||
|
||||
u32 getScreenWidth() {
|
||||
return screenWidth;
|
||||
}
|
||||
|
@ -249,6 +254,10 @@ void setPlayBGM(bool enable) {
|
|||
playBGM = enable;
|
||||
}
|
||||
|
||||
void setBGMvolume(int volume) {
|
||||
BGMvolume = volume;
|
||||
}
|
||||
|
||||
void setLanguage(u32 language) {
|
||||
m_language = language;
|
||||
}
|
||||
|
@ -412,6 +421,7 @@ void load(const std::filesystem::path& path) {
|
|||
isNeo = toml::find_or<bool>(general, "isPS4Pro", false);
|
||||
isFullscreen = toml::find_or<bool>(general, "Fullscreen", false);
|
||||
playBGM = toml::find_or<bool>(general, "playBGM", false);
|
||||
BGMvolume = toml::find_or<int>(general, "BGMvolume", 50);
|
||||
logFilter = toml::find_or<std::string>(general, "logFilter", "");
|
||||
logType = toml::find_or<std::string>(general, "logType", "sync");
|
||||
userName = toml::find_or<std::string>(general, "userName", "shadPS4");
|
||||
|
@ -513,6 +523,7 @@ void save(const std::filesystem::path& path) {
|
|||
data["General"]["isPS4Pro"] = isNeo;
|
||||
data["General"]["Fullscreen"] = isFullscreen;
|
||||
data["General"]["playBGM"] = playBGM;
|
||||
data["General"]["BGMvolume"] = BGMvolume;
|
||||
data["General"]["logFilter"] = logFilter;
|
||||
data["General"]["logType"] = logType;
|
||||
data["General"]["userName"] = userName;
|
||||
|
@ -565,6 +576,7 @@ void setDefaultValues() {
|
|||
isNeo = false;
|
||||
isFullscreen = false;
|
||||
playBGM = false;
|
||||
BGMvolume = 50;
|
||||
screenWidth = 1280;
|
||||
screenHeight = 720;
|
||||
logFilter = "";
|
||||
|
|
|
@ -14,6 +14,8 @@ void save(const std::filesystem::path& path);
|
|||
bool isNeoMode();
|
||||
bool isFullscreenMode();
|
||||
bool getPlayBGM();
|
||||
int getBGMvolume();
|
||||
|
||||
std::string getLogFilter();
|
||||
std::string getLogType();
|
||||
std::string getUserName();
|
||||
|
@ -49,6 +51,7 @@ void setScreenWidth(u32 width);
|
|||
void setScreenHeight(u32 height);
|
||||
void setFullscreenMode(bool enable);
|
||||
void setPlayBGM(bool enable);
|
||||
void setBGMvolume(int volume);
|
||||
void setLanguage(u32 language);
|
||||
void setNeoMode(bool enable);
|
||||
void setUserName(const std::string& type);
|
||||
|
|
|
@ -10,6 +10,12 @@ BackgroundMusicPlayer::BackgroundMusicPlayer(QObject* parent) : QObject(parent)
|
|||
m_mediaPlayer->setLoops(QMediaPlayer::Infinite);
|
||||
}
|
||||
|
||||
void BackgroundMusicPlayer::setVolume(int volume) {
|
||||
float linearVolume = QAudio::convertVolume(volume / 100.0f, QAudio::LogarithmicVolumeScale,
|
||||
QAudio::LinearVolumeScale);
|
||||
m_audioOutput->setVolume(linearVolume);
|
||||
}
|
||||
|
||||
void BackgroundMusicPlayer::playMusic(const QString& snd0path) {
|
||||
if (snd0path.isEmpty()) {
|
||||
stopMusic();
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
return instance;
|
||||
}
|
||||
|
||||
void setVolume(int volume);
|
||||
void playMusic(const QString& snd0path);
|
||||
void stopMusic();
|
||||
|
||||
|
@ -25,4 +26,4 @@ private:
|
|||
QMediaPlayer* m_mediaPlayer;
|
||||
QAudioOutput* m_audioOutput;
|
||||
QUrl m_currentMusic;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -527,7 +527,11 @@ void MainWindow::PlayBackgroundMusic() {
|
|||
int itemID = isTableList ? m_game_list_frame->currentItem()->row()
|
||||
: m_game_grid_frame->crtRow * m_game_grid_frame->columnCnt +
|
||||
m_game_grid_frame->crtColumn;
|
||||
|
||||
if (itemID > m_game_info->m_games.size() - 1) {
|
||||
// Can happen in grid mode
|
||||
BackgroundMusicPlayer::getInstance().stopMusic();
|
||||
return;
|
||||
}
|
||||
QString snd0path;
|
||||
Common::FS::PathToQString(snd0path, m_game_info->m_games[itemID].snd0_path);
|
||||
BackgroundMusicPlayer::getInstance().playMusic(snd0path);
|
||||
|
@ -619,6 +623,7 @@ void MainWindow::ConfigureGuiFromSettings() {
|
|||
} else {
|
||||
ui->setlistModeGridAct->setChecked(true);
|
||||
}
|
||||
BackgroundMusicPlayer::getInstance().setVolume(Config::getBGMvolume());
|
||||
}
|
||||
|
||||
void MainWindow::SaveWindowState() const {
|
||||
|
|
|
@ -140,8 +140,17 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
|
|||
checkUpdate->exec();
|
||||
});
|
||||
|
||||
connect(ui->playBGMCheckBox, &QCheckBox::stateChanged, this,
|
||||
[](int val) { Config::setPlayBGM(val); });
|
||||
connect(ui->playBGMCheckBox, &QCheckBox::stateChanged, this, [](int val) {
|
||||
Config::setPlayBGM(val);
|
||||
if (val == Qt::Unchecked) {
|
||||
BackgroundMusicPlayer::getInstance().stopMusic();
|
||||
}
|
||||
});
|
||||
|
||||
connect(ui->BGMVolumeSlider, &QSlider::valueChanged, this, [](float val) {
|
||||
Config::setBGMvolume(val);
|
||||
BackgroundMusicPlayer::getInstance().setVolume(val);
|
||||
});
|
||||
}
|
||||
|
||||
// GPU TAB
|
||||
|
@ -231,6 +240,7 @@ void SettingsDialog::LoadValuesFromConfig() {
|
|||
ui->nullGpuCheckBox->setChecked(Config::nullGpu());
|
||||
ui->dumpPM4CheckBox->setChecked(Config::dumpPM4());
|
||||
ui->playBGMCheckBox->setChecked(Config::getPlayBGM());
|
||||
ui->BGMVolumeSlider->setValue((Config::getBGMvolume()));
|
||||
ui->fullscreenCheckBox->setChecked(Config::isFullscreenMode());
|
||||
ui->showSplashCheckBox->setChecked(Config::showSplash());
|
||||
ui->ps4proCheckBox->setChecked(Config::isNeoMode());
|
||||
|
@ -371,4 +381,4 @@ bool SettingsDialog::eventFilter(QObject* obj, QEvent* event) {
|
|||
}
|
||||
}
|
||||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>836</width>
|
||||
<height>442</height>
|
||||
<height>446</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -369,7 +369,7 @@
|
|||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>241</width>
|
||||
<height>41</height>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
|
@ -386,6 +386,55 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Volume</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="BGMVolumeSlider">
|
||||
<property name="toolTip">
|
||||
<string>Set the volume of the background music.</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TickPosition::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>تشغيل موسيقى العنوان</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>الصوت</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Afspil titelsang</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Lydstyrke</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Titelmusik abspielen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Lautstärke</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Αναπαραγωγή μουσικής τίτλου</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>ένταση</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Play title music</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volume</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Reproducir la música de apertura</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volumen</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>پخش موسیقی عنوان</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>صدا </translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Soita otsikkomusiikkia</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Äänenvoimakkuus</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Lire la musique du titre</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volume</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Címzene lejátszása</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Hangerő</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Putar musik judul</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volume</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Riproduci musica del titolo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volume</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>タイトル音楽を再生する</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>音量</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Play title music</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>음량</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Groti antraštės muziką</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Garsumas</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Spill tittelmusikk</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volum</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Titelmuziek afspelen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volume</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Odtwórz muzykę tytułową</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Głośność</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Reproduzir música de abertura</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volume</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Redă muzica titlului</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volum</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Воспроизведение заглавной музыки</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Громкость</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Luaj muzikën e titullit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Volumi</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Başlık müziğini çal</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Ses seviyesi</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>Phát nhạc tiêu đề</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>Âm lượng</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>播放标题音乐</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>音量</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
|
@ -534,6 +534,11 @@
|
|||
<source>Play title music</source>
|
||||
<translation>播放標題音樂</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="394"/>
|
||||
<source>Volume</source>
|
||||
<translation>音量</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
|
Loading…
Reference in a new issue