Пример #1
0
menu_dats_view::menu_dats_view(mame_ui_manager &mui, render_container &container, const game_driver *driver)
	: menu(mui, container)
	, m_actual(0)
	, m_driver((driver == nullptr) ? &mui.machine().system() : driver)
	, m_swinfo(nullptr)
	, m_issoft(false)

{
	for (device_image_interface& image : image_interface_iterator(mui.machine().root_device()))
	{
		if (image.filename())
		{
			m_list = strensure(image.software_list_name());
			m_short = image.software_entry()->shortname();
			m_long = image.software_entry()->longname();
			m_parent = image.software_entry()->parentname();
		}
	}
	std::vector<std::string> lua_list;
	if (mame_machine_manager::instance()->lua()->call_plugin("data_list", driver ? driver->name : "", lua_list))
	{
		int count = 0;
		for (std::string& item : lua_list)
		{
			std::string version;
			mame_machine_manager::instance()->lua()->call_plugin("data_version", count, version);
			m_items_list.emplace_back(item.c_str(), count, std::move(version));
			count++;
		}
	}
}
Пример #2
0
void MainWindow::createImagesMenu()
{
	QMenu* imagesMenu = menuBar()->addMenu("&Images");

	int interfaceIndex = 0;
	for (device_image_interface &img : image_interface_iterator(m_machine->root_device()))
	{
		std::string menuName = string_format("%s : %s", img.device().name(), img.exists() ? img.filename() : "[empty slot]");

		QMenu* interfaceMenu = imagesMenu->addMenu(menuName.c_str());
		interfaceMenu->setObjectName(img.device().name());

		QAction* mountAct = new QAction("Mount...", interfaceMenu);
		QAction* unmountAct = new QAction("Unmount", interfaceMenu);
		mountAct->setObjectName("mount");
		mountAct->setData(QVariant(interfaceIndex));
		unmountAct->setObjectName("unmount");
		unmountAct->setData(QVariant(interfaceIndex));
		connect(mountAct, &QAction::triggered, this, &MainWindow::mountImage);
		connect(unmountAct, &QAction::triggered, this, &MainWindow::unmountImage);

		if (!img.exists())
			unmountAct->setEnabled(false);

		interfaceMenu->addAction(mountAct);
		interfaceMenu->addAction(unmountAct);

		// TODO: Cassette operations

		interfaceIndex++;
	}
}
Пример #3
0
void image_manager::config_load(config_type cfg_type, xml_data_node *parentnode)
{
	xml_data_node *node;
	const char *dev_instance;
	const char *working_directory;

	if ((cfg_type == config_type::CONFIG_TYPE_GAME) && (parentnode != nullptr))
	{
		for (node = xml_get_sibling(parentnode->child, "device"); node; node = xml_get_sibling(node->next, "device"))
		{
			dev_instance = xml_get_attribute_string(node, "instance", nullptr);

			if ((dev_instance != nullptr) && (dev_instance[0] != '\0'))
			{
				for (device_image_interface &image : image_interface_iterator(machine().root_device()))
				{
					if (!strcmp(dev_instance, image.instance_name())) {
						working_directory = xml_get_attribute_string(node, "directory", nullptr);
						if (working_directory != nullptr)
							image.set_working_directory(working_directory);
					}
				}
			}
		}
	}
}
Пример #4
0
menu_dats_view::menu_dats_view(mame_ui_manager &mui, render_container &container, const game_driver *driver)
	: menu(mui, container)
	, m_actual(0)
	, m_driver((driver == nullptr) ? &mui.machine().system() : driver)
	, m_issoft(false)

