summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/frontend/mame/ui/custmenu.cpp204
-rw-r--r--src/frontend/mame/ui/custui.cpp93
-rw-r--r--src/frontend/mame/ui/menu.h2
-rw-r--r--src/frontend/mame/ui/miscmenu.cpp2
-rw-r--r--src/frontend/mame/ui/optsmenu.cpp71
-rw-r--r--src/frontend/mame/ui/selector.cpp87
-rw-r--r--src/frontend/mame/ui/selector.h22
-rw-r--r--src/frontend/mame/ui/selgame.cpp226
-rw-r--r--src/frontend/mame/ui/selmenu.cpp1
-rw-r--r--src/frontend/mame/ui/selmenu.h1
-rw-r--r--src/frontend/mame/ui/selsoft.cpp364
-rw-r--r--src/frontend/mame/ui/selsoft.h11
-rw-r--r--src/frontend/mame/ui/sndmenu.cpp8
-rw-r--r--src/frontend/mame/ui/utils.cpp96
-rw-r--r--src/frontend/mame/ui/utils.h151
15 files changed, 720 insertions, 619 deletions
diff --git a/src/frontend/mame/ui/custmenu.cpp b/src/frontend/mame/ui/custmenu.cpp
index 35dce95c03a..45d981174d1 100644
--- a/src/frontend/mame/ui/custmenu.cpp
+++ b/src/frontend/mame/ui/custmenu.cpp
@@ -9,8 +9,9 @@
*********************************************************************/
#include "emu.h"
-#include "ui/ui.h"
#include "ui/custmenu.h"
+
+#include "ui/ui.h"
#include "ui/selector.h"
#include "ui/inifile.h"
@@ -18,6 +19,7 @@
namespace ui {
+
/**************************************************
MENU CUSTOM FILTER
**************************************************/
@@ -52,61 +54,70 @@ void menu_custom_filter::handle()
{
switch ((uintptr_t)menu_event->itemref)
{
- case MAIN_FILTER:
- if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
- {
- (menu_event->iptkey == IPT_UI_RIGHT) ? custfltr::main++ : custfltr::main--;
- changed = true;
- }
- break;
+ case MAIN_FILTER:
+ if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
+ {
+ (menu_event->iptkey == IPT_UI_RIGHT) ? custfltr::main++ : custfltr::main--;
+ changed = true;
+ }
+ break;
- case ADD_FILTER:
- if (menu_event->iptkey == IPT_UI_SELECT)
- {
- custfltr::numother++;
- custfltr::other[custfltr::numother] = FILTER_UNAVAILABLE + 1;
- m_added = true;
- }
- break;
+ case ADD_FILTER:
+ if (menu_event->iptkey == IPT_UI_SELECT)
+ {
+ custfltr::numother++;
+ custfltr::other[custfltr::numother] = machine_filter::UNAVAILABLE;
+ ++custfltr::other[custfltr::numother];
+ m_added = true;
+ }
+ break;
- case REMOVE_FILTER:
- if (menu_event->iptkey == IPT_UI_SELECT)
- {
- custfltr::other[custfltr::numother] = FILTER_UNAVAILABLE + 1;
- custfltr::numother--;
- changed = true;
- }
- break;
+ case REMOVE_FILTER:
+ if (menu_event->iptkey == IPT_UI_SELECT)
+ {
+ custfltr::other[custfltr::numother] = machine_filter::UNAVAILABLE;
+ ++custfltr::other[custfltr::numother];
+ custfltr::numother--;
+ changed = true;
+ }
+ break;
}
if ((uintptr_t)menu_event->itemref >= OTHER_FILTER && (uintptr_t)menu_event->itemref < OTHER_FILTER + MAX_CUST_FILTER)
{
int pos = (int)((uintptr_t)menu_event->itemref - OTHER_FILTER);
- if (menu_event->iptkey == IPT_UI_LEFT && custfltr::other[pos] > FILTER_UNAVAILABLE + 1)
+ if (menu_event->iptkey == IPT_UI_LEFT && custfltr::other[pos] > machine_filter::UNAVAILABLE + 1)
{
custfltr::other[pos]--;
- for ( ; custfltr::other[pos] > FILTER_UNAVAILABLE && (custfltr::other[pos] == FILTER_CATEGORY
- || custfltr::other[pos] == FILTER_FAVORITE); custfltr::other[pos]--) { };
+ for ( ; custfltr::other[pos] > machine_filter::UNAVAILABLE && (custfltr::other[pos] == machine_filter::CATEGORY
+ || custfltr::other[pos] == machine_filter::FAVORITE); custfltr::other[pos]--) { };
changed = true;
}
- else if (menu_event->iptkey == IPT_UI_RIGHT && custfltr::other[pos] < FILTER_LAST - 1)
+ else if (menu_event->iptkey == IPT_UI_RIGHT && custfltr::other[pos] < machine_filter::LAST - 1)
{
custfltr::other[pos]++;
- for ( ; custfltr::other[pos] < FILTER_LAST && (custfltr::other[pos] == FILTER_CATEGORY
- || custfltr::other[pos] == FILTER_FAVORITE); custfltr::other[pos]++) { };
+ for ( ; custfltr::other[pos] < machine_filter::LAST && (custfltr::other[pos] == machine_filter::CATEGORY
+ || custfltr::other[pos] == machine_filter::FAVORITE); custfltr::other[pos]++) { };
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
{
- size_t total = main_filters::length;
- std::vector<std::string> s_sel(total);
- for (size_t index = 0; index < total; ++index)
- if (index <= FILTER_UNAVAILABLE || index == FILTER_CATEGORY || index == FILTER_FAVORITE || index == FILTER_CUSTOM)
- s_sel[index] = "_skip_";
- else
- s_sel[index] = main_filters::text[index];
-
- menu::stack_push<menu_selector>(ui(), container(), s_sel, custfltr::other[pos]);
+ std::vector<machine_filter::type> types;
+ std::vector<std::string> names;
+ types.reserve(machine_filter::COUNT);
+ names.reserve(machine_filter::COUNT);
+ int sel(-1);
+ for (machine_filter::type index = machine_filter::FIRST; index < machine_filter::COUNT; ++index)
+ {
+ if ((index > machine_filter::UNAVAILABLE) && (index != machine_filter::CATEGORY) && (index != machine_filter::FAVORITE) && (index != machine_filter::CUSTOM))
+ {
+ if (custfltr::other[pos] == index)
+ sel = types.size();
+ types.emplace_back(index);
+ names.emplace_back(machine_filter::display_name(index));
+ }
+ }
+ menu::stack_push<menu_selector>(ui(), container(), std::move(names), sel, [this, pos, t = std::move(types)] (int selection) { custfltr::other[pos] = t[selection]; reset(reset_options::REMEMBER_REF); });
}
}
else if ((uintptr_t)menu_event->itemref >= YEAR_FILTER && (uintptr_t)menu_event->itemref < YEAR_FILTER + MAX_CUST_FILTER)
@@ -123,7 +134,9 @@ void menu_custom_filter::handle()
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_selector>(ui(), container(), c_year::ui, custfltr::year[pos]);
+ {
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(c_year::ui), custfltr::year[pos], [this, pos] (int selection) { custfltr::year[pos] = selection; reset(reset_options::REMEMBER_REF); });
+ }
}
else if ((uintptr_t)menu_event->itemref >= MNFCT_FILTER && (uintptr_t)menu_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER)
{
@@ -139,7 +152,9 @@ void menu_custom_filter::handle()
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_selector>(ui(), container(), c_mnfct::ui, custfltr::mnfct[pos]);
+ {
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(c_mnfct::ui), custfltr::mnfct[pos], [this, pos] (int selection) { custfltr::mnfct[pos] = selection; reset(reset_options::REMEMBER_REF); });
+ }
}
}
@@ -155,8 +170,8 @@ void menu_custom_filter::handle()
void menu_custom_filter::populate(float &customtop, float &custombottom)
{
// add main filter
- uint32_t arrow_flags = get_arrow_flags<uint16_t>(FILTER_ALL, FILTER_UNAVAILABLE, custfltr::main);
- item_append(_("Main filter"), main_filters::text[custfltr::main], arrow_flags, (void *)(uintptr_t)MAIN_FILTER);
+ uint32_t arrow_flags = get_arrow_flags<uint16_t>(machine_filter::ALL, machine_filter::UNAVAILABLE, custfltr::main);
+ item_append(_("Main filter"), machine_filter::display_name(custfltr::main), arrow_flags, (void *)(uintptr_t)MAIN_FILTER);
// add other filters
for (int x = 1; x <= custfltr::numother; x++)
@@ -164,14 +179,14 @@ void menu_custom_filter::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
// add filter items
- arrow_flags = get_arrow_flags<uint16_t>(FILTER_UNAVAILABLE + 1, FILTER_LAST - 1, custfltr::other[x]);
- item_append(_("Other filter"), main_filters::text[custfltr::other[x]], arrow_flags, (void *)(uintptr_t)(OTHER_FILTER + x));
+ arrow_flags = get_arrow_flags<uint16_t>(machine_filter::UNAVAILABLE + 1, machine_filter::LAST - 1, custfltr::other[x]);
+ item_append(_("Other filter"), machine_filter::display_name(custfltr::other[x]), arrow_flags, (void *)(uintptr_t)(OTHER_FILTER + x));
if (m_added)
selected = item.size() - 2;
// add manufacturer subitem
- if (custfltr::other[x] == FILTER_MANUFACTURER && c_mnfct::ui.size() > 0)
+ if (custfltr::other[x] == machine_filter::MANUFACTURER && c_mnfct::ui.size() > 0)
{
arrow_flags = get_arrow_flags<uint16_t>(0, c_mnfct::ui.size() - 1, custfltr::mnfct[x]);
std::string fbuff(_("^!Manufacturer"));
@@ -180,7 +195,7 @@ void menu_custom_filter::populate(float &customtop, float &custombottom)
}
// add year subitem
- else if (custfltr::other[x] == FILTER_YEAR && c_year::ui.size() > 0)
+ else if (custfltr::other[x] == machine_filter::YEAR && c_year::ui.size() > 0)
{
arrow_flags = get_arrow_flags<uint16_t>(0, c_year::ui.size() - 1, custfltr::year[x]);
std::string fbuff(_("^!Year"));
@@ -227,14 +242,14 @@ void menu_custom_filter::save_custom_filters()
// generate custom filters info
std::ostringstream cinfo;
util::stream_format(cinfo, "Total filters = %d\n", (custfltr::numother + 1));
- util::stream_format(cinfo, "Main filter = %s\n", main_filters::text[custfltr::main]);
+ util::stream_format(cinfo, "Main filter = %s\n", machine_filter::config_name(custfltr::main));
for (int x = 1; x <= custfltr::numother; x++)
{
- util::stream_format(cinfo, "Other filter = %s\n", main_filters::text[custfltr::other[x]]);
- if (custfltr::other[x] == FILTER_MANUFACTURER)
+ util::stream_format(cinfo, "Other filter = %s\n", machine_filter::config_name(custfltr::other[x]));
+ if (custfltr::other[x] == machine_filter::MANUFACTURER)
util::stream_format(cinfo, " Manufacturer filter = %s\n", c_mnfct::ui[custfltr::mnfct[x]]);
- else if (custfltr::other[x] == FILTER_YEAR)
+ else if (custfltr::other[x] == machine_filter::YEAR)
util::stream_format(cinfo, " Year filter = %s\n", c_year::ui[custfltr::year[x]]);
}
file.puts(cinfo.str().c_str());
@@ -288,7 +303,8 @@ void menu_swcustom_filter::handle()
if (menu_event->iptkey == IPT_UI_SELECT)
{
sw_custfltr::numother++;
- sw_custfltr::other[sw_custfltr::numother] = UI_SW_UNAVAILABLE + 1;
+ sw_custfltr::other[sw_custfltr::numother] = software_filter::UNAVAILABLE;
+ ++sw_custfltr::other[sw_custfltr::numother];
m_added = true;
}
break;
@@ -296,7 +312,8 @@ void menu_swcustom_filter::handle()
case REMOVE_FILTER:
if (menu_event->iptkey == IPT_UI_SELECT)
{
- sw_custfltr::other[sw_custfltr::numother] = UI_SW_UNAVAILABLE + 1;
+ sw_custfltr::other[sw_custfltr::numother] = software_filter::UNAVAILABLE;
+ ++sw_custfltr::other[sw_custfltr::numother];
sw_custfltr::numother--;
changed = true;
}
@@ -306,27 +323,34 @@ void menu_swcustom_filter::handle()
if ((uintptr_t)menu_event->itemref >= OTHER_FILTER && (uintptr_t)menu_event->itemref < OTHER_FILTER + MAX_CUST_FILTER)
{
int pos = (int)((uintptr_t)menu_event->itemref - OTHER_FILTER);
- if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::other[pos] > UI_SW_UNAVAILABLE + 1)
+ if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::other[pos] > software_filter::UNAVAILABLE + 1)
{
sw_custfltr::other[pos]--;
changed = true;
}
- else if (menu_event->iptkey == IPT_UI_RIGHT && sw_custfltr::other[pos] < UI_SW_LAST - 1)
+ else if (menu_event->iptkey == IPT_UI_RIGHT && sw_custfltr::other[pos] < software_filter::LAST - 1)
{
sw_custfltr::other[pos]++;
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
{
- size_t total = sw_filters::length;
- std::vector<std::string> s_sel(total);
- for (size_t index = 0; index < total; ++index)
- if (index <= UI_SW_UNAVAILABLE|| index == UI_SW_CUSTOM)
- s_sel[index] = "_skip_";
- else
- s_sel[index] = sw_filters::text[index];
-
- menu::stack_push<menu_selector>(ui(), container(), s_sel, sw_custfltr::other[pos]);
+ std::vector<software_filter::type> types;
+ std::vector<std::string> names;
+ types.reserve(software_filter::COUNT);
+ names.reserve(software_filter::COUNT);
+ uint16_t sel(0);
+ for (software_filter::type index = software_filter::FIRST; index < software_filter::COUNT; ++index)
+ {
+ if ((index >= software_filter::UNAVAILABLE) && (index != software_filter::CUSTOM))
+ {
+ if (sw_custfltr::other[pos] == index)
+ sel = types.size();
+ types.emplace_back(index);
+ names.emplace_back(software_filter::display_name(index));
+ }
+ }
+ menu::stack_push<menu_selector>(ui(), container(), std::move(names), sel, [this, pos, t = std::move(types)] (int selection) { sw_custfltr::other[pos] = t[selection]; reset(reset_options::REMEMBER_REF); });
}
}
else if ((uintptr_t)menu_event->itemref >= YEAR_FILTER && (uintptr_t)menu_event->itemref < YEAR_FILTER + MAX_CUST_FILTER)
@@ -343,7 +367,9 @@ void menu_swcustom_filter::handle()
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_selector>(ui(), container(), m_filter.year.ui, sw_custfltr::year[pos]);
+ {
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.year.ui), sw_custfltr::year[pos], [this, pos] (int selection) { sw_custfltr::year[pos] = selection; reset(reset_options::REMEMBER_REF); });
+ }
}
else if ((uintptr_t)menu_event->itemref >= TYPE_FILTER && (uintptr_t)menu_event->itemref < TYPE_FILTER + MAX_CUST_FILTER)
{
@@ -359,7 +385,9 @@ void menu_swcustom_filter::handle()
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_selector>(ui(), container(), m_filter.type.ui, sw_custfltr::type[pos]);
+ {
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.type.ui), sw_custfltr::type[pos], [this, pos] (int selection) { sw_custfltr::type[pos] = selection; reset(reset_options::REMEMBER_REF); });
+ }
}
else if ((uintptr_t)menu_event->itemref >= MNFCT_FILTER && (uintptr_t)menu_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER)
{
@@ -375,7 +403,9 @@ void menu_swcustom_filter::handle()
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_selector>(ui(), container(), m_filter.publisher.ui, sw_custfltr::mnfct[pos]);
+ {
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.publisher.ui), sw_custfltr::mnfct[pos], [this, pos] (int selection) { sw_custfltr::mnfct[pos] = selection; reset(reset_options::REMEMBER_REF); });
+ }
}
else if ((uintptr_t)menu_event->itemref >= REGION_FILTER && (uintptr_t)menu_event->itemref < REGION_FILTER + MAX_CUST_FILTER)
{
@@ -391,7 +421,9 @@ void menu_swcustom_filter::handle()
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_selector>(ui(), container(), m_filter.region.ui, sw_custfltr::region[pos]);
+ {
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.region.ui), sw_custfltr::region[pos], [this, pos] (int selection) { sw_custfltr::region[pos] = selection; reset(reset_options::REMEMBER_REF); });
+ }
}
else if ((uintptr_t)menu_event->itemref >= LIST_FILTER && (uintptr_t)menu_event->itemref < LIST_FILTER + MAX_CUST_FILTER)
{
@@ -407,7 +439,9 @@ void menu_swcustom_filter::handle()
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_selector>(ui(), container(), m_filter.swlist.description, sw_custfltr::list[pos]);
+ {
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.swlist.description), sw_custfltr::list[pos], [this, pos] (int selection) { sw_custfltr::list[pos] = selection; reset(reset_options::REMEMBER_REF); });
+ }
}
}
@@ -423,8 +457,8 @@ void menu_swcustom_filter::handle()
void menu_swcustom_filter::populate(float &customtop, float &custombottom)
{
// add main filter
- uint32_t arrow_flags = get_arrow_flags<uint16_t>(UI_SW_ALL, UI_SW_UNAVAILABLE, sw_custfltr::main);
- item_append(_("Main filter"), sw_filters::text[sw_custfltr::main], arrow_flags, (void *)(uintptr_t)MAIN_FILTER);
+ uint32_t arrow_flags = get_arrow_flags<uint16_t>(software_filter::ALL, software_filter::UNAVAILABLE, sw_custfltr::main);
+ item_append(_("Main filter"), software_filter::display_name(sw_custfltr::main), arrow_flags, (void *)(uintptr_t)MAIN_FILTER);
// add other filters
for (int x = 1; x <= sw_custfltr::numother; x++)
@@ -432,14 +466,14 @@ void menu_swcustom_filter::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
// add filter items
- arrow_flags = get_arrow_flags<uint16_t>(UI_SW_UNAVAILABLE + 1, UI_SW_LAST - 1, sw_custfltr::other[x]);
- item_append(_("Other filter"), sw_filters::text[sw_custfltr::other[x]], arrow_flags, (void *)(uintptr_t)(OTHER_FILTER + x));
+ arrow_flags = get_arrow_flags<uint16_t>(software_filter::UNAVAILABLE + 1, software_filter::LAST - 1, sw_custfltr::other[x]);
+ item_append(_("Other filter"), software_filter::display_name(sw_custfltr::other[x]), arrow_flags, (void *)(uintptr_t)(OTHER_FILTER + x));
if (m_added)
selected = item.size() - 2;
// add publisher subitem
- if (sw_custfltr::other[x] == UI_SW_PUBLISHERS && m_filter.publisher.ui.size() > 0)
+ if (sw_custfltr::other[x] == software_filter::PUBLISHERS && m_filter.publisher.ui.size())
{
arrow_flags = get_arrow_flags<uint16_t>(0, m_filter.publisher.ui.size() - 1, sw_custfltr::mnfct[x]);
std::string fbuff(_("^!Publisher"));
@@ -448,7 +482,7 @@ void menu_swcustom_filter::populate(float &customtop, float &custombottom)
}
// add year subitem
- else if (sw_custfltr::other[x] == UI_SW_YEARS && m_filter.year.ui.size() > 0)
+ else if (sw_custfltr::other[x] == software_filter::YEARS && m_filter.year.ui.size())
{
arrow_flags = get_arrow_flags<uint16_t>(0, m_filter.year.ui.size() - 1, sw_custfltr::year[x]);
std::string fbuff(_("^!Year"));
@@ -457,7 +491,7 @@ void menu_swcustom_filter::populate(float &customtop, float &custombottom)
}
// add year subitem
- else if (sw_custfltr::other[x] == UI_SW_LIST && m_filter.swlist.name.size() > 0)
+ else if (sw_custfltr::other[x] == software_filter::LIST && m_filter.swlist.name.size())
{
arrow_flags = get_arrow_flags<uint16_t>(0, m_filter.swlist.name.size() - 1, sw_custfltr::list[x]);
std::string fbuff(_("^!Software List"));
@@ -466,7 +500,7 @@ void menu_swcustom_filter::populate(float &customtop, float &custombottom)
}
// add device type subitem
- else if (sw_custfltr::other[x] == UI_SW_TYPE && m_filter.type.ui.size() > 0)
+ else if (sw_custfltr::other[x] == software_filter::DEVICE_TYPE && m_filter.type.ui.size())
{
arrow_flags = get_arrow_flags<uint16_t>(0, m_filter.type.ui.size() - 1, sw_custfltr::type[x]);
std::string fbuff(_("^!Device type"));
@@ -475,7 +509,7 @@ void menu_swcustom_filter::populate(float &customtop, float &custombottom)
}
// add region subitem
- else if (sw_custfltr::other[x] == UI_SW_REGION && m_filter.region.ui.size() > 0)
+ else if (sw_custfltr::other[x] == software_filter::REGION && m_filter.region.ui.size())
{
arrow_flags = get_arrow_flags<uint16_t>(0, m_filter.region.ui.size() - 1, sw_custfltr::region[x]);
std::string fbuff(_("^!Region"));
@@ -523,20 +557,20 @@ void menu_swcustom_filter::save_sw_custom_filters()
// generate custom filters info
std::ostringstream cinfo;
util::stream_format(cinfo, "Total filters = %d\n", (sw_custfltr::numother + 1));
- util::stream_format(cinfo, "Main filter = %s\n", sw_filters::text[sw_custfltr::main]);
+ util::stream_format(cinfo, "Main filter = %s\n", software_filter::config_name(sw_custfltr::main));
for (int x = 1; x <= sw_custfltr::numother; x++)
{
- util::stream_format(cinfo, "Other filter = %s\n", sw_filters::text[sw_custfltr::other[x]]);
- if (sw_custfltr::other[x] == UI_SW_PUBLISHERS)
+ util::stream_format(cinfo, "Other filter = %s\n", software_filter::config_name(sw_custfltr::other[x]));
+ if (sw_custfltr::other[x] == software_filter::PUBLISHERS)
util::stream_format(cinfo, " Manufacturer filter = %s\n", m_filter.publisher.ui[sw_custfltr::mnfct[x]]);
- else if (sw_custfltr::other[x] == UI_SW_LIST)
+ else if (sw_custfltr::other[x] == software_filter::LIST)
util::stream_format(cinfo, " Software List filter = %s\n", m_filter.swlist.name[sw_custfltr::list[x]]);
- else if (sw_custfltr::other[x] == UI_SW_YEARS)
+ else if (sw_custfltr::other[x] == software_filter::YEARS)
util::stream_format(cinfo, " Year filter = %s\n", m_filter.year.ui[sw_custfltr::year[x]]);
- else if (sw_custfltr::other[x] == UI_SW_TYPE)
+ else if (sw_custfltr::other[x] == software_filter::DEVICE_TYPE)
util::stream_format(cinfo, " Type filter = %s\n", m_filter.type.ui[sw_custfltr::type[x]]);
- else if (sw_custfltr::other[x] == UI_SW_REGION)
+ else if (sw_custfltr::other[x] == software_filter::REGION)
util::stream_format(cinfo, " Region filter = %s\n", m_filter.region.ui[sw_custfltr::region[x]]);
}
file.puts(cinfo.str().c_str());
diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp
index 612d1f5cec0..a1a1fb5f67b 100644
--- a/src/frontend/mame/ui/custui.cpp
+++ b/src/frontend/mame/ui/custui.cpp
@@ -26,11 +26,12 @@
namespace ui {
+
const char *const menu_custom_ui::HIDE_STATUS[] = {
- __("Show All"),
- __("Hide Filters"),
- __("Hide Info/Image"),
- __("Hide Both") };
+ __("Show All"),
+ __("Hide Filters"),
+ __("Hide Info/Image"),
+ __("Hide Both") };
//-------------------------------------------------
// ctor
@@ -88,42 +89,51 @@ void menu_custom_ui::handle()
{
switch ((uintptr_t)menu_event->itemref)
{
- case FONT_MENU:
- if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_font_ui>(ui(), container());
- break;
- case COLORS_MENU:
- if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_colors_ui>(ui(), container());
- break;
- case HIDE_MENU:
+ case FONT_MENU:
+ if (menu_event->iptkey == IPT_UI_SELECT)
+ menu::stack_push<menu_font_ui>(ui(), container());
+ break;
+ case COLORS_MENU:
+ if (menu_event->iptkey == IPT_UI_SELECT)
+ menu::stack_push<menu_colors_ui>(ui(), container());
+ break;
+ case HIDE_MENU:
+ if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
{
- if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
- {
- changed = true;
- (menu_event->iptkey == IPT_UI_RIGHT) ? ui_globals::panels_status++ : ui_globals::panels_status--;
- }
- else if (menu_event->iptkey == IPT_UI_SELECT)
- {
- std::vector<std::string> s_sel(ARRAY_LENGTH(HIDE_STATUS));
- std::transform(std::begin(HIDE_STATUS), std::end(HIDE_STATUS), s_sel.begin(), [](auto &s) { return _(s); });
- menu::stack_push<menu_selector>(ui(), container(), std::move(s_sel), ui_globals::panels_status);
- }
- break;
+ changed = true;
+ (menu_event->iptkey == IPT_UI_RIGHT) ? ui_globals::panels_status++ : ui_globals::panels_status--;
}
- case LANGUAGE_MENU:
+ else if (menu_event->iptkey == IPT_UI_SELECT)
{
- if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
- {
- changed = true;
- (menu_event->iptkey == IPT_UI_RIGHT) ? m_currlang++ : m_currlang--;
- }
- else if (menu_event->iptkey == IPT_UI_SELECT)
- {
- menu::stack_push<menu_selector>(ui(), container(), m_lang, m_currlang);
- }
- break;
+ std::vector<std::string> s_sel(ARRAY_LENGTH(HIDE_STATUS));
+ std::transform(std::begin(HIDE_STATUS), std::end(HIDE_STATUS), s_sel.begin(), [](auto &s) { return _(s); });
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::move(s_sel), ui_globals::panels_status,
+ [this] (int selection)
+ {
+ ui_globals::panels_status = selection;
+ reset(reset_options::REMEMBER_REF);
+ });
+ }
+ break;
+ case LANGUAGE_MENU:
+ if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
+ {
+ changed = true;
+ (menu_event->iptkey == IPT_UI_RIGHT) ? m_currlang++ : m_currlang--;
}
+ else if (menu_event->iptkey == IPT_UI_SELECT)
+ {
+ // copying list of language names - expensive
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::vector<std::string>(m_lang), m_currlang,
+ [this] (int selection)
+ {
+ m_currlang = selection;
+ reset(reset_options::REMEMBER_REF);
+ });
+ }
+ break;
}
}
@@ -278,8 +288,15 @@ void menu_font_ui::handle()
{
std::vector<std::string> display_names;
display_names.reserve(m_fonts.size());
- for (auto const &font : m_fonts) display_names.emplace_back(font.second);
- menu::stack_push<menu_selector>(ui(), container(), std::move(display_names), m_actual);
+ for (auto const &font : m_fonts)
+ display_names.emplace_back(font.second);
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::move(display_names), m_actual,
+ [this] (int selection)
+ {
+ m_actual = selection;
+ reset(reset_options::REMEMBER_REF);
+ });
changed = true;
}
break;
diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h
index 478d62545c9..b4e3cab118a 100644
--- a/src/frontend/mame/ui/menu.h
+++ b/src/frontend/mame/ui/menu.h
@@ -132,8 +132,6 @@ protected:
std::vector<menu_item> item; // array of items
int top_line; // main box top line
- int l_sw_hover;
- int l_hover;
int skip_main_items;
int selected; // which item is selected
diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp
index eaab23df9b4..b36377c5382 100644
--- a/src/frontend/mame/ui/miscmenu.cpp
+++ b/src/frontend/mame/ui/miscmenu.cpp
@@ -720,7 +720,7 @@ void menu_machine_configure::handle()
break;
case DELFAV:
mame_machine_manager::instance()->favorite().remove_favorite_game();
- if (main_filters::actual == FILTER_FAVORITE)
+ if (main_filters::actual == machine_filter::FAVORITE)
{
m_fav_reset = true;
menu::stack_pop();
diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp
index 33058f836cf..ffeca417473 100644
--- a/src/frontend/mame/ui/optsmenu.cpp
+++ b/src/frontend/mame/ui/optsmenu.cpp
@@ -9,7 +9,6 @@
*********************************************************************/
#include "emu.h"
-
#include "ui/optsmenu.h"
#include "ui/ui.h"
@@ -27,6 +26,7 @@
#include "rendfont.h"
namespace ui {
+
//-------------------------------------------------
// ctor
//-------------------------------------------------
@@ -42,7 +42,7 @@ menu_game_options::menu_game_options(mame_ui_manager &mui, render_container &con
menu_game_options::~menu_game_options()
{
- main_filters::actual = m_main;
+ main_filters::actual = machine_filter::type(m_main);
reset_topmost(reset_options::SELECT_FIRST);
ui().save_ui_options();
ui_globals::switch_image = true;
@@ -80,12 +80,17 @@ void menu_game_options::handle()
}
else if (menu_event->iptkey == IPT_UI_SELECT)
{
- int total = main_filters::length;
- std::vector<std::string> s_sel(total);
- for (int index = 0; index < total; ++index)
- s_sel[index] = main_filters::text[index];
-
- menu::stack_push<menu_selector>(ui(), container(), s_sel, m_main);
+ std::vector<std::string> s_sel(machine_filter::COUNT);
+ for (unsigned index = 0; index < s_sel.size(); ++index)
+ s_sel[index] = machine_filter::display_name(machine_filter::type(index));
+
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::move(s_sel), m_main,
+ [this] (int selection)
+ {
+ m_main = selection;
+ reset(reset_options::REMEMBER_REF);
+ });
}
break;
}
@@ -110,7 +115,14 @@ void menu_game_options::handle()
for (size_t index = 0; index < total; ++index)
s_sel[index] = ifile.get_file(index);
- menu::stack_push<menu_selector>(ui(), container(), s_sel, ifile.cur_file(), menu_selector::INIFILE);
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::move(s_sel), ifile.cur_file(),
+ [this] (int selection)
+ {
+ mame_machine_manager::instance()->inifile().set_file(selection);
+ mame_machine_manager::instance()->inifile().set_cat(0);
+ reset(reset_options::REMEMBER_REF);
+ });
}
break;
}
@@ -134,7 +146,14 @@ void menu_game_options::handle()
for (int index = 0; index < total; ++index)
s_sel[index] = ifile.get_category(index);
- menu::stack_push<menu_selector>(ui(), container(), s_sel, ifile.cur_cat(), menu_selector::CATEGORY);
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::move(s_sel), ifile.cur_cat(),
+ [this] (int selection)
+ {
+ mame_machine_manager::instance()->inifile().cur_cat() = selection;
+ mame_machine_manager::instance()->inifile().set_cat(selection);
+ reset(reset_options::REMEMBER_REF);
+ });
}
break;
}
@@ -145,7 +164,15 @@ void menu_game_options::handle()
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_selector>(ui(), container(), c_mnfct::ui, c_mnfct::actual);
+ {
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::vector<std::string>(c_mnfct::ui), c_mnfct::actual,
+ [this] (int selection)
+ {
+ c_mnfct::actual = selection;
+ reset(reset_options::REMEMBER_REF);
+ });
+ }
break;
case YEAR_CAT_FILTER:
@@ -155,7 +182,15 @@ void menu_game_options::handle()
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_selector>(ui(), container(), c_year::ui, c_year::actual);
+ {
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::vector<std::string>(c_year::ui), c_year::actual,
+ [this] (int selection)
+ {
+ c_year::actual = selection;
+ reset(reset_options::REMEMBER_REF);
+ });
+ }
break;
case CONF_DIR:
@@ -228,11 +263,11 @@ void menu_game_options::populate(float &customtop, float &custombottom)
std::string fbuff;
// add filter item
- uint32_t arrow_flags = get_arrow_flags<uint16_t>(FILTER_FIRST, FILTER_LAST, m_main);
- item_append(_("Filter"), main_filters::text[m_main], arrow_flags, (void *)(uintptr_t)FILTER_MENU);
+ uint32_t arrow_flags = get_arrow_flags<uint16_t>(machine_filter::FIRST, machine_filter::LAST, m_main);
+ item_append(_("Filter"), machine_filter::display_name(machine_filter::type(m_main)), arrow_flags, (void *)(uintptr_t)FILTER_MENU);
// add category subitem
- if (m_main == FILTER_CATEGORY && mame_machine_manager::instance()->inifile().total() > 0)
+ if (m_main == machine_filter::CATEGORY && mame_machine_manager::instance()->inifile().total() > 0)
{
inifile_manager &inif = mame_machine_manager::instance()->inifile();
@@ -247,7 +282,7 @@ void menu_game_options::populate(float &customtop, float &custombottom)
item_append(fbuff, inif.get_category(), arrow_flags, (void *)(uintptr_t)CATEGORY_FILTER);
}
// add manufacturer subitem
- else if (m_main == FILTER_MANUFACTURER && c_mnfct::ui.size() > 0)
+ else if (m_main == machine_filter::MANUFACTURER && c_mnfct::ui.size() > 0)
{
arrow_flags = get_arrow_flags(uint16_t(0), uint16_t(c_mnfct::ui.size() - 1), c_mnfct::actual);
fbuff = _("^!Manufacturer");
@@ -255,7 +290,7 @@ void menu_game_options::populate(float &customtop, float &custombottom)
item_append(fbuff, c_mnfct::ui[c_mnfct::actual], arrow_flags, (void *)(uintptr_t)MANUFACT_CAT_FILTER);
}
// add year subitem
- else if (m_main == FILTER_YEAR && c_year::ui.size() > 0)
+ else if (m_main == machine_filter::YEAR && c_year::ui.size() > 0)
{
arrow_flags = get_arrow_flags(uint16_t(0), uint16_t(c_year::ui.size() - 1), c_year::actual);
fbuff.assign(_("^!Year"));
@@ -263,7 +298,7 @@ void menu_game_options::populate(float &customtop, float &custombottom)
item_append(fbuff, c_year::ui[c_year::actual], arrow_flags, (void *)(uintptr_t)YEAR_CAT_FILTER);
}
// add custom subitem
- else if (m_main == FILTER_CUSTOM)
+ else if (m_main == machine_filter::CUSTOM)
{
fbuff = _("^!Setup custom filter");
convert_command_glyph(fbuff);
diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp
index 56b8af13ec0..59aa51f9d13 100644
--- a/src/frontend/mame/ui/selector.cpp
+++ b/src/frontend/mame/ui/selector.cpp
@@ -9,38 +9,29 @@
*********************************************************************/
#include "emu.h"
-
#include "ui/selector.h"
+
#include "ui/ui.h"
-#include "ui/inifile.h"
+#include "ui/utils.h"
-#include "mame.h"
namespace ui {
+
//-------------------------------------------------
// ctor / dtor
//-------------------------------------------------
-menu_selector::menu_selector(mame_ui_manager &mui, render_container &container, std::vector<std::string> const &s_sel, uint16_t &s_actual, int category, int _hover)
+menu_selector::menu_selector(
+ mame_ui_manager &mui,
+ render_container &container,
+ std::vector<std::string> &&sel,
+ int initial,
+ std::function<void (int)> &&handler)
: menu(mui, container)
, m_search()
- , m_selector(s_actual)
- , m_category(category)
- , m_hover(_hover)
- , m_first_pass(true)
- , m_str_items(s_sel)
-{
- m_searchlist[0] = nullptr;
-}
-
-menu_selector::menu_selector(mame_ui_manager &mui, render_container &container, std::vector<std::string> &&s_sel, uint16_t &s_actual, int category, int _hover)
- : menu(mui, container)
- , m_search()
- , m_selector(s_actual)
- , m_category(category)
- , m_hover(_hover)
- , m_first_pass(true)
- , m_str_items(std::move(s_sel))
+ , m_str_items(std::move(sel))
+ , m_handler(std::move(handler))
+ , m_initial(initial)
{
m_searchlist[0] = nullptr;
}
@@ -62,37 +53,12 @@ void menu_selector::handle()
{
if (menu_event->iptkey == IPT_UI_SELECT)
{
- for (size_t idx = 0; idx < m_str_items.size(); ++idx)
+ int selection(-1);
+ for (size_t idx = 0; (m_str_items.size() > idx) && (0 > selection); ++idx)
if ((void*)&m_str_items[idx] == menu_event->itemref)
- m_selector = idx;
-
- switch (m_category)
- {
- case INIFILE:
- mame_machine_manager::instance()->inifile().set_file(m_selector);
- mame_machine_manager::instance()->inifile().set_cat(0);
- reset_parent(reset_options::REMEMBER_REF);
- break;
-
- case CATEGORY:
- mame_machine_manager::instance()->inifile().set_cat(m_selector);
- reset_parent(reset_options::REMEMBER_REF);
- break;
-
- case GAME:
- main_filters::actual = m_hover;
- reset_parent(reset_options::SELECT_FIRST);
- break;
+ selection = int(unsigned(idx));
- case SOFTWARE:
- sw_filters::actual = m_hover;
- reset_parent(reset_options::SELECT_FIRST);
- break;
-
- default:
- reset_parent(reset_options::REMEMBER_REF);
- break;
- }
+ m_handler(selection);
ui_globals::switch_image = true;
stack_pop();
@@ -127,20 +93,18 @@ void menu_selector::populate(float &customtop, float &custombottom)
}
else
{
- for (size_t index = 0, added = 0; index < m_str_items.size(); ++index)
- if (m_str_items[index] != "_skip_")
- {
- if (m_first_pass && m_selector == index)
- selected = added;
+ for (size_t index = 0; index < m_str_items.size(); ++index)
+ {
+ if ((0 <= m_initial) && (unsigned(m_initial) == index))
+ selected = index;
- added++;
- item_append(m_str_items[index], "", 0, (void *)&m_str_items[index]);
- }
+ item_append(m_str_items[index], "", 0, (void *)&m_str_items[index]);
+ }
}
item_append(menu_item_type::SEPARATOR);
customtop = custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
- m_first_pass = false;
+ m_initial = -1;
}
//-------------------------------------------------
@@ -161,7 +125,7 @@ void menu_selector::custom_render(void *selectedref, float top, float bottom, fl
draw_text_box(
std::begin(tempbuf), std::end(tempbuf),
origx1, origx2, origy2 + UI_BOX_TB_BORDER, origy2 + bottom,
- ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
+ ui::text_layout::CENTER, ui::text_layout::NEVER, false,
UI_TEXT_COLOR, UI_RED_COLOR, 1.0f);
}
@@ -177,9 +141,6 @@ void menu_selector::find_matches(const char *str)
for (; index < m_str_items.size(); ++index)
{
- if (m_str_items[index] == "_skip_")
- continue;
-
int curpenalty = fuzzy_substring(str, m_str_items[index]);
// insert into the sorted table of matches
diff --git a/src/frontend/mame/ui/selector.h b/src/frontend/mame/ui/selector.h
index 7a74a9d2c76..bd6a87c4ef9 100644
--- a/src/frontend/mame/ui/selector.h
+++ b/src/frontend/mame/ui/selector.h
@@ -16,6 +16,7 @@
#include "ui/menu.h"
namespace ui {
+
//-------------------------------------------------
// class selector menu
//-------------------------------------------------
@@ -23,16 +24,12 @@ namespace ui {
class menu_selector : public menu
{
public:
- enum
- {
- INIFILE = 1,
- CATEGORY,
- GAME,
- SOFTWARE
- };
-
- menu_selector(mame_ui_manager &mui, render_container &container, std::vector<std::string> const &_sel, uint16_t &_actual, int _category = 0, int _hover = 0);
- menu_selector(mame_ui_manager &mui, render_container &container, std::vector<std::string> &&_sel, uint16_t &_actual, int _category = 0, int _hover = 0);
+ menu_selector(
+ mame_ui_manager &mui,
+ render_container &container,
+ std::vector<std::string> &&sel,
+ int initial,
+ std::function<void (int)> &&handler);
virtual ~menu_selector() override;
protected:
@@ -48,10 +45,9 @@ private:
void find_matches(const char *str);
std::string m_search;
- uint16_t &m_selector;
- int m_category, m_hover;
- bool m_first_pass;
std::vector<std::string> m_str_items;
+ std::function<void (int)> m_handler;
+ int m_initial;
std::string *m_searchlist[VISIBLE_GAMES_IN_SEARCH + 1];
};
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp
index ed2ccaa089d..aa3d1580e6f 100644
--- a/src/frontend/mame/ui/selgame.cpp
+++ b/src/frontend/mame/ui/selgame.cpp
@@ -9,7 +9,6 @@
*********************************************************************/
#include "emu.h"
-
#include "ui/selgame.h"
#include "ui/ui.h"
@@ -34,9 +33,11 @@
#include "uiinput.h"
#include "luaengine.h"
+
extern const char UI_VERSION_TAG[];
namespace ui {
+
bool menu_select_game::first_start = true;
std::vector<const game_driver *> menu_select_game::m_sortedlist;
int menu_select_game::m_isabios = 0;
@@ -89,23 +90,25 @@ menu_select_game::menu_select_game(mame_ui_manager &mui, render_container &conta
sub_filter = tmp.substr(found + 1);
}
- main_filters::actual = FILTER_ALL;
- for (size_t ind = 0; ind < main_filters::length; ++ind)
- if (last_filter == main_filters::text[ind])
+ main_filters::actual = machine_filter::ALL;
+ for (machine_filter::type ind = machine_filter::FIRST; ind < machine_filter::COUNT; ++ind)
+ {
+ if (last_filter == machine_filter::config_name(ind))
{
main_filters::actual = ind;
break;
}
+ }
- if (main_filters::actual == FILTER_CATEGORY)
- main_filters::actual = FILTER_ALL;
- else if (main_filters::actual == FILTER_MANUFACTURER)
+ if (main_filters::actual == machine_filter::CATEGORY)
+ main_filters::actual = machine_filter::ALL;
+ else if (main_filters::actual == machine_filter::MANUFACTURER)
{
for (size_t id = 0; id < c_mnfct::ui.size(); ++id)
if (sub_filter == c_mnfct::ui[id])
c_mnfct::actual = id;
}
- else if (main_filters::actual == FILTER_YEAR)
+ else if (main_filters::actual == machine_filter::YEAR)
{
for (size_t id = 0; id < c_year::ui.size(); ++id)
if (sub_filter == c_year::ui[id])
@@ -148,10 +151,10 @@ menu_select_game::~menu_select_game()
else if (swinfo && m_prev_selected)
last_driver = reinterpret_cast<ui_software_info *>(m_prev_selected)->shortname;
- std::string filter(main_filters::text[main_filters::actual]);
- if (main_filters::actual == FILTER_MANUFACTURER)
+ std::string filter(machine_filter::config_name(main_filters::actual));
+ if (main_filters::actual == machine_filter::MANUFACTURER)
filter.append(",").append(c_mnfct::ui[c_mnfct::actual]);
- else if (main_filters::actual == FILTER_YEAR)
+ else if (main_filters::actual == machine_filter::YEAR)
filter.append(",").append(c_year::ui[c_year::actual]);
ui_options &mopt = ui().options();
@@ -271,12 +274,12 @@ void menu_select_game::handle()
change_info_pane(1);
}
}
- else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > FILTER_FIRST)
+ else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > machine_filter::FIRST)
{
// handle UI_UP_FILTER
highlight--;
}
- else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < FILTER_LAST)
+ else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < machine_filter::LAST)
{
// handle UI_DOWN_FILTER
highlight++;
@@ -401,12 +404,12 @@ void menu_select_game::handle()
l_hover = highlight;
check_filter = true;
}
- else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > FILTER_FIRST)
+ else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > machine_filter::FIRST)
{
// handle UI_UP_FILTER
highlight--;
}
- else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < FILTER_LAST)
+ else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < machine_filter::LAST)
{
// handle UI_DOWN_FILTER
highlight++;
@@ -420,24 +423,42 @@ void menu_select_game::handle()
if (check_filter)
{
m_search.clear();
- if (l_hover == FILTER_CATEGORY)
+ if (l_hover == machine_filter::CATEGORY)
{
- main_filters::actual = l_hover;
+ main_filters::actual = machine_filter::type(l_hover);
menu::stack_push<menu_game_options>(ui(), container());
}
- else if (l_hover == FILTER_CUSTOM)
+ else if (l_hover == machine_filter::CUSTOM)
{
- main_filters::actual = l_hover;
+ main_filters::actual = machine_filter::type(l_hover);
menu::stack_push<menu_custom_filter>(ui(), container(), true);
}
- else if (l_hover == FILTER_MANUFACTURER)
- menu::stack_push<menu_selector>(ui(), container(), c_mnfct::ui, c_mnfct::actual, menu_selector::GAME, l_hover);
- else if (l_hover == FILTER_YEAR)
- menu::stack_push<menu_selector>(ui(), container(), c_year::ui, c_year::actual, menu_selector::GAME, l_hover);
+ else if (l_hover == machine_filter::MANUFACTURER)
+ {
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::vector<std::string>(c_mnfct::ui), c_mnfct::actual,
+ [this] (int selection)
+ {
+ c_mnfct::actual = selection;
+ main_filters::actual = machine_filter::type(l_hover);
+ reset(reset_options::SELECT_FIRST);
+ });
+ }
+ else if (l_hover == machine_filter::YEAR)
+ {
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::vector<std::string>(c_year::ui), c_year::actual,
+ [this] (int selection)
+ {
+ c_year::actual = selection;
+ main_filters::actual = machine_filter::type(l_hover);
+ reset(reset_options::SELECT_FIRST);
+ });
+ }
else
{
- if (l_hover >= FILTER_ALL)
- main_filters::actual = l_hover;
+ if (l_hover >= machine_filter::ALL)
+ main_filters::actual = machine_filter::type(l_hover);
reset(reset_options::SELECT_FIRST);
}
}
@@ -468,21 +489,21 @@ void menu_select_game::populate(float &customtop, float &custombottom)
// if filter is set on category, build category list
switch (main_filters::actual)
{
- case FILTER_CATEGORY:
- build_category();
- break;
- case FILTER_MANUFACTURER:
- build_list(c_mnfct::ui[c_mnfct::actual].c_str());
- break;
- case FILTER_YEAR:
- build_list(c_year::ui[c_year::actual].c_str());
- break;
- case FILTER_CUSTOM:
- build_custom();
- break;
- default:
- build_list();
- break;
+ case machine_filter::CATEGORY:
+ build_category();
+ break;
+ case machine_filter::MANUFACTURER:
+ build_list(c_mnfct::ui[c_mnfct::actual].c_str());
+ break;
+ case machine_filter::YEAR:
+ build_list(c_year::ui[c_year::actual].c_str());
+ break;
+ case machine_filter::CUSTOM:
+ build_custom();
+ break;
+ default:
+ build_list();
+ break;
}
// iterate over entries
@@ -868,7 +889,7 @@ void menu_select_game::inkey_select_favorite(const event *menu_event)
inline bool menu_select_game::isfavorite() const
{
- return (main_filters::actual == FILTER_FAVORITE);
+ return (main_filters::actual == machine_filter::FAVORITE);
}
//-------------------------------------------------
@@ -894,9 +915,9 @@ void menu_select_game::build_list(const char *filter_text, int filter, bool bios
if (s_drivers.empty())
{
filter = main_filters::actual;
- if (filter == FILTER_AVAILABLE)
+ if (filter == machine_filter::AVAILABLE)
s_drivers = m_availsortedlist;
- else if (filter == FILTER_UNAVAILABLE)
+ else if (filter == machine_filter::UNAVAILABLE)
s_drivers = m_unavailsortedlist;
else
s_drivers = m_sortedlist;
@@ -904,34 +925,34 @@ void menu_select_game::build_list(const char *filter_text, int filter, bool bios
for (auto & s_driver : s_drivers)
{
- if (!bioscheck && filter != FILTER_BIOS && (s_driver->flags & machine_flags::IS_BIOS_ROOT) != 0)
+ if (!bioscheck && filter != machine_filter::BIOS && (s_driver->flags & machine_flags::IS_BIOS_ROOT) != 0)
continue;
switch (filter)
{
- case FILTER_ALL:
- case FILTER_AVAILABLE:
- case FILTER_UNAVAILABLE:
+ case machine_filter::ALL:
+ case machine_filter::AVAILABLE:
+ case machine_filter::UNAVAILABLE:
m_displaylist.push_back(s_driver);
break;
- case FILTER_WORKING:
+ case machine_filter::WORKING:
if (!(s_driver->flags & machine_flags::NOT_WORKING))
m_displaylist.push_back(s_driver);
break;
- case FILTER_NOT_MECHANICAL:
+ case machine_filter::NOT_MECHANICAL:
if (!(s_driver->flags & machine_flags::MECHANICAL))
m_displaylist.push_back(s_driver);
break;
- case FILTER_BIOS:
+ case machine_filter::BIOS:
if (s_driver->flags & machine_flags::IS_BIOS_ROOT)
m_displaylist.push_back(s_driver);
break;
- case FILTER_PARENT:
- case FILTER_CLONES:
+ case machine_filter::PARENT:
+ case machine_filter::CLONES:
{
bool cloneof = strcmp(s_driver->parent, "0");
if (cloneof)
@@ -941,55 +962,55 @@ void menu_select_game::build_list(const char *filter_text, int filter, bool bios
cloneof = false;
}
- if (filter == FILTER_CLONES && cloneof)
+ if (filter == machine_filter::CLONES && cloneof)
m_displaylist.push_back(s_driver);
- else if (filter == FILTER_PARENT && !cloneof)
+ else if (filter == machine_filter::PARENT && !cloneof)
m_displaylist.push_back(s_driver);
}
break;
- case FILTER_NOT_WORKING:
+ case machine_filter::NOT_WORKING:
if (s_driver->flags & machine_flags::NOT_WORKING)
m_displaylist.push_back(s_driver);
break;
- case FILTER_MECHANICAL:
+ case machine_filter::MECHANICAL:
if (s_driver->flags & machine_flags::MECHANICAL)
m_displaylist.push_back(s_driver);
break;
- case FILTER_SAVE:
+ case machine_filter::SAVE:
if (s_driver->flags & machine_flags::SUPPORTS_SAVE)
m_displaylist.push_back(s_driver);
break;
- case FILTER_NOSAVE:
+ case machine_filter::NOSAVE:
if (!(s_driver->flags & machine_flags::SUPPORTS_SAVE))
m_displaylist.push_back(s_driver);
break;
- case FILTER_YEAR:
+ case machine_filter::YEAR:
if (!core_stricmp(filter_text, s_driver->year))
m_displaylist.push_back(s_driver);
break;
- case FILTER_VERTICAL:
+ case machine_filter::VERTICAL:
if (s_driver->flags & ORIENTATION_SWAP_XY)
m_displaylist.push_back(s_driver);
break;
- case FILTER_HORIZONTAL:
+ case machine_filter::HORIZONTAL:
if (!(s_driver->flags & ORIENTATION_SWAP_XY))
m_displaylist.push_back(s_driver);
break;
- case FILTER_MANUFACTURER:
+ case machine_filter::MANUFACTURER:
{
std::string name = c_mnfct::getname(s_driver->manufacturer);
if (!core_stricmp(filter_text, name.c_str()))
m_displaylist.push_back(s_driver);
}
break;
- case FILTER_CHD:
+ case machine_filter::CHD:
{
auto entries = rom_build_entries(s_driver->rom);
for (const rom_entry &rom : entries)
@@ -1000,7 +1021,7 @@ void menu_select_game::build_list(const char *filter_text, int filter, bool bios
}
}
break;
- case FILTER_NOCHD:
+ case machine_filter::NOCHD:
{
auto entries = rom_build_entries(s_driver->rom);
bool found = false;
@@ -1062,9 +1083,9 @@ void menu_select_game::build_custom()
std::vector<const game_driver *> s_drivers;
bool bioscheck = false;
- if (custfltr::main == FILTER_AVAILABLE)
+ if (custfltr::main == machine_filter::AVAILABLE)
s_drivers = m_availsortedlist;
- else if (custfltr::main == FILTER_UNAVAILABLE)
+ else if (custfltr::main == machine_filter::UNAVAILABLE)
s_drivers = m_unavailsortedlist;
else
s_drivers = m_sortedlist;
@@ -1077,7 +1098,7 @@ void menu_select_game::build_custom()
for (int count = 1; count <= custfltr::numother; ++count)
{
int filter = custfltr::other[count];
- if (filter == FILTER_BIOS)
+ if (filter == machine_filter::BIOS)
bioscheck = true;
}
@@ -1089,15 +1110,15 @@ void menu_select_game::build_custom()
switch (filter)
{
- case FILTER_YEAR:
- build_list(c_year::ui[custfltr::year[count]].c_str(), filter, bioscheck, s_drivers);
- break;
- case FILTER_MANUFACTURER:
- build_list(c_mnfct::ui[custfltr::mnfct[count]].c_str(), filter, bioscheck, s_drivers);
- break;
- default:
- build_list(nullptr, filter, bioscheck, s_drivers);
- break;
+ case machine_filter::YEAR:
+ build_list(c_year::ui[custfltr::year[count]].c_str(), filter, bioscheck, s_drivers);
+ break;
+ case machine_filter::MANUFACTURER:
+ build_list(c_mnfct::ui[custfltr::mnfct[count]].c_str(), filter, bioscheck, s_drivers);
+ break;
+ default:
+ build_list(nullptr, filter, bioscheck, s_drivers);
+ break;
}
}
}
@@ -1451,22 +1472,27 @@ void menu_select_game::load_custom_filters()
file.gets(buffer, MAX_CHAR_INFO);
pb = strchr(buffer, '=') + 2;
- for (int y = 0; y < main_filters::length; ++y)
- if (!strncmp(pb, main_filters::text[y], strlen(main_filters::text[y])))
+ for (machine_filter::type y = machine_filter::FIRST; y < machine_filter::COUNT; ++y)
+ {
+ char const *const name(machine_filter::config_name(y));
+ if (!strncmp(pb, name, strlen(name)))
{
custfltr::main = y;
break;
}
+ }
for (int x = 1; x <= custfltr::numother; ++x)
{
file.gets(buffer, MAX_CHAR_INFO);
char *cb = strchr(buffer, '=') + 2;
- for (int y = 0; y < main_filters::length; ++y)
- if (!strncmp(cb, main_filters::text[y], strlen(main_filters::text[y])))
+ for (machine_filter::type y = machine_filter::FIRST; y < machine_filter::COUNT; ++y)
+ {
+ char const *const name(machine_filter::config_name(y));
+ if (!strncmp(cb, name, strlen(name)))
{
custfltr::other[x] = y;
- if (y == FILTER_MANUFACTURER)
+ if (y == machine_filter::MANUFACTURER)
{
file.gets(buffer, MAX_CHAR_INFO);
char *ab = strchr(buffer, '=') + 2;
@@ -1474,7 +1500,7 @@ void menu_select_game::load_custom_filters()
if (!strncmp(ab, c_mnfct::ui[z].c_str(), c_mnfct::ui[z].length()))
custfltr::mnfct[x] = z;
}
- else if (y == FILTER_YEAR)
+ else if (y == machine_filter::YEAR)
{
file.gets(buffer, MAX_CHAR_INFO);
char *db = strchr(buffer, '=') + 2;
@@ -1483,6 +1509,7 @@ void menu_select_game::load_custom_filters()
custfltr::year[x] = z;
}
}
+ }
}
file.close();
}
@@ -1505,26 +1532,25 @@ float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2)
float text_size = ui().options().infos_size();
float line_height_max = line_height * text_size;
float left_width = 0.0f;
- int text_lenght = main_filters::length;
+ int line_count = machine_filter::COUNT;
int afilter = main_filters::actual;
int phover = HOVER_FILTER_FIRST;
- const char **text = main_filters::text;
float sc = y2 - y1 - (2.0f * UI_BOX_TB_BORDER);
- if ((text_lenght * line_height_max) > sc)
+ if ((line_count * line_height_max) > sc)
{
- float lm = sc / (text_lenght);
+ float lm = sc / (line_count);
text_size = lm / line_height;
line_height_max = line_height * text_size;
}
float text_sign = ui().get_string_width("_# ", text_size);
- for (int x = 0; x < text_lenght; ++x)
+ for (machine_filter::type x = machine_filter::FIRST; x < machine_filter::COUNT; ++x)
{
float total_width;
// compute width of left hand side
- total_width = ui().get_string_width(text[x], text_size);
+ total_width = ui().get_string_width(machine_filter::display_name(x), text_size);
total_width += text_sign;
// track the maximum
@@ -1541,9 +1567,9 @@ float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2)
y1 += UI_BOX_TB_BORDER;
y2 -= UI_BOX_TB_BORDER;
- for (int filter = 0; filter < text_lenght; ++filter)
+ for (machine_filter::type filter = machine_filter::FIRST; filter < machine_filter::COUNT; ++filter)
{
- std::string str(text[filter]);
+ std::string str(machine_filter::display_name(filter));
rgb_t bgcolor = UI_TEXT_BG_COLOR;
rgb_t fgcolor = UI_TEXT_COLOR;
@@ -1564,11 +1590,11 @@ float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2)
}
float x1t = x1 + text_sign;
- if (afilter == FILTER_CUSTOM)
+ if (afilter == machine_filter::CUSTOM)
{
if (filter == custfltr::main)
{
- str.assign("@custom1 ").append(text[filter]);
+ str = std::string("@custom1 ") + str;
x1t -= text_sign;
}
else
@@ -1578,7 +1604,7 @@ float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2)
int cfilter = custfltr::other[count];
if (cfilter == filter)
{
- str = string_format("@custom%d %s", count + 1, text[filter]);
+ str = string_format("@custom%d %s", count + 1, str);
x1t -= text_sign;
break;
}
@@ -1588,7 +1614,7 @@ float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2)
}
else if (filter == main_filters::actual)
{
- str.assign("_> ").append(text[filter]);
+ str = std::string("_> ") + str;
x1t -= text_sign;
convert_command_glyph(str);
}
@@ -1680,23 +1706,23 @@ void menu_select_game::make_topbox_text(std::string &line0, std::string &line1,
m_isabios);
std::string filtered;
- if (main_filters::actual == FILTER_CATEGORY && inifile.total() > 0)
+ if (main_filters::actual == machine_filter::CATEGORY && inifile.total() > 0)
{
filtered = string_format(_("%1$s (%2$s - %3$s) - "),
- main_filters::text[main_filters::actual],
+ machine_filter::display_name(main_filters::actual),
inifile.get_file(),
inifile.get_category());
}
- else if (main_filters::actual == FILTER_MANUFACTURER)
+ else if (main_filters::actual == machine_filter::MANUFACTURER)
{
filtered = string_format(_("%1$s (%2$s) - "),
- main_filters::text[main_filters::actual],
+ machine_filter::display_name(main_filters::actual),
c_mnfct::ui[c_mnfct::actual]);
}
- else if (main_filters::actual == FILTER_YEAR)
+ else if (main_filters::actual == machine_filter::YEAR)
{
filtered = string_format(_("%1$s (%2$s) - "),
- main_filters::text[main_filters::actual],
+ machine_filter::display_name(main_filters::actual),
c_year::ui[c_year::actual]);
}
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index f9c5fffd8f2..1c620fb0f14 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -9,7 +9,6 @@
***************************************************************************/
#include "emu.h"
-
#include "ui/selmenu.h"
#include "ui/icorender.h"
diff --git a/src/frontend/mame/ui/selmenu.h b/src/frontend/mame/ui/selmenu.h
index d9e4c33ba75..b961413bc9e 100644
--- a/src/frontend/mame/ui/selmenu.h
+++ b/src/frontend/mame/ui/selmenu.h
@@ -117,6 +117,7 @@ protected:
template <typename T> bool select_bios(T const &driver, bool inlist);
bool select_part(software_info const &info, ui_software_info const &ui_info);
+ int l_hover, l_sw_hover;
int visible_items;
void *m_prev_selected;
int m_total_lines;
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index 7082d96a3b4..c58a6a0fbc8 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -9,7 +9,6 @@
***************************************************************************/
#include "emu.h"
-
#include "ui/selsoft.h"
#include "ui/ui.h"
@@ -90,10 +89,10 @@ bool compare_software(ui_software_info a, ui_software_info b)
menu_select_software::menu_select_software(mame_ui_manager &mui, render_container &container, const game_driver *driver)
: menu_select_launch(mui, container, true)
+ , m_filter_type(software_filter::ALL)
{
reselect_last::reselect(false);
- sw_filters::actual = 0;
highlight = 0;
m_driver = driver;
@@ -132,8 +131,7 @@ void menu_select_software::handle()
// process the menu
const event *menu_event = process(PROCESS_LR_REPEAT);
-
- if (menu_event && menu_event->itemref)
+ if (menu_event)
{
if (dismiss_error())
{
@@ -142,16 +140,16 @@ void menu_select_software::handle()
else if (menu_event->iptkey == IPT_UI_SELECT)
{
// handle selections
- if (get_focus() == focused_menu::MAIN)
- {
- inkey_select(menu_event);
- }
- else if (get_focus() == focused_menu::LEFT)
+ if (get_focus() == focused_menu::LEFT)
{
l_sw_hover = highlight;
check_filter = true;
m_prev_selected = nullptr;
}
+ else if ((get_focus() == focused_menu::MAIN) && menu_event->itemref)
+ {
+ inkey_select(menu_event);
+ }
}
else if (menu_event->iptkey == IPT_UI_LEFT)
{
@@ -187,26 +185,6 @@ void menu_select_software::handle()
m_topline_datsview = 0;
}
}
- else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > UI_SW_FIRST)
- {
- // handle UI_UP_FILTER
- highlight--;
- }
- else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < UI_SW_LAST)
- {
- // handle UI_DOWN_FILTER
- highlight++;
- }
- else if (menu_event->iptkey == IPT_UI_DATS)
- {
- // handle UI_DATS
- ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref;
-
- if (ui_swinfo->startempty == 1 && mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", ui_swinfo->driver->name, true))
- menu::stack_push<menu_dats_view>(ui(), container(), ui_swinfo->driver);
- else if (mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", std::string(ui_swinfo->shortname).append(1, ',').append(ui_swinfo->listname).c_str()) || !ui_swinfo->usage.empty())
- menu::stack_push<menu_dats_view>(ui(), container(), ui_swinfo);
- }
else if (menu_event->iptkey == IPT_UI_LEFT_PANEL)
{
// handle UI_LEFT_PANEL
@@ -217,37 +195,15 @@ void menu_select_software::handle()
// handle UI_RIGHT_PANEL
ui_globals::rpanel = RP_INFOS;
}
- else if (menu_event->iptkey == IPT_UI_CANCEL && !m_search.empty())
- {
- // escape pressed with non-empty text clears the text
- m_search.clear();
- reset(reset_options::SELECT_FIRST);
- }
- else if (menu_event->iptkey == IPT_UI_FAVORITES)
+ else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > software_filter::FIRST)
{
- // handle UI_FAVORITES
- ui_software_info *swinfo = (ui_software_info *)menu_event->itemref;
-
- if ((uintptr_t)swinfo > 2)
- {
- favorite_manager &mfav = mame_machine_manager::instance()->favorite();
- if (!mfav.isgame_favorite(*swinfo))
- {
- mfav.add_favorite_game(*swinfo);
- machine().popmessage(_("%s\n added to favorites list."), swinfo->longname.c_str());
- }
-
- else
- {
- machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname.c_str());
- mfav.remove_favorite_game();
- }
- }
+ // handle UI_UP_FILTER
+ highlight--;
}
- else if (menu_event->iptkey == IPT_SPECIAL)
+ else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < software_filter::LAST)
{
- // typed characters append to the buffer
- inkey_special(menu_event);
+ // handle UI_DOWN_FILTER
+ highlight++;
}
else if (menu_event->iptkey == IPT_OTHER)
{
@@ -259,74 +215,51 @@ void menu_select_software::handle()
{
inkey_navigation();
}
- }
-
- if (menu_event && !menu_event->itemref)
- {
- if (menu_event->iptkey == IPT_UI_CONFIGURE)
- {
- inkey_navigation();
- }
- else if (menu_event->iptkey == IPT_UI_LEFT)
+ else if (menu_event->itemref)
{
- // handle UI_LEFT
- if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view > FIRST_VIEW)
+ if (menu_event->iptkey == IPT_UI_DATS)
{
- // Images
- ui_globals::curimage_view--;
- ui_globals::switch_image = true;
- ui_globals::default_image = false;
+ // handle UI_DATS
+ ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref;
+
+ if (ui_swinfo->startempty == 1 && mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", ui_swinfo->driver->name, true))
+ menu::stack_push<menu_dats_view>(ui(), container(), ui_swinfo->driver);
+ else if (mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", std::string(ui_swinfo->shortname).append(1, ',').append(ui_swinfo->listname).c_str()) || !ui_swinfo->usage.empty())
+ menu::stack_push<menu_dats_view>(ui(), container(), ui_swinfo);
}
- else if (ui_globals::rpanel == RP_INFOS && ui_globals::cur_sw_dats_view > 0)
+ else if (menu_event->iptkey == IPT_UI_CANCEL && !m_search.empty())
{
- // Infos
- ui_globals::cur_sw_dats_view--;
- m_topline_datsview = 0;
+ // escape pressed with non-empty text clears the text
+ m_search.clear();
+ reset(reset_options::SELECT_FIRST);
}
- }
- else if (menu_event->iptkey == IPT_UI_RIGHT)
- {
- // handle UI_RIGHT
- if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view < LAST_VIEW)
+ else if (menu_event->iptkey == IPT_UI_FAVORITES)
{
- // Images
- ui_globals::curimage_view++;
- ui_globals::switch_image = true;
- ui_globals::default_image = false;
+ // handle UI_FAVORITES
+ ui_software_info *swinfo = (ui_software_info *)menu_event->itemref;
+
+ if ((uintptr_t)swinfo > 2)
+ {
+ favorite_manager &mfav = mame_machine_manager::instance()->favorite();
+ if (!mfav.isgame_favorite(*swinfo))
+ {
+ mfav.add_favorite_game(*swinfo);
+ machine().popmessage(_("%s\n added to favorites list."), swinfo->longname.c_str());
+ }
+
+ else
+ {
+ machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname.c_str());
+ mfav.remove_favorite_game();
+ }
+ }
}
- else if (ui_globals::rpanel == RP_INFOS && ui_globals::cur_sw_dats_view < ui_globals::cur_sw_dats_total)
+ else if (menu_event->iptkey == IPT_SPECIAL)
{
- // Infos
- ui_globals::cur_sw_dats_view++;
- m_topline_datsview = 0;
+ // typed characters append to the buffer
+ inkey_special(menu_event);
}
}
- else if (menu_event->iptkey == IPT_UI_LEFT_PANEL)
- {
- // handle UI_LEFT_PANEL
- ui_globals::rpanel = RP_IMAGES;
- }
- else if (menu_event->iptkey == IPT_UI_RIGHT_PANEL)
- {
- // handle UI_RIGHT_PANEL
- ui_globals::rpanel = RP_INFOS;
- }
- else if (menu_event->iptkey == IPT_UI_UP_FILTER && highlight > UI_SW_FIRST)
- {
- // handle UI_UP_FILTER
- highlight--;
- }
- else if (menu_event->iptkey == IPT_UI_DOWN_FILTER && highlight < UI_SW_LAST)
- {
- // handle UI_DOWN_FILTER
- highlight++;
- }
- else if (menu_event->iptkey == IPT_OTHER && get_focus() == focused_menu::LEFT)
- {
- l_sw_hover = highlight;
- check_filter = true;
- m_prev_selected = nullptr;
- }
}
// if we're in an error state, overlay an error message
@@ -336,29 +269,38 @@ void menu_select_software::handle()
if (check_filter)
{
m_search.clear();
+ auto handler =
+ [this] (uint16_t &actual, int selection)
+ {
+ actual = selection;
+ m_filter_type = software_filter::type(l_sw_hover);
+ reset(reset_options::SELECT_FIRST);
+ };
+
+ using std::placeholders::_1;
switch (l_sw_hover)
{
- case UI_SW_REGION:
- menu::stack_push<menu_selector>(ui(), container(), m_filter.region.ui, m_filter.region.actual, menu_selector::SOFTWARE, l_sw_hover);
+ case software_filter::REGION:
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.region.ui), m_filter.region.actual, std::bind(handler, std::ref(m_filter.region.actual), _1));
break;
- case UI_SW_YEARS:
- menu::stack_push<menu_selector>(ui(), container(), m_filter.year.ui, m_filter.year.actual, menu_selector::SOFTWARE, l_sw_hover);
+ case software_filter::YEARS:
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.year.ui), m_filter.year.actual, std::bind(handler, std::ref(m_filter.year.actual), _1));
break;
- case UI_SW_LIST:
- menu::stack_push<menu_selector>(ui(), container(), m_filter.swlist.description, m_filter.swlist.actual, menu_selector::SOFTWARE, l_sw_hover);
+ case software_filter::LIST:
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.swlist.description), m_filter.swlist.actual, std::bind(handler, std::ref(m_filter.swlist.actual), _1));
break;
- case UI_SW_TYPE:
- menu::stack_push<menu_selector>(ui(), container(), m_filter.type.ui, m_filter.type.actual, menu_selector::SOFTWARE, l_sw_hover);
+ case software_filter::DEVICE_TYPE:
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.type.ui), m_filter.type.actual, std::bind(handler, std::ref(m_filter.type.actual), _1));
break;
- case UI_SW_PUBLISHERS:
- menu::stack_push<menu_selector>(ui(), container(), m_filter.publisher.ui, m_filter.publisher.actual, menu_selector::SOFTWARE, l_sw_hover);
+ case software_filter::PUBLISHERS:
+ menu::stack_push<menu_selector>(ui(), container(), std::vector<std::string>(m_filter.publisher.ui), m_filter.publisher.actual, std::bind(handler, std::ref(m_filter.publisher.actual), _1));
break;
- case UI_SW_CUSTOM:
- sw_filters::actual = l_sw_hover;
+ case software_filter::CUSTOM:
+ m_filter_type = software_filter::type(l_sw_hover);
menu::stack_push<menu_swcustom_filter>(ui(), container(), m_driver, m_filter);
break;
default:
- sw_filters::actual = l_sw_hover;
+ m_filter_type = software_filter::type(l_sw_hover);
reset(reset_options::SELECT_FIRST);
break;
}
@@ -393,35 +335,35 @@ void menu_select_software::populate(float &customtop, float &custombottom)
m_displaylist.clear();
m_tmp.clear();
- switch (sw_filters::actual)
+ switch (m_filter_type)
{
- case UI_SW_PUBLISHERS:
- build_list(m_tmp, m_filter.publisher.ui[m_filter.publisher.actual].c_str());
- break;
+ case software_filter::PUBLISHERS:
+ build_list(m_tmp, m_filter.publisher.ui[m_filter.publisher.actual].c_str());
+ break;
- case UI_SW_LIST:
- build_list(m_tmp, m_filter.swlist.name[m_filter.swlist.actual].c_str());
- break;
+ case software_filter::LIST:
+ build_list(m_tmp, m_filter.swlist.name[m_filter.swlist.actual].c_str());
+ break;
- case UI_SW_YEARS:
- build_list(m_tmp, m_filter.year.ui[m_filter.year.actual].c_str());
- break;
+ case software_filter::YEARS:
+ build_list(m_tmp, m_filter.year.ui[m_filter.year.actual].c_str());
+ break;
- case UI_SW_TYPE:
- build_list(m_tmp, m_filter.type.ui[m_filter.type.actual].c_str());
- break;
+ case software_filter::DEVICE_TYPE:
+ build_list(m_tmp, m_filter.type.ui[m_filter.type.actual].c_str());
+ break;
- case UI_SW_REGION:
- build_list(m_tmp, m_filter.region.ui[m_filter.region.actual].c_str());
- break;
+ case software_filter::REGION:
+ build_list(m_tmp, m_filter.region.ui[m_filter.region.actual].c_str());
+ break;
- case UI_SW_CUSTOM:
- build_custom();
- break;
+ case software_filter::CUSTOM:
+ build_custom();
+ break;
- default:
- build_list(m_tmp);
- break;
+ default:
+ build_list(m_tmp);
+ break;
}
// iterate over entries
@@ -665,23 +607,27 @@ void menu_select_software::load_sw_custom_filters()
file.gets(buffer, MAX_CHAR_INFO);
pb = strchr(buffer, '=') + 2;
- for (int y = 0; y < sw_filters::length; ++y)
- if (!strncmp(pb, sw_filters::text[y], strlen(sw_filters::text[y])))
+ for (software_filter::type y = software_filter::FIRST; y < software_filter::COUNT; ++y)
+ {
+ char const *const name(software_filter::config_name(y));
+ if (!strncmp(pb, name, strlen(name)))
{
sw_custfltr::main = y;
break;
}
+ }
for (int x = 1; x <= sw_custfltr::numother; ++x)
{
file.gets(buffer, MAX_CHAR_INFO);
char *cb = strchr(buffer, '=') + 2;
- for (int y = 0; y < sw_filters::length; y++)
+ for (software_filter::type y = software_filter::FIRST; y < software_filter::COUNT; ++y)
{
- if (!strncmp(cb, sw_filters::text[y], strlen(sw_filters::text[y])))
+ char const *const name(software_filter::config_name(y));
+ if (!strncmp(cb, name, strlen(name)))
{
sw_custfltr::other[x] = y;
- if (y == UI_SW_PUBLISHERS)
+ if (y == software_filter::PUBLISHERS)
{
file.gets(buffer, MAX_CHAR_INFO);
char *ab = strchr(buffer, '=') + 2;
@@ -689,7 +635,7 @@ void menu_select_software::load_sw_custom_filters()
if (!strncmp(ab, m_filter.publisher.ui[z].c_str(), m_filter.publisher.ui[z].length()))
sw_custfltr::mnfct[x] = z;
}
- else if (y == UI_SW_YEARS)
+ else if (y == software_filter::YEARS)
{
file.gets(buffer, MAX_CHAR_INFO);
char *db = strchr(buffer, '=') + 2;
@@ -697,7 +643,7 @@ void menu_select_software::load_sw_custom_filters()
if (!strncmp(db, m_filter.year.ui[z].c_str(), m_filter.year.ui[z].length()))
sw_custfltr::year[x] = z;
}
- else if (y == UI_SW_LIST)
+ else if (y == software_filter::LIST)
{
file.gets(buffer, MAX_CHAR_INFO);
char *gb = strchr(buffer, '=') + 2;
@@ -705,7 +651,7 @@ void menu_select_software::load_sw_custom_filters()
if (!strncmp(gb, m_filter.swlist.name[z].c_str(), m_filter.swlist.name[z].length()))
sw_custfltr::list[x] = z;
}
- else if (y == UI_SW_TYPE)
+ else if (y == software_filter::DEVICE_TYPE)
{
file.gets(buffer, MAX_CHAR_INFO);
char *fb = strchr(buffer, '=') + 2;
@@ -713,7 +659,7 @@ void menu_select_software::load_sw_custom_filters()
if (!strncmp(fb, m_filter.type.ui[z].c_str(), m_filter.type.ui[z].length()))
sw_custfltr::type[x] = z;
}
- else if (y == UI_SW_REGION)
+ else if (y == software_filter::REGION)
{
file.gets(buffer, MAX_CHAR_INFO);
char *eb = strchr(buffer, '=') + 2;
@@ -813,7 +759,7 @@ void menu_select_software::build_list(std::vector<ui_software_info *> &s_drivers
{
if (s_drivers.empty() && filter == -1)
{
- filter = sw_filters::actual;
+ filter = m_filter_type;
s_drivers = m_sortedlist;
}
@@ -822,42 +768,42 @@ void menu_select_software::build_list(std::vector<ui_software_info *> &s_drivers
{
switch (filter)
{
- case UI_SW_PARENTS:
+ case software_filter::PARENTS:
if (s_driver->parentname.empty())
m_displaylist.push_back(s_driver);
break;
- case UI_SW_CLONES:
+ case software_filter::CLONES:
if (!s_driver->parentname.empty())
m_displaylist.push_back(s_driver);
break;
- case UI_SW_AVAILABLE:
+ case software_filter::AVAILABLE:
if (s_driver->available)
m_displaylist.push_back(s_driver);
break;
- case UI_SW_UNAVAILABLE:
+ case software_filter::UNAVAILABLE:
if (!s_driver->available)
m_displaylist.push_back(s_driver);
break;
- case UI_SW_SUPPORTED:
+ case software_filter::SUPPORTED:
if (s_driver->supported == SOFTWARE_SUPPORTED_YES)
m_displaylist.push_back(s_driver);
break;
- case UI_SW_PARTIAL_SUPPORTED:
+ case software_filter::PARTIAL_SUPPORTED:
if (s_driver->supported == SOFTWARE_SUPPORTED_PARTIAL)
m_displaylist.push_back(s_driver);
break;
- case UI_SW_UNSUPPORTED:
+ case software_filter::UNSUPPORTED:
if (s_driver->supported == SOFTWARE_SUPPORTED_NO)
m_displaylist.push_back(s_driver);
break;
- case UI_SW_REGION:
+ case software_filter::REGION:
{
std::string name = m_filter.region.getname(s_driver->longname);
@@ -866,7 +812,7 @@ void menu_select_software::build_list(std::vector<ui_software_info *> &s_drivers
}
break;
- case UI_SW_PUBLISHERS:
+ case software_filter::PUBLISHERS:
{
std::string name = m_filter.publisher.getname(s_driver->publisher);
@@ -875,17 +821,17 @@ void menu_select_software::build_list(std::vector<ui_software_info *> &s_drivers
}
break;
- case UI_SW_YEARS:
+ case software_filter::YEARS:
if(s_driver->year == filter_text)
m_displaylist.push_back(s_driver);
break;
- case UI_SW_LIST:
+ case software_filter::LIST:
if(s_driver->listname == filter_text)
m_displaylist.push_back(s_driver);
break;
- case UI_SW_TYPE:
+ case software_filter::DEVICE_TYPE:
if(s_driver->devicetype == filter_text)
m_displaylist.push_back(s_driver);
break;
@@ -947,30 +893,30 @@ void menu_select_software::build_custom()
for (int count = 1; count <= sw_custfltr::numother; ++count)
{
- int filter = sw_custfltr::other[count];
+ software_filter::type filter = sw_custfltr::other[count];
s_drivers = m_displaylist;
m_displaylist.clear();
switch (filter)
{
- case UI_SW_YEARS:
- build_list(s_drivers, m_filter.year.ui[sw_custfltr::year[count]].c_str(), filter);
- break;
- case UI_SW_LIST:
- build_list(s_drivers, m_filter.swlist.name[sw_custfltr::list[count]].c_str(), filter);
- break;
- case UI_SW_TYPE:
- build_list(s_drivers, m_filter.type.ui[sw_custfltr::type[count]].c_str(), filter);
- break;
- case UI_SW_PUBLISHERS:
- build_list(s_drivers, m_filter.publisher.ui[sw_custfltr::mnfct[count]].c_str(), filter);
- break;
- case UI_SW_REGION:
- build_list(s_drivers, m_filter.region.ui[sw_custfltr::region[count]].c_str(), filter);
- break;
- default:
- build_list(s_drivers, nullptr, filter);
- break;
+ case software_filter::YEARS:
+ build_list(s_drivers, m_filter.year.ui[sw_custfltr::year[count]].c_str(), filter);
+ break;
+ case software_filter::LIST:
+ build_list(s_drivers, m_filter.swlist.name[sw_custfltr::list[count]].c_str(), filter);
+ break;
+ case software_filter::DEVICE_TYPE:
+ build_list(s_drivers, m_filter.type.ui[sw_custfltr::type[count]].c_str(), filter);
+ break;
+ case software_filter::PUBLISHERS:
+ build_list(s_drivers, m_filter.publisher.ui[sw_custfltr::mnfct[count]].c_str(), filter);
+ break;
+ case software_filter::REGION:
+ build_list(s_drivers, m_filter.region.ui[sw_custfltr::region[count]].c_str(), filter);
+ break;
+ default:
+ build_list(s_drivers, nullptr, filter);
+ break;
}
}
}
@@ -989,26 +935,24 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
float l_height = ui().get_line_height();
float line_height = l_height * text_size;
float left_width = 0.0f;
- int text_lenght = sw_filters::length;
- int afilter = sw_filters::actual;
+ int line_count = software_filter::COUNT;
int phover = HOVER_SW_FILTER_FIRST;
- const char **text = sw_filters::text;
float sc = y2 - y1 - (2.0f * UI_BOX_TB_BORDER);
- if ((text_lenght * line_height) > sc)
+ if ((line_count * line_height) > sc)
{
- float lm = sc / (text_lenght);
+ float lm = sc / (line_count);
text_size = lm / l_height;
line_height = l_height * text_size;
}
float text_sign = ui().get_string_width("_# ", text_size);
- for (int x = 0; x < text_lenght; ++x)
+ for (software_filter::type x = software_filter::FIRST; x < software_filter::COUNT; ++x)
{
float total_width;
// compute width of left hand side
- total_width = ui().get_string_width(text[x], text_size);
+ total_width = ui().get_string_width(software_filter::display_name(x), text_size);
total_width += text_sign;
// track the maximum
@@ -1025,9 +969,9 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
y1 += UI_BOX_TB_BORDER;
y2 -= UI_BOX_TB_BORDER;
- for (int filter = 0; filter < text_lenght; ++filter)
+ for (software_filter::type filter = software_filter::FIRST; filter < software_filter::COUNT; ++filter)
{
- std::string str(text[filter]);
+ std::string str(software_filter::display_name(filter));
rgb_t bgcolor = UI_TEXT_BG_COLOR;
rgb_t fgcolor = UI_TEXT_COLOR;
@@ -1051,11 +995,11 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
}
float x1t = x1 + text_sign;
- if (afilter == UI_SW_CUSTOM)
+ if (m_filter_type == software_filter::CUSTOM)
{
if (filter == sw_custfltr::main)
{
- str.assign("@custom1 ").append(text[filter]);
+ str = std::string("@custom1 ") + str;
x1t -= text_sign;
}
else
@@ -1065,7 +1009,7 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
int cfilter = sw_custfltr::other[count];
if (cfilter == filter)
{
- str = string_format("@custom%d %s", count + 1, text[filter]);
+ str = string_format("@custom%d %s", count + 1, str);
x1t -= text_sign;
break;
}
@@ -1073,9 +1017,9 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
}
convert_command_glyph(str);
}
- else if (filter == sw_filters::actual)
+ else if (filter == m_filter_type)
{
- str.assign("_> ").append(text[filter]);
+ str = std::string("_> ") + str;
x1t -= text_sign;
convert_command_glyph(str);
}
@@ -1154,15 +1098,15 @@ void menu_select_software::make_topbox_text(std::string &line0, std::string &lin
line1 = string_format(_("Driver: \"%1$s\" software list "), m_driver->type.fullname());
std::string filtered;
- if (sw_filters::actual == UI_SW_REGION && m_filter.region.ui.size() != 0)
+ if (m_filter_type == software_filter::REGION && m_filter.region.ui.size())
filtered = string_format(_("Region: %1$s -"), m_filter.region.ui[m_filter.region.actual]);
- else if (sw_filters::actual == UI_SW_PUBLISHERS)
+ else if (m_filter_type == software_filter::PUBLISHERS)
filtered = string_format(_("Publisher: %1$s -"), m_filter.publisher.ui[m_filter.publisher.actual]);
- else if (sw_filters::actual == UI_SW_YEARS)
+ else if (m_filter_type == software_filter::YEARS)
filtered = string_format(_("Year: %1$s -"), m_filter.year.ui[m_filter.year.actual]);
- else if (sw_filters::actual == UI_SW_LIST)
+ else if (m_filter_type == software_filter::LIST)
filtered = string_format(_("Software List: %1$s -"), m_filter.swlist.description[m_filter.swlist.actual]);
- else if (sw_filters::actual == UI_SW_TYPE)
+ else if (m_filter_type == software_filter::DEVICE_TYPE)
filtered = string_format(_("Device type: %1$s -"), m_filter.type.ui[m_filter.type.actual]);
line2 = string_format(_("%s Search: %s_"), filtered, m_search);
diff --git a/src/frontend/mame/ui/selsoft.h b/src/frontend/mame/ui/selsoft.h
index 68bce43f6c1..60b6bbeda02 100644
--- a/src/frontend/mame/ui/selsoft.h
+++ b/src/frontend/mame/ui/selsoft.h
@@ -30,11 +30,12 @@ protected:
private:
enum { VISIBLE_GAMES_IN_SEARCH = 200 };
- std::string m_search;
- const game_driver *m_driver;
- bool m_has_empty_start;
- s_filter m_filter;
- int highlight;
+ std::string m_search;
+ const game_driver *m_driver;
+ bool m_has_empty_start;
+ s_filter m_filter;
+ software_filter::type m_filter_type;
+ int highlight;
virtual void populate(float &customtop, float &custombottom) override;
virtual void handle() override;
diff --git a/src/frontend/mame/ui/sndmenu.cpp b/src/frontend/mame/ui/sndmenu.cpp
index aa9abf0c9c3..2456c44992e 100644
--- a/src/frontend/mame/ui/sndmenu.cpp
+++ b/src/frontend/mame/ui/sndmenu.cpp
@@ -97,7 +97,13 @@ void menu_sound_options::handle()
for (int index = 0; index < total; index++)
s_sel[index] = std::to_string(m_sound_rate[index]);
- menu::stack_push<menu_selector>(ui(), container(), s_sel, m_cur_rates);
+ menu::stack_push<menu_selector>(
+ ui(), container(), std::move(s_sel), m_cur_rates,
+ [this] (int selection)
+ {
+ m_cur_rates = selection;
+ reset(reset_options::REMEMBER_REF);
+ });
}
break;
diff --git a/src/frontend/mame/ui/utils.cpp b/src/frontend/mame/ui/utils.cpp
index 7395b0b8a1c..31122ffe256 100644
--- a/src/frontend/mame/ui/utils.cpp
+++ b/src/frontend/mame/ui/utils.cpp
@@ -11,9 +11,85 @@
#include "emu.h"
#include "ui/utils.h"
+#include "language.h"
+
#include "softlist.h"
+namespace ui {
+
+namespace {
+
+constexpr char const *machine_filter_names[machine_filter::COUNT] = {
+ __("Unfiltered"),
+ __("Available"),
+ __("Unavailable"),
+ __("Working"),
+ __("Not Working"),
+ __("Mechanical"),
+ __("Not Mechanical"),
+ __("Category"),
+ __("Favorites"),
+ __("BIOS"),
+ __("Parents"),
+ __("Clones"),
+ __("Manufacturers"),
+ __("Release Years"),
+ __("Save Supported"),
+ __("Save Unsupported"),
+ __("CHD Required"),
+ __("No CHD Required"),
+ __("Vertical Screen"),
+ __("Horizontal Screen"),
+ __("Custom Filter") };
+
+constexpr char const *software_filter_names[software_filter::COUNT] = {
+ __("Unfiltered"),
+ __("Available"),
+ __("Unavailable"),
+ __("Parents"),
+ __("Clones"),
+ __("Release Years"),
+ __("Publishers"),
+ __("Supported"),
+ __("Partially Supported"),
+ __("Unsupported"),
+ __("Release Region"),
+ __("Device Type"),
+ __("Software List"),
+ __("Custom Filter") };
+
+} // anonymous namespace
+
+
+char const *machine_filter::config_name(type n)
+{
+ assert(COUNT > n);
+ return machine_filter_names[n];
+}
+
+char const *machine_filter::display_name(type n)
+{
+ assert(COUNT > n);
+ return _(machine_filter_names[n]);
+}
+
+
+char const *software_filter::config_name(type n)
+{
+ assert(COUNT > n);
+ return software_filter_names[n];
+}
+
+char const *software_filter::display_name(type n)
+{
+ assert(COUNT > n);
+ return _(software_filter_names[n]);
+}
+
+} // namesapce ui
+
+
extern const char UI_VERSION_TAG[];
const char UI_VERSION_TAG[] = "# UI INFO ";
@@ -27,17 +103,7 @@ std::vector<std::string> c_mnfct::ui;
std::unordered_map<std::string, int> c_mnfct::uimap;
// Main filters
-uint16_t main_filters::actual = 0;
-const char *main_filters::text[] = { "All", "Available", "Unavailable", "Working", "Not Working", "Mechanical", "Not Mechanical",
- "Category", "Favorites", "BIOS", "Parents", "Clones", "Manufacturers", "Years", "Support Save",
- "Not Support Save", "CHD", "No CHD", "Vertical", "Horizontal", "Custom" };
-size_t main_filters::length = ARRAY_LENGTH(main_filters::text);
-
-// Software filters
-uint16_t sw_filters::actual = 0;
-const char *sw_filters::text[] = { "All", "Available", "Unavailable", "Parents", "Clones", "Years", "Publishers", "Supported",
- "Partial Supported", "Unsupported", "Region", "Device Type", "Software List", "Custom" };
-size_t sw_filters::length = ARRAY_LENGTH(sw_filters::text);
+ui::machine_filter::type main_filters::actual = ui::machine_filter::ALL;
// Globals
uint8_t ui_globals::rpanel = 0;
@@ -56,17 +122,17 @@ uint16_t ui_globals::panels_status = 0;
bool ui_globals::has_icons = false;
// Custom filter
-uint16_t custfltr::main = 0;
+ui::machine_filter::type custfltr::main = ui::machine_filter::ALL;
uint16_t custfltr::numother = 0;
-uint16_t custfltr::other[MAX_CUST_FILTER];
+ui::machine_filter::type custfltr::other[MAX_CUST_FILTER];
uint16_t custfltr::mnfct[MAX_CUST_FILTER];
uint16_t custfltr::year[MAX_CUST_FILTER];
uint16_t custfltr::screen[MAX_CUST_FILTER];
// Custom filter
-uint16_t sw_custfltr::main = 0;
+ui::software_filter::type sw_custfltr::main = ui::software_filter::ALL;
uint16_t sw_custfltr::numother = 0;
-uint16_t sw_custfltr::other[MAX_CUST_FILTER];
+ui::software_filter::type sw_custfltr::other[MAX_CUST_FILTER];
uint16_t sw_custfltr::mnfct[MAX_CUST_FILTER];
uint16_t sw_custfltr::year[MAX_CUST_FILTER];
uint16_t sw_custfltr::region[MAX_CUST_FILTER];
diff --git a/src/frontend/mame/ui/utils.h b/src/frontend/mame/ui/utils.h
index b00f0c3a775..abec24b9d73 100644
--- a/src/frontend/mame/ui/utils.h
+++ b/src/frontend/mame/ui/utils.h
@@ -7,45 +7,91 @@
Internal UI user interface.
***************************************************************************/
+#ifndef MAME_FRONTEND_UI_UTILS_H
+#define MAME_FRONTEND_UI_UTILS_H
#pragma once
-#ifndef __UI_UTILS_H__
-#define __UI_UTILS_H__
-
#include "unicode.h"
-#define MAX_CHAR_INFO 256
-#define MAX_CUST_FILTER 8
-// GLOBAL ENUMERATORS
-enum : uint16_t
+namespace ui {
+
+class machine_filter
{
- FILTER_FIRST = 0,
- FILTER_ALL = FILTER_FIRST,
- FILTER_AVAILABLE,
- FILTER_UNAVAILABLE,
- FILTER_WORKING,
- FILTER_NOT_WORKING,
- FILTER_MECHANICAL,
- FILTER_NOT_MECHANICAL,
- FILTER_CATEGORY,
- FILTER_FAVORITE,
- FILTER_BIOS,
- FILTER_PARENT,
- FILTER_CLONES,
- FILTER_MANUFACTURER,
- FILTER_YEAR,
- FILTER_SAVE,
- FILTER_NOSAVE,
- FILTER_CHD,
- FILTER_NOCHD,
- FILTER_VERTICAL,
- FILTER_HORIZONTAL,
- FILTER_CUSTOM,
- FILTER_LAST = FILTER_CUSTOM
+public:
+ enum type : uint16_t
+ {
+ ALL = 0,
+ AVAILABLE,
+ UNAVAILABLE,
+ WORKING,
+ NOT_WORKING,
+ MECHANICAL,
+ NOT_MECHANICAL,
+ CATEGORY,
+ FAVORITE,
+ BIOS,
+ PARENT,
+ CLONES,
+ MANUFACTURER,
+ YEAR,
+ SAVE,
+ NOSAVE,
+ CHD,
+ NOCHD,
+ VERTICAL,
+ HORIZONTAL,
+ CUSTOM,
+
+ COUNT,
+ FIRST = 0,
+ LAST = COUNT - 1
+ };
+
+ static char const *config_name(type n);
+ static char const *display_name(type n);
+};
+
+DECLARE_ENUM_INCDEC_OPERATORS(machine_filter::type)
+
+
+class software_filter
+{
+public:
+ enum type : uint16_t
+ {
+ ALL = 0,
+ AVAILABLE,
+ UNAVAILABLE,
+ PARENTS,
+ CLONES,
+ YEARS,
+ PUBLISHERS,
+ SUPPORTED,
+ PARTIAL_SUPPORTED,
+ UNSUPPORTED,
+ REGION,
+ DEVICE_TYPE,
+ LIST,
+ CUSTOM,
+
+ COUNT,
+ FIRST = 0,
+ LAST = COUNT - 1
+ };
+
+ static char const *config_name(type n);
+ static char const *display_name(type n);
};
+DECLARE_ENUM_INCDEC_OPERATORS(software_filter::type)
+
+} // namespace ui
+
+#define MAX_CHAR_INFO 256
+#define MAX_CUST_FILTER 8
+
enum
{
FIRST_VIEW = 0,
@@ -84,26 +130,6 @@ enum
HIDE_BOTH
};
-enum : uint16_t
-{
- UI_SW_FIRST = 0,
- UI_SW_ALL = UI_SW_FIRST,
- UI_SW_AVAILABLE,
- UI_SW_UNAVAILABLE,
- UI_SW_PARENTS,
- UI_SW_CLONES,
- UI_SW_YEARS,
- UI_SW_PUBLISHERS,
- UI_SW_SUPPORTED,
- UI_SW_PARTIAL_SUPPORTED,
- UI_SW_UNSUPPORTED,
- UI_SW_REGION,
- UI_SW_TYPE,
- UI_SW_LIST,
- UI_SW_CUSTOM,
- UI_SW_LAST = UI_SW_CUSTOM
-};
-
enum
{
HOVER_DAT_UP = -1000,
@@ -118,9 +144,9 @@ enum
HOVER_RPANEL_ARROW,
HOVER_LPANEL_ARROW,
HOVER_FILTER_FIRST,
- HOVER_FILTER_LAST = (HOVER_FILTER_FIRST) + 1 + FILTER_LAST,
+ HOVER_FILTER_LAST = (HOVER_FILTER_FIRST) + ui::machine_filter::COUNT,
HOVER_SW_FILTER_FIRST,
- HOVER_SW_FILTER_LAST = (HOVER_SW_FILTER_FIRST) + 1 + UI_SW_LAST,
+ HOVER_SW_FILTER_LAST = (HOVER_SW_FILTER_FIRST) + ui::software_filter::COUNT,
HOVER_RP_FIRST,
HOVER_RP_LAST = (HOVER_RP_FIRST) + 1 + RP_LAST
};
@@ -203,23 +229,14 @@ struct ui_globals
static bool has_icons;
};
-#define main_struct(name) \
-struct name##_filters \
-{ \
- static uint16_t actual; \
- static const char *text[]; \
- static size_t length; \
-};
-
-main_struct(main);
-main_struct(sw);
+struct main_filters { static ui::machine_filter::type actual; };
// Custom filter
struct custfltr
{
- static uint16_t main;
+ static ui::machine_filter::type main;
static uint16_t numother;
- static uint16_t other[MAX_CUST_FILTER];
+ static ui::machine_filter::type other[MAX_CUST_FILTER];
static uint16_t mnfct[MAX_CUST_FILTER];
static uint16_t screen[MAX_CUST_FILTER];
static uint16_t year[MAX_CUST_FILTER];
@@ -228,9 +245,9 @@ struct custfltr
// Software custom filter
struct sw_custfltr
{
- static uint16_t main;
+ static ui::software_filter::type main;
static uint16_t numother;
- static uint16_t other[MAX_CUST_FILTER];
+ static ui::software_filter::type other[MAX_CUST_FILTER];
static uint16_t mnfct[MAX_CUST_FILTER];
static uint16_t year[MAX_CUST_FILTER];
static uint16_t region[MAX_CUST_FILTER];
@@ -295,4 +312,4 @@ bool input_character(std::string &buffer, char32_t unichar, F &&filter)
}
-#endif /* __UI_UTILS_H__ */
+#endif // MAME_FRONTEND_UI_UTILS_H