void crosshair_manager::config_save(config_type cfg_type, xml_data_node *parentnode) { /* Note: crosshair_save() is only registered if crosshairs are used */ xml_data_node *crosshairnode; int player; /* we only care about game files */ if (cfg_type != config_type::CONFIG_TYPE_GAME) return; for (player = 0; player < MAX_PLAYERS; player++) { const render_crosshair &crosshair = *m_crosshair[player]; if (crosshair.is_used()) { /* create a node */ crosshairnode = xml_add_child(parentnode, "crosshair", nullptr); if (crosshairnode != nullptr) { bool changed = false; xml_set_attribute_int(crosshairnode, "player", player); if (crosshair.mode() != CROSSHAIR_VISIBILITY_DEFAULT) { xml_set_attribute_int(crosshairnode, "mode", crosshair.mode()); changed = true; } // only save graphic name if not the default if (*crosshair.bitmap_name() != '\0') { xml_set_attribute(crosshairnode, "pic", crosshair.bitmap_name()); changed = true; } /* if nothing changed, kill the node */ if (!changed) xml_delete_node(crosshairnode); } } } /* always store autotime so that it stays at the user value if it is needed */ if (m_auto_time != CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT) { /* create a node */ crosshairnode = xml_add_child(parentnode, "autotime", nullptr); if (crosshairnode != nullptr) xml_set_attribute_int(crosshairnode, "val", m_auto_time); } }
static void crosshair_save(running_machine &machine, int config_type, xml_data_node *parentnode) { /* Note: crosshair_save() is only registered if crosshairs are used */ xml_data_node *crosshairnode; int player; /* we only care about game files */ if (config_type != CONFIG_TYPE_GAME) return; for (player = 0; player < MAX_PLAYERS; player++) { if (global.used[player]) { /* create a node */ crosshairnode = xml_add_child(parentnode, "crosshair", NULL); if (crosshairnode != NULL) { int changed = FALSE; xml_set_attribute_int(crosshairnode, "player", player); if (global.visible[player] != CROSSHAIR_VISIBILITY_DEFAULT) { xml_set_attribute_int(crosshairnode, "mode", global.mode[player]); changed = TRUE; } /* the default graphic name is "", so only save if not */ if (*(global.name[player]) != 0) { xml_set_attribute(crosshairnode, "pic", global.name[player]); changed = TRUE; } /* if nothing changed, kill the node */ if (!changed) xml_delete_node(crosshairnode); } } } /* always store autotime so that it stays at the user value if it is needed */ if (global.auto_time != CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT) { /* create a node */ crosshairnode = xml_add_child(parentnode, "autotime", NULL); if (crosshairnode != NULL) xml_set_attribute_int(crosshairnode, "val", global.auto_time); } }
void laserdisc_device::config_save(config_type cfg_type, xml_data_node *parentnode) { // we only care about game files if (cfg_type != config_type::CONFIG_TYPE_GAME) return; // create a node xml_data_node *ldnode = xml_add_child(parentnode, "device", nullptr); if (ldnode != nullptr) { // output the basics xml_set_attribute(ldnode, "tag", tag().c_str()); // add an overlay node xml_data_node *overnode = xml_add_child(ldnode, "overlay", nullptr); bool changed = false; if (overnode != nullptr) { // output the positioning controls if (m_overposx != m_orig_config.m_overposx) { xml_set_attribute_float(overnode, "hoffset", m_overposx); changed = true; } if (m_overscalex != m_orig_config.m_overscalex) { xml_set_attribute_float(overnode, "hstretch", m_overscalex); changed = true; } if (m_overposy != m_orig_config.m_overposy) { xml_set_attribute_float(overnode, "voffset", m_overposy); changed = true; } if (m_overscaley != m_orig_config.m_overscaley) { xml_set_attribute_float(overnode, "vstretch", m_overscaley); changed = true; } } // if nothing changed, kill the node if (!changed) xml_delete_node(ldnode); } }
static int config_save_xml(running_machine &machine, emu_file &file, int which_type) { xml_data_node *root = xml_file_create(); xml_data_node *confignode, *systemnode; config_type *type; /* if we don't have a root, bail */ if (!root) return 0; /* create a config node */ confignode = xml_add_child(root, "mameconfig", NULL); if (!confignode) goto error; xml_set_attribute_int(confignode, "version", CONFIG_VERSION); /* create a system node */ systemnode = xml_add_child(confignode, "system", NULL); if (!systemnode) goto error; xml_set_attribute(systemnode, "name", (which_type == CONFIG_TYPE_DEFAULT) ? "default" : machine.system().name); /* create the input node and write it out */ /* loop over all registrants and call their save function */ for (type = typelist; type; type = type->next) { xml_data_node *curnode = xml_add_child(systemnode, type->name, NULL); if (!curnode) goto error; type->save(which_type, curnode); /* if nothing was added, just nuke the node */ if (!curnode->value && !curnode->child) xml_delete_node(curnode); } /* flush the file */ xml_file_write(root, file); /* free and get out of here */ xml_file_free(root); return 1; error: xml_file_free(root); return 0; }