示例#1
0
 void Serializer::applyStateToComponent(const Component::Ptr &theComponent,
                                        const std::string &theState,
                                        const PropertyIO &theIO)
 {
     Json::Reader myReader;
     Json::Value myRoot;
     bool myParsingSuccessful = myReader.parse(theState, myRoot);
     
     if (!myParsingSuccessful)
     {
         throw ParsingException(theState);
     }
     
     for (unsigned int i=0; i<myRoot.size(); i++)
     {
         Json::Value myComponentNode = myRoot[i];
         if(myComponentNode[PropertyIO::PROPERTY_NAME] != theComponent->getName()){continue;}
         
         for (unsigned int i=0; i < myComponentNode[PropertyIO::PROPERTIES].size(); i++)
         {
             try
             {
                 std::string myName =
                 myComponentNode[PropertyIO::PROPERTIES][i][PropertyIO::PROPERTY_NAME].asString();
                 
                 Property::Ptr myProperty = theComponent->getPropertyByName(myName);
                 theIO.writePropertyValue(myProperty, myComponentNode[PropertyIO::PROPERTIES][i]);
                 
             } catch (PropertyNotFoundException &myException)
             {
                 LOG_WARNING << myException.what();
             }
         }
     }
 }
示例#2
0
 void GLFW_App::create_tweakbar_from_component(const Component::Ptr &the_component)
 {
     if(!the_component) return;
     m_tweakBars.push_back(TwNewBar(the_component->getName().c_str()));
     setBarColor(glm::vec4(0, 0, 0, .5), m_tweakBars.back());
     setBarSize(glm::ivec2(250, 500));
     glm::ivec2 offset(10);
     setBarPosition(glm::ivec2(offset.x + 260 * (m_tweakBars.size() - 1), offset.y), m_tweakBars.back());
     addPropertyListToTweakBar(the_component->getPropertyList(), "", m_tweakBars.back());
 }
示例#3
0
void DesignStore::addComponent(Component::Ptr c){
  c->setComponentId(next_componentid++);
  components[c->getId()] = c;
  componentIndex[c->getName()] = c->getId();
  Game::getGame()->getPersistence()->saveComponent(c);
}