mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-14 18:58:36 +12:00
Fix native UI save_dialog when there are no saves (#4113)
- Also implements single action list view with cancel action only
This commit is contained in:
parent
cd8e97a7c6
commit
d37aa466ff
2 changed files with 39 additions and 1 deletions
|
@ -1331,6 +1331,8 @@ namespace rsx
|
||||||
s16 m_selected_entry = -1;
|
s16 m_selected_entry = -1;
|
||||||
u16 m_elements_count = 0;
|
u16 m_elements_count = 0;
|
||||||
|
|
||||||
|
bool m_cancel_only = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
list_view(u16 width, u16 height)
|
list_view(u16 width, u16 height)
|
||||||
{
|
{
|
||||||
|
@ -1461,6 +1463,17 @@ namespace rsx
|
||||||
return m_items[m_selected_entry]->text;
|
return m_items[m_selected_entry]->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_cancel_only(bool cancel_only)
|
||||||
|
{
|
||||||
|
if (cancel_only)
|
||||||
|
m_cancel_btn->set_pos(x + 30, y + h + 20);
|
||||||
|
else
|
||||||
|
m_cancel_btn->set_pos(x + 180, y + h + 20);
|
||||||
|
|
||||||
|
m_cancel_only = cancel_only;
|
||||||
|
is_compiled = false;
|
||||||
|
}
|
||||||
|
|
||||||
void translate(s16 _x, s16 _y) override
|
void translate(s16 _x, s16 _y) override
|
||||||
{
|
{
|
||||||
layout_container::translate(_x, _y);
|
layout_container::translate(_x, _y);
|
||||||
|
@ -1478,9 +1491,11 @@ namespace rsx
|
||||||
compiled.add(m_highlight_box->get_compiled());
|
compiled.add(m_highlight_box->get_compiled());
|
||||||
compiled.add(m_scroll_indicator_top->get_compiled());
|
compiled.add(m_scroll_indicator_top->get_compiled());
|
||||||
compiled.add(m_scroll_indicator_bottom->get_compiled());
|
compiled.add(m_scroll_indicator_bottom->get_compiled());
|
||||||
compiled.add(m_accept_btn->get_compiled());
|
|
||||||
compiled.add(m_cancel_btn->get_compiled());
|
compiled.add(m_cancel_btn->get_compiled());
|
||||||
|
|
||||||
|
if (!m_cancel_only)
|
||||||
|
compiled.add(m_accept_btn->get_compiled());
|
||||||
|
|
||||||
compiled_resources = compiled;
|
compiled_resources = compiled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,6 +254,7 @@ namespace rsx
|
||||||
std::unique_ptr<list_view> m_list;
|
std::unique_ptr<list_view> m_list;
|
||||||
std::unique_ptr<label> m_description;
|
std::unique_ptr<label> m_description;
|
||||||
std::unique_ptr<label> m_time_thingy;
|
std::unique_ptr<label> m_time_thingy;
|
||||||
|
std::unique_ptr<label> m_no_saves_text;
|
||||||
|
|
||||||
std::string current_time()
|
std::string current_time()
|
||||||
{
|
{
|
||||||
|
@ -264,6 +265,8 @@ namespace rsx
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool m_no_saves = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
save_dialog()
|
save_dialog()
|
||||||
{
|
{
|
||||||
|
@ -297,6 +300,8 @@ namespace rsx
|
||||||
switch (button_press)
|
switch (button_press)
|
||||||
{
|
{
|
||||||
case pad_button::cross:
|
case pad_button::cross:
|
||||||
|
if (m_no_saves)
|
||||||
|
break;
|
||||||
return_code = m_list->get_selected_index();
|
return_code = m_list->get_selected_index();
|
||||||
//Fall through
|
//Fall through
|
||||||
case pad_button::circle:
|
case pad_button::circle:
|
||||||
|
@ -320,6 +325,10 @@ namespace rsx
|
||||||
result.add(m_list->get_compiled());
|
result.add(m_list->get_compiled());
|
||||||
result.add(m_description->get_compiled());
|
result.add(m_description->get_compiled());
|
||||||
result.add(m_time_thingy->get_compiled());
|
result.add(m_time_thingy->get_compiled());
|
||||||
|
|
||||||
|
if (m_no_saves)
|
||||||
|
result.add(m_no_saves_text->get_compiled());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,6 +358,20 @@ namespace rsx
|
||||||
m_list->add_entry(new_stub);
|
m_list->add_entry(new_stub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_list->m_items.size())
|
||||||
|
{
|
||||||
|
m_no_saves_text = std::make_unique<label>();
|
||||||
|
m_no_saves_text->set_font("Arial", 20);
|
||||||
|
m_no_saves_text->align_text(overlay_element::text_align::center);
|
||||||
|
m_no_saves_text->set_pos(m_list->x, m_list->y + m_list->h / 2);
|
||||||
|
m_no_saves_text->set_size(m_list->w, 30);
|
||||||
|
m_no_saves_text->set_text("There is no saved data.");
|
||||||
|
m_no_saves_text->back_color.a = 0;
|
||||||
|
|
||||||
|
m_no_saves = true;
|
||||||
|
m_list->set_cancel_only(true);
|
||||||
|
}
|
||||||
|
|
||||||
static_cast<label*>(m_description.get())->auto_resize();
|
static_cast<label*>(m_description.get())->auto_resize();
|
||||||
|
|
||||||
if (auto err = run_input_loop())
|
if (auto err = run_input_loop())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue