bool Actions::loadFromXml(const std::string &_datadir) { this->loaded = false; Action *action = NULL; datadir = _datadir; std::string filename = datadir + "actions/actions.xml"; std::transform(filename.begin(), filename.end(), filename.begin(), tolower); xmlDocPtr doc = xmlParseFile(filename.c_str()); if (doc){ this->loaded=true; xmlNodePtr root, p; root = xmlDocGetRootElement(doc); if (xmlStrcmp(root->name,(const xmlChar*) "actions")){ xmlFreeDoc(doc); return false; } p = root->children; while (p) { const char* str = (char*)p->name; if (strcmp(str, "action") == 0){ int itemid,uniqueid,actionid; if(readXMLInteger(p,"itemid",itemid)){ action = loadAction(p); useItemMap[itemid] = action; action = NULL; } else if(readXMLInteger(p,"uniqueid",uniqueid)){ action = loadAction(p); uniqueItemMap[uniqueid] = action; action = NULL; } else if(readXMLInteger(p,"actionid",actionid)){ action = loadAction(p); actionItemMap[actionid] = action; action = NULL; } else{ std::cout << "missing action id." << std::endl; } } p = p->next; } xmlFreeDoc(doc); } return this->loaded; }
boost::shared_ptr<Action> Root::loadAction(const pugi::xml_node &node) { // XXX: This needs to be kept synchronized with the editor enum NodeType { Empty, Speech, Emote, Sequence, Concurrent, Conditional, Jump, EndConversation }; NodeType type = (NodeType)node.attribute("type").as_int(); switch(type) { case Empty: Message3(Game, Debug, "Empty action found!"); return boost::shared_ptr<Action>(); case Speech: /*Message3(Game, Debug, "Speech action found! [" << node.attribute("speaker").as_string() << "]: " << node.attribute("speech").as_string());*/ return boost::shared_ptr<Action>(); case Emote: return boost::shared_ptr<Action>(); case Sequence: { auto ret = boost::make_shared<SequenceAction>(); for(auto n = node.first_child(); n; n = n.next_sibling()) { ret->addAction(loadAction(n)); } return ret; } case Concurrent: { auto ret = boost::make_shared<ConcurrentAction>(); for(auto n = node.first_child(); n; n = n.next_sibling()) { ret->addAction(loadAction(n)); } return ret; } case Conditional: case Jump: case EndConversation: break; } return boost::shared_ptr<Action>(); }
void SpriteDef::loadSprite(xmlNodePtr spriteNode, int variant, const std::string &palettes) { // Get the variant const int variantCount = XML::getProperty(spriteNode, "variants", 0); int variant_offset = 0; if (variantCount > 0 && variant < variantCount) { variant_offset = variant * XML::getProperty(spriteNode, "variant_offset", 0); } for_each_xml_child_node(node, spriteNode) { if (xmlStrEqual(node->name, BAD_CAST "imageset")) { loadImageSet(node, palettes); } else if (xmlStrEqual(node->name, BAD_CAST "action")) { loadAction(node, variant_offset); } else if (xmlStrEqual(node->name, BAD_CAST "include")) { includeSprite(node); } } }
void CWorld::LoadLOD() { loadMob(); loadShop(); loadSkill(); loadSkillTree(); loadArmorPreview(); loadSSkill(); loadAction(); loadItemData(); loadSetItemData(); loadAffinity(); loadMakeItem(); loadCatalog(); loadEvent(); loadNPCHelp(); loadCombo(); loadBigpet(); loadRareOption(); loadOption(); loadTitleData(); loadQuest(); loadLacarette(); loadZone(); loadNotice(); loadEntity(); loadZoneData(); loadTEventString(); loadLevelUpGuide(); loadChangeEquipment(); LoadItemCollection(); LoadItemCompose(); }
void Root::loadNode(int id, const pugi::xml_node &node) { auto n = m_nodeMap[id]; if(!std::strcmp(node.attribute("entry").as_string(), "true")) m_rootNode = n; for(auto a = node.first_child(); ; a = a.next_sibling()) { auto action = loadAction(a); if(a == node.last_child()) break; } }
StateManagerWindow::StateManagerWindow() { layout = new QVBoxLayout; layout->setMargin(Style::WindowMargin); layout->setSpacing(Style::WidgetSpacing); setLayout(layout); list = new QTreeWidget; list->setColumnCount(2); list->setHeaderLabels(QStringList() << "Slot" << "Description"); list->setAllColumnsShowFocus(true); list->sortByColumn(0, Qt::AscendingOrder); list->setRootIsDecorated(false); list->resizeColumnToContents(0); layout->addWidget(list); infoLayout = new QHBoxLayout; layout->addLayout(infoLayout); descriptionLabel = new QLabel("Description:"); infoLayout->addWidget(descriptionLabel); descriptionText = new QLineEdit; infoLayout->addWidget(descriptionText); controlLayout = new QHBoxLayout; layout->addLayout(controlLayout); spacer = new QWidget; spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); controlLayout->addWidget(spacer); loadButton = new QPushButton("Load"); controlLayout->addWidget(loadButton); saveButton = new QPushButton("Save"); controlLayout->addWidget(saveButton); eraseButton = new QPushButton("Erase"); controlLayout->addWidget(eraseButton); connect(list, SIGNAL(itemSelectionChanged()), this, SLOT(synchronize())); connect(list, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(loadAction())); connect(descriptionText, SIGNAL(textEdited(const QString&)), this, SLOT(writeDescription())); connect(loadButton, SIGNAL(released()), this, SLOT(loadAction())); connect(saveButton, SIGNAL(released()), this, SLOT(saveAction())); connect(eraseButton, SIGNAL(released()), this, SLOT(eraseAction())); synchronize(); }
static std::error_code loadRule(ExecState& exec, const JSObject& ruleObject, Vector<ContentExtensionRule>& ruleList) { Trigger trigger; auto triggerError = loadTrigger(exec, ruleObject, trigger); if (triggerError) return triggerError; Action action; bool validSelector; auto actionError = loadAction(exec, ruleObject, action, validSelector); if (actionError) return actionError; if (validSelector) ruleList.append(ContentExtensionRule(trigger, action)); return { }; }
void run() { switch (routes[action]) { case LOAD: loadAction(); break; case INSERT: insertAction(); break; case FIND: findAction(); break; case REMOVE: removeAction(); break; case CLEAR: clearAction(); break; case DELETE: deleteAction(); break; case SHOW: showAction(); break; case TEST: testAction(); break; case HELP: helpAction(); break; case REPORT: reportAction(); break; default: usageAction(); break; } }
void LocationBar::keyPressEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_V: if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) { pasteAndGo(); event->accept(); return; } break; case Qt::Key_Down: m_completer->complete(text()); break; case Qt::Key_Left: m_completer->closePopup(); break; case Qt::Key_Escape: m_webView->setFocus(); showUrl(m_webView->url()); event->accept(); break; case Qt::Key_Alt: m_holdingAlt = true; break; case Qt::Key_Return: case Qt::Key_Enter: switch (event->modifiers()) { case Qt::ControlModifier: if (!text().endsWith(QL1S(".com"))) setText(text().append(QL1S(".com"))); requestLoadUrl(); m_holdingAlt = false; break; case Qt::AltModifier: m_completer->closePopup(); if (m_window) { m_window->tabWidget()->addView(loadAction(text()).loadRequest); } m_holdingAlt = false; break; default: requestLoadUrl(); m_holdingAlt = false; } break; case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3: case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9: if (event->modifiers() & Qt::AltModifier || event->modifiers() & Qt::ControlModifier) { event->ignore(); m_holdingAlt = false; return; } break; default: m_holdingAlt = false; } LineEdit::keyPressEvent(event); }
void LocationBar::requestLoadUrl() { loadRequest(loadAction(text()).loadRequest); }