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"); }
//-------------------------------------------------------------------------------- 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); } } }
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); } } }
ResourceItemInfo::ResourceItemInfo(MyGUI::xml::ElementEnumerator _node, MyGUI::Version _version) : IResource(_node, _version) { MyGUI::xml::ElementEnumerator node = _node->getElementEnumerator(); while (node.next()) { if (node->getName() == "Name") mItemName = node->getContent(); else if (node->getName() == "Description") mItemDescription = node->getContent(); else if (node->getName() == "Image") mItemResourceImage = node->findAttribute("RefID"); }; }
void ResourceW32Pointer::deserialization(MyGUI::xml::ElementPtr _node, MyGUI::Version _version) { Base::deserialization(_node, _version); MyGUI::xml::ElementEnumerator info = _node->getElementEnumerator(); while (info.next()) { if (info->getName() == "Property") { const std::string& key = info->findAttribute("key"); if (key == "SourceFile") { std::string path = MyGUI::DataManager::getInstance().getDataPath(info->getContent()); mHandle = (size_t)LoadCursorFromFileA(path.c_str()); } else if (key == "SourceSystem") { std::string value = info->getContent(); if (value == "IDC_ARROW") mHandle = (size_t)::LoadCursor(NULL, IDC_ARROW); else if (value == "IDC_IBEAM") mHandle = (size_t)::LoadCursor(NULL, IDC_IBEAM); else if (value == "IDC_WAIT") mHandle = (size_t)::LoadCursor(NULL, IDC_WAIT); else if (value == "IDC_CROSS") mHandle = (size_t)::LoadCursor(NULL, IDC_CROSS); else if (value == "IDC_UPARROW") mHandle = (size_t)::LoadCursor(NULL, IDC_UPARROW); else if (value == "IDC_SIZE") mHandle = (size_t)::LoadCursor(NULL, IDC_SIZE); else if (value == "IDC_ICON") mHandle = (size_t)::LoadCursor(NULL, IDC_ICON); else if (value == "IDC_SIZENWSE") mHandle = (size_t)::LoadCursor(NULL, IDC_SIZENWSE); else if (value == "IDC_SIZENESW") mHandle = (size_t)::LoadCursor(NULL, IDC_SIZENESW); else if (value == "IDC_SIZEWE") mHandle = (size_t)::LoadCursor(NULL, IDC_SIZEWE); else if (value == "IDC_SIZENS") mHandle = (size_t)::LoadCursor(NULL, IDC_SIZENS); else if (value == "IDC_SIZEALL") mHandle = (size_t)::LoadCursor(NULL, IDC_SIZEALL); else if (value == "IDC_NO") mHandle = (size_t)::LoadCursor(NULL, IDC_NO); else if (value == "IDC_HAND") mHandle = (size_t)::LoadCursor(NULL, IDC_HAND); else if (value == "IDC_APPSTARTING") mHandle = (size_t)::LoadCursor(NULL, IDC_APPSTARTING); else if (value == "IDC_HELP") mHandle = (size_t)::LoadCursor(NULL, IDC_HELP); } } } }
void HotKeyManager::loadXml(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version) { MyGUI::xml::ElementEnumerator node = _node->getElementEnumerator(); while (node.next("Command")) { HotKeyCommand command; MyGUI::xml::ElementEnumerator nodeCommand = node->getElementEnumerator(); while (nodeCommand.next()) { if (nodeCommand->getName() == "Name") { command.setCommand(nodeCommand->getContent()); } /*else if (nodeCommand->getName() == "Pressed") { command.setPressed(MyGUI::utility::parseValue<bool>(nodeCommand->getContent())); }*/ else if (nodeCommand->getName() == "KeyCode") { MapKeys::const_iterator item = mKeyNames.find(nodeCommand->getContent()); if (item != mKeyNames.end()) { command.setKey((*item).second); } else { // log } } else if (nodeCommand->getName() == "Modifier") { command.setShift(nodeCommand->getContent().find("Shift") != std::string::npos); command.setControl(nodeCommand->getContent().find("Control") != std::string::npos); } } addCommand(command); } }
void ResourceSDLPointer::deserialization(MyGUI::xml::ElementPtr _node, MyGUI::Version _version) { Base::deserialization(_node, _version); MyGUI::xml::ElementEnumerator info = _node->getElementEnumerator(); while (info.next()) { if (info->getName() == "Property") { const std::string& key = info->findAttribute("key"); if (key == "SourceFile") { //std::string path = MyGUI::DataManager::getInstance().getDataPath(info->getContent()); //mCursorType = (size_t)LoadCursorFromFileA(path.c_str()); } else if (key == "SourceSystem") { std::string value = info->getContent(); if (value == "SDL_SYSTEM_CURSOR_ARROW") mCursorType = SDL_SYSTEM_CURSOR_ARROW; else if (value == "SDL_SYSTEM_CURSOR_IBEAM") mCursorType = SDL_SYSTEM_CURSOR_IBEAM; else if (value == "SDL_SYSTEM_CURSOR_WAIT") mCursorType = SDL_SYSTEM_CURSOR_WAIT; else if (value == "SDL_SYSTEM_CURSOR_CROSSHAIR") mCursorType = SDL_SYSTEM_CURSOR_CROSSHAIR; else if (value == "SDL_SYSTEM_CURSOR_SIZENWSE") mCursorType = SDL_SYSTEM_CURSOR_SIZENWSE; else if (value == "SDL_SYSTEM_CURSOR_SIZENESW") mCursorType = SDL_SYSTEM_CURSOR_SIZENESW; else if (value == "SDL_SYSTEM_CURSOR_SIZEWE") mCursorType = SDL_SYSTEM_CURSOR_SIZEWE; else if (value == "SDL_SYSTEM_CURSOR_SIZENS") mCursorType = SDL_SYSTEM_CURSOR_SIZENS; else if (value == "SDL_SYSTEM_CURSOR_SIZEALL") mCursorType = SDL_SYSTEM_CURSOR_SIZEALL; else if (value == "SDL_SYSTEM_CURSOR_NO") mCursorType = SDL_SYSTEM_CURSOR_NO; else if (value == "SDL_SYSTEM_CURSOR_HAND") mCursorType = SDL_SYSTEM_CURSOR_HAND; } } } }
void ExportManager::convertSkin(MyGUI::xml::Element* _from, MyGUI::xml::Element* _to) { _to->addAttribute("type", "ResourceSkin"); _to->addAttribute("name", _from->findAttribute("name")); MyGUI::xml::ElementEnumerator nodes = _from->getElementEnumerator(); while (nodes.next()) { MyGUI::UString coordValue; MyGUI::UString textureValue; MyGUI::xml::Element* node = nodes.current(); if (node->getName() == "PropertySet") { MyGUI::xml::ElementEnumerator propertyNodes = node->getElementEnumerator(); while (propertyNodes.next("Property")) { MyGUI::xml::Element* propertyNode = propertyNodes.current(); std::string name; if (propertyNode->findAttribute("name", name)) { if (name == "Coord") { MyGUI::IntCoord coord = MyGUI::IntCoord::parse(propertyNode->getContent()); coordValue = coord.size().print(); } else if (name == "Texture") { textureValue = propertyNode->getContent(); } } } _to->addAttribute("size", coordValue); _to->addAttribute("texture", textureValue); break; } else if (node->getName() == "RegionItem") { bool regionVisible = true; MyGUI::xml::ElementEnumerator regionNodes = node->getElementEnumerator(); while (regionNodes.next("PropertySet")) { MyGUI::xml::ElementEnumerator propertyNodes = regionNodes->getElementEnumerator(); while (propertyNodes.next("Property")) { MyGUI::xml::Element* propertyNode = propertyNodes.current(); std::string name; if (propertyNode->findAttribute("name", name)) { if (name == "Visible") { if (propertyNode->getContent() != "True") regionVisible = false; } else if (name == "Enabled") { if (propertyNode->getContent() != "True") regionVisible = false; } } } break; } if (!regionVisible) continue; MyGUI::xml::Element* region = _to->createChild("BasisSkin"); MyGUI::IntCoord regionCoord; MyGUI::UString regionTypeValue; MyGUI::UString regionOffsetValue; MyGUI::UString alignValue; regionNodes = node->getElementEnumerator(); while (regionNodes.next("PropertySet")) { MyGUI::xml::ElementEnumerator regionPropertyNode = regionNodes->getElementEnumerator(); while (regionPropertyNode.next("Property")) { std::string name; if (regionPropertyNode->findAttribute("name", name)) { if (name == "RegionType") { regionTypeValue = regionPropertyNode->getContent(); } else if (name == "Position") { regionCoord = MyGUI::IntCoord::parse(regionPropertyNode->getContent()); regionOffsetValue = regionCoord.print(); } else if (name == "Align") { alignValue = regionPropertyNode->getContent(); } } } bool tileHor = true; bool tileVer = true; if (regionTypeValue == "TileRect Hor") { regionTypeValue = "TileRect"; tileVer = false; } else if (regionTypeValue == "TileRect Ver") { regionTypeValue = "TileRect"; tileHor = false; } region->addAttribute("type", regionTypeValue); region->addAttribute("offset", regionOffsetValue); region->addAttribute("align", alignValue); MyGUI::xml::ElementEnumerator stateNodes = _from->getElementEnumerator(); while (stateNodes.next("StateItem")) { bool stateVisible = true; MyGUI::xml::ElementEnumerator propertySetNodes = stateNodes->getElementEnumerator(); while (propertySetNodes.next("PropertySet")) { MyGUI::xml::ElementEnumerator statePropertyNode = propertySetNodes->getElementEnumerator(); while (statePropertyNode.next("Property")) { std::string name; if (statePropertyNode->findAttribute("name", name)) { if (name == "Visible") { if (statePropertyNode->getContent() != "True") stateVisible = false; } } } break; } if (!stateVisible) continue; MyGUI::xml::Element* state = region->createChild("State"); MyGUI::UString stateOffsetValue; MyGUI::UString textColourValue; MyGUI::UString textShiftValue; propertySetNodes = stateNodes->getElementEnumerator(); while (propertySetNodes.next("PropertySet")) { MyGUI::xml::ElementEnumerator propertyNodes = propertySetNodes->getElementEnumerator(); while (propertyNodes.next("Property")) { MyGUI::xml::Element* propertyNode = propertyNodes.current(); std::string name; if (propertyNode->findAttribute("name", name)) { if (name == "Position") { MyGUI::IntCoord coord = regionCoord + MyGUI::IntPoint::parse(propertyNode->getContent()); stateOffsetValue = coord.print(); } else if (name == "TextColour") { textColourValue = propertyNode->getContent(); } else if (name == "TextShift") { textShiftValue = propertyNode->getContent(); } } } break; } MyGUI::UString stateNameValue = stateNodes->findAttribute("name"); state->addAttribute("name", convertStateName(stateNameValue)); if (regionTypeValue == "SimpleText" || regionTypeValue == "EditText") { state->addAttribute("colour", textColourValue); state->addAttribute("shift", textShiftValue); } else { state->addAttribute("offset", stateOffsetValue); if (stateNameValue == "Normal") { if (regionTypeValue == "TileRect") { MyGUI::xml::Element* prop = state->createChild("Property"); prop->addAttribute("key", "TileSize"); prop->addAttribute("value", regionCoord.size().print()); prop = state->createChild("Property"); prop->addAttribute("key", "TileH"); prop->addAttribute("value", MyGUI::utility::toString(tileHor)); prop = state->createChild("Property"); prop->addAttribute("key", "TileV"); prop->addAttribute("value", MyGUI::utility::toString(tileVer)); } } } } break; } } } }