summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2019-05-22 11:35:39 -0400
committer AJR <ajrhacker@users.noreply.github.com>2019-05-22 11:35:39 -0400
commitb085fad792639d0da2e236ad45fdf71f740e8aa8 (patch)
tree5f680d0dec4042f92ea8642ace1d4636c76ad1a8
parentaa724006054f7d7cd0c4bd66119ad7342f008649 (diff)
ui/menu.cpp: Privatize a few variables (nw)
-rw-r--r--src/frontend/mame/ui/datmenu.cpp16
-rw-r--r--src/frontend/mame/ui/dirmenu.cpp16
-rw-r--r--src/frontend/mame/ui/menu.cpp168
-rw-r--r--src/frontend/mame/ui/menu.h50
-rw-r--r--src/frontend/mame/ui/selector.cpp2
-rw-r--r--src/frontend/mame/ui/selgame.cpp8
-rw-r--r--src/frontend/mame/ui/selmenu.cpp172
-rw-r--r--src/frontend/mame/ui/selmenu.h8
-rw-r--r--src/frontend/mame/ui/selsoft.cpp6
-rw-r--r--src/frontend/mame/ui/sliders.cpp4
-rw-r--r--src/frontend/mame/ui/utils.cpp2
11 files changed, 225 insertions, 227 deletions
diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp
index 344cc59ee84..52e7416a43e 100644
--- a/src/frontend/mame/ui/datmenu.cpp
+++ b/src/frontend/mame/ui/datmenu.cpp
@@ -156,7 +156,7 @@ void menu_dats_view::draw(uint32_t flags)
float const visible_left = (1.0f - visible_width) * 0.5f;
float const extra_height = 2.0f * line_height;
float const visible_extra_menu_height = get_customtop() + get_custombottom() + extra_height;
- int const visible_items = item.size() - 2;
+ int const visible_items = item_count() - 2;
// determine effective positions taking into account the hilighting arrows
float const effective_width = visible_width - 2.0f * gutter_width;
@@ -187,13 +187,13 @@ void menu_dats_view::draw(uint32_t flags)
if (top_line + m_visible_lines >= visible_items)
top_line = visible_items - m_visible_lines;
- hover = item.size() + 1;
+ clear_hover();
int const n_loop = (std::min)(visible_items, m_visible_lines);
for (int linenum = 0; linenum < n_loop; linenum++)
{
float const line_y = visible_top + (float)linenum * line_height;
int const itemnum = top_line + linenum;
- menu_item const &pitem = item[itemnum];
+ menu_item const &pitem = item(itemnum);
char const *const itemtext = pitem.text.c_str();
float const line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
float const line_y0 = line_y;
@@ -211,7 +211,7 @@ void menu_dats_view::draw(uint32_t flags)
fgcolor = UI_MOUSEOVER_COLOR;
bgcolor = UI_MOUSEOVER_BG_COLOR;
highlight(line_x0, line_y0, line_x1, line_y1, bgcolor);
- hover = HOVER_ARROW_UP;
+ set_hover(HOVER_ARROW_UP);
}
draw_arrow(
0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height,
@@ -226,7 +226,7 @@ void menu_dats_view::draw(uint32_t flags)
fgcolor = UI_MOUSEOVER_COLOR;
bgcolor = UI_MOUSEOVER_BG_COLOR;
highlight(line_x0, line_y0, line_x1, line_y1, bgcolor);
- hover = HOVER_ARROW_DOWN;
+ set_hover(HOVER_ARROW_DOWN);
}
draw_arrow(
0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height,
@@ -245,9 +245,9 @@ void menu_dats_view::draw(uint32_t flags)
}
}
- for (size_t count = visible_items; count < item.size(); count++)
+ for (size_t count = visible_items; count < item_count(); count++)
{
- menu_item const &pitem = item[count];
+ menu_item const &pitem = item(count);
char const *const itemtext = pitem.text.c_str();
float const line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
float const line_y0 = line;
@@ -257,7 +257,7 @@ void menu_dats_view::draw(uint32_t flags)
rgb_t const bgcolor = UI_SELECTED_BG_COLOR;
if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem))
- hover = count;
+ set_hover(count);
if (pitem.type == menu_item_type::SEPARATOR)
{
diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp
index f3939089f25..77e64b8463d 100644
--- a/src/frontend/mame/ui/dirmenu.cpp
+++ b/src/frontend/mame/ui/dirmenu.cpp
@@ -250,7 +250,7 @@ void menu_add_change_folder::handle()
if (menu_event->iptkey == IPT_UI_SELECT)
{
int index = (uintptr_t)menu_event->itemref - 1;
- const menu_item &pitem = item[index];
+ const menu_item &pitem = item(index);
// go up to the parent path
if (!strcmp(pitem.text.c_str(), ".."))
@@ -330,39 +330,39 @@ void menu_add_change_folder::handle()
int entry, bestmatch = 0;
// from current item to the end
- for (entry = cur_selected; entry < item.size(); entry++)
- if (item[entry].ref != nullptr && !m_search.empty())
+ for (entry = cur_selected; entry < item_count(); entry++)
+ if (item(entry).ref != nullptr && !m_search.empty())
{
int match = 0;
for (int i = 0; i < m_search.size() + 1; i++)
{
- if (core_strnicmp(item[entry].text.c_str(), m_search.data(), i) == 0)
+ if (core_strnicmp(item(entry).text.c_str(), m_search.data(), i) == 0)
match = i;
}
if (match > bestmatch)
{
bestmatch = match;
- selected = entry;
+ set_selected_index(entry);
}
}
// and from the first item to current one
for (entry = 0; entry < cur_selected; entry++)
{
- if (item[entry].ref != nullptr && !m_search.empty())
+ if (item(entry).ref != nullptr && !m_search.empty())
{
int match = 0;
for (int i = 0; i < m_search.size() + 1; i++)
{
- if (core_strnicmp(item[entry].text.c_str(), m_search.data(), i) == 0)
+ if (core_strnicmp(item(entry).text.c_str(), m_search.data(), i) == 0)
match = i;
}
if (match > bestmatch)
{
bestmatch = match;
- selected = entry;
+ set_selected_index(entry);
}
}
}
diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp
index eecaab68978..67addfa1a21 100644
--- a/src/frontend/mame/ui/menu.cpp
+++ b/src/frontend/mame/ui/menu.cpp
@@ -287,16 +287,16 @@ void menu::reset(reset_options options)
m_resetpos = 0;
m_resetref = nullptr;
if (options == reset_options::REMEMBER_POSITION)
- m_resetpos = selected;
+ m_resetpos = m_selected;
else if (options == reset_options::REMEMBER_REF)
m_resetref = get_selection_ref();
- // reset all the pools and the item.size() back to 0
+ // reset all the pools and the item count back to 0
for (pool *ppool = m_pool; ppool != nullptr; ppool = ppool->next)
ppool->top = (uint8_t *)(ppool + 1);
- item.clear();
+ m_items.clear();
m_visible_items = 0;
- selected = 0;
+ m_selected = 0;
// add an item to return
if (!m_parent)
@@ -383,11 +383,11 @@ void menu::item_append(std::string &&text, std::string &&subtext, uint32_t flags
{
// only allow multiline as the first item
if ((flags & FLAG_MULTILINE) != 0)
- assert(item.size() == 1);
+ assert(m_items.size() == 1);
// only allow a single multi-line item
- else if (item.size() >= 2)
- assert((item[0].flags & FLAG_MULTILINE) == 0);
+ else if (m_items.size() >= 2)
+ assert((m_items[0].flags & FLAG_MULTILINE) == 0);
// allocate a new item and populate it
menu_item pitem;
@@ -398,20 +398,20 @@ void menu::item_append(std::string &&text, std::string &&subtext, uint32_t flags
pitem.type = type;
// append to array
- auto index = item.size();
- if (!item.empty())
+ auto index = m_items.size();
+ if (!m_items.empty())
{
- item.emplace(item.end() - 1, std::move(pitem));
+ m_items.emplace(m_items.end() - 1, std::move(pitem));
--index;
}
else
- item.emplace_back(std::move(pitem));
+ m_items.emplace_back(std::move(pitem));
// update the selection if we need to
if (m_resetpos == index || (m_resetref != nullptr && m_resetref == ref))
- selected = index;
- if (m_resetpos == (item.size() - 1))
- selected = item.size() - 1;
+ m_selected = index;
+ if (m_resetpos == (m_items.size() - 1))
+ m_selected = m_items.size() - 1;
}
@@ -456,7 +456,7 @@ const menu::event *menu::process(uint32_t flags, float x0, float y0)
validate_selection(1);
// draw the menu
- if (item.size() > 1 && (item[0].flags & FLAG_MULTILINE) != 0)
+ if (m_items.size() > 1 && (m_items[0].flags & FLAG_MULTILINE) != 0)
draw_text_box();
else
draw(flags);
@@ -476,7 +476,7 @@ const menu::event *menu::process(uint32_t flags, float x0, float y0)
if ((m_event.iptkey != IPT_INVALID) && selection_valid())
{
m_event.itemref = get_selection_ref();
- m_event.type = item[selected].type;
+ m_event.type = m_items[m_selected].type;
return &m_event;
}
else
@@ -525,12 +525,12 @@ void *menu::m_pool_alloc(size_t size)
void menu::set_selection(void *selected_itemref)
{
- selected = -1;
- for (int itemnum = 0; itemnum < item.size(); itemnum++)
+ m_selected = -1;
+ for (int itemnum = 0; itemnum < m_items.size(); itemnum++)
{
- if (item[itemnum].ref == selected_itemref)
+ if (m_items[itemnum].ref == selected_itemref)
{
- selected = itemnum;
+ m_selected = itemnum;
break;
}
}
@@ -569,7 +569,7 @@ void menu::draw(uint32_t flags)
// compute the width and height of the full menu
float visible_width = 0;
float visible_main_menu_height = 0;
- for (auto const &pitem : item)
+ for (auto const &pitem : m_items)
{
// compute width of left hand side
float total_width = gutter_width + ui().get_string_width(pitem.text.c_str()) + gutter_width;
@@ -601,7 +601,7 @@ void menu::draw(uint32_t flags)
if (visible_main_menu_height + visible_extra_menu_height + 2.0f * UI_BOX_TB_BORDER > 1.0f)
visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height;
- m_visible_lines = std::min(int(std::floor(visible_main_menu_height / line_height)), int(unsigned(item.size())));
+ m_visible_lines = std::min(int(std::floor(visible_main_menu_height / line_height)), int(unsigned(m_items.size())));
visible_main_menu_height = float(m_visible_lines) * line_height;
// compute top/left of inner menu area by centering
@@ -618,14 +618,14 @@ void menu::draw(uint32_t flags)
if (top_line < 0 || is_first_selected())
top_line = 0;
- if (selected >= (top_line + m_visible_lines))
- top_line = selected - (m_visible_lines / 2);
- if ((top_line > (item.size() - m_visible_lines)) || is_last_selected())
- top_line = item.size() - m_visible_lines;
+ if (m_selected >= (top_line + m_visible_lines))
+ top_line = m_selected - (m_visible_lines / 2);
+ if ((top_line > (m_items.size() - m_visible_lines)) || is_last_selected())
+ top_line = m_items.size() - m_visible_lines;
// if scrolling, show arrows
- bool const show_top_arrow((item.size() > m_visible_lines) && !first_item_visible());
- bool const show_bottom_arrow((item.size() > m_visible_lines) && !last_item_visible());
+ bool const show_top_arrow((m_items.size() > m_visible_lines) && !first_item_visible());
+ bool const show_bottom_arrow((m_items.size() > m_visible_lines) && !last_item_visible());
// set the number of visible lines, minus 1 for top arrow and 1 for bottom arrow
m_visible_items = m_visible_lines - (show_top_arrow ? 1 : 0) - (show_bottom_arrow ? 1 : 0);
@@ -641,7 +641,7 @@ void menu::draw(uint32_t flags)
ignore_mouse();
// loop over visible lines
- hover = item.size() + 1;
+ m_hover = m_items.size() + 1;
bool selected_subitem_too_big = false;
float const line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
float const line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
@@ -650,7 +650,7 @@ void menu::draw(uint32_t flags)
for (int linenum = 0; linenum < m_visible_lines; linenum++)
{
auto const itemnum = top_line + linenum;
- menu_item const &pitem = item[itemnum];
+ menu_item const &pitem = m_items[itemnum];
char const *const itemtext = pitem.text.c_str();
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
@@ -661,7 +661,7 @@ void menu::draw(uint32_t flags)
// set the hover if this is our item
if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem))
- hover = itemnum;
+ m_hover = itemnum;
// if we're selected, draw with a different background
if (is_selected(itemnum))
@@ -671,7 +671,7 @@ void menu::draw(uint32_t flags)
}
// else if the mouse is over this item, draw with a different background
- else if (itemnum == hover)
+ else if (itemnum == m_hover)
{
fgcolor = fgcolor2 = fgcolor3 = UI_MOUSEOVER_COLOR;
bgcolor = UI_MOUSEOVER_BG_COLOR;
@@ -691,8 +691,8 @@ void menu::draw(uint32_t flags)
line_y0 + 0.75f * line_height,
fgcolor,
ROT0);
- if (hover == itemnum)
- hover = HOVER_ARROW_UP;
+ if (m_hover == itemnum)
+ m_hover = HOVER_ARROW_UP;
}
else if (linenum == m_visible_lines - 1 && show_bottom_arrow)
{
@@ -704,8 +704,8 @@ void menu::draw(uint32_t flags)
line_y0 + 0.75f * line_height,
fgcolor,
ROT0 ^ ORIENTATION_FLIP_Y);
- if (hover == itemnum)
- hover = HOVER_ARROW_DOWN;
+ if (m_hover == itemnum)
+ m_hover = HOVER_ARROW_DOWN;
}
else if (pitem.type == menu_item_type::SEPARATOR)
{
@@ -803,7 +803,7 @@ void menu::draw(uint32_t flags)
{
menu_item const &pitem = selected_item();
bool const subitem_invert(pitem.flags & FLAG_INVERT);
- auto const linenum = selected - top_line;
+ auto const linenum = m_selected - top_line;
float const line_y = visible_top + (float)linenum * line_height;
float target_width, target_height;
@@ -844,8 +844,8 @@ void menu::custom_render(void *selectedref, float top, float bottom, float x, fl
void menu::draw_text_box()
{
- const char *text = item[0].text.c_str();
- const char *backtext = item[1].text.c_str();
+ const char *text = m_items[0].text.c_str();
+ const char *backtext = m_items[1].text.c_str();
float line_height = ui().get_line_height();
float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect();
float gutter_width = lr_arrow_width;
@@ -882,7 +882,7 @@ void menu::draw_text_box()
target_y - UI_BOX_TB_BORDER,
target_x + target_width + gutter_width + UI_BOX_LR_BORDER,
target_y + target_height + UI_BOX_TB_BORDER,
- (item[0].flags & FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR);
+ (m_items[0].flags & FLAG_REDTEXT) ? UI_RED_COLOR : UI_BACKGROUND_COLOR);
ui().draw_text_full(container(), text, target_x, target_y, target_width,
ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
@@ -897,7 +897,7 @@ void menu::draw_text_box()
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr);
// artificially set the hover to the last item so a double-click exits
- hover = item.size() - 1;
+ m_hover = m_items.size() - 1;
}
@@ -955,30 +955,30 @@ void menu::handle_events(uint32_t flags, event &ev)
if ((flags & PROCESS_ONLYCHAR) == 0)
{
- if (hover >= 0 && hover < item.size())
- selected = hover;
- else if (hover == HOVER_ARROW_UP)
+ if (m_hover >= 0 && m_hover < m_items.size())
+ m_selected = m_hover;
+ else if (m_hover == HOVER_ARROW_UP)
{
if ((flags & FLAG_UI_DATS) != 0)
{
top_line -= m_visible_items - (last_item_visible() ? 1 : 0);
return;
}
- selected -= m_visible_items;
- if (selected < 0)
- selected = 0;
+ m_selected -= m_visible_items;
+ if (m_selected < 0)
+ m_selected = 0;
top_line -= m_visible_items - (last_item_visible() ? 1 : 0);
}
- else if (hover == HOVER_ARROW_DOWN)
+ else if (m_hover == HOVER_ARROW_DOWN)
{
if ((flags & FLAG_UI_DATS) != 0)
{
top_line += m_visible_lines - 2;
return;
}
- selected += m_visible_lines - 2 + is_first_selected();
- if (selected > item.size() - 1)
- selected = item.size() - 1;
+ m_selected += m_visible_lines - 2 + is_first_selected();
+ if (m_selected > m_items.size() - 1)
+ m_selected = m_items.size() - 1;
top_line += m_visible_lines - 2;
}
}
@@ -986,9 +986,9 @@ void menu::handle_events(uint32_t flags, event &ev)
// if we are hovering over a valid item, fake a UI_SELECT with a double-click
case ui_event::MOUSE_DOUBLE_CLICK:
- if (!(flags & PROCESS_ONLYCHAR) && hover >= 0 && hover < item.size())
+ if (!(flags & PROCESS_ONLYCHAR) && m_hover >= 0 && m_hover < m_items.size())
{
- selected = hover;
+ m_selected = m_hover;
ev.iptkey = IPT_UI_SELECT;
if (is_last_selected())
{
@@ -1010,10 +1010,10 @@ void menu::handle_events(uint32_t flags, event &ev)
top_line -= local_menu_event.num_lines;
return;
}
- is_first_selected() ? selected = top_line = item.size() - 1 : selected -= local_menu_event.num_lines;
+ is_first_selected() ? m_selected = top_line = m_items.size() - 1 : m_selected -= local_menu_event.num_lines;
validate_selection(-1);
- top_line -= (selected <= top_line && top_line != 0);
- if (selected <= top_line && m_visible_items != m_visible_lines)
+ top_line -= (m_selected <= top_line && top_line != 0);
+ if (m_selected <= top_line && m_visible_items != m_visible_lines)
top_line -= local_menu_event.num_lines;
}
else
@@ -1023,10 +1023,10 @@ void menu::handle_events(uint32_t flags, event &ev)
top_line += local_menu_event.num_lines;
return;
}
- is_last_selected() ? selected = top_line = 0 : selected += local_menu_event.num_lines;
+ is_last_selected() ? m_selected = top_line = 0 : m_selected += local_menu_event.num_lines;
validate_selection(1);
- top_line += (selected >= top_line + m_visible_items + (top_line != 0));
- if (selected >= (top_line + m_visible_items + (top_line != 0)))
+ top_line += (m_selected >= top_line + m_visible_items + (top_line != 0));
+ if (m_selected >= (top_line + m_visible_items + (top_line != 0)))
top_line += local_menu_event.num_lines;
}
}
@@ -1058,7 +1058,7 @@ void menu::handle_keys(uint32_t flags, int &iptkey)
int code;
// bail if no items
- if (item.empty())
+ if (m_items.empty())
return;
// if we hit select, return true or pop the stack, depending on the item
@@ -1091,7 +1091,7 @@ void menu::handle_keys(uint32_t flags, int &iptkey)
bool ignoreleft = ((selected_item().flags & FLAG_LEFT_ARROW) == 0);
bool ignoreright = ((selected_item().flags & FLAG_RIGHT_ARROW) == 0);
- if ((item[0].flags & FLAG_UI_DATS))
+ if ((m_items[0].flags & FLAG_UI_DATS))
ignoreleft = ignoreright = false;
// accept left/right keys as-is with repeat
@@ -1103,65 +1103,65 @@ void menu::handle_keys(uint32_t flags, int &iptkey)
// up backs up by one item
if (exclusive_input_pressed(iptkey, IPT_UI_UP, 6))
{
- if ((item[0].flags & FLAG_UI_DATS))
+ if ((m_items[0].flags & FLAG_UI_DATS))
{
top_line--;
return;
}
- is_first_selected() ? selected = top_line = item.size() - 1 : --selected;
+ is_first_selected() ? m_selected = top_line = m_items.size() - 1 : --m_selected;
validate_selection(-1);
- top_line -= (selected <= top_line && top_line != 0);
- if (selected <= top_line && m_visible_items != m_visible_lines)
+ top_line -= (m_selected <= top_line && top_line != 0);
+ if (m_selected <= top_line && m_visible_items != m_visible_lines)
top_line--;
}
// down advances by one item
if (exclusive_input_pressed(iptkey, IPT_UI_DOWN, 6))
{
- if ((item[0].flags & FLAG_UI_DATS))
+ if ((m_items[0].flags & FLAG_UI_DATS))
{
top_line++;
return;
}
- is_last_selected() ? selected = top_line = 0 : ++selected;
+ is_last_selected() ? m_selected = top_line = 0 : ++m_selected;
validate_selection(1);
- top_line += (selected >= top_line + m_visible_items + (top_line != 0));
- if (selected >= (top_line + m_visible_items + (top_line != 0)))
+ top_line += (m_selected >= top_line + m_visible_items + (top_line != 0));
+ if (m_selected >= (top_line + m_visible_items + (top_line != 0)))
top_line++;
}
// page up backs up by m_visible_items
if (exclusive_input_pressed(iptkey, IPT_UI_PAGE_UP, 6))
{
- selected -= m_visible_items;
+ m_selected -= m_visible_items;
top_line -= m_visible_items - (last_item_visible() ? 1 : 0);
- if (selected < 0)
- selected = 0;
+ if (m_selected < 0)
+ m_selected = 0;
validate_selection(1);
}
// page down advances by m_visible_items
if (exclusive_input_pressed(iptkey, IPT_UI_PAGE_DOWN, 6))
{
- selected += m_visible_lines - 2 + is_first_selected();
+ m_selected += m_visible_lines - 2 + is_first_selected();
top_line += m_visible_lines - 2;
- if (selected > item.size() - 1)
- selected = item.size() - 1;
+ if (m_selected > m_items.size() - 1)
+ m_selected = m_items.size() - 1;
validate_selection(-1);
}
// home goes to the start
if (exclusive_input_pressed(iptkey, IPT_UI_HOME, 0))
{
- selected = top_line = 0;
+ m_selected = top_line = 0;
validate_selection(1);
}
// end goes to the last
if (exclusive_input_pressed(iptkey, IPT_UI_END, 0))
{
- selected = top_line = item.size() - 1;
+ m_selected = top_line = m_items.size() - 1;
validate_selection(-1);
}
@@ -1201,14 +1201,14 @@ void menu::handle_keys(uint32_t flags, int &iptkey)
void menu::validate_selection(int scandir)
{
// clamp to be in range
- if (selected < 0)
- selected = 0;
- else if (selected >= item.size())
- selected = item.size() - 1;
+ if (m_selected < 0)
+ m_selected = 0;
+ else if (m_selected >= m_items.size())
+ m_selected = m_items.size() - 1;
// skip past unselectable items
- while (!is_selectable(item[selected]))
- selected = (selected + item.size() + scandir) % item.size();
+ while (!is_selectable(m_items[m_selected]))
+ m_selected = (m_selected + m_items.size() + scandir) % m_items.size();
}
@@ -1219,7 +1219,7 @@ void menu::validate_selection(int scandir)
void menu::do_handle()
{
- if (item.size() < 2)
+ if (m_items.size() < 2)
populate(m_customtop, m_custombottom);
handle();
}
diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h
index ffcb0ed71e8..0b472b80f0c 100644
--- a/src/frontend/mame/ui/menu.h
+++ b/src/frontend/mame/ui/menu.h
@@ -130,16 +130,6 @@ protected:
render_bounds mouse; // mouse position if iptkey == IPT_CUSTOM
};
- int hover; // which item is being hovered over
- std::vector<menu_item> item; // array of items
-
- int top_line; // main box top line
- int skip_main_items;
- int selected; // which item is selected
-
- int m_visible_lines; // main box visible lines
- int m_visible_items; // number of visible items
-
menu(mame_ui_manager &mui, render_container &container);
mame_ui_manager &ui() const { return m_ui; }
@@ -167,22 +157,31 @@ protected:
const event *process(uint32_t flags, float x0 = 0.0f, float y0 = 0.0f);
void process_parent() { m_parent->process(PROCESS_NOINPUT); }
+ menu_item &item(int index) { return m_items[index]; }
+ menu_item const &item(int index) const { return m_items[index]; }
+ int item_count() const { return m_items.size(); }
+
// retrieves the ref of the currently selected menu item or nullptr
- void *get_selection_ref() const { return selection_valid() ? item[selected].ref : nullptr; }
+ void *get_selection_ref() const { return selection_valid() ? m_items[m_selected].ref : nullptr; }
- menu_item &selected_item() { return item[selected]; }
- menu_item const &selected_item() const { return item[selected]; }
- int selected_index() const { return selected; }
- bool selection_valid() const { return (0 <= selected) && (item.size() > selected); }
- bool is_selected(int index) const { return selection_valid() && (selected == index); }
- bool is_first_selected() const { return 0 == selected; }
- bool is_last_selected() const { return (item.size() - 1) == selected; }
+ menu_item &selected_item() { return m_items[m_selected]; }
+ menu_item const &selected_item() const { return m_items[m_selected]; }
+ int selected_index() const { return m_selected; }
+ bool selection_valid() const { return (0 <= m_selected) && (m_items.size() > m_selected); }
+ bool is_selected(int index) const { return selection_valid() && (m_selected == index); }
+ bool is_first_selected() const { return 0 == m_selected; }
+ bool is_last_selected() const { return (m_items.size() - 1) == m_selected; }
// changes the index of the currently selected menu item
void set_selection(void *selected_itemref);
+ void set_selected_index(int index) { m_selected = index; }
+
+ int hover() const { return m_hover; }
+ void set_hover(int index) { m_hover = index; }
+ void clear_hover() { m_hover = m_items.size() + 1; }
// scroll position control
- void centre_selection() { top_line = selected - (m_visible_lines / 2); }
+ void centre_selection() { top_line = m_selected - (m_visible_lines / 2); }
// test if the given key is pressed and we haven't already reported a key
bool exclusive_input_pressed(int &iptkey, int key, int repeat);
@@ -356,7 +355,7 @@ private:
void extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction);
bool first_item_visible() const { return top_line <= 0; }
- bool last_item_visible() const { return (top_line + m_visible_lines) >= item.size(); }
+ bool last_item_visible() const { return (top_line + m_visible_lines) >= m_items.size(); }
static void exit(running_machine &machine);
static global_state_ptr get_global_state(running_machine &machine);
@@ -364,6 +363,17 @@ private:
static char const *get_c_str(std::string const &str) { return str.c_str(); }
static char const *get_c_str(char const *str) { return str; }
+ int m_selected; // which item is selected
+ int m_hover; // which item is being hovered over
+ std::vector<menu_item> m_items; // array of items
+
+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
+
+private:
global_state_ptr const m_global_state;
bool m_special_main_menu;
mame_ui_manager &m_ui; // UI we are attached to
diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp
index 83738641142..3ad8aef995a 100644
--- a/src/frontend/mame/ui/selector.cpp
+++ b/src/frontend/mame/ui/selector.cpp
@@ -95,7 +95,7 @@ void menu_selector::populate(float &customtop, float &custombottom)
for (size_t index = 0; index < m_str_items.size(); ++index)
{
if ((0 <= m_initial) && (unsigned(m_initial) == index))
- selected = index;
+ set_selected_index(index);
item_append(m_str_items[index], "", 0, (void *)&m_str_items[index]);
}
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp
index def4ceaa5f9..b9a7fffed35 100644
--- a/src/frontend/mame/ui/selgame.cpp
+++ b/src/frontend/mame/ui/selgame.cpp
@@ -319,7 +319,7 @@ menu_select_game::~menu_select_game()
void menu_select_game::handle()
{
if (!m_prev_selected)
- m_prev_selected = item[0].ref;
+ m_prev_selected = item(0).ref;
// if I have to load datfile, perform a hard reset
if (ui_globals::reset)
@@ -622,11 +622,11 @@ void menu_select_game::populate(float &customtop, float &custombottom)
// reselect prior game launched, if any
if (old_item_selected != -1)
{
- selected = old_item_selected;
+ set_selected_index(old_item_selected);
if (ui_globals::visible_main_lines == 0)
- top_line = (selected != 0) ? selected - 1 : 0;
+ top_line = (selected_index() != 0) ? selected_index() - 1 : 0;
else
- top_line = selected - (ui_globals::visible_main_lines / 2);
+ top_line = selected_index() - (ui_globals::visible_main_lines / 2);
if (reselect_last::software().empty())
reselect_last::reset();
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index 306c2cad1f0..16f514afebe 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 <= visible_items)
+ if (selected_index() <= visible_items)
{
m_prev_selected = get_selection_ref();
- selected = visible_items + 1;
+ set_selected_index(visible_items + 1);
}
else
{
@@ -731,9 +731,9 @@ void menu_select_launch::inkey_navigation()
else if (ui_globals::panels_status == HIDE_BOTH)
{
- for (int x = 0; x < item.size(); ++x)
- if (item[x].ref == m_prev_selected)
- selected = x;
+ for (int x = 0; x < item_count(); ++x)
+ if (item(x).ref == m_prev_selected)
+ set_selected_index(x);
}
else
{
@@ -815,14 +815,14 @@ void menu_select_launch::draw_common_arrow(float origx1, float origy1, float ori
{
ui().draw_textured_box(container(), ar_x0 + 0.01f, ar_y0, ar_x1 - 0.01f, ar_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43),
hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1));
- hover = HOVER_UI_RIGHT;
+ set_hover(HOVER_UI_RIGHT);
fgcolor_right = UI_MOUSEOVER_COLOR;
}
else if (mouse_in_rect(al_x0, al_y0, al_x1, al_y1) && current != dmin)
{
ui().draw_textured_box(container(), al_x0 + 0.01f, al_y0, al_x1 - 0.01f, al_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43),
hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1));
- hover = HOVER_UI_LEFT;
+ set_hover(HOVER_UI_LEFT);
fgcolor_left = UI_MOUSEOVER_COLOR;
}
@@ -854,7 +854,7 @@ void menu_select_launch::draw_info_arrow(int ub, float origx1, float origx2, flo
{
ui().draw_textured_box(container(), origx1 + 0.01f, oy1, origx2 - 0.01f, oy1 + (line_height * text_size), UI_MOUSEOVER_BG_COLOR,
rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1));
- hover = (!ub) ? HOVER_DAT_UP : HOVER_DAT_DOWN;
+ set_hover((!ub) ? HOVER_DAT_UP : HOVER_DAT_DOWN);
fgcolor = UI_MOUSEOVER_COLOR;
}
@@ -937,7 +937,7 @@ float menu_select_launch::draw_left_panel(
{
bgcolor = UI_MOUSEOVER_BG_COLOR;
fgcolor = UI_MOUSEOVER_COLOR;
- hover = HOVER_FILTER_FIRST + filter;
+ set_hover(HOVER_FILTER_FIRST + filter);
highlight(x1, y1, x2, y1 + line_height_max, bgcolor);
}
@@ -983,7 +983,7 @@ float menu_select_launch::draw_left_panel(
if (mouse_in_rect(x1, y1, x2, y2))
{
fgcolor = UI_MOUSEOVER_COLOR;
- hover = HOVER_LPANEL_ARROW;
+ set_hover(HOVER_LPANEL_ARROW);
}
draw_arrow(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor, ROT90 ^ ORIENTATION_FLIP_X);
@@ -1203,7 +1203,7 @@ void menu_select_launch::draw_toolbar(float x1, float y1, float x2, float y2)
rgb_t color(0xEFEFEFEF);
if (mouse_in_rect(x1, y1, x2, y2))
{
- hover = HOVER_B_FAV + z;
+ set_hover(HOVER_B_FAV + z);
color = rgb_t::white();
float ypos = y2 + ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
ui().draw_text_box(container(), _(hover_msg[z]), ui::text_layout::CENTER, 0.5f, ypos, UI_BACKGROUND_COLOR);
@@ -1301,7 +1301,7 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
bool const ignorepause = stack_has_special_main_menu();
// bail if no items
- if (item.size() == 0)
+ if (item_count() == 0)
return;
// if we hit select, return true or pop the stack, depending on the item
@@ -1382,14 +1382,14 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
m_topline_datsview--;
return;
}
- else if (selected == visible_items + 1 || is_first_selected() || m_ui_error)
+ else if (selected_index() == visible_items + 1 || is_first_selected() || m_ui_error)
{
return;
}
- selected--;
+ set_selected_index(selected_index() - 1);
- if (selected == top_line && top_line != 0)
+ if (selected_index() == top_line && top_line != 0)
top_line--;
}
@@ -1405,13 +1405,13 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
m_topline_datsview++;
return;
}
- else if (is_last_selected() || selected == visible_items - 1 || m_ui_error)
+ else if (is_last_selected() || selected_index() == visible_items - 1 || m_ui_error)
{
return;
}
- selected++;
- if (selected == top_line + m_visible_items + (top_line != 0))
+ set_selected_index(selected_index() + 1);
+ if (selected_index() == top_line + m_visible_items + (top_line != 0))
top_line++;
}
@@ -1425,12 +1425,9 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
return;
}
- if (selected < visible_items && !m_ui_error)
+ if (selected_index() < visible_items && !m_ui_error)
{
- selected -= m_visible_items;
-
- if (selected < 0)
- selected = 0;
+ set_selected_index(std::max(selected_index() - m_visible_items, 0));
top_line -= m_visible_items - (top_line + m_visible_lines == visible_items);
}
@@ -1446,12 +1443,9 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
return;
}
- if (selected < visible_items && !m_ui_error)
+ if (selected_index() < visible_items && !m_ui_error)
{
- selected += m_visible_lines - 2 + (selected == 0);
-
- if (selected >= visible_items)
- selected = visible_items - 1;
+ set_selected_index(std::min(selected_index() + m_visible_lines - 2 + (selected_index() == 0), visible_items - 1));
top_line += m_visible_lines - 2;
}
@@ -1470,9 +1464,9 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
return;
}
- if (selected < visible_items && !m_ui_error)
+ if (selected_index() < visible_items && !m_ui_error)
{
- selected = 0;
+ set_selected_index(0);
top_line = 0;
}
}
@@ -1490,8 +1484,8 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
return;
}
- if (selected < visible_items && !m_ui_error)
- selected = top_line = visible_items - 1;
+ if (selected_index() < visible_items && !m_ui_error)
+ set_selected_index(top_line = visible_items - 1);
}
// pause enables/disables pause
@@ -1534,7 +1528,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
int32_t target_x, target_y;
bool button;
render_target *const mouse_target = machine().ui_input().find_mouse(&target_x, &target_y, &button);
- if (mouse_target && button && (hover == HOVER_ARROW_DOWN || hover == HOVER_ARROW_UP))
+ if (mouse_target && button && (hover() == HOVER_ARROW_DOWN || hover() == HOVER_ARROW_UP))
{
if (pressed)
machine().ui_input().push_mouse_down_event(mouse_target, target_x, target_y);
@@ -1561,38 +1555,34 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
}
else
{
- if (hover >= 0 && hover < item.size())
+ if (hover() >= 0 && hover() < item_count())
{
- if (hover >= visible_items - 1 && selected < visible_items)
+ if (hover() >= visible_items - 1 && selected_index() < visible_items)
m_prev_selected = get_selection_ref();
- selected = hover;
+ set_selected_index(hover());
m_focus = focused_menu::MAIN;
}
- else if (hover == HOVER_ARROW_UP)
+ else if (hover() == HOVER_ARROW_UP)
{
- selected -= m_visible_items;
- if (selected < 0)
- selected = 0;
+ set_selected_index(std::max(selected_index() - m_visible_items, 0));
top_line -= m_visible_items - (top_line + m_visible_lines == visible_items);
set_pressed();
}
- else if (hover == HOVER_ARROW_DOWN)
+ else if (hover() == HOVER_ARROW_DOWN)
{
- selected += m_visible_lines - 2 + (selected == 0);
- if (selected >= visible_items)
- selected = visible_items - 1;
+ set_selected_index(std::min(selected_index() + m_visible_lines - 2 + (selected_index() == 0), visible_items - 1));
top_line += m_visible_lines - 2;
set_pressed();
}
- else if (hover == HOVER_UI_RIGHT)
+ else if (hover() == HOVER_UI_RIGHT)
ev.iptkey = IPT_UI_RIGHT;
- else if (hover == HOVER_UI_LEFT)
+ else if (hover() == HOVER_UI_LEFT)
ev.iptkey = IPT_UI_LEFT;
- else if (hover == HOVER_DAT_DOWN)
+ else if (hover() == HOVER_DAT_DOWN)
m_topline_datsview += m_right_visible_lines - 1;
- else if (hover == HOVER_DAT_UP)
+ else if (hover() == HOVER_DAT_UP)
m_topline_datsview -= m_right_visible_lines - 1;
- else if (hover == HOVER_LPANEL_ARROW)
+ else if (hover() == HOVER_LPANEL_ARROW)
{
if (ui_globals::panels_status == HIDE_LEFT_PANEL)
ui_globals::panels_status = SHOW_PANELS;
@@ -1603,7 +1593,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
else if (ui_globals::panels_status == HIDE_RIGHT_PANEL)
ui_globals::panels_status = HIDE_BOTH;
}
- else if (hover == HOVER_RPANEL_ARROW)
+ else if (hover() == HOVER_RPANEL_ARROW)
{
if (ui_globals::panels_status == HIDE_RIGHT_PANEL)
ui_globals::panels_status = SHOW_PANELS;
@@ -1614,30 +1604,30 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
else if (ui_globals::panels_status == HIDE_LEFT_PANEL)
ui_globals::panels_status = HIDE_BOTH;
}
- else if (hover == HOVER_B_FAV)
+ else if (hover() == HOVER_B_FAV)
{
ev.iptkey = IPT_UI_FAVORITES;
stop = true;
}
- else if (hover == HOVER_B_EXPORT)
+ else if (hover() == HOVER_B_EXPORT)
{
inkey_export();
stop = true;
}
- else if (hover == HOVER_B_DATS)
+ else if (hover() == HOVER_B_DATS)
{
inkey_dats();
stop = true;
}
- else if (hover >= HOVER_RP_FIRST && hover <= HOVER_RP_LAST)
+ else if (hover() >= HOVER_RP_FIRST && hover() <= HOVER_RP_LAST)
{
- ui_globals::rpanel = (HOVER_RP_FIRST - hover) * (-1);
+ ui_globals::rpanel = (HOVER_RP_FIRST - hover()) * (-1);
stop = true;
}
- else if (hover >= HOVER_FILTER_FIRST && hover <= HOVER_FILTER_LAST)
+ else if (hover() >= HOVER_FILTER_FIRST && hover() <= HOVER_FILTER_LAST)
{
m_prev_selected = nullptr;
- m_filter_highlight = hover - HOVER_FILTER_FIRST;
+ m_filter_highlight = hover() - HOVER_FILTER_FIRST;
filter_selected();
stop = true;
}
@@ -1646,9 +1636,9 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
// if we are hovering over a valid item, fake a UI_SELECT with a double-click
case ui_event::MOUSE_DOUBLE_CLICK:
- if (hover >= 0 && hover < item.size())
+ if (hover() >= 0 && hover() < item_count())
{
- selected = hover;
+ set_selected_index(hover());
ev.iptkey = IPT_UI_SELECT;
}
@@ -1662,28 +1652,26 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
// caught scroll event
case ui_event::MOUSE_WHEEL:
- if (hover >= 0 && hover < item.size() - skip_main_items - 1)
+ if (hover() >= 0 && hover() < item_count() - skip_main_items - 1)
{
if (local_menu_event.zdelta > 0)
{
- if (selected >= visible_items || is_first_selected() || m_ui_error)
+ if (selected_index() >= visible_items || is_first_selected() || m_ui_error)
break;
- selected -= local_menu_event.num_lines;
- if (selected < top_line + (top_line != 0))
+ set_selected_index(selected_index() - local_menu_event.num_lines);
+ if (selected_index() < top_line + (top_line != 0))
top_line -= local_menu_event.num_lines;
}
else
{
- if (selected >= visible_items - 1 || m_ui_error)
+ if (selected_index() >= visible_items - 1 || m_ui_error)
break;
- selected += local_menu_event.num_lines;
- if (selected > visible_items - 1)
- selected = visible_items - 1;
- if (selected >= top_line + m_visible_items + (top_line != 0))
+ set_selected_index(std::min(selected_index() + local_menu_event.num_lines, visible_items - 1));
+ if (selected_index() >= top_line + m_visible_items + (top_line != 0))
top_line += local_menu_event.num_lines;
}
}
- else if (hover == HOVER_INFO_TEXT)
+ else if (hover() == HOVER_INFO_TEXT)
{
if (local_menu_event.zdelta > 0)
m_topline_datsview -= local_menu_event.num_lines;
@@ -1712,9 +1700,9 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
break;
case ui_event::MOUSE_RDOWN:
- if (hover >= 0 && hover < item.size() - skip_main_items - 1)
+ if (hover() >= 0 && hover() < item_count() - skip_main_items - 1)
{
- selected = hover;
+ set_selected_index(hover());
m_prev_selected = get_selection_ref();
m_focus = focused_menu::MAIN;
ev.iptkey = IPT_CUSTOM;
@@ -1773,8 +1761,8 @@ void menu_select_launch::draw(uint32_t flags)
draw_background();
- hover = item.size() + 1;
- visible_items = (m_is_swlist) ? item.size() - 2 : item.size() - 2 - skip_main_items;
+ clear_hover();
+ visible_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;
@@ -1821,14 +1809,14 @@ void menu_select_launch::draw(uint32_t flags)
m_visible_lines = visible_items;
if (top_line < 0 || is_first_selected())
top_line = 0;
- if (selected < visible_items && top_line + m_visible_lines >= visible_items)
+ if (selected_index() < visible_items && top_line + m_visible_lines >= visible_items)
top_line = visible_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 < visible_items))
+ if ((m_focus == focused_menu::MAIN) && (selected_index() < visible_items))
m_prev_selected = nullptr;
int const n_loop = (std::min)(m_visible_lines, visible_items);
@@ -1836,7 +1824,7 @@ void menu_select_launch::draw(uint32_t flags)
{
float line_y = visible_top + (float)linenum * line_height;
int itemnum = top_line + linenum;
- const menu_item &pitem = item[itemnum];
+ const menu_item &pitem = item(itemnum);
const char *itemtext = pitem.text.c_str();
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
@@ -1848,7 +1836,7 @@ void menu_select_launch::draw(uint32_t flags)
// set the hover if this is our item
if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem))
- hover = itemnum;
+ set_hover(itemnum);
if (is_selected(itemnum) && m_focus == focused_menu::MAIN)
{
@@ -1862,7 +1850,7 @@ void menu_select_launch::draw(uint32_t flags)
bgcolor, rgb_t(43, 43, 43),
hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1));
}
- else if (itemnum == hover)
+ else if (itemnum == hover())
{
// else if the mouse is over this item, draw with a different background
fgcolor = fgcolor3 = UI_MOUSEOVER_COLOR;
@@ -1883,8 +1871,8 @@ void menu_select_launch::draw(uint32_t flags)
draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height,
0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0);
- if (hover == itemnum)
- hover = HOVER_ARROW_UP;
+ if (hover() == itemnum)
+ set_hover(HOVER_ARROW_UP);
}
else if (linenum == m_visible_lines - 1 && itemnum != visible_items - 1)
{
@@ -1892,8 +1880,8 @@ void menu_select_launch::draw(uint32_t flags)
draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height,
0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0 ^ ORIENTATION_FLIP_Y);
- if (hover == itemnum)
- hover = HOVER_ARROW_DOWN;
+ if (hover() == itemnum)
+ set_hover(HOVER_ARROW_DOWN);
}
else if (pitem.type == menu_item_type::SEPARATOR)
{
@@ -1906,7 +1894,7 @@ void menu_select_launch::draw(uint32_t flags)
// draw the item centered
int const item_invert = pitem.flags & FLAG_INVERT;
if (m_has_icons)
- draw_icon(linenum, item[itemnum].ref, effective_left, line_y);
+ draw_icon(linenum, item(itemnum).ref, effective_left, line_y);
ui().draw_text_full(
container(),
itemtext,
@@ -1933,7 +1921,7 @@ void menu_select_launch::draw(uint32_t flags)
// draw the item left-justified
if (m_has_icons)
- draw_icon(linenum, item[itemnum].ref, effective_left, line_y);
+ draw_icon(linenum, item(itemnum).ref, effective_left, line_y);
ui().draw_text_full(
container(),
itemtext,
@@ -1953,9 +1941,9 @@ void menu_select_launch::draw(uint32_t flags)
}
}
- for (size_t count = visible_items; count < item.size(); count++)
+ for (size_t count = visible_items; count < item_count(); count++)
{
- const menu_item &pitem = item[count];
+ const menu_item &pitem = item(count);
const char *itemtext = pitem.text.c_str();
float line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
float line_y0 = line;
@@ -1965,7 +1953,7 @@ void menu_select_launch::draw(uint32_t flags)
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem))
- hover = count;
+ set_hover(count);
// if we're selected, draw with a different background
if (is_selected(count) && m_focus == focused_menu::MAIN)
@@ -1976,7 +1964,7 @@ void menu_select_launch::draw(uint32_t flags)
hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1));
}
// else if the mouse is over this item, draw with a different background
- else if (count == hover)
+ else if (count == hover())
{
fgcolor = UI_MOUSEOVER_COLOR;
bgcolor = UI_MOUSEOVER_BG_COLOR;
@@ -2045,7 +2033,7 @@ void menu_select_launch::draw_right_panel(float origx1, float origy1, float orig
if (mouse_in_rect(origx1, origy1, x2, origy2))
{
fgcolor = UI_MOUSEOVER_COLOR;
- hover = HOVER_RPANEL_ARROW;
+ set_hover(HOVER_RPANEL_ARROW);
}
if (hide)
@@ -2103,7 +2091,7 @@ float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, flo
{
bgcolor = UI_MOUSEOVER_BG_COLOR;
fgcolor = UI_MOUSEOVER_COLOR;
- hover = HOVER_RP_FIRST + cells;
+ set_hover(HOVER_RP_FIRST + cells);
}
}
@@ -2518,7 +2506,7 @@ float menu_select_launch::draw_collapsed_left_panel(float x1, float y1, float x2
if (mouse_in_rect(x1, y1, x2, y2))
{
fgcolor = UI_MOUSEOVER_COLOR;
- hover = HOVER_LPANEL_ARROW;
+ set_hover(HOVER_LPANEL_ARROW);
}
draw_arrow(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor, ROT90);
@@ -2697,7 +2685,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
m_topline_datsview = m_total_lines - r_visible_lines;
if (mouse_in_rect(origx1 + gutter_width, oy1, origx2 - gutter_width, origy2))
- hover = HOVER_INFO_TEXT;
+ set_hover(HOVER_INFO_TEXT);
sc = origx2 - origx1 - (2.0f * gutter_width);
for (int r = 0; r < r_visible_lines; ++r)
diff --git a/src/frontend/mame/ui/selmenu.h b/src/frontend/mame/ui/selmenu.h
index 5e85cb0ce96..728ca02cd32 100644
--- a/src/frontend/mame/ui/selmenu.h
+++ b/src/frontend/mame/ui/selmenu.h
@@ -235,15 +235,15 @@ private:
{
if (!m_prev_selected)
{
- selected = 0;
+ set_selected_index(0);
}
else
{
- for (int x = 0; x < item.size(); ++x)
+ for (int x = 0; x < item_count(); ++x)
{
- if (item[x].ref == m_prev_selected)
+ if (item(x).ref == m_prev_selected)
{
- selected = x;
+ set_selected_index(x);
break;
}
}
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index 26635c6d31a..a5b5a5bb594 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -135,7 +135,7 @@ menu_select_software::~menu_select_software()
void menu_select_software::handle()
{
if (m_prev_selected == nullptr)
- m_prev_selected = item[0].ref;
+ m_prev_selected = item(0).ref;
// ignore pause keys by swallowing them before we process the menu
machine().ui_input().pressed(IPT_UI_PAUSE);
@@ -326,8 +326,8 @@ void menu_select_software::populate(float &customtop, float &custombottom)
if (old_software != -1)
{
- selected = old_software;
- top_line = selected - (ui_globals::visible_sw_lines / 2);
+ set_selected_index(old_software);
+ top_line = selected_index() - (ui_globals::visible_sw_lines / 2);
}
reselect_last::reset();
diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp
index 8631fc47971..f94843ecccd 100644
--- a/src/frontend/mame/ui/sliders.cpp
+++ b/src/frontend/mame/ui/sliders.cpp
@@ -115,14 +115,14 @@ void menu_sliders::handle()
// if we got here via up or page up, select the previous item
if (menu_event->iptkey == IPT_UI_UP || menu_event->iptkey == IPT_UI_PAGE_UP)
{
- selected = (selected + item.size() - 1) % item.size();
+ set_selected_index((selected_index() + item_count() - 1) % item_count());
validate_selection(-1);
}
// otherwise select the next item
else if (menu_event->iptkey == IPT_UI_DOWN || menu_event->iptkey == IPT_UI_PAGE_DOWN)
{
- selected = (selected + 1) % item.size();
+ set_selected_index((selected_index() + 1) % item_count());
validate_selection(1);
}
}
diff --git a/src/frontend/mame/ui/utils.cpp b/src/frontend/mame/ui/utils.cpp
index 52857fc6dbf..7511a219bf8 100644
--- a/src/frontend/mame/ui/utils.cpp
+++ b/src/frontend/mame/ui/utils.cpp
@@ -506,7 +506,7 @@ void composite_filter_impl_base<Impl, Base, Type>::menu_configure::populate(floa
{
item_append(util::string_format(_("Filter %1$u"), i + 1), m_parent.m_filters[i]->display_name(), get_arrow_flags(i), (void *)(FILTER_FIRST + i));
if (m_added)
- selected = item.size() - 2;
+ set_selected_index(item_count() - 2);
if (m_parent.m_filters[i]->wants_adjuster())
{
std::string name("^!");