overlays: review fixes

This commit is contained in:
Megamouse 2023-02-07 23:35:52 +01:00
parent 69435dd951
commit cfb788941c
11 changed files with 80 additions and 100 deletions

View File

@ -19,28 +19,24 @@ namespace rsx
}
home_menu_dialog::home_menu_dialog()
: m_main_menu(20, 85, virtual_width - 2 * 20, 540, false, nullptr)
{
m_allow_input_on_pause = true;
m_dim_background = std::make_unique<overlay_element>();
m_dim_background->set_size(overlay::virtual_width, overlay::virtual_height);
m_dim_background->back_color.a = 0.5f;
m_dim_background.set_size(virtual_width, virtual_height);
m_dim_background.back_color.a = 0.5f;
m_main_menu = std::make_unique<home_menu_main_menu>(20, 85, 1240, 540, false, nullptr);
m_description.set_font("Arial", 20);
m_description.set_pos(20, 37);
m_description.set_text(m_main_menu.title);
m_description.auto_resize();
m_description.back_color.a = 0.f;
m_description = std::make_unique<label>();
m_description->set_font("Arial", 20);
m_description->set_pos(20, 37);
m_description->set_text(m_main_menu->title);
m_description->auto_resize();
m_description->back_color.a = 0.f;
m_time_display = std::make_unique<label>();
m_time_display->set_font("Arial", 14);
m_time_display->set_text(get_time_string());
m_time_display->auto_resize();
m_time_display->set_pos(overlay::virtual_width - (20 + m_time_display->w), (m_description->y + m_description->h) - m_time_display->h);
m_time_display->back_color.a = 0.f;
m_time_display.set_font("Arial", 14);
m_time_display.set_text(get_time_string());
m_time_display.auto_resize();
m_time_display.set_pos(virtual_width - (20 + m_time_display.w), (m_description.y + m_description.h) - m_time_display.h);
m_time_display.back_color.a = 0.f;
fade_animation.duration = 0.15f;
@ -71,8 +67,8 @@ namespace rsx
if (last_time != new_time)
{
m_time_display->set_text(new_time);
m_time_display->auto_resize();
m_time_display.set_text(new_time);
m_time_display.auto_resize();
last_time = std::move(new_time);
}
}
@ -95,22 +91,22 @@ namespace rsx
break;
}
const page_navigation navigation = m_main_menu->handle_button_press(button_press);
const page_navigation navigation = m_main_menu.handle_button_press(button_press);
switch (navigation)
{
case page_navigation::back:
case page_navigation::next:
{
if (home_menu_page* page = m_main_menu->get_current_page(true))
if (home_menu_page* page = m_main_menu.get_current_page(true))
{
std::string path = page->title;
for (home_menu_page* parent = page->parent; parent; parent = parent->parent)
{
path = parent->title + " > " + path;
}
m_description->set_text(path);
m_description->auto_resize();
m_description.set_text(path);
m_description.auto_resize();
}
break;
}
@ -149,10 +145,10 @@ namespace rsx
}
compiled_resource result;
result.add(m_dim_background->get_compiled());
result.add(m_main_menu->get_compiled());
result.add(m_description->get_compiled());
result.add(m_time_display->get_compiled());
result.add(m_dim_background.get_compiled());
result.add(m_main_menu.get_compiled());
result.add(m_description.get_compiled());
result.add(m_time_display.get_compiled());
fade_animation.apply(result);

View File

@ -11,7 +11,7 @@ namespace rsx
struct home_menu_dialog : public user_interface
{
public:
explicit home_menu_dialog();
home_menu_dialog();
void update() override;
void on_button_pressed(pad_button button_press) override;
@ -21,12 +21,12 @@ namespace rsx
error_code show(std::function<void(s32 status)> on_close);
private:
std::unique_ptr<overlay_element> m_dim_background;
std::unique_ptr<home_menu_main_menu> m_main_menu;
std::unique_ptr<label> m_description;
std::unique_ptr<label> m_time_display;
home_menu_main_menu m_main_menu;
overlay_element m_dim_background{};
label m_description{};
label m_time_display{};
animation_color_interpolate fade_animation;
animation_color_interpolate fade_animation{};
};
}
}

View File

