2020-12-05 13:08:24 +01:00
|
|
|
#include "trophy_notification_helper.h"
|
2017-10-24 17:43:05 +02:00
|
|
|
#include "trophy_notification_frame.h"
|
|
|
|
|
|
2020-11-06 18:45:06 +01:00
|
|
|
#include "../Emu/IdManager.h"
|
2018-01-17 17:14:00 +01:00
|
|
|
#include "../Emu/System.h"
|
2020-02-25 22:42:29 +01:00
|
|
|
#include "../Emu/RSX/Overlays/overlay_trophy_notification.h"
|
2018-01-17 17:14:00 +01:00
|
|
|
|
2021-10-29 22:04:49 +02:00
|
|
|
#include "Utilities/File.h"
|
|
|
|
|
|
2017-10-24 17:43:05 +02:00
|
|
|
s32 trophy_notification_helper::ShowTrophyNotification(const SceNpTrophyDetails& trophy, const std::vector<uchar>& trophy_icon_buffer)
|
|
|
|
|
{
|
2021-02-03 19:14:31 +01:00
|
|
|
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
|
2018-01-17 17:14:00 +01:00
|
|
|
{
|
2020-01-03 18:43:00 +01:00
|
|
|
// Allow adding more than one trophy notification. The notification class manages scheduling
|
|
|
|
|
auto popup = std::make_shared<rsx::overlays::trophy_notification>();
|
|
|
|
|
return manager->add(popup, false)->show(trophy, trophy_icon_buffer);
|
2018-01-17 17:14:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-12-03 08:32:28 +01:00
|
|
|
if (!Emu.HasGui())
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-20 18:44:49 +01:00
|
|
|
Emu.CallFromMainThread([=, this]
|
2018-01-17 17:14:00 +01:00
|
|
|
{
|
|
|
|
|
trophy_notification_frame* trophy_notification = new trophy_notification_frame(trophy_icon_buffer, trophy, m_game_window->frameGeometry().height() / 10);
|
2017-10-24 17:43:05 +02:00
|
|
|
|
2018-01-17 17:14:00 +01:00
|
|
|
// Move notification to upper lefthand corner
|
|
|
|
|
trophy_notification->move(m_game_window->mapToGlobal(QPoint(0, 0)));
|
|
|
|
|
trophy_notification->show();
|
2021-10-29 22:04:49 +02:00
|
|
|
|
2021-10-31 00:48:41 +02:00
|
|
|
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_trophy.wav");
|
2018-01-17 17:14:00 +01:00
|
|
|
});
|
2017-10-24 17:43:05 +02:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|