void MainPage::createActions(void) { MAction *newAction = new MAction("icon-m-toolbar-add", tr("Create a new tag"), this); newAction->setLocation(MAction::ToolBarLocation); connect(newAction, SIGNAL(triggered()), this, SLOT(createTag())); addAction(newAction); MAction *killallAction = new MAction(tr("Remove all tags"), this); killallAction->setLocation(MAction::ApplicationMenuLocation); connect(killallAction, SIGNAL(triggered()), this, SLOT(removeAllTags())); addAction(killallAction); MAction *aboutAction = new MAction(tr("About..."), this); aboutAction->setLocation(MAction::ApplicationMenuLocation); connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout())); addAction(aboutAction); MAction *helpAction = new MAction(tr("Instructions..."), this); helpAction->setLocation(MAction::ApplicationMenuLocation); connect(helpAction, SIGNAL(triggered()), this, SLOT(showHelp())); addAction(helpAction); }
//------------------------------------------------------------------------------ void Entity::unserializeState(const Variant & o, const SerializationContext & context) { // Name m_name = o["name"].getString(); // Enabled flag bool bEnabled = false; sn::unserialize(o["enabled"], bEnabled, true); setFlag(SN_EF_ENABLED, bEnabled); // Deserialize tags removeAllTags(); std::unordered_set<std::string> tags; sn::unserialize(o["tags"], tags); for (auto it = tags.begin(); it != tags.end(); ++it) { const std::string & tagName = *it; addTag(tagName); } // Script auto & script = o["script"]; if (script.isDictionary()) { std::string classPath = script["class"].getString(); if (!classPath.empty()) { // TODO should be context.squirrelVM HSQUIRRELVM vm = Application::get().getScriptManager().getVM(); if (m_script.create(vm, classPath)) { // Set the "entity" member if (pushScriptObject(vm)) { HSQOBJECT entityObj; sq_getstackobj(vm, -1, &entityObj); m_script.setMember("entity", entityObj); sq_pop(vm, 1); // pop entityObj } // Call onCreate m_script.callMethod("onCreate"); } } } // TODO Unserialize script members }
//------------------------------------------------------------------------------ Entity::~Entity() { if (r_parent) r_parent->removeChild(this); destroyChildren(); removeAllTags(); // Unregister update callback if (getFlag(SN_EF_UPDATABLE)) setUpdatable(false); if (getFlag(SN_EF_SYSTEM_EVENT_LISTENER)) listenToSystemEvents(false); //SN_LOG("Entity " << getName() << " destroyed"); }