Revert "C++ comments for some parts."

This reverts commit 19c4764090.
This commit is contained in:
Vas Crabb 2016-07-05 11:16:05 +10:00
parent 09b6b311ff
commit 2c9dfd77ba
32 changed files with 697 additions and 617 deletions

View File

@ -22,8 +22,8 @@
//************************************************************************** //**************************************************************************
// hashes to use for validation // hashes to use for validation
#define AUDIT_VALIDATE_FAST "R" // CRC only #define AUDIT_VALIDATE_FAST "R" /* CRC only */
#define AUDIT_VALIDATE_FULL "RS" // CRC + SHA1 #define AUDIT_VALIDATE_FULL "RS" /* CRC + SHA1 */
@ -111,15 +111,15 @@ public:
private: private:
// internal state // internal state
audit_record * m_next; audit_record * m_next;
media_type m_type; // type of item that was audited media_type m_type; /* type of item that was audited */
audit_status m_status; // status of audit on this item audit_status m_status; /* status of audit on this item */
audit_substatus m_substatus; // finer-detail status audit_substatus m_substatus; /* finer-detail status */
const char * m_name; // name of item const char * m_name; /* name of item */
UINT64 m_explength; // expected length of item UINT64 m_explength; /* expected length of item */
UINT64 m_length; // actual length of item UINT64 m_length; /* actual length of item */
hash_collection m_exphashes; // expected hash data hash_collection m_exphashes; /* expected hash data */
hash_collection m_hashes; // actual hash information hash_collection m_hashes; /* actual hash information */
device_t * m_shared_device; // device that shares the rom device_t * m_shared_device; /* device that shares the rom */
}; };

View File

