diff options
Diffstat (limited to 'src/frontend/mame/ui/cheatopt.cpp')
-rw-r--r-- | src/frontend/mame/ui/cheatopt.cpp | 119 |
1 files changed, 69 insertions, 50 deletions
diff --git a/src/frontend/mame/ui/cheatopt.cpp b/src/frontend/mame/ui/cheatopt.cpp index 6d86a4bacd7..b7d6852c3b9 100644 --- a/src/frontend/mame/ui/cheatopt.cpp +++ b/src/frontend/mame/ui/cheatopt.cpp @@ -36,19 +36,19 @@ namespace ui { void menu_cheat::handle() { - // process the menu - auto menu_event = process(PROCESS_LR_REPEAT); + /* process the menu */ + const event *menu_event = process(PROCESS_LR_REPEAT); - // handle events + /* handle events */ 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(); - // 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) { for (auto &curcheat : mame_machine_manager::instance()->cheat().entries()) @@ -56,34 +56,34 @@ void menu_cheat::handle() changed = true; } - // handle individual cheats + /* handle individual cheats */ 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; switch (menu_event->iptkey) { - // if selected, activate a oneshot + /* if selected, activate a oneshot */ case IPT_UI_SELECT: changed = curcheat->activate(); break; - // if cleared, reset to default value + /* if cleared, reset to default value */ case IPT_UI_CLEAR: changed = curcheat->select_default_state(); break; - // left decrements + /* left decrements */ case IPT_UI_LEFT: changed = curcheat->select_previous_state(); break; - // right increments + /* right increments */ case IPT_UI_RIGHT: changed = curcheat->select_next_state(); break; - // bring up display comment if one exists + /* bring up display comment if one exists */ case IPT_UI_DISPLAY_COMMENT: case IPT_UI_UP: 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) { - // 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(); - // display the reloaded cheats + /* display the reloaded cheats */ reset(reset_options::REMEMBER_REF); 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) + { menu::stack_push<menu_autofire>(ui(), container); + } - // if things changed, update + /* if things changed, update */ if (changed) reset(reset_options::REMEMBER_REF); } @@ -120,26 +122,26 @@ void menu_cheat::handle() menu_cheat_populate - populate the cheat menu -------------------------------------------------*/ -menu_cheat::menu_cheat(mame_ui_manager &mui, render_container *container) - : menu(mui, container) +menu_cheat::menu_cheat(mame_ui_manager &mui, render_container *container) : menu(mui, container) { } void menu_cheat::populate() { + /* iterate over cheats */ + std::string text; + std::string subtext; // add the autofire menu item_append(_("Autofire Settings"), "", 0, (void *)ITEMREF_CHEATS_AUTOFIRE_SETTINGS); - // add a separator + /* add a separator */ item_append(menu_item_type::SEPARATOR); // add other cheats if (!mame_machine_manager::instance()->cheat().entries().empty()) { for (auto &curcheat : mame_machine_manager::instance()->cheat().entries()) { - std::string text; - std::string subtext; UINT32 flags; curcheat->menu_text(text, subtext, flags); if (text == MENU_SEPARATOR_ITEM) @@ -148,13 +150,13 @@ void menu_cheat::populate() item_append(text, subtext, flags, curcheat.get()); } - // add a separator + /* add a 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); - // add a reload all cheats option + /* add a reload all cheats option */ 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 -------------------------------------------------*/ -menu_autofire::menu_autofire(mame_ui_manager &mui, render_container *container) - : menu(mui, container) - , last_toggle(false) +menu_autofire::menu_autofire(mame_ui_manager &mui, render_container *container) : menu(mui, container), last_toggle(false) { - auto screen = mui.machine().first_screen(); - refresh = (screen == nullptr) ? 60.0 : ATTOSECONDS_TO_HZ(screen->refresh_attoseconds()); + const screen_device *screen = mui.machine().first_screen(); + + if (screen == nullptr) + { + refresh = 60.0; + } + else + { + refresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds()); + } } menu_autofire::~menu_autofire() @@ -183,12 +195,12 @@ menu_autofire::~menu_autofire() void menu_autofire::handle() { ioport_field *field; - auto changed = false; + bool changed = false; - // process the menu - auto menu_event = process(0); + /* process the menu */ + const event *menu_event = process(0); - // handle events + /* handle events */ if (menu_event != nullptr && menu_event->itemref != nullptr) { // menu item is changed using left/right keys only @@ -197,14 +209,14 @@ void menu_autofire::handle() if (menu_event->itemref == ITEMREF_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); changed = true; } else if (menu_event->itemref == ITEMREF_AUTOFIRE_DELAY) { // 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) { autofire_delay--; @@ -235,11 +247,15 @@ void menu_autofire::handle() // if toggle settings changed, redraw menu to reflect new options if (!changed) + { changed = (last_toggle != machine().ioport().get_autofire_toggle()); + } - // if something changed, rebuild the menu + /* if something changed, rebuild the menu */ if (changed) + { reset(reset_options::REMEMBER_REF); + } } @@ -252,16 +268,16 @@ void menu_autofire::populate() { char temp_text[64]; - // add autofire toggle item - auto autofire_toggle = machine().ioport().get_autofire_toggle(); + /* add autofire toggle item */ + bool autofire_toggle = machine().ioport().get_autofire_toggle(); item_append(_("Autofire Status"), (autofire_toggle ? _("Disabled") : _("Enabled")), (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; for (auto &port : machine().ioport().ports()) { - auto is_first_button = true; + bool is_first_button = true; for (ioport_field &field : port.second->fields()) { if (field.type() >= IPT_BUTTON1 && field.type() <= IPT_BUTTON16) @@ -272,11 +288,11 @@ void menu_autofire::populate() if (is_first_button) { - // add a separator for each player + /* add a separator for each player */ item_append(menu_item_type::SEPARATOR); is_first_button = false; } - // add an autofire item + /* add an autofire item */ if (!autofire_toggle) { // 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) { item_append(menu_item_type::SEPARATOR); item_append(_("No buttons found on this machine!"), "", FLAG_DISABLE, nullptr); } - // add a separator + /* add a separator */ item_append(menu_item_type::SEPARATOR); - // add autofire delay item - auto value = machine().ioport().get_autofire_delay(); + /* add autofire delay item */ + int value = machine().ioport().get_autofire_delay(); snprintf(temp_text, ARRAY_LENGTH(temp_text), "%d = %.2f Hz", value, (float)refresh/value); - if (!autofire_toggle) + { item_append(_("Autofire Delay"), temp_text, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)ITEMREF_AUTOFIRE_DELAY); + } else + { item_append(_("Autofire Delay"), temp_text, FLAG_DISABLE | FLAG_INVERT, nullptr); + } - // add a separator + /* add a separator */ item_append(menu_item_type::SEPARATOR); last_toggle = autofire_toggle; |