Permalink
Browse files

Standardize "On"/"Off" items in UI menus. "On" is now consistently to…

… the right of "Off", as with DIP switches.
  • Loading branch information...
ajrhacker committed Jun 24, 2018
1 parent f5f123c commit d2fbefd97733188b4ceb2e3de963971b9e658813
@@ -292,19 +292,9 @@ void menu_autofire::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
is_first_button = false;
}
/* add an autofire item */
if (!autofire_toggle)
{
// item is enabled and can be switched to values on/off
item_append(field.name(), (settings.autofire ? _("On") : _("Off")),
(settings.autofire ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW), (void *)&field);
}
else
{
// item is disabled
item_append(field.name(), (settings.autofire ? _("On") : _("Off")),
FLAG_DISABLE | FLAG_INVERT, nullptr);
}
item_append_on_off(field.name(), settings.autofire, (autofire_toggle ? FLAG_DISABLE : FLAG_INVERT), (void *)&field);
}
}
}
@@ -333,8 +333,8 @@ void menu_font_ui::populate(float &customtop, float &custombottom)
#ifdef UI_WINDOWS
if (m_fonts[m_actual].first != "default")
{
item_append(_("Bold"), m_bold ? "On" : "Off", m_bold ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(uintptr_t)MUI_BOLD);
item_append(_("Italic"), m_italic ? "On" : "Off", m_italic ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(uintptr_t)MUI_ITALIC);
item_append_on_off(_("Bold"), m_bold, 0, (void *)(uintptr_t)MUI_BOLD);
item_append_on_off(_("Italic"), m_italic, 0, (void *)(uintptr_t)MUI_ITALIC);
}
#endif
@@ -405,6 +405,22 @@ void menu::item_append(std::string &&text, std::string &&subtext, uint32_t flags
}
//-------------------------------------------------
// item_append_on_off - append a new "On"/"Off"
// item to the end of the menu
//-------------------------------------------------
void menu::item_append_on_off(const std::string &text, bool state, uint32_t flags, void *ref, menu_item_type type)
{
if (state & FLAG_DISABLE)

This comment has been minimized.

Show comment
Hide comment
@pmackinlay

pmackinlay Jun 25, 2018

Contributor

This isn't right - state is a bool, presumably this should be: if (flags & FLAG_DISABLE)

@pmackinlay

pmackinlay Jun 25, 2018

Contributor

This isn't right - state is a bool, presumably this should be: if (flags & FLAG_DISABLE)

ref = nullptr;
else
flags |= state ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW;
item_append(std::string(text), state ? _("On") : _("Off"), flags, ref, type);
}
//-------------------------------------------------
// repopulate - repopulate menu items
//-------------------------------------------------
@@ -56,6 +56,7 @@ class menu
void item_append(std::string &&text, std::string &&subtext, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN);
void item_append(menu_item item);
void item_append(menu_item_type type, uint32_t flags = 0);
void item_append_on_off(const std::string &text, bool state, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN);
// Global initialization
static void init(running_machine &machine, ui_options &mopt);
@@ -892,8 +892,7 @@ void menu_plugins_configure::populate(float &customtop, float &custombottom)
if (curentry->type() != OPTION_HEADER)
{
auto enabled = !strcmp(curentry->value(), "1");
item_append(curentry->description(), enabled ? _("On") : _("Off"),
enabled ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(uintptr_t)curentry->name().c_str());
item_append_on_off(curentry->description(), enabled, 0, (void *)(uintptr_t)curentry->name().c_str());
}
}
item_append(menu_item_type::SEPARATOR);
@@ -132,9 +132,9 @@ void menu_sound_options::populate(float &customtop, float &custombottom)
m_sample_rate = m_sound_rate[m_cur_rates];
// add options items
item_append(_("Sound"), m_sound ? _("On") : _("Off"), m_sound ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(uintptr_t)ENABLE_SOUND);
item_append_on_off(_("Sound"), m_sound, 0, (void *)(uintptr_t)ENABLE_SOUND);
item_append(_("Sample Rate"), string_format("%d", m_sample_rate), arrow_flags, (void *)(uintptr_t)SAMPLE_RATE);
item_append(_("Use External Samples"), m_samples ? _("On") : _("Off"), m_samples ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)(uintptr_t)ENABLE_SAMPLES);
item_append_on_off(_("Use External Samples"), m_samples, 0, (void *)(uintptr_t)ENABLE_SAMPLES);
item_append(menu_item_type::SEPARATOR);
customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
@@ -342,10 +342,9 @@ void submenu::populate(float &customtop, float &custombottom)
switch (sm_option->entry->type())
{
case OPTION_BOOLEAN:
arrow_flags = sm_option->options->bool_value(sm_option->name) ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW;
item_append(_(sm_option->description),
(arrow_flags == FLAG_RIGHT_ARROW) ? "On" : "Off",
arrow_flags,
item_append_on_off(_(sm_option->description),
sm_option->options->bool_value(sm_option->name),
0,
static_cast<void*>(&(*sm_option)));
break;
case OPTION_INTEGER:

0 comments on commit d2fbefd

Please sign in to comment.