本文整理汇总了C++中mygui::xml::Document类的典型用法代码示例。如果您正苦于以下问题:C++ Document类的具体用法?C++ Document怎么用?C++ Document使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupResources
void BaseManager::setupResources()
{
MyGUI::xml::Document doc;
if (!doc.open(std::string("resources.xml")))
doc.getLastError();
MyGUI::xml::ElementPtr root = doc.getRoot();
if (root == nullptr || root->getName() != "Paths")
return;
MyGUI::xml::ElementEnumerator node = root->getElementEnumerator();
while (node.next())
{
if (node->getName() == "Path")
{
if (node->findAttribute("root") != "")
{
bool root = MyGUI::utility::parseBool(node->findAttribute("root"));
if (root)
mRootMedia = node->getContent();
}
addResourceLocation(node->getContent(), false);
}
}
addResourceLocation(getRootMedia() + "/Common/Base");
}
示例2: setupResources
void MYGUIManager::setupResources()
{
MyGUI::xml::Document doc;
if ( !_platform || !doc.open(_resourcePathFile) ) doc.getLastError();
MyGUI::xml::ElementPtr root = doc.getRoot();
if ( root==nullptr || root->getName()!="Paths" ) return;
MyGUI::xml::ElementEnumerator node = root->getElementEnumerator();
while ( node.next() )
{
if ( node->getName()=="Path" )
{
bool root = false, recursive = false;
if (!node->findAttribute("root").empty())
{
root = MyGUI::utility::parseBool( node->findAttribute("root") );
if ( root ) _rootMedia = node->getContent();
}
if (!node->findAttribute("recursive").empty())
{
recursive = MyGUI::utility::parseBool(node->findAttribute("recursive"));
}
_platform->getDataManagerPtr()->addResourceLocation(node->getContent(), recursive);
}
}
}
示例3: isMetaSolution
bool EditorState::isMetaSolution(const MyGUI::UString& _fileName)
{
MyGUI::xml::Document doc;
if (!doc.open(_fileName))
{
return false;
}
MyGUI::xml::ElementPtr root = doc.getRoot();
if (!root || (root->getName() != "MyGUI"))
{
return false;
}
std::string type;
if (root->findAttribute("type", type))
{
if (type == "MetaSolution")
{
return true;
}
}
return false;
}
示例4: Setup
//--------------------------------------------------------------------------------
void System::Setup()
{
MyGUI::xml::Document doc;
if (!doc.open(std::string("resources.xml")))
doc.getLastError();
MyGUI::xml::ElementPtr root = doc.getRoot();
if (root == nullptr || root->getName() != "Paths")
return;
MyGUI::xml::ElementEnumerator node = root->getElementEnumerator();
while (node.next())
{
if (node->getName() == "Path")
{
bool root = false;
if (node->findAttribute("root") != "")
{
root = MyGUI::utility::parseBool(node->findAttribute("root"));
if (root) mRootMedia = node->getContent();
}
mPlatform->getDataManagerPtr()->addResourceLocation(node->getContent(), false);
}
}
}
示例5: generateSkin
void TestWindow::generateSkin()
{
if (MyGUI::ResourceManager::getInstance().isExist(mSkinName))
MyGUI::ResourceManager::getInstance().removeByName(mSkinName);
pugi::xml_document doc;
pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
decl.append_attribute("version") = "1.0";
decl.append_attribute("encoding") = "UTF-8";
pugi::xml_node root = doc.append_child("MyGUI");
root.append_attribute("type").set_value("Resource");
root.append_attribute("version").set_value("1.1");
SkinExportSerializer* serializer = new SkinExportSerializer();
serializer->writeSkin(root, mSkinItem);
delete serializer;
root.select_single_node("Resource/@name").attribute().set_value(mSkinName.c_str());
bool result = doc.save_file(mTestSkinFileName.c_str(), "\t", (pugi::format_indent | pugi::format_write_bom | pugi::format_win_new_line) & (~pugi::format_space_before_slash));
MyGUI::xml::Document docLoad;
docLoad.open(mTestSkinFileName);
MyGUI::xml::Element* resourceNode = docLoad.getRoot();
MyGUI::ResourceManager::getInstance().loadFromXmlNode(resourceNode, "", MyGUI::Version(1, 1, 0));
}
示例6: saveFontTTFXml
void FontPanel::saveFontTTFXml(const std::string& _fontName, const std::string& _fileName)
{
MyGUI::xml::Document document;
document.createDeclaration();
MyGUI::xml::ElementPtr root = document.createRoot("MyGUI");
generateFontTTFXml(root, _fontName);
if (document.save(_fileName))
MyGUI::Message::createMessageBox("Message", "success", _fileName, MyGUI::MessageBoxStyle::Ok | MyGUI::MessageBoxStyle::IconInfo);
else
MyGUI::Message::createMessageBox("Message", "error", document.getLastError(), MyGUI::MessageBoxStyle::Ok | MyGUI::MessageBoxStyle::IconError);
}
示例7: load
void EditorState::load()
{
SkinManager::getInstance().clear();
MyGUI::xml::Document doc;
if (doc.open(mFileName))
{
bool result = false;
MyGUI::xml::Element* root = doc.getRoot();
if (root->getName() == "Root")
{
MyGUI::xml::ElementEnumerator nodes = root->getElementEnumerator();
while (nodes.next("SkinManager"))
{
SkinManager::getInstance().deserialization(nodes.current(), MyGUI::Version());
result = true;
if (mFileName != mDefaultFileName)
RecentFilesManager::getInstance().addRecentFile(mFileName);
break;
}
}
if (!result)
{
/*MyGUI::Message* message =*/ MessageBoxManager::getInstance().create(
replaceTags("Error"),
replaceTags("MessageIncorrectFileFormat"),
MyGUI::MessageBoxStyle::IconError
| MyGUI::MessageBoxStyle::Yes);
mFileName = mDefaultFileName;
addUserTag("CurrentFileName", mFileName);
updateCaption();
}
}
else
{
/*MyGUI::Message* message =*/ MessageBoxManager::getInstance().create(
replaceTags("Error"),
doc.getLastError(),
MyGUI::MessageBoxStyle::IconError
| MyGUI::MessageBoxStyle::Yes);
}
ActionManager::getInstance().setChanges(false);
}
示例8: save
void EditorState::save()
{
MyGUI::xml::Document doc;
doc.createDeclaration();
MyGUI::xml::Element* root = doc.createRoot("Root");
MyGUI::xml::Element* skins = root->createChild("SkinManager");
SkinManager::getInstance().serialization(skins, MyGUI::Version());
doc.save(mFileName);
if (mFileName != mDefaultFileName)
RecentFilesManager::getInstance().addRecentFile(mFileName);
ActionManager::getInstance().setChanges(false);
}
示例9: notifyMouseButtonClick
void FontPanel::notifyMouseButtonClick(MyGUI::Widget* _widget)
{
// шрифтов нету
if (mComboFont->getOnlyText().empty())
return;
if (mEditSaveFileName->getOnlyText().empty() && _widget == mButtonSave)
return;
if (_widget == mButtonSave)
{
std::string textureName = mEditSaveFileName->getOnlyText() + ".png";
saveTexture(mFontName, textureName);
std::string fontName = MyGUI::utility::toString(mEditSaveFileName->getOnlyText(), ".ttf.", mFontHeight);
std::string fileName = mEditSaveFileName->getOnlyText() + ".ttf.xml";
saveFontTTFXml(fontName, fileName);
fontName = MyGUI::utility::toString(mEditSaveFileName->getOnlyText(), ".manual.", mFontHeight);
fileName = mEditSaveFileName->getOnlyText() + ".manual.xml";
saveFontManualXml(fontName, textureName, fileName);
}
else if (_widget == mButtonGenerate)
{
MyGUI::ResourceManager& manager = MyGUI::ResourceManager::getInstance();
if (manager.isExist(mFontName))
{
manager.removeByName(mFontName);
}
MyGUI::xml::Document document;
document.createDeclaration();
MyGUI::xml::ElementPtr root = document.createRoot("MyGUI");
generateFontTTFXml(root, mFontName);
MyGUI::ResourceManager::getInstance().loadFromXmlNode(root, "", MyGUI::Version());
MyGUI::IResource* resource = manager.getByName(mFontName, false);
MYGUI_ASSERT(resource != nullptr, "Could not find font '" << mFontName << "'");
MyGUI::IFont* font = resource->castType<MyGUI::IFont>();
// вывод реального размера шрифта
mFontHeight = font->getDefaultHeight();
mTextPix->setCaption(MyGUI::utility::toString("Height of a font is ", mFontHeight, " pixels"));
mFontView->setFontName(mFontName);
mTextureView->setFontName(mFontName);
}
}
示例10: convertProjectName
MyGUI::UString EditorState::convertProjectName(const MyGUI::UString& _fileName)
{
size_t pos = mFileName.find_last_of("\\/");
MyGUI::UString shortName = pos == MyGUI::UString::npos ? mFileName : mFileName.substr(pos + 1);
addUserTag("ResourceName", shortName);
size_t index = _fileName.find("|");
if (index == MyGUI::UString::npos)
return _fileName;
MyGUI::UString fileName = _fileName.substr(0, index);
MyGUI::UString itemIndexName = _fileName.substr(index + 1);
size_t itemIndex = MyGUI::utility::parseValue<size_t>(itemIndexName);
MyGUI::xml::Document doc;
if (!doc.open(fileName))
return _fileName;
MyGUI::xml::ElementPtr root = doc.getRoot();
if ((nullptr == root) || (root->getName() != "MyGUI"))
return _fileName;
if (root->findAttribute("type") == "Resource")
{
// берем детей и крутимся
MyGUI::xml::ElementEnumerator element = root->getElementEnumerator();
while (element.next("Resource"))
{
if (element->findAttribute("type") == "ResourceLayout")
{
if (itemIndex == 0)
{
// поменять на теги
std::string resourceName = element->findAttribute("name");
addUserTag("ResourceName", resourceName);
return MyGUI::utility::toString(fileName, " [", resourceName, "]");
}
else
{
itemIndex --;
}
}
}
}
return _fileName;
}
示例11: notifyMouseButtonClick
void FontPanel::notifyMouseButtonClick(MyGUI::Widget* _widget)
{
// шрифто?нету
if (mComboFont->getOnlyText().empty()) return;
if (mEditSaveFileName->getOnlyText().empty() && _widget == mButtonSave) return;
MyGUI::xml::Document document;
document.createDeclaration();
MyGUI::xml::ElementPtr root = document.createRoot("MyGUI");
generateFontTTFXml(root);
if (_widget == mButtonSave)
{
if (!document.save(mEditSaveFileName->getOnlyText() + ".xml"))
{
/*MyGUI::Message* message =*/ MyGUI::Message::createMessageBox("Message", "error", document.getLastError(), MyGUI::MessageBoxStyle::Ok | MyGUI::MessageBoxStyle::IconError);
}
else
{
/*MyGUI::Message* message =*/ MyGUI::Message::createMessageBox("Message", "success", mEditSaveFileName->getOnlyText() + ".xml", MyGUI::MessageBoxStyle::Ok | MyGUI::MessageBoxStyle::IconInfo);
}
MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(mFontName);
MyGUI::ITexture* texture = font->getTextureFont();
texture->saveToFile(mEditSaveFileName->getOnlyText() + ".png");
}
else if (_widget == mButtonGenerate)
{
MyGUI::ResourceManager& manager = MyGUI::ResourceManager::getInstance();
if (manager.isExist(mFontName))
{
manager.removeByName(mFontName);
}
MyGUI::ResourceManager::getInstance().loadFromXmlNode(root, "", MyGUI::Version());
MyGUI::IResource* resource = manager.getByName(mFontName, false);
MYGUI_ASSERT(resource != nullptr, "Could not find font '" << mFontName << "'");
MyGUI::IFont* font = resource->castType<MyGUI::IFont>();
// выво?реальног?размер?шрифта
mFontHeight = font->getDefaultHeight();
mTextPix->setCaption(MyGUI::utility::toString("Height of a font is ", mFontHeight, " pixels"));
mFontView->setFontName(mFontName);
mTextureView->setFontName(mFontName);
}
}
示例12: saveSettings
void SettingsManager::saveSettings(const MyGUI::UString& _fileName)
{
std::string _instance = "Editor";
MyGUI::xml::Document doc;
doc.createDeclaration();
MyGUI::xml::ElementPtr root = doc.createRoot("MyGUI");
root->addAttribute("type", "Settings");
saveSectors(root);
if (!doc.save(_fileName))
{
MYGUI_LOGGING(LogSection, Error, _instance << " : " << doc.getLastError());
return;
}
}
示例13: exportData
bool FontExportSerializer::exportData(const MyGUI::UString& _folderName, const MyGUI::UString& _fileName)
{
MyGUI::xml::Document document;
document.createDeclaration();
MyGUI::xml::ElementPtr root = document.createRoot("MyGUI");
root->addAttribute("type", "Resource");
root->addAttribute("version", "1.1");
DataPtr data = DataManager::getInstance().getRoot();
for (Data::VectorData::const_iterator child = data->getChilds().begin(); child != data->getChilds().end(); child ++)
{
generateFont((*child));
generateFontManualXml(root, _folderName, (*child));
}
return document.save(common::concatenatePath(_folderName, _fileName));
}
示例14: save
bool HotkeyManager::save( string xml )
{
MyGUI::xml::Document doc;
string path = Game::getSingleton().getResourcePath() + xml;
MyGUI::xml::ElementPtr root = doc.createRoot("HKS");
doc.createDeclaration();
MyGUI::xml::ElementPtr node;
for( HotkeyTable::iterator it = mHotkeys.begin();it!=mHotkeys.end();++it )
{
node = root->createChild("hotkey");
node->addAttribute("name",it->mName);
node->addAttribute("caption",it->mCaption);
node->addAttribute("tip",it->mTip);
node->addAttribute("key",it->mHotkey);
}
return doc.save( path );
}
示例15: saveSettings
void EditorState::saveSettings(const MyGUI::UString& _fileName)
{
std::string _instance = "Editor";
MyGUI::xml::Document doc;
doc.createDeclaration();
MyGUI::xml::ElementPtr root = doc.createRoot("MyGUI");
root->addAttribute("type", "Settings");
mPropertiesPanelView->save(root);
mSettingsWindow->save(root);
mWidgetsWindow->save(root);
mMetaSolutionWindow->save(root);
// cleanup for duplicates
std::reverse(recentFiles.begin(), recentFiles.end());
for (size_t i = 0; i < recentFiles.size(); ++i)
recentFiles.erase(std::remove(recentFiles.begin() + i + 1, recentFiles.end(), recentFiles[i]), recentFiles.end());
// remove old files
while (recentFiles.size() > MAX_RECENT_FILES)
recentFiles.pop_back();
std::reverse(recentFiles.begin(), recentFiles.end());
for (std::vector<MyGUI::UString>::iterator iter = recentFiles.begin(); iter != recentFiles.end(); ++iter)
{
MyGUI::xml::ElementPtr nodeProp = root->createChild("RecentFile");
nodeProp->addAttribute("name", *iter);
}
for (std::vector<MyGUI::UString>::iterator iter = additionalPaths.begin(); iter != additionalPaths.end(); ++iter)
{
MyGUI::xml::ElementPtr nodeProp = root->createChild("AdditionalPath");
nodeProp->addAttribute("name", *iter);
}
if (!doc.save(_fileName))
{
MYGUI_LOGGING(LogSection, Error, _instance << " : " << doc.getLastError());
return;
}
}