fwRefContainer<Component> ComponentData::CreateManualInstance() { fwRefContainer<Component> instance = CreateComponent(); m_instances.push_back(instance); return instance; }
ComponentPtr Entity::GetOrCreateComponent(u32 typeId, AttributeChange::Type change, bool replicated) { ComponentPtr existing = Component(typeId); if (existing) return existing; return CreateComponent(typeId, change, replicated); }
ComponentPtr Entity::GetOrCreateComponent(u32 typeId, const QString &name, AttributeChange::Type change, bool replicated) { ComponentPtr new_comp = Component(typeId, name); if (new_comp) return new_comp; return CreateComponent(typeId, name, change, replicated); }
ComponentPtr Entity::GetOrCreateComponent(const QString &type_name, const QString &name, AttributeChange::Type change, bool replicated) { ComponentPtr existing = Component(type_name, name); if (existing) return existing; return CreateComponent(type_name, name, change, replicated); }
ComponentPtr Entity::GetOrCreateComponent(const QString &type_name, const QString &name, AttributeChange::Type change, bool syncEnabled) { ComponentPtr new_comp = GetComponent(type_name, name); if (new_comp) return new_comp; return CreateComponent(type_name, name, change, syncEnabled); }
Component* Node::GetOrCreateComponent(ShortStringHash type, CreateMode mode) { Component* oldComponent = GetComponent(type); if (oldComponent) return oldComponent; else return CreateComponent(type, mode); }
ComponentPtr Entity::GetOrCreateComponent(uint type_hash, const QString &name, AttributeChange::Type change) { ComponentPtr new_comp = GetComponent(type_hash, name); if (new_comp) return new_comp; return CreateComponent(type_hash, name, change); }
void TLevelScene::loadObjects(const Parameters& info) { for (const auto& objectInfo : info.objects) { Object object; for (const auto& componentInfo : objectInfo.components) { const auto componentHandle = CreateComponent(componentInfo.id, componentInfo.parameters.get()); object.AddComponent(componentInfo.name, componentHandle); } AddSceneObject(objectInfo.name, std::move(object)); } }
CGameObject* CFactory::CreateGameObject(const string &AClassName, const string &AName /*= ""*/, bool AFinalizeCreation /*= true*/) { CGameObject *result; if (IsComponentExists(AClassName)) result = CreateComponent(AClassName, AName, AFinalizeCreation); else result = InstantiatePrototype(AClassName, AName); return result; }
OMX_ERRORTYPE PureOmxPlatformLayer::InitOmxToStateLoaded(const TrackInfo* aInfo) { LOG(""); if (!aInfo) { return OMX_ErrorUndefined; } mInfo = aInfo; return CreateComponent(); }
ClientStateIndicator::ClientStateIndicator(CSimplePanel* parent,wxPoint coord) : wxPanel(parent, wxID_ANY, coord, wxSize(343,314), wxNO_BORDER) { m_connRenderTimer = NULL; connIndicatorWidth = 14; connIndicatorHeight = 15; numOfIndic = 5; indexIndVis = 1;//first will be visible on start rightPosition = 118; topPosition = 5; stateMessage = wxEmptyString; clientState = CLIENT_STATE_NONE; CreateComponent(); error_time = 0; }
CProjectsComponent::CProjectsComponent(CSimplePanel* parent,wxPoint coord) : wxPanel(parent, -1, coord, wxSize(343,113), wxNO_BORDER) { wxASSERT(parent); m_maxNumOfIcons = 6; // max number of icons in component m_leftIndex = 0; lastMessageId = 0; CreateComponent(); receivedErrorMessage = false; alertMessageDisplayed = false; checkForMessagesTimer = new wxTimer(this, ID_SIMPLEMESSAGECHECKTIMER); checkForMessagesTimer->Start(5000); }
/** Creates an actor and all its components based on XML configuration ** resource: filename for xml ** state: current game state **/ StrongActorPtr ActorFactory::CreateActor(const char* resource, int* state) { //Holds referenced to loaded XML file pugi::xml_document doc; //Error check to see if file was loaded corectly pugi::xml_parse_result result; std::string resource_str(resource); if (!(result = doc.load_file(("./assets/actors/" + resource_str + ".xml").c_str()))) { std::cout << "ActorFactory::CreateActor(...): Failed to load" << std::endl; std::cout << "Filename: " << resource << " Load result: " << result.description() << std::endl; return StrongActorPtr(); } // Constructs a default actor and gives in the current game state StrongActorPtr actor(new Actor()); actor->resetGameState(state); //Used to iterate over XML file to get attributes pugi::xml_node tools = doc.child(resource); //Initializes the specified actor with chosen XML attributes if(!actor->Init(&tools)) { std::cout << "ActorFactory::CreateActor(...): Failed to initialize actor: " << resource << std::endl; return StrongActorPtr(); } //Iterates over XML to get components to add for (pugi::xml_node tool = tools.first_child(); tool; tool = tool.next_sibling()) { //Creates each component given the XML attribute StrongActorComponentPtr component(CreateComponent(&tool)); if (component) { //Adds the component to the actor actor->AddComponent(component); //Gives the component a reference to its owner component->SetOwner(actor); //Completes any post-initialization of the components component->PostInit(NULL); } else { std::cout << "ActorFactory::CreateActor(...): Failed to create component" << std::endl; return StrongActorPtr(); } } return actor; }
AudioComponent AudioComponentFindNext(AudioComponent inAComponent, AudioComponentDescription *inDesc) { TRACE2(inAComponent, inDesc); int index = -1; if (inDesc->componentType != kAudioUnitType_Output && inDesc->componentType != kAudioUnitType_Mixer) return nullptr; if (inAComponent != nullptr) index = GetComponentIndex(inAComponent); if (snd_card_next(&index) || index == -1) return nullptr; return CreateComponent(kComponentTypeAudioUnit, index); }
void ActorFactory::CreateTemplateActor(const tinyxml2::XMLElement* i_pTemplateActor) { if (i_pTemplateActor) { char szTemplateActorName[32]; sprintf_s(szTemplateActorName,i_pTemplateActor->Attribute("Name")); for (const tinyxml2::XMLElement* pNode = i_pTemplateActor->FirstChildElement(); pNode; pNode = pNode->NextSiblingElement()) { Component* pComponent = CreateComponent(pNode, szTemplateActorName); MGD_ASSERT(pComponent); if (pComponent) { SystemManager::GetSingleton().AddTemplate(ObjectId(szTemplateActorName), pComponent); } } } }
bool Node::LoadXML(const XMLElement& source, SceneResolver& resolver, bool readChildren, bool rewriteIDs, CreateMode mode) { // Remove all children and components first in case this is not a fresh load RemoveAllChildren(); RemoveAllComponents(); if (!Serializable::LoadXML(source)) return false; XMLElement compElem = source.GetChild("component"); while (compElem) { String typeName = compElem.GetAttribute("type"); unsigned compID = compElem.GetInt("id"); Component* newComponent = CreateComponent(ShortStringHash(typeName), (mode == REPLICATED && compID < FIRST_LOCAL_ID) ? REPLICATED : LOCAL, rewriteIDs ? 0 : compID); if (newComponent) { resolver.AddComponent(compID, newComponent); if (!newComponent->LoadXML(compElem)) return false; } compElem = compElem.GetNext("component"); } if (!readChildren) return true; XMLElement childElem = source.GetChild("node"); while (childElem) { unsigned nodeID = childElem.GetInt("id"); Node* newNode = CreateChild(rewriteIDs ? 0 : nodeID, (mode == REPLICATED && nodeID < FIRST_LOCAL_ID) ? REPLICATED : LOCAL); resolver.AddNode(nodeID, newNode); if (!newNode->LoadXML(childElem, resolver, readChildren, rewriteIDs, mode)) return false; childElem = childElem.GetNext("node"); } return true; }
bool Node::Load(Deserializer& source, SceneResolver& resolver, bool readChildren, bool rewriteIDs, CreateMode mode) { // Remove all children and components first in case this is not a fresh load RemoveAllChildren(); RemoveAllComponents(); // ID has been read at the parent level if (!Serializable::Load(source)) return false; unsigned numComponents = source.ReadVLE(); for (unsigned i = 0; i < numComponents; ++i) { VectorBuffer compBuffer(source, source.ReadVLE()); ShortStringHash compType = compBuffer.ReadShortStringHash(); unsigned compID = compBuffer.ReadUInt(); Component* newComponent = CreateComponent(compType, (mode == REPLICATED && compID < FIRST_LOCAL_ID) ? REPLICATED : LOCAL, rewriteIDs ? 0 : compID); if (newComponent) { resolver.AddComponent(compID, newComponent); if (!newComponent->Load(compBuffer)) return false; } } if (!readChildren) return true; unsigned numChildren = source.ReadVLE(); for (unsigned i = 0; i < numChildren; ++i) { unsigned nodeID = source.ReadUInt(); Node* newNode = CreateChild(rewriteIDs ? 0 : nodeID, (mode == REPLICATED && nodeID < FIRST_LOCAL_ID) ? REPLICATED : LOCAL); resolver.AddNode(nodeID, newNode); if (!newNode->Load(source, resolver, readChildren, rewriteIDs, mode)) return false; } return true; }
void ActorFactory::CreateActor(const tinyxml2::XMLElement* i_pActor, MGDVector<Component*>& o_vNewComponents) { if(i_pActor) { const char* pActorName = i_pActor->Attribute("Name"); for (const tinyxml2::XMLElement* pNode = i_pActor->FirstChildElement(); pNode; pNode = pNode->NextSiblingElement()) { Component* pComponent = CreateComponent(pNode, pActorName); #if defined(_DEBUG) ++NumComponents; #endif MGD_ASSERT(pComponent); if (pComponent) { SystemManager::GetSingleton().AddComponent(pComponent, ObjectId(pActorName)); o_vNewComponents.push_back(pComponent); } } } }
int ClearComponentsList(ComponentsList* list) { int ret; Component *temp; CreateComponent(&temp, 0); if (list == NULL) { printf("ClearComponentsList: List is not initialised...\n"); return -1; } while (list->count>0) { if ((ret = PopComponent(list, temp)) != 0) { printf("ClearComponentsList, PopComponent error \n"); return -1; } } return 0; }
//need to differentiate between ships and projectiles void CEntitiesFactory::AddComponents(CEntity * const entity, const SEntityParams * params) { if(params->GetType() == EET_SHIP) { /* JSON COMPONENTS */ const rapidjson::Value &ship = m_doc[static_cast<const SShipParams *> (params)->GetShipName().c_str()]; const rapidjson::Value ¶meters = ship.FindMember("parameters")->value; //ship params int16 linearSpeed = static_cast<int16>(parameters["linearSpeed"].GetInt()); int16 angularSpeed = static_cast<int16>(parameters["angularSpeed"].GetInt()); uint16 energy = static_cast<uint16>(parameters["energy"].GetInt()); float energyChargeRate = static_cast<float>(parameters["energyChargeRate"].GetFloat()); int16 hitpoints = static_cast<int16>(parameters["hitpoints"].GetInt()); CCompShipParams * shipParamsComp = new CCompShipParams(entity, linearSpeed, angularSpeed, energy, energyChargeRate, hitpoints); entity->AddComponent(shipParamsComp); //components const rapidjson::Value &components = ship.FindMember("components")->value; for (rapidjson::Value::ConstMemberIterator itr = components.MemberBegin(); itr != components.MemberEnd(); ++itr) { if (!strcmp(itr->name.GetString(), "ai") && static_cast<const SShipParams *>(params)->IsAI()) { CComponent * comp = CreateAI(entity, itr->value["name"].GetString()); entity->AddComponent(comp); //entity already has CCompShipParams, so set it's isAI to true SSetAIMsg setAIMsg(true); entity->ReceiveMessage(setAIMsg); } else if(!strcmp(itr->name.GetString(), "primaryWeapon")) { CComponent * comp = CreateWeapon(entity, 0, itr); entity->AddComponent(comp); } else if(!strcmp(itr->name.GetString(), "secondaryWeapon")) { CComponent * comp = CreateWeapon(entity, 1, itr); entity->AddComponent(comp); } else { CComponent * newComp = CreateComponent(entity, itr); if (newComp != nullptr) { entity->AddComponent(newComp); } } } } else if(params->GetType() == EET_PROJECTILE) { const SProjectileParams * projParams = static_cast<const SProjectileParams *>(params); CCompTransform * transformComp = new CCompTransform(entity, 0, 0, 0); entity->AddComponent(transformComp); Sprite * sprt = new Sprite(projParams->GetImage()); CCompRender * renderComp = new CCompRender(entity, sprt); entity->AddComponent(renderComp); SGetLinSpeedMsg getLinSpeedMsg; entity->ReceiveMessage(getLinSpeedMsg); SGetAngSpeedMsg getAngSpeedMsg; entity->ReceiveMessage(getAngSpeedMsg); CCompProjectileMove * projMoveComp = new CCompProjectileMove(entity, getLinSpeedMsg.GetLinSpeed(), getAngSpeedMsg.GetAngSpeed()); entity->AddComponent(projMoveComp); CCompProjParams * projParamsComp = new CCompProjParams(entity, projParams->GetDamage()); entity->AddComponent(projParamsComp); SSetRotMsg setRotMsg(projParams->GetRot()); entity->ReceiveMessage(setRotMsg); SSetPosMsg setPosMsg(projParams->GetX(), projParams->GetY()); entity->ReceiveMessage(setPosMsg); } else if (params->GetType() == EET_EXPLOSION) { const SExplosionParams * explParams = static_cast<const SExplosionParams *>(params); const rapidjson::Value &explosion = m_doc[static_cast<const SExplosionParams *> (params)->GetExplName().c_str()]; //ship params Image * img = ResourceManager::Instance().LoadImage(explosion["image"].GetString(), 4, 4); img->SetMidHandle(); float lifeTime = static_cast<float>(explosion["lifetime"].GetFloat()); int16 fps = static_cast<int16>(explosion["fps"].GetInt()); Sprite * sprt = new Sprite(img); sprt->SetFrameRange(0, 15); CCompRender * renderComp = new CCompRender(entity, sprt); entity->AddComponent(renderComp); entity->AddComponent(new CCompTransform(entity, explParams->GetX(), explParams->GetY(), explParams->GetRot())); entity->AddComponent(new CCompExplParams(entity, fps, lifeTime)); SSetRotMsg setRotMsg(explParams->GetRot()); entity->ReceiveMessage(setRotMsg); SSetPosMsg setPosMsg(explParams->GetX(), explParams->GetY()); entity->ReceiveMessage(setPosMsg); SSetFPSMsg setFPSMsg(fps); entity->ReceiveMessage(setFPSMsg); } else if (params->GetType() == EET_DECOY) { const SDecoyParams * decoyParams = static_cast<const SDecoyParams *>(params); Sprite * sprt = new Sprite(decoyParams->GetImg()); CCompRender * compRender = new CCompRender(entity, sprt); entity->AddComponent(compRender); CCompTransform * transfComp = new CCompTransform(entity, decoyParams->GetX(), decoyParams->GetY(), decoyParams->GetRot()); entity->AddComponent(transfComp); CCompDecoyParams * decoyComp = new CCompDecoyParams(entity, decoyParams->GetLifeTime(), decoyParams->GetDamage(), decoyParams->GetAttractFactor()); entity->AddComponent(decoyComp); CCompTractorDecoy * tractorDecoyComp = new CCompTractorDecoy(entity, decoyParams->GetLifeTime()); entity->AddComponent(tractorDecoyComp); SSetRotMsg setRotMsg(decoyParams->GetRot()); entity->ReceiveMessage(setRotMsg); SSetPosMsg setPosMsg(decoyParams->GetX(), decoyParams->GetY()); entity->ReceiveMessage(setPosMsg); } else if (params->GetType() == EET_BOT) { const SBotParams * botParams = static_cast<const SBotParams *>(params); Sprite * sprt = new Sprite(botParams->GetImg()); CCompRender * compRender = new CCompRender(entity, sprt); entity->AddComponent(compRender); SSetFPSMsg setFpsMsg(20); compRender->ReceiveMessage(setFpsMsg); CCompTransform * transfComp = new CCompTransform(entity, botParams->GetX(), botParams->GetY(), 0.f); entity->AddComponent(transfComp); CCompBotParams * botParamsComp = new CCompBotParams(entity, botParams->GetLifeTime(), botParams->GetDamage(), botParams->GetSpeed()); entity->AddComponent(botParamsComp); CCompAIBot * botAIComp = new CCompAIBot(entity, botParams->GetLifeTime()); entity->AddComponent(botAIComp); SSetRotMsg setRotMsg(0.f); entity->ReceiveMessage(setRotMsg); SSetPosMsg setPosMsg(botParams->GetX(), botParams->GetY()); entity->ReceiveMessage(setPosMsg); } CCompCollision * colComp = new CCompCollision(entity); entity->AddComponent(colComp); }
bool EntityManager::CloneEntity(EntityId target, EntityId origin) { bool success = true; std::vector<Component*> comps; for(EntitySystemStore::iterator i = mEntitySystemStore.begin(); i != mEntitySystemStore.end(); ++i) { EntitySystem* sys = i->second; if(sys->AllowComponentCreationBySpawner()) { Component* c; if(sys->GetComponent(origin, c)) { comps.push_back(c); } } } // first create all components in target for(std::vector<Component*>::iterator i = comps.begin(); i != comps.end(); ++i) { Component* origincomp = *i; Component* newcomp; if(!CreateComponent(target, origincomp->GetType(), newcomp)) { LOG_ERROR("Could not clone component " << GetStringFromSID(origincomp->GetType())); success = false; } } // then configure them for(std::vector<Component*>::iterator i = comps.begin(); i != comps.end(); ++i) { Component* origincomp = *i; Component* clonecomp; if(!GetComponent(target, origincomp->GetType(), clonecomp)) { LOG_ERROR("Error in clone entity, could not find cloned component?!?"); success = false; continue; } const PropertyGroup& props = origincomp->Get(); for(PropertyGroup::const_iterator i = props.begin(); i != props.end(); ++i) { Property* prp = clonecomp->Get(i->first); if(prp) { prp->SetFrom(*i->second); #if CALL_ONPROPERTYCHANGED_METHOD clonecomp->OnPropertyChanged(i->first, *prp); #endif } else { LOG_ERROR("Error cloning: Property does not exist in target"); success = false; } } } // then configure them for(std::vector<Component*>::iterator i = comps.begin(); i != comps.end(); ++i) { Component* origincomp = *i; Component* clonecomp; if(!GetComponent(target, origincomp->GetType(), clonecomp)) { LOG_ERROR("Error in clone entity, could not find cloned component?!?"); success = false; continue; } clonecomp->Finished(); } return success; }
ECEditorWindow::ECEditorWindow(Framework* fw, QWidget *parent) : QWidget(parent), framework(fw), ecBrowser(0), hasFocus(true) { /// @todo Create UI fully in code (very simple UI file). setupUi(this); installEventFilter(this); Scene *scene = fw->Scene()->MainCameraScene(); assert(scene); undoManager_ = new UndoManager(scene->shared_from_this(), this); transformEditor = new TransformEditor(scene->shared_from_this(), undoManager_); undoButton->setDisabled(true); redoButton->setDisabled(true); undoButton->setIcon(QIcon(Application::InstallationDirectory() + "data/ui/images/icon/undo-icon.png")); redoButton->setIcon(QIcon(Application::InstallationDirectory() + "data/ui/images/icon/redo-icon.png")); undoButton->setMenu(undoManager_->UndoMenu()); redoButton->setMenu(undoManager_->RedoMenu()); entityWidget->hide(); ecBrowser = new ECBrowser(framework, this, browserWidget); ecBrowser->setMinimumWidth(100); browserWidget->layout()->addWidget(ecBrowser); // signals from attribute browser to editor window. connect(ecBrowser, SIGNAL(ShowXmlEditorForComponent(const QString &)), SLOT(ShowXmlEditorForComponent(const QString &))); connect(ecBrowser, SIGNAL(CreateNewComponent()), SLOT(CreateComponent())); connect(ecBrowser, SIGNAL(SelectionChanged(const QString&, const QString &, const QString&, const QString&)), SLOT(HighlightEntities(const QString&, const QString&))); connect(ecBrowser, SIGNAL(SelectionChanged(const QString&, const QString &, const QString&, const QString&)), SIGNAL(SelectionChanged(const QString&, const QString&, const QString&, const QString&)), Qt::UniqueConnection); ECEditorModule *ecEditorModule = framework->Module<ECEditorModule>(); ecBrowser->SetItemExpandMemory(ecEditorModule->ExpandMemory()); entityList->setSelectionMode(QAbstractItemView::ExtendedSelection); connect(entityList, SIGNAL(itemSelectionChanged()), this, SLOT(Refresh())); connect(entityList, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ShowEntityContextMenu(const QPoint &))); connect(toggleEntitiesButton, SIGNAL(pressed()), this, SLOT(ToggleEntityList())); connect(expandOrCollapseButton, SIGNAL(clicked()), ecBrowser, SLOT(ExpandOrCollapseAll())); connect(scene, SIGNAL(EntityRemoved(Entity*, AttributeChange::Type)), SLOT(RemoveEntity(Entity*)), Qt::UniqueConnection); connect(scene, SIGNAL(ActionTriggered(Entity *, const QString &, const QStringList &, EntityAction::ExecTypeField)), SLOT(OnActionTriggered(Entity *, const QString &, const QStringList &)), Qt::UniqueConnection); connect(this, SIGNAL(FocusChanged(ECEditorWindow *)), ecEditorModule, SLOT(ECEditorFocusChanged(ECEditorWindow*))); connect(this, SIGNAL(EditEntityXml(const QList<EntityPtr> &)), ecEditorModule, SLOT(CreateXmlEditor(const QList<EntityPtr> &))); connect(this, SIGNAL(EditComponentXml(const QList<ComponentPtr> &)), ecEditorModule, SLOT(CreateXmlEditor(const QList<ComponentPtr> &))); //connect(this, SIGNAL(AttributeAboutToBeEdited(IAttribute *)), this, SLOT(OnAboutToEditAttribute(IAttribute* ))); connect(undoManager_, SIGNAL(CanUndoChanged(bool)), this, SLOT(OnUndoChanged(bool))); connect(undoManager_, SIGNAL(CanRedoChanged(bool)), this, SLOT(OnRedoChanged(bool))); connect(undoButton, SIGNAL(clicked()), undoManager_, SLOT(Undo())); connect(redoButton, SIGNAL(clicked()), undoManager_, SLOT(Redo())); connect(framework->Input()->TopLevelInputContext(), SIGNAL(KeyPressed(KeyEvent*)), SLOT(OnKeyEvent(KeyEvent*))); // Make sure the editor is cleared if the scene is cleared or removed. connect(scene, SIGNAL(SceneCleared(Scene *)), SLOT(OnSceneRemoved(Scene *))); connect(framework->Scene(), SIGNAL(SceneAboutToBeRemoved(Scene *, AttributeChange::Type)), SLOT(OnSceneRemoved(Scene *))); }
void CComponentProxyManager::LoadFile(uint32_t uFileId, std::vector<CComponentBase*>* pComponentContainer) { const TString& strFilePath = m_pProject->GetComponentFileName(uFileId); BEATS_ASSERT(strFilePath.length() > 0); if (CFilePathTool::GetInstance()->Exists(strFilePath.c_str())) { rapidxml::file<> fdoc(strFilePath.c_str()); rapidxml::xml_document<> doc; try { doc.parse<rapidxml::parse_default>(fdoc.data()); doc.m_pszFilePath = strFilePath.c_str(); } catch (rapidxml::parse_error &e) { TCHAR info[MAX_PATH]; _stprintf(info, _T("Load file :%s Failed! error :%s"), strFilePath.c_str(), e.what()); MessageBox(BEYONDENGINE_HWND, info, _T("Load File Failed"), MB_OK | MB_ICONERROR); } BEATS_ASSERT(std::find(m_loadedFiles.begin(), m_loadedFiles.end(), uFileId) == m_loadedFiles.end()); m_loadedFiles.push_back(uFileId); rapidxml::xml_node<>* pRootElement = doc.first_node("Root"); rapidxml::xml_node<>* pComponentListNode = pRootElement->first_node("Components"); if (pComponentListNode != NULL) { bool bRestoreLoadingPhase = CComponentInstanceManager::GetInstance()->IsInLoadingPhase(); CComponentInstanceManager::GetInstance()->SetLoadPhaseFlag(true); std::vector<CComponentProxy*> loadedProxyList; rapidxml::xml_node<>* pComponentElement = pComponentListNode->first_node("Component"); while (pComponentElement != NULL) { const char* pGuidStr = pComponentElement->first_attribute("GUID")->value(); char* pStopPos = NULL; int guid = strtoul(pGuidStr, &pStopPos, 16); BEATS_ASSERT(*pStopPos == 0, _T("Guid value %s is not a 0x value at file %s."), pGuidStr, strFilePath.c_str()); if (GetComponentTemplate(guid) == NULL) { CComponentProxyManager::GetInstance()->GetRefreshFileList().insert(uFileId); BEATS_ASSERT(false, _T("Can't create component with \nGUID 0x%x\nName %s\nFile id:%d Name:%s\nHave you removed this component class?"), guid, pComponentElement->first_attribute("Name")->value(), uFileId, strFilePath.c_str()); } else { rapidxml::xml_node<>* pInstanceElement = pComponentElement->first_node(); while (pInstanceElement != NULL) { int id = atoi(pInstanceElement->first_attribute("Id")->value()); BEATS_ASSERT(id != -1); CComponentProxy* pComponentProxy = NULL; if (strcmp(pInstanceElement->name(), "Instance") == 0) { pComponentProxy = down_cast<CComponentProxy*>(CreateComponent(guid, false, false, id, false, NULL, false)); } pComponentProxy->LoadFromXML(pInstanceElement); loadedProxyList.push_back(pComponentProxy); if (pComponentContainer != nullptr) { pComponentContainer->push_back(pComponentProxy); } pInstanceElement = pInstanceElement->next_sibling(); } } pComponentElement = pComponentElement->next_sibling("Component"); } ResolveDependency(); CComponentInstanceManager::GetInstance()->SetLoadPhaseFlag(bRestoreLoadingPhase); if (!CComponentProxyManager::GetInstance()->IsExporting()) { // Call component proxy's initialize means we have sync all value to host component, so we call host component's load function. for (size_t i = 0; i < loadedProxyList.size(); ++i) { loadedProxyList[i]->Initialize(); } for (size_t i = 0; i < loadedProxyList.size(); ++i) { CComponentInstance* pHostComponent = static_cast<CComponentProxy*>(loadedProxyList[i])->GetHostComponent(); if (pHostComponent != nullptr) { pHostComponent->Load(); } else { BEATS_ASSERT(m_bCreateInstanceWithProxy == false, "Only when m_bCreateInstanceWithProxy is set to false, we can't get the host component"); } } } } } }
AudioComponent AudioComponentInstanceGetComponent(AudioComponentInstance inInstance) { return CreateComponent(kComponentTypeAudioUnit, inInstance->cardIndex()); }
ECEditorWindow::ECEditorWindow(Framework* fw, QWidget *parent) : QWidget(parent), framework(fw), toggleEntitiesButton(0), entityList(0), ecBrowser(0), hasFocus(true) { QUiLoader loader; loader.setLanguageChangeEnabled(true); QFile file(Application::InstallationDirectory() + "data/ui/eceditor.ui"); file.open(QFile::ReadOnly); if (!file.exists()) { LogError("Cannot find " + Application::InstallationDirectory() + "data/ui/eceditor.ui file."); return; } QWidget *contents = loader.load(&file, this); if (!contents) { LogError("Could not load editor layout"); return; } contents->installEventFilter(this); file.close(); Scene *scene = fw->Scene()->MainCameraScene(); assert(scene); undoManager_ = new UndoManager(scene->shared_from_this(), this); transformEditor = new TransformEditor(scene->shared_from_this(), undoManager_); QVBoxLayout *layout = new QVBoxLayout(this); undoButton_ = findChild<QToolButton *>("undoButton"); undoButton_->setDisabled(true); redoButton_ = findChild<QToolButton *>("redoButton"); redoButton_->setDisabled(true); undoButton_->setIcon(QIcon(Application::InstallationDirectory() + "data/ui/images/icon/undo-icon.png")); redoButton_->setIcon(QIcon(Application::InstallationDirectory() + "data/ui/images/icon/redo-icon.png")); undoButton_->setMenu(undoManager_->UndoMenu()); redoButton_->setMenu(undoManager_->RedoMenu()); layout->addWidget(contents); layout->setContentsMargins(0,0,0,0); setLayout(layout); setWindowTitle(contents->windowTitle()); resize(contents->size()); toggleEntitiesButton = findChild<QPushButton *>("but_show_entities"); entityList = findChild<QListWidget*>("list_entities"); QWidget *entity_widget = findChild<QWidget*>("entity_widget"); if(entity_widget) entity_widget->hide(); QWidget *browserWidget = findChild<QWidget*>("browser_widget"); if (browserWidget) { ecBrowser = new ECBrowser(framework, this, browserWidget); ecBrowser->setMinimumWidth(100); QVBoxLayout *property_layout = dynamic_cast<QVBoxLayout *>(browserWidget->layout()); if (property_layout) property_layout->addWidget(ecBrowser); } ECEditorModule *ecEditorModule = framework->GetModule<ECEditorModule>(); if (ecBrowser) { // signals from attribute browser to editor window. connect(ecBrowser, SIGNAL(ShowXmlEditorForComponent(const QString &)), SLOT(ShowXmlEditorForComponent(const QString &))); connect(ecBrowser, SIGNAL(CreateNewComponent()), SLOT(CreateComponent())); connect(ecBrowser, SIGNAL(SelectionChanged(const QString&, const QString &, const QString&, const QString&)), SLOT(HighlightEntities(const QString&, const QString&))); connect(ecBrowser, SIGNAL(SelectionChanged(const QString&, const QString &, const QString&, const QString&)), SIGNAL(SelectionChanged(const QString&, const QString&, const QString&, const QString&)), Qt::UniqueConnection); ecBrowser->SetItemExpandMemory(ecEditorModule->ExpandMemory()); } if (entityList) { entityList->setSelectionMode(QAbstractItemView::ExtendedSelection); connect(entityList, SIGNAL(itemSelectionChanged()), this, SLOT(RefreshPropertyBrowser())); connect(entityList, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ShowEntityContextMenu(const QPoint &))); } if (toggleEntitiesButton) connect(toggleEntitiesButton, SIGNAL(pressed()), this, SLOT(ToggleEntityList())); QPushButton *expandOrCollapseButton = findChild<QPushButton *>("expandOrCollapseButton"); if (expandOrCollapseButton && ecBrowser) connect(expandOrCollapseButton, SIGNAL(clicked()), ecBrowser, SLOT(ExpandOrCollapseAll())); connect(scene, SIGNAL(EntityRemoved(Entity*, AttributeChange::Type)), SLOT(RemoveEntity(Entity*)), Qt::UniqueConnection); connect(scene, SIGNAL(ActionTriggered(Entity *, const QString &, const QStringList &, EntityAction::ExecTypeField)), SLOT(OnActionTriggered(Entity *, const QString &, const QStringList &)), Qt::UniqueConnection); connect(this, SIGNAL(FocusChanged(ECEditorWindow *)), ecEditorModule, SLOT(ECEditorFocusChanged(ECEditorWindow*))); connect(this, SIGNAL(EditEntityXml(const QList<EntityPtr> &)), ecEditorModule, SLOT(CreateXmlEditor(const QList<EntityPtr> &))); connect(this, SIGNAL(EditComponentXml(const QList<ComponentPtr> &)), ecEditorModule, SLOT(CreateXmlEditor(const QList<ComponentPtr> &))); //connect(this, SIGNAL(AttributeAboutToBeEdited(IAttribute *)), this, SLOT(OnAboutToEditAttribute(IAttribute* ))); connect(undoManager_, SIGNAL(CanUndoChanged(bool)), this, SLOT(OnUndoChanged(bool))); connect(undoManager_, SIGNAL(CanRedoChanged(bool)), this, SLOT(OnRedoChanged(bool))); connect(undoButton_, SIGNAL(clicked()), undoManager_, SLOT(Undo())); connect(redoButton_, SIGNAL(clicked()), undoManager_, SLOT(Redo())); }
ComponentPtr Entity::CreateLocalComponent(const QString &type_name, const QString &name) { return CreateComponent(type_name, name, AttributeChange::LocalOnly, false); }