@ -1260,7 +1260,7 @@ void cli_frontend::output_single_softlist(FILE *out, software_list_device &swlis
for (feature_list_item &flist : part.featurelist()) for (feature_list_item &flist : part.featurelist())
fprintf(out, "\t\t\t\t<feature name=\"%s\" value=\"%s\" />\n", flist.name(), xml_normalize_string(flist.value())); fprintf(out, "\t\t\t\t<feature name=\"%s\" value=\"%s\" />\n", flist.name(), xml_normalize_string(flist.value()));
// TODO: display rom region information /* TODO: display rom region information */
for (const rom_entry *region = part.romdata(); region; region = rom_next_region(region)) for (const rom_entry *region = part.romdata(); region; region = rom_next_region(region))
{ {
int is_disk = ROMREGION_ISDISKDATA(region); int is_disk = ROMREGION_ISDISKDATA(region);
@ -1279,7 +1279,7 @@ void cli_frontend::output_single_softlist(FILE *out, software_list_device &swlis
else else
fprintf( out, "\t\t\t\t\t<disk name=\"%s\"", xml_normalize_string(ROM_GETNAME(rom)) ); fprintf( out, "\t\t\t\t\t<disk name=\"%s\"", xml_normalize_string(ROM_GETNAME(rom)) );
// dump checksum information only if there is a known dump /* dump checksum information only if there is a known dump */
hash_collection hashes(ROM_GETHASHDATA(rom)); hash_collection hashes(ROM_GETHASHDATA(rom));
if ( !hashes.flag(hash_collection::FLAG_NO_DUMP) ) if ( !hashes.flag(hash_collection::FLAG_NO_DUMP) )
fprintf( out, " %s", hashes.attribute_string().c_str() ); fprintf( out, " %s", hashes.attribute_string().c_str() );

View File

@ -103,12 +103,12 @@ std::vector<std::string> split(const std::string &text, char sep)
std::vector<std::string> tokens; std::vector<std::string> tokens;
std::size_t start = 0, end = 0; std::size_t start = 0, end = 0;
while ((end = text.find(sep, start)) != std::string::npos) { while ((end = text.find(sep, start)) != std::string::npos) {
auto temp = text.substr(start, end - start); std::string temp = text.substr(start, end - start);
if (!temp.empty()) tokens.push_back(temp); if (temp != "") tokens.push_back(temp);
start = end + 1; start = end + 1;
} }
auto temp = text.substr(start); std::string temp = text.substr(start);
if (!temp.empty()) tokens.push_back(temp); if (temp != "") tokens.push_back(temp);
return tokens; return tokens;
} }

View File

@ -52,7 +52,7 @@ public:
virtual void ui_initialize(running_machine& machine) override; virtual void ui_initialize(running_machine& machine) override;
// execute as configured by the OPTION_SYSTEMNAME option on the specified options /* execute as configured by the OPTION_SYSTEMNAME option on the specified options */
int execute(); int execute();
void start_luaengine(); void start_luaengine();
void schedule_new_driver(const game_driver &driver); void schedule_new_driver(const game_driver &driver);

View File

@ -26,8 +26,8 @@ inline int cs_stricmp(const char *s1, const char *s2)
{ {
for (;;) for (;;)
{ {
auto c1 = tolower(*s1++); int c1 = tolower(*s1++);
auto c2 = tolower(*s2++); int c2 = tolower(*s2++);
if (c1 == 0 || c1 != c2) if (c1 == 0 || c1 != c2)
return c1 - c2; return c1 - c2;
} }
@ -35,8 +35,8 @@ inline int cs_stricmp(const char *s1, const char *s2)
bool sorted_game_list(const game_driver *x, const game_driver *y) bool sorted_game_list(const game_driver *x, const game_driver *y)
{ {
auto clonex = (x->parent[0] != '0'); bool clonex = (x->parent[0] != '0');
auto cloney = (y->parent[0] != '0'); bool cloney = (y->parent[0] != '0');
if (!clonex && !cloney) if (!clonex && !cloney)
return (cs_stricmp(x->description, y->description) < 0); return (cs_stricmp(x->description, y->description) < 0);
@ -120,13 +120,13 @@ void menu_audit::handle()
if (m_audit_mode == 1) if (m_audit_mode == 1)
{ {
auto iter = m_unavailablesorted.begin(); vptr_game::iterator iter = m_unavailablesorted.begin();
while (iter != m_unavailablesorted.end()) while (iter != m_unavailablesorted.end())
{ {
driver_enumerator enumerator(machine().options(), (*iter)->name); driver_enumerator enumerator(machine().options(), (*iter)->name);
enumerator.next(); enumerator.next();
media_auditor auditor(enumerator); media_auditor auditor(enumerator);
auto summary = auditor.audit_media(AUDIT_VALIDATE_FAST); media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST);
// if everything looks good, include the driver // if everything looks good, include the driver
if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED)
@ -144,7 +144,7 @@ void menu_audit::handle()
media_auditor auditor(enumerator); media_auditor auditor(enumerator);
while (enumerator.next()) while (enumerator.next())
{ {
auto summary = auditor.audit_media(AUDIT_VALIDATE_FAST); media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST);
// if everything looks good, include the driver // if everything looks good, include the driver
if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED)
@ -188,16 +188,16 @@ void menu_audit::save_available_machines()
util::stream_format(buffer, "%d\n", m_unavailablesorted.size()); util::stream_format(buffer, "%d\n", m_unavailablesorted.size());
// generate available list // generate available list
for (auto & e : m_availablesorted) for (size_t x = 0; x < m_availablesorted.size(); ++x)
{ {
auto find = driver_list::find(e->name); int find = driver_list::find(m_availablesorted[x]->name);
util::stream_format(buffer, "%d\n", find); util::stream_format(buffer, "%d\n", find);
} }
// generate unavailable list // generate unavailable list
for (auto & e : m_unavailablesorted) for (size_t x = 0; x < m_unavailablesorted.size(); ++x)
{ {
auto find = driver_list::find(e->name); int find = driver_list::find(m_unavailablesorted[x]->name);
util::stream_format(buffer, "%d\n", find); util::stream_format(buffer, "%d\n", find);
} }
file.puts(buffer.str().c_str()); file.puts(buffer.str().c_str());

View File

@ -66,7 +66,9 @@ void menu_barcode_reader::populate()
new_barcode = buffer.c_str(); new_barcode = buffer.c_str();
} }
else else
{
new_barcode = m_barcode_buffer; new_barcode = m_barcode_buffer;
}
item_append(_("New Barcode:"), new_barcode, 0, ITEMREF_NEW_BARCODE); item_append(_("New Barcode:"), new_barcode, 0, ITEMREF_NEW_BARCODE);
@ -90,7 +92,7 @@ void menu_barcode_reader::handle()
populate(); populate();
// process the menu // process the menu
auto event = process(PROCESS_LR_REPEAT); const event *event = process(PROCESS_LR_REPEAT);
// process the event // process the event
if (event) if (event)

View File

@ -36,19 +36,19 @@ namespace ui {
void menu_cheat::handle() void menu_cheat::handle()
{ {
// process the menu /* process the menu */
auto menu_event = process(PROCESS_LR_REPEAT); const event *menu_event = process(PROCESS_LR_REPEAT);
// handle events /* handle events */
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
auto changed = false; bool changed = false;
// clear cheat comment on any movement or keypress /* clear cheat comment on any movement or keypress */
machine().popmessage(); machine().popmessage();
// handle reset all + reset all cheats for reload all option /* handle reset all + reset all cheats for reload all option */
if ((menu_event->itemref == ITEMREF_CHEATS_RESET_ALL || menu_event->itemref == ITEMREF_CHEATS_RELOAD_ALL) && menu_event->iptkey == IPT_UI_SELECT) if ((menu_event->itemref == ITEMREF_CHEATS_RESET_ALL || menu_event->itemref == ITEMREF_CHEATS_RELOAD_ALL) && menu_event->iptkey == IPT_UI_SELECT)
{ {
for (auto &curcheat : mame_machine_manager::instance()->cheat().entries()) for (auto &curcheat : mame_machine_manager::instance()->cheat().entries())
@ -56,34 +56,34 @@ void menu_cheat::handle()
changed = true; changed = true;
} }
// handle individual cheats /* handle individual cheats */
else if (menu_event->itemref >= ITEMREF_CHEATS_FIRST_ITEM) else if (menu_event->itemref >= ITEMREF_CHEATS_FIRST_ITEM)
{ {
auto curcheat = reinterpret_cast<cheat_entry *>(menu_event->itemref); cheat_entry *curcheat = reinterpret_cast<cheat_entry *>(menu_event->itemref);
const char *string; const char *string;
switch (menu_event->iptkey) switch (menu_event->iptkey)
{ {
// if selected, activate a oneshot /* if selected, activate a oneshot */
case IPT_UI_SELECT: case IPT_UI_SELECT:
changed = curcheat->activate(); changed = curcheat->activate();
break; break;
// if cleared, reset to default value /* if cleared, reset to default value */
case IPT_UI_CLEAR: case IPT_UI_CLEAR:
changed = curcheat->select_default_state(); changed = curcheat->select_default_state();
break; break;
// left decrements /* left decrements */
case IPT_UI_LEFT: case IPT_UI_LEFT:
changed = curcheat->select_previous_state(); changed = curcheat->select_previous_state();
break; break;
// right increments /* right increments */
case IPT_UI_RIGHT: case IPT_UI_RIGHT:
changed = curcheat->select_next_state(); changed = curcheat->select_next_state();
break; break;
// bring up display comment if one exists /* bring up display comment if one exists */
case IPT_UI_DISPLAY_COMMENT: case IPT_UI_DISPLAY_COMMENT:
case IPT_UI_UP: case IPT_UI_UP:
case IPT_UI_DOWN: case IPT_UI_DOWN:
@ -94,22 +94,24 @@ void menu_cheat::handle()
} }
} }
// handle reload all /* handle reload all */
if (menu_event->itemref == ITEMREF_CHEATS_RELOAD_ALL && menu_event->iptkey == IPT_UI_SELECT) if (menu_event->itemref == ITEMREF_CHEATS_RELOAD_ALL && menu_event->iptkey == IPT_UI_SELECT)
{ {
// re-init cheat engine and thus reload cheats/cheats have already been turned off by here /* re-init cheat engine and thus reload cheats/cheats have already been turned off by here */
mame_machine_manager::instance()->cheat().reload(); mame_machine_manager::instance()->cheat().reload();
// display the reloaded cheats /* display the reloaded cheats */
reset(reset_options::REMEMBER_REF); reset(reset_options::REMEMBER_REF);
machine().popmessage(_("All cheats reloaded")); machine().popmessage(_("All cheats reloaded"));
} }
// handle autofire menu /* handle autofire menu */
if (menu_event->itemref == ITEMREF_CHEATS_AUTOFIRE_SETTINGS && menu_event->iptkey == IPT_UI_SELECT) if (menu_event->itemref == ITEMREF_CHEATS_AUTOFIRE_SETTINGS && menu_event->iptkey == IPT_UI_SELECT)
{
menu::stack_push<menu_autofire>(ui(), container); menu::stack_push<menu_autofire>(ui(), container);
}
// if things changed, update /* if things changed, update */
if (changed) if (changed)
reset(reset_options::REMEMBER_REF); reset(reset_options::REMEMBER_REF);
} }
@ -120,26 +122,26 @@ void menu_cheat::handle()
menu_cheat_populate - populate the cheat menu menu_cheat_populate - populate the cheat menu
-------------------------------------------------*/ -------------------------------------------------*/
menu_cheat::menu_cheat(mame_ui_manager &mui, render_container *container) menu_cheat::menu_cheat(mame_ui_manager &mui, render_container *container) : menu(mui, container)
: menu(mui, container)
{ {
} }
void menu_cheat::populate() void menu_cheat::populate()
{ {
/* iterate over cheats */
std::string text;
std::string subtext;
// add the autofire menu // add the autofire menu
item_append(_("Autofire Settings"), "", 0, (void *)ITEMREF_CHEATS_AUTOFIRE_SETTINGS); item_append(_("Autofire Settings"), "", 0, (void *)ITEMREF_CHEATS_AUTOFIRE_SETTINGS);
// add a separator /* add a separator */
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
// add other cheats // add other cheats
if (!mame_machine_manager::instance()->cheat().entries().empty()) { if (!mame_machine_manager::instance()->cheat().entries().empty()) {
for (auto &curcheat : mame_machine_manager::instance()->cheat().entries()) for (auto &curcheat : mame_machine_manager::instance()->cheat().entries())
{ {
std::string text;
std::string subtext;
UINT32 flags; UINT32 flags;
curcheat->menu_text(text, subtext, flags); curcheat->menu_text(text, subtext, flags);
if (text == MENU_SEPARATOR_ITEM) if (text == MENU_SEPARATOR_ITEM)
@ -148,13 +150,13 @@ void menu_cheat::populate()
item_append(text, subtext, flags, curcheat.get()); item_append(text, subtext, flags, curcheat.get());
} }
// add a separator /* add a separator */
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
// add a reset all option /* add a reset all option */
item_append(_("Reset All"), "", 0, (void *)ITEMREF_CHEATS_RESET_ALL); item_append(_("Reset All"), "", 0, (void *)ITEMREF_CHEATS_RESET_ALL);
// add a reload all cheats option /* add a reload all cheats option */
item_append(_("Reload All"), "", 0, (void *)ITEMREF_CHEATS_RELOAD_ALL); item_append(_("Reload All"), "", 0, (void *)ITEMREF_CHEATS_RELOAD_ALL);
} }
} }
@ -163,17 +165,27 @@ menu_cheat::~menu_cheat()
{ {
} }
/*------------------------------------------------- /*-------------------------------------------------
menu_autofire - handle the autofire settings menu_autofire - handle the autofire settings
menu menu
-------------------------------------------------*/ -------------------------------------------------*/
menu_autofire::menu_autofire(mame_ui_manager &mui, render_container *container) menu_autofire::menu_autofire(mame_ui_manager &mui, render_container *container) : menu(mui, container), last_toggle(false)
: menu(mui, container)
, last_toggle(false)
{ {
auto screen = mui.machine().first_screen(); const screen_device *screen = mui.machine().first_screen();
refresh = (screen == nullptr) ? 60.0 : ATTOSECONDS_TO_HZ(screen->refresh_attoseconds());
if (screen == nullptr)
{
refresh = 60.0;
}
else
{
refresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds());
}
} }
menu_autofire::~menu_autofire() menu_autofire::~menu_autofire()
@ -183,12 +195,12 @@ menu_autofire::~menu_autofire()
void menu_autofire::handle() void menu_autofire::handle()
{ {
ioport_field *field; ioport_field *field;
auto changed = false; bool changed = false;
// process the menu /* process the menu */
auto menu_event = process(0); const event *menu_event = process(0);
// handle events /* handle events */
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
// menu item is changed using left/right keys only // menu item is changed using left/right keys only
@ -197,14 +209,14 @@ void menu_autofire::handle()
if (menu_event->itemref == ITEMREF_AUTOFIRE_STATUS) if (menu_event->itemref == ITEMREF_AUTOFIRE_STATUS)
{ {
// toggle autofire status // toggle autofire status
auto autofire_toggle = machine().ioport().get_autofire_toggle(); // (menu_event->iptkey == IPT_UI_LEFT); bool autofire_toggle = machine().ioport().get_autofire_toggle(); // (menu_event->iptkey == IPT_UI_LEFT);
machine().ioport().set_autofire_toggle(!autofire_toggle); machine().ioport().set_autofire_toggle(!autofire_toggle);
changed = true; changed = true;
} }
else if (menu_event->itemref == ITEMREF_AUTOFIRE_DELAY) else if (menu_event->itemref == ITEMREF_AUTOFIRE_DELAY)
{ {
// change autofire frequency // change autofire frequency
auto autofire_delay = machine().ioport().get_autofire_delay(); int autofire_delay = machine().ioport().get_autofire_delay();
if (menu_event->iptkey == IPT_UI_LEFT) if (menu_event->iptkey == IPT_UI_LEFT)
{ {
autofire_delay--; autofire_delay--;
@ -235,11 +247,15 @@ void menu_autofire::handle()
// if toggle settings changed, redraw menu to reflect new options // if toggle settings changed, redraw menu to reflect new options
if (!changed) if (!changed)
{
changed = (last_toggle != machine().ioport().get_autofire_toggle()); changed = (last_toggle != machine().ioport().get_autofire_toggle());
}
// if something changed, rebuild the menu /* if something changed, rebuild the menu */
if (changed) if (changed)
{
reset(reset_options::REMEMBER_REF); reset(reset_options::REMEMBER_REF);
}
} }
@ -252,16 +268,16 @@ void menu_autofire::populate()
{ {
char temp_text[64]; char temp_text[64];
// add autofire toggle item /* add autofire toggle item */
auto autofire_toggle = machine().ioport().get_autofire_toggle(); bool autofire_toggle = machine().ioport().get_autofire_toggle();
item_append(_("Autofire Status"), (autofire_toggle ? _("Disabled") : _("Enabled")), item_append(_("Autofire Status"), (autofire_toggle ? _("Disabled") : _("Enabled")),
(autofire_toggle ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW), (void *)ITEMREF_AUTOFIRE_STATUS); (autofire_toggle ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW), (void *)ITEMREF_AUTOFIRE_STATUS);
// iterate over the input ports and add autofire toggle items /* iterate over the input ports and add autofire toggle items */
int menu_items = 0; int menu_items = 0;
for (auto &port : machine().ioport().ports()) for (auto &port : machine().ioport().ports())
{ {
auto is_first_button = true; bool is_first_button = true;
for (ioport_field &field : port.second->fields()) for (ioport_field &field : port.second->fields())
{ {
if (field.type() >= IPT_BUTTON1 && field.type() <= IPT_BUTTON16) if (field.type() >= IPT_BUTTON1 && field.type() <= IPT_BUTTON16)
@ -272,11 +288,11 @@ void menu_autofire::populate()
if (is_first_button) if (is_first_button)
{ {
// add a separator for each player /* add a separator for each player */
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
is_first_button = false; is_first_button = false;
} }
// add an autofire item /* add an autofire item */
if (!autofire_toggle) if (!autofire_toggle)
{ {
// item is enabled and can be switched to values on/off // item is enabled and can be switched to values on/off
@ -293,26 +309,29 @@ void menu_autofire::populate()
} }
} }
// add text item if no buttons found /* add text item if no buttons found */
if (menu_items==0) if (menu_items==0)
{ {
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
item_append(_("No buttons found on this machine!"), "", FLAG_DISABLE, nullptr); item_append(_("No buttons found on this machine!"), "", FLAG_DISABLE, nullptr);
} }
// add a separator /* add a separator */
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
// add autofire delay item /* add autofire delay item */
auto value = machine().ioport().get_autofire_delay(); int value = machine().ioport().get_autofire_delay();
snprintf(temp_text, ARRAY_LENGTH(temp_text), "%d = %.2f Hz", value, (float)refresh/value); snprintf(temp_text, ARRAY_LENGTH(temp_text), "%d = %.2f Hz", value, (float)refresh/value);
if (!autofire_toggle) if (!autofire_toggle)
{
item_append(_("Autofire Delay"), temp_text, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)ITEMREF_AUTOFIRE_DELAY); item_append(_("Autofire Delay"), temp_text, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)ITEMREF_AUTOFIRE_DELAY);
}
else else
{
item_append(_("Autofire Delay"), temp_text, FLAG_DISABLE | FLAG_INVERT, nullptr); item_append(_("Autofire Delay"), temp_text, FLAG_DISABLE | FLAG_INVERT, nullptr);
}
// add a separator /* add a separator */
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
last_toggle = autofire_toggle; last_toggle = autofire_toggle;

View File

@ -25,7 +25,9 @@ namespace ui {
// ctor / dtor // ctor / dtor
//------------------------------------------------- //-------------------------------------------------
menu_custom_filter::menu_custom_filter(mame_ui_manager &mui, render_container *container, bool _single_menu) menu_custom_filter::menu_custom_filter(mame_ui_manager &mui, render_container *container, bool _single_menu)
: menu(mui, container), m_single_menu(_single_menu), m_added(false) : menu(mui, container)
, m_single_menu(_single_menu)
, m_added(false)
{ {
} }
@ -41,11 +43,11 @@ menu_custom_filter::~menu_custom_filter()
//------------------------------------------------- //-------------------------------------------------
void menu_custom_filter::handle() void menu_custom_filter::handle()
{ {
auto changed = false; bool changed = false;
m_added = false; m_added = false;
// process the menu // process the menu
auto menu_event = process(PROCESS_LR_REPEAT); const event *menu_event = process(PROCESS_LR_REPEAT);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
switch ((FPTR)menu_event->itemref) switch ((FPTR)menu_event->itemref)
@ -61,7 +63,8 @@ void menu_custom_filter::handle()
case ADD_FILTER: case ADD_FILTER:
if (menu_event->iptkey == IPT_UI_SELECT) if (menu_event->iptkey == IPT_UI_SELECT)
{ {
custfltr::other[++custfltr::numother] = FILTER_UNAVAILABLE + 1; custfltr::numother++;
custfltr::other[custfltr::numother] = FILTER_UNAVAILABLE + 1;
m_added = true; m_added = true;
} }
break; break;
@ -69,7 +72,8 @@ void menu_custom_filter::handle()
case REMOVE_FILTER: case REMOVE_FILTER:
if (menu_event->iptkey == IPT_UI_SELECT) if (menu_event->iptkey == IPT_UI_SELECT)
{ {
custfltr::other[custfltr::numother--] = FILTER_UNAVAILABLE + 1; custfltr::other[custfltr::numother] = FILTER_UNAVAILABLE + 1;
custfltr::numother--;
changed = true; changed = true;
} }
break; break;
@ -77,7 +81,7 @@ void menu_custom_filter::handle()
if ((FPTR)menu_event->itemref >= OTHER_FILTER && (FPTR)menu_event->itemref < OTHER_FILTER + MAX_CUST_FILTER) if ((FPTR)menu_event->itemref >= OTHER_FILTER && (FPTR)menu_event->itemref < OTHER_FILTER + MAX_CUST_FILTER)
{ {
auto pos = (int)((FPTR)menu_event->itemref - OTHER_FILTER); int pos = (int)((FPTR)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] > FILTER_UNAVAILABLE + 1)
{ {
custfltr::other[pos]--; custfltr::other[pos]--;
@ -94,7 +98,7 @@ void menu_custom_filter::handle()
} }
else if (menu_event->iptkey == IPT_UI_SELECT) else if (menu_event->iptkey == IPT_UI_SELECT)
{ {
auto total = main_filters::length; size_t total = main_filters::length;
std::vector<std::string> s_sel(total); std::vector<std::string> s_sel(total);
for (size_t index = 0; index < total; ++index) for (size_t index = 0; index < total; ++index)
if (index <= FILTER_UNAVAILABLE || index == FILTER_CATEGORY || index == FILTER_FAVORITE || index == FILTER_CUSTOM) if (index <= FILTER_UNAVAILABLE || index == FILTER_CATEGORY || index == FILTER_FAVORITE || index == FILTER_CUSTOM)
@ -102,12 +106,12 @@ void menu_custom_filter::handle()
else else
s_sel[index] = main_filters::text[index]; s_sel[index] = main_filters::text[index];
menu::stack_push<menu_selector>(ui(), container, std::move(s_sel), custfltr::other[pos]); menu::stack_push<menu_selector>(ui(), container, s_sel, custfltr::other[pos]);
} }
} }
else if ((FPTR)menu_event->itemref >= YEAR_FILTER && (FPTR)menu_event->itemref < YEAR_FILTER + MAX_CUST_FILTER) else if ((FPTR)menu_event->itemref >= YEAR_FILTER && (FPTR)menu_event->itemref < YEAR_FILTER + MAX_CUST_FILTER)
{ {
auto pos = (int)((FPTR)menu_event->itemref - YEAR_FILTER); int pos = (int)((FPTR)menu_event->itemref - YEAR_FILTER);
if (menu_event->iptkey == IPT_UI_LEFT && custfltr::year[pos] > 0) if (menu_event->iptkey == IPT_UI_LEFT && custfltr::year[pos] > 0)
{ {
custfltr::year[pos]--; custfltr::year[pos]--;
@ -123,7 +127,7 @@ void menu_custom_filter::handle()
} }
else if ((FPTR)menu_event->itemref >= MNFCT_FILTER && (FPTR)menu_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER) else if ((FPTR)menu_event->itemref >= MNFCT_FILTER && (FPTR)menu_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER)
{ {
auto pos = (int)((FPTR)menu_event->itemref - MNFCT_FILTER); int pos = (int)((FPTR)menu_event->itemref - MNFCT_FILTER);
if (menu_event->iptkey == IPT_UI_LEFT && custfltr::mnfct[pos] > 0) if (menu_event->iptkey == IPT_UI_LEFT && custfltr::mnfct[pos] > 0)
{ {
custfltr::mnfct[pos]--; custfltr::mnfct[pos]--;
@ -151,11 +155,11 @@ void menu_custom_filter::handle()
void menu_custom_filter::populate() void menu_custom_filter::populate()
{ {
// add main filter // add main filter
auto arrow_flags = get_arrow_flags((int)FILTER_ALL, (int)FILTER_UNAVAILABLE, custfltr::main); UINT32 arrow_flags = get_arrow_flags((int)FILTER_ALL, (int)FILTER_UNAVAILABLE, custfltr::main);
item_append(_("Main filter"), main_filters::text[custfltr::main], arrow_flags, (void *)(FPTR)MAIN_FILTER); item_append(_("Main filter"), main_filters::text[custfltr::main], arrow_flags, (void *)(FPTR)MAIN_FILTER);
// add other filters // add other filters
for (int x = 1; x <= custfltr::numother; ++x) for (int x = 1; x <= custfltr::numother; x++)
{ {
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
@ -244,7 +248,7 @@ void menu_custom_filter::save_custom_filters()
util::stream_format(cinfo, "Total filters = %d\n", (custfltr::numother + 1)); 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", main_filters::text[custfltr::main]);
for (int x = 1; x <= custfltr::numother; ++x) for (int x = 1; x <= custfltr::numother; x++)
{ {
util::stream_format(cinfo, "Other filter = %s\n", main_filters::text[custfltr::other[x]]); util::stream_format(cinfo, "Other filter = %s\n", main_filters::text[custfltr::other[x]]);
if (custfltr::other[x] == FILTER_MANUFACTURER) if (custfltr::other[x] == FILTER_MANUFACTURER)
@ -264,7 +268,10 @@ void menu_custom_filter::save_custom_filters()
// ctor / dtor // ctor / dtor
//------------------------------------------------- //-------------------------------------------------
menu_swcustom_filter::menu_swcustom_filter(mame_ui_manager &mui, render_container *container, const game_driver *_driver, s_filter &_filter) menu_swcustom_filter::menu_swcustom_filter(mame_ui_manager &mui, render_container *container, const game_driver *_driver, s_filter &_filter)
: menu(mui, container), m_added(false), m_filter(_filter), m_driver(_driver) : menu(mui, container)
, m_added(false)
, m_filter(_filter)
, m_driver(_driver)
{ {
} }
@ -279,11 +286,11 @@ menu_swcustom_filter::~menu_swcustom_filter()
//------------------------------------------------- //-------------------------------------------------
void menu_swcustom_filter::handle() void menu_swcustom_filter::handle()
{ {
auto changed = false; bool changed = false;
m_added = false; m_added = false;
// process the menu // process the menu
auto menu_event = process(PROCESS_LR_REPEAT); const event *menu_event = process(PROCESS_LR_REPEAT);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
switch ((FPTR)menu_event->itemref) switch ((FPTR)menu_event->itemref)
@ -299,7 +306,8 @@ void menu_swcustom_filter::handle()
case ADD_FILTER: case ADD_FILTER:
if (menu_event->iptkey == IPT_UI_SELECT) if (menu_event->iptkey == IPT_UI_SELECT)
{ {
sw_custfltr::other[++sw_custfltr::numother] = UI_SW_UNAVAILABLE + 1; sw_custfltr::numother++;
sw_custfltr::other[sw_custfltr::numother] = UI_SW_UNAVAILABLE + 1;
m_added = true; m_added = true;
} }
break; break;
@ -307,7 +315,8 @@ void menu_swcustom_filter::handle()
case REMOVE_FILTER: case REMOVE_FILTER:
if (menu_event->iptkey == IPT_UI_SELECT) if (menu_event->iptkey == IPT_UI_SELECT)
{ {
sw_custfltr::other[sw_custfltr::numother--] = UI_SW_UNAVAILABLE + 1; sw_custfltr::other[sw_custfltr::numother] = UI_SW_UNAVAILABLE + 1;
sw_custfltr::numother--;
changed = true; changed = true;
} }
break; break;
@ -315,7 +324,7 @@ void menu_swcustom_filter::handle()
if ((FPTR)menu_event->itemref >= OTHER_FILTER && (FPTR)menu_event->itemref < OTHER_FILTER + MAX_CUST_FILTER) if ((FPTR)menu_event->itemref >= OTHER_FILTER && (FPTR)menu_event->itemref < OTHER_FILTER + MAX_CUST_FILTER)
{ {
auto pos = (int)((FPTR)menu_event->itemref - OTHER_FILTER); int pos = (int)((FPTR)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] > UI_SW_UNAVAILABLE + 1)
{ {
sw_custfltr::other[pos]--; sw_custfltr::other[pos]--;
@ -328,7 +337,7 @@ void menu_swcustom_filter::handle()
} }
else if (menu_event->iptkey == IPT_UI_SELECT) else if (menu_event->iptkey == IPT_UI_SELECT)
{ {
auto total = sw_filters::length; size_t total = sw_filters::length;
std::vector<std::string> s_sel(total); std::vector<std::string> s_sel(total);
for (size_t index = 0; index < total; ++index) for (size_t index = 0; index < total; ++index)
if (index <= UI_SW_UNAVAILABLE|| index == UI_SW_CUSTOM) if (index <= UI_SW_UNAVAILABLE|| index == UI_SW_CUSTOM)
@ -336,12 +345,12 @@ void menu_swcustom_filter::handle()
else else
s_sel[index] = sw_filters::text[index]; s_sel[index] = sw_filters::text[index];
menu::stack_push<menu_selector>(ui(), container, std::move(s_sel), sw_custfltr::other[pos]); menu::stack_push<menu_selector>(ui(), container, s_sel, sw_custfltr::other[pos]);
} }
} }
else if ((FPTR)menu_event->itemref >= YEAR_FILTER && (FPTR)menu_event->itemref < YEAR_FILTER + MAX_CUST_FILTER) else if ((FPTR)menu_event->itemref >= YEAR_FILTER && (FPTR)menu_event->itemref < YEAR_FILTER + MAX_CUST_FILTER)
{ {
auto pos = (int)((FPTR)menu_event->itemref - YEAR_FILTER); int pos = (int)((FPTR)menu_event->itemref - YEAR_FILTER);
if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::year[pos] > 0) if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::year[pos] > 0)
{ {
sw_custfltr::year[pos]--; sw_custfltr::year[pos]--;
@ -357,7 +366,7 @@ void menu_swcustom_filter::handle()
} }
else if ((FPTR)menu_event->itemref >= TYPE_FILTER && (FPTR)menu_event->itemref < TYPE_FILTER + MAX_CUST_FILTER) else if ((FPTR)menu_event->itemref >= TYPE_FILTER && (FPTR)menu_event->itemref < TYPE_FILTER + MAX_CUST_FILTER)
{ {
auto pos = (int)((FPTR)menu_event->itemref - TYPE_FILTER); int pos = (int)((FPTR)menu_event->itemref - TYPE_FILTER);
if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::type[pos] > 0) if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::type[pos] > 0)
{ {
sw_custfltr::type[pos]--; sw_custfltr::type[pos]--;
@ -373,7 +382,7 @@ void menu_swcustom_filter::handle()
} }
else if ((FPTR)menu_event->itemref >= MNFCT_FILTER && (FPTR)menu_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER) else if ((FPTR)menu_event->itemref >= MNFCT_FILTER && (FPTR)menu_event->itemref < MNFCT_FILTER + MAX_CUST_FILTER)
{ {
auto pos = (int)((FPTR)menu_event->itemref - MNFCT_FILTER); int pos = (int)((FPTR)menu_event->itemref - MNFCT_FILTER);
if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::mnfct[pos] > 0) if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::mnfct[pos] > 0)
{ {
sw_custfltr::mnfct[pos]--; sw_custfltr::mnfct[pos]--;
@ -389,7 +398,7 @@ void menu_swcustom_filter::handle()
} }
else if ((FPTR)menu_event->itemref >= REGION_FILTER && (FPTR)menu_event->itemref < REGION_FILTER + MAX_CUST_FILTER) else if ((FPTR)menu_event->itemref >= REGION_FILTER && (FPTR)menu_event->itemref < REGION_FILTER + MAX_CUST_FILTER)
{ {
auto pos = (int)((FPTR)menu_event->itemref - REGION_FILTER); int pos = (int)((FPTR)menu_event->itemref - REGION_FILTER);
if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::region[pos] > 0) if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::region[pos] > 0)
{ {
sw_custfltr::region[pos]--; sw_custfltr::region[pos]--;
@ -405,7 +414,7 @@ void menu_swcustom_filter::handle()
} }
else if ((FPTR)menu_event->itemref >= LIST_FILTER && (FPTR)menu_event->itemref < LIST_FILTER + MAX_CUST_FILTER) else if ((FPTR)menu_event->itemref >= LIST_FILTER && (FPTR)menu_event->itemref < LIST_FILTER + MAX_CUST_FILTER)
{ {
auto pos = (int)((FPTR)menu_event->itemref - LIST_FILTER); int pos = (int)((FPTR)menu_event->itemref - LIST_FILTER);
if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::list[pos] > 0) if (menu_event->iptkey == IPT_UI_LEFT && sw_custfltr::list[pos] > 0)
{ {
sw_custfltr::list[pos]--; sw_custfltr::list[pos]--;
@ -433,11 +442,11 @@ void menu_swcustom_filter::handle()
void menu_swcustom_filter::populate() void menu_swcustom_filter::populate()
{ {
// add main filter // add main filter
auto arrow_flags = get_arrow_flags((int)UI_SW_ALL, (int)UI_SW_UNAVAILABLE, sw_custfltr::main); UINT32 arrow_flags = get_arrow_flags((int)UI_SW_ALL, (int)UI_SW_UNAVAILABLE, sw_custfltr::main);
item_append(_("Main filter"), sw_filters::text[sw_custfltr::main], arrow_flags, (void *)(FPTR)MAIN_FILTER); item_append(_("Main filter"), sw_filters::text[sw_custfltr::main], arrow_flags, (void *)(FPTR)MAIN_FILTER);
// add other filters // add other filters
for (int x = 1; x <= sw_custfltr::numother; ++x) for (int x = 1; x <= sw_custfltr::numother; x++)
{ {
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
@ -554,7 +563,7 @@ void menu_swcustom_filter::save_sw_custom_filters()
util::stream_format(cinfo, "Total filters = %d\n", (sw_custfltr::numother + 1)); 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", sw_filters::text[sw_custfltr::main]);
for (int x = 1; x <= sw_custfltr::numother; ++x) for (int x = 1; x <= sw_custfltr::numother; x++)
{ {
util::stream_format(cinfo, "Other filter = %s\n", sw_filters::text[sw_custfltr::other[x]]); util::stream_format(cinfo, "Other filter = %s\n", sw_filters::text[sw_custfltr::other[x]]);
if (sw_custfltr::other[x] == UI_SW_PUBLISHERS) if (sw_custfltr::other[x] == UI_SW_PUBLISHERS)

View File

@ -20,7 +20,7 @@
#include "osdepend.h" #include "osdepend.h"
namespace ui { namespace ui {
std::vector<std::string> menu_custom_ui::hide_status = { const char *const menu_custom_ui::hide_status[] = {
__("Show All"), __("Show All"),
__("Hide Filters"), __("Hide Filters"),
__("Hide Info/Image"), __("Hide Info/Image"),
@ -30,8 +30,7 @@ std::vector<std::string> menu_custom_ui::hide_status = {
// ctor // ctor
//------------------------------------------------- //-------------------------------------------------
menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container *container) menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container *container) : menu(mui, container)
: menu(mui, container)
{ {
// load languages // load languages
file_enumerator path(mui.machine().options().language_path()); file_enumerator path(mui.machine().options().language_path());
@ -45,7 +44,7 @@ menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container *container
auto i = strreplace(name, "_", " ("); auto i = strreplace(name, "_", " (");
if (i > 0) name = name.append(")"); if (i > 0) name = name.append(")");
m_lang.push_back(name); m_lang.push_back(name);
if (name == lang) if (strcmp(name.c_str(), lang) == 0)
m_currlang = cnt; m_currlang = cnt;
++cnt; ++cnt;
} }
@ -74,10 +73,10 @@ menu_custom_ui::~menu_custom_ui()
void menu_custom_ui::handle() void menu_custom_ui::handle()
{ {
auto changed = false; bool changed = false;
// process the menu // process the menu
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
@ -99,7 +98,14 @@ void menu_custom_ui::handle()
(menu_event->iptkey == IPT_UI_RIGHT) ? ui_globals::panels_status++ : ui_globals::panels_status--; (menu_event->iptkey == IPT_UI_RIGHT) ? ui_globals::panels_status++ : ui_globals::panels_status--;
} }
else if (menu_event->iptkey == IPT_UI_SELECT) else if (menu_event->iptkey == IPT_UI_SELECT)
menu::stack_push<menu_selector>(ui(), container, hide_status, ui_globals::panels_status); {
int total = ARRAY_LENGTH(hide_status);
std::vector<std::string> s_sel(total);
for (int index = 0; index < total; ++index)
s_sel[index] = _(hide_status[index]);
menu::stack_push<menu_selector>(ui(), container, s_sel, ui_globals::panels_status);
}
break; break;
} }
case LANGUAGE_MENU: case LANGUAGE_MENU:
@ -110,7 +116,14 @@ void menu_custom_ui::handle()
(menu_event->iptkey == IPT_UI_RIGHT) ? m_currlang++ : m_currlang--; (menu_event->iptkey == IPT_UI_RIGHT) ? m_currlang++ : m_currlang--;
} }
else if (menu_event->iptkey == IPT_UI_SELECT) else if (menu_event->iptkey == IPT_UI_SELECT)
menu::stack_push<menu_selector>(ui(), container, m_lang, m_currlang); {
int total = m_lang.size();
std::vector<std::string> s_sel(total);
for (int index = 0; index < total; ++index)
s_sel[index] = m_lang[index];
menu::stack_push<menu_selector>(ui(), container, s_sel, m_currlang);
}
break; break;
} }
} }
@ -137,7 +150,7 @@ void menu_custom_ui::populate()
} }
arrow_flags = get_arrow_flags(0, (int)HIDE_BOTH, ui_globals::panels_status); arrow_flags = get_arrow_flags(0, (int)HIDE_BOTH, ui_globals::panels_status);
item_append(_("Show side panels"), _(hide_status[ui_globals::panels_status].c_str()), arrow_flags, (void *)(FPTR)HIDE_MENU); item_append(_("Show side panels"), _(hide_status[ui_globals::panels_status]), arrow_flags, (void *)(FPTR)HIDE_MENU);
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
@ -152,7 +165,7 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f
float width; float width;
ui().draw_text_full(container, _("Custom UI Settings"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, _("Custom UI Settings"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width); float maxwidth = MAX(origx2 - origx1, width);
@ -172,7 +185,7 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f
// draw the text within it // draw the text within it
ui().draw_text_full(container, _("Custom UI Settings"), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, _("Custom UI Settings"), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
} }
//------------------------------------------------- //-------------------------------------------------
@ -181,7 +194,7 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f
menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container *container) : menu(mui, container) menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container *container) : menu(mui, container)
{ {
auto moptions = mui.options(); ui_options &moptions = mui.options();
std::string name(mui.machine().options().ui_font()); std::string name(mui.machine().options().ui_font());
list(); list();
@ -191,7 +204,7 @@ menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container *container) :
#endif #endif
m_actual = 0; m_actual = 0;
for (size_t index = 0; index < m_fonts.size(); ++index) for (size_t index = 0; index < m_fonts.size(); index++)
{ {
if (m_fonts[index].first == name) if (m_fonts[index].first == name)
{ {
@ -217,6 +230,7 @@ menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container *container) :
m_font_min = atof(f_entry.minimum()); m_font_min = atof(f_entry.minimum());
} }
} }
} }
//------------------------------------------------- //-------------------------------------------------
@ -238,7 +252,7 @@ void menu_font_ui::list()
menu_font_ui::~menu_font_ui() menu_font_ui::~menu_font_ui()
{ {
std::string error_string; std::string error_string;
auto moptions = ui().options(); ui_options &moptions = ui().options();
std::string name(m_fonts[m_actual].first); std::string name(m_fonts[m_actual].first);
#ifdef UI_WINDOWS #ifdef UI_WINDOWS
@ -263,10 +277,10 @@ menu_font_ui::~menu_font_ui()
void menu_font_ui::handle() void menu_font_ui::handle()
{ {
auto changed = false; bool changed = false;
// process the menu // process the menu
auto menu_event = process(PROCESS_LR_REPEAT); const event *menu_event = process(PROCESS_LR_REPEAT);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
switch ((FPTR)menu_event->itemref) switch ((FPTR)menu_event->itemref)
@ -326,8 +340,11 @@ void menu_font_ui::handle()
void menu_font_ui::populate() void menu_font_ui::populate()
{ {
// set filter arrow
UINT32 arrow_flags;
// add fonts option // add fonts option
auto arrow_flags = get_arrow_flags(0, m_fonts.size() - 1, m_actual); arrow_flags = get_arrow_flags(0, m_fonts.size() - 1, m_actual);
item_append(_("UI Font"), m_fonts[m_actual].second, arrow_flags, (void *)(FPTR)MUI_FNT); item_append(_("UI Font"), m_fonts[m_actual].second, arrow_flags, (void *)(FPTR)MUI_FNT);
#ifdef UI_WINDOWS #ifdef UI_WINDOWS
@ -364,7 +381,7 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo
std::string topbuf(_("UI Fonts Settings")); std::string topbuf(_("UI Fonts Settings"));
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width); float maxwidth = MAX(origx2 - origx1, width);
@ -384,14 +401,14 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo
// draw the text within it // draw the text within it
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
if ((FPTR)selectedref == INFOS_SIZE) if ((FPTR)selectedref == INFOS_SIZE)
{ {
topbuf = _("Sample text - Lorem ipsum dolor sit amet, consectetur adipiscing elit."); topbuf = _("Sample text - Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr, m_info_size); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr, m_info_size);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(origx2 - origx1, width); maxwidth = MAX(origx2 - origx1, width);
@ -411,7 +428,7 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo
// draw the text within it // draw the text within it
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::LEFT, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::LEFT, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, m_info_size); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, m_info_size);
} }
} }
@ -447,7 +464,7 @@ menu_colors_ui::menu_colors_ui(mame_ui_manager &mui, render_container *container
menu_colors_ui::~menu_colors_ui() menu_colors_ui::~menu_colors_ui()
{ {
std::string error_string, dec_color; std::string error_string, dec_color;
for (int index = 1; index < MUI_RESTORE; ++index) for (int index = 1; index < MUI_RESTORE; index++)
{ {
dec_color = string_format("%x", (UINT32)m_color_table[index].color); dec_color = string_format("%x", (UINT32)m_color_table[index].color);
ui().options().set_value(m_color_table[index].option, dec_color.c_str(), OPTION_PRIORITY_CMDLINE, error_string); ui().options().set_value(m_color_table[index].option, dec_color.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
@ -460,10 +477,10 @@ menu_colors_ui::~menu_colors_ui()
void menu_colors_ui::handle() void menu_colors_ui::handle()
{ {
auto changed = false; bool changed = false;
// process the menu // process the menu
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT)
{ {
@ -522,7 +539,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
std::string topbuf(_("UI Colors Settings")); std::string topbuf(_("UI Colors Settings"));
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width); maxwidth = MAX(maxwidth, width);
@ -542,7 +559,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
// draw the text within it // draw the text within it
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
// bottom text // bottom text
// get the text for 'UI Select' // get the text for 'UI Select'
@ -550,7 +567,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
topbuf = string_format(_("Double click or press %1$s to change the color value"), ui_select_text); topbuf = string_format(_("Double click or press %1$s to change the color value"), ui_select_text);
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width); maxwidth = MAX(maxwidth, width);
@ -570,13 +587,13 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
// draw the text within it // draw the text within it
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
// compute maxwidth // compute maxwidth
topbuf = _("Menu Preview"); topbuf = _("Menu Preview");
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
maxwidth = width + 2.0f * UI_BOX_LR_BORDER; maxwidth = width + 2.0f * UI_BOX_LR_BORDER;
std::string sampletxt[5]; std::string sampletxt[5];
@ -590,7 +607,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
for (auto & elem: sampletxt) for (auto & elem: sampletxt)
{ {
ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width); maxwidth = MAX(maxwidth, width);
} }
@ -612,7 +629,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
// draw the text within it // draw the text within it
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
// compute our bounds for menu preview // compute our bounds for menu preview
x1 -= UI_BOX_LR_BORDER; x1 -= UI_BOX_LR_BORDER;
@ -630,29 +647,29 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
// draw normal text // draw normal text
ui().draw_text_full(container, sampletxt[0].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, sampletxt[0].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_TEXT_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr); mame_ui_manager::NORMAL, m_color_table[MUI_TEXT_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr);
y1 += line_height; y1 += line_height;
// draw subitem text // draw subitem text
ui().draw_text_full(container, sampletxt[1].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, sampletxt[1].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_SUBITEM_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr); mame_ui_manager::NORMAL, m_color_table[MUI_SUBITEM_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr);
y1 += line_height; y1 += line_height;
// draw selected text // draw selected text
highlight(container, x1, y1, x2, y1 + line_height, m_color_table[MUI_SELECTED_BG_COLOR].color); highlight(container, x1, y1, x2, y1 + line_height, m_color_table[MUI_SELECTED_BG_COLOR].color);
ui().draw_text_full(container, sampletxt[2].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, sampletxt[2].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_SELECTED_COLOR].color, m_color_table[MUI_SELECTED_BG_COLOR].color, nullptr, nullptr); mame_ui_manager::NORMAL, m_color_table[MUI_SELECTED_COLOR].color, m_color_table[MUI_SELECTED_BG_COLOR].color, nullptr, nullptr);
y1 += line_height; y1 += line_height;
// draw mouse over text // draw mouse over text
highlight(container, x1, y1, x2, y1 + line_height, m_color_table[MUI_MOUSEOVER_BG_COLOR].color); highlight(container, x1, y1, x2, y1 + line_height, m_color_table[MUI_MOUSEOVER_BG_COLOR].color);
ui().draw_text_full(container, sampletxt[3].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, sampletxt[3].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_MOUSEOVER_COLOR].color, m_color_table[MUI_MOUSEOVER_BG_COLOR].color, nullptr, nullptr); mame_ui_manager::NORMAL, m_color_table[MUI_MOUSEOVER_COLOR].color, m_color_table[MUI_MOUSEOVER_BG_COLOR].color, nullptr, nullptr);
y1 += line_height; y1 += line_height;
// draw clone text // draw clone text
ui().draw_text_full(container, sampletxt[4].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, sampletxt[4].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, m_color_table[MUI_CLONE_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr); mame_ui_manager::NORMAL, m_color_table[MUI_CLONE_COLOR].color, m_color_table[MUI_TEXT_BG_COLOR].color, nullptr, nullptr);
} }
@ -663,7 +680,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
void menu_colors_ui::restore_colors() void menu_colors_ui::restore_colors()
{ {
ui_options options; ui_options options;
for (int index = 1; index < MUI_RESTORE; ++index) for (int index = 1; index < MUI_RESTORE; index++)
m_color_table[index].color = rgb_t((UINT32)strtoul(options.value(m_color_table[index].option), nullptr, 16)); m_color_table[index].color = rgb_t((UINT32)strtoul(options.value(m_color_table[index].option), nullptr, 16));
} }
@ -671,9 +688,12 @@ void menu_colors_ui::restore_colors()
// ctor // ctor
//------------------------------------------------- //-------------------------------------------------
menu_rgb_ui::menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title) menu_rgb_ui::menu_rgb_ui(mame_ui_manager &mui, render_container *container, rgb_t *_color, std::string _title) : menu(mui, container)
: menu(mui, container), m_color(_color), m_key_active(false), m_lock_ref(0), m_title(_title)
{ {
m_color = _color;
m_key_active = false;
m_lock_ref = 0;
m_title = _title;
m_search[0] = '\0'; m_search[0] = '\0';
} }
@ -691,7 +711,7 @@ menu_rgb_ui::~menu_rgb_ui()
void menu_rgb_ui::handle() void menu_rgb_ui::handle()
{ {
auto changed = false; bool changed = false;
// process the menu // process the menu
const event *menu_event; const event *menu_event;
@ -860,7 +880,7 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
// top text // top text
std::string topbuf = std::string(m_title).append(_(" - ARGB Settings")); std::string topbuf = std::string(m_title).append(_(" - ARGB Settings"));
ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width); maxwidth = MAX(maxwidth, width);
@ -880,12 +900,12 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
// draw the text within it // draw the text within it
ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, topbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
std::string sampletxt(_("Color preview =")); std::string sampletxt(_("Color preview ="));
maxwidth = origx2 - origx1; maxwidth = origx2 - origx1;
ui().draw_text_full(container, sampletxt.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, sampletxt.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width); maxwidth = MAX(maxwidth, width);
@ -905,7 +925,7 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
// draw the normal text // draw the normal text
ui().draw_text_full(container, sampletxt.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, sampletxt.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, rgb_t::white, rgb_t::black, nullptr, nullptr); mame_ui_manager::NORMAL, rgb_t::white, rgb_t::black, nullptr, nullptr);
float t_x2 = x1 - UI_BOX_LR_BORDER + maxwidth; float t_x2 = x1 - UI_BOX_LR_BORDER + maxwidth;
x1 = x2 + 2.0f * UI_BOX_LR_BORDER; x1 = x2 + 2.0f * UI_BOX_LR_BORDER;
@ -929,15 +949,26 @@ void menu_rgb_ui::inkey_special(const event *menu_event)
if (!m_key_active) if (!m_key_active)
{ {
auto val = atoi(m_search); int val = atoi(m_search);
val = m_color->clamp(val); val = m_color->clamp(val);
switch ((FPTR)menu_event->itemref) switch ((FPTR)menu_event->itemref)
{ {
case RGB_ALPHA: m_color->set_a(val); break; case RGB_ALPHA:
case RGB_RED: m_color->set_r(val); break; m_color->set_a(val);
case RGB_GREEN: m_color->set_g(val); break; break;
case RGB_BLUE: m_color->set_b(val); break;
case RGB_RED:
m_color->set_r(val);
break;
case RGB_GREEN:
m_color->set_g(val);
break;
case RGB_BLUE:
m_color->set_b(val);
break;
} }
m_search[0] = 0; m_search[0] = 0;
@ -1007,7 +1038,7 @@ menu_palette_sel::~menu_palette_sel()
void menu_palette_sel::handle() void menu_palette_sel::handle()
{ {
// process the menu // process the menu
auto menu_event = process(FLAG_UI_PALETTE); const event *menu_event = process(FLAG_UI_PALETTE);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
if (menu_event->iptkey == IPT_UI_SELECT) if (menu_event->iptkey == IPT_UI_SELECT)
@ -1025,9 +1056,8 @@ void menu_palette_sel::handle()
void menu_palette_sel::populate() void menu_palette_sel::populate()
{ {
int x = 0; for (int x = 0; x < m_palette.size(); ++x)
for (auto & e : m_palette) item_append(_(m_palette[x].first), m_palette[x].second, FLAG_UI_PALETTE, (void *)(FPTR)(x + 1));
item_append(_(e.first), e.second, FLAG_UI_PALETTE, (void *)(FPTR)(++x));
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
} }

View File

@ -37,7 +37,7 @@ private:
COLORS_MENU, COLORS_MENU,
HIDE_MENU HIDE_MENU
}; };
static std::vector<std::string> hide_status; static const char *const hide_status[];
std::vector<std::string> m_lang; std::vector<std::string> m_lang;
std::uint16_t m_currlang; std::uint16_t m_currlang;
}; };

View File

@ -81,7 +81,7 @@ menu_dats_view::~menu_dats_view()
void menu_dats_view::handle() void menu_dats_view::handle()
{ {
auto menu_event = process(FLAG_UI_DATS); const event *menu_event = process(FLAG_UI_DATS);
if (menu_event != nullptr) if (menu_event != nullptr)
{ {
if (menu_event->iptkey == IPT_UI_LEFT && m_actual > 0) if (menu_event->iptkey == IPT_UI_LEFT && m_actual > 0)

View File

@ -271,7 +271,7 @@ void menu_device_config::populate()
void menu_device_config::handle() void menu_device_config::handle()
{ {
// process the menu /* process the menu */
process(0); process(0);
} }

View File

@ -71,8 +71,7 @@ static const folders_entry s_folders[] =
// ctor / dtor // ctor / dtor
//------------------------------------------------- //-------------------------------------------------
menu_directory::menu_directory(mame_ui_manager &mui, render_container *container) menu_directory::menu_directory(mame_ui_manager &mui, render_container *container) : menu(mui, container)
: menu(mui, container)
{ {
} }
@ -90,7 +89,7 @@ menu_directory::~menu_directory()
void menu_directory::handle() void menu_directory::handle()
{ {
// process the menu // process the menu
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT)
menu::stack_push<menu_display_actual>(ui(), container, selected); menu::stack_push<menu_display_actual>(ui(), container, selected);
@ -165,7 +164,7 @@ menu_display_actual::~menu_display_actual()
void menu_display_actual::handle() void menu_display_actual::handle()
{ {
// process the menu // process the menu
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT)
switch ((FPTR)menu_event->itemref) switch ((FPTR)menu_event->itemref)
{ {
@ -217,15 +216,13 @@ void menu_display_actual::custom_render(void *selectedref, float top, float bott
for (auto & elem : m_folders) for (auto & elem : m_folders)
{ {
ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::TRUNCATE, ui().draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f; width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
maxwidth = MAX(maxwidth, width); maxwidth = MAX(maxwidth, width);
} }
// get the size of the text // get the size of the text
ui().draw_text_full(container, m_tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, m_tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f; width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
maxwidth = MAX(width, maxwidth); maxwidth = MAX(width, maxwidth);
@ -278,9 +275,9 @@ MENU ADD FOLDER
// ctor / dtor // ctor / dtor
//------------------------------------------------- //-------------------------------------------------
menu_add_change_folder::menu_add_change_folder(mame_ui_manager &mui, render_container *container, int ref) menu_add_change_folder::menu_add_change_folder(mame_ui_manager &mui, render_container *container, int ref) : menu(mui, container)
: menu(mui, container), m_ref(ref)
{ {
m_ref = ref;
m_change = (s_folders[ref].action == CHANGE); m_change = (s_folders[ref].action == CHANGE);
m_search[0] = '\0'; m_search[0] = '\0';
@ -310,7 +307,7 @@ menu_add_change_folder::~menu_add_change_folder()
void menu_add_change_folder::handle() void menu_add_change_folder::handle()
{ {
// process the menu // process the menu
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
@ -571,9 +568,9 @@ void menu_add_change_folder::custom_render(void *selectedref, float top, float b
// ctor / dtor // ctor / dtor
//------------------------------------------------- //-------------------------------------------------
menu_remove_folder::menu_remove_folder(mame_ui_manager &mui, render_container *container, int ref) menu_remove_folder::menu_remove_folder(mame_ui_manager &mui, render_container *container, int ref) : menu(mui, container)
: menu(mui, container), m_ref(ref)
{ {
m_ref = ref;
if (mui.options().exists(s_folders[m_ref].option)) if (mui.options().exists(s_folders[m_ref].option))
m_searchpath.assign(mui.options().value(s_folders[m_ref].option)); m_searchpath.assign(mui.options().value(s_folders[m_ref].option));
else else
@ -596,7 +593,7 @@ menu_remove_folder::~menu_remove_folder()
void menu_remove_folder::handle() void menu_remove_folder::handle()
{ {
// process the menu // process the menu
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT)
{ {
std::string tmppath, error_string; std::string tmppath, error_string;
@ -645,8 +642,7 @@ void menu_remove_folder::custom_render(void *selectedref, float top, float botto
std::string tempbuf = string_format(_("Remove %1$s Folder"), _(s_folders[m_ref].name)); std::string tempbuf = string_format(_("Remove %1$s Folder"), _(s_folders[m_ref].name));
// get the size of the text // get the size of the text
ui().draw_text_full(container, tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f; width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
float maxwidth = MAX(width, origx2 - origx1); float maxwidth = MAX(width, origx2 - origx1);
@ -665,8 +661,8 @@ void menu_remove_folder::custom_render(void *selectedref, float top, float botto
y1 += UI_BOX_TB_BORDER; y1 += UI_BOX_TB_BORDER;
// draw the text within it // draw the text within it
ui().draw_text_full(container, tempbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, tempbuf.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NORMAL,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
} }
} // namespace ui } // namespace ui

View File

@ -56,7 +56,7 @@ menu_control_device_image::menu_control_device_image(mame_ui_manager &mui, rende
{ {
state = START_FILE; state = START_FILE;
// if the image exists, set the working directory to the parent directory /* if the image exists, set the working directory to the parent directory */
if (image->exists()) if (image->exists())
{ {
current_file.assign(image->filename()); current_file.assign(image->filename());
@ -64,7 +64,7 @@ menu_control_device_image::menu_control_device_image(mame_ui_manager &mui, rende
} else } else
current_directory.assign(image->working_directory()); current_directory.assign(image->working_directory());
// check to see if the path exists; if not clear it /* check to see if the path exists; if not clear it */
if (util::zippath_opendir(current_directory.c_str(), nullptr) != osd_file::error::NONE) if (util::zippath_opendir(current_directory.c_str(), nullptr) != osd_file::error::NONE)
current_directory.clear(); current_directory.clear();
} }
@ -89,29 +89,29 @@ void menu_control_device_image::test_create(bool &can_create, bool &need_confirm
std::string path; std::string path;
osd::directory::entry::entry_type file_type; osd::directory::entry::entry_type file_type;
// assemble the full path /* assemble the full path */
util::zippath_combine(path, current_directory.c_str(), current_file.c_str()); util::zippath_combine(path, current_directory.c_str(), current_file.c_str());
// does a file or a directory exist at the path /* does a file or a directory exist at the path */
auto entry = osd_stat(path.c_str()); auto entry = osd_stat(path.c_str());
file_type = (entry != nullptr) ? entry->type : osd::directory::entry::entry_type::NONE; file_type = (entry != nullptr) ? entry->type : osd::directory::entry::entry_type::NONE;
switch(file_type) switch(file_type)
{ {
case osd::directory::entry::entry_type::NONE: case osd::directory::entry::entry_type::NONE:
// no file/dir here - always create /* no file/dir here - always create */
can_create = true; can_create = true;
need_confirm = false; need_confirm = false;
break; break;
case osd::directory::entry::entry_type::FILE: case osd::directory::entry::entry_type::FILE:
// a file exists here - ask for permission from the user /* a file exists here - ask for permission from the user */
can_create = true; can_create = true;
need_confirm = true; need_confirm = true;
break; break;
case osd::directory::entry::entry_type::DIR: case osd::directory::entry::entry_type::DIR:
// a directory exists here - we can't save over it /* a directory exists here - we can't save over it */
ui().popup_time(5, "%s", _("Cannot save over directory")); ui().popup_time(5, "%s", _("Cannot save over directory"));
can_create = false; can_create = false;
need_confirm = false; need_confirm = false;

View File

@ -25,12 +25,12 @@ namespace ui {
#define MAX_INPUT_PORTS 32 #define MAX_INPUT_PORTS 32
#define MAX_BITS_PER_PORT 32 #define MAX_BITS_PER_PORT 32
// DIP switch rendering parameters /* DIP switch rendering parameters */
#define DIP_SWITCH_HEIGHT 0.05f #define DIP_SWITCH_HEIGHT 0.05f
#define DIP_SWITCH_SPACING 0.01f #define DIP_SWITCH_SPACING 0.01f
#define SINGLE_TOGGLE_SWITCH_FIELD_WIDTH 0.025f #define SINGLE_TOGGLE_SWITCH_FIELD_WIDTH 0.025f
#define SINGLE_TOGGLE_SWITCH_WIDTH 0.020f #define SINGLE_TOGGLE_SWITCH_WIDTH 0.020f
// make the switch 80% of the width space and 1/2 of the switch height /* make the switch 80% of the width space and 1/2 of the switch height */
#define PERCENTAGE_OF_HALF_FIELD_USED 0.80f #define PERCENTAGE_OF_HALF_FIELD_USED 0.80f
#define SINGLE_TOGGLE_SWITCH_HEIGHT ((DIP_SWITCH_HEIGHT / 2) * PERCENTAGE_OF_HALF_FIELD_USED) #define SINGLE_TOGGLE_SWITCH_HEIGHT ((DIP_SWITCH_HEIGHT / 2) * PERCENTAGE_OF_HALF_FIELD_USED)
@ -49,7 +49,7 @@ void menu_input_groups::populate()
{ {
int player; int player;
// build up the menu /* build up the menu */
item_append(_("User Interface"), "", 0, (void *)(IPG_UI + 1)); item_append(_("User Interface"), "", 0, (void *)(IPG_UI + 1));
for (player = 0; player < MAX_PLAYERS; player++) for (player = 0; player < MAX_PLAYERS; player++)
{ {
@ -70,7 +70,7 @@ menu_input_groups::~menu_input_groups()
void menu_input_groups::handle() void menu_input_groups::handle()
{ {
// process the menu /* process the menu */
const event *menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT)
menu::stack_push<menu_input_general>(ui(), container, int((long long)(menu_event->itemref)-1)); menu::stack_push<menu_input_general>(ui(), container, int((long long)(menu_event->itemref)-1));
@ -94,24 +94,24 @@ void menu_input_general::populate()
int suborder[SEQ_TYPE_TOTAL]; int suborder[SEQ_TYPE_TOTAL];
int sortorder = 1; int sortorder = 1;
// create a mini lookup table for sort order based on sequence type /* create a mini lookup table for sort order based on sequence type */
suborder[SEQ_TYPE_STANDARD] = 0; suborder[SEQ_TYPE_STANDARD] = 0;
suborder[SEQ_TYPE_DECREMENT] = 1; suborder[SEQ_TYPE_DECREMENT] = 1;
suborder[SEQ_TYPE_INCREMENT] = 2; suborder[SEQ_TYPE_INCREMENT] = 2;
// iterate over the input ports and add menu items /* iterate over the input ports and add menu items */
for (input_type_entry &entry : machine().ioport().types()) for (input_type_entry &entry : machine().ioport().types())
// add if we match the group and we have a valid name /* add if we match the group and we have a valid name */
if (entry.group() == group && entry.name() != nullptr && entry.name()[0] != 0) if (entry.group() == group && entry.name() != nullptr && entry.name()[0] != 0)
{ {
input_seq_type seqtype; input_seq_type seqtype;
// loop over all sequence types /* loop over all sequence types */
sortorder++; sortorder++;
for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype) for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype)
{ {
// build an entry for the standard sequence /* build an entry for the standard sequence */
input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item));
memset(item, 0, sizeof(*item)); memset(item, 0, sizeof(*item));
item->ref = &entry; item->ref = &entry;
@ -127,13 +127,13 @@ void menu_input_general::populate()
item->next = itemlist; item->next = itemlist;
itemlist = item; itemlist = item;
// stop after one, unless we're analog /* stop after one, unless we're analog */
if (item->type == INPUT_TYPE_DIGITAL) if (item->type == INPUT_TYPE_DIGITAL)
break; break;
} }
} }
// sort and populate the menu in a standard fashion /* sort and populate the menu in a standard fashion */
populate_and_sort(itemlist); populate_and_sort(itemlist);
} }
@ -156,12 +156,12 @@ void menu_input_specific::populate()
int suborder[SEQ_TYPE_TOTAL]; int suborder[SEQ_TYPE_TOTAL];
int port_count = 0; int port_count = 0;
// create a mini lookup table for sort order based on sequence type /* create a mini lookup table for sort order based on sequence type */
suborder[SEQ_TYPE_STANDARD] = 0; suborder[SEQ_TYPE_STANDARD] = 0;
suborder[SEQ_TYPE_DECREMENT] = 1; suborder[SEQ_TYPE_DECREMENT] = 1;
suborder[SEQ_TYPE_INCREMENT] = 2; suborder[SEQ_TYPE_INCREMENT] = 2;
// iterate over the input ports and add menu items /* iterate over the input ports and add menu items */
for (auto &port : machine().ioport().ports()) for (auto &port : machine().ioport().ports())
{ {
port_count++; port_count++;
@ -169,13 +169,13 @@ void menu_input_specific::populate()
{ {
ioport_type_class type_class = field.type_class(); ioport_type_class type_class = field.type_class();
// add if we match the group and we have a valid name /* add if we match the group and we have a valid name */
if (field.enabled() && (type_class == INPUT_CLASS_CONTROLLER || type_class == INPUT_CLASS_MISC || type_class == INPUT_CLASS_KEYBOARD)) if (field.enabled() && (type_class == INPUT_CLASS_CONTROLLER || type_class == INPUT_CLASS_MISC || type_class == INPUT_CLASS_KEYBOARD))
{ {
input_seq_type seqtype; input_seq_type seqtype;
UINT32 sortorder; UINT32 sortorder;
// determine the sorting order /* determine the sorting order */
if (type_class == INPUT_CLASS_CONTROLLER) if (type_class == INPUT_CLASS_CONTROLLER)
{ {
sortorder = (field.type() << 2) | (field.player() << 12); sortorder = (field.type() << 2) | (field.player() << 12);
@ -185,10 +185,10 @@ void menu_input_specific::populate()
else else
sortorder = field.type() | 0xf000; sortorder = field.type() | 0xf000;
// loop over all sequence types /* loop over all sequence types */
for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype) for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype)
{ {
// build an entry for the standard sequence /* build an entry for the standard sequence */
input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item));
memset(item, 0, sizeof(*item)); memset(item, 0, sizeof(*item));
item->ref = &field; item->ref = &field;
@ -204,7 +204,7 @@ void menu_input_specific::populate()
item->next = itemlist; item->next = itemlist;
itemlist = item; itemlist = item;
// stop after one, unless we're analog /* stop after one, unless we're analog */
if (item->type == INPUT_TYPE_DIGITAL) if (item->type == INPUT_TYPE_DIGITAL)
break; break;
} }
@ -212,7 +212,7 @@ void menu_input_specific::populate()
} }
} }
// sort and populate the menu in a standard fashion /* sort and populate the menu in a standard fashion */
populate_and_sort(itemlist); populate_and_sort(itemlist);
} }
@ -241,11 +241,11 @@ menu_input::~menu_input()
void menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq) void menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq)
{ {
// if we used to be "none", toggle to the default value /* if we used to be "none", toggle to the default value */
if (original_seq.length() == 0) if (original_seq.length() == 0)
selected_seq = selected_defseq; selected_seq = selected_defseq;
// otherwise, toggle to "none" /* otherwise, toggle to "none" */
else else
selected_seq.reset(); selected_seq.reset();
} }
@ -253,74 +253,75 @@ void menu_input::toggle_none_default(input_seq &selected_seq, input_seq &origina
void menu_input::handle() void menu_input::handle()
{ {
input_item_data *seqchangeditem = nullptr; input_item_data *seqchangeditem = nullptr;
auto invalidate = false; const event *menu_event;
int invalidate = false;
// process the menu /* process the menu */
auto menu_event = process((pollingitem != nullptr) ? PROCESS_NOKEYS : 0); menu_event = process((pollingitem != nullptr) ? PROCESS_NOKEYS : 0);
// if we are polling, handle as a special case /* if we are polling, handle as a special case */
if (pollingitem != nullptr) if (pollingitem != nullptr)
{ {
auto pitem = pollingitem; input_item_data *item = pollingitem;
// if UI_CANCEL is pressed, abort /* if UI_CANCEL is pressed, abort */
if (machine().ui_input().pressed(IPT_UI_CANCEL)) if (machine().ui_input().pressed(IPT_UI_CANCEL))
{ {
pollingitem = nullptr; pollingitem = nullptr;
record_next = false; record_next = false;
toggle_none_default(pitem->seq, starting_seq, *pitem->defseq); toggle_none_default(item->seq, starting_seq, *item->defseq);
seqchangeditem = pitem; seqchangeditem = item;
} }
// poll again; if finished, update the sequence /* poll again; if finished, update the sequence */
if (machine().input().seq_poll()) if (machine().input().seq_poll())
{ {
pollingitem = nullptr; pollingitem = nullptr;
record_next = true; record_next = true;
pitem->seq = machine().input().seq_poll_final(); item->seq = machine().input().seq_poll_final();
seqchangeditem = pitem; seqchangeditem = item;
} }
} }
// otherwise, handle the events /* otherwise, handle the events */
else if (menu_event != nullptr && menu_event->itemref != nullptr) else if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
auto pitem = (input_item_data *)menu_event->itemref; input_item_data *item = (input_item_data *)menu_event->itemref;
switch (menu_event->iptkey) switch (menu_event->iptkey)
{ {
// an item was selected: begin polling /* an item was selected: begin polling */
case IPT_UI_SELECT: case IPT_UI_SELECT:
pollingitem = pitem; pollingitem = item;
last_sortorder = pitem->sortorder; last_sortorder = item->sortorder;
starting_seq = pitem->seq; starting_seq = item->seq;
machine().input().seq_poll_start((pitem->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &pitem->seq : nullptr); machine().input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &item->seq : nullptr);
invalidate = true; invalidate = true;
break; break;
// if the clear key was pressed, reset the selected item /* if the clear key was pressed, reset the selected item */
case IPT_UI_CLEAR: case IPT_UI_CLEAR:
toggle_none_default(pitem->seq, pitem->seq, *pitem->defseq); toggle_none_default(item->seq, item->seq, *item->defseq);
record_next = false; record_next = false;
seqchangeditem = pitem; seqchangeditem = item;
break; break;
} }
// if the selection changed, reset the "record next" flag /* if the selection changed, reset the "record next" flag */
if (pitem->sortorder != last_sortorder) if (item->sortorder != last_sortorder)
record_next = false; record_next = false;
last_sortorder = pitem->sortorder; last_sortorder = item->sortorder;
} }
// if the sequence changed, update it /* if the sequence changed, update it */
if (seqchangeditem != nullptr) if (seqchangeditem != nullptr)
{ {
update_input(seqchangeditem); update_input(seqchangeditem);
// invalidate the menu to force an update /* invalidate the menu to force an update */
invalidate = true; invalidate = true;
} }
// if the menu is invalidated, clear it now /* if the menu is invalidated, clear it now */
if (invalidate) if (invalidate)
{ {
pollingref = nullptr; pollingref = nullptr;
@ -335,7 +336,7 @@ void menu_input::handle()
void menu_input_general::update_input(struct input_item_data *seqchangeditem) void menu_input_general::update_input(struct input_item_data *seqchangeditem)
{ {
auto entry = (const input_type_entry *)seqchangeditem->ref; const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref;
machine().ioport().set_type_seq(entry->type(), entry->player(), seqchangeditem->seqtype, seqchangeditem->seq); machine().ioport().set_type_seq(entry->type(), entry->player(), seqchangeditem->seqtype, seqchangeditem->seq);
} }
@ -356,8 +357,8 @@ void menu_input_specific::update_input(struct input_item_data *seqchangeditem)
int menu_input::compare_items(const void *i1, const void *i2) int menu_input::compare_items(const void *i1, const void *i2)
{ {
auto data1 = (const input_item_data * const *)i1; const input_item_data * const *data1 = (const input_item_data * const *)i1;
auto data2 = (const input_item_data * const *)i2; const input_item_data * const *data2 = (const input_item_data * const *)i2;
if ((*data1)->sortorder < (*data2)->sortorder) if ((*data1)->sortorder < (*data2)->sortorder)
return -1; return -1;
if ((*data1)->sortorder > (*data2)->sortorder) if ((*data1)->sortorder > (*data2)->sortorder)
@ -381,30 +382,30 @@ void menu_input::populate_and_sort(input_item_data *itemlist)
std::string prev_owner; std::string prev_owner;
bool first_entry = true; bool first_entry = true;
// create a mini lookup table for name format based on type /* create a mini lookup table for name format based on type */
nameformat[INPUT_TYPE_DIGITAL] = "%s"; nameformat[INPUT_TYPE_DIGITAL] = "%s";
nameformat[INPUT_TYPE_ANALOG] = "%s Analog"; nameformat[INPUT_TYPE_ANALOG] = "%s Analog";
nameformat[INPUT_TYPE_ANALOG_INC] = "%s Analog Inc"; nameformat[INPUT_TYPE_ANALOG_INC] = "%s Analog Inc";
nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec"; nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec";
// first count the number of items /* first count the number of items */
for (item = itemlist; item != nullptr; item = item->next) for (item = itemlist; item != nullptr; item = item->next)
numitems++; numitems++;
// now allocate an array of items and fill it up /* now allocate an array of items and fill it up */
itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems); itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems);
for (item = itemlist, curitem = 0; item != nullptr; item = item->next) for (item = itemlist, curitem = 0; item != nullptr; item = item->next)
itemarray[curitem++] = item; itemarray[curitem++] = item;
// sort it /* sort it */
qsort(itemarray, numitems, sizeof(*itemarray), compare_items); qsort(itemarray, numitems, sizeof(*itemarray), compare_items);
// build the menu /* build the menu */
for (curitem = 0; curitem < numitems; curitem++) for (curitem = 0; curitem < numitems; curitem++)
{ {
UINT32 flags = 0; UINT32 flags = 0;
// generate the name of the item itself, based off the base name and the type /* generate the name of the item itself, based off the base name and the type */
item = itemarray[curitem]; item = itemarray[curitem];
assert(nameformat[item->type] != nullptr); assert(nameformat[item->type] != nullptr);
@ -420,21 +421,21 @@ void menu_input::populate_and_sort(input_item_data *itemlist)
std::string text = string_format(nameformat[item->type], item->name); std::string text = string_format(nameformat[item->type], item->name);
// if we're polling this item, use some spaces with left/right arrows /* if we're polling this item, use some spaces with left/right arrows */
if (pollingref == item->ref) if (pollingref == item->ref)
{ {
subtext.assign(" "); subtext.assign(" ");
flags |= FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; flags |= FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW;
} }
// otherwise, generate the sequence name and invert it if different from the default /* otherwise, generate the sequence name and invert it if different from the default */
else else
{ {
subtext = machine().input().seq_name(item->seq); subtext = machine().input().seq_name(item->seq);
flags |= (item->seq != *item->defseq) ? FLAG_INVERT : 0; flags |= (item->seq != *item->defseq) ? FLAG_INVERT : 0;
} }
// add the item /* add the item */
item_append(text, subtext, flags, item); item_append(text, subtext, flags, item);
} }
} }
@ -494,7 +495,7 @@ void menu_settings::handle()
switch (menu_event->iptkey) switch (menu_event->iptkey)
{ {
// if selected, reset to default value /* if selected, reset to default value */
case IPT_UI_SELECT: case IPT_UI_SELECT:
field->get_user_settings(settings); field->get_user_settings(settings);
settings.value = field->defvalue(); settings.value = field->defvalue();
@ -502,20 +503,20 @@ void menu_settings::handle()
changed = true; changed = true;
break; break;
// left goes to previous setting /* left goes to previous setting */
case IPT_UI_LEFT: case IPT_UI_LEFT:
field->select_previous_setting(); field->select_previous_setting();
changed = true; changed = true;
break; break;
// right goes to next setting /* right goes to next setting */
case IPT_UI_RIGHT: case IPT_UI_RIGHT:
field->select_next_setting(); field->select_next_setting();
changed = true; changed = true;
break; break;
} }
// if anything changed, rebuild the menu, trying to stay on the same field /* if anything changed, rebuild the menu, trying to stay on the same field */
if (changed) if (changed)
reset(reset_options::REMEMBER_REF); reset(reset_options::REMEMBER_REF);
} }
@ -539,25 +540,25 @@ void menu_settings::populate()
std::string prev_owner; std::string prev_owner;
bool first_entry = true; bool first_entry = true;
// reset the dip switch tracking /* reset the dip switch tracking */
dipcount = 0; dipcount = 0;
diplist = nullptr; diplist = nullptr;
diplist_tailptr = &diplist; diplist_tailptr = &diplist;
// loop over input ports and set up the current values /* loop over input ports and set up the current values */
for (auto &port : machine().ioport().ports()) for (auto &port : machine().ioport().ports())
for (ioport_field &field : port.second->fields()) for (ioport_field &field : port.second->fields())
if (field.type() == type && field.enabled()) if (field.type() == type && field.enabled())
{ {
UINT32 flags = 0; UINT32 flags = 0;
// set the left/right flags appropriately /* set the left/right flags appropriately */
if (field.has_previous_setting()) if (field.has_previous_setting())
flags |= FLAG_LEFT_ARROW; flags |= FLAG_LEFT_ARROW;
if (field.has_next_setting()) if (field.has_next_setting())
flags |= FLAG_RIGHT_ARROW; flags |= FLAG_RIGHT_ARROW;
// add the menu item /* add the menu item */
if (strcmp(field.device().tag(), prev_owner.c_str()) != 0) if (strcmp(field.device().tag(), prev_owner.c_str()) != 0)
{ {
if (first_entry) if (first_entry)
@ -571,27 +572,27 @@ void menu_settings::populate()
item_append(field.name(), field.setting_name(), flags, (void *)&field); item_append(field.name(), field.setting_name(), flags, (void *)&field);
// for DIP switches, build up the model /* for DIP switches, build up the model */
if (type == IPT_DIPSWITCH && !field.diplocations().empty()) if (type == IPT_DIPSWITCH && !field.diplocations().empty())
{ {
ioport_field::user_settings settings; ioport_field::user_settings settings;
auto accummask = field.mask(); UINT32 accummask = field.mask();
// get current settings /* get current settings */
field.get_user_settings(settings); field.get_user_settings(settings);
// iterate over each bit in the field /* iterate over each bit in the field */
for (const ioport_diplocation &diploc : field.diplocations()) for (const ioport_diplocation &diploc : field.diplocations())
{ {
UINT32 mask = accummask & ~(accummask - 1); UINT32 mask = accummask & ~(accummask - 1);
dip_descriptor *dip; dip_descriptor *dip;
// find the matching switch name /* find the matching switch name */
for (dip = diplist; dip != nullptr; dip = dip->next) for (dip = diplist; dip != nullptr; dip = dip->next)
if (strcmp(dip->name, diploc.name()) == 0) if (strcmp(dip->name, diploc.name()) == 0)
break; break;
// allocate new if none /* allocate new if none */
if (dip == nullptr) if (dip == nullptr)
{ {
dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip)); dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip));
@ -603,12 +604,12 @@ void menu_settings::populate()
dipcount++; dipcount++;
} }
// apply the bits /* apply the bits */
dip->mask |= 1 << (diploc.number() - 1); dip->mask |= 1 << (diploc.number() - 1);
if (((settings.value & mask) != 0 && !diploc.inverted()) || ((settings.value & mask) == 0 && diploc.inverted())) if (((settings.value & mask) != 0 && !diploc.inverted()) || ((settings.value & mask) == 0 && diploc.inverted()))
dip->state |= 1 << (diploc.number() - 1); dip->state |= 1 << (diploc.number() - 1);
// clear the relevant bit in the accumulated mask /* clear the relevant bit in the accumulated mask */
accummask &= ~mask; accummask &= ~mask;
} }
} }
@ -651,7 +652,7 @@ void menu_settings_dip_switches::custom_render(void *selectedref, float top, flo
// determine the mask of selected bits // determine the mask of selected bits
if ((FPTR)selectedref != 1) if ((FPTR)selectedref != 1)
{ {
auto field = (ioport_field *)selectedref; ioport_field *field = (ioport_field *)selectedref;
if (field != nullptr && !field->diplocations().empty()) if (field != nullptr && !field->diplocations().empty())
for (const ioport_diplocation &diploc : field->diplocations()) for (const ioport_diplocation &diploc : field->diplocations())
@ -679,13 +680,13 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2,
float switch_toggle_gap; float switch_toggle_gap;
float y1_off, y1_on; float y1_off, y1_on;
// determine the number of toggles in the DIP /* determine the number of toggles in the DIP */
numtoggles = 32 - count_leading_zeros(dip->mask); numtoggles = 32 - count_leading_zeros(dip->mask);
// center based on the number of switches /* center based on the number of switches */
x1 += (x2 - x1 - numtoggles * switch_field_width) / 2; x1 += (x2 - x1 - numtoggles * switch_field_width) / 2;
// draw the dip switch name /* draw the dip switch name */
ui().draw_text_full( container, ui().draw_text_full( container,
dip->name, dip->name,
0, 0,
@ -699,23 +700,23 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2,
nullptr , nullptr ,
nullptr); nullptr);
// compute top and bottom for on and off positions /* compute top and bottom for on and off positions */
switch_toggle_gap = ((DIP_SWITCH_HEIGHT/2) - SINGLE_TOGGLE_SWITCH_HEIGHT)/2; switch_toggle_gap = ((DIP_SWITCH_HEIGHT/2) - SINGLE_TOGGLE_SWITCH_HEIGHT)/2;
y1_off = y1 + UI_LINE_WIDTH + switch_toggle_gap; y1_off = y1 + UI_LINE_WIDTH + switch_toggle_gap;
y1_on = y1 + DIP_SWITCH_HEIGHT/2 + switch_toggle_gap; y1_on = y1 + DIP_SWITCH_HEIGHT/2 + switch_toggle_gap;
// iterate over toggles /* iterate over toggles */
for (toggle = 0; toggle < numtoggles; toggle++) for (toggle = 0; toggle < numtoggles; toggle++)
{ {
float innerx1; float innerx1;
// first outline the switch /* first outline the switch */
ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR); ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR);
// compute x1/x2 for the inner filled in switch /* compute x1/x2 for the inner filled in switch */
innerx1 = x1 + (switch_field_width - switch_width) / 2; innerx1 = x1 + (switch_field_width - switch_width) / 2;
// see if the switch is actually used /* see if the switch is actually used */
if (dip->mask & (1 << toggle)) if (dip->mask & (1 << toggle))
{ {
float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off; float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off;
@ -730,7 +731,7 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2,
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
} }
// advance to the next switch /* advance to the next switch */
x1 += switch_field_width; x1 += switch_field_width;
} }
} }
@ -742,45 +743,45 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2,
void menu_analog::handle() void menu_analog::handle()
{ {
// process the menu /* process the menu */
auto menu_event = process(PROCESS_LR_REPEAT); const event *menu_event = process(PROCESS_LR_REPEAT);
// handle events /* handle events */
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
auto data = (analog_item_data *)menu_event->itemref; analog_item_data *data = (analog_item_data *)menu_event->itemref;
auto newval = data->cur; int newval = data->cur;
switch (menu_event->iptkey) switch (menu_event->iptkey)
{ {
// if selected, reset to default value /* if selected, reset to default value */
case IPT_UI_SELECT: case IPT_UI_SELECT:
newval = data->defvalue; newval = data->defvalue;
break; break;
// left decrements /* left decrements */
case IPT_UI_LEFT: case IPT_UI_LEFT:
newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
break; break;
// right increments /* right increments */
case IPT_UI_RIGHT: case IPT_UI_RIGHT:
newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
break; break;
} }
// clamp to range /* clamp to range */
if (newval < data->min) if (newval < data->min)
newval = data->min; newval = data->min;
if (newval > data->max) if (newval > data->max)
newval = data->max; newval = data->max;
// if things changed, update /* if things changed, update */
if (newval != data->cur) if (newval != data->cur)
{ {
ioport_field::user_settings settings; ioport_field::user_settings settings;
// get the settings and set the new value /* get the settings and set the new value */
data->field->get_user_settings(settings); data->field->get_user_settings(settings);
switch (data->type) switch (data->type)
{ {
@ -791,7 +792,7 @@ void menu_analog::handle()
} }
data->field->set_user_settings(settings); data->field->set_user_settings(settings);
// rebuild the menu /* rebuild the menu */
reset(reset_options::REMEMBER_POSITION); reset(reset_options::REMEMBER_POSITION);
} }
} }
@ -812,7 +813,7 @@ void menu_analog::populate()
std::string prev_owner; std::string prev_owner;
bool first_entry = true; bool first_entry = true;
// loop over input ports and add the items /* loop over input ports and add the items */
for (auto &port : machine().ioport().ports()) for (auto &port : machine().ioport().ports())
for (ioport_field &field : port.second->fields()) for (ioport_field &field : port.second->fields())
if (field.is_analog() && field.enabled()) if (field.is_analog() && field.enabled())
@ -821,7 +822,7 @@ void menu_analog::populate()
int use_autocenter = false; int use_autocenter = false;
int type; int type;
// based on the type, determine if we enable autocenter /* based on the type, determine if we enable autocenter */
switch (field.type()) switch (field.type())
{ {
case IPT_POSITIONAL: case IPT_POSITIONAL:
@ -844,10 +845,10 @@ void menu_analog::populate()
break; break;
} }
// get the user settings /* get the user settings */
field.get_user_settings(settings); field.get_user_settings(settings);
// iterate over types /* iterate over types */
for (type = 0; type < ANALOG_ITEM_COUNT; type++) for (type = 0; type < ANALOG_ITEM_COUNT; type++)
if (type != ANALOG_ITEM_CENTERSPEED || use_autocenter) if (type != ANALOG_ITEM_CENTERSPEED || use_autocenter)
{ {
@ -865,12 +866,12 @@ void menu_analog::populate()
prev_owner.assign(field.device().tag()); prev_owner.assign(field.device().tag());
} }
// allocate a data item for tracking what this menu item refers to /* allocate a data item for tracking what this menu item refers to */
data = (analog_item_data *)m_pool_alloc(sizeof(*data)); data = (analog_item_data *)m_pool_alloc(sizeof(*data));
data->field = &field; data->field = &field;
data->type = type; data->type = type;
// determine the properties of this item /* determine the properties of this item */
switch (type) switch (type)
{ {
default: default:
@ -911,13 +912,13 @@ void menu_analog::populate()
break; break;
} }
// put on arrows /* put on arrows */
if (data->cur > data->min) if (data->cur > data->min)
flags |= FLAG_LEFT_ARROW; flags |= FLAG_LEFT_ARROW;
if (data->cur < data->max) if (data->cur < data->max)
flags |= FLAG_RIGHT_ARROW; flags |= FLAG_RIGHT_ARROW;
// append a menu item /* append a menu item */
item_append(std::move(text), std::move(subtext), flags, data); item_append(std::move(text), std::move(subtext), flags, data);
} }
} }

View File

@ -42,18 +42,18 @@ protected:
INPUT_TYPE_TOTAL = INPUT_TYPE_ANALOG + SEQ_TYPE_TOTAL INPUT_TYPE_TOTAL = INPUT_TYPE_ANALOG + SEQ_TYPE_TOTAL
}; };
// internal input menu item data /* internal input menu item data */
struct input_item_data struct input_item_data
{ {
input_item_data * next; // pointer to next item in the list input_item_data * next; /* pointer to next item in the list */
const void * ref; // reference to type description for global inputs or field for game inputs const void * ref; /* reference to type description for global inputs or field for game inputs */
input_seq_type seqtype; // sequence type input_seq_type seqtype; /* sequence type */
input_seq seq; // copy of the live sequence input_seq seq; /* copy of the live sequence */
const input_seq * defseq; // pointer to the default sequence const input_seq * defseq; /* pointer to the default sequence */
const char * name; // pointer to the base name of the item const char * name; /* pointer to the base name of the item */
const char * owner_name; // pointer to the name of the owner of the item const char * owner_name; /* pointer to the name of the owner of the item */
UINT32 sortorder; // sorting information UINT32 sortorder; /* sorting information */
UINT8 type; // type of port UINT8 type; /* type of port */
}; };
void populate_and_sort(struct input_item_data *itemlist); void populate_and_sort(struct input_item_data *itemlist);
@ -105,7 +105,7 @@ public:
virtual void handle() override; virtual void handle() override;
protected: protected:
// DIP switch descriptor /* DIP switch descriptor */
struct dip_descriptor struct dip_descriptor
{ {
dip_descriptor * next; dip_descriptor * next;
@ -154,7 +154,7 @@ private:
ANALOG_ITEM_COUNT ANALOG_ITEM_COUNT
}; };
// internal analog menu item data /* internal analog menu item data */
struct analog_item_data { struct analog_item_data {
ioport_field *field; ioport_field *field;
int type; int type;

View File

@ -50,12 +50,12 @@ menu_main::menu_main(mame_ui_manager &mui, render_container *container) : menu(m
void menu_main::populate() void menu_main::populate()
{ {
// add input menu items /* add input menu items */
item_append(_("Input (general)"), "", 0, (void *)INPUT_GROUPS); item_append(_("Input (general)"), "", 0, (void *)INPUT_GROUPS);
item_append(_("Input (this Machine)"), "", 0, (void *)INPUT_SPECIFIC); item_append(_("Input (this Machine)"), "", 0, (void *)INPUT_SPECIFIC);
// add optional input-related menus /* add optional input-related menus */
if (machine().ioport().has_analog()) if (machine().ioport().has_analog())
item_append(_("Analog Controls"), "", 0, (void *)ANALOG); item_append(_("Analog Controls"), "", 0, (void *)ANALOG);
if (machine().ioport().has_dips()) if (machine().ioport().has_dips())
@ -65,27 +65,27 @@ void menu_main::populate()
item_append(_("Machine Configuration"), "", 0, (void *)SETTINGS_DRIVER_CONFIG); item_append(_("Machine Configuration"), "", 0, (void *)SETTINGS_DRIVER_CONFIG);
} }
// add bookkeeping menu /* add bookkeeping menu */
item_append(_("Bookkeeping Info"), "", 0, (void *)BOOKKEEPING); item_append(_("Bookkeeping Info"), "", 0, (void *)BOOKKEEPING);
// add game info menu /* add game info menu */
item_append(_("Machine Information"), "", 0, (void *)GAME_INFO); item_append(_("Machine Information"), "", 0, (void *)GAME_INFO);
for (device_image_interface &image : image_interface_iterator(machine().root_device())) for (device_image_interface &image : image_interface_iterator(machine().root_device()))
{ {
if (image.user_loadable()) if (image.user_loadable())
{ {
// add image info menu /* add image info menu */
item_append(_("Image Information"), "", 0, (void *)IMAGE_MENU_IMAGE_INFO); item_append(_("Image Information"), "", 0, (void *)IMAGE_MENU_IMAGE_INFO);
// add file manager menu /* add file manager menu */
item_append(_("File Manager"), "", 0, (void *)IMAGE_MENU_FILE_MANAGER); item_append(_("File Manager"), "", 0, (void *)IMAGE_MENU_FILE_MANAGER);
break; break;
} }
} }
// add tape control menu /* add tape control menu */
if (cassette_device_iterator(machine().root_device()).first() != nullptr) if (cassette_device_iterator(machine().root_device()).first() != nullptr)
item_append(_("Tape Control"), "", 0, (void *)TAPE_CONTROL); item_append(_("Tape Control"), "", 0, (void *)TAPE_CONTROL);
@ -95,33 +95,33 @@ void menu_main::populate()
if (machine().ioport().has_bioses()) if (machine().ioport().has_bioses())
item_append(_("Bios Selection"), "", 0, (void *)BIOS_SELECTION); item_append(_("Bios Selection"), "", 0, (void *)BIOS_SELECTION);
// add slot info menu /* add slot info menu */
if (slot_interface_iterator(machine().root_device()).first() != nullptr) if (slot_interface_iterator(machine().root_device()).first() != nullptr)
item_append(_("Slot Devices"), "", 0, (void *)SLOT_DEVICES); item_append(_("Slot Devices"), "", 0, (void *)SLOT_DEVICES);
// add Barcode reader menu /* add Barcode reader menu */
if (barcode_reader_device_iterator(machine().root_device()).first() != nullptr) if (barcode_reader_device_iterator(machine().root_device()).first() != nullptr)
item_append(_("Barcode Reader"), "", 0, (void *)BARCODE_READ); item_append(_("Barcode Reader"), "", 0, (void *)BARCODE_READ);
// add network info menu /* add network info menu */
if (network_interface_iterator(machine().root_device()).first() != nullptr) if (network_interface_iterator(machine().root_device()).first() != nullptr)
item_append(_("Network Devices"), "", 0, (void*)NETWORK_DEVICES); item_append(_("Network Devices"), "", 0, (void*)NETWORK_DEVICES);
// add keyboard mode menu /* add keyboard mode menu */
if (machine().ioport().has_keyboard() && machine().ioport().natkeyboard().can_post()) if (machine().ioport().has_keyboard() && machine().ioport().natkeyboard().can_post())
item_append(_("Keyboard Mode"), "", 0, (void *)KEYBOARD_MODE); item_append(_("Keyboard Mode"), "", 0, (void *)KEYBOARD_MODE);
// add sliders menu /* add sliders menu */
item_append(_("Slider Controls"), "", 0, (void *)SLIDERS); item_append(_("Slider Controls"), "", 0, (void *)SLIDERS);
// add video options menu /* add video options menu */
item_append(_("Video Options"), "", 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS); item_append(_("Video Options"), "", 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS);
// add crosshair options menu /* add crosshair options menu */
if (machine().crosshair().get_usage()) if (machine().crosshair().get_usage())
item_append(_("Crosshair Options"), "", 0, (void *)CROSSHAIR); item_append(_("Crosshair Options"), "", 0, (void *)CROSSHAIR);
// add cheat menu /* add cheat menu */
if (machine().options().cheat()) if (machine().options().cheat())
item_append(_("Cheat"), "", 0, (void *)CHEAT); item_append(_("Cheat"), "", 0, (void *)CHEAT);
@ -134,7 +134,7 @@ void menu_main::populate()
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
// add favorite menu /* add favorite menu */
if (!mame_machine_manager::instance()->favorite().isgame_favorite()) if (!mame_machine_manager::instance()->favorite().isgame_favorite())
item_append(_("Add To Favorites"), "", 0, (void *)ADD_FAVORITE); item_append(_("Add To Favorites"), "", 0, (void *)ADD_FAVORITE);
else else
@ -144,7 +144,7 @@ void menu_main::populate()
// item_append(_("Quit from Machine"), nullptr, 0, (void *)QUIT_GAME); // item_append(_("Quit from Machine"), nullptr, 0, (void *)QUIT_GAME);
// add reset and exit menus /* add reset and exit menus */
item_append(_("Select New Machine"), "", 0, (void *)SELECT_GAME); item_append(_("Select New Machine"), "", 0, (void *)SELECT_GAME);
} }
@ -158,7 +158,7 @@ menu_main::~menu_main()
void menu_main::handle() void menu_main::handle()
{ {
// process the menu /* process the menu */
const event *menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) { if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) {
switch((long long)(menu_event->itemref)) { switch((long long)(menu_event->itemref)) {

View File

@ -38,7 +38,7 @@ menu_keyboard_mode::menu_keyboard_mode(mame_ui_manager &mui, render_container *c
void menu_keyboard_mode::populate() void menu_keyboard_mode::populate()
{ {
auto natural = ui().use_natural_keyboard(); bool natural = ui().use_natural_keyboard();
item_append(_("Keyboard Mode:"), natural ? _("Natural") : _("Emulated"), natural ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, nullptr); item_append(_("Keyboard Mode:"), natural ? _("Natural") : _("Emulated"), natural ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, nullptr);
} }
@ -48,19 +48,22 @@ menu_keyboard_mode::~menu_keyboard_mode()
void menu_keyboard_mode::handle() void menu_keyboard_mode::handle()
{ {
auto natural = ui().use_natural_keyboard(); bool natural = ui().use_natural_keyboard();
// process the menu /* process the menu */
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr) if (menu_event != nullptr)
{
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)
{ {
ui().set_use_natural_keyboard(natural ^ true); ui().set_use_natural_keyboard(natural ^ true);
reset(reset_options::REMEMBER_REF); reset(reset_options::REMEMBER_REF);
} }
}
} }
/*------------------------------------------------- /*-------------------------------------------------
menu_bios_selection - populates the main menu_bios_selection - populates the main
bios selection menu bios selection menu
@ -72,17 +75,22 @@ menu_bios_selection::menu_bios_selection(mame_ui_manager &mui, render_container
void menu_bios_selection::populate() void menu_bios_selection::populate()
{ {
// cycle through all devices for this system /* cycle through all devices for this system */
for (device_t &device : device_iterator(machine().root_device())) for (device_t &device : device_iterator(machine().root_device()))
{
if (device.rom_region()) if (device.rom_region())
{ {
const char *val = "default"; const char *val = "default";
for (auto rom = device.rom_region(); !ROMENTRY_ISEND(rom); ++rom) for (const rom_entry *rom = device.rom_region(); !ROMENTRY_ISEND(rom); rom++)
{
if (ROMENTRY_ISSYSTEM_BIOS(rom) && ROM_GETBIOSFLAGS(rom) == device.system_bios()) if (ROMENTRY_ISSYSTEM_BIOS(rom) && ROM_GETBIOSFLAGS(rom) == device.system_bios())
{
val = ROM_GETHASHDATA(rom); val = ROM_GETHASHDATA(rom);
}
}
item_append(device.owner() == nullptr ? "driver" : device.tag()+1, val, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)&device); item_append(device.owner() == nullptr ? "driver" : device.tag()+1, val, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)&device);
} }
}
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
item_append(_("Reset"), "", 0, (void *)1); item_append(_("Reset"), "", 0, (void *)1);
@ -98,8 +106,8 @@ menu_bios_selection::~menu_bios_selection()
void menu_bios_selection::handle() void menu_bios_selection::handle()
{ {
// process the menu /* process the menu */
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
@ -107,26 +115,23 @@ void menu_bios_selection::handle()
machine().schedule_hard_reset(); machine().schedule_hard_reset();
else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
{ {
auto dev = (device_t *)menu_event->itemref; device_t *dev = (device_t *)menu_event->itemref;
int cnt = 0; int cnt = 0;
for (auto rom = dev->rom_region(); !ROMENTRY_ISEND(rom); ++rom) for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++)
if (ROMENTRY_ISSYSTEM_BIOS(rom))
cnt++;
int val = dev->system_bios() + ((menu_event->iptkey == IPT_UI_LEFT) ? -1 : +1);
if (val < 1) val = cnt;
if (val > cnt) val = 1;
dev->set_system_bios(val);
if (strcmp(dev->tag(), ":") == 0)
{ {
std::string error; if (ROMENTRY_ISSYSTEM_BIOS(rom)) cnt ++;
machine().options().set_value("bios", val - 1, OPTION_PRIORITY_CMDLINE, error);
assert(error.empty());
} }
else int val = dev->system_bios() + ((menu_event->iptkey == IPT_UI_LEFT) ? -1 : +1);
{ if (val<1) val=cnt;
if (val>cnt) val=1;
dev->set_system_bios(val);
if (strcmp(dev->tag(),":")==0) {
std::string error; std::string error;
std::string value = string_format("%s,bios=%d", machine().options().main_value(dev->owner()->tag() + 1), val - 1); machine().options().set_value("bios", val-1, OPTION_PRIORITY_CMDLINE, error);
assert(error.empty());
} else {
std::string error;
std::string value = string_format("%s,bios=%d", machine().options().main_value(dev->owner()->tag()+1), val-1);
machine().options().set_value(dev->owner()->tag()+1, value.c_str(), OPTION_PRIORITY_CMDLINE, error); machine().options().set_value(dev->owner()->tag()+1, value.c_str(), OPTION_PRIORITY_CMDLINE, error);
assert(error.empty()); assert(error.empty());
} }
@ -152,17 +157,18 @@ menu_network_devices::~menu_network_devices()
void menu_network_devices::populate() void menu_network_devices::populate()
{ {
// cycle through all devices for this system /* cycle through all devices for this system */
for (device_network_interface &network : network_interface_iterator(machine().root_device())) for (device_network_interface &network : network_interface_iterator(machine().root_device()))
{ {
auto curr = network.get_interface(); int curr = network.get_interface();
const char *title = nullptr; const char *title = nullptr;
for(auto &entry : get_netdev_list()) for(auto &entry : get_netdev_list())
if(entry->id == curr) {
{ if(entry->id==curr) {
title = entry->description; title = entry->description;
break; break;
} }
}
item_append(network.device().tag(), (title) ? title : "------", FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)network); item_append(network.device().tag(), (title) ? title : "------", FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)network);
} }
@ -174,20 +180,20 @@ void menu_network_devices::populate()
void menu_network_devices::handle() void menu_network_devices::handle()
{ {
// process the menu /* process the menu */
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
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) {
auto network = (device_network_interface *)menu_event->itemref; device_network_interface *network = (device_network_interface *)menu_event->itemref;
int curr = network->get_interface(); int curr = network->get_interface();
(menu_event->iptkey == IPT_UI_LEFT) ? curr-- : curr++; if (menu_event->iptkey == IPT_UI_LEFT) curr--; else curr++;
if (curr == -2) if (curr==-2) curr = netdev_count() - 1;
curr = netdev_count() - 1;
network->set_interface(curr); network->set_interface(curr);
reset(reset_options::REMEMBER_REF); reset(reset_options::REMEMBER_REF);
} }
}
} }
@ -200,7 +206,7 @@ void menu_bookkeeping::handle()
{ {
attotime curtime; attotime curtime;
// if the time has rolled over another second, regenerate /* if the time has rolled over another second, regenerate */
curtime = machine().time(); curtime = machine().time();
if (prevtime.seconds() != curtime.seconds()) if (prevtime.seconds() != curtime.seconds())
{ {
@ -209,7 +215,7 @@ void menu_bookkeeping::handle()
populate(); populate();
} }
// process the menu /* process the menu */
process(0); process(0);
} }
@ -228,27 +234,28 @@ menu_bookkeeping::~menu_bookkeeping()
void menu_bookkeeping::populate() void menu_bookkeeping::populate()
{ {
auto tickets = machine().bookkeeping().get_dispensed_tickets(); int tickets = machine().bookkeeping().get_dispensed_tickets();
std::ostringstream tempstring; std::ostringstream tempstring;
int ctrnum;
// show total time first /* show total time first */
if (prevtime.seconds() >= (60 * 60)) if (prevtime.seconds() >= (60 * 60))
util::stream_format(tempstring, _("Uptime: %1$d:%2$02d:%3$02d\n\n"), prevtime.seconds() / (60 * 60), (prevtime.seconds() / 60) % 60, prevtime.seconds() % 60); util::stream_format(tempstring, _("Uptime: %1$d:%2$02d:%3$02d\n\n"), prevtime.seconds() / (60 * 60), (prevtime.seconds() / 60) % 60, prevtime.seconds() % 60);
else else
util::stream_format(tempstring, _("Uptime: %1$d:%2$02d\n\n"), (prevtime.seconds() / 60) % 60, prevtime.seconds() % 60); util::stream_format(tempstring, _("Uptime: %1$d:%2$02d\n\n"), (prevtime.seconds() / 60) % 60, prevtime.seconds() % 60);
// show tickets at the top /* show tickets at the top */
if (tickets > 0) if (tickets > 0)
util::stream_format(tempstring, _("Tickets dispensed: %1$d\n\n"), tickets); util::stream_format(tempstring, _("Tickets dispensed: %1$d\n\n"), tickets);
// loop over coin counters /* loop over coin counters */
for (int ctrnum = 0; ctrnum < COIN_COUNTERS; ++ctrnum) for (ctrnum = 0; ctrnum < COIN_COUNTERS; ctrnum++)
{ {
auto count = machine().bookkeeping().coin_counter_get_count(ctrnum); int count = machine().bookkeeping().coin_counter_get_count(ctrnum);
// display the coin counter number /* display the coin counter number */
// display how many coins /* display how many coins */
// display whether or not we are locked out /* display whether or not we are locked out */
util::stream_format(tempstring, util::stream_format(tempstring,
(count == 0) ? _("Coin %1$c: NA%3$s\n") : _("Coin %1$c: %2$d%3$s\n"), (count == 0) ? _("Coin %1$c: NA%3$s\n") : _("Coin %1$c: %2$d%3$s\n"),
ctrnum + 'A', ctrnum + 'A',
@ -256,7 +263,7 @@ void menu_bookkeeping::populate()
machine().bookkeeping().coin_lockout_get_state(ctrnum) ? _(" (locked)") : ""); machine().bookkeeping().coin_lockout_get_state(ctrnum) ? _(" (locked)") : "");
} }
// append the single item /* append the single item */
item_append(tempstring.str(), "", FLAG_MULTILINE, nullptr); item_append(tempstring.str(), "", FLAG_MULTILINE, nullptr);
} }
@ -267,58 +274,58 @@ void menu_bookkeeping::populate()
void menu_crosshair::handle() void menu_crosshair::handle()
{ {
// process the menu /* process the menu */
auto menu_event = process(PROCESS_LR_REPEAT); const event *menu_event = process(PROCESS_LR_REPEAT);
// handle events /* handle events */
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
crosshair_user_settings settings; crosshair_user_settings settings;
auto data = (crosshair_item_data *)menu_event->itemref; crosshair_item_data *data = (crosshair_item_data *)menu_event->itemref;
auto changed = false; bool changed = false;
//int set_def = false; //int set_def = false;
auto newval = data->cur; int newval = data->cur;
// retreive the user settings /* retreive the user settings */
machine().crosshair().get_user_settings(data->player, &settings); machine().crosshair().get_user_settings(data->player, &settings);
switch (menu_event->iptkey) switch (menu_event->iptkey)
{ {
// if selected, reset to default value /* if selected, reset to default value */
case IPT_UI_SELECT: case IPT_UI_SELECT:
newval = data->defvalue; newval = data->defvalue;
//set_def = true; //set_def = true;
break; break;
// left decrements /* left decrements */
case IPT_UI_LEFT: case IPT_UI_LEFT:
newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
break; break;
// right increments /* right increments */
case IPT_UI_RIGHT: case IPT_UI_RIGHT:
newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
break; break;
} }
// clamp to range /* clamp to range */
if (newval < data->min) if (newval < data->min)
newval = data->min; newval = data->min;
if (newval > data->max) if (newval > data->max)
newval = data->max; newval = data->max;
// if things changed, update /* if things changed, update */
if (newval != data->cur) if (newval != data->cur)
{ {
switch (data->type) switch (data->type)
{ {
// visibility state /* visibility state */
case CROSSHAIR_ITEM_VIS: case CROSSHAIR_ITEM_VIS:
settings.mode = newval; settings.mode = newval;
changed = true; changed = true;
break; break;
// auto time /* auto time */
case CROSSHAIR_ITEM_AUTO_TIME: case CROSSHAIR_ITEM_AUTO_TIME:
settings.auto_time = newval; settings.auto_time = newval;
changed = true; changed = true;
@ -326,13 +333,13 @@ void menu_crosshair::handle()
} }
} }
// crosshair graphic name /* crosshair graphic name */
if (data->type == CROSSHAIR_ITEM_PIC) if (data->type == CROSSHAIR_ITEM_PIC)
{ {
switch (menu_event->iptkey) switch (menu_event->iptkey)
{ {
case IPT_UI_SELECT: case IPT_UI_SELECT:
// clear the name string to reset to default crosshair /* clear the name string to reset to default crosshair */
settings.name[0] = 0; settings.name[0] = 0;
changed = true; changed = true;
break; break;
@ -351,10 +358,10 @@ void menu_crosshair::handle()
if (changed) if (changed)
{ {
// save the user settings /* save the user settings */
machine().crosshair().set_user_settings(data->player, &settings); machine().crosshair().set_user_settings(data->player, &settings);
// rebuild the menu /* rebuild the menu */
reset(reset_options::REMEMBER_POSITION); reset(reset_options::REMEMBER_POSITION);
} }
} }
@ -379,22 +386,22 @@ void menu_crosshair::populate()
UINT8 use_auto = false; UINT8 use_auto = false;
UINT32 flags = 0; UINT32 flags = 0;
// loop over player and add the manual items /* loop over player and add the manual items */
for (player = 0; player < MAX_PLAYERS; player++) for (player = 0; player < MAX_PLAYERS; player++)
{ {
// get the user settings /* get the user settings */
machine().crosshair().get_user_settings(player, &settings); machine().crosshair().get_user_settings(player, &settings);
// add menu items for usable crosshairs /* add menu items for usable crosshairs */
if (settings.used) if (settings.used)
{ {
// Make sure to keep these matched to the CROSSHAIR_VISIBILITY_xxx types /* Make sure to keep these matched to the CROSSHAIR_VISIBILITY_xxx types */
static const char *const vis_text[] = { "Off", "On", "Auto" }; static const char *const vis_text[] = { "Off", "On", "Auto" };
// track if we need the auto time menu /* track if we need the auto time menu */
if (settings.mode == CROSSHAIR_VISIBILITY_AUTO) use_auto = true; if (settings.mode == CROSSHAIR_VISIBILITY_AUTO) use_auto = true;
// CROSSHAIR_ITEM_VIS - allocate a data item and fill it /* CROSSHAIR_ITEM_VIS - allocate a data item and fill it */
data = (crosshair_item_data *)m_pool_alloc(sizeof(*data)); data = (crosshair_item_data *)m_pool_alloc(sizeof(*data));
data->type = CROSSHAIR_ITEM_VIS; data->type = CROSSHAIR_ITEM_VIS;
data->player = player; data->player = player;
@ -403,95 +410,95 @@ void menu_crosshair::populate()
data->defvalue = CROSSHAIR_VISIBILITY_DEFAULT; data->defvalue = CROSSHAIR_VISIBILITY_DEFAULT;
data->cur = settings.mode; data->cur = settings.mode;
// put on arrows /* put on arrows */
if (data->cur > data->min) if (data->cur > data->min)
flags |= FLAG_LEFT_ARROW; flags |= FLAG_LEFT_ARROW;
if (data->cur < data->max) if (data->cur < data->max)
flags |= FLAG_RIGHT_ARROW; flags |= FLAG_RIGHT_ARROW;
// add CROSSHAIR_ITEM_VIS menu /* add CROSSHAIR_ITEM_VIS menu */
sprintf(temp_text, "P%d Visibility", player + 1); sprintf(temp_text, "P%d Visibility", player + 1);
item_append(temp_text, vis_text[settings.mode], flags, data); item_append(temp_text, vis_text[settings.mode], flags, data);
// CROSSHAIR_ITEM_PIC - allocate a data item and fill it /* CROSSHAIR_ITEM_PIC - allocate a data item and fill it */
data = (crosshair_item_data *)m_pool_alloc(sizeof(*data)); data = (crosshair_item_data *)m_pool_alloc(sizeof(*data));
data->type = CROSSHAIR_ITEM_PIC; data->type = CROSSHAIR_ITEM_PIC;
data->player = player; data->player = player;
data->last_name[0] = 0; data->last_name[0] = 0;
// other data item not used by this menu /* other data item not used by this menu */
// search for crosshair graphics /* search for crosshair graphics */
// open a path to the crosshairs /* open a path to the crosshairs */
file_enumerator path(machine().options().crosshair_path()); file_enumerator path(machine().options().crosshair_path());
const osd::directory::entry *dir; const osd::directory::entry *dir;
// reset search flags /* reset search flags */
bool using_default = false; bool using_default = false;
bool finished = false; bool finished = false;
bool found = false; bool found = false;
// if we are using the default, then we just need to find the first in the list /* if we are using the default, then we just need to find the first in the list */
if (*(settings.name) == 0) if (*(settings.name) == 0)
using_default = true; using_default = true;
// look for the current name, then remember the name before /* look for the current name, then remember the name before */
// and find the next name /* and find the next name */
while (((dir = path.next()) != nullptr) && !finished) while (((dir = path.next()) != nullptr) && !finished)
{ {
int length = strlen(dir->name); int length = strlen(dir->name);
// look for files ending in .png with a name not larger then 9 chars /* look for files ending in .png with a name not larger then 9 chars*/
if ((length > 4) && (length <= CROSSHAIR_PIC_NAME_LENGTH + 4) && core_filename_ends_with(dir->name, ".png")) if ((length > 4) && (length <= CROSSHAIR_PIC_NAME_LENGTH + 4) && core_filename_ends_with(dir->name, ".png"))
{ {
// remove .png from length /* remove .png from length */
length -= 4; length -= 4;
if (found || using_default) if (found || using_default)
{ {
// get the next name /* get the next name */
strncpy(data->next_name, dir->name, length); strncpy(data->next_name, dir->name, length);
data->next_name[length] = 0; data->next_name[length] = 0;
finished = true; finished = true;
} }
else if (!strncmp(dir->name, settings.name, length)) else if (!strncmp(dir->name, settings.name, length))
{ {
// we found the current name /* we found the current name */
// so loop once more to find the next name /* so loop once more to find the next name */
found = true; found = true;
} }
else else
// remember last name /* remember last name */
// we will do it here in case files get added to the directory /* we will do it here in case files get added to the directory */
{ {
strncpy(data->last_name, dir->name, length); strncpy(data->last_name, dir->name, length);
data->last_name[length] = 0; data->last_name[length] = 0;
} }
} }
} }
// if name not found then next item is DEFAULT /* if name not found then next item is DEFAULT */
if (!found && !using_default) if (!found && !using_default)
{ {
data->next_name[0] = 0; data->next_name[0] = 0;
finished = true; finished = true;
} }
// setup the selection flags /* setup the selection flags */
flags = 0; flags = 0;
if (finished) if (finished)
flags |= FLAG_RIGHT_ARROW; flags |= FLAG_RIGHT_ARROW;
if (found) if (found)
flags |= FLAG_LEFT_ARROW; flags |= FLAG_LEFT_ARROW;
// add CROSSHAIR_ITEM_PIC menu /* add CROSSHAIR_ITEM_PIC menu */
sprintf(temp_text, "P%d Crosshair", player + 1); sprintf(temp_text, "P%d Crosshair", player + 1);
item_append(temp_text, using_default ? "DEFAULT" : settings.name, flags, data); item_append(temp_text, using_default ? "DEFAULT" : settings.name, flags, data);
} }
} }
if (use_auto) if (use_auto)
{ {
// any player can be used to get the autotime /* any player can be used to get the autotime */
machine().crosshair().get_user_settings(0, &settings); machine().crosshair().get_user_settings(0, &settings);
// CROSSHAIR_ITEM_AUTO_TIME - allocate a data item and fill it /* CROSSHAIR_ITEM_AUTO_TIME - allocate a data item and fill it */
data = (crosshair_item_data *)m_pool_alloc(sizeof(*data)); data = (crosshair_item_data *)m_pool_alloc(sizeof(*data));
data->type = CROSSHAIR_ITEM_AUTO_TIME; data->type = CROSSHAIR_ITEM_AUTO_TIME;
data->min = CROSSHAIR_VISIBILITY_AUTOTIME_MIN; data->min = CROSSHAIR_VISIBILITY_AUTOTIME_MIN;
@ -499,18 +506,18 @@ void menu_crosshair::populate()
data->defvalue = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT; data->defvalue = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT;
data->cur = settings.auto_time; data->cur = settings.auto_time;
// put on arrows in visible menu /* put on arrows in visible menu */
if (data->cur > data->min) if (data->cur > data->min)
flags |= FLAG_LEFT_ARROW; flags |= FLAG_LEFT_ARROW;
if (data->cur < data->max) if (data->cur < data->max)
flags |= FLAG_RIGHT_ARROW; flags |= FLAG_RIGHT_ARROW;
// add CROSSHAIR_ITEM_AUTO_TIME menu /* add CROSSHAIR_ITEM_AUTO_TIME menu */
sprintf(temp_text, "%d", settings.auto_time); sprintf(temp_text, "%d", settings.auto_time);
item_append(_("Visible Delay"), temp_text, flags, data); item_append(_("Visible Delay"), temp_text, flags, data);
} }
// else // else
// // leave a blank filler line when not in auto time so size does not rescale // /* leave a blank filler line when not in auto time so size does not rescale */
// item_append("", "", nullptr, nullptr); // item_append("", "", nullptr, nullptr);
} }
@ -537,10 +544,10 @@ void menu_quit_game::populate()
void menu_quit_game::handle() void menu_quit_game::handle()
{ {
// request a reset /* request a reset */
machine().schedule_exit(); machine().schedule_exit();
// reset the menu stack /* reset the menu stack */
menu::stack_reset(machine()); menu::stack_reset(machine());
} }
@ -565,7 +572,7 @@ void menu_export::handle()
{ {
// process the menu // process the menu
process_parent(); process_parent();
auto menu_event = process(PROCESS_NOIMAGE); const event *menu_event = process(PROCESS_NOIMAGE);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
switch ((FPTR)menu_event->itemref) switch ((FPTR)menu_event->itemref)
@ -580,7 +587,7 @@ void menu_export::handle()
if (infile.open(filename.c_str(), ".xml") == osd_file::error::NONE) if (infile.open(filename.c_str(), ".xml") == osd_file::error::NONE)
for (int seq = 0; ; ++seq) for (int seq = 0; ; ++seq)
{ {
auto seqtext = string_format("%s_%04d", filename, seq); std::string seqtext = string_format("%s_%04d", filename, seq);
if (infile.open(seqtext.c_str(), ".xml") != osd_file::error::NONE) if (infile.open(seqtext.c_str(), ".xml") != osd_file::error::NONE)
{ {
filename = seqtext; filename = seqtext;
@ -620,7 +627,7 @@ void menu_export::handle()
if (infile.open(filename.c_str(), ".txt") == osd_file::error::NONE) if (infile.open(filename.c_str(), ".txt") == osd_file::error::NONE)
for (int seq = 0; ; ++seq) for (int seq = 0; ; ++seq)
{ {
auto seqtext = string_format("%s_%04d", filename, seq); std::string seqtext = string_format("%s_%04d", filename, seq);
if (infile.open(seqtext.c_str(), ".txt") != osd_file::error::NONE) if (infile.open(seqtext.c_str(), ".txt") != osd_file::error::NONE)
{ {
filename = seqtext; filename = seqtext;
@ -700,7 +707,7 @@ void menu_machine_configure::handle()
{ {
// process the menu // process the menu
process_parent(); process_parent();
auto menu_event = process((PROCESS_NOIMAGE | PROCESS_LR_REPEAT), x0, y0); const event *menu_event = process(PROCESS_NOIMAGE, x0, y0);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
if (menu_event->iptkey == IPT_UI_SELECT) if (menu_event->iptkey == IPT_UI_SELECT)
@ -840,19 +847,19 @@ void menu_machine_configure::setup_bios()
std::string specbios(m_opts.bios()); std::string specbios(m_opts.bios());
std::string default_name; std::string default_name;
for (auto rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom) for (const rom_entry *rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom)
if (ROMENTRY_ISDEFAULT_BIOS(rom)) if (ROMENTRY_ISDEFAULT_BIOS(rom))
default_name = ROM_GETNAME(rom); default_name = ROM_GETNAME(rom);
int bios_count = 0; int bios_count = 0;
for (auto rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom) for (const rom_entry *rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom)
{ {
if (ROMENTRY_ISSYSTEM_BIOS(rom)) if (ROMENTRY_ISSYSTEM_BIOS(rom))
{ {
std::string name(ROM_GETHASHDATA(rom)); std::string name(ROM_GETHASHDATA(rom));
std::string biosname(ROM_GETNAME(rom)); std::string biosname(ROM_GETNAME(rom));
int bios_flags = ROM_GETBIOSFLAGS(rom); int bios_flags = ROM_GETBIOSFLAGS(rom);
auto bios_number = std::to_string(bios_flags - 1); std::string bios_number = std::to_string(bios_flags - 1);
// check biosnumber and name // check biosnumber and name
if (bios_number == specbios || biosname == specbios) if (bios_number == specbios || biosname == specbios)
@ -863,11 +870,9 @@ void menu_machine_configure::setup_bios()
name.append(_(" (default)")); name.append(_(" (default)"));
if (specbios == "default") if (specbios == "default")
m_curbios = bios_count; m_curbios = bios_count;
m_bios.emplace(m_bios.begin(), name, bios_flags - 1);
} }
else
m_bios.emplace_back(name, bios_flags - 1);
m_bios.emplace_back(name, bios_flags - 1);
bios_count++; bios_count++;
} }
} }
@ -903,15 +908,15 @@ menu_plugins_configure::~menu_plugins_configure()
void menu_plugins_configure::handle() void menu_plugins_configure::handle()
{ {
// process the menu // process the menu
auto changed = false; bool changed = false;
auto plugins = mame_machine_manager::instance()->plugins(); plugin_options& plugins = mame_machine_manager::instance()->plugins();
process_parent(); process_parent();
auto menu_event = process(PROCESS_NOIMAGE); const event *menu_event = process(PROCESS_NOIMAGE);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT) if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT)
{ {
auto oldval = plugins.int_value((const char*)menu_event->itemref); int oldval = plugins.int_value((const char*)menu_event->itemref);
std::string error_string; std::string error_string;
plugins.set_value((const char*)menu_event->itemref, oldval == 1 ? 0 : 1, OPTION_PRIORITY_CMDLINE, error_string); plugins.set_value((const char*)menu_event->itemref, oldval == 1 ? 0 : 1, OPTION_PRIORITY_CMDLINE, error_string);
changed = true; changed = true;
@ -927,16 +932,17 @@ void menu_plugins_configure::handle()
void menu_plugins_configure::populate() void menu_plugins_configure::populate()
{ {
auto plugins = mame_machine_manager::instance()->plugins(); plugin_options& plugins = mame_machine_manager::instance()->plugins();
for (auto &curentry : plugins) for (auto &curentry : plugins)
{
if (!curentry.is_header()) if (!curentry.is_header())
{ {
auto enabled = std::string(curentry.value()) == "1"; auto enabled = std::string(curentry.value()) == "1";
item_append(curentry.description(), enabled ? _("On") : _("Off"), item_append(curentry.description(), enabled ? _("On") : _("Off"),
enabled ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(FPTR)curentry.name()); enabled ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(FPTR)curentry.name());
} }
}
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER); customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
} }

View File

@ -31,9 +31,9 @@ namespace ui {
// ctor // ctor
//------------------------------------------------- //-------------------------------------------------
menu_game_options::menu_game_options(mame_ui_manager &mui, render_container *container) menu_game_options::menu_game_options(mame_ui_manager &mui, render_container *container) : menu(mui, container)
: menu(mui, container), m_main(main_filters::actual)
{ {
m_main = main_filters::actual;
} }
//------------------------------------------------- //-------------------------------------------------
@ -54,7 +54,7 @@ menu_game_options::~menu_game_options()
void menu_game_options::handle() void menu_game_options::handle()
{ {
auto changed = false; bool changed = false;
// process the menu // process the menu
const event *menu_event; const event *menu_event;
@ -85,7 +85,7 @@ void menu_game_options::handle()
for (int index = 0; index < total; ++index) for (int index = 0; index < total; ++index)
s_sel[index] = main_filters::text[index]; s_sel[index] = main_filters::text[index];
menu::stack_push<menu_selector>(ui(), container, std::move(s_sel), m_main); menu::stack_push<menu_selector>(ui(), container, s_sel, m_main);
} }
break; break;
} }
@ -110,7 +110,7 @@ void menu_game_options::handle()
for (size_t index = 0; index < total; ++index) for (size_t index = 0; index < total; ++index)
s_sel[index] = ifile.get_file(index); s_sel[index] = ifile.get_file(index);
menu::stack_push<menu_selector>(ui(), container, std::move(s_sel), ifile.cur_file(), menu_selector::INIFILE); menu::stack_push<menu_selector>(ui(), container, s_sel, ifile.cur_file(), menu_selector::INIFILE);
} }
break; break;
} }
@ -128,13 +128,13 @@ void menu_game_options::handle()
} }
else if (menu_event->iptkey == IPT_UI_SELECT) else if (menu_event->iptkey == IPT_UI_SELECT)
{ {
auto ifile = mame_machine_manager::instance()->inifile(); inifile_manager &ifile = mame_machine_manager::instance()->inifile();
auto total = ifile.cat_total(); int total = ifile.cat_total();
std::vector<std::string> s_sel(total); std::vector<std::string> s_sel(total);
for (size_t index = 0; index < total; ++index) for (int index = 0; index < total; ++index)
s_sel[index] = ifile.get_category(index); s_sel[index] = ifile.get_category(index);
menu::stack_push<menu_selector>(ui(), container, std::move(s_sel), ifile.cur_cat(), menu_selector::CATEGORY); menu::stack_push<menu_selector>(ui(), container, s_sel, ifile.cur_cat(), menu_selector::CATEGORY);
} }
break; break;
} }
@ -228,13 +228,13 @@ void menu_game_options::populate()
std::string fbuff; std::string fbuff;
// add filter item // add filter item
auto arrow_flags = get_arrow_flags((int)FILTER_FIRST, (int)FILTER_LAST, m_main); UINT32 arrow_flags = get_arrow_flags((int)FILTER_FIRST, (int)FILTER_LAST, m_main);
item_append(_("Filter"), main_filters::text[m_main], arrow_flags, (void *)(FPTR)FILTER_MENU); item_append(_("Filter"), main_filters::text[m_main], arrow_flags, (void *)(FPTR)FILTER_MENU);
// add category subitem // add category subitem
if (m_main == FILTER_CATEGORY && mame_machine_manager::instance()->inifile().total() > 0) if (m_main == FILTER_CATEGORY && mame_machine_manager::instance()->inifile().total() > 0)
{ {
auto inif = mame_machine_manager::instance()->inifile(); inifile_manager &inif = mame_machine_manager::instance()->inifile();
arrow_flags = get_arrow_flags(0, inif.total() - 1, inif.cur_file()); arrow_flags = get_arrow_flags(0, inif.total() - 1, inif.cur_file());
fbuff = _(" ^!File"); fbuff = _(" ^!File");
@ -297,7 +297,7 @@ void menu_game_options::custom_render(void *selectedref, float top, float bottom
{ {
float width; float width;
ui().draw_text_full(container, _("Settings"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, _("Settings"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width); float maxwidth = MAX(origx2 - origx1, width);
@ -317,7 +317,8 @@ void menu_game_options::custom_render(void *selectedref, float top, float bottom
// draw the text within it // draw the text within it
ui().draw_text_full(container, _("Settings"), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, _("Settings"), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
} }
} // namespace ui } // namespace ui

View File

@ -22,14 +22,24 @@ namespace ui {
//------------------------------------------------- //-------------------------------------------------
menu_selector::menu_selector(mame_ui_manager &mui, render_container *container, std::vector<std::string> const &s_sel, UINT16 &s_actual, int category, int _hover) menu_selector::menu_selector(mame_ui_manager &mui, render_container *container, std::vector<std::string> const &s_sel, UINT16 &s_actual, int category, int _hover)
: menu(mui, container), m_selector(s_actual), m_category(category), m_hover(_hover), m_first_pass(true), m_str_items(s_sel) : menu(mui, container)
, m_selector(s_actual)
, m_category(category)
, m_hover(_hover)
, m_first_pass(true)
, m_str_items(s_sel)
{ {
m_search[0] = '\0'; m_search[0] = '\0';
m_searchlist[0] = nullptr; m_searchlist[0] = nullptr;
} }
menu_selector::menu_selector(mame_ui_manager &mui, render_container *container, std::vector<std::string> &&s_sel, UINT16 &s_actual, int category, int _hover) menu_selector::menu_selector(mame_ui_manager &mui, render_container *container, std::vector<std::string> &&s_sel, UINT16 &s_actual, int category, int _hover)
: menu(mui, container), m_selector(s_actual), m_category(category), m_hover(_hover), m_first_pass(true), m_str_items(std::move(s_sel)) : menu(mui, container)
, m_selector(s_actual)
, m_category(category)
, m_hover(_hover)
, m_first_pass(true)
, m_str_items(std::move(s_sel))
{ {
m_search[0] = '\0'; m_search[0] = '\0';
m_searchlist[0] = nullptr; m_searchlist[0] = nullptr;
@ -46,7 +56,7 @@ menu_selector::~menu_selector()
void menu_selector::handle() void menu_selector::handle()
{ {
// process the menu // process the menu
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
@ -125,6 +135,7 @@ void menu_selector::populate()
if (m_search[0] != 0) if (m_search[0] != 0)
{ {
find_matches(m_search); find_matches(m_search);
for (int curitem = 0; m_searchlist[curitem]; ++curitem) for (int curitem = 0; m_searchlist[curitem]; ++curitem)
item_append(*m_searchlist[curitem], "", 0, (void *)m_searchlist[curitem]); item_append(*m_searchlist[curitem], "", 0, (void *)m_searchlist[curitem]);
} }

View File

@ -180,6 +180,9 @@ void menu_select_game::handle()
if (m_prev_selected == nullptr) if (m_prev_selected == nullptr)
m_prev_selected = item[0].ref; m_prev_selected = item[0].ref;
bool check_filter = false;
bool enabled_dats = ui().options().enabled_dats();
// if i have to load datfile, performe an hard reset // if i have to load datfile, performe an hard reset
if (ui_globals::reset) if (ui_globals::reset)
{ {
@ -197,14 +200,11 @@ void menu_select_game::handle()
return; return;
} }
auto check_filter = false;
auto enabled_dats = ui().options().enabled_dats();
// ignore pause keys by swallowing them before we process the menu // ignore pause keys by swallowing them before we process the menu
machine().ui_input().pressed(IPT_UI_PAUSE); machine().ui_input().pressed(IPT_UI_PAUSE);
// process the menu // process the menu
auto menu_event = process(PROCESS_LR_REPEAT); const event *menu_event = process(PROCESS_LR_REPEAT);
if (menu_event && menu_event->itemref) if (menu_event && menu_event->itemref)
{ {
if (ui_error) if (ui_error)
@ -257,7 +257,7 @@ void menu_select_game::handle()
// Infos // Infos
if (!isfavorite()) if (!isfavorite())
{ {
auto drv = (const game_driver *)menu_event->itemref; const game_driver *drv = (const game_driver *)menu_event->itemref;
if ((FPTR)drv > skip_main_items && ui_globals::curdats_view > UI_FIRST_LOAD) if ((FPTR)drv > skip_main_items && ui_globals::curdats_view > UI_FIRST_LOAD)
{ {
ui_globals::curdats_view--; ui_globals::curdats_view--;
@ -266,7 +266,7 @@ void menu_select_game::handle()
} }
else else
{ {
auto drv = (ui_software_info *)menu_event->itemref; ui_software_info *drv = (ui_software_info *)menu_event->itemref;
if (drv->startempty == 1 && ui_globals::curdats_view > UI_FIRST_LOAD) if (drv->startempty == 1 && ui_globals::curdats_view > UI_FIRST_LOAD)
{ {
ui_globals::curdats_view--; ui_globals::curdats_view--;
@ -295,7 +295,7 @@ void menu_select_game::handle()
// Infos // Infos
if (!isfavorite()) if (!isfavorite())
{ {
auto drv = (const game_driver *)menu_event->itemref; const game_driver *drv = (const game_driver *)menu_event->itemref;
if ((FPTR)drv > skip_main_items && ui_globals::curdats_view < UI_LAST_LOAD) if ((FPTR)drv > skip_main_items && ui_globals::curdats_view < UI_LAST_LOAD)
{ {
ui_globals::curdats_view++; ui_globals::curdats_view++;
@ -304,7 +304,7 @@ void menu_select_game::handle()
} }
else else
{ {
auto drv = (ui_software_info *)menu_event->itemref; ui_software_info *drv = (ui_software_info *)menu_event->itemref;
if (drv->startempty == 1 && ui_globals::curdats_view < UI_LAST_LOAD) if (drv->startempty == 1 && ui_globals::curdats_view < UI_LAST_LOAD)
{ {
ui_globals::curdats_view++; ui_globals::curdats_view++;
@ -349,14 +349,14 @@ void menu_select_game::handle()
// handle UI_DATS // handle UI_DATS
if (!isfavorite()) if (!isfavorite())
{ {
auto driver = (const game_driver *)menu_event->itemref; const game_driver *driver = (const game_driver *)menu_event->itemref;
if ((FPTR)driver > skip_main_items && mame_machine_manager::instance()->datfile().has_data(driver)) if ((FPTR)driver > skip_main_items && mame_machine_manager::instance()->datfile().has_data(driver))
menu::stack_push<menu_dats_view>(ui(), container, driver); menu::stack_push<menu_dats_view>(ui(), container, driver);
} }
else else
{ {
auto ui_swinfo = (ui_software_info *)menu_event->itemref; ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref;
auto mdat = mame_machine_manager::instance()->datfile(); datfile_manager &mdat = mame_machine_manager::instance()->datfile();
if ((FPTR)ui_swinfo > skip_main_items) if ((FPTR)ui_swinfo > skip_main_items)
{ {
@ -372,10 +372,10 @@ void menu_select_game::handle()
// handle UI_FAVORITES // handle UI_FAVORITES
if (!isfavorite()) if (!isfavorite())
{ {
auto driver = (const game_driver *)menu_event->itemref; const game_driver *driver = (const game_driver *)menu_event->itemref;
if ((FPTR)driver > skip_main_items) if ((FPTR)driver > skip_main_items)
{ {
auto mfav = mame_machine_manager::instance()->favorite(); favorite_manager &mfav = mame_machine_manager::instance()->favorite();
if (!mfav.isgame_favorite(driver)) if (!mfav.isgame_favorite(driver))
{ {
mfav.add_favorite_game(driver); mfav.add_favorite_game(driver);
@ -391,7 +391,7 @@ void menu_select_game::handle()
} }
else else
{ {
auto swinfo = (ui_software_info *)menu_event->itemref; ui_software_info *swinfo = (ui_software_info *)menu_event->itemref;
if ((FPTR)swinfo > skip_main_items) if ((FPTR)swinfo > skip_main_items)
{ {
machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname.c_str()); machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname.c_str());
@ -632,7 +632,7 @@ void menu_select_game::populate()
void menu_select_game::build_available_list() void menu_select_game::build_available_list()
{ {
auto m_total = driver_list::total(); int m_total = driver_list::total();
std::vector<bool> m_included(m_total, false); std::vector<bool> m_included(m_total, false);
// open a path to the ROMs and find them in the array // open a path to the ROMs and find them in the array
@ -651,7 +651,7 @@ void menu_select_game::build_available_list()
*dst++ = tolower((UINT8) * src); *dst++ = tolower((UINT8) * src);
*dst = 0; *dst = 0;
auto drivnum = driver_list::find(drivername); int drivnum = driver_list::find(drivername);
if (drivnum != -1 && !m_included[drivnum]) if (drivnum != -1 && !m_included[drivnum])
{ {
m_availsortedlist.push_back(&driver_list::driver(drivnum)); m_availsortedlist.push_back(&driver_list::driver(drivnum));
@ -667,8 +667,8 @@ void menu_select_game::build_available_list()
auto driver = &driver_list::driver(x); auto driver = &driver_list::driver(x);
if (!m_included[x] && driver != &GAME_NAME(___empty)) if (!m_included[x] && driver != &GAME_NAME(___empty))
{ {
auto rom = driver->rom; const rom_entry *rom = driver->rom;
auto noroms = true; bool noroms = true;
// check NO-DUMP // check NO-DUMP
for (; !ROMENTRY_ISEND(rom) && noroms == true; ++rom) for (; !ROMENTRY_ISEND(rom) && noroms == true; ++rom)
@ -754,9 +754,9 @@ void menu_select_game::custom_render(void *selectedref, float top, float bottom,
float width, maxwidth = origx2 - origx1; float width, maxwidth = origx2 - origx1;
std::string tempbuf[5]; std::string tempbuf[5];
rgb_t color = UI_BACKGROUND_COLOR; rgb_t color = UI_BACKGROUND_COLOR;
auto isstar = false; bool isstar = false;
auto inifile = mame_machine_manager::instance()->inifile(); inifile_manager &inifile = mame_machine_manager::instance()->inifile();
auto tbarspace = ui().get_line_height(); float tbarspace = ui().get_line_height();
float text_size = 1.0f; float text_size = 1.0f;
tempbuf[0] = string_format(_("%1$s %2$s ( %3$d / %4$d machines (%5$d BIOS) )"), tempbuf[0] = string_format(_("%1$s %2$s ( %3$d / %4$d machines (%5$d BIOS) )"),

View File

@ -125,16 +125,14 @@ bool has_multiple_bios(const game_driver *driver, s_bios &biosname)
// ctor // ctor
//------------------------------------------------- //-------------------------------------------------
menu_select_software::menu_select_software(mame_ui_manager &mui, render_container *container, const game_driver *driver) menu_select_software::menu_select_software(mame_ui_manager &mui, render_container *container, const game_driver *driver) : menu(mui, container)
: menu(mui, container)
{ {
if (reselect_last::get()) if (reselect_last::get())
reselect_last::set(false); reselect_last::set(false);
sw_filters::actual = 0; sw_filters::actual = 0;
highlight = 0; highlight = 0;
m_has_empty_start = false;
m_searchlist.fill(nullptr);
m_driver = driver; m_driver = driver;
build_software_list(); build_software_list();
load_sw_custom_filters(); load_sw_custom_filters();
@ -471,17 +469,16 @@ void menu_select_software::populate()
} }
// iterate over entries // iterate over entries
int curitem = 0; for (size_t curitem = 0; curitem < m_displaylist.size(); ++curitem)
for (auto & e : m_displaylist)
{ {
if (reselect_last::software == "[Start empty]" && !reselect_last::driver.empty()) if (reselect_last::software == "[Start empty]" && !reselect_last::driver.empty())
old_software = 0; old_software = 0;
else if (e->shortname == reselect_last::software && e->listname == reselect_last::swlist) else if (m_displaylist[curitem]->shortname == reselect_last::software && m_displaylist[curitem]->listname == reselect_last::swlist)
old_software = m_has_empty_start ? curitem + 1 : curitem; old_software = m_has_empty_start ? curitem + 1 : curitem;
item_append(e->longname, e->devicetype, e->parentname.empty() ? flags_ui : (FLAG_INVERT | flags_ui), (void *)e); item_append(m_displaylist[curitem]->longname, m_displaylist[curitem]->devicetype,
curitem++; m_displaylist[curitem]->parentname.empty() ? flags_ui : (FLAG_INVERT | flags_ui), (void *)m_displaylist[curitem]);
} }
} }
@ -489,7 +486,7 @@ void menu_select_software::populate()
{ {
find_matches(m_search, VISIBLE_GAMES_IN_SEARCH); find_matches(m_search, VISIBLE_GAMES_IN_SEARCH);
for (int curitem = 0; m_searchlist[curitem]; ++curitem) for (int curitem = 0; m_searchlist[curitem] != nullptr; ++curitem)
item_append(m_searchlist[curitem]->longname, m_searchlist[curitem]->devicetype, item_append(m_searchlist[curitem]->longname, m_searchlist[curitem]->devicetype,
m_searchlist[curitem]->parentname.empty() ? flags_ui : (FLAG_INVERT | flags_ui), m_searchlist[curitem]->parentname.empty() ? flags_ui : (FLAG_INVERT | flags_ui),
(void *)m_searchlist[curitem]); (void *)m_searchlist[curitem]);
@ -506,6 +503,7 @@ void menu_select_software::populate()
selected = old_software; selected = old_software;
top_line = selected - (ui_globals::visible_sw_lines / 2); top_line = selected - (ui_globals::visible_sw_lines / 2);
} }
reselect_last::reset(); reselect_last::reset();
} }
@ -587,7 +585,7 @@ void menu_select_software::build_software_list()
if (!m_swinfo[y].parentname.empty()) if (!m_swinfo[y].parentname.empty())
{ {
std::string lparent(m_swinfo[y].parentname); std::string lparent(m_swinfo[y].parentname);
auto found = false; bool found = false;
// first scan backward // first scan backward
for (int x = y; x > 0; --x) for (int x = y; x > 0; --x)
@ -661,13 +659,13 @@ void menu_select_software::custom_render(void *selectedref, float top, float bot
const game_driver *driver = nullptr; const game_driver *driver = nullptr;
float width; float width;
std::string tempbuf[5], filtered; std::string tempbuf[5], filtered;
auto color = UI_BACKGROUND_COLOR; rgb_t color = UI_BACKGROUND_COLOR;
auto isstar = false; bool isstar = false;
float tbarspace = ui().get_line_height(); float tbarspace = ui().get_line_height();
float text_size = 1.0f; float text_size = 1.0f;
// determine the text for the header // determine the text for the header
auto vis_item = (m_search[0] != 0) ? visible_items : (m_has_empty_start ? visible_items - 1 : visible_items); int vis_item = (m_search[0] != 0) ? visible_items : (m_has_empty_start ? visible_items - 1 : visible_items);
tempbuf[0] = string_format(_("%1$s %2$s ( %3$d / %4$d software packages )"), emulator_info::get_appname(), bare_build_version, vis_item, m_swinfo.size() - 1); tempbuf[0] = string_format(_("%1$s %2$s ( %3$d / %4$d software packages )"), emulator_info::get_appname(), bare_build_version, vis_item, m_swinfo.size() - 1);
tempbuf[1] = string_format(_("Driver: \"%1$s\" software list "), m_driver->description); tempbuf[1] = string_format(_("Driver: \"%1$s\" software list "), m_driver->description);
@ -883,8 +881,8 @@ void menu_select_software::custom_render(void *selectedref, float top, float bot
void menu_select_software::inkey_select(const event *menu_event) void menu_select_software::inkey_select(const event *menu_event)
{ {
auto ui_swinfo = (ui_software_info *)menu_event->itemref; ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref;
auto mopt = ui().options(); ui_options &mopt = ui().options();
if (ui_swinfo->startempty == 1) if (ui_swinfo->startempty == 1)
{ {
@ -909,10 +907,10 @@ void menu_select_software::inkey_select(const event *menu_event)
driver_enumerator drivlist(machine().options(), *ui_swinfo->driver); driver_enumerator drivlist(machine().options(), *ui_swinfo->driver);
media_auditor auditor(drivlist); media_auditor auditor(drivlist);
drivlist.next(); drivlist.next();
auto swlist = software_list_device::find_by_name(drivlist.config(), ui_swinfo->listname.c_str()); software_list_device *swlist = software_list_device::find_by_name(drivlist.config(), ui_swinfo->listname.c_str());
auto swinfo = swlist->find(ui_swinfo->shortname.c_str()); software_info *swinfo = swlist->find(ui_swinfo->shortname.c_str());
auto summary = auditor.audit_software(swlist->list_name(), swinfo, AUDIT_VALIDATE_FAST); media_auditor::summary summary = auditor.audit_software(swlist->list_name(), swinfo, AUDIT_VALIDATE_FAST);
if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED) if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED)
{ {
@ -1069,7 +1067,7 @@ void menu_select_software::load_sw_custom_filters()
// get number of filters // get number of filters
file.gets(buffer, MAX_CHAR_INFO); file.gets(buffer, MAX_CHAR_INFO);
auto pb = strchr(buffer, '='); char *pb = strchr(buffer, '=');
sw_custfltr::numother = atoi(++pb) - 1; sw_custfltr::numother = atoi(++pb) - 1;
// get main filter // get main filter
@ -1086,8 +1084,8 @@ void menu_select_software::load_sw_custom_filters()
for (int x = 1; x <= sw_custfltr::numother; ++x) for (int x = 1; x <= sw_custfltr::numother; ++x)
{ {
file.gets(buffer, MAX_CHAR_INFO); file.gets(buffer, MAX_CHAR_INFO);
auto cb = strchr(buffer, '=') + 2; char *cb = strchr(buffer, '=') + 2;
for (int y = 0; y < sw_filters::length; ++y) for (int y = 0; y < sw_filters::length; y++)
{ {
if (!strncmp(cb, sw_filters::text[y], strlen(sw_filters::text[y]))) if (!strncmp(cb, sw_filters::text[y], strlen(sw_filters::text[y])))
{ {
@ -1156,11 +1154,11 @@ std::string c_sw_region::getname(std::string &str)
{ {
std::string fullname(str); std::string fullname(str);
strmakelower(fullname); strmakelower(fullname);
auto found = fullname.find("("); size_t found = fullname.find("(");
if (found != std::string::npos) if (found != std::string::npos)
{ {
auto ends = fullname.find_first_not_of("abcdefghijklmnopqrstuvwxyz", found + 1); size_t ends = fullname.find_first_not_of("abcdefghijklmnopqrstuvwxyz", found + 1);
std::string temp(fullname.substr(found + 1, ends - found - 1)); std::string temp(fullname.substr(found + 1, ends - found - 1));
for (auto & elem : region_lists) for (auto & elem : region_lists)
@ -1200,7 +1198,7 @@ void c_sw_year::set(std::string &str)
void c_sw_publisher::set(std::string &str) void c_sw_publisher::set(std::string &str)
{ {
auto name = getname(str); std::string name = getname(str);
if (std::find(ui.begin(), ui.end(), name) != ui.end()) if (std::find(ui.begin(), ui.end(), name) != ui.end())
return; return;
@ -1209,7 +1207,7 @@ void c_sw_publisher::set(std::string &str)
std::string c_sw_publisher::getname(std::string &str) std::string c_sw_publisher::getname(std::string &str)
{ {
auto found = str.find("("); size_t found = str.find("(");
if (found != std::string::npos) if (found != std::string::npos)
return (str.substr(0, found - 1)); return (str.substr(0, found - 1));
@ -1270,7 +1268,7 @@ void menu_select_software::build_list(std::vector<ui_software_info *> &s_drivers
case UI_SW_REGION: case UI_SW_REGION:
{ {
auto name = m_filter.region.getname(s_driver->longname); std::string name = m_filter.region.getname(s_driver->longname);
if(!name.empty() && name == filter_text) if(!name.empty() && name == filter_text)
m_displaylist.push_back(s_driver); m_displaylist.push_back(s_driver);
@ -1279,7 +1277,7 @@ void menu_select_software::build_list(std::vector<ui_software_info *> &s_drivers
case UI_SW_PUBLISHERS: case UI_SW_PUBLISHERS:
{ {
auto name = m_filter.publisher.getname(s_driver->publisher); std::string name = m_filter.publisher.getname(s_driver->publisher);
if(!name.empty() && name == filter_text) if(!name.empty() && name == filter_text)
m_displaylist.push_back(s_driver); m_displaylist.push_back(s_driver);
@ -1400,8 +1398,8 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
float l_height = ui().get_line_height(); float l_height = ui().get_line_height();
float line_height = l_height * text_size; float line_height = l_height * text_size;
float left_width = 0.0f; float left_width = 0.0f;
auto text_lenght = sw_filters::length; int text_lenght = sw_filters::length;
auto afilter = sw_filters::actual; int afilter = sw_filters::actual;
int phover = HOVER_SW_FILTER_FIRST; int phover = HOVER_SW_FILTER_FIRST;
const char **text = sw_filters::text; const char **text = sw_filters::text;
float sc = y2 - y1 - (2.0f * UI_BOX_TB_BORDER); float sc = y2 - y1 - (2.0f * UI_BOX_TB_BORDER);
@ -1413,11 +1411,13 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
line_height = l_height * text_size; line_height = l_height * text_size;
} }
auto text_sign = ui().get_string_width("_# ", text_size); float text_sign = ui().get_string_width("_# ", text_size);
for (int x = 0; x < text_lenght; ++x) for (int x = 0; x < text_lenght; ++x)
{ {
float total_width;
// compute width of left hand side // compute width of left hand side
auto total_width = ui().get_string_width(text[x], text_size); total_width = ui().get_string_width(text[x], text_size);
total_width += text_sign; total_width += text_sign;
// track the maximum // track the maximum
@ -1498,7 +1498,7 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
y2 = origy2; y2 = origy2;
float space = x2 - x1; float space = x2 - x1;
float lr_arrow_width = 0.4f * space * machine().render().ui_aspect(); float lr_arrow_width = 0.4f * space * machine().render().ui_aspect();
auto fgcolor = UI_TEXT_COLOR; rgb_t fgcolor = UI_TEXT_COLOR;
// set left-right arrows dimension // set left-right arrows dimension
float ar_x0 = 0.5f * (x2 + x1) - 0.5f * lr_arrow_width; float ar_x0 = 0.5f * (x2 + x1) - 0.5f * lr_arrow_width;
@ -1521,7 +1521,7 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float
{ {
float space = x2 - x1; float space = x2 - x1;
float lr_arrow_width = 0.4f * space * machine().render().ui_aspect(); float lr_arrow_width = 0.4f * space * machine().render().ui_aspect();
auto fgcolor = UI_TEXT_COLOR; rgb_t fgcolor = UI_TEXT_COLOR;
// set left-right arrows dimension // set left-right arrows dimension
float ar_x0 = 0.5f * (x2 + x1) - 0.5f * lr_arrow_width; float ar_x0 = 0.5f * (x2 + x1) - 0.5f * lr_arrow_width;

View File

@ -44,7 +44,7 @@ private:
s_filter m_filter; s_filter m_filter;
int highlight; int highlight;
std::array<ui_software_info *, VISIBLE_GAMES_IN_SEARCH + 1> m_searchlist; ui_software_info *m_searchlist[VISIBLE_GAMES_IN_SEARCH + 1];
std::vector<ui_software_info *> m_displaylist, m_tmp, m_sortedlist; std::vector<ui_software_info *> m_displaylist, m_tmp, m_sortedlist;
std::vector<ui_software_info> m_swinfo; std::vector<ui_software_info> m_swinfo;

View File

@ -33,7 +33,7 @@ public:
private: private:
// internal state // internal state
enum { VISIBLE_GAMES_IN_LIST = 15 }; enum { VISIBLE_GAMES_IN_LIST = 15 };
bool m_error; UINT8 m_error;
bool m_rerandomize; bool m_rerandomize;
char m_search[40]; char m_search[40];
int m_matchlist[VISIBLE_GAMES_IN_LIST]; int m_matchlist[VISIBLE_GAMES_IN_LIST];

View File

@ -153,10 +153,10 @@ menu_slot_devices::menu_slot_devices(mame_ui_manager &mui, render_container *con
void menu_slot_devices::populate() void menu_slot_devices::populate()
{ {
// cycle through all devices for this system /* cycle through all devices for this system */
for (device_slot_interface &slot : slot_interface_iterator(machine().root_device())) for (device_slot_interface &slot : slot_interface_iterator(machine().root_device()))
{ {
// record the menu item /* record the menu item */
const device_slot_option *option = slot_get_current_option(slot); const device_slot_option *option = slot_get_current_option(slot);
std::string opt_name; std::string opt_name;
if (option == nullptr) if (option == nullptr)
@ -184,7 +184,7 @@ menu_slot_devices::~menu_slot_devices()
void menu_slot_devices::handle() void menu_slot_devices::handle()
{ {
// process the menu /* process the menu */
const event *menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)

View File

@ -21,10 +21,9 @@ const int menu_sound_options::m_sound_rate[] = { 11025, 22050, 44100, 48000 };
// ctor // ctor
//------------------------------------------------- //-------------------------------------------------
menu_sound_options::menu_sound_options(mame_ui_manager &mui, render_container *container) menu_sound_options::menu_sound_options(mame_ui_manager &mui, render_container *container) : menu(mui, container)
: menu(mui, container)
{ {
auto options = downcast<osd_options &>(mui.machine().options()); osd_options &options = downcast<osd_options &>(mui.machine().options());
m_sample_rate = mui.machine().options().sample_rate(); m_sample_rate = mui.machine().options().sample_rate();
m_sound = (strcmp(options.sound(), OSDOPTVAL_NONE) && strcmp(options.sound(), "0")); m_sound = (strcmp(options.sound(), OSDOPTVAL_NONE) && strcmp(options.sound(), "0"));
@ -32,7 +31,7 @@ menu_sound_options::menu_sound_options(mame_ui_manager &mui, render_container *c
int total = ARRAY_LENGTH(m_sound_rate); int total = ARRAY_LENGTH(m_sound_rate);
for (m_cur_rates = 0; m_cur_rates < total; ++m_cur_rates) for (m_cur_rates = 0; m_cur_rates < total; m_cur_rates++)
if (m_sample_rate == m_sound_rate[m_cur_rates]) if (m_sample_rate == m_sound_rate[m_cur_rates])
break; break;
@ -47,21 +46,19 @@ menu_sound_options::menu_sound_options(mame_ui_manager &mui, render_container *c
menu_sound_options::~menu_sound_options() menu_sound_options::~menu_sound_options()
{ {
std::string error_string; std::string error_string;
auto moptions = machine().options(); emu_options &moptions = machine().options();
if (strcmp(moptions.value(OSDOPTION_SOUND), m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE) != 0) if (strcmp(moptions.value(OSDOPTION_SOUND),m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE)!=0)
{ {
moptions.set_value(OSDOPTION_SOUND, m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE, OPTION_PRIORITY_CMDLINE, error_string); moptions.set_value(OSDOPTION_SOUND, m_sound ? OSDOPTVAL_AUTO : OSDOPTVAL_NONE, OPTION_PRIORITY_CMDLINE, error_string);
machine().options().mark_changed(OSDOPTION_SOUND); machine().options().mark_changed(OSDOPTION_SOUND);
} }
if (moptions.int_value(OPTION_SAMPLERATE)!=m_sound_rate[m_cur_rates])
if (moptions.int_value(OPTION_SAMPLERATE) != m_sound_rate[m_cur_rates])
{ {
moptions.set_value(OPTION_SAMPLERATE, m_sound_rate[m_cur_rates], OPTION_PRIORITY_CMDLINE, error_string); moptions.set_value(OPTION_SAMPLERATE, m_sound_rate[m_cur_rates], OPTION_PRIORITY_CMDLINE, error_string);
machine().options().mark_changed(OPTION_SAMPLERATE); machine().options().mark_changed(OPTION_SAMPLERATE);
} }
if (moptions.bool_value(OPTION_SAMPLES)!=m_samples)
if (moptions.bool_value(OPTION_SAMPLES) != m_samples)
{ {
moptions.set_value(OPTION_SAMPLES, m_samples, OPTION_PRIORITY_CMDLINE, error_string); moptions.set_value(OPTION_SAMPLES, m_samples, OPTION_PRIORITY_CMDLINE, error_string);
machine().options().mark_changed(OPTION_SAMPLES); machine().options().mark_changed(OPTION_SAMPLES);
@ -74,17 +71,17 @@ menu_sound_options::~menu_sound_options()
void menu_sound_options::handle() void menu_sound_options::handle()
{ {
auto changed = false; bool changed = false;
// process the menu // process the menu
auto event = process(0); const event *menu_event = process(0);
if (event != nullptr && event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
switch ((FPTR)event->itemref) switch ((FPTR)menu_event->itemref)
{ {
case ENABLE_SOUND: case ENABLE_SOUND:
if (event->iptkey == IPT_UI_LEFT || event->iptkey == IPT_UI_RIGHT || event->iptkey == IPT_UI_SELECT) if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT)
{ {
m_sound = !m_sound; m_sound = !m_sound;
changed = true; changed = true;
@ -92,23 +89,24 @@ void menu_sound_options::handle()
break; break;
case SAMPLE_RATE: case SAMPLE_RATE:
if (event->iptkey == IPT_UI_LEFT || event->iptkey == IPT_UI_RIGHT) if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
{ {
(event->iptkey == IPT_UI_LEFT) ? m_cur_rates-- : m_cur_rates++; (menu_event->iptkey == IPT_UI_LEFT) ? m_cur_rates-- : m_cur_rates++;
changed = true; changed = true;
} }
else if (event->iptkey == IPT_UI_SELECT) else if (menu_event->iptkey == IPT_UI_SELECT)
{ {
std::vector<std::string> s_sel; int total = ARRAY_LENGTH(m_sound_rate);
for (auto e : m_sound_rate) std::vector<std::string> s_sel(total);
s_sel.emplace_back(std::to_string(e)); for (int index = 0; index < total; index++)
s_sel[index] = std::to_string(m_sound_rate[index]);
menu::stack_push<menu_selector>(ui(), container, std::move(s_sel), m_cur_rates); menu::stack_push<menu_selector>(ui(), container, s_sel, m_cur_rates);
} }
break; break;
case ENABLE_SAMPLES: case ENABLE_SAMPLES:
if (event->iptkey == IPT_UI_LEFT || event->iptkey == IPT_UI_RIGHT || event->iptkey == IPT_UI_SELECT) if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT)
{ {
m_samples = !m_samples; m_samples = !m_samples;
changed = true; changed = true;
@ -128,7 +126,7 @@ void menu_sound_options::handle()
void menu_sound_options::populate() void menu_sound_options::populate()
{ {
auto arrow_flags = get_arrow_flags(0, ARRAY_LENGTH(m_sound_rate) - 1, m_cur_rates); UINT32 arrow_flags = get_arrow_flags(0, ARRAY_LENGTH(m_sound_rate) - 1, m_cur_rates);
m_sample_rate = m_sound_rate[m_cur_rates]; m_sample_rate = m_sound_rate[m_cur_rates];
// add options items // add options items
@ -148,7 +146,7 @@ void menu_sound_options::custom_render(void *selectedref, float top, float botto
{ {
float width; float width;
ui().draw_text_full(container, _("Sound Options"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, _("Sound Options"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width); float maxwidth = MAX(origx2 - origx1, width);
@ -168,7 +166,7 @@ void menu_sound_options::custom_render(void *selectedref, float top, float botto
// draw the text within it // draw the text within it
ui().draw_text_full(container, _("Sound Options"), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, _("Sound Options"), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
} }
} // namespace ui } // namespace ui

View File

@ -124,7 +124,9 @@ std::vector<submenu::option> submenu::video_options = {
//------------------------------------------------- //-------------------------------------------------
submenu::submenu(mame_ui_manager &mui, render_container *container, std::vector<option> &suboptions, const game_driver *drv, emu_options *options) submenu::submenu(mame_ui_manager &mui, render_container *container, std::vector<option> &suboptions, const game_driver *drv, emu_options *options)
: menu(mui, container), m_options(suboptions), m_driver(drv) : menu(mui, container)
, m_options(suboptions)
, m_driver(drv)
{ {
core_options *opts = nullptr; core_options *opts = nullptr;
if (m_driver == nullptr) if (m_driver == nullptr)
@ -206,17 +208,17 @@ submenu::~submenu()
void submenu::handle() void submenu::handle()
{ {
auto changed = false; bool changed = false;
std::string error_string, tmptxt; std::string error_string, tmptxt;
float f_cur, f_step; float f_cur, f_step;
// process the menu // process the menu
auto menu_event = process(PROCESS_LR_REPEAT); const event *menu_event = process(PROCESS_LR_REPEAT);
if (menu_event != nullptr && menu_event->itemref != nullptr && if (menu_event != nullptr && menu_event->itemref != nullptr &&
(menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT)) (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT))
{ {
auto sm_option = *reinterpret_cast<option *>(menu_event->itemref); option &sm_option = *reinterpret_cast<option *>(menu_event->itemref);
switch (sm_option.type) switch (sm_option.type)
{ {
@ -234,7 +236,7 @@ void submenu::handle()
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; changed = true;
auto i_cur = atoi(sm_option.entry->value()); int i_cur = atoi(sm_option.entry->value());
(menu_event->iptkey == IPT_UI_LEFT) ? i_cur-- : i_cur++; (menu_event->iptkey == IPT_UI_LEFT) ? i_cur-- : i_cur++;
sm_option.options->set_value(sm_option.name, i_cur, OPTION_PRIORITY_CMDLINE, error_string); sm_option.options->set_value(sm_option.name, i_cur, OPTION_PRIORITY_CMDLINE, error_string);
sm_option.entry->mark_changed(); sm_option.entry->mark_changed();
@ -249,20 +251,22 @@ void submenu::handle()
{ {
f_step = atof(sm_option.entry->minimum()); f_step = atof(sm_option.entry->minimum());
if (f_step <= 0.0f) { if (f_step <= 0.0f) {
auto pmin = getprecisionchr(sm_option.entry->minimum()); int pmin = getprecisionchr(sm_option.entry->minimum());
auto pmax = getprecisionchr(sm_option.entry->maximum()); int pmax = getprecisionchr(sm_option.entry->maximum());
tmptxt = '1' + std::string((pmin > pmax) ? pmin : pmax, '0'); tmptxt = '1' + std::string((pmin > pmax) ? pmin : pmax, '0');
f_step = 1 / atof(tmptxt.c_str()); f_step = 1 / atof(tmptxt.c_str());
} }
} }
else else
{ {
auto precision = getprecisionchr(sm_option.entry->default_value()); int precision = getprecisionchr(sm_option.entry->default_value());
tmptxt = '1' + std::string(precision, '0'); tmptxt = '1' + std::string(precision, '0');
f_step = 1 / atof(tmptxt.c_str()); f_step = 1 / atof(tmptxt.c_str());
} }
if (menu_event->iptkey == IPT_UI_LEFT)
(menu_event->iptkey == IPT_UI_LEFT) ? f_cur -= f_step : f_cur += f_step; f_cur -= f_step;
else
f_cur += f_step;
tmptxt = string_format("%g", f_cur); tmptxt = string_format("%g", f_cur);
sm_option.options->set_value(sm_option.name, tmptxt.c_str(), OPTION_PRIORITY_CMDLINE, error_string); sm_option.options->set_value(sm_option.name, tmptxt.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
sm_option.entry->mark_changed(); sm_option.entry->mark_changed();
@ -274,7 +278,10 @@ void submenu::handle()
changed = true; changed = true;
std::string v_cur(sm_option.entry->value()); std::string v_cur(sm_option.entry->value());
int cur_value = std::distance(sm_option.value.begin(), std::find(sm_option.value.begin(), sm_option.value.end(), v_cur)); int cur_value = std::distance(sm_option.value.begin(), std::find(sm_option.value.begin(), sm_option.value.end(), v_cur));
v_cur = (menu_event->iptkey == IPT_UI_LEFT) ? sm_option.value[--cur_value] : sm_option.value[++cur_value]; if (menu_event->iptkey == IPT_UI_LEFT)
v_cur = sm_option.value[--cur_value];
else
v_cur = sm_option.value[++cur_value];
sm_option.options->set_value(sm_option.name, v_cur.c_str(), OPTION_PRIORITY_CMDLINE, error_string); sm_option.options->set_value(sm_option.name, v_cur.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
sm_option.entry->mark_changed(); sm_option.entry->mark_changed();
} }
@ -364,7 +371,7 @@ void submenu::populate()
f_max = std::numeric_limits<float>::max(); f_max = std::numeric_limits<float>::max();
} }
arrow_flags = get_arrow_flags(f_min, f_max, f_cur); arrow_flags = get_arrow_flags(f_min, f_max, f_cur);
auto tmptxt = string_format("%g", f_cur); std::string tmptxt = string_format("%g", f_cur);
item_append(_(sm_option->description), item_append(_(sm_option->description),
tmptxt.c_str(), tmptxt.c_str(),
arrow_flags, arrow_flags,
@ -432,11 +439,11 @@ void submenu::custom_render(void *selectedref, float top, float bottom, float or
if (selectedref != nullptr) if (selectedref != nullptr)
{ {
auto selected_sm_option = *reinterpret_cast<option *>(selectedref); option &selected_sm_option = *reinterpret_cast<option *>(selectedref);
if (selected_sm_option.entry != nullptr) if (selected_sm_option.entry != nullptr)
{ {
ui().draw_text_full(container, selected_sm_option.entry->description(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(container, selected_sm_option.entry->description(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr); mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER; width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(origx2 - origx1, width); maxwidth = MAX(origx2 - origx1, width);
@ -457,7 +464,7 @@ void submenu::custom_render(void *selectedref, float top, float bottom, float or
// draw the text within it // draw the text within it
ui().draw_text_full(container, selected_sm_option.entry->description(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(container, selected_sm_option.entry->description(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr); mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
} }
} }
} }

View File

@ -21,7 +21,7 @@ namespace ui {
CONSTANTS CONSTANTS
***************************************************************************/ ***************************************************************************/
// time (in seconds) to display errors /* time (in seconds) to display errors */
#define ERROR_MESSAGE_TIME 5 #define ERROR_MESSAGE_TIME 5
@ -129,7 +129,6 @@ menu_software_list::menu_software_list(mame_ui_manager &mui, render_container *c
m_swlist = swlist; m_swlist = swlist;
m_interface = interface; m_interface = interface;
m_ordered_by_shortname = true; m_ordered_by_shortname = true;
memset(m_filename_buffer, '\0', ARRAY_LENGTH(m_filename_buffer));
} }

View File

@ -32,20 +32,20 @@ class menu_item;
CONSTANTS CONSTANTS
***************************************************************************/ ***************************************************************************/
// preferred font height; use ui_get_line_height() to get actual height /* preferred font height; use ui_get_line_height() to get actual height */
#define UI_TARGET_FONT_ROWS get_font_rows() #define UI_TARGET_FONT_ROWS get_font_rows()
#define UI_TARGET_FONT_HEIGHT (1.0f / (float)UI_TARGET_FONT_ROWS) #define UI_TARGET_FONT_HEIGHT (1.0f / (float)UI_TARGET_FONT_ROWS)
#define UI_MAX_FONT_HEIGHT (1.0f / 15.0f) #define UI_MAX_FONT_HEIGHT (1.0f / 15.0f)
// width of lines drawn in the UI /* width of lines drawn in the UI */
#define UI_LINE_WIDTH (1.0f / 500.0f) #define UI_LINE_WIDTH (1.0f / 500.0f)
// border between outlines and inner text on left/right and top/bottom sides /* border between outlines and inner text on left/right and top/bottom sides */
#define UI_BOX_LR_BORDER (UI_TARGET_FONT_HEIGHT * 0.25f) #define UI_BOX_LR_BORDER (UI_TARGET_FONT_HEIGHT * 0.25f)
#define UI_BOX_TB_BORDER (UI_TARGET_FONT_HEIGHT * 0.25f) #define UI_BOX_TB_BORDER (UI_TARGET_FONT_HEIGHT * 0.25f)
// handy colors /* handy colors */
#define UI_GREEN_COLOR rgb_t(0xef,0x10,0x60,0x10) #define UI_GREEN_COLOR rgb_t(0xef,0x10,0x60,0x10)
#define UI_YELLOW_COLOR rgb_t(0xef,0x60,0x60,0x10) #define UI_YELLOW_COLOR rgb_t(0xef,0x60,0x60,0x10)
#define UI_RED_COLOR rgb_t(0xf0,0x60,0x10,0x10) #define UI_RED_COLOR rgb_t(0xf0,0x60,0x10,0x10)
@ -66,7 +66,7 @@ class menu_item;
#define UI_DIPSW_COLOR decode_ui_color(14) #define UI_DIPSW_COLOR decode_ui_color(14)
#define UI_SLIDER_COLOR decode_ui_color(15) #define UI_SLIDER_COLOR decode_ui_color(15)
// cancel return value for a UI handler /* cancel return value for a UI handler */
#define UI_HANDLER_CANCEL ((UINT32)~0) #define UI_HANDLER_CANCEL ((UINT32)~0)
#define SLIDER_DEVICE_SPACING 0x0ff #define SLIDER_DEVICE_SPACING 0x0ff

View File

@ -81,7 +81,7 @@ char* chartrimcarriage(char str[])
const char* strensure(const char* s) const char* strensure(const char* s)
{ {
return (s == nullptr) ? "" : s; return s == nullptr ? "" : s;
} }
int getprecisionchr(const char* s) int getprecisionchr(const char* s)
@ -100,11 +100,11 @@ std::vector<std::string> tokenize(const std::string &text, char sep)
std::size_t start = 0, end = 0; std::size_t start = 0, end = 0;
while ((end = text.find(sep, start)) != std::string::npos) while ((end = text.find(sep, start)) != std::string::npos)
{ {
auto temp = text.substr(start, end - start); std::string temp = text.substr(start, end - start);
if (!temp.empty()) tokens.push_back(temp); if (!temp.empty()) tokens.push_back(temp);
start = end + 1; start = end + 1;
} }
auto temp = text.substr(start); std::string temp = text.substr(start);
if (!temp.empty()) tokens.push_back(temp); if (!temp.empty()) tokens.push_back(temp);
return tokens; return tokens;
} }

View File

@ -22,8 +22,8 @@ namespace ui {
void menu_video_targets::handle() void menu_video_targets::handle()
{ {
// process the menu /* process the menu */
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT)
menu::stack_push<menu_video_options>(ui(), container, static_cast<render_target *>(menu_event->itemref)); menu::stack_push<menu_video_options>(ui(), container, static_cast<render_target *>(menu_event->itemref));
} }
@ -34,24 +34,25 @@ void menu_video_targets::handle()
video targets menu video targets menu
-------------------------------------------------*/ -------------------------------------------------*/
menu_video_targets::menu_video_targets(mame_ui_manager &mui, render_container *container) menu_video_targets::menu_video_targets(mame_ui_manager &mui, render_container *container) : menu(mui, container)
: menu(mui, container)
{ {
} }
void menu_video_targets::populate() void menu_video_targets::populate()
{ {
// find the targets int targetnum;
for (int targetnum = 0; ; ++targetnum)
/* find the targets */
for (targetnum = 0; ; targetnum++)
{ {
auto target = machine().render().target_by_index(targetnum); render_target *target = machine().render().target_by_index(targetnum);
char buffer[40]; char buffer[40];
// stop when we run out /* stop when we run out */
if (target == nullptr) if (target == nullptr)
break; break;
// add a menu item /* add a menu item */
sprintf(buffer, _("Screen #%d"), targetnum); sprintf(buffer, _("Screen #%d"), targetnum);
item_append(buffer, "", 0, target); item_append(buffer, "", 0, target);
} }
@ -68,21 +69,21 @@ menu_video_targets::~menu_video_targets()
void menu_video_options::handle() void menu_video_options::handle()
{ {
auto changed = false; bool changed = false;
// process the menu /* process the menu */
auto menu_event = process(0); const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event != nullptr && menu_event->itemref != nullptr)
{ {
switch ((FPTR)menu_event->itemref) switch ((FPTR)menu_event->itemref)
{ {
// rotate adds rotation depending on the direction /* rotate adds rotation depending on the direction */
case VIDEO_ITEM_ROTATE: case VIDEO_ITEM_ROTATE:
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)
{ {
int delta = (menu_event->iptkey == IPT_UI_LEFT) ? ROT270 : ROT90; int delta = (menu_event->iptkey == IPT_UI_LEFT) ? ROT270 : ROT90;
m_target->set_orientation(orientation_add(delta, m_target->orientation())); target->set_orientation(orientation_add(delta, target->orientation()));
if (m_target->is_ui_target()) if (target->is_ui_target())
{ {
render_container::user_settings settings; render_container::user_settings settings;
container->get_user_settings(settings); container->get_user_settings(settings);
@ -93,11 +94,11 @@ void menu_video_options::handle()
} }
break; break;
// layer config bitmasks handle left/right keys the same (toggle) /* layer config bitmasks handle left/right keys the same (toggle) */
case VIDEO_ITEM_BACKDROPS: case VIDEO_ITEM_BACKDROPS:
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)
{ {
m_target->set_backdrops_enabled(!m_target->backdrops_enabled()); target->set_backdrops_enabled(!target->backdrops_enabled());
changed = true; changed = true;
} }
break; break;
@ -105,7 +106,7 @@ void menu_video_options::handle()
case VIDEO_ITEM_OVERLAYS: case VIDEO_ITEM_OVERLAYS:
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)
{ {
m_target->set_overlays_enabled(!m_target->overlays_enabled()); target->set_overlays_enabled(!target->overlays_enabled());
changed = true; changed = true;
} }
break; break;
@ -113,7 +114,7 @@ void menu_video_options::handle()
case VIDEO_ITEM_BEZELS: case VIDEO_ITEM_BEZELS:
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)
{ {
m_target->set_bezels_enabled(!m_target->bezels_enabled()); target->set_bezels_enabled(!target->bezels_enabled());
changed = true; changed = true;
} }
break; break;
@ -121,7 +122,7 @@ void menu_video_options::handle()
case VIDEO_ITEM_CPANELS: case VIDEO_ITEM_CPANELS:
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)
{ {
m_target->set_cpanels_enabled(!m_target->cpanels_enabled()); target->set_cpanels_enabled(!target->cpanels_enabled());
changed = true; changed = true;
} }
break; break;
@ -129,7 +130,7 @@ void menu_video_options::handle()
case VIDEO_ITEM_MARQUEES: case VIDEO_ITEM_MARQUEES:
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)
{ {
m_target->set_marquees_enabled(!m_target->marquees_enabled()); target->set_marquees_enabled(!target->marquees_enabled());
changed = true; changed = true;
} }
break; break;
@ -137,23 +138,23 @@ void menu_video_options::handle()
case VIDEO_ITEM_ZOOM: case VIDEO_ITEM_ZOOM:
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)
{ {
m_target->set_zoom_to_screen(!m_target->zoom_to_screen()); target->set_zoom_to_screen(!target->zoom_to_screen());
changed = true; changed = true;
} }
break; break;
// anything else is a view item /* anything else is a view item */
default: default:
if (menu_event->iptkey == IPT_UI_SELECT && (int)(FPTR)menu_event->itemref >= VIDEO_ITEM_VIEW) if (menu_event->iptkey == IPT_UI_SELECT && (int)(FPTR)menu_event->itemref >= VIDEO_ITEM_VIEW)
{ {
m_target->set_view((FPTR)menu_event->itemref - VIDEO_ITEM_VIEW); target->set_view((FPTR)menu_event->itemref - VIDEO_ITEM_VIEW);
changed = true; changed = true;
} }
break; break;
} }
} }
// if something changed, rebuild the menu /* if something changed, rebuild the menu */
if (changed) if (changed)
reset(reset_options::REMEMBER_REF); reset(reset_options::REMEMBER_REF);
} }
@ -164,36 +165,36 @@ void menu_video_options::handle()
video options menu video options menu
-------------------------------------------------*/ -------------------------------------------------*/
menu_video_options::menu_video_options(mame_ui_manager &mui, render_container *container, render_target *_target) menu_video_options::menu_video_options(mame_ui_manager &mui, render_container *container, render_target *_target) : menu(mui, container)
: menu(mui, container)
, m_target(_target)
{ {
target = _target;
} }
void menu_video_options::populate() void menu_video_options::populate()
{ {
const char *subtext = ""; const char *subtext = "";
std::string tempstring; std::string tempstring;
bool enabled; int viewnum;
int enabled;
// add items for each view /* add items for each view */
for (int viewnum = 0; ; ++viewnum) for (viewnum = 0; ; viewnum++)
{ {
const char *name = m_target->view_name(viewnum); const char *name = target->view_name(viewnum);
if (name == nullptr) if (name == nullptr)
break; break;
// create a string for the item, replacing underscores with spaces /* create a string for the item, replacing underscores with spaces */
tempstring.assign(name); tempstring.assign(name);
strreplace(tempstring, "_", " "); strreplace(tempstring, "_", " ");
item_append(tempstring, "", 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum)); item_append(tempstring, "", 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum));
} }
// add a separator /* add a separator */
item_append(menu_item_type::SEPARATOR); item_append(menu_item_type::SEPARATOR);
// add a rotate item /* add a rotate item */
switch (m_target->orientation()) switch (target->orientation())
{ {
case ROT0: subtext = "None"; break; case ROT0: subtext = "None"; break;
case ROT90: subtext = "CW 90" UTF8_DEGREES; break; case ROT90: subtext = "CW 90" UTF8_DEGREES; break;
@ -202,28 +203,28 @@ void menu_video_options::populate()
} }
item_append(_("Rotate"), subtext, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_ROTATE); item_append(_("Rotate"), subtext, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_ROTATE);
// backdrop item /* backdrop item */
enabled = m_target->backdrops_enabled(); enabled = target->backdrops_enabled();
item_append(_("Backdrops"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BACKDROPS); item_append(_("Backdrops"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BACKDROPS);
// overlay item /* overlay item */
enabled = m_target->overlays_enabled(); enabled = target->overlays_enabled();
item_append(_("Overlays"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_OVERLAYS); item_append(_("Overlays"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_OVERLAYS);
// bezel item /* bezel item */
enabled = m_target->bezels_enabled(); enabled = target->bezels_enabled();
item_append(_("Bezels"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BEZELS); item_append(_("Bezels"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BEZELS);
// cpanel item /* cpanel item */
enabled = m_target->cpanels_enabled(); enabled = target->cpanels_enabled();
item_append(_("CPanels"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_CPANELS); item_append(_("CPanels"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_CPANELS);
// marquee item /* marquee item */
enabled = m_target->marquees_enabled(); enabled = target->marquees_enabled();
item_append(_("Marquees"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_MARQUEES); item_append(_("Marquees"), enabled ? _("Enabled") : _("Disabled"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_MARQUEES);
// cropping /* cropping */
enabled = m_target->zoom_to_screen(); enabled = target->zoom_to_screen();
item_append(_("View"), enabled ? _("Cropped") : _("Full"), enabled ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM); item_append(_("View"), enabled ? _("Cropped") : _("Full"), enabled ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM);
} }

View File

@ -45,7 +45,7 @@ private:
VIDEO_ITEM_VIEW VIDEO_ITEM_VIEW
}; };
render_target *m_target; render_target *target;
}; };
} // namespace ui } // namespace ui