1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

overlays: implement native recvmessage dialog

This commit is contained in:
Megamouse 2024-01-27 08:56:26 +01:00
parent cdfe3ee7c8
commit 9ef5a01de4
17 changed files with 449 additions and 25 deletions

View File

@ -471,6 +471,7 @@ target_sources(rpcs3_emu PRIVATE
RSX/Overlays/HomeMenu/overlay_home_menu_message_box.cpp
RSX/Overlays/HomeMenu/overlay_home_menu_page.cpp
RSX/Overlays/HomeMenu/overlay_home_menu_settings.cpp
RSX/Overlays/Network/overlay_recvmessage_dialog.cpp
RSX/Overlays/overlay_animated_icon.cpp
RSX/Overlays/overlay_animation.cpp
RSX/Overlays/overlay_controls.cpp

View File

@ -24,6 +24,9 @@
#include "Emu/NP/np_structs_extra.h"
#include "Emu/system_config.h"
#include "Emu/RSX/Overlays/overlay_manager.h"
#include "Emu/RSX/Overlays/Network/overlay_recvmessage_dialog.h"
LOG_CHANNEL(sceNp);
error_code sceNpManagerGetNpId(vm::ptr<SceNpId> npId);
@ -1398,13 +1401,20 @@ error_code sceNpBasicRecvMessageCustom(u16 mainType, u32 recvOptions, sys_memory
return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT;
}
bool result = false;
input::SetIntercepted(true);
error_code result = CELL_CANCEL;
SceNpBasicMessageRecvAction recv_result{};
u64 chosen_msg_id{};
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
{
auto recv_dlg = manager->create<rsx::overlays::recvmessage_dialog>();
result = recv_dlg->Exec(static_cast<SceNpBasicMessageMainType>(mainType), static_cast<SceNpBasicMessageRecvOptions>(recvOptions), recv_result, chosen_msg_id);
}
else
{
input::SetIntercepted(true);
Emu.BlockingCallFromMainThread([=, &result, &recv_result, &chosen_msg_id]()
{
auto recv_dlg = Emu.GetCallbacks().get_recvmessage_dialog();
@ -1412,13 +1422,22 @@ error_code sceNpBasicRecvMessageCustom(u16 mainType, u32 recvOptions, sys_memory
});
input::SetIntercepted(false);
}
if (!result)
if (result != CELL_OK)
{
return SCE_NP_BASIC_ERROR_CANCEL;
}
const auto msg_pair = nph.get_message(chosen_msg_id).value();
const auto opt_msg = nph.get_message(chosen_msg_id);
if (!opt_msg)
{
sceNp.fatal("sceNpBasicRecvMessageCustom: message is invalid: chosen_msg_id=%d", chosen_msg_id);
return SCE_NP_BASIC_ERROR_CANCEL;
}
const auto msg_pair = opt_msg.value();
const auto& msg = msg_pair->second;
const u32 event_to_send = (mainType == SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE) ? SCE_NP_BASIC_EVENT_RECV_INVITATION_RESULT : SCE_NP_BASIC_EVENT_RECV_CUSTOM_DATA_RESULT;

View File

@ -1702,6 +1702,11 @@ struct message_data
void print() const;
};
namespace rpcn
{
class rpcn_client;
}
class SendMessageDialogBase
{
public:
@ -1715,5 +1720,9 @@ class RecvMessageDialogBase
public:
virtual ~RecvMessageDialogBase() = default;
virtual bool Exec(SceNpBasicMessageMainType type, SceNpBasicMessageRecvOptions options, SceNpBasicMessageRecvAction& recv_result, u64& chosen_msg_id) = 0;
virtual error_code Exec(SceNpBasicMessageMainType type, SceNpBasicMessageRecvOptions options, SceNpBasicMessageRecvAction& recv_result, u64& chosen_msg_id) = 0;
virtual void callback_handler(const std::shared_ptr<std::pair<std::string, message_data>> new_msg, u64 msg_id) = 0;
protected:
std::shared_ptr<rpcn::rpcn_client> m_rpcn;
};

View File

@ -0,0 +1,291 @@
#include "stdafx.h"
#include "../overlay_manager.h"
#include "overlay_recvmessage_dialog.h"
#include "Emu/RSX/RSXThread.h"
#include "Emu/NP/rpcn_client.h"
#include "Utilities/Thread.h"
namespace rsx
{
namespace overlays
{
void recvmessage_callback(void* param, std::shared_ptr<std::pair<std::string, message_data>> new_msg, u64 msg_id)
{
auto* dlg = static_cast<recvmessage_dialog*>(param);
dlg->callback_handler(std::move(new_msg), msg_id);
}
recvmessage_dialog::list_entry::list_entry(const std::string& msg)
{
std::unique_ptr<overlay_element> text_stack = std::make_unique<vertical_layout>();
std::unique_ptr<overlay_element> padding = std::make_unique<spacer>();
std::unique_ptr<overlay_element> text_label = std::make_unique<label>(msg);
padding->set_size(1, 1);
text_label->set_size(800, 40);
text_label->set_font("Arial", 16);
text_label->set_wrap_text(true);
// Make back color transparent for text
text_label->back_color.a = 0.f;
static_cast<vertical_layout*>(text_stack.get())->pack_padding = 5;
static_cast<vertical_layout*>(text_stack.get())->add_element(padding);
static_cast<vertical_layout*>(text_stack.get())->add_element(text_label);
// Pack
pack_padding = 15;
add_element(text_stack);
}
recvmessage_dialog::recvmessage_dialog() : RecvMessageDialogBase()
{
m_dim_background = std::make_unique<overlay_element>();
m_dim_background->set_size(virtual_width, virtual_height);
m_dim_background->back_color.a = 0.5f;
m_list = std::make_unique<list_view>(virtual_width - 2 * 20, 540, true, true);
m_list->set_pos(20, 85);
m_description = std::make_unique<label>();
m_description->set_font("Arial", 20);
m_description->set_pos(20, 37);
m_description->set_text(get_localized_string(localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE));
m_description->auto_resize();
m_description->back_color.a = 0.f;
fade_animation.duration = 0.15f;
return_code = selection_code::canceled;
}
void recvmessage_dialog::update()
{
if (fade_animation.active)
{
fade_animation.update(rsx::get_current_renderer()->vblank_count);
}
}
void recvmessage_dialog::on_button_pressed(pad_button button_press, bool is_auto_repeat)
{
if (fade_animation.active) return;
bool close_dialog = false;
std::lock_guard lock(m_mutex);
switch (button_press)
{
case pad_button::cross:
case pad_button::triangle:
if (m_list->m_items.empty())
break;
if (const usz index = static_cast<usz>(m_list->get_selected_index()); index < m_entry_ids.size())
{
return_code = button_press == pad_button::cross ? selection_code::ok : selection_code::no;
}
else
{
return_code = selection_code::error;
}
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav");
close_dialog = true;
break;
case pad_button::circle:
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav");
close_dialog = true;
break;
case pad_button::dpad_up:
case pad_button::ls_up:
m_list->select_previous();
break;
case pad_button::dpad_down:
case pad_button::ls_down:
m_list->select_next();
break;
case pad_button::L1:
m_list->select_previous(10);
break;
case pad_button::R1:
m_list->select_next(10);
break;
default:
rsx_log.trace("[ui] Button %d pressed", static_cast<u8>(button_press));
break;
}
if (close_dialog)
{
fade_animation.current = color4f(1.f);
fade_animation.end = color4f(0.f);
fade_animation.active = true;
fade_animation.on_finish = [this]
{
close(true, true);
};
}
// Play a sound unless this is a fast auto repeat which would induce a nasty noise
else if (!is_auto_repeat || m_auto_repeat_ms_interval >= m_auto_repeat_ms_interval_default)
{
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav");
}
}
compiled_resource recvmessage_dialog::get_compiled()
{
if (!visible)
{
return {};
}
compiled_resource result;
result.add(m_dim_background->get_compiled());
result.add(m_list->get_compiled());
result.add(m_description->get_compiled());
fade_animation.apply(result);
return result;
}
error_code recvmessage_dialog::Exec(SceNpBasicMessageMainType type, SceNpBasicMessageRecvOptions options, SceNpBasicMessageRecvAction& recv_result, u64& chosen_msg_id)
{
visible = false;
switch (type)
{
case SceNpBasicMessageMainType::SCE_NP_BASIC_MESSAGE_MAIN_TYPE_ADD_FRIEND:
m_description->set_text(get_localized_string(localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE_ADD_FRIEND));
m_description->auto_resize();
break;
case SceNpBasicMessageMainType::SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE:
m_description->set_text(get_localized_string(localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE_INVITE));
m_description->auto_resize();
break;
case SceNpBasicMessageMainType::SCE_NP_BASIC_MESSAGE_MAIN_TYPE_DATA_ATTACHMENT:
case SceNpBasicMessageMainType::SCE_NP_BASIC_MESSAGE_MAIN_TYPE_GENERAL:
case SceNpBasicMessageMainType::SCE_NP_BASIC_MESSAGE_MAIN_TYPE_CUSTOM_DATA:
case SceNpBasicMessageMainType::SCE_NP_BASIC_MESSAGE_MAIN_TYPE_URL_ATTACHMENT:
default:
break; // Title already set in constructor
}
const bool preserve = options & SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_PRESERVE;
const bool include_bootable = options & SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_INCLUDE_BOOTABLE;
m_rpcn = rpcn::rpcn_client::get_instance(true);
// Get list of messages
const auto messages = m_rpcn->get_messages_and_register_cb(type, include_bootable, recvmessage_callback, this);
{
std::lock_guard lock(m_mutex);
for (const auto& [id, message] : messages)
{
ensure(message);
std::unique_ptr<overlay_element> entry = std::make_unique<list_entry>(message->first);
m_entries.emplace_back(std::move(entry));
m_entry_ids.push_back(id);
}
for (auto& entry : m_entries)
{
m_list->add_entry(entry);
}
if (m_list->m_items.empty())
{
m_list->set_cancel_only(true);
}
else
{
// Only select an entry if there are entries available
m_list->select_entry(0);
}
}
fade_animation.current = color4f(0.f);
fade_animation.end = color4f(1.f);
fade_animation.active = true;
visible = true;
const auto notify = std::make_shared<atomic_t<u32>>(0);
auto& overlayman = g_fxo->get<display_manager>();
// Block until the user exits the dialog
overlayman.attach_thread_input(
uid, "Recvmessage dialog", nullptr,
[notify](s32) { *notify = true; notify->notify_one(); }
);
while (!Emu.IsStopped() && !*notify)
{
notify->wait(0, atomic_wait_timeout{1'000'000});
}
m_rpcn->remove_message_cb(recvmessage_callback, this);
error_code result = CELL_CANCEL;
auto accept_or_deny = [preserve, this, &result, &recv_result, &chosen_msg_id](SceNpBasicMessageRecvAction result_from_action)
{
{
std::lock_guard lock(m_mutex);
const int selected_index = m_list->get_selected_index();
if (selected_index < 0 || static_cast<usz>(selected_index) >= m_entry_ids.size())
{
rsx_log.error("recvmessage dialog exited with unexpected selection: index=%d, entries=%d", selected_index, m_entry_ids.size());
return;
}
chosen_msg_id = ::at32(m_entry_ids, selected_index);
}
recv_result = result_from_action;
result = CELL_OK;
if (!preserve)
{
m_rpcn->mark_message_used(chosen_msg_id);
}
};
switch (return_code)
{
case selection_code::ok:
accept_or_deny(SCE_NP_BASIC_MESSAGE_ACTION_ACCEPT);
break;
case selection_code::no:
accept_or_deny(SCE_NP_BASIC_MESSAGE_ACTION_DENY);
break;
default:
rsx_log.error("recvmessage dialog exited with error: %d", return_code);
break;
}
return result;
}
void recvmessage_dialog::callback_handler(std::shared_ptr<std::pair<std::string, message_data>> new_msg, u64 msg_id)
{
ensure(new_msg);
std::lock_guard lock(m_mutex);
std::unique_ptr<overlay_element> entry = std::make_unique<list_entry>(new_msg->first);
m_entries.emplace_back(std::move(entry));
m_entry_ids.push_back(msg_id);
m_list->add_entry(m_entries.back());
if (m_list->get_cancel_only())
{
m_list->set_cancel_only(false);
m_list->select_entry(0);
}
}
} // namespace overlays
} // namespace RSX

View File

@ -0,0 +1,42 @@
#pragma once
#include "../overlays.h"
#include "../overlay_list_view.hpp"
#include "Emu/Cell/ErrorCodes.h"
#include "Emu/Cell/Modules/sceNp.h"
namespace rsx
{
namespace overlays
{
struct recvmessage_dialog : public user_interface, public RecvMessageDialogBase
{
private:
struct list_entry : horizontal_layout
{
public:
list_entry(const std::string& msg);
};
shared_mutex m_mutex;
std::vector<std::unique_ptr<overlay_element>> m_entries;
std::vector<u64> m_entry_ids;
std::unique_ptr<overlay_element> m_dim_background;
std::unique_ptr<list_view> m_list;
std::unique_ptr<label> m_description;
animation_color_interpolate fade_animation;
public:
recvmessage_dialog();
void update() override;
void on_button_pressed(pad_button button_press, bool is_auto_repeat) override;
compiled_resource get_compiled() override;
error_code Exec(SceNpBasicMessageMainType type, SceNpBasicMessageRecvOptions options, SceNpBasicMessageRecvAction& recv_result, u64& chosen_msg_id) override;
void callback_handler(const std::shared_ptr<std::pair<std::string, message_data>> new_msg, u64 msg_id) override;
};
}
}

View File

@ -1,3 +1,5 @@
#pragma once
#include "overlay_controls.h"
namespace rsx

View File

@ -6,7 +6,7 @@ namespace rsx
{
namespace overlays
{
list_view::list_view(u16 width, u16 height, bool use_separators)
list_view::list_view(u16 width, u16 height, bool use_separators, bool can_deny)
: m_use_separators(use_separators)
{
w = width;
@ -39,7 +39,22 @@ namespace rsx
m_scroll_indicator_bottom->set_pos(0, height - 40);
m_accept_btn->set_pos(30, height + 20);
if (can_deny)
{
m_deny_btn = std::make_unique<image_button>(120, 20);
m_deny_btn->set_size(120, 30);
m_deny_btn->set_image_resource(resource_config::standard_image_resource::triangle);
m_deny_btn->set_pos(180, height + 20);
m_deny_btn->set_text(localized_string_id::RSX_OVERLAYS_LIST_DENY);
m_deny_btn->set_font("Arial", 16);
m_cancel_btn->set_pos(330, height + 20);
}
else
{
m_cancel_btn->set_pos(180, height + 20);
}
m_accept_btn->set_text(localized_string_id::RSX_OVERLAYS_LIST_SELECT);
m_cancel_btn->set_text(localized_string_id::RSX_OVERLAYS_LIST_CANCEL);
@ -173,6 +188,8 @@ namespace rsx
{
if (cancel_only)
m_cancel_btn->set_pos(x + 30, y + h + 20);
else if (m_deny_btn)
m_cancel_btn->set_pos(x + 330, y + h + 20);
else
m_cancel_btn->set_pos(x + 180, y + h + 20);
@ -180,6 +197,11 @@ namespace rsx
is_compiled = false;
}
bool list_view::get_cancel_only() const
{
return m_cancel_only;
}
void list_view::translate(s16 _x, s16 _y)
{
layout_container::translate(_x, _y);
@ -187,6 +209,11 @@ namespace rsx
m_scroll_indicator_bottom->translate(_x, _y);
m_accept_btn->translate(_x, _y);
m_cancel_btn->translate(_x, _y);
if (m_deny_btn)
{
m_deny_btn->translate(_x, _y);
}
}
compiled_resource& list_view::get_compiled()
@ -200,8 +227,15 @@ namespace rsx
compiled.add(m_cancel_btn->get_compiled());
if (!m_cancel_only)
{
compiled.add(m_accept_btn->get_compiled());
if (m_deny_btn)
{
compiled.add(m_deny_btn->get_compiled());
}
}
compiled_resources = compiled;
}

View File

@ -1,3 +1,5 @@
#pragma once
#include "overlay_controls.h"
namespace rsx
@ -11,6 +13,7 @@ namespace rsx
std::unique_ptr<image_view> m_scroll_indicator_bottom;
std::unique_ptr<image_button> m_cancel_btn;
std::unique_ptr<image_button> m_accept_btn;
std::unique_ptr<image_button> m_deny_btn;
std::unique_ptr<overlay_element> m_highlight_box;
u16 m_elements_height = 0;
@ -21,7 +24,7 @@ namespace rsx
bool m_cancel_only = false;
public:
list_view(u16 width, u16 height, bool use_separators = true);
list_view(u16 width, u16 height, bool use_separators = true, bool can_deny = false);
void update_selection();
@ -32,6 +35,7 @@ namespace rsx
void add_entry(std::unique_ptr<overlay_element>& entry);
int get_selected_index() const;
bool get_cancel_only() const;
std::u32string get_selected_item();

View File

@ -1,3 +1,5 @@
#pragma once
#include "overlay_controls.h"
namespace rsx

View File

@ -57,7 +57,8 @@ namespace rsx
new_save = -1,
canceled = -2,
error = -3,
interrupted = -4
interrupted = -4,
no = -5
};
static constexpr u64 m_auto_repeat_ms_interval_default = 200;

View File

@ -30,6 +30,7 @@ enum class localized_string_id
RSX_OVERLAYS_MEDIA_DIALOG_EMPTY,
RSX_OVERLAYS_LIST_SELECT,
RSX_OVERLAYS_LIST_CANCEL,
RSX_OVERLAYS_LIST_DENY,
CELL_GAME_ERROR_BROKEN_GAMEDATA,
CELL_GAME_ERROR_BROKEN_HDDGAME,
@ -135,6 +136,10 @@ enum class localized_string_id
CELL_CROSS_CONTROLLER_MSG,
CELL_CROSS_CONTROLLER_FW_MSG,
CELL_NP_RECVMESSAGE_DIALOG_TITLE,
CELL_NP_RECVMESSAGE_DIALOG_TITLE_INVITE,
CELL_NP_RECVMESSAGE_DIALOG_TITLE_ADD_FRIEND,
RECORDING_ABORTED,
RPCN_NO_ERROR,

View File

@ -99,6 +99,7 @@
<ClCompile Include="Emu\RSX\Overlays\HomeMenu\overlay_home_menu_main_menu.cpp" />
<ClCompile Include="Emu\RSX\Overlays\HomeMenu\overlay_home_menu_page.cpp" />
<ClCompile Include="Emu\RSX\Overlays\HomeMenu\overlay_home_menu_settings.cpp" />
<ClCompile Include="Emu\RSX\Overlays\Network\overlay_recvmessage_dialog.cpp" />
<ClCompile Include="Emu\RSX\Overlays\overlay_animated_icon.cpp" />
<ClCompile Include="Emu\RSX\Overlays\overlay_controls.cpp" />
<ClCompile Include="Emu\RSX\Overlays\overlay_cursor.cpp" />
@ -583,6 +584,7 @@
<ClInclude Include="Emu\RSX\Overlays\HomeMenu\overlay_home_menu_main_menu.h" />
<ClInclude Include="Emu\RSX\Overlays\HomeMenu\overlay_home_menu_page.h" />
<ClInclude Include="Emu\RSX\Overlays\HomeMenu\overlay_home_menu_settings.h" />
<ClInclude Include="Emu\RSX\Overlays\Network\overlay_recvmessage_dialog.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_animated_icon.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_cursor.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_debug_overlay.h" />

View File

@ -88,6 +88,9 @@
<Filter Include="Emu\GPU\RSX\Program\Snippets\RSXProg">
<UniqueIdentifier>{f990b0be-adbd-4a1c-b8c7-d6f963d5b629}</UniqueIdentifier>
</Filter>
<Filter Include="Emu\GPU\RSX\Overlays\Network">
<UniqueIdentifier>{d7a60dc0-ac4e-4983-97d3-ce1328af49a7}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Crypto\aes.cpp">
@ -1186,6 +1189,9 @@
<ClCompile Include="Emu\RSX\Overlays\overlay_debug_overlay.cpp">
<Filter>Emu\GPU\RSX\Overlays</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Overlays\Network\overlay_recvmessage_dialog.cpp">
<Filter>Emu\GPU\RSX\Overlays\Network</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Crypto\aes.h">
@ -2407,6 +2413,9 @@
<ClInclude Include="Emu\RSX\Overlays\overlay_debug_overlay.h">
<Filter>Emu\GPU\RSX\Overlays</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Overlays\Network\overlay_recvmessage_dialog.h">
<Filter>Emu\GPU\RSX\Overlays\Network</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Emu\RSX\Program\GLSLSnippets\GPUDeswizzle.glsl">

View File

@ -63,6 +63,7 @@ private:
case localized_string_id::RSX_OVERLAYS_MEDIA_DIALOG_EMPTY: return tr("No media found.", "Media dialog");
case localized_string_id::RSX_OVERLAYS_LIST_SELECT: return tr("Enter", "Enter Dialog List");
case localized_string_id::RSX_OVERLAYS_LIST_CANCEL: return tr("Back", "Cancel Dialog List");
case localized_string_id::RSX_OVERLAYS_LIST_DENY: return tr("Deny", "Deny Dialog List");
case localized_string_id::CELL_GAME_ERROR_BROKEN_GAMEDATA: return tr("ERROR: Game data is corrupted. The application will continue.", "Game Error");
case localized_string_id::CELL_GAME_ERROR_BROKEN_HDDGAME: return tr("ERROR: HDD boot game is corrupted. The application will continue.", "Game Error");
case localized_string_id::CELL_GAME_ERROR_BROKEN_EXIT_GAMEDATA: return tr("ERROR: Game data is corrupted. The application will be terminated.", "Game Error");
@ -159,6 +160,9 @@ private:
case localized_string_id::CELL_SAVEDATA_OVERWRITE: return tr("Do you want to overwrite the saved data?\n\n%0", "Savedata entry info").arg(std::forward<Args>(args)...);
case localized_string_id::CELL_CROSS_CONTROLLER_MSG: return tr("Start [%0] on the PS Vita system.\nIf you have not installed [%0], go to [Remote Play] on the PS Vita system and start [Cross-Controller] from the LiveArea™ screen.", "Cross-Controller message").arg(std::forward<Args>(args)...);
case localized_string_id::CELL_CROSS_CONTROLLER_FW_MSG: return tr("If your system software version on the PS Vita system is earlier than 1.80, you must update the system software to the latest version.", "Cross-Controller firmware message");
case localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE: return tr("Choose Message");
case localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE_INVITE: return tr("Select Invite");
case localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE_ADD_FRIEND: return tr("Add Friend");
case localized_string_id::RECORDING_ABORTED: return tr("Recording aborted!");
case localized_string_id::RPCN_NO_ERROR: return tr("RPCN: No Error");
case localized_string_id::RPCN_ERROR_INVALID_INPUT: return tr("RPCN: Invalid Input (Wrong Host/Port)");

View File

@ -8,7 +8,7 @@
LOG_CHANNEL(recvmessage_dlg_log, "recvmessage dlg");
void recvmessage_callback(void* param, const std::shared_ptr<std::pair<std::string, message_data>> new_msg, u64 msg_id)
void recvmessage_callback(void* param, std::shared_ptr<std::pair<std::string, message_data>> new_msg, u64 msg_id)
{
auto* dlg = static_cast<recvmessage_dialog_frame*>(param);
dlg->callback_handler(std::move(new_msg), msg_id);
@ -22,7 +22,7 @@ recvmessage_dialog_frame::~recvmessage_dialog_frame()
}
}
bool recvmessage_dialog_frame::Exec(SceNpBasicMessageMainType type, SceNpBasicMessageRecvOptions options, SceNpBasicMessageRecvAction& recv_result, u64& chosen_msg_id)
error_code recvmessage_dialog_frame::Exec(SceNpBasicMessageMainType type, SceNpBasicMessageRecvOptions options, SceNpBasicMessageRecvAction& recv_result, u64& chosen_msg_id)
{
qRegisterMetaType<recvmessage_signal_struct>();
@ -56,7 +56,7 @@ bool recvmessage_dialog_frame::Exec(SceNpBasicMessageMainType type, SceNpBasicMe
m_dialog->setLayout(vbox_global);
bool result = false;
error_code result = CELL_CANCEL;
const bool preserve = options & SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_PRESERVE;
const bool include_bootable = options & SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_INCLUDE_BOOTABLE;
@ -71,7 +71,7 @@ bool recvmessage_dialog_frame::Exec(SceNpBasicMessageMainType type, SceNpBasicMe
chosen_msg_id = selected[0]->data(Qt::UserRole).toULongLong();
recv_result = result_from_action;
result = true;
result = CELL_OK;
if (!preserve)
{
@ -91,9 +91,9 @@ bool recvmessage_dialog_frame::Exec(SceNpBasicMessageMainType type, SceNpBasicMe
// Get list of messages
const auto messages = m_rpcn->get_messages_and_register_cb(type, include_bootable, recvmessage_callback, this);
for (const auto& message : messages)
for (const auto& [id, message] : messages)
{
add_message(message.second, message.first);
add_message(message, id);
}
m_dialog->exec();

View File

@ -22,8 +22,8 @@ class recvmessage_dialog_frame : public QObject, public RecvMessageDialogBase
public:
recvmessage_dialog_frame() = default;
~recvmessage_dialog_frame();
bool Exec(SceNpBasicMessageMainType type, SceNpBasicMessageRecvOptions options, SceNpBasicMessageRecvAction& recv_result, u64& chosen_msg_id) override;
void callback_handler(const std::shared_ptr<std::pair<std::string, message_data>> new_msg, u64 msg_id);
error_code Exec(SceNpBasicMessageMainType type, SceNpBasicMessageRecvOptions options, SceNpBasicMessageRecvAction& recv_result, u64& chosen_msg_id) override;
void callback_handler(const std::shared_ptr<std::pair<std::string, message_data>> new_msg, u64 msg_id) override;
private:
void add_message(const std::shared_ptr<std::pair<std::string, message_data>>& msg, u64 msg_id);
@ -37,5 +37,4 @@ private Q_SLOTS:
private:
custom_dialog* m_dialog = nullptr;
QListWidget* m_lst_messages = nullptr;
std::shared_ptr<rpcn::rpcn_client> m_rpcn;
};

View File

@ -498,7 +498,7 @@ bool update_manager::handle_rpcs3(const QByteArray& data, bool auto_accept)
usz offset = 0;
usz outSizeProcessed = 0;
const bool isDir = SzArEx_IsDir(&db, i);
const DWORD attribs = SzBitWithVals_Check(&db.Attribs, i) ? db.Attribs.Vals[i] : 0;
[[maybe_unused]] const DWORD attribs = SzBitWithVals_Check(&db.Attribs, i) ? db.Attribs.Vals[i] : 0;
#ifdef _WIN32
// This is commented out for now as we shouldn't need it and symlinks
// aren't well supported on Windows. Left in case it is needed in the future.