{
	for (device_image_interface &image : image_interface_iterator(mui.machine().root_device()))
	{
		if (image.filename())
		{
			m_list = strensure(image.software_list_name());
			m_short = image.software_entry()->shortname();
			m_long = image.software_entry()->longname();
			m_parent = image.software_entry()->parentname();
		}
	}
	const char *lua_list = mame_machine_manager::instance()->lua()->call_plugin(driver ? driver->name : "", "data_list");
	if(lua_list)
	{
		std::string list(lua_list);
		char *token = strtok((char *)list.c_str(), ",");
		int count = 0;
		while(token)
		{
			m_items_list.emplace_back(_(token), count, mame_machine_manager::instance()->lua()->call_plugin(util::string_format("%d", count).c_str(), "data_version"));
			count++;
			token = strtok(nullptr, ",");
		}
	}
}
Пример #5
0
void favorite_manager::apply_running_machine(running_machine &machine, T &&action)
{
	bool done(false);

	// TODO: this should be changed - it interacts poorly with cartslots on arcade systems
	if ((machine.system().flags & machine_flags::MASK_TYPE) == machine_flags::TYPE_ARCADE)
	{
		action(machine.system(), nullptr, nullptr, done);
	}
	else
	{
		bool have_software(false);
		for (device_image_interface &image_dev : image_interface_iterator(machine.root_device()))
		{
			software_info const *const sw(image_dev.software_entry());
			if (image_dev.exists() && image_dev.loaded_through_softlist() && sw)
			{
				assert(image_dev.software_list_name());

				have_software = true;
				action(machine.system(), &image_dev, sw, done);
				if (done)
					return;
			}
		}

		if (!have_software)
			action(machine.system(), nullptr, nullptr, done);
	}
}
Пример #6
0
void favorite_manager::add_favorite_game()
{
	if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0)
	{
		add_favorite_game(&machine().system());
		return;
	}

	bool software_avail = false;
	for (device_image_interface &image : image_interface_iterator(machine().root_device()))
	{
		if (image.exists() && image.software_entry())
		{
			const software_info *swinfo = image.software_entry();
			const software_part *part = image.part_entry();
			ui_software_info tmpmatches;
			tmpmatches.shortname = strensure(swinfo->shortname());
			tmpmatches.longname = strensure(image.longname());
			tmpmatches.parentname = strensure(swinfo->parentname());
			tmpmatches.year = strensure(image.year());
			tmpmatches.publisher = strensure(image.manufacturer());
			tmpmatches.supported = image.supported();
			tmpmatches.part = strensure(part->name());
			tmpmatches.driver = &machine().system();
			tmpmatches.listname = strensure(image.software_list_name());
			tmpmatches.interface = strensure(part->interface());
			tmpmatches.instance = strensure(image.instance_name());
			tmpmatches.startempty = 0;
			tmpmatches.parentlongname.clear();
			if (swinfo->parentname())
			{
				software_list_device *swlist = software_list_device::find_by_name(machine().config(), image.software_list_name());
				for (software_info &c_swinfo : swlist->get_info())
				{
					std::string c_parent(c_swinfo.parentname());
					if (!c_parent.empty() && c_parent == swinfo->shortname())
						{
							tmpmatches.parentlongname = c_swinfo.longname();
							break;
						}
				}
			}

			tmpmatches.usage.clear();
			for (feature_list_item &flist : swinfo->other_info())
				if (!strcmp(flist.name(), "usage"))
					tmpmatches.usage = flist.value();

			tmpmatches.devicetype = strensure(image.image_type_name());
			tmpmatches.available = true;
			software_avail = true;
			m_list.push_back(tmpmatches);
			save_favorite_games();
		}
	}

	if (!software_avail)
		add_favorite_game(&machine().system());
}
Пример #7
0
void menu_image_info::populate()
{
	item_append(machine().system().description, "", FLAG_DISABLE, nullptr);
	item_append("", "", FLAG_DISABLE, nullptr);

	for (device_image_interface &image : image_interface_iterator(machine().root_device()))
		image_info(&image);
}
Пример #8
0
std::string &image_manager::mandatory_scan(std::string &mandatory)
{
	mandatory.clear();
	// make sure that any required image has a mounted file
	for (device_image_interface &image : image_interface_iterator(machine().root_device()))
	{
		if (image.filename() == nullptr && image.must_be_loaded())
			mandatory.append("\"").append(image.instance_name()).append("\", ");
	}
	return mandatory;
}
Пример #9
0
//-------------------------------------------------
//  unload_all - unload all images and
//  extract options
//-------------------------------------------------
void image_manager::unload_all()
{
	// extract the options
	options_extract();

	for (device_image_interface &image : image_interface_iterator(machine().root_device()))
	{
		// unload this image
		image.unload();
	}
}
Пример #10
0
std::string machine_info::mandatory_images()
{
	std::ostringstream buf;

	// make sure that any required image has a mounted file
	for (device_image_interface &image : image_interface_iterator(m_machine.root_device()))
	{
		if (image.filename() == nullptr && image.must_be_loaded())
			buf << "\"" << image.instance_name() << "\", ";
	}
	return buf.str();
}
Пример #11
0
image_manager::image_manager(running_machine &machine)
	: m_machine(machine)
{
	// make sure that any required devices have been allocated
	for (device_image_interface &image : image_interface_iterator(machine.root_device()))
	{
		// ignore things not user loadable
		if (!image.user_loadable())
			continue;

		// is an image specified for this image
		const char *image_name_ptr = machine.options().value(image.instance_name());
		if ((image_name_ptr != nullptr) && (image_name_ptr[0] != '\0'))
		{
			image_init_result result = image_init_result::FAIL;
			std::string image_name(image_name_ptr);

			// mark init state
			image.set_init_phase();

			// try as a softlist
			if (software_name_parse(image_name))
				result = image.load_software(image_name);

			// failing that, try as an image
			if (result != image_init_result::PASS)
				result = image.load(image_name);

			// failing that, try creating it (if appropriate)
			if (result != image_init_result::PASS && image.support_command_line_image_creation())
				result = image.create(image_name);

			// did the image load fail?
			if (result != image_init_result::PASS)
			{
				// retrieve image error message
				std::string image_err = std::string(image.error());

				// unload all images
				unload_all();

				fatalerror_exitcode(machine, EMU_ERR_DEVICE, "Device %s load (%s) failed: %s",
					image.device().name(),
					image_name.c_str(),
					image_err.c_str());
			}
		}
	}

	machine.configuration().config_register("image_directories", config_saveload_delegate(FUNC(image_manager::config_load), this), config_saveload_delegate(FUNC(image_manager::config_save), this));
}
Пример #12
0
static void MessRemoveImage(int drvindex, const char *pszFilename)
{
	const char *s;
	windows_options o;

	for (device_image_interface &dev : image_interface_iterator(s_config->mconfig->root_device()))
	{
		const char *opt_name = dev.instance_name();
		load_options(o, OPTIONS_GAME, drvindex);
		s = o.value(opt_name);
		if ((s) && !strcmp(pszFilename, s))
			MessSpecifyImage(drvindex, &dev, NULL);
	}
}
Пример #13
0
device_image_interface *software_list_device::find_mountable_image(const machine_config &mconfig, const software_part &part, std::function<bool(const device_image_interface &)> filter)
{
	// if automount="no", don't bother
	const char *mount = part.feature("automount");
	if (mount != nullptr && strcmp(mount, "no") == 0)
		return nullptr;

	for (device_image_interface &image : image_interface_iterator(mconfig.root_device()))
	{
		const char *interface = image.image_interface();
		if (interface != nullptr && part.matches_interface(interface) && filter(image))
			return &image;
	}
	return nullptr;
}
Пример #14
0
void cheat_manager::reload()
{
	// if the cheat engine is disabled, we're done
	if (!machine().options().cheat())
		return;

	// free everything
	m_cheatlist.clear();

	// reset state
	m_framecount = 0;
	m_numlines = 0;
	m_lastline = 0;
	m_disabled = false;

	// load the cheat file, if it's a system that has a software list then try softlist_name/shortname.xml first,
	// if it fails to load then try to load via crc32 - basename/crc32.xml ( eg. 01234567.xml )
	for (device_image_interface &image : image_interface_iterator(machine().root_device()))
		if (image.exists())
		{
			// if we are loading through a software list, try to load softlist_name/shortname.xml
			// this allows the coexistence of arcade cheats with cheats for home conversions which
			// have the same shortname
			if (image.software_entry() != nullptr)
			{
				load_cheats(string_format("%s%s%s", image.software_list_name(), PATH_SEPARATOR, image.basename()).c_str());
				break;
			}
			// else we are loading outside the software list, try to load machine_basename/crc32.xml
			else
			{
				uint32_t crc = image.crc();
				if (crc != 0)
				{
					load_cheats(string_format("%s%s%08X", machine().basename(), PATH_SEPARATOR, crc).c_str());
					break;
				}
			}
		}

	// if we haven't found the cheats yet, load by basename
	if (m_cheatlist.size() == 0)
		load_cheats(machine().basename());

	// temporary: save the file back out as output.xml for comparison
	if (m_cheatlist.size() != 0)
		save_all("output");
}
Пример #15
0
/* Specify IO_COUNT for type if you want all types */
static void SetupImageTypes(const machine_config *config, mess_image_type *types, int count, BOOL bZip, const device_image_interface *dev)
{
	int num_extensions = 0;

	memset(types, 0, sizeof(*types) * count);
	count--;

	if (bZip)
	{
		/* add the ZIP extension */
		types[num_extensions].ext = core_strdup("zip");
		types[num_extensions].dev = NULL;
		types[num_extensions].dlgname = NULL;
		num_extensions++;
		types[num_extensions].ext = core_strdup("7z");
		types[num_extensions].dev = NULL;
		types[num_extensions].dlgname = NULL;
		num_extensions++;
	}

	if (dev == NULL)
	{
		/* special case; all non-printer devices */
		for (device_image_interface &device : image_interface_iterator(s_config->mconfig->root_device()))
		{
			if (device.image_type() != IO_PRINTER)
				SetupImageTypes(config, &types[num_extensions], count - num_extensions, FALSE, &device);
		}

	}
	else
	{
		std::string extensions((char*)dev->file_extensions());
		char *ext = strtok((char*)extensions.c_str(),",");
		while (ext)
		{
			if (num_extensions < count)
			{
				types[num_extensions].dev = dev;
				types[num_extensions].ext = core_strdup(ext);
				types[num_extensions].dlgname = lookupdevice(dev->image_type())->dlgname;
				num_extensions++;
			}
			ext = strtok (NULL, ",");
		}
	}
}
Пример #16
0
void consolewin_info::update_menu()
{
	disasmbasewin_info::update_menu();

	if (m_devices_menu != nullptr)
	{
		// create the image menu
		uint32_t cnt = 0;
		for (device_image_interface &img : image_interface_iterator(machine().root_device()))
		{
			HMENU const devicesubmenu = CreatePopupMenu();

			UINT_PTR const new_item = ID_DEVICE_OPTIONS + (cnt * DEVOPTION_MAX);

			UINT flags_for_exists = MF_ENABLED | MF_STRING;
			if (!img.exists())
				flags_for_exists |= MF_GRAYED;

			UINT flags_for_writing = flags_for_exists;
			if (img.is_readonly())
				flags_for_writing |= MF_GRAYED;

			AppendMenu(devicesubmenu, MF_STRING, new_item + DEVOPTION_OPEN, TEXT("Mount..."));

			if (img.is_creatable())
				AppendMenu(devicesubmenu, MF_STRING, new_item + DEVOPTION_CREATE, TEXT("Create..."));
			AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CLOSE, TEXT("Unmount"));

			if (img.device().type() == CASSETTE)
			{
				cassette_state const state = (cassette_state)(img.exists() ? (downcast<cassette_image_device *>(&img.device())->get_state() & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED);
				AppendMenu(devicesubmenu, MF_SEPARATOR, 0, nullptr);
				AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_STOPPED) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_STOPPAUSE, TEXT("Pause/Stop"));
				AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_PLAY) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_PLAY, TEXT("Play"));
				AppendMenu(devicesubmenu, flags_for_writing | ((state == CASSETTE_RECORD) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_RECORD, TEXT("Record"));
				AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CASSETTE_REWIND, TEXT("Rewind"));
				AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CASSETTE_FASTFORWARD, TEXT("Fast Forward"));
			}

			osd::text::tstring tc_buf = osd::text::to_tstring(string_format("%s :%s", img.device().name(), img.exists() ? img.filename() : "[empty slot]"));
			ModifyMenu(m_devices_menu, cnt, MF_BYPOSITION | MF_POPUP, (UINT_PTR)devicesubmenu, tc_buf.c_str());

			cnt++;
		}
	}
}
Пример #17
0
static void MessRefreshPicker(void)
{
	HWND hwndSoftware;
	int i = 0;
	LVFINDINFO lvfi;
	const char *s;
	windows_options o;

	hwndSoftware = GetDlgItem(GetMainWindow(), IDC_SWLIST);

	s_bIgnoreSoftwarePickerNotifies = TRUE;

	// Now clear everything out; this may call back into us but it should not
	// be problematic
	ListView_SetItemState(hwndSoftware, -1, 0, LVIS_SELECTED);

	for (device_image_interface &dev : image_interface_iterator(s_config->mconfig->root_device()))
	{
		const char *opt_name = dev.instance_name(); // get name of device slot
		load_options(o, OPTIONS_GAME, s_config->driver_index);
		s = o.value(opt_name); // get name of software in the slot

		if (s[0]) // if software is loaded
		{
			i = SoftwarePicker_LookupIndex(hwndSoftware, s); // see if its in the picker
			if (i < 0) // not there
			{
				// add already loaded software to picker, but not if its already there
				SoftwarePicker_AddFile(hwndSoftware, s, 1);
				i = SoftwarePicker_LookupIndex(hwndSoftware, s); // refresh pointer
			}
			if (i >= 0) // is there
			{
				memset(&lvfi, 0, sizeof(lvfi));
				lvfi.flags = LVFI_PARAM;
				lvfi.lParam = i;
				i = ListView_FindItem(hwndSoftware, -1, &lvfi);
				ListView_SetItemState(hwndSoftware, i, LVIS_SELECTED, LVIS_SELECTED); // highlight it
			}
		}
	}

	s_bIgnoreSoftwarePickerNotifies = FALSE;
}
Пример #18
0
device_image_interface *software_list_device::find_mountable_image(const machine_config &mconfig, const software_part &part)
{
	// if automount="no", don't bother
	const char *mount = part.feature("automount");
	if (mount != nullptr && strcmp(mount, "no") == 0)
		return nullptr;

	for (device_image_interface &image : image_interface_iterator(mconfig.root_device()))
	{
		const char *interface = image.image_interface();
		if (interface != nullptr && part.matches_interface(interface))
		{
			// mount only if not already mounted
			const char *option = mconfig.options().value(image.brief_instance_name());
			if (*option == '\0' && !image.filename())
				return &image;
		}
	}
	return nullptr;
}
Пример #19
0
void image_manager::config_save(config_type cfg_type, xml_data_node *parentnode)
{
	xml_data_node *node;
	const char *dev_instance;

	/* only care about game-specific data */
	if (cfg_type == config_type::CONFIG_TYPE_GAME)
	{
		for (device_image_interface &image : image_interface_iterator(machine().root_device()))
		{
			dev_instance = image.instance_name();

			node = xml_add_child(parentnode, "device", nullptr);
			if (node != nullptr)
			{
				xml_set_attribute(node, "instance", dev_instance);
				xml_set_attribute(node, "directory", image.working_directory());
			}
		}
	}
}
Пример #20
0
image_manager::image_manager(running_machine &machine)
	: m_machine(machine)
{
	/* make sure that any required devices have been allocated */
	for (device_image_interface &image : image_interface_iterator(machine.root_device()))
	{
		/* is an image specified for this image */
		const char *image_name = machine.options().value(image.instance_name());
		if (!image.user_loadable())
			continue;

		if ((image_name != nullptr) && (image_name[0] != '\0'))
		{
			/* mark init state */
			image.set_init_phase();

			/* try to load this image */
			bool result = image.load(image_name);

			/* did the image load fail? */
			if (result)
			{
				/* retrieve image error message */
				std::string image_err = std::string(image.error());
				std::string image_basename(image_name);

				/* unload all images */
				unload_all();

				fatalerror_exitcode(machine, EMU_ERR_DEVICE, "Device %s load (%s) failed: %s",
					image.device().name(),
					image_basename.c_str(),
					image_err.c_str());
			}
		}
	}

	machine.configuration().config_register("image_directories", config_saveload_delegate(FUNC(image_manager::config_load), this), config_saveload_delegate(FUNC(image_manager::config_save), this));
}
Пример #21
0
void image_manager::options_extract()
{
	/* only extract the device options if we've added them
	   no need to assert in case they are missing */
	{
		int index = 0;

		for (device_image_interface &image : image_interface_iterator(machine().root_device()))
		{
			const char *filename = image.filename();

			/* and set the option */
			std::string error;
			machine().options().set_value(image.instance_name(), filename ? filename : "", OPTION_PRIORITY_CMDLINE, error);

			index++;
		}
	}

	/* write the config, if appropriate */
	if (machine().options().write_config())
		write_config(machine().options(), nullptr, &machine().system());
}
Пример #22
0
void image_manager::postdevice_init()
{
	/* make sure that any required devices have been allocated */
	for (device_image_interface &image : image_interface_iterator(machine().root_device()))
	{
		int result = image.finish_load();

		/* did the image load fail? */
		if (result)
		{
			/* retrieve image error message */
			std::string image_err = std::string(image.error());

			/* unload all images */
			unload_all();

			fatalerror_exitcode(machine(), EMU_ERR_DEVICE, "Device %s load failed: %s",
				image.device().name(),
				image_err.c_str());
		}
	}
	/* add a callback for when we shut down */
	machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(image_manager::unload_all), this));
}
Пример #23
0
void device_image_interface::update_names(const device_type device_type, const char *inst, const char *brief)
{
	int count = 0;
	int index = -1;
	for (const device_image_interface &image : image_interface_iterator(device().mconfig().root_device()))
	{
		if (this == &image)
			index = count;
		if ((image.image_type() == image_type() && device_type == nullptr) || (device_type == image.device().type()))
			count++;
	}
	const char *inst_name = (device_type!=nullptr) ? inst : device_typename(image_type());
	const char *brief_name = (device_type!=nullptr) ? brief : device_brieftypename(image_type());
	if (count > 1)
	{
		m_instance_name = string_format("%s%d", inst_name, index + 1);
		m_brief_instance_name = string_format("%s%d", brief_name, index + 1);
	}
	else
	{
		m_instance_name = inst_name;
		m_brief_instance_name = brief_name;
	}
}
Пример #24
0
void menu_main::populate()
{
	/* add input menu items */
	item_append(_("Input (general)"), "", 0, (void *)INPUT_GROUPS);

	item_append(_("Input (this Machine)"), "", 0, (void *)INPUT_SPECIFIC);

	/* add optional input-related menus */
	if (ui().machine_info().has_analog())
		item_append(_("Analog Controls"), "", 0, (void *)ANALOG);
	if (ui().machine_info().has_dips())
		item_append(_("Dip Switches"), "", 0, (void *)SETTINGS_DIP_SWITCHES);
	if (ui().machine_info().has_configs())
	{
		item_append(_("Machine Configuration"), "", 0, (void *)SETTINGS_DRIVER_CONFIG);
	}

	/* add bookkeeping menu */
	item_append(_("Bookkeeping Info"), "", 0, (void *)BOOKKEEPING);

	/* add game info menu */
	item_append(_("Machine Information"), "", 0, (void *)GAME_INFO);

	for (device_image_interface &image : image_interface_iterator(machine().root_device()))
	{
		if (image.user_loadable())
		{
			/* add image info menu */
			item_append(_("Image Information"), "", 0, (void *)IMAGE_MENU_IMAGE_INFO);

			/* add file manager menu */
			item_append(_("File Manager"), "", 0, (void *)IMAGE_MENU_FILE_MANAGER);

			break;
		}
	}

	/* add tape control menu */
	if (cassette_device_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Tape Control"), "", 0, (void *)TAPE_CONTROL);

	if (pty_interface_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Pseudo terminals"), "", 0, (void *)PTY_INFO);

	if (ui().machine_info().has_bioses())
		item_append(_("Bios Selection"), "", 0, (void *)BIOS_SELECTION);

	/* add slot info menu */
	if (slot_interface_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Slot Devices"), "", 0, (void *)SLOT_DEVICES);

	/* add Barcode reader menu */
	if (barcode_reader_device_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Barcode Reader"), "", 0, (void *)BARCODE_READ);

	/* add network info menu */
	if (network_interface_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Network Devices"), "", 0, (void*)NETWORK_DEVICES);

	/* add keyboard mode menu */
	if (ui().machine_info().has_keyboard() && machine().ioport().natkeyboard().can_post())
		item_append(_("Keyboard Mode"), "", 0, (void *)KEYBOARD_MODE);

	/* add sliders menu */
	item_append(_("Slider Controls"), "", 0, (void *)SLIDERS);

	/* add video options menu */
	item_append(_("Video Options"), "", 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS);

	/* add crosshair options menu */
	if (machine().crosshair().get_usage())
		item_append(_("Crosshair Options"), "", 0, (void *)CROSSHAIR);

	/* add cheat menu */
	if (machine().options().cheat())
		item_append(_("Cheat"), "", 0, (void *)CHEAT);

	if (machine().options().plugins())
		item_append(_("Plugin Options"), "", 0, (void *)PLUGINS);

	// add dats menu
	if (mame_machine_manager::instance()->lua()->call_plugin("", "data_list"))
		item_append(_("External DAT View"), "", 0, (void *)EXTERNAL_DATS);

	item_append(menu_item_type::SEPARATOR);

	/* add favorite menu */
	if (!mame_machine_manager::instance()->favorite().isgame_favorite())
		item_append(_("Add To Favorites"), "", 0, (void *)ADD_FAVORITE);
	else
		item_append(_("Remove From Favorites"), "", 0, (void *)REMOVE_FAVORITE);

	item_append(menu_item_type::SEPARATOR);

//  item_append(_("Quit from Machine"), nullptr, 0, (void *)QUIT_GAME);

	/* add reset and exit menus */
	item_append(_("Select New Machine"), "", 0, (void *)SELECT_GAME);
}
Пример #25
0
void MyFillSoftwareList(int drvindex, BOOL bForce)
{
	BOOL is_same = 0;
	HWND hwndSoftwarePicker;
	HWND hwndSoftwareList;
	HWND hwndSoftwareDevView;

	// do we have to do anything?
	if (!bForce)
	{
		if (s_config != NULL)
			is_same = (drvindex == s_config->driver_index);
		else
			is_same = (drvindex < 0);
		if (is_same)
			return;
	}

	// free the machine config, if necessary
	MySoftwareListClose();

	// allocate the machine config, if necessary
	if (drvindex >= 0)
		s_config = software_config_alloc(drvindex);

	// locate key widgets
	hwndSoftwarePicker = GetDlgItem(GetMainWindow(), IDC_SWLIST);
	hwndSoftwareList = GetDlgItem(GetMainWindow(), IDC_SOFTLIST);
	hwndSoftwareDevView = GetDlgItem(GetMainWindow(), IDC_SWDEVVIEW);

	// set up the device view
	DevView_SetDriver(hwndSoftwareDevView, s_config);

	// set up the software picker
	SoftwarePicker_Clear(hwndSoftwarePicker);
	SoftwarePicker_SetDriver(hwndSoftwarePicker, s_config);

	// Get the game's software path
	int driver_index = drvindex;
	windows_options o;
	load_options(o, OPTIONS_GAME, driver_index);
	const char* paths = o.value(OPTION_SWPATH);
	if (paths && (paths[0] > 64)) 
	{} else
	// search deeper when looking for software
	{
		// not specified in driver, try parent if it has one
		int nParentIndex = -1;
		if (DriverIsClone(driver_index) == TRUE)
		{
			nParentIndex = GetParentIndex(&driver_list::driver(driver_index));
			if (nParentIndex >= 0)
			{
				load_options(o, OPTIONS_PARENT, nParentIndex);
				paths = o.value(OPTION_SWPATH);
			}
		}
		if (paths && (paths[0] > 64))
		{} else
		{

			// still nothing, try for a system in the 'compat' field
			if (nParentIndex >= 0)
				driver_index = nParentIndex;

			// now recycle variable as a compat system number
			nParentIndex = GetCompatIndex(&driver_list::driver(driver_index));
			if (nParentIndex >= 0)
			{
				load_options(o, OPTIONS_PARENT, nParentIndex);
				paths = o.value(OPTION_SWPATH);
			}
		}
	}

	// These are the only paths that matter
	AddSoftwarePickerDirs(hwndSoftwarePicker, paths, NULL);
	paths = 0;
	// set up the software picker
	SoftwareList_Clear(hwndSoftwareList);
	SoftwareList_SetDriver(hwndSoftwareList, s_config);

	/* allocate the machine config */
	machine_config config(driver_list::driver(drvindex),MameUIGlobal());

	for (software_list_device &swlistdev : software_list_device_iterator(config.root_device()))
	{
		for (const software_info &swinfo : swlistdev.get_info())
		{
			const software_part &swpart = swinfo.parts().front();

			// search for a device with the right interface
			for (device_image_interface &image : image_interface_iterator(config.root_device()))
			{
				const char *interface = image.image_interface();
				if (interface)
				{
					if (swpart.matches_interface(interface))
					{
						// Extract the Usage data from the "info" fields.
						const char* usage = NULL;
						for (const feature_list_item &flist : swinfo.other_info())
							if (flist.name() == "usage")
								usage = flist.value().c_str();
						// Now actually add the item
						SoftwareList_AddFile(hwndSoftwareList, swinfo.shortname().c_str(), swlistdev.list_name().c_str(), swinfo.longname().c_str(), swinfo.publisher().c_str(), swinfo.year().c_str(), usage, image.brief_instance_name());
						break;
					}
				}
			}
		}
	}
}
Пример #26
0
// Places the specified image in the specified slot; nID = -1 means don't matter
static void MessSpecifyImage(int drvindex, const device_image_interface *device, LPCSTR pszFilename)
{
	const char *s, *file_extension;
	windows_options o;
	load_options(o, OPTIONS_GAME, drvindex);

	if (LOG_SOFTWARE)
		dprintf("MessSpecifyImage(): device=%p pszFilename='%s'\n", device, pszFilename);

	// see if the software is already loaded (why?)
	if (device == NULL)
	{
		for (device_image_interface &dev : image_interface_iterator(s_config->mconfig->root_device()))
		{
			const char *opt_name = dev.instance_name();
			s = o.value(opt_name);
			if ((s != NULL) && (core_stricmp(s, pszFilename)==0))
			{
				device = &dev;
				break;
			}
		}
	}


	// still not found?  find an empty slot for which the device uses the
	// same file extension
	if (device == NULL)
	{
		// identify the file extension
		file_extension = strrchr(pszFilename, '.');
		file_extension = file_extension ? file_extension + 1 : NULL;

		if (file_extension)
		{
			for (device_image_interface &dev : image_interface_iterator(s_config->mconfig->root_device()))
			{
				const char *opt_name = dev.instance_name();
				s = o.value(opt_name);
				if (is_null_or_empty(s) && dev.uses_file_extension(file_extension))
				{
					device = &dev;
					break;
				}
			}
		}
	}
	// no choice but to replace the existing cart
	if (device == NULL)
	{
		if (file_extension)
		{
			for (device_image_interface &dev : image_interface_iterator(s_config->mconfig->root_device()))
			{
				const char *opt_name = dev.instance_name();
				s = o.value(opt_name);
				if (!is_null_or_empty(s) && dev.uses_file_extension(file_extension))
				{
					device = &dev;
					break;
				}
			}
		}
	}

	if (device)
	{
		// place the image
		InternalSetSelectedSoftware(drvindex, s_config->mconfig, device, pszFilename);
	}
	else
	{
		// could not place the image
		if (LOG_SOFTWARE)
			dprintf("MessSpecifyImage(): Failed to place image '%s'\n", pszFilename);
	}
}
Пример #27
0
static BOOL DevView_GetOpenItemName(HWND hwndDevView, const machine_config *config, const device_image_interface *dev, LPTSTR pszFilename, UINT nFilenameLength)
{
	BOOL bResult = 0;
	TCHAR *t_s;
	int i = 0;
	mess_image_type imagetypes[256];
	HWND hwndList = GetDlgItem(GetMainWindow(), IDC_LIST);
	int drvindex = Picker_GetSelectedItem(hwndList);
	std::string as, dst;
	const char *s, *opt_name = dev->instance_name();
	windows_options o;
	load_options(o, OPTIONS_GAME, drvindex);
	s = o.value(opt_name);

	/* Get the path to the currently mounted image, chop off any trailing backslash */
	util::zippath_parent(as, s);
	size_t t1 = as.length()-1;
	if (as[t1] == '\\') as[t1]='\0';
	dst = as;

	/* See if an image was loaded, and that the path still exists */
	if ((!osd::directory::open(as.c_str())) || (as.find(':') == std::string::npos))
	{
		/* Get the path from the SL base */
		as = GetSLDir();

		/* We only want the first path; throw out the rest */
		i = as.find(';');
		if (i > 0) as.substr(0, i);

		// Get the path to suitable software
		i = 0;
		for (software_list_device &swlist : software_list_device_iterator(config->root_device()))
		{
			for (const software_info &swinfo : swlist.get_info())
			{
				const software_part &part = swinfo.parts().front();
				if (swlist.is_compatible(part) == SOFTWARE_IS_COMPATIBLE)
				{
					for (device_image_interface &image : image_interface_iterator(config->root_device()))
					{
						if ((i == 0) && (std::string(opt_name) == std::string(image.instance_name())))
						{
							const char *interface = image.image_interface();
							if (interface != nullptr && part.matches_interface(interface))
							{
								as.append("\\").append(swlist.list_name());
								i++;
							}
						}
					}
				}
			}
		}

		dst = as;

		/* Make sure a folder was specified in the tab, and that it exists */
		if ((!osd::directory::open(as.c_str())) || (as.find(':') == std::string::npos))
		{
			/* Default to emu directory */
			osd_get_full_path(dst,".");
		}
	}

	SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev);
	t_s = ui_wstring_from_utf8(dst.c_str());
	bResult = CommonFileImageDialog(t_s, GetOpenFileName, pszFilename, config, imagetypes);
	CleanupImageTypes(imagetypes, ARRAY_LENGTH(imagetypes));

	// This crappy code is typical of what you get with strings in c++
	// All we want to do is get the Item name out of the full path
	char t2[nFilenameLength];
	wcstombs(t2, pszFilename, nFilenameLength-1); // convert wide string to a normal one
	std::string t3 = t2; // then convert to a c++ string so we can manipulate it
	t1 = t3.find(".zip"); // get rid of zip name and anything after
	if (t1) t3[t1] = '\0';
	t1 = t3.find(".7z"); // get rid of 7zip name and anything after
	if (t1) t3[t1] = '\0';
//	t1 = t3.find_last_of("\\");   // we can force the swlist name in, if needed
//	t3[t1] = ':';
	t1 = t3.find_last_of("\\"); // get rid of path; we only want the item name
	t3.erase(0, t1+1);

	// set up editbox display text
	mbstowcs(pszFilename, t3.c_str(), nFilenameLength-1); // convert it back to a wide string

	// set up inifile text to signify to MAME that a SW ITEM is to be used
	strcpy(g_szSelectedSoftware, t3.c_str()); // store to global item name
	strcpy(g_szSelectedDevice, opt_name); // get media-device name (brief_instance_name is ok too)

	free(t_s);
	return bResult;
}
Пример #28
0
osd_file::error video_manager::open_next(emu_file &file, const char *extension)
{
	u32 origflags = file.openflags();

	// handle defaults
	const char *snapname = machine().options().snap_name();

	if (snapname == nullptr || snapname[0] == 0)
		snapname = "%g/%i";
	std::string snapstr(snapname);

	// strip any extension in the provided name
	int index = snapstr.find_last_of('.');
	if (index != -1)
		snapstr = snapstr.substr(0, index);

	// handle %d in the template (for image devices)
	std::string snapdev("%d_");
	int pos = snapstr.find(snapdev);

	if (pos != -1)
	{
		// if more %d are found, revert to default and ignore them all
		if (snapstr.find(snapdev.c_str(), pos + 3) != -1)
			snapstr.assign("%g/%i");
		// else if there is a single %d, try to create the correct snapname
		else
		{
			int name_found = 0;

			// find length of the device name
			int end1 = snapstr.find("/", pos + 3);
			int end2 = snapstr.find("%", pos + 3);
			int end;

			if ((end1 != -1) && (end2 != -1))
				end = std::min(end1, end2);
			else if (end1 != -1)
				end = end1;
			else if (end2 != -1)
				end = end2;
			else
				end = snapstr.length();

			if (end - pos < 3)
				fatalerror("Something very wrong is going on!!!\n");

			// copy the device name to an std::string
			std::string snapdevname;
			snapdevname.assign(snapstr.substr(pos + 3, end - pos - 3));
			//printf("check template: %s\n", snapdevname.c_str());

			// verify that there is such a device for this system
			for (device_image_interface &image : image_interface_iterator(machine().root_device()))
			{
				// get the device name
				std::string tempdevname(image.brief_instance_name());
				//printf("check device: %s\n", tempdevname.c_str());

				if (snapdevname.compare(tempdevname) == 0)
				{
					// verify that such a device has an image mounted
					if (image.basename() != nullptr)
					{
						std::string filename(image.basename());

						// strip extension
						filename = filename.substr(0, filename.find_last_of('.'));

						// setup snapname and remove the %d_
						strreplace(snapstr, snapdevname.c_str(), filename.c_str());
						snapstr.erase(pos, 3);
						//printf("check image: %s\n", filename.c_str());

						name_found = 1;
					}
				}
			}

			// or fallback to default
			if (name_found == 0)
				snapstr.assign("%g/%i");
		}
	}

	// add our own extension
	snapstr.append(".").append(extension);

	// substitute path and gamename up front
	strreplace(snapstr, "/", PATH_SEPARATOR);
	strreplace(snapstr, "%g", machine().basename());

	// determine if the template has an index; if not, we always use the same name
	std::string fname;
	if (snapstr.find("%i") == -1)
		fname.assign(snapstr);

	// otherwise, we scan for the next available filename
	else
	{
		// try until we succeed
		file.set_openflags(OPEN_FLAG_READ);
		for (int seq = 0; ; seq++)
		{
			// build up the filename
			fname.assign(snapstr);
			strreplace(fname, "%i", string_format("%04d", seq).c_str());

			// try to open the file; stop when we fail
			osd_file::error filerr = file.open(fname.c_str());
			if (filerr != osd_file::error::NONE)
				break;
		}
	}

	// create the final file
	file.set_openflags(origflags);
	return file.open(fname.c_str());
}