Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlays: add subject and body to recvmessage dialog #15140

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 53 additions & 15 deletions rpcs3/Emu/RSX/Overlays/Network/overlay_recvmessage_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,64 @@ namespace rsx
dlg->callback_handler(std::move(new_msg), msg_id);
}

recvmessage_dialog::list_entry::list_entry(const std::string& msg)
recvmessage_dialog::list_entry::list_entry(const std::string& name, const std::string& subj, const std::string& body)
{
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);
std::unique_ptr<overlay_element> prefix_stack = std::make_unique<vertical_layout>();
std::unique_ptr<overlay_element> text_stack = std::make_unique<vertical_layout>();
std::unique_ptr<overlay_element> name_label = std::make_unique<label>(name);
std::unique_ptr<overlay_element> subj_label = std::make_unique<label>(subj);
std::unique_ptr<overlay_element> body_label = std::make_unique<label>(body);
std::unique_ptr<overlay_element> name_prefix_label = std::make_unique<label>(get_localized_string(localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_FROM));
std::unique_ptr<overlay_element> subj_prefix_label = std::make_unique<label>(get_localized_string(localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_SUBJECT));

name_prefix_label->set_size(0, 40);
name_prefix_label->set_font("Arial", 16);
name_prefix_label->set_wrap_text(false);
static_cast<label*>(name_prefix_label.get())->auto_resize(true);

subj_prefix_label->set_size(0, 40);
subj_prefix_label->set_font("Arial", 16);
subj_prefix_label->set_wrap_text(false);
static_cast<label*>(subj_prefix_label.get())->auto_resize(true);

name_label->set_size(200, 40);
name_label->set_font("Arial", 16);
name_label->set_wrap_text(false);

subj_label->set_size(600, 40);
subj_label->set_font("Arial", 16);
subj_label->set_wrap_text(false);

body_label->set_size(800, 0);
body_label->set_font("Arial", 16);
body_label->set_wrap_text(true);
static_cast<label*>(body_label.get())->auto_resize(true);

// Make back color transparent for text
text_label->back_color.a = 0.f;
name_label->back_color.a = 0.f;
subj_label->back_color.a = 0.f;
body_label->back_color.a = 0.f;
name_prefix_label->back_color.a = 0.f;
subj_prefix_label->back_color.a = 0.f;

static_cast<vertical_layout*>(prefix_stack.get())->pack_padding = 5;
static_cast<vertical_layout*>(prefix_stack.get())->add_spacer();
static_cast<vertical_layout*>(prefix_stack.get())->add_element(name_prefix_label);
static_cast<vertical_layout*>(prefix_stack.get())->add_element(subj_prefix_label);

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);
static_cast<vertical_layout*>(text_stack.get())->add_spacer();
static_cast<vertical_layout*>(text_stack.get())->add_element(name_label);
static_cast<vertical_layout*>(text_stack.get())->add_element(subj_label);
static_cast<vertical_layout*>(text_stack.get())->add_element(body_label);

// Add spacer to make the thing look a bit nicer at the bottom... should ideally not be necessary
static_cast<vertical_layout*>(text_stack.get())->pack_padding = 25;
static_cast<vertical_layout*>(text_stack.get())->add_spacer();

// Pack
pack_padding = 15;
add_element(prefix_stack);
add_element(text_stack);
}

Expand All @@ -44,7 +82,7 @@ namespace rsx
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, false, true);
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>();
Expand Down Expand Up @@ -186,7 +224,7 @@ namespace rsx
for (const auto& [id, message] : messages)
{
ensure(message);
std::unique_ptr<overlay_element> entry = std::make_unique<list_entry>(message->first);
std::unique_ptr<overlay_element> entry = std::make_unique<list_entry>(message->first, message->second.subject, message->second.body);
m_entries.emplace_back(std::move(entry));
m_entry_ids.push_back(id);
}
Expand Down Expand Up @@ -279,7 +317,7 @@ namespace rsx

std::lock_guard lock(m_mutex);

std::unique_ptr<overlay_element> entry = std::make_unique<list_entry>(new_msg->first);
std::unique_ptr<overlay_element> entry = std::make_unique<list_entry>(new_msg->first, new_msg->second.subject, new_msg->second.body);
m_entries.emplace_back(std::move(entry));
m_entry_ids.push_back(msg_id);
m_list->add_entry(m_entries.back());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace rsx
struct list_entry : horizontal_layout
{
public:
list_entry(const std::string& msg);
list_entry(const std::string& name, const std::string& subj, const std::string& body);
};

shared_mutex m_mutex;
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/RSX/Overlays/overlay_controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,12 @@ namespace rsx
return compiled_resources;
}

void layout_container::add_spacer()
{
std::unique_ptr<overlay_element> spacer_element = std::make_unique<spacer>();
add_element(spacer_element);
}

overlay_element* vertical_layout::add_element(std::unique_ptr<overlay_element>& item, int offset)
{
if (auto_resize)
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/RSX/Overlays/overlay_controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ namespace rsx
compiled_resource& get_compiled() override;

virtual u16 get_scroll_offset_px() = 0;
void add_spacer();
};

struct vertical_layout : public layout_container
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/localized_string_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ enum class localized_string_id
CELL_NP_RECVMESSAGE_DIALOG_TITLE,
CELL_NP_RECVMESSAGE_DIALOG_TITLE_INVITE,
CELL_NP_RECVMESSAGE_DIALOG_TITLE_ADD_FRIEND,
CELL_NP_RECVMESSAGE_DIALOG_FROM,
CELL_NP_RECVMESSAGE_DIALOG_SUBJECT,

CELL_NP_SENDMESSAGE_DIALOG_TITLE,
CELL_NP_SENDMESSAGE_DIALOG_TITLE_INVITE,
Expand Down
14 changes: 8 additions & 6 deletions rpcs3/rpcs3qt/localized_emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ class localized_emu : public QObject
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("Select 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::CELL_NP_SENDMESSAGE_DIALOG_TITLE: return tr("Select Message To Send");
case localized_string_id::CELL_NP_SENDMESSAGE_DIALOG_TITLE_INVITE: return tr("Send Invite");
case localized_string_id::CELL_NP_SENDMESSAGE_DIALOG_TITLE_ADD_FRIEND: return tr("Add Friend");
case localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE: return tr("Select Message", "RECVMESSAGE_DIALOG");
case localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE_INVITE: return tr("Select Invite", "RECVMESSAGE_DIALOG");
case localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE_ADD_FRIEND: return tr("Add Friend", "RECVMESSAGE_DIALOG");
case localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_FROM: return tr("From:", "RECVMESSAGE_DIALOG");
case localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_SUBJECT: return tr("Subject:", "RECVMESSAGE_DIALOG");
case localized_string_id::CELL_NP_SENDMESSAGE_DIALOG_TITLE: return tr("Select Message To Send", "SENDMESSAGE_DIALOG");
case localized_string_id::CELL_NP_SENDMESSAGE_DIALOG_TITLE_INVITE: return tr("Send Invite", "SENDMESSAGE_DIALOG");
case localized_string_id::CELL_NP_SENDMESSAGE_DIALOG_TITLE_ADD_FRIEND: return tr("Add Friend", "SENDMESSAGE_DIALOG");
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)");
Expand Down