Skip to content

Commit

Permalink
-frontend: Fixed crashes switching between favourites and other filters.
Browse files Browse the repository at this point in the history
* Also made the system and software selection menus a bit less eager to
  reselect the first item.

-docs: Bumped documentation version to 0.238.
  • Loading branch information
cuavas committed Nov 23, 2021
1 parent 8077a9e commit 5668590
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs/source/conf.py
Expand Up @@ -56,16 +56,16 @@

# General information about the project.
project = u'MAME Documentation'
copyright = u'2021, MAMEdev Team'
copyright = u'1997-2021, MAMEdev and contributors'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.237'
version = '0.238'
# The full version, including alpha/beta/rc tags.
release = '0.237'
release = '0.238'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
12 changes: 8 additions & 4 deletions src/frontend/mame/ui/selgame.cpp
Expand Up @@ -341,6 +341,8 @@ void menu_select_game::populate(float &customtop, float &custombottom)

if (!isfavorite())
{
if (m_populated_favorites)
m_prev_selected = nullptr;
m_populated_favorites = false;
m_displaylist.clear();
machine_filter const *const flt(m_persistent_data.filter_data().get_current_filter());
Expand Down Expand Up @@ -399,6 +401,8 @@ void menu_select_game::populate(float &customtop, float &custombottom)
else
{
// populate favorites list
if (!m_populated_favorites)
m_prev_selected = nullptr;
m_populated_favorites = true;
m_search.clear();
mame_machine_manager::instance()->favorite().apply_sorted(
Expand All @@ -412,8 +416,8 @@ void menu_select_game::populate(float &customtop, float &custombottom)
bool cloneof = strcmp(info.driver->parent, "0");
if (cloneof)
{
int cx = driver_list::find(info.driver->parent);
if (cx != -1 && ((driver_list::driver(cx).flags & machine_flags::IS_BIOS_ROOT) != 0))
int const cx = driver_list::find(info.driver->parent);
if ((0 <= cx) && ((driver_list::driver(cx).flags & machine_flags::IS_BIOS_ROOT) != 0))
cloneof = false;
}

Expand Down Expand Up @@ -1036,7 +1040,7 @@ void menu_select_game::get_selection(ui_software_info const *&software, ui_syste
if (m_populated_favorites)
{
software = reinterpret_cast<ui_software_info const *>(get_selection_ptr());
system = &m_persistent_data.systems()[driver_list::find(software->driver->name)];
system = software ? &m_persistent_data.systems()[driver_list::find(software->driver->name)] : nullptr;
}
else
{
Expand Down Expand Up @@ -1100,7 +1104,7 @@ void menu_select_game::filter_selected()
}
}
m_persistent_data.filter_data().set_current_filter_type(new_type);
reset(reset_options::SELECT_FIRST);
reset(reset_options::REMEMBER_REF);
});
}
}
Expand Down
25 changes: 17 additions & 8 deletions src/frontend/mame/ui/selmenu.cpp
Expand Up @@ -1419,7 +1419,6 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
}
else if (m_focus == focused_menu::LEFT)
{
m_prev_selected = nullptr;
filter_selected();
}
return;
Expand Down Expand Up @@ -1774,7 +1773,6 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
}
else if (hover() >= HOVER_FILTER_FIRST && hover() <= HOVER_FILTER_LAST)
{
m_prev_selected = nullptr;
m_filter_highlight = hover() - HOVER_FILTER_FIRST;
filter_selected();
stop = true;
Expand Down Expand Up @@ -1953,18 +1951,29 @@ void menu_select_launch::draw(uint32_t flags)
// make sure the selection
if (m_available_items < m_visible_lines)
m_visible_lines = m_available_items;
if (top_line < 0 || is_first_selected())
int selection;
if (selected_index() < m_available_items)
{
selection = selected_index();
}
else
{
selection = 0;
while ((m_available_items > selection) && (item(selection).ref() != m_prev_selected))
++selection;
}
if (top_line < 0 || !selection)
{
top_line = 0;
}
else if (selected_index() < m_available_items)
else if (selection < m_available_items)
{
if (selected_index() >= (top_line + m_visible_lines))
top_line = selected_index() - (m_visible_lines / 2);
if ((selection >= (top_line + m_visible_lines)) || (selection <= top_line))
top_line = (std::max)(selection - (m_visible_lines / 2), 0);
if ((top_line + m_visible_lines) >= m_available_items)
top_line = m_available_items - m_visible_lines;
else if (selected_index() >= (top_line + m_visible_lines - 2))
top_line = selected_index() - m_visible_lines + ((selected_index() == (m_available_items - 1)) ? 1: 2);
else if (selection >= (top_line + m_visible_lines - 2))
top_line = selection - m_visible_lines + ((selection == (m_available_items - 1)) ? 1: 2);
}

// determine effective positions taking into account the hilighting arrows
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/mame/ui/selsoft.cpp
Expand Up @@ -741,7 +741,7 @@ void menu_select_software::filter_selected()
}
}
m_data->set_filter_type(new_type);
reset(reset_options::SELECT_FIRST);
reset(reset_options::REMEMBER_REF);
});
}
}
Expand Down

0 comments on commit 5668590

Please sign in to comment.