本文整理汇总了C++中gd::Project::SetDirty方法的典型用法代码示例。如果您正苦于以下问题:C++ Project::SetDirty方法的具体用法?C++ Project::SetDirty怎么用?C++ Project::SetDirty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::Project
的用法示例。
在下文中一共展示了Project::SetDirty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromFile
bool ProjectFileWriter::LoadFromFile(gd::Project & project, const gd::String & filename)
{
//Load the XML document structure
TiXmlDocument doc;
if ( !doc.LoadFile(filename.ToLocale().c_str()) )
{
gd::String errorTinyXmlDesc = doc.ErrorDesc();
gd::String error = _( "Error while loading :" ) + "\n" + errorTinyXmlDesc + "\n\n" +_("Make sure the file exists and that you have the right to open the file.");
gd::LogError( error );
return false;
}
#if defined(GD_IDE_ONLY)
project.SetProjectFile(filename);
project.SetDirty(false);
#endif
TiXmlHandle hdl( &doc );
gd::SerializerElement rootElement;
ConvertANSIXMLFile(hdl, doc, filename);
//Load the root element
TiXmlElement * rootXmlElement = hdl.FirstChildElement("project").ToElement();
//Compatibility with GD <= 3.3
if (!rootXmlElement) rootXmlElement = hdl.FirstChildElement("Project").ToElement();
if (!rootXmlElement) rootXmlElement = hdl.FirstChildElement("Game").ToElement();
//End of compatibility code
gd::Serializer::FromXML(rootElement, rootXmlElement);
//Unsplit the project
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
wxString projectPath = wxFileName::FileName(filename).GetPath();
gd::Splitter splitter;
splitter.Unsplit(rootElement, [&projectPath](gd::String path, gd::String name) {
TiXmlDocument doc;
gd::SerializerElement rootElement;
gd::String filename = projectPath + path + "-" + MakeFileNameSafe(name);
if (!doc.LoadFile(filename.ToLocale().c_str()))
{
gd::String errorTinyXmlDesc = doc.ErrorDesc();
gd::String error = _( "Error while loading :" ) + "\n" + errorTinyXmlDesc + "\n\n" +_("Make sure the file exists and that you have the right to open the file.");
gd::LogError(error);
return rootElement;
}
TiXmlHandle hdl( &doc );
gd::Serializer::FromXML(rootElement, hdl.FirstChildElement().ToElement());
return rootElement;
});
#endif
//Unserialize the whole project
project.UnserializeFrom(rootElement);
return true;
}
示例2: LoadFromJSONFile
bool ProjectFileWriter::LoadFromJSONFile(gd::Project & project, const gd::String & filename)
{
std::ifstream ifs(filename.ToLocale().c_str());
if (!ifs.is_open())
{
gd::String error = _( "Unable to open the file.") + _("Make sure the file exists and that you have the right to open the file.");
gd::LogError(error);
return false;
}
project.SetProjectFile(filename);
project.SetDirty(false);
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
gd::SerializerElement rootElement = gd::Serializer::FromJSON(str);
project.UnserializeFrom(rootElement);
return true;
}