mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-13 07:14:49 +00:00
overlays: add optional sound to trophy popup
This commit is contained in:
parent
f262e77fbd
commit
0e20acdf55
@ -175,6 +175,9 @@ namespace rsx
|
|||||||
fade_animation.active = true;
|
fade_animation.active = true;
|
||||||
|
|
||||||
visible = true;
|
visible = true;
|
||||||
|
|
||||||
|
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/trophy.wav");
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
} // namespace overlays
|
} // namespace overlays
|
||||||
|
@ -80,6 +80,7 @@ struct EmuCallbacks
|
|||||||
std::function<std::unique_ptr<class TrophyNotificationBase>()> get_trophy_notification_dialog;
|
std::function<std::unique_ptr<class TrophyNotificationBase>()> get_trophy_notification_dialog;
|
||||||
std::function<std::string(localized_string_id, const char*)> get_localized_string;
|
std::function<std::string(localized_string_id, const char*)> get_localized_string;
|
||||||
std::function<std::u32string(localized_string_id, const char*)> get_localized_u32string;
|
std::function<std::u32string(localized_string_id, const char*)> get_localized_u32string;
|
||||||
|
std::function<void(const std::string&)> play_sound;
|
||||||
std::string(*resolve_path)(std::string_view) = nullptr; // Resolve path using Qt
|
std::string(*resolve_path)(std::string_view) = nullptr; // Resolve path using Qt
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,6 +110,8 @@ void headless_application::InitializeCallbacks()
|
|||||||
callbacks.get_localized_string = [](localized_string_id, const char*) -> std::string { return {}; };
|
callbacks.get_localized_string = [](localized_string_id, const char*) -> std::string { return {}; };
|
||||||
callbacks.get_localized_u32string = [](localized_string_id, const char*) -> std::u32string { return {}; };
|
callbacks.get_localized_u32string = [](localized_string_id, const char*) -> std::u32string { return {}; };
|
||||||
|
|
||||||
|
callbacks.play_sound = [](const std::string&){};
|
||||||
|
|
||||||
callbacks.resolve_path = [](std::string_view sv)
|
callbacks.resolve_path = [](std::string_view sv)
|
||||||
{
|
{
|
||||||
return QFileInfo(QString::fromUtf8(sv.data(), static_cast<int>(sv.size()))).canonicalFilePath().toStdString();
|
return QFileInfo(QString::fromUtf8(sv.data(), static_cast<int>(sv.size()))).canonicalFilePath().toStdString();
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QSound>
|
||||||
|
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
|
||||||
@ -412,6 +413,17 @@ void gui_application::InitializeCallbacks()
|
|||||||
return localized_emu::get_u32string(id, args);
|
return localized_emu::get_u32string(id, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
callbacks.play_sound = [](const std::string& path)
|
||||||
|
{
|
||||||
|
Emu.CallAfter([path]()
|
||||||
|
{
|
||||||
|
if (fs::is_file(path))
|
||||||
|
{
|
||||||
|
QSound::play(qstr(path));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
callbacks.resolve_path = [](std::string_view sv)
|
callbacks.resolve_path = [](std::string_view sv)
|
||||||
{
|
{
|
||||||
return QFileInfo(QString::fromUtf8(sv.data(), static_cast<int>(sv.size()))).canonicalFilePath().toStdString();
|
return QFileInfo(QString::fromUtf8(sv.data(), static_cast<int>(sv.size()))).canonicalFilePath().toStdString();
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include "../Emu/System.h"
|
#include "../Emu/System.h"
|
||||||
#include "../Emu/RSX/Overlays/overlay_trophy_notification.h"
|
#include "../Emu/RSX/Overlays/overlay_trophy_notification.h"
|
||||||
|
|
||||||
|
#include "Utilities/File.h"
|
||||||
|
|
||||||
s32 trophy_notification_helper::ShowTrophyNotification(const SceNpTrophyDetails& trophy, const std::vector<uchar>& trophy_icon_buffer)
|
s32 trophy_notification_helper::ShowTrophyNotification(const SceNpTrophyDetails& trophy, const std::vector<uchar>& trophy_icon_buffer)
|
||||||
{
|
{
|
||||||
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
|
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
|
||||||
@ -26,6 +28,8 @@ s32 trophy_notification_helper::ShowTrophyNotification(const SceNpTrophyDetails&
|
|||||||
// Move notification to upper lefthand corner
|
// Move notification to upper lefthand corner
|
||||||
trophy_notification->move(m_game_window->mapToGlobal(QPoint(0, 0)));
|
trophy_notification->move(m_game_window->mapToGlobal(QPoint(0, 0)));
|
||||||
trophy_notification->show();
|
trophy_notification->show();
|
||||||
|
|
||||||
|
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/trophy.wav");
|
||||||
});
|
});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user