@ -9,42 +9,37 @@ namespace rsx
{
home_menu_message_box::home_menu_message_box(u16 x, u16 y, u16 width, u16 height)
: overlay_element()
, m_accept_btn(120, 30)
, m_cancel_btn(120, 30)
{
back_color = {0.15f, 0.15f, 0.15f, 0.95f};
set_size(width, height);
set_pos(x, y);
m_label = std::make_unique<label>();
m_label->align_text(text_align::center);
m_label->set_font("Arial", 16);
m_label->back_color.a = 0.0f;
m_accept_btn = std::make_unique<image_button>(120, 20);
m_cancel_btn = std::make_unique<image_button>(120, 20);
m_accept_btn->set_size(120, 30);
m_cancel_btn->set_size(120, 30);
m_label.align_text(text_align::center);
m_label.set_font("Arial", 16);
m_label.back_color.a = 0.0f;
if (g_cfg.sys.enter_button_assignment == enter_button_assign::circle)
{
m_accept_btn->set_image_resource(resource_config::standard_image_resource::circle);
m_cancel_btn->set_image_resource(resource_config::standard_image_resource::cross);
m_accept_btn.set_image_resource(resource_config::standard_image_resource::circle);
m_cancel_btn.set_image_resource(resource_config::standard_image_resource::cross);
}
else
{
m_accept_btn->set_image_resource(resource_config::standard_image_resource::cross);
m_cancel_btn->set_image_resource(resource_config::standard_image_resource::circle);
m_accept_btn.set_image_resource(resource_config::standard_image_resource::cross);
m_cancel_btn.set_image_resource(resource_config::standard_image_resource::circle);
}
m_accept_btn->set_pos(x + 30, y + height + 20);
m_cancel_btn->set_pos(x + 180, y + height + 20);
m_accept_btn.set_pos(x + 30, y + height + 20);
m_cancel_btn.set_pos(x + 180, y + 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);
m_accept_btn.set_text(localized_string_id::RSX_OVERLAYS_LIST_SELECT);
m_cancel_btn.set_text(localized_string_id::RSX_OVERLAYS_LIST_CANCEL);
m_accept_btn->set_font("Arial", 16);
m_cancel_btn->set_font("Arial", 16);
m_accept_btn.set_font("Arial", 16);
m_cancel_btn.set_font("Arial", 16);
}
compiled_resource& home_menu_message_box::get_compiled()
@ -52,9 +47,9 @@ namespace rsx
if (!is_compiled)
{
compiled_resource& compiled = overlay_element::get_compiled();
compiled.add(m_label->get_compiled());
compiled.add(m_cancel_btn->get_compiled());
compiled.add(m_accept_btn->get_compiled());
compiled.add(m_label.get_compiled());
compiled.add(m_cancel_btn.get_compiled());
compiled.add(m_accept_btn.get_compiled());
}
return compiled_resources;
}
@ -63,9 +58,9 @@ namespace rsx
{
m_on_accept = std::move(on_accept);
m_on_cancel = std::move(on_cancel);
m_label->set_text(text);
m_label->auto_resize();
m_label->set_pos(x + (w - m_label->w) / 2, y + (h - m_label->h) / 2);
m_label.set_text(text);
m_label.auto_resize();
m_label.set_pos(x + (w - m_label.w) / 2, y + (h - m_label.h) / 2);
m_visible = true;
refresh();
}

View File

@ -18,9 +18,9 @@ namespace rsx
private:
bool m_visible = false;
std::unique_ptr<label> m_label;
std::unique_ptr<image_button> m_cancel_btn;
std::unique_ptr<image_button> m_accept_btn;
label m_label{};
image_button m_accept_btn;
image_button m_cancel_btn;
std::function<void()> m_on_accept;
std::function<void()> m_on_cancel;
};

View File

@ -11,6 +11,8 @@ namespace rsx
: list_view(width, height, use_separators)
, parent(parent)
, title(title)
, m_save_btn(120, 30)
, m_discard_btn(120, 30)
{
if (parent)
{
@ -18,23 +20,17 @@ namespace rsx
m_config_changed = parent->m_config_changed;
}
m_save_btn = std::make_unique<image_button>(120, 20);
m_discard_btn = std::make_unique<image_button>(120, 20);
m_save_btn.set_image_resource(resource_config::standard_image_resource::square);
m_discard_btn.set_image_resource(resource_config::standard_image_resource::triangle);
m_save_btn->set_size(120, 30);
m_discard_btn->set_size(120, 30);
m_save_btn.set_pos(width - 2 * (30 + 120), height + 20);
m_discard_btn.set_pos(width - (30 + 120), height + 20);
m_save_btn->set_image_resource(resource_config::standard_image_resource::square);
m_discard_btn->set_image_resource(resource_config::standard_image_resource::triangle);
m_save_btn.set_text(localized_string_id::HOME_MENU_SETTINGS_SAVE_BUTTON);
m_discard_btn.set_text(localized_string_id::HOME_MENU_SETTINGS_DISCARD_BUTTON);
m_save_btn->set_pos(width - 2 * (30 + 120), height + 20);
m_discard_btn->set_pos(width - (30 + 120), height + 20);
m_save_btn->set_text(localized_string_id::HOME_MENU_SETTINGS_SAVE_BUTTON);
m_discard_btn->set_text(localized_string_id::HOME_MENU_SETTINGS_DISCARD_BUTTON);
m_save_btn->set_font("Arial", 16);
m_discard_btn->set_font("Arial", 16);
m_save_btn.set_font("Arial", 16);
m_discard_btn.set_font("Arial", 16);
set_pos(x, y);
}
@ -248,8 +244,8 @@ namespace rsx
void home_menu_page::translate(s16 _x, s16 _y)
{
list_view::translate(_x, _y);
m_save_btn->translate(_x, _y);
m_discard_btn->translate(_x, _y);
m_save_btn.translate(_x, _y);
m_discard_btn.translate(_x, _y);
}
compiled_resource& home_menu_page::get_compiled()
@ -272,8 +268,8 @@ namespace rsx
}
else if (m_config_changed && *m_config_changed)
{
compiled_resources.add(m_save_btn->get_compiled());
compiled_resources.add(m_discard_btn->get_compiled());
compiled_resources.add(m_save_btn.get_compiled());
compiled_resources.add(m_discard_btn.get_compiled());
}
}

