Skip to content

Commit 1c22cc2

Browse files
committed
overlays: add trophy list dialog
1 parent 0bb2f72 commit 1c22cc2

18 files changed

+545
-34
lines changed

rpcs3/Emu/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ target_sources(rpcs3_emu PRIVATE
528528
RSX/Overlays/HomeMenu/overlay_home_menu_savestate.cpp
529529
RSX/Overlays/Network/overlay_recvmessage_dialog.cpp
530530
RSX/Overlays/Network/overlay_sendmessage_dialog.cpp
531+
RSX/Overlays/Trophies/overlay_trophy_list_dialog.cpp
531532
RSX/Overlays/overlays.cpp
532533
RSX/Overlays/overlay_animated_icon.cpp
533534
RSX/Overlays/overlay_animation.cpp

rpcs3/Emu/Cell/Modules/sceNp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5214,7 +5214,7 @@ error_code sceNpProfileCallGui(vm::cptr<SceNpId> npid, vm::ptr<SceNpProfileResul
52145214

52155215
if (!nph.is_NP_init)
52165216
{
5217-
return SCE_NP_ERROR_NOT_INITIALIZED;
5217+
return SCE_NP_PROFILE_ERROR_NOT_INITIALIZED;
52185218
}
52195219

52205220
// TODO: SCE_NP_PROFILE_ERROR_BUSY
@@ -5240,7 +5240,7 @@ error_code sceNpProfileAbortGui()
52405240

52415241
if (!nph.is_NP_init)
52425242
{
5243-
return SCE_NP_ERROR_NOT_INITIALIZED;
5243+
return SCE_NP_FRIENDLIST_ERROR_NOT_INITIALIZED; // Not SCE_NP_PROFILE_ERROR_NOT_INITIALIZED !
52445244
}
52455245

52465246
return CELL_OK;

rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,17 @@ error_code sceNpTrophyCreateContext(vm::ptr<u32> context, vm::cptr<SceNpCommunic
504504
}
505505

506506
// set trophy context parameters (could be passed to constructor through make_ptr call)
507-
ctxt->trp_name = std::move(name);
507+
ctxt->trp_name = name;
508508
ctxt->read_only = !!(options & SCE_NP_TROPHY_OPTIONS_CREATE_CONTEXT_READ_ONLY);
509509
*context = idm::last_id();
510510

511+
// set current trophy name for trophy list overlay
512+
{
513+
current_trophy_name& current_id = g_fxo->get<current_trophy_name>();
514+
std::lock_guard lock(current_id.mtx);
515+
current_id.name = std::move(name);
516+
}
517+
511518
return CELL_OK;
512519
}
513520

rpcs3/Emu/Cell/Modules/sceNpTrophy.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,9 @@ class TrophyNotificationBase
168168

169169
virtual s32 ShowTrophyNotification(const SceNpTrophyDetails& trophy, const std::vector<uchar>& trophyIconBfr) = 0;
170170
};
171+
172+
struct current_trophy_name
173+
{
174+
std::mutex mtx;
175+
std::string name;
176+
};

rpcs3/Emu/RSX/GL/GLOverlays.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ namespace gl
217217
gl::texture_view* ui_overlay_renderer::load_simple_image(rsx::overlays::image_info* desc, bool temp_resource, u32 owner_uid)
218218
{
219219
auto tex = std::make_unique<gl::texture>(GL_TEXTURE_2D, desc->w, desc->h, 1, 1, GL_RGBA8);
220-
tex->copy_from(desc->data, gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {});
220+
tex->copy_from(desc->get_data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {});
221221

222222
GLenum remap[] = { GL_RED, GL_ALPHA, GL_BLUE, GL_GREEN };
223223
auto view = std::make_unique<gl::texture_view>(tex.get(), remap);

rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_main_menu.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
#include "overlay_home_menu_settings.h"
55
#include "overlay_home_menu_savestate.h"
66
#include "Emu/RSX/Overlays/FriendsList/overlay_friends_list_dialog.h"
7+
#include "Emu/RSX/Overlays/Trophies/overlay_trophy_list_dialog.h"
78
#include "Emu/RSX/Overlays/overlay_manager.h"
89
#include "Emu/System.h"
910
#include "Emu/system_config.h"
11+
#include "Emu/Cell/Modules/sceNpTrophy.h"
1012

1113
extern atomic_t<bool> g_user_asked_for_recording;
1214
extern atomic_t<bool> g_user_asked_for_screenshot;
@@ -55,6 +57,32 @@ namespace rsx
5557
return page_navigation::stay;
5658
});
5759

60+
// get current trophy name for trophy list overlay
61+
std::string trop_name;
62+
{
63+
current_trophy_name& current_id = g_fxo->get<current_trophy_name>();
64+
std::lock_guard lock(current_id.mtx);
65+
trop_name = current_id.name;
66+
}
67+
if (!trop_name.empty())
68+
{
69+
std::unique_ptr<overlay_element> trophies = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_TROPHIES));
70+
add_item(trophies, [trop_name = std::move(trop_name)](pad_button btn) -> page_navigation
71+
{
72+
if (btn != pad_button::cross) return page_navigation::stay;
73+
74+
rsx_log.notice("User selected trophies in home menu");
75+
Emu.CallFromMainThread([trop_name = std::move(trop_name)]()
76+
{
77+
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
78+
{
79+
manager->create<rsx::overlays::trophy_list_dialog>()->show(trop_name);
80+
}
81+
});
82+
return page_navigation::stay;
83+
});
84+
}
85+
5886
std::unique_ptr<overlay_element> screenshot = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_SCREENSHOT));
5987
add_item(screenshot, [](pad_button btn) -> page_navigation
6088
{

0 commit comments

Comments
 (0)