diff options
author | ajrhacker <ajrhacker@users.noreply.github.com> | 2017-02-27 00:13:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-27 00:13:19 -0500 |
commit | 73d399e9e5b22121c9f51eaf6b10b36aeb44491b (patch) | |
tree | 489371c0b9a0ecf980ef88cd3d7432db856a60a8 | |
parent | 94bbcc889b5aef5cb771f07fdb414c3996a8ba19 (diff) | |
parent | f407afa013989e434e63711aa304691929a53a4f (diff) |
Merge pull request #2099 from npwoods/minor_slotopt_cleanups
Cleanup of slot code
-rw-r--r-- | src/emu/dislot.cpp | 11 | ||||
-rw-r--r-- | src/emu/dislot.h | 1 | ||||
-rw-r--r-- | src/frontend/mame/mameopts.cpp | 4 | ||||
-rw-r--r-- | src/frontend/mame/ui/slotopt.cpp | 26 |
4 files changed, 30 insertions, 12 deletions
diff --git a/src/emu/dislot.cpp b/src/emu/dislot.cpp index 037a2749567..7174293098c 100644 --- a/src/emu/dislot.cpp +++ b/src/emu/dislot.cpp @@ -77,6 +77,17 @@ device_t* device_slot_interface::get_card_device() return dev; } +bool device_slot_interface::has_selectable_options() const +{ + if (!fixed()) + { + for (auto &option : option_list()) + if (option.second->selectable()) + return true; + } + return false; +} + device_slot_card_interface::device_slot_card_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "slot") diff --git a/src/emu/dislot.h b/src/emu/dislot.h index 967442631de..54b75a353fb 100644 --- a/src/emu/dislot.h +++ b/src/emu/dislot.h @@ -110,6 +110,7 @@ public: static void static_set_option_device_input_defaults(device_t &device, const char *option, const input_device_default *default_input) { static_option(device, option)->m_input_device_defaults = default_input; } static void static_set_option_clock(device_t &device, const char *option, u32 default_clock) { static_option(device, option)->m_clock = default_clock; } bool fixed() const { return m_fixed; } + bool has_selectable_options() const; const char *default_option() const { return m_default_option; } const std::unordered_map<std::string, std::unique_ptr<device_slot_option>> &option_list() const { return m_options; } device_slot_option *option(const char *name) const { if (name) { auto search = m_options.find(name); if (search != m_options.end()) return search->second.get(); else return nullptr; } else return nullptr; } diff --git a/src/frontend/mame/mameopts.cpp b/src/frontend/mame/mameopts.cpp index 10f8a50ce3a..be3ceb89845 100644 --- a/src/frontend/mame/mameopts.cpp +++ b/src/frontend/mame/mameopts.cpp @@ -38,8 +38,8 @@ bool mame_options::add_slot_options(emu_options &options, std::function<void(emu int starting_count = options.options_count(); for (const device_slot_interface &slot : slot_interface_iterator(config.root_device())) { - // skip fixed slots - if (slot.fixed()) + // skip slots without selectable options + if (!slot.has_selectable_options()) continue; // retrieve info about the device instance diff --git a/src/frontend/mame/ui/slotopt.cpp b/src/frontend/mame/ui/slotopt.cpp index 3c0353160c6..236dbb561c1 100644 --- a/src/frontend/mame/ui/slotopt.cpp +++ b/src/frontend/mame/ui/slotopt.cpp @@ -153,22 +153,28 @@ menu_slot_devices::menu_slot_devices(mame_ui_manager &mui, render_container &con void menu_slot_devices::populate(float &customtop, float &custombottom) { - /* 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())) { - /* record the menu item */ + // does this slot have any selectable options? + bool has_selectable_options = slot.has_selectable_options(); + + // name this option + std::string opt_name("------"); const device_slot_option *option = slot_get_current_option(slot); - std::string opt_name; - if (option == nullptr) - opt_name.assign("------"); - else + if (option) { - opt_name.assign(option->name()); - if (slot.fixed() || slot_get_length(slot) == 0) - opt_name.append(_(" [internal]")); + opt_name = has_selectable_options + ? option->name() + : string_format(_("%s [internal]"), option->name()); } - item_append(slot.device().tag() + 1, opt_name, (slot.fixed() || slot_get_length(slot) == 0) ? 0 : (FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW), (void *)&slot); + // choose item flags + uint32_t item_flags = has_selectable_options + ? FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW + : FLAG_DISABLE; + + item_append(slot.device().tag() + 1, opt_name, item_flags, (void *)&slot); } item_append(menu_item_type::SEPARATOR); item_append(_("Reset"), "", 0, (void *)1); |