コード例 #1
0
ファイル: sound_animation.cpp プロジェクト: CCChaos/RyzomCore
void CSoundAnimation::save()
{
	// File stream
	COFile file;
	vector<NLMISC::CSheetId>	sounds;

	// Open the file
	if (!file.open(_Filename.c_str()))
	{
		throw NLMISC::Exception("Can't open the file for writing");
	}

	// Create the XML stream
	COXml output;

	// Init
	if (output.init (&file, "1.0"))
	{
		xmlDocPtr xmlDoc = output.getDocument();

		// Create the first node
		xmlNodePtr root = xmlNewDocNode (xmlDoc, NULL, (const xmlChar*)"SOUNDANIMATION", NULL);
		xmlDocSetRootElement (xmlDoc, root);

		vector<CSoundAnimMarker*>::iterator iter;
		for (iter = _Markers.begin(); iter != _Markers.end(); iter++)
		{
			CSoundAnimMarker* marker = (*iter);

			set<string>::iterator iter;

			char s[64];
			smprintf(s, 64, "%f", marker->getTime());

			xmlNodePtr markerNode = xmlNewChild (root, NULL, (const xmlChar*)"MARKER", NULL);
			xmlSetProp (markerNode, (const xmlChar*) "time", (const xmlChar*) s);

			marker->getSounds(sounds);

			vector<NLMISC::CSheetId>::iterator iter2;
			for (iter2 = sounds.begin(); iter2 != sounds.end(); iter2++)
			{
				xmlNodePtr soundNode = xmlNewChild ( markerNode, NULL, (const xmlChar*)"SOUND", NULL );
				xmlSetProp (soundNode, (const xmlChar*)"name", (const xmlChar*)iter2->toString().c_str() /*CStringMapper::unmap(*iter2).c_str()*/);
			}

			sounds.clear();
		}

		// Flush the stream, write all the output file
		output.flush ();
	}

	// Close the file
	file.close ();

	_Dirty = false;
}
コード例 #2
0
// ---------------------------------------------------------------------------
void CGeorgesImpl::createInstanceFile (const std::string &_sxFullnameWithoutExt, const std::string &_dfnname)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CFormLoader formLoader;
	CFormDfn *dfn = formLoader.loadFormDfn (_dfnname.c_str(), false);
	if (!dfn)
	{
		char msg[512];
		smprintf (msg, 512, "Can't load DFN '%s'", _dfnname);
		theApp.outputError (msg);
		return;
	}

	NLMISC::CSmartPtr<NLGEORGES::UForm> Form = new CForm;

	std::string fullName;
	fullName = _sxFullnameWithoutExt + ".";

	int i = 0;
	if (_dfnname[i] == '.') ++i;
	for (; i < (int)_dfnname.size(); ++i)
	{
		if (_dfnname[i] == '.') break;
		fullName += _dfnname[i];
	}

	((CFormElmStruct*)&Form->getRootNode ())->build (dfn);
	COFile f;
	COXml ox;
	if (f.open (fullName))
	{
		ox.init(&f);
		((NLGEORGES::CForm*)((UForm*)Form))->write (ox.getDocument(), _sxFullnameWithoutExt.c_str ());
		ox.flush();
		f.close();
	}
	else
	{
		char msg[512];
		smprintf (msg, 512, "Can't write '%s'", fullName);
		theApp.outputError (msg);
		return;
	}
}
コード例 #3
0
/*
 * Save the ranges into a data file
 */
void				CRangeMirrorManager::saveRanges()
{
	try
	{
		COFile file;
		if ( file.open( RANGE_MANAGER_BACKUP_FILE ) )
		{
			COXml output;
			if ( output.init( &file, "1.0" ) )
			{
				output.serialCont( _RangeListByDataSet );
				output.flush();
			}
			file.close();
		}
		else
			throw EFileNotOpened( RANGE_MANAGER_BACKUP_FILE );
	}
	catch ( Exception& e )
	{
		nlwarning( "Can't save ranges: %s", e.what() );
	}
}
コード例 #4
0
ファイル: misc.cpp プロジェクト: AzyxWare/ryzom
//-----------------------------------------------
// dump :
// Create a file with information to debug.
//-----------------------------------------------
void dump(const std::string &name)
{
	// Write information to start as the version
	COFile fStart;
	if(fStart.open(name + "_start.rec", false, false))
	{
		CVectorD currentPos = UserEntity->pos();
		fStart.serialVersion(RecordVersion);
		fStart.serial(currentPos);
		// Close the File.
		fStart.close();
	}
	else
		nlwarning("dump: cannot open/create the file '%s_start.rec'.", name.c_str());

	// Write the DB
	IngameDbMngr.write(name + "_db.rec");
	// Open the file.
	COFile f;
	if(f.open(name + ".rec", false, false))
	{
		// Dump entities.
		EntitiesMngr.dump(f);

		// Dump Client CFG.
		ClientCfg.serial(f);

		// Close the File.
		f.close();
	}
	else
		nlwarning("dump: cannot open/create the file '%s.rec'.", name.c_str());


	// Open the file.
	if(f.open(name + ".xml", false, true))
	{
		// Create the XML stream
		COXml output;
		// Init
		if(output.init (&f, "1.0"))
		{
			// Open the XML Dump.
			output.xmlPush("XML");

			// Dump Client CFG.
			ClientCfg.serial(output);

			// Dump entities.
			EntitiesMngr.dumpXML(output);

			// Close the XML Dump.
			output.xmlPop();

			// Flush the stream, write all the output file
			output.flush();
		}
		else
			nlwarning("dump: cannot initialize '%s.xml'.", name.c_str());
		// Close the File.
		f.close();
	}
	else
		nlwarning("dump: cannot open/create the file '%s.xml'.", name.c_str());
}// dump //