View File

@ -37,8 +37,8 @@ namespace rsx
std::vector<std::shared_ptr<home_menu_page>> m_pages;
private:
std::unique_ptr<image_button> m_save_btn;
std::unique_ptr<image_button> m_discard_btn;
image_button m_save_btn;
image_button m_discard_btn;
std::vector<std::unique_ptr<overlay_element>> m_entries;
std::vector<std::function<page_navigation(pad_button)>> m_callbacks;
};

View File

@ -128,7 +128,7 @@ namespace rsx
media_list_dialog::media_list_dialog()
{
m_dim_background = std::make_unique<overlay_element>();
m_dim_background->set_size(overlay::virtual_width, overlay::virtual_height);
m_dim_background->set_size(virtual_width, virtual_height);
m_dim_background->back_color.a = 0.5f;
m_description = std::make_unique<label>();
@ -269,7 +269,7 @@ namespace rsx
status_flags |= status_bits::invalidate_image_cache;
}
m_list = std::make_unique<list_view>(1240, 540);
m_list = std::make_unique<list_view>(virtual_width - 2 * 20, 540);
m_list->set_pos(20, 85);
for (const media_entry& child : m_media->children)

View File

@ -16,7 +16,7 @@ namespace rsx
message_dialog::message_dialog(bool allow_custom_background)
: custom_background_allowed(allow_custom_background)
{
background.set_size(overlay::virtual_width, overlay::virtual_height);
background.set_size(virtual_width, virtual_height);
background.back_color.a = 0.85f;
text_display.set_size(1100, 40);
@ -367,7 +367,7 @@ namespace rsx
background_poster.fore_color = color4f(color, color, color, 1.);
background.back_color.a = 0.f;
background_poster.set_size(overlay::virtual_width, overlay::virtual_height);
background_poster.set_size(virtual_width, virtual_height);
background_poster.set_raw_image(background_image.get());
background_poster.set_blur_strength(static_cast<u8>(background_blur_strength));

View File

@ -82,9 +82,9 @@ namespace rsx
save_dialog::save_dialog()
{
m_dim_background = std::make_unique<overlay_element>();
m_dim_background->set_size(overlay::virtual_width, overlay::virtual_height);
m_dim_background->set_size(virtual_width, virtual_height);
m_list = std::make_unique<list_view>(1240, 540);
m_list = std::make_unique<list_view>(virtual_width - 2 * 20, 540);
m_description = std::make_unique<label>();
m_time_thingy = std::make_unique<label>();

View File

@ -69,10 +69,10 @@ namespace rsx
user_list_dialog::user_list_dialog()
{
m_dim_background = std::make_unique<overlay_element>();
m_dim_background->set_size(overlay::virtual_width, overlay::virtual_height);
m_dim_background->set_size(virtual_width, virtual_height);
m_dim_background->back_color.a = 0.5f;
m_list = std::make_unique<list_view>(1240, 540);
m_list = std::make_unique<list_view>(virtual_width - 2 * 20, 540);
m_list->set_pos(20, 85);
m_description = std::make_unique<label>();

View File

@ -70,11 +70,11 @@ void main_application::OnEmuSettingsChange()
{
if (g_cfg.misc.prevent_display_sleep)
{
enable_display_sleep();
disable_display_sleep();
}
else
{
disable_display_sleep();
enable_display_sleep();
}
}
@ -83,14 +83,7 @@ void main_application::OnEmuSettingsChange()
if (!Emu.IsStopped())
{
// Force audio provider
if (Emu.IsVsh())
{
g_cfg.audio.provider.set(audio_provider::rsxaudio);
}
else
{
g_cfg.audio.provider.set(audio_provider::cell_audio);
}
g_cfg.audio.provider.set(Emu.IsVsh() ? audio_provider::rsxaudio : audio_provider::cell_audio);
}
audio::configure_audio();