mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-03-17 18:55:19 +01:00
overlays/home: Add icons to the home menu
This commit is contained in:
parent
ce2afa1d54
commit
27ecfaee9c
|
|
@ -5,25 +5,56 @@ namespace rsx
|
|||
{
|
||||
namespace overlays
|
||||
{
|
||||
home_menu_entry::home_menu_entry(const std::string& text, u16 width)
|
||||
home_menu_entry::home_menu_entry(home_menu::fa_icon icon, const std::string& text, u16 width)
|
||||
{
|
||||
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> title = std::make_unique<label>(text);
|
||||
auto text_stack = std::make_unique<vertical_layout>();
|
||||
auto padding = std::make_unique<spacer>();
|
||||
auto title = std::make_unique<label>(text);
|
||||
|
||||
padding->set_size(1, 1);
|
||||
title->set_size(width, menu_entry_height);
|
||||
title->set_font("Arial", 16);
|
||||
title->set_font("Arial", 14);
|
||||
title->set_wrap_text(true);
|
||||
title->align_text(text_align::center);
|
||||
|
||||
// Make back color transparent for text
|
||||
title->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(title);
|
||||
text_stack->pack_padding = 8;
|
||||
text_stack->add_element(padding);
|
||||
text_stack->add_element(title);
|
||||
|
||||
if (icon == home_menu::fa_icon::none)
|
||||
{
|
||||
add_element(text_stack);
|
||||
return;
|
||||
}
|
||||
|
||||
auto icon_info = ensure(home_menu::get_icon(icon));
|
||||
auto icon_view = std::make_unique<image_view>();
|
||||
icon_view->set_raw_image(icon_info);
|
||||
icon_view->set_size(32, text_stack->h);
|
||||
|
||||
if (text_stack->h > 24)
|
||||
{
|
||||
const u16 pad = (text_stack->h - 24) / 2;
|
||||
icon_view->set_padding(0, 8, pad, pad);
|
||||
}
|
||||
|
||||
const auto image_size_with_padding = icon_view->w + 16;
|
||||
if (width > image_size_with_padding)
|
||||
{
|
||||
auto text = text_stack->m_items.back().get();
|
||||
static_cast<label*>(text)->auto_resize(false, width - image_size_with_padding);
|
||||
|
||||
const auto content_w = text->w + image_size_with_padding;
|
||||
const auto offset = (std::max<u16>(width, content_w) - content_w) / 2;
|
||||
|
||||
// For autosized containers, just set the initial size, let the packing grow it automatically
|
||||
this->set_size(offset, menu_entry_height);
|
||||
}
|
||||
|
||||
add_element(icon_view);
|
||||
add_element(text_stack);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "Emu/System.h"
|
||||
#include "Utilities/Config.h"
|
||||
|
||||
#include "overlay_home_icons.h"
|
||||
|
||||
namespace rsx
|
||||
{
|
||||
namespace overlays
|
||||
|
|
@ -25,7 +27,7 @@ namespace rsx
|
|||
struct home_menu_entry : horizontal_layout
|
||||
{
|
||||
public:
|
||||
home_menu_entry(const std::string& text, u16 width);
|
||||
home_menu_entry(home_menu::fa_icon icon, const std::string& text, u16 width);
|
||||
};
|
||||
|
||||
template <typename T, typename C>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace rsx
|
|||
m_sliding_animation.duration_sec = 0.5f;
|
||||
m_sliding_animation.type = animation_type::ease_in_out_cubic;
|
||||
|
||||
add_item(get_localized_string(localized_string_id::HOME_MENU_RESUME), [](pad_button btn) -> page_navigation
|
||||
add_item(home_menu::fa_icon::back, get_localized_string(localized_string_id::HOME_MENU_RESUME), [](pad_button btn) -> page_navigation
|
||||
{
|
||||
if (btn != pad_button::cross) return page_navigation::stay;
|
||||
|
||||
|
|
@ -42,11 +42,11 @@ namespace rsx
|
|||
return page_navigation::exit;
|
||||
});
|
||||
|
||||
add_page(std::make_shared<home_menu_settings>(x, y, width, height, use_separators, this));
|
||||
add_page(home_menu::fa_icon::settings, std::make_shared<home_menu_settings>(x, y, width, height, use_separators, this));
|
||||
|
||||
if (rsx::overlays::friends_list_dialog::rpcn_configured())
|
||||
{
|
||||
add_item(get_localized_string(localized_string_id::HOME_MENU_FRIENDS), [](pad_button btn) -> page_navigation
|
||||
add_item(home_menu::fa_icon::settings, get_localized_string(localized_string_id::HOME_MENU_FRIENDS), [](pad_button btn) -> page_navigation
|
||||
{
|
||||
if (btn != pad_button::cross) return page_navigation::stay;
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ namespace rsx
|
|||
}
|
||||
if (!trop_name.empty())
|
||||
{
|
||||
add_item(get_localized_string(localized_string_id::HOME_MENU_TROPHIES), [trop_name = std::move(trop_name)](pad_button btn) -> page_navigation
|
||||
add_item(home_menu::fa_icon::settings, get_localized_string(localized_string_id::HOME_MENU_TROPHIES), [trop_name = std::move(trop_name)](pad_button btn) -> page_navigation
|
||||
{
|
||||
if (btn != pad_button::cross) return page_navigation::stay;
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ namespace rsx
|
|||
});
|
||||
}
|
||||
|
||||
add_item(get_localized_string(localized_string_id::HOME_MENU_SCREENSHOT), [](pad_button btn) -> page_navigation
|
||||
add_item(home_menu::fa_icon::screenshot, get_localized_string(localized_string_id::HOME_MENU_SCREENSHOT), [](pad_button btn) -> page_navigation
|
||||
{
|
||||
if (btn != pad_button::cross) return page_navigation::stay;
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ namespace rsx
|
|||
return page_navigation::exit_for_screenshot;
|
||||
});
|
||||
|
||||
add_item(get_localized_string(localized_string_id::HOME_MENU_RECORDING), [](pad_button btn) -> page_navigation
|
||||
add_item(home_menu::fa_icon::video_camera, get_localized_string(localized_string_id::HOME_MENU_RECORDING), [](pad_button btn) -> page_navigation
|
||||
{
|
||||
if (btn != pad_button::cross) return page_navigation::stay;
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ namespace rsx
|
|||
return page_navigation::exit;
|
||||
});
|
||||
|
||||
add_item(get_localized_string(localized_string_id::HOME_MENU_TOGGLE_FULLSCREEN), [](pad_button btn) -> page_navigation
|
||||
add_item(home_menu::fa_icon::maximize, get_localized_string(localized_string_id::HOME_MENU_TOGGLE_FULLSCREEN), [](pad_button btn) -> page_navigation
|
||||
{
|
||||
if (btn != pad_button::cross)
|
||||
return page_navigation::stay;
|
||||
|
|
@ -123,9 +123,9 @@ namespace rsx
|
|||
return page_navigation::stay; // No need to exit
|
||||
});
|
||||
|
||||
add_page(std::make_shared<home_menu_savestate>(x, y, width, height, use_separators, this));
|
||||
add_page(home_menu::fa_icon::floppy, std::make_shared<home_menu_savestate>(x, y, width, height, use_separators, this));
|
||||
|
||||
add_item(get_localized_string(localized_string_id::HOME_MENU_RESTART), [](pad_button btn) -> page_navigation
|
||||
add_item(home_menu::fa_icon::restart, get_localized_string(localized_string_id::HOME_MENU_RESTART), [](pad_button btn) -> page_navigation
|
||||
{
|
||||
if (btn != pad_button::cross) return page_navigation::stay;
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ namespace rsx
|
|||
return page_navigation::exit;
|
||||
});
|
||||
|
||||
add_item(get_localized_string(localized_string_id::HOME_MENU_EXIT_GAME), [](pad_button btn) -> page_navigation
|
||||
add_item(home_menu::fa_icon::poweroff, get_localized_string(localized_string_id::HOME_MENU_EXIT_GAME), [](pad_button btn) -> page_navigation
|
||||
{
|
||||
if (btn != pad_button::cross) return page_navigation::stay;
|
||||
|
||||
|
|
@ -188,26 +188,44 @@ namespace rsx
|
|||
}
|
||||
}
|
||||
|
||||
void home_menu_main_menu::add_sidebar_entry(std::string_view title)
|
||||
void home_menu_main_menu::add_sidebar_entry(home_menu::fa_icon icon, std::string_view title)
|
||||
{
|
||||
std::unique_ptr<overlay_element> label_widget = std::make_unique<label>(title.data());
|
||||
label_widget->set_size(m_sidebar->w, 60);
|
||||
label_widget->set_font("Arial", 14);
|
||||
label_widget->set_font("Arial", 16);
|
||||
label_widget->back_color.a = 0.f;
|
||||
label_widget->set_padding(16, 4, 16, 4);
|
||||
m_sidebar->add_entry(label_widget);
|
||||
|
||||
if (icon == home_menu::fa_icon::none)
|
||||
{
|
||||
m_sidebar->add_entry(label_widget);
|
||||
return;
|
||||
}
|
||||
|
||||
auto icon_info = ensure(home_menu::get_icon(icon));
|
||||
auto icon_view = std::make_unique<image_view>();
|
||||
icon_view->set_raw_image(icon_info);
|
||||
icon_view->set_size(42, 60);
|
||||
icon_view->set_padding(18, 0, 18, 18);
|
||||
|
||||
auto box = std::make_unique<horizontal_layout>();
|
||||
box->set_size(0, 16);
|
||||
box->set_padding(1);
|
||||
box->add_element(icon_view);
|
||||
box->add_element(label_widget);
|
||||
m_sidebar->add_entry(box);
|
||||
}
|
||||
|
||||
void home_menu_main_menu::add_item(std::string_view title, std::function<page_navigation(pad_button)> callback)
|
||||
void home_menu_main_menu::add_item(home_menu::fa_icon icon, std::string_view title, std::function<page_navigation(pad_button)> callback)
|
||||
{
|
||||
add_sidebar_entry(title);
|
||||
home_menu_page::add_item(title, callback);
|
||||
add_sidebar_entry(icon, title);
|
||||
home_menu_page::add_item(home_menu::fa_icon::none, title, callback);
|
||||
}
|
||||
|
||||
void home_menu_main_menu::add_page(std::shared_ptr<home_menu_page> page)
|
||||
void home_menu_main_menu::add_page(home_menu::fa_icon icon, std::shared_ptr<home_menu_page> page)
|
||||
{
|
||||
add_sidebar_entry(page->title);
|
||||
home_menu_page::add_page(page);
|
||||
add_sidebar_entry(icon, page->title);
|
||||
home_menu_page::add_page(home_menu::fa_icon::none, page);
|
||||
}
|
||||
|
||||
void home_menu_main_menu::select_entry(s32 entry)
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ namespace rsx
|
|||
private:
|
||||
void apply_layout(bool center_vertically = false) override;
|
||||
|
||||
void add_page(std::shared_ptr<home_menu_page> page) override;
|
||||
void add_item(std::string_view title, std::function<page_navigation(pad_button)> callback) override;
|
||||
void add_page(home_menu::fa_icon icon, std::shared_ptr<home_menu_page> page) override;
|
||||
void add_item(home_menu::fa_icon icon, std::string_view title, std::function<page_navigation(pad_button)> callback) override;
|
||||
|
||||
void add_sidebar_entry(std::string_view title);
|
||||
void add_sidebar_entry(home_menu::fa_icon icon, std::string_view title);
|
||||
|
||||
u64 m_animation_timer = 0;
|
||||
animation_translate m_sliding_animation;
|
||||
|
|
|
|||
|
|
@ -92,10 +92,10 @@ namespace rsx
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void home_menu_page::add_page(std::shared_ptr<home_menu_page> page)
|
||||
void home_menu_page::add_page(home_menu::fa_icon icon, std::shared_ptr<home_menu_page> page)
|
||||
{
|
||||
ensure(page);
|
||||
std::unique_ptr<overlay_element> elem = std::make_unique<home_menu_entry>(page->title, w);
|
||||
std::unique_ptr<overlay_element> elem = std::make_unique<home_menu_entry>(icon, page->title, w);
|
||||
m_pages.push_back(page);
|
||||
|
||||
add_item(elem, [this, page](pad_button btn) -> page_navigation
|
||||
|
|
@ -114,9 +114,9 @@ namespace rsx
|
|||
m_entries.push_back(std::move(element));
|
||||
}
|
||||
|
||||
void home_menu_page::add_item(std::string_view title, std::function<page_navigation(pad_button)> callback)
|
||||
void home_menu_page::add_item(home_menu::fa_icon icon, std::string_view title, std::function<page_navigation(pad_button)> callback)
|
||||
{
|
||||
std::unique_ptr<overlay_element> title_element = std::make_unique<home_menu_entry>(title.data(), w);
|
||||
std::unique_ptr<overlay_element> title_element = std::make_unique<home_menu_entry>(icon, title.data(), w);
|
||||
add_item(title_element, callback);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Emu/RSX/Overlays/overlay_list_view.hpp"
|
||||
#include "Emu/RSX/Overlays/HomeMenu/overlay_home_icons.h"
|
||||
#include "Emu/RSX/Overlays/HomeMenu/overlay_home_menu_components.h"
|
||||
#include "Emu/RSX/Overlays/HomeMenu/overlay_home_menu_message_box.h"
|
||||
|
||||
|
|
@ -35,9 +36,9 @@ namespace rsx
|
|||
std::shared_ptr<bool> m_config_changed;
|
||||
|
||||
protected:
|
||||
virtual void add_page(std::shared_ptr<home_menu_page> page);
|
||||
virtual void add_page(home_menu::fa_icon icon, std::shared_ptr<home_menu_page> page);
|
||||
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 add_item(std::string_view, 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace rsx
|
|||
const bool suspend_mode = g_cfg.savestate.suspend_emu.get();
|
||||
|
||||
std::unique_ptr<overlay_element> save_state = std::make_unique<home_menu_entry>(
|
||||
suspend_mode ? home_menu::fa_icon::poweroff : home_menu::fa_icon::floppy,
|
||||
get_localized_string(suspend_mode ? localized_string_id::HOME_MENU_SAVESTATE_AND_EXIT : localized_string_id::HOME_MENU_SAVESTATE_SAVE), width);
|
||||
|
||||
add_item(save_state, [suspend_mode](pad_button btn) -> page_navigation
|
||||
|
|
@ -40,7 +41,7 @@ namespace rsx
|
|||
if (boot_current_game_savestate(true, save_index))
|
||||
{
|
||||
const localized_string_id str_id = static_cast<localized_string_id>(static_cast<usz>(localized_string_id::HOME_MENU_RELOAD_SAVESTATE) + (save_index - 1));
|
||||
std::unique_ptr<overlay_element> reload_state = std::make_unique<home_menu_entry>(get_localized_string(str_id), width);
|
||||
std::unique_ptr<overlay_element> reload_state = std::make_unique<home_menu_entry>(home_menu::fa_icon::restart, get_localized_string(str_id), width);
|
||||
|
||||
add_item(reload_state, [save_index](pad_button btn) -> page_navigation
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,19 +13,19 @@ namespace rsx
|
|||
m_tabs->set_pos(x, y);
|
||||
m_tabs->set_headers_background_color({ 0.25f, 0.25f, 0.25f, 0.95f });
|
||||
|
||||
add_page(std::make_shared<home_menu_settings_audio>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(std::make_shared<home_menu_settings_video>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(std::make_shared<home_menu_settings_input>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(std::make_shared<home_menu_settings_advanced>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(std::make_shared<home_menu_settings_overlays>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(std::make_shared<home_menu_settings_performance_overlay>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(std::make_shared<home_menu_settings_debug>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(home_menu::fa_icon::none, std::make_shared<home_menu_settings_audio>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(home_menu::fa_icon::none, std::make_shared<home_menu_settings_video>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(home_menu::fa_icon::none, std::make_shared<home_menu_settings_input>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(home_menu::fa_icon::none, std::make_shared<home_menu_settings_advanced>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(home_menu::fa_icon::none, std::make_shared<home_menu_settings_overlays>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(home_menu::fa_icon::none, std::make_shared<home_menu_settings_performance_overlay>(x, y, width, height, use_separators, nullptr));
|
||||
add_page(home_menu::fa_icon::none, std::make_shared<home_menu_settings_debug>(x, y, width, height, use_separators, nullptr));
|
||||
|
||||
// Select the first item
|
||||
m_tabs->set_selected_tab(0);
|
||||
}
|
||||
|
||||
void home_menu_settings::add_page(std::shared_ptr<home_menu_page> page)
|
||||
void home_menu_settings::add_page(home_menu::fa_icon icon, std::shared_ptr<home_menu_page> page)
|
||||
{
|
||||
auto panel = std::static_pointer_cast<overlay_element>(page);
|
||||
page->on_deactivate();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace rsx
|
|||
compiled_resource& get_compiled() override;
|
||||
|
||||
private:
|
||||
void add_page(std::shared_ptr<home_menu_page> page) override;
|
||||
void add_page(home_menu::fa_icon icon, std::shared_ptr<home_menu_page> page) override;
|
||||
|
||||
std::unique_ptr<tabbed_container> m_tabs;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue