mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-07-10 01:54:46 -06:00
Use std::string_view in overlays
This commit is contained in:
parent
0fda2dd60f
commit
74f3349b19
@ -14,7 +14,7 @@ namespace rsx
|
||||
dlg->callback_handler(ntype, username, status);
|
||||
}
|
||||
|
||||
friends_list_dialog::friends_list_entry::friends_list_entry(friends_list_dialog_page page, const std::string& username, const rpcn::friend_online_data& data)
|
||||
friends_list_dialog::friends_list_entry::friends_list_entry(friends_list_dialog_page page, std::string_view username, const rpcn::friend_online_data& data)
|
||||
{
|
||||
std::unique_ptr<overlay_element> image = std::make_unique<image_view>();
|
||||
image->set_size(160, 110);
|
||||
|
||||
@ -26,7 +26,7 @@ namespace rsx
|
||||
std::unique_ptr<image_info> icon_data;
|
||||
|
||||
public:
|
||||
friends_list_entry(friends_list_dialog_page page, const std::string& username, const rpcn::friend_online_data& data);
|
||||
friends_list_entry(friends_list_dialog_page page, std::string_view username, const rpcn::friend_online_data& data);
|
||||
};
|
||||
|
||||
std::mutex m_list_mutex;
|
||||
|
||||
@ -5,7 +5,7 @@ namespace rsx
|
||||
{
|
||||
namespace overlays
|
||||
{
|
||||
home_menu_entry::home_menu_entry(home_menu::fa_icon icon, const std::string& text, u16 width, text_align alignment)
|
||||
home_menu_entry::home_menu_entry(home_menu::fa_icon icon, std::string_view text, u16 width, text_align alignment)
|
||||
{
|
||||
auto text_stack = std::make_unique<vertical_layout>();
|
||||
auto padding = std::make_unique<spacer>();
|
||||
|
||||
@ -31,7 +31,7 @@ namespace rsx
|
||||
struct home_menu_entry : horizontal_layout
|
||||
{
|
||||
public:
|
||||
home_menu_entry(home_menu::fa_icon icon, const std::string& text, u16 width, text_align alignment = text_align::center);
|
||||
home_menu_entry(home_menu::fa_icon icon, std::string_view text, u16 width, text_align alignment = text_align::center);
|
||||
};
|
||||
|
||||
template <typename T, typename C>
|
||||
|
||||
@ -53,7 +53,7 @@ namespace rsx
|
||||
return compiled_resources;
|
||||
}
|
||||
|
||||
void home_menu_message_box::show(const std::string& text, std::function<void()> on_accept, std::function<void()> on_cancel)
|
||||
void home_menu_message_box::show(std::string_view text, std::function<void()> on_accept, std::function<void()> on_cancel)
|
||||
{
|
||||
m_on_accept = std::move(on_accept);
|
||||
m_on_cancel = std::move(on_cancel);
|
||||
|
||||
@ -11,7 +11,7 @@ namespace rsx
|
||||
public:
|
||||
home_menu_message_box(s16 x, s16 y, u16 width, u16 height);
|
||||
compiled_resource& get_compiled() override;
|
||||
void show(const std::string& text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
|
||||
void show(std::string_view text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
|
||||
void hide();
|
||||
page_navigation handle_button_press(pad_button button_press);
|
||||
|
||||
|
||||
@ -155,7 +155,7 @@ namespace rsx
|
||||
refresh();
|
||||
}
|
||||
|
||||
void home_menu_page::show_dialog(const std::string& text, std::function<void()> on_accept, std::function<void()> on_cancel)
|
||||
void home_menu_page::show_dialog(std::string_view text, std::function<void()> on_accept, std::function<void()> on_cancel)
|
||||
{
|
||||
if (m_message_box && !m_message_box->visible)
|
||||
{
|
||||
|
||||
@ -26,7 +26,7 @@ namespace rsx
|
||||
struct home_menu_page : public list_view
|
||||
{
|
||||
public:
|
||||
home_menu_page(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent, const std::string& text);
|
||||
home_menu_page(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent, const std::string& title);
|
||||
|
||||
void set_current_page(home_menu_page* page);
|
||||
home_menu_page* get_current_page(bool include_this);
|
||||
@ -56,7 +56,7 @@ namespace rsx
|
||||
virtual void add_item(home_menu::fa_icon icon, std::string_view, std::function<page_navigation(pad_button)> callback);
|
||||
virtual void add_item(std::unique_ptr<overlay_element>& element, std::function<page_navigation(pad_button)> callback);
|
||||
virtual void apply_layout(bool center_vertically = false);
|
||||
void show_dialog(const std::string& text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
|
||||
void show_dialog(std::string_view text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
|
||||
|
||||
std::vector<std::shared_ptr<home_menu_page>> m_pages;
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ namespace rsx
|
||||
dlg->callback_handler(std::move(new_msg), msg_id);
|
||||
}
|
||||
|
||||
recvmessage_dialog::list_entry::list_entry(const std::string& name, const std::string& subj, const std::string& body)
|
||||
recvmessage_dialog::list_entry::list_entry(std::string_view name, std::string_view subj, std::string_view body)
|
||||
{
|
||||
std::unique_ptr<overlay_element> prefix_stack = std::make_unique<vertical_layout>();
|
||||
std::unique_ptr<overlay_element> text_stack = std::make_unique<vertical_layout>();
|
||||
|
||||
@ -15,7 +15,7 @@ namespace rsx
|
||||
struct list_entry : horizontal_layout
|
||||
{
|
||||
public:
|
||||
list_entry(const std::string& name, const std::string& subj, const std::string& body);
|
||||
list_entry(std::string_view name, std::string_view subj, std::string_view body);
|
||||
};
|
||||
|
||||
shared_mutex m_mutex;
|
||||
|
||||
@ -18,7 +18,7 @@ namespace rsx
|
||||
dlg->callback_handler(ntype, username, status);
|
||||
}
|
||||
|
||||
sendmessage_dialog::list_entry::list_entry(const std::string& msg)
|
||||
sendmessage_dialog::list_entry::list_entry(std::string_view msg)
|
||||
{
|
||||
std::unique_ptr<overlay_element> text_stack = std::make_unique<vertical_layout>();
|
||||
std::unique_ptr<overlay_element> padding = std::make_unique<spacer>();
|
||||
@ -336,7 +336,7 @@ namespace rsx
|
||||
return {};
|
||||
}
|
||||
|
||||
void sendmessage_dialog::reload(const std::string& previous_selection)
|
||||
void sendmessage_dialog::reload(std::string_view previous_selection)
|
||||
{
|
||||
if (m_list)
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@ namespace rsx
|
||||
struct list_entry : horizontal_layout
|
||||
{
|
||||
public:
|
||||
list_entry(const std::string& msg);
|
||||
list_entry(std::string_view msg);
|
||||
};
|
||||
|
||||
shared_mutex m_mutex;
|
||||
@ -29,7 +29,7 @@ namespace rsx
|
||||
animation_color_interpolate fade_animation;
|
||||
|
||||
std::string get_current_selection() const;
|
||||
void reload(const std::string& previous_selection);
|
||||
void reload(std::string_view previous_selection);
|
||||
|
||||
public:
|
||||
sendmessage_dialog();
|
||||
|
||||
@ -221,7 +221,7 @@ namespace rsx
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 media_list_dialog::show(std::shared_ptr<media_entry> root, media_entry& result, const std::string& title, u32 focused, bool enable_overlay)
|
||||
s32 media_list_dialog::show(std::shared_ptr<media_entry> root, media_entry& result, std::string_view title, u32 focused, bool enable_overlay)
|
||||
{
|
||||
auto ref = g_fxo->get<display_manager>().get(uid);
|
||||
|
||||
@ -291,7 +291,7 @@ namespace rsx
|
||||
return return_code;
|
||||
}
|
||||
|
||||
void media_list_dialog::reload(const std::string& title, u32 focused)
|
||||
void media_list_dialog::reload(std::string_view title, u32 focused)
|
||||
{
|
||||
ensure(m_media);
|
||||
|
||||
|
||||
@ -39,10 +39,10 @@ namespace rsx
|
||||
|
||||
compiled_resource get_compiled() override;
|
||||
|
||||
s32 show(std::shared_ptr<media_entry> root, media_entry& result, const std::string& title, u32 focused, bool enable_overlay);
|
||||
s32 show(std::shared_ptr<media_entry> root, media_entry& result, std::string_view title, u32 focused, bool enable_overlay);
|
||||
|
||||
private:
|
||||
void reload(const std::string& title, u32 focused);
|
||||
void reload(std::string_view title, u32 focused);
|
||||
|
||||
struct media_list_entry : horizontal_layout
|
||||
{
|
||||
|
||||
@ -95,7 +95,7 @@ namespace rsx
|
||||
return m_text.text == text;
|
||||
}
|
||||
|
||||
void message_item::set_label_text(const std::string& text)
|
||||
void message_item::set_label_text(std::string_view text)
|
||||
{
|
||||
m_text.set_text(text);
|
||||
m_is_compiled = false;
|
||||
@ -338,12 +338,12 @@ namespace rsx
|
||||
return check_lists(location, check_list);
|
||||
}
|
||||
|
||||
bool message::message_exists(message_pin_location location, const std::string& msg, bool allow_refresh, bool compare_id)
|
||||
bool message::message_exists(message_pin_location location, std::string_view msg, bool allow_refresh, bool compare_id)
|
||||
{
|
||||
return message_exists(location, utf8_to_u32string(msg), allow_refresh, compare_id);
|
||||
}
|
||||
|
||||
bool message::message_exists(message_pin_location location, const std::u32string& msg, bool allow_refresh, bool /*compare_id*/)
|
||||
bool message::message_exists(message_pin_location location, std::u32string_view msg, bool allow_refresh, bool /*compare_id*/)
|
||||
{
|
||||
const auto check_list = [&](std::deque<message_item>& list)
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ namespace rsx
|
||||
bool id_matches(localized_string_id id) const;
|
||||
bool text_matches(std::u32string_view text) const;
|
||||
|
||||
void set_label_text(const std::string& text);
|
||||
void set_label_text(std::string_view text);
|
||||
|
||||
private:
|
||||
localized_string_id m_loc_id = localized_string_id::INVALID;
|
||||
@ -126,8 +126,8 @@ namespace rsx
|
||||
// Stacking. Extends the lifetime of a message instead of inserting a duplicate
|
||||
bool check_lists(message_pin_location location, std::function<bool(std::deque<message_item>& list)> check_list);
|
||||
bool message_exists(message_pin_location location, localized_string_id id, bool allow_refresh, bool compare_id);
|
||||
bool message_exists(message_pin_location location, const std::string& msg, bool allow_refresh, bool compare_id);
|
||||
bool message_exists(message_pin_location location, const std::u32string& msg, bool allow_refresh, bool compare_id);
|
||||
bool message_exists(message_pin_location location, std::string_view msg, bool allow_refresh, bool compare_id);
|
||||
bool message_exists(message_pin_location location, std::u32string_view msg, bool allow_refresh, bool compare_id);
|
||||
bool message_exists(message_pin_location location, const localized_string& container, bool allow_refresh, bool compare_id);
|
||||
};
|
||||
|
||||
|
||||
@ -467,7 +467,7 @@ namespace rsx
|
||||
m_update = true;
|
||||
}
|
||||
|
||||
void osk_dialog::initialize_layout(const std::u32string& title, const std::u32string& initial_text)
|
||||
void osk_dialog::initialize_layout(std::u32string_view title, std::u32string_view initial_text)
|
||||
{
|
||||
const auto scale_font = [this](overlay_element& elem)
|
||||
{
|
||||
@ -1096,14 +1096,14 @@ namespace rsx
|
||||
on_text_changed();
|
||||
}
|
||||
|
||||
void osk_dialog::on_shift(const std::u32string&)
|
||||
void osk_dialog::on_shift(std::u32string_view /*str*/)
|
||||
{
|
||||
const u32 max = num_shift_layers_by_charset[m_selected_charset];
|
||||
selected_z = (selected_z + 1) % max;
|
||||
m_update = true;
|
||||
}
|
||||
|
||||
void osk_dialog::on_layer(const std::u32string&)
|
||||
void osk_dialog::on_layer(std::u32string_view /*str*/)
|
||||
{
|
||||
const u32 num_charsets = std::max<u32>(::size32(num_shift_layers_by_charset), 1);
|
||||
m_selected_charset = (m_selected_charset + 1) % num_charsets;
|
||||
@ -1120,7 +1120,7 @@ namespace rsx
|
||||
m_update = true;
|
||||
}
|
||||
|
||||
void osk_dialog::on_space(const std::u32string&)
|
||||
void osk_dialog::on_space(std::u32string_view /*str*/)
|
||||
{
|
||||
if (!(flags & CELL_OSKDIALOG_NO_SPACE))
|
||||
{
|
||||
@ -1132,19 +1132,19 @@ namespace rsx
|
||||
}
|
||||
}
|
||||
|
||||
void osk_dialog::on_backspace(const std::u32string&)
|
||||
void osk_dialog::on_backspace(std::u32string_view /*str*/)
|
||||
{
|
||||
m_preview.erase();
|
||||
on_text_changed();
|
||||
}
|
||||
|
||||
void osk_dialog::on_delete(const std::u32string&)
|
||||
void osk_dialog::on_delete(std::u32string_view /*str*/)
|
||||
{
|
||||
m_preview.del();
|
||||
on_text_changed();
|
||||
}
|
||||
|
||||
void osk_dialog::on_enter(const std::u32string&)
|
||||
void osk_dialog::on_enter(std::u32string_view /*str*/)
|
||||
{
|
||||
if (!(flags & CELL_OSKDIALOG_NO_RETURN))
|
||||
{
|
||||
@ -1156,7 +1156,7 @@ namespace rsx
|
||||
}
|
||||
}
|
||||
|
||||
void osk_dialog::on_move_cursor(const std::u32string&, edit_text::direction dir)
|
||||
void osk_dialog::on_move_cursor(std::u32string_view /*str*/, edit_text::direction dir)
|
||||
{
|
||||
m_preview.move_caret(dir);
|
||||
m_update = true;
|
||||
@ -1371,11 +1371,11 @@ namespace rsx
|
||||
m_title.back_color.a = 0.7f; // Uses the dimmed color of the frame background
|
||||
}
|
||||
|
||||
const callback_t shift_cb = [this](const std::u32string& text){ on_shift(text); };
|
||||
const callback_t layer_cb = [this](const std::u32string& text){ on_layer(text); };
|
||||
const callback_t space_cb = [this](const std::u32string& text){ on_space(text); };
|
||||
const callback_t delete_cb = [this](const std::u32string& text){ on_backspace(text); };
|
||||
const callback_t enter_cb = [this](const std::u32string& text){ on_enter(text); };
|
||||
const callback_t shift_cb = [this](std::u32string_view text){ on_shift(text); };
|
||||
const callback_t layer_cb = [this](std::u32string_view text){ on_layer(text); };
|
||||
const callback_t space_cb = [this](std::u32string_view text){ on_space(text); };
|
||||
const callback_t delete_cb = [this](std::u32string_view text){ on_backspace(text); };
|
||||
const callback_t enter_cb = [this](std::u32string_view text){ on_enter(text); };
|
||||
|
||||
const auto is_supported = [&](u32 mode) -> bool
|
||||
{
|
||||
|
||||
@ -111,7 +111,7 @@ namespace rsx
|
||||
void SetText(const std::u16string& text) override;
|
||||
void Insert(const std::u16string& text) override;
|
||||
|
||||
void initialize_layout(const std::u32string& title, const std::u32string& initial_text);
|
||||
void initialize_layout(std::u32string_view title, std::u32string_view initial_text);
|
||||
void add_panel(const osk_panel& panel);
|
||||
void step_panel(bool next_panel);
|
||||
void update_panel();
|
||||
@ -128,13 +128,13 @@ namespace rsx
|
||||
void on_text_changed();
|
||||
|
||||
void on_default_callback(const std::u32string& str);
|
||||
void on_shift(const std::u32string&);
|
||||
void on_layer(const std::u32string&);
|
||||
void on_space(const std::u32string&);
|
||||
void on_backspace(const std::u32string&);
|
||||
void on_delete(const std::u32string&);
|
||||
void on_enter(const std::u32string&);
|
||||
void on_move_cursor(const std::u32string&, edit_text::direction dir);
|
||||
void on_shift(std::u32string_view str);
|
||||
void on_layer(std::u32string_view str);
|
||||
void on_space(std::u32string_view str);
|
||||
void on_backspace(std::u32string_view str);
|
||||
void on_delete(std::u32string_view str);
|
||||
void on_enter(std::u32string_view str);
|
||||
void on_move_cursor(std::u32string_view str, edit_text::direction dir);
|
||||
|
||||
std::u32string get_placeholder() const;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ namespace rsx
|
||||
{
|
||||
namespace overlays
|
||||
{
|
||||
save_dialog::save_dialog_entry::save_dialog_entry(const std::string& text1, const std::string& text2, const std::string& text3, u8 resource_id, const std::vector<u8>& icon_buf, const std::string& video_path)
|
||||
save_dialog::save_dialog_entry::save_dialog_entry(std::string_view text1, std::string_view text2, std::string_view text3, u8 resource_id, const std::vector<u8>& icon_buf, const std::string& video_path)
|
||||
{
|
||||
const std::string audio_path; // no audio here
|
||||
std::unique_ptr<overlay_element> image = resource_id != image_resource_id::raw_image
|
||||
|
||||
@ -14,7 +14,7 @@ namespace rsx
|
||||
struct save_dialog_entry : horizontal_layout
|
||||
{
|
||||
public:
|
||||
save_dialog_entry(const std::string& text1, const std::string& text2, const std::string& text3, u8 resource_id, const std::vector<u8>& icon_buf, const std::string& video_path);
|
||||
save_dialog_entry(std::string_view text1, std::string_view text2, std::string_view text3, u8 resource_id, const std::vector<u8>& icon_buf, const std::string& video_path);
|
||||
void set_selected(bool selected) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -9,7 +9,7 @@ namespace rsx
|
||||
{
|
||||
namespace overlays
|
||||
{
|
||||
user_list_dialog::user_list_entry::user_list_entry(const std::string& username, const std::string& user_id, const std::string& avatar_path)
|
||||
user_list_dialog::user_list_entry::user_list_entry(std::string_view username, std::string_view user_id, const std::string& avatar_path)
|
||||
{
|
||||
std::unique_ptr<overlay_element> image = std::make_unique<image_view>();
|
||||
image->set_size(160, 110);
|
||||
@ -174,7 +174,7 @@ namespace rsx
|
||||
return result;
|
||||
}
|
||||
|
||||
error_code user_list_dialog::show(const std::string& title, u32 focused, const std::vector<u32>& user_ids, bool enable_overlay, std::function<void(s32 status)> on_close)
|
||||
error_code user_list_dialog::show(std::string_view title, u32 focused, const std::vector<u32>& user_ids, bool enable_overlay, std::function<void(s32 status)> on_close)
|
||||
{
|
||||
visible = false;
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ namespace rsx
|
||||
std::unique_ptr<image_info> icon_data;
|
||||
|
||||
public:
|
||||
user_list_entry(const std::string& username, const std::string& user_id, const std::string& avatar_path);
|
||||
user_list_entry(std::string_view username, std::string_view user_id, const std::string& avatar_path);
|
||||
};
|
||||
|
||||
std::vector<u32> m_entry_ids;
|
||||
@ -35,7 +35,7 @@ namespace rsx
|
||||
|
||||
compiled_resource get_compiled() override;
|
||||
|
||||
error_code show(const std::string& title, u32 focused, const std::vector<u32>& user_ids, bool enable_overlay, std::function<void(s32 status)> on_close);
|
||||
error_code show(std::string_view title, u32 focused, const std::vector<u32>& user_ids, bool enable_overlay, std::function<void(s32 status)> on_close);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user