Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/frontend/mame/ui/slotopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <algorithm>

#include "../osd/modules/lib/osdlib.h"

/***************************************************************************
UTILITY
Expand All @@ -28,6 +29,7 @@ namespace {

// constants
void *const ITEMREF_RESET = ((void *)1);
void *const ITEMREF_COPYTOCLIPBOARD = ((void *)2);
constexpr char const DIVIDER[] = "------";

} // anonymous namespace
Expand Down Expand Up @@ -202,6 +204,7 @@ void menu_slot_devices::populate()
}
item_append(menu_item_type::SEPARATOR);
item_append(_("Reset System"), 0, ITEMREF_RESET);
item_append(_("Copy to Clipboard"), 0, ITEMREF_COPYTOCLIPBOARD);
}


Expand All @@ -224,7 +227,7 @@ void menu_slot_devices::recompute_metrics(uint32_t width, uint32_t height, float

void menu_slot_devices::custom_render(uint32_t flags, void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
if (selectedref && (ITEMREF_RESET != selectedref))
if (selectedref && (ITEMREF_RESET != selectedref) && (ITEMREF_COPYTOCLIPBOARD != selectedref))
{
device_slot_interface *const slot(reinterpret_cast<device_slot_interface *>(selectedref));
device_slot_interface::slot_option const *const option(get_current_option(*slot));
Expand Down Expand Up @@ -252,6 +255,29 @@ bool menu_slot_devices::handle(event const *ev)
if (ev->iptkey == IPT_UI_SELECT)
machine().schedule_hard_reset();
}
else if (ev->itemref == ITEMREF_COPYTOCLIPBOARD)
{
if (ev->iptkey == IPT_UI_SELECT || ev->iptkey == IPT_UI_CLEAR)
{
bool inistyle = (ev->iptkey == IPT_UI_CLEAR);
std::stringstream outss;
for (device_slot_interface &slot : slot_interface_enumerator(m_config->root_device()))
{
if (slot.has_selectable_options())
{
// get the slot option
const slot_option &opt(machine().options().slot_option(slot.slot_name()));

outss << (inistyle ? "" : "-") << slot.slot_name() << " " <<
(!opt.value().empty() ? opt.value() : (inistyle ? "" : "\"\"") ) << (inistyle ? "\n" : " ");
}
}

if (!osd_set_clipboard_text(outss.str()))
machine().popmessage(_("Slot Options",
inistyle ? "Copied .ini slot options to clipboard" : "Copied command line slot options to clipboard"));
}
}
else if (ev->iptkey == IPT_UI_LEFT || ev->iptkey == IPT_UI_RIGHT)
{
device_slot_interface *slot = (device_slot_interface *)ev->itemref;
Expand Down
Loading