// 获取属性值 Any TriggerObject::getProperty(uint id)const { if(id > ID_NullObject_Begin && id < ID_NullObject_End) return NullObject::getProperty(id); switch(id) { case ID_Trigger: // 触发器设置 { return Any(); } break; case ID_TriggerCondition: // 满足条件 { return Any(getCondition()); } break; case ID_TriggerOnEnterEvent: // 进入事件 { return Any(getOnEnterEvent()); } break; case ID_TriggerOnLeaveEvent: // 退出事件 { return Any(getOnLeaveEvent()); } break; default: return Any(); break; } }
//--------------------------------------------------------------------- WorkQueue::Response* Page::handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ) { // Background thread (maybe) PageRequest preq = any_cast<PageRequest>(req->getData()); // only deal with own requests; we shouldn't ever get here though if (preq.srcPage != this) return 0; PageResponse res; res.pageData = OGRE_NEW PageData(); WorkQueue::Response* response = 0; try { prepareImpl(res.pageData); response = OGRE_NEW WorkQueue::Response(req, true, Any(res)); } catch (Exception& e) { // oops response = OGRE_NEW WorkQueue::Response(req, false, Any(res), e.getFullDescription()); } return response; }
//--------------------------------------------------------------------- WorkQueue::Response* TerrainPagedWorldSection::handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ) { if(mPagesInLoading.empty()) { mHasRunningTasks = false; req->abortRequest(); return OGRE_NEW WorkQueue::Response(req, true, Any()); } unsigned long currentTime = Root::getSingletonPtr()->getTimer()->getMilliseconds(); if(currentTime < mNextLoadingTime) { // Wait until the next page is to be loaded -> we are in background thread here OGRE_THREAD_SLEEP(mNextLoadingTime - currentTime); } PageID pageID = mPagesInLoading.front(); // call the TerrainDefiner from the background thread long x, y; // pageID is the same as a packed index mTerrainGroup->unpackIndex(pageID, &x, &y); if(!mTerrainDefiner) mTerrainDefiner = OGRE_NEW TerrainDefiner(); mTerrainDefiner->define(mTerrainGroup, x, y); // continue loading in main thread return OGRE_NEW WorkQueue::Response(req, true, Any()); }
void Preferences::onChangeHedgeSelection(int) { fl::Engine* engine = Model::Default()->engine(); if (ui->ckx_any->isChecked() and not engine->hasHedge(Any().name())) engine->addHedge(new Any); else if (not ui->ckx_any->isChecked() and engine->hasHedge(Any().name())) delete engine->removeHedge(Any().name()); if (ui->ckx_extremely->isChecked() and not engine->hasHedge(Extremely().name())) engine->addHedge(new Extremely); else if (not ui->ckx_extremely->isChecked() and engine->hasHedge(Extremely().name())) delete engine->removeHedge(Extremely().name()); if (ui->ckx_not->isChecked() and not engine->hasHedge(Not().name())) engine->addHedge(new Not); else if (not ui->ckx_not->isChecked() and engine->hasHedge(Not().name())) delete engine->removeHedge(Not().name()); if (ui->ckx_seldom->isChecked() and not engine->hasHedge(Seldom().name())) engine->addHedge(new Seldom); else if (not ui->ckx_seldom->isChecked() and engine->hasHedge(Seldom().name())) delete engine->removeHedge(Seldom().name()); if (ui->ckx_somewhat->isChecked() and not engine->hasHedge(Somewhat().name())) engine->addHedge(new Somewhat); else if (not ui->ckx_somewhat->isChecked() and engine->hasHedge(Somewhat().name())) delete engine->removeHedge(Somewhat().name()); if (ui->ckx_very->isChecked() and not engine->hasHedge(Very().name())) engine->addHedge(new Very); else if (not ui->ckx_very->isChecked() and engine->hasHedge(Very().name())) delete engine->removeHedge(Very().name()); Window::mainWindow()->fixDependencies(); }
Any Converter<float>::convert(const Any& a) { if (typeid(int) == a.type()) return Any(helper<float, int>::convert(a)); else if (typeid(const char *) == a.type()) return Any(helper<float, const char *>::convert(a)); return any_cast<float>(a); }
Any Converter<float>::convert(const Any& a) { if (Type::from<int>() == a.type()) return Any(helper<float, int>::convert(a)); else if (Type::from<const char *>() == a.type()) return Any(helper<float, const char *>::convert(a)); return any_cast<float>(a); }
// 获取属性值 Any CameraObject::getProperty(uint id)const { if(id > ID_NullObject_Begin && id < ID_NullObject_End) return NullObject::getProperty(id); switch(id) { case ID_Camera: // 摄像机设置 { return Any(); } break; case ID_PolygonMode: // 几何渲染模式 { return Any((long)m_camera->getPolygonMode()); } break; case ID_LodBias: // LOD偏移 { return Any(m_camera->getLodBias()); } break; case ID_NearClipDistance: // 近裁面 { return Any(m_camera->getNearClipDistance()); } break; case ID_FarClipDistance: // 远裁面 { return Any(m_camera->getFarClipDistance()); } break; case ID_FOVy: // FOVy角度 { return Any(m_camera->getFOVy().valueDegrees()); } break; case ID_AspectRatio: // 窗口比率 { return Any(m_camera->getAspectRatio()); } break; case ID_ProjectionType: // 投影方式 { return Any((long)m_camera->getProjectionType()); } break; case ID_OrthoWindow: // 正交投影窗口大小 { return Any(Vector2(m_camera->getOrthoWindowWidth() , m_camera->getOrthoWindowHeight())); } break; default: return Any(); break; } }
Any ArticulatedModel::Instruction::Identifier::toAny() const { if (isAll()) { return Any(Any::ARRAY, "all"); } else if (isRoot()) { return Any(Any::ARRAY, "root"); } else if (id.initialized()) { return Any(int(id)); } else { return Any(name); } }
Any convertToAny(NPP npp, const NPVariant* variant) { switch (variant->type) { case NPVariantType_Void: case NPVariantType_Null: return Any(); break; case NPVariantType_Bool: return NPVARIANT_TO_BOOLEAN(*variant); break; case NPVariantType_Int32: return NPVARIANT_TO_INT32(*variant); break; case NPVariantType_Double: return NPVARIANT_TO_DOUBLE(*variant); break; case NPVariantType_String: return std::string(NPVARIANT_TO_STRING(*variant).utf8characters, NPVARIANT_TO_STRING(*variant).utf8length); break; case NPVariantType_Object: { NPObject* object = NPVARIANT_TO_OBJECT(*variant); if (!object) { break; } if (StubObject::isStub(object)) { StubObject* stub = static_cast<StubObject*>(object); return stub->getObject(); } PluginInstance* instance = static_cast<PluginInstance*>(npp->pdata); if (instance) { ProxyControl* proxyControl = instance->getProxyControl(); if (proxyControl) { return proxyControl->createProxy(object); } } break; } default: break; } return Any(); }
void CCPlayer::Open(const std::string& loadParams) { CCMessageCenter::GetInstance()->PostMessage(MESSAGE_OBJECT_ENUM_CLIENT, MESSAGE_OBJECT_ENUM_PLAYER, COMMAND_TYPE_ENUM_OPEN, Any(loadParams)); }
void CCPlayer::SetVolume(float volume) { CCMessageCenter::GetInstance()->PostMessage(MESSAGE_OBJECT_ENUM_CLIENT, MESSAGE_OBJECT_ENUM_PLAYER, MESSAGE_TYPE_ENUM_SET_VOLUME, Any(volume)); }
void CCPlayer::Stop() { CCMessageCenter::GetInstance()->PostMessage(MESSAGE_OBJECT_ENUM_CLIENT, MESSAGE_OBJECT_ENUM_PLAYER, COMMAND_TYPE_ENUM_STOP, Any()); }
void CCPlayer::Continue() { CCMessageCenter::GetInstance()->PostMessage(MESSAGE_OBJECT_ENUM_CLIENT, MESSAGE_OBJECT_ENUM_PLAYER, COMMAND_TYPE_ENUM_CONTINUE, Any()); }
//--------------------------------------------------------------------- void TerrainPagedWorldSection::loadPage(PageID pageID, bool forceSynchronous) { if (!mParent->getManager()->getPagingOperationsEnabled()) return; PageMap::iterator i = mPages.find(pageID); if (i == mPages.end()) { std::list<PageID>::iterator it = find( mPagesInLoading.begin(), mPagesInLoading.end(), pageID); if(it==mPagesInLoading.end()) { mPagesInLoading.push_back(pageID); mHasRunningTasks = true; } // no running tasks, start the new one if(mPagesInLoading.size()==1) { Root::getSingleton().getWorkQueue()->addRequest( mWorkQueueChannel, WORKQUEUE_LOAD_TERRAIN_PAGE_REQUEST, Any(), 0, forceSynchronous); } } PagedWorldSection::loadPage(pageID, forceSynchronous); }
void StateRoom::accessRoom() { INetworkRelay *network = this->_world->getSharedObject<INetworkRelay>("NetworkRelay"); if (network) { Remote *remote = NULL; if (this->_textboxRoom->getString() != "") this->_textboxRoom->setString("defaulte"); if (!(remote = network->getRemote(0))) throw RTException("Invalid remote"); IBuffer *buffer = network->getTCPBuffer(); *buffer << static_cast<char>(INetworkRelay::CHANGE_ROOM_QUERY); *buffer << this->_textboxRoom->getString(); remote->sendTCP(buffer); Thread<INetworkRelay> *thread = new Thread<INetworkRelay>(); thread->start(network, &INetworkRelay::start, Any()); while (42) { LockVector<IBuffer *> &recv_buffer = remote->getRecvBufferTCP(); auto guard = create_lock(recv_buffer); for (auto it = recv_buffer.begin(); it != recv_buffer.end();) { if (this->parsePacket(recv_buffer, it)) return ; } } } else { throw RTException("Invalid network"); } }
Signature TextureProxy::MakeSignature(const Proxy<res::Image> &image, vid::opengl::TextureFormat format, vid::opengl::TextureFlags flags, const math::Vector<2, bool> &clamp) { std::ostringstream ss(image.GetSignature()); switch (format) { case vid::opengl::defaultTextureFormat: break; case vid::opengl::alphaTextureFormat: ss << ":alpha"; break; case vid::opengl::luminanceTextureFormat: ss << ":luminance"; break; default: assert(!"invalid texture format"); } if (flags & vid::opengl::filterTextureFlag) ss << ":filter"; if (flags & vid::opengl::mipmapTextureFlag) ss << ":mipmap"; if (Any(clamp)) { ss << ":clamp"; if (!clamp.x) ss << ".y"; else if (!clamp.y) ss << ".x"; } return Signature("OpenGL texture", ss.str()); }
RoomServer::RoomServer(ServerRelay *server, const std::string &nameRoomServer) : Room(), _serverRelay(server), _nameRoomServer(nameRoomServer) { std::cout << "Creating new room: " << this->_nameRoomServer << std::endl; this->_runWorldServer = new RunWorldServer(server, nameRoomServer); this->_thread.start(this->_runWorldServer, &RunWorldServer::run, Any()); }
void Instance::LoadModList() { if (GetModListFile().FileExists()) { wxFileInputStream inputStream(GetModListFile().GetFullPath()); wxStringList modListFile = ReadAllLines(inputStream); for (wxStringList::iterator iter = modListFile.begin(); iter != modListFile.end(); iter++) { // Normalize the path to the instMods dir. wxFileName modFile(*iter); modFile.Normalize(wxPATH_NORM_ALL, GetInstModsDir().GetFullPath()); modFile.MakeRelativeTo(); if (!Any(modList.begin(), modList.end(), [&modFile] (Mod mod) -> bool { return mod.GetFileName().SameAs(wxFileName(modFile)); })) { //SetNeedsRebuild(); modList.push_back(Mod(modFile)); } } } for (size_t i = 0; i < modList.size(); i++) { if (!modList[i].GetFileName().FileExists()) { SetNeedsRebuild(); modList.erase(modList.begin() + i); i--; } } LoadModListFromDir(GetInstModsDir()); }
void GameObject::createGameObject(const String &name, const String &meshName) { mEntity = mSceneMgr->createEntity(generateName(name), meshName); mSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); mSceneNode->getUserObjectBindings().setUserAny("GameObject", Any(this)); mSceneNode->attachObject(mEntity); }
void ServiceControl(int offset, const std::string& operation, int ranking) { if (0 <= offset && offset <= 3) { if (operation == "register") { if (!servregs[offset]) { std::stringstream servicename; servicename << SERVICE << offset; InterfaceMap ifm; ifm.insert(std::make_pair(servicename.str(), static_cast<void*>(this))); ServiceProperties props; props.insert(std::make_pair(ServiceConstants::SERVICE_RANKING(), Any(ranking))); servregs[offset] = mc->RegisterService(ifm, props); } } if (operation == "unregister") { if (servregs[offset]) { ServiceRegistrationU sr1 = servregs[offset]; sr1.Unregister(); servregs[offset] = 0; } } } }
std::string csharpformat(std::string fmt, T1 t1) { std::vector<streamable> args; args.push_back(Any(t1)); csharpformat(fmt, arga); }
Any& Any::operator=(Type t) { switch (t) { case NONE: *this = Any(); break; case TABLE: case ARRAY: *this = Any(t); break; default: alwaysAssertM(false, "Can only assign NONE, TABLE, or ARRAY Type enum."); } return *this; }
GLight::operator Any() const { Any a(Any::TABLE, "GLight"); a.set("position", position.operator Any()); a.set("rightDirection", rightDirection.operator Any()); a.set("spotDirection", spotDirection.operator Any()); a.set("spotCutoff", spotCutoff); a.set("spotSquare", spotSquare); Any att(Any::ARRAY); att.append(attenuation[0], attenuation[1], attenuation[2]); a.set("attenuation", att); a.set("color", color.operator Any()); a.set("enabled", enabled); a.set("specular", specular); a.set("diffuse", diffuse); return a; }
/** * * \param pluginName * \param nPageX * \param nPageY * \param vPos * \param nMinBatchSize * \param nMaxBatchSize * \param nLayerCount * \param tpl * \param bAtOnceLoad * \return */ EditorTerrainPage::EditorTerrainPage(const String& pluginName, int nPageX, int nPageY, const Vector3& vPos, uint16 nMinBatchSize, uint16 nMaxBatchSize, uint16 nLayerCount, const STerrainPageLayer& tpl, bool bAtOnceLoad) : EditorPlugin(pluginName), m_pTerrain(NULL), m_pSaveHeight(NULL) { m_AlterRect = Rect(0, 0, 0, 0); if (configure(nPageX, nPageY, vPos, nMinBatchSize, nMaxBatchSize, nLayerCount, tpl, bAtOnceLoad)) { addProperty(terrainPageName[TERRAINPAGE_PLUGIN_NAME], Any(pluginName), PVT_STRING, 0, terrainPageDesc[TERRAINPAGE_PLUGIN_NAME]); addProperty(terrainPageName[TERRAINPAGE_LAYERCOUNT], Any(nLayerCount), PVT_USHORT, true, terrainPageDesc[TERRAINPAGE_LAYERCOUNT]); addProperty(terrainPageName[TERRAINPAGE_PAGEX], Any(nPageX), PVT_INT, true, terrainPageDesc[TERRAINPAGE_PAGEX]); addProperty(terrainPageName[TERRAINPAGE_PAGEY], Any(nPageY), PVT_INT, true, terrainPageDesc[TERRAINPAGE_PAGEY]); } }
void Scale::SetScale(const math::Vec3 &value) { // NOTE: comparing value to avoid redundant dirty marking if (Any(value != this->value)) { this->value = value; dirtyTransformSig(); } }
Any ModuleManifest::GetValue(const std::string& key) const { AnyMap::const_iterator iter = m_Properties.find(key); if (iter != m_Properties.end()) { return iter->second; } return Any(); }
// 创建对象实体 void BoxTriggerObject::create(IScene *scene , const NameValuePairList* params) { destroy(); NullObject::create(scene , params); // 创建实体 m_entity = m_scene->getTriggerWorld()->createBoxTriggerEntity(getFullName()); m_entity->setUserAny(Any(static_cast<ISceneObject*>(this))); m_node->setListener(this); }
std::string CppExporter::toString(const Hedge * hedge) const { if (hedge->name() == Any().name()) return "new " + fl("Any"); if (hedge->name() == Extremely().name()) return "new " + fl("Extremely"); if (hedge->name() == Not().name()) return "new " + fl("Not"); if (hedge->name() == Seldom().name()) return "new " + fl("Seldom"); if (hedge->name() == Somewhat().name()) return "new " + fl("Somewhat"); if (hedge->name() == Very().name()) return "new " + fl("Very"); return "new " + fl(hedge->name()); }
HedgeFactory::HedgeFactory() : ConstructionFactory<Hedge*>("Hedge") { registerConstructor("", fl::null); registerConstructor(Any().name(), &(Any::constructor)); registerConstructor(Extremely().name(), &(Extremely::constructor)); registerConstructor(Not().name(), &(Not::constructor)); registerConstructor(Seldom().name(), &(Seldom::constructor)); registerConstructor(Somewhat().name(), &(Somewhat::constructor)); registerConstructor(Very().name(), &(Very::constructor)); }
std::string CppExporter::toString(const Hedge * hedge) const { if (hedge->name() == Any().name()) return "new fl::Any"; if (hedge->name() == Extremely().name()) return "new fl::Extremely"; if (hedge->name() == Not().name()) return "new fl::Not"; if (hedge->name() == Seldom().name()) return "new fl::Seldom"; if (hedge->name() == Somewhat().name()) return "new fl::Somewhat"; if (hedge->name() == Very().name()) return "new fl::Very"; return hedge->name(); }