summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend
diff options
context:
space:
mode:
authorGravatarGravatar AJR <ajrhacker@users.noreply.github.com>2019-09-26 12:26:10 -0400
committerGravatarGravatar AJR <ajrhacker@users.noreply.github.com>2019-09-26 12:26:10 -0400
commit39e33cc407c743d91685490e6ff8eae23215f9ba (patch)
tree561d9793550e2f1683a8fcbf23d40f81b477a9e7 /src/frontend
parentdefc0ce5cf1e1d5715d4d5c02b1d0799490d4fd5 (diff)
ui/menu: Move one variable down into subclasses; fix some confusing variable naming (nw)
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/mame/ui/menu.h1
-rw-r--r--src/frontend/mame/ui/selgame.cpp2
-rw-r--r--src/frontend/mame/ui/selmenu.cpp54
-rw-r--r--src/frontend/mame/ui/selmenu.h3
-rw-r--r--src/frontend/mame/ui/selsoft.cpp2
-rw-r--r--src/frontend/mame/ui/simpleselgame.cpp5
-rw-r--r--src/frontend/mame/ui/simpleselgame.h1
7 files changed, 35 insertions, 33 deletions
diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h
index 8df66a92882..16d50f7227b 100644
--- a/src/frontend/mame/ui/menu.h
+++ b/src/frontend/mame/ui/menu.h
@@ -371,7 +371,6 @@ private:
protected: // TODO: remove need to expose these
int top_line; // main box top line
- int skip_main_items;
int m_visible_lines; // main box visible lines
int m_visible_items; // number of visible items
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp
index ae86b2e2f52..6e9bbf917fe 100644
--- a/src/frontend/mame/ui/selgame.cpp
+++ b/src/frontend/mame/ui/selgame.cpp
@@ -1396,7 +1396,7 @@ void menu_select_game::make_topbox_text(std::string &line0, std::string &line1,
line0 = string_format(_("%1$s %2$s ( %3$d / %4$d machines (%5$d BIOS) )"),
emulator_info::get_appname(),
bare_build_version,
- visible_items,
+ m_available_items,
(driver_list::total() - 1),
m_persistent_data.bios_count());
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index a021348c273..6e287bc247e 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -719,10 +719,10 @@ void menu_select_launch::inkey_navigation()
switch (get_focus())
{
case focused_menu::MAIN:
- if (selected_index() <= visible_items)
+ if (selected_index() <= m_available_items)
{
m_prev_selected = get_selection_ref();
- set_selected_index(visible_items + 1);
+ set_selected_index(m_available_items + 1);
}
else
{
@@ -1382,7 +1382,7 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
m_topline_datsview--;
return;
}
- else if (selected_index() == visible_items + 1 || is_first_selected() || m_ui_error)
+ else if (selected_index() == m_available_items + 1 || is_first_selected() || m_ui_error)
{
return;
}
@@ -1405,7 +1405,7 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
m_topline_datsview++;
return;
}
- else if (is_last_selected() || selected_index() == visible_items - 1 || m_ui_error)
+ else if (is_last_selected() || selected_index() == m_available_items - 1 || m_ui_error)
{
return;
}
@@ -1425,11 +1425,11 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
return;
}
- if (selected_index() < visible_items && !m_ui_error)
+ if (selected_index() < m_available_items && !m_ui_error)
{
set_selected_index(std::max(selected_index() - m_visible_items, 0));
- top_line -= m_visible_items - (top_line + m_visible_lines == visible_items);
+ top_line -= m_visible_items - (top_line + m_visible_lines == m_available_items);
}
}
@@ -1443,9 +1443,9 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
return;
}
- if (selected_index() < visible_items && !m_ui_error)
+ if (selected_index() < m_available_items && !m_ui_error)
{
- set_selected_index(std::min(selected_index() + m_visible_lines - 2 + (selected_index() == 0), visible_items - 1));
+ set_selected_index(std::min(selected_index() + m_visible_lines - 2 + (selected_index() == 0), m_available_items - 1));
top_line += m_visible_lines - 2;
}
@@ -1464,7 +1464,7 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
return;
}
- if (selected_index() < visible_items && !m_ui_error)
+ if (selected_index() < m_available_items && !m_ui_error)
select_first_item();
}
@@ -1481,8 +1481,8 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
return;
}
- if (selected_index() < visible_items && !m_ui_error)
- set_selected_index(top_line = visible_items - 1);
+ if (selected_index() < m_available_items && !m_ui_error)
+ set_selected_index(top_line = m_available_items - 1);
}
// pause enables/disables pause
@@ -1554,7 +1554,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
{
if (hover() >= 0 && hover() < item_count())
{
- if (hover() >= visible_items - 1 && selected_index() < visible_items)
+ if (hover() >= m_available_items - 1 && selected_index() < m_available_items)
m_prev_selected = get_selection_ref();
set_selected_index(hover());
m_focus = focused_menu::MAIN;
@@ -1562,12 +1562,12 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
else if (hover() == HOVER_ARROW_UP)
{
set_selected_index(std::max(selected_index() - m_visible_items, 0));
- top_line -= m_visible_items - (top_line + m_visible_lines == visible_items);
+ top_line -= m_visible_items - (top_line + m_visible_lines == m_available_items);
set_pressed();
}
else if (hover() == HOVER_ARROW_DOWN)
{
- set_selected_index(std::min(selected_index() + m_visible_lines - 2 + (selected_index() == 0), visible_items - 1));
+ set_selected_index(std::min(selected_index() + m_visible_lines - 2 + (selected_index() == 0), m_available_items - 1));
top_line += m_visible_lines - 2;
set_pressed();
}
@@ -1653,7 +1653,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
{
if (local_menu_event.zdelta > 0)
{
- if (selected_index() >= visible_items || is_first_selected() || m_ui_error)
+ if (selected_index() >= m_available_items || is_first_selected() || m_ui_error)
break;
set_selected_index(selected_index() - local_menu_event.num_lines);
if (selected_index() < top_line + (top_line != 0))
@@ -1661,9 +1661,9 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
}
else
{
- if (selected_index() >= visible_items - 1 || m_ui_error)
+ if (selected_index() >= m_available_items - 1 || m_ui_error)
break;
- set_selected_index(std::min(selected_index() + local_menu_event.num_lines, visible_items - 1));
+ set_selected_index(std::min(selected_index() + local_menu_event.num_lines, m_available_items - 1));
if (selected_index() >= top_line + m_visible_items + (top_line != 0))
top_line += local_menu_event.num_lines;
}
@@ -1759,7 +1759,7 @@ void menu_select_launch::draw(uint32_t flags)
draw_background();
clear_hover();
- visible_items = (m_is_swlist) ? item_count() - 2 : item_count() - 2 - skip_main_items;
+ m_available_items = (m_is_swlist) ? item_count() - 2 : item_count() - 2 - skip_main_items;
float extra_height = (m_is_swlist) ? 2.0f * line_height : (2.0f + skip_main_items) * line_height;
float visible_extra_menu_height = get_customtop() + get_custombottom() + extra_height;
@@ -1802,21 +1802,21 @@ void menu_select_launch::draw(uint32_t flags)
float line = visible_top + (float(m_visible_lines) * line_height);
ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
- if (visible_items < m_visible_lines)
- m_visible_lines = visible_items;
+ if (m_available_items < m_visible_lines)
+ m_visible_lines = m_available_items;
if (top_line < 0 || is_first_selected())
top_line = 0;
- if (selected_index() < visible_items && top_line + m_visible_lines >= visible_items)
- top_line = visible_items - m_visible_lines;
+ if (selected_index() < m_available_items && top_line + m_visible_lines >= m_available_items)
+ top_line = m_available_items - m_visible_lines;
// determine effective positions taking into account the hilighting arrows
float effective_width = visible_width - 2.0f * gutter_width;
float effective_left = visible_left + gutter_width;
- if ((m_focus == focused_menu::MAIN) && (selected_index() < visible_items))
+ if ((m_focus == focused_menu::MAIN) && (selected_index() < m_available_items))
m_prev_selected = nullptr;
- int const n_loop = (std::min)(m_visible_lines, visible_items);
+ int const n_loop = (std::min)(m_visible_lines, m_available_items);
for (int linenum = 0; linenum < n_loop; linenum++)
{
float line_y = visible_top + (float)linenum * line_height;
@@ -1871,7 +1871,7 @@ void menu_select_launch::draw(uint32_t flags)
if (hover() == itemnum)
set_hover(HOVER_ARROW_UP);
}
- else if (linenum == m_visible_lines - 1 && itemnum != visible_items - 1)
+ else if (linenum == m_visible_lines - 1 && itemnum != m_available_items - 1)
{
// if we're on the bottom line, display the down arrow
draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height,
@@ -1938,7 +1938,7 @@ void menu_select_launch::draw(uint32_t flags)
}
}
- for (size_t count = visible_items; count < item_count(); count++)
+ for (size_t count = m_available_items; count < item_count(); count++)
{
const menu_item &pitem = item(count);
const char *itemtext = pitem.text.c_str();
@@ -1993,7 +1993,7 @@ void menu_select_launch::draw(uint32_t flags)
custom_render(get_selection_ref(), get_customtop(), get_custombottom(), x1, y1, x2, y2);
// return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow
- m_visible_items = m_visible_lines - (top_line != 0) - (top_line + m_visible_lines != visible_items);
+ m_visible_items = m_visible_lines - (top_line != 0) - (top_line + m_visible_lines != m_available_items);
// noinput
if (noinput)
diff --git a/src/frontend/mame/ui/selmenu.h b/src/frontend/mame/ui/selmenu.h
index 728ca02cd32..01d98aa8be0 100644
--- a/src/frontend/mame/ui/selmenu.h
+++ b/src/frontend/mame/ui/selmenu.h
@@ -156,7 +156,8 @@ protected:
return (uintptr_t(selected_ref) > skip_main_items) ? selected_ref : m_prev_selected;
}
- int visible_items;
+ int m_available_items;
+ int skip_main_items;
void *m_prev_selected;
int m_total_lines;
int m_topline_datsview;
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index ef5d6a5d1c3..6f2ecd5ee4f 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -633,7 +633,7 @@ void menu_select_software::get_selection(ui_software_info const *&software, game
void menu_select_software::make_topbox_text(std::string &line0, std::string &line1, std::string &line2) const
{
// determine the text for the header
- int vis_item = !m_search.empty() ? visible_items : (m_has_empty_start ? visible_items - 1 : visible_items);
+ int vis_item = !m_search.empty() ? m_available_items : (m_has_empty_start ? m_available_items - 1 : m_available_items);
line0 = string_format(_("%1$s %2$s ( %3$d / %4$d software packages )"), emulator_info::get_appname(), bare_build_version, vis_item, m_swinfo.size() - 1);
line1 = string_format(_("Driver: \"%1$s\" software list "), m_driver.type.fullname());
diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp
index a2334a3485d..20ce36c9b2d 100644
--- a/src/frontend/mame/ui/simpleselgame.cpp
+++ b/src/frontend/mame/ui/simpleselgame.cpp
@@ -37,6 +37,7 @@ simple_menu_select_game::simple_menu_select_game(mame_ui_manager &mui, render_co
: menu(mui, container)
, m_error(false), m_rerandomize(false)
, m_search()
+ , m_skip_main_items(0)
, m_driverlist(driver_list::total() + 1)
, m_drivlist()
, m_cached_driver(nullptr)
@@ -275,7 +276,7 @@ void simple_menu_select_game::populate(float &customtop, float &custombottom)
{
item_append(menu_item_type::SEPARATOR);
item_append(_("Configure Options"), "", 0, (void *)1);
- skip_main_items = 1;
+ m_skip_main_items = 1;
}
// configure the custom rendering
@@ -307,7 +308,7 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float
ui().colors().text_color(), ui().colors().background_color(), 1.0f);
// determine the text to render below
- driver = ((uintptr_t)selectedref > skip_main_items) ? (const game_driver *)selectedref : nullptr;
+ driver = ((uintptr_t)selectedref > m_skip_main_items) ? (const game_driver *)selectedref : nullptr;
if (driver)
{
// first line is game name
diff --git a/src/frontend/mame/ui/simpleselgame.h b/src/frontend/mame/ui/simpleselgame.h
index e56dac8185b..96383c3b458 100644
--- a/src/frontend/mame/ui/simpleselgame.h
+++ b/src/frontend/mame/ui/simpleselgame.h
@@ -48,6 +48,7 @@ private:
bool m_error;
bool m_rerandomize;
std::string m_search;
+ int m_skip_main_items;
int m_matchlist[VISIBLE_GAMES_IN_LIST];
std::vector<const game_driver *> m_driverlist;
std::unique_ptr<driver_enumerator> m_drivlist;