rsx/overlays: Replace home menu with a sidebar
This commit is contained in:
@@ -56,6 +56,8 @@ namespace rsx
|
|||||||
m_time_display.auto_resize();
|
m_time_display.auto_resize();
|
||||||
last_time = std::move(new_time);
|
last_time = std::move(new_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_main_menu.update(timestamp_us);
|
||||||
}
|
}
|
||||||
|
|
||||||
void home_menu_dialog::on_button_pressed(pad_button button_press, bool is_auto_repeat)
|
void home_menu_dialog::on_button_pressed(pad_button button_press, bool is_auto_repeat)
|
||||||
@@ -88,6 +90,11 @@ namespace rsx
|
|||||||
std::string path = page->title;
|
std::string path = page->title;
|
||||||
for (home_menu_page* parent = page->parent; parent; parent = parent->parent)
|
for (home_menu_page* parent = page->parent; parent; parent = parent->parent)
|
||||||
{
|
{
|
||||||
|
if (parent->title.empty())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
path = parent->title + " > " + path;
|
path = parent->title + " > " + path;
|
||||||
}
|
}
|
||||||
m_description.set_text(path);
|
m_description.set_text(path);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace rsx
|
|||||||
namespace overlays
|
namespace overlays
|
||||||
{
|
{
|
||||||
home_menu_main_menu::home_menu_main_menu(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
|
home_menu_main_menu::home_menu_main_menu(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent)
|
||||||
: home_menu_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_TITLE))
|
: home_menu_page(x, y, width, height, use_separators, parent, "")
|
||||||
{
|
{
|
||||||
is_current_page = true;
|
is_current_page = true;
|
||||||
|
|
||||||
@@ -28,8 +28,15 @@ namespace rsx
|
|||||||
|
|
||||||
m_config_changed = std::make_shared<bool>(g_backup_cfg.to_string() != g_cfg.to_string());
|
m_config_changed = std::make_shared<bool>(g_backup_cfg.to_string() != g_cfg.to_string());
|
||||||
|
|
||||||
std::unique_ptr<overlay_element> resume = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_RESUME), width);
|
m_sidebar = std::make_unique<list_view>(350, height, false);
|
||||||
add_item(resume, [](pad_button btn) -> page_navigation
|
m_sidebar->set_pos(x, y);
|
||||||
|
m_sidebar->hide_prompt_buttons();
|
||||||
|
m_sidebar->back_color = color4f(0.15f, 0.15f, 0.15f, 0.85f);
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
if (btn != pad_button::cross) return page_navigation::stay;
|
if (btn != pad_button::cross) return page_navigation::stay;
|
||||||
|
|
||||||
@@ -41,8 +48,7 @@ namespace rsx
|
|||||||
|
|
||||||
if (rsx::overlays::friends_list_dialog::rpcn_configured())
|
if (rsx::overlays::friends_list_dialog::rpcn_configured())
|
||||||
{
|
{
|
||||||
std::unique_ptr<overlay_element> friends = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_FRIENDS), width);
|
add_item(get_localized_string(localized_string_id::HOME_MENU_FRIENDS), [](pad_button btn) -> page_navigation
|
||||||
add_item(friends, [](pad_button btn) -> page_navigation
|
|
||||||
{
|
{
|
||||||
if (btn != pad_button::cross) return page_navigation::stay;
|
if (btn != pad_button::cross) return page_navigation::stay;
|
||||||
|
|
||||||
@@ -76,8 +82,7 @@ namespace rsx
|
|||||||
}
|
}
|
||||||
if (!trop_name.empty())
|
if (!trop_name.empty())
|
||||||
{
|
{
|
||||||
std::unique_ptr<overlay_element> trophies = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_TROPHIES), width);
|
add_item(get_localized_string(localized_string_id::HOME_MENU_TROPHIES), [trop_name = std::move(trop_name)](pad_button btn) -> page_navigation
|
||||||
add_item(trophies, [trop_name = std::move(trop_name)](pad_button btn) -> page_navigation
|
|
||||||
{
|
{
|
||||||
if (btn != pad_button::cross) return page_navigation::stay;
|
if (btn != pad_button::cross) return page_navigation::stay;
|
||||||
|
|
||||||
@@ -93,8 +98,7 @@ namespace rsx
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<overlay_element> screenshot = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_SCREENSHOT), width);
|
add_item(get_localized_string(localized_string_id::HOME_MENU_SCREENSHOT), [](pad_button btn) -> page_navigation
|
||||||
add_item(screenshot, [](pad_button btn) -> page_navigation
|
|
||||||
{
|
{
|
||||||
if (btn != pad_button::cross) return page_navigation::stay;
|
if (btn != pad_button::cross) return page_navigation::stay;
|
||||||
|
|
||||||
@@ -102,8 +106,7 @@ namespace rsx
|
|||||||
return page_navigation::exit_for_screenshot;
|
return page_navigation::exit_for_screenshot;
|
||||||
});
|
});
|
||||||
|
|
||||||
std::unique_ptr<overlay_element> recording = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_RECORDING), width);
|
add_item(get_localized_string(localized_string_id::HOME_MENU_RECORDING), [](pad_button btn) -> page_navigation
|
||||||
add_item(recording, [](pad_button btn) -> page_navigation
|
|
||||||
{
|
{
|
||||||
if (btn != pad_button::cross) return page_navigation::stay;
|
if (btn != pad_button::cross) return page_navigation::stay;
|
||||||
|
|
||||||
@@ -112,8 +115,7 @@ namespace rsx
|
|||||||
return page_navigation::exit;
|
return page_navigation::exit;
|
||||||
});
|
});
|
||||||
|
|
||||||
std::unique_ptr<overlay_element> fullscreen = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_TOGGLE_FULLSCREEN), width);
|
add_item(get_localized_string(localized_string_id::HOME_MENU_TOGGLE_FULLSCREEN), [](pad_button btn) -> page_navigation
|
||||||
add_item(fullscreen, [](pad_button btn) -> page_navigation
|
|
||||||
{
|
{
|
||||||
if (btn != pad_button::cross)
|
if (btn != pad_button::cross)
|
||||||
return page_navigation::stay;
|
return page_navigation::stay;
|
||||||
@@ -125,8 +127,7 @@ namespace rsx
|
|||||||
|
|
||||||
add_page(std::make_shared<home_menu_savestate>(x, y, width, height, use_separators, this));
|
add_page(std::make_shared<home_menu_savestate>(x, y, width, height, use_separators, this));
|
||||||
|
|
||||||
std::unique_ptr<overlay_element> restart = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_RESTART), width);
|
add_item(get_localized_string(localized_string_id::HOME_MENU_RESTART), [](pad_button btn) -> page_navigation
|
||||||
add_item(restart, [](pad_button btn) -> page_navigation
|
|
||||||
{
|
{
|
||||||
if (btn != pad_button::cross) return page_navigation::stay;
|
if (btn != pad_button::cross) return page_navigation::stay;
|
||||||
|
|
||||||
@@ -141,8 +142,7 @@ namespace rsx
|
|||||||
return page_navigation::exit;
|
return page_navigation::exit;
|
||||||
});
|
});
|
||||||
|
|
||||||
std::unique_ptr<overlay_element> exit_game = std::make_unique<home_menu_entry>(get_localized_string(localized_string_id::HOME_MENU_EXIT_GAME), width);
|
add_item(get_localized_string(localized_string_id::HOME_MENU_EXIT_GAME), [](pad_button btn) -> page_navigation
|
||||||
add_item(exit_game, [](pad_button btn) -> page_navigation
|
|
||||||
{
|
{
|
||||||
if (btn != pad_button::cross) return page_navigation::stay;
|
if (btn != pad_button::cross) return page_navigation::stay;
|
||||||
|
|
||||||
@@ -156,5 +156,77 @@ namespace rsx
|
|||||||
|
|
||||||
apply_layout();
|
apply_layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void home_menu_main_menu::add_sidebar_entry(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", 18);
|
||||||
|
label_widget->back_color.a = 0.f;
|
||||||
|
label_widget->set_padding(16, 4, 16, 4);
|
||||||
|
m_sidebar->add_entry(label_widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void home_menu_main_menu::add_item(std::string_view title, std::function<page_navigation(pad_button)> callback)
|
||||||
|
{
|
||||||
|
add_sidebar_entry(title);
|
||||||
|
home_menu_page::add_item(title, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
void home_menu_main_menu::add_page(std::shared_ptr<home_menu_page> page)
|
||||||
|
{
|
||||||
|
add_sidebar_entry(page->title);
|
||||||
|
home_menu_page::add_page(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
void home_menu_main_menu::select_entry(s32 entry)
|
||||||
|
{
|
||||||
|
m_sidebar->select_entry(entry);
|
||||||
|
list_view::select_entry(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void home_menu_main_menu::select_next(u16 count)
|
||||||
|
{
|
||||||
|
m_sidebar->select_next(count);
|
||||||
|
list_view::select_next(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void home_menu_main_menu::select_previous(u16 count)
|
||||||
|
{
|
||||||
|
m_sidebar->select_previous(count);
|
||||||
|
list_view::select_previous(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void home_menu_main_menu::update(u64 timestamp_us)
|
||||||
|
{
|
||||||
|
if (m_animation_timer == 0)
|
||||||
|
{
|
||||||
|
m_animation_timer = timestamp_us;
|
||||||
|
m_sliding_animation.current = { -f32(m_sidebar->x + m_sidebar->w), 0, 0 };
|
||||||
|
m_sliding_animation.end = {};
|
||||||
|
m_sliding_animation.active = true;
|
||||||
|
m_sliding_animation.update(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_sliding_animation.active)
|
||||||
|
{
|
||||||
|
m_sliding_animation.update(timestamp_us);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compiled_resource& home_menu_main_menu::get_compiled()
|
||||||
|
{
|
||||||
|
m_is_compiled = true;
|
||||||
|
|
||||||
|
if (home_menu_page* page = get_current_page(false))
|
||||||
|
{
|
||||||
|
return page->get_compiled();
|
||||||
|
}
|
||||||
|
|
||||||
|
compiled_resources = m_sidebar->get_compiled();
|
||||||
|
m_sliding_animation.apply(compiled_resources);
|
||||||
|
return compiled_resources;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "overlay_home_menu_page.h"
|
#include "overlay_home_menu_page.h"
|
||||||
|
#include "../overlay_animation.h"
|
||||||
|
|
||||||
namespace rsx
|
namespace rsx
|
||||||
{
|
{
|
||||||
@@ -9,6 +10,23 @@ namespace rsx
|
|||||||
struct home_menu_main_menu : public home_menu_page
|
struct home_menu_main_menu : public home_menu_page
|
||||||
{
|
{
|
||||||
home_menu_main_menu(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
|
home_menu_main_menu(s16 x, s16 y, u16 width, u16 height, bool use_separators, home_menu_page* parent);
|
||||||
|
|
||||||
|
void select_entry(s32 entry) override;
|
||||||
|
void select_next(u16 count = 1) override;
|
||||||
|
void select_previous(u16 count = 1) override;
|
||||||
|
compiled_resource& get_compiled() override;
|
||||||
|
|
||||||
|
void update(u64 timestamp_us) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
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_sidebar_entry(std::string_view title);
|
||||||
|
|
||||||
|
u64 m_animation_timer = 0;
|
||||||
|
animation_translate m_sliding_animation;
|
||||||
|
std::unique_ptr<list_view> m_sidebar; // Render proxy
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ namespace rsx
|
|||||||
m_entries.push_back(std::move(element));
|
m_entries.push_back(std::move(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void home_menu_page::add_item(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);
|
||||||
|
add_item(title_element, callback);
|
||||||
|
}
|
||||||
|
|
||||||
void home_menu_page::apply_layout(bool center_vertically)
|
void home_menu_page::apply_layout(bool center_vertically)
|
||||||
{
|
{
|
||||||
if (!m_items.empty())
|
if (!m_items.empty())
|
||||||
@@ -308,40 +314,41 @@ namespace rsx
|
|||||||
|
|
||||||
compiled_resource& home_menu_page::get_compiled()
|
compiled_resource& home_menu_page::get_compiled()
|
||||||
{
|
{
|
||||||
if (!is_compiled() || (m_message_box && !m_message_box->is_compiled()))
|
if (m_message_box && !m_message_box->is_compiled())
|
||||||
{
|
{
|
||||||
m_is_compiled = false;
|
m_is_compiled = false;
|
||||||
|
|
||||||
if (home_menu_page* page = get_current_page(false))
|
|
||||||
{
|
|
||||||
compiled_resources = page->get_compiled();
|
|
||||||
}
|
|
||||||
else if (visible)
|
|
||||||
{
|
|
||||||
compiled_resources = list_view::get_compiled();
|
|
||||||
|
|
||||||
if (m_message_box && m_message_box->visible)
|
|
||||||
{
|
|
||||||
compiled_resources.add(m_message_box->get_compiled());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (show_reset_button())
|
|
||||||
{
|
|
||||||
compiled_resources.add(m_reset_btn.get_compiled());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_config_changed && *m_config_changed)
|
|
||||||
{
|
|
||||||
compiled_resources.add(m_save_btn.get_compiled());
|
|
||||||
compiled_resources.add(m_discard_btn.get_compiled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_is_compiled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_compiled())
|
||||||
|
{
|
||||||
|
return compiled_resources;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (home_menu_page* page = get_current_page(false))
|
||||||
|
{
|
||||||
|
compiled_resources = page->get_compiled();
|
||||||
|
}
|
||||||
|
else if (is_visible())
|
||||||
|
{
|
||||||
|
compiled_resources = list_view::get_compiled();
|
||||||
|
|
||||||
|
if (m_message_box && m_message_box->is_visible())
|
||||||
|
{
|
||||||
|
compiled_resources.add(m_message_box->get_compiled());
|
||||||
|
}
|
||||||
|
else if (m_config_changed && *m_config_changed)
|
||||||
|
{
|
||||||
|
if (show_reset_button())
|
||||||
|
{
|
||||||
|
compiled_resources.add(m_reset_btn.get_compiled());
|
||||||
|
}
|
||||||
|
|
||||||
|
compiled_resources.add(m_save_btn.get_compiled());
|
||||||
|
compiled_resources.add(m_discard_btn.get_compiled());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_is_compiled = true;
|
||||||
return compiled_resources;
|
return compiled_resources;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace rsx
|
|||||||
void on_activate();
|
void on_activate();
|
||||||
void on_deactivate();
|
void on_deactivate();
|
||||||
|
|
||||||
|
virtual void update(u64 timestamp_us) {}
|
||||||
virtual bool show_reset_button() const { return false; }
|
virtual bool show_reset_button() const { return false; }
|
||||||
|
|
||||||
bool is_current_page = false;
|
bool is_current_page = false;
|
||||||
@@ -34,8 +35,9 @@ namespace rsx
|
|||||||
std::shared_ptr<bool> m_config_changed;
|
std::shared_ptr<bool> m_config_changed;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void add_page(std::shared_ptr<home_menu_page> page);
|
virtual void add_page(std::shared_ptr<home_menu_page> page);
|
||||||
void add_item(std::unique_ptr<overlay_element>& element, 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);
|
||||||
void apply_layout(bool center_vertically = true);
|
void apply_layout(bool center_vertically = true);
|
||||||
void show_dialog(const std::string& text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
|
void show_dialog(const std::string& text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ namespace rsx
|
|||||||
|
|
||||||
void update_selection();
|
void update_selection();
|
||||||
|
|
||||||
void select_entry(s32 entry);
|
virtual void select_entry(s32 entry);
|
||||||
void select_next(u16 count = 1);
|
virtual void select_next(u16 count = 1);
|
||||||
void select_previous(u16 count = 1);
|
virtual void select_previous(u16 count = 1);
|
||||||
|
|
||||||
void add_entry(std::unique_ptr<overlay_element>& entry);
|
void add_entry(std::unique_ptr<overlay_element>& entry);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user