Exemple #1
0
void tmx::Tileset::init(pugi::xml_node tilesetNode) {
	setFirstGid(tilesetNode.attribute("firstgid").as_int());
	setSource(tilesetNode.attribute("source").as_string());
	setName(tilesetNode.attribute("name").as_string());
	setTileWidth(tilesetNode.attribute("tilewidth").as_uint());
	setTileHeight(tilesetNode.attribute("tileheight").as_uint());
	setSpacing(tilesetNode.attribute("spacing").as_uint());
	setMargin(tilesetNode.attribute("margin").as_uint());

	for(pugi::xml_node prop = tilesetNode.child("properties").first_child(); prop; prop = prop.next_sibling()) {
		mProperties.insert(std::pair<std::string, std::string>(prop.attribute("name").as_string(), prop.attribute("value").as_string()));
	}

	mTileOffset.init(tilesetNode.child("tileoffset"));

	mImage.init(tilesetNode.child("image"));

	mTerrainTypes.init(tilesetNode.child("terraintypes"));

	for(pugi::xml_node tile = tilesetNode.child("tile"); tile; tile = tile.next_sibling("tile")) {
		tmx::Tile tempTile;
		tempTile.setID(tile.attribute("id").as_uint());
		tempTile.setTerrain(tile.attribute("terrain").as_string());
		mTile.push_back(tempTile);
	}
}
Exemple #2
0
// Called before render is available
bool j1Render::Awake(pugi::xml_node& config)
{
	LOG("Create SDL rendering context");
	bool ret = true;
	// load flags
	Uint32 flags = SDL_RENDERER_ACCELERATED;

	if(config.child("vsync").attribute("value").as_bool(true) == true)
	{
		flags |= SDL_RENDERER_PRESENTVSYNC;
		LOG("Using vsync");
	}

	renderer = SDL_CreateRenderer(App->win->window, -1, flags);

	if(renderer == NULL)
	{
		LOG("Could not create the renderer! SDL_Error: %s\n", SDL_GetError());
		ret = false;
	}
	else
	{
		camera.w = App->win->screen_surface->w;
		camera.h = App->win->screen_surface->h;
		camera.x = config.child("cam").attribute("x").as_int(0);
		camera.y = config.child("cam").attribute("y").as_int(0);
	}

	return ret;
}
// Called before render is available
bool Fonts::awake(pugi::xml_node& conf)
{
	LOG("Init True Type Font library");
	bool ret = true;

	if (TTF_Init() == -1)
	{
		LOG("SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError());
		ret = false;
	}
	else
	{
		const char* path = conf.child("default_font").attribute("file").as_string(DEFAULT_FONT);
		int size = conf.child("default_font").attribute("size").as_int(DEFAULT_FONT_SIZE);
		default = load(path, size);

		pugi::xml_node		node = conf.child("default_font");
		node = node.next_sibling("default_font");

		const char* path2 = node.attribute("file").as_string(DEFAULT_FONT);
		int size2 = node.attribute("size").as_int(DEFAULT_FONT_SIZE);
		default_2 = load(path2, size2);

	}

	return ret;
}
Exemple #4
0
bool Animation::Load(const pugi::xml_node& node)
{
    Reset();

    if (strcmp(node.name(), "animation"))
        return false;

    id_ = node.attribute("id").as_int();
    name_ = node.attribute("name").as_string();
    length_ = node.attribute("length").as_float() * 0.001f;
    looping_ = node.attribute("looping").as_bool(true);

    xml_node mainlineNode = node.child("mainline");
    for (xml_node keyNode = mainlineNode.child("key"); !keyNode.empty(); keyNode = keyNode.next_sibling("key"))
    {
        mainlineKeys_.Push(new MainlineKey());
        if (!mainlineKeys_.Back()->Load(keyNode))
            return false;
    }

    for (xml_node timelineNode = node.child("timeline"); !timelineNode.empty(); timelineNode = timelineNode.next_sibling("timeline"))
    {
        timelines_.Push(new Timeline());
        if (!timelines_.Back()->Load(timelineNode))
            return false;
    }

    return true;
}
Exemple #5
0
bool SpriterData::Load(const pugi::xml_node& node)
{
    Reset();

    if (strcmp(node.name(), "spriter_data"))
        return false;

    scmlVersion_ = node.attribute("scml_version").as_int();
    generator_ = node.attribute("generator").as_string();
    generatorVersion_ = node.attribute("scml_version").as_string();

    for (xml_node folderNode = node.child("folder"); !folderNode.empty(); folderNode = folderNode.next_sibling("folder"))
    {
        folders_.Push(new  Folder());
        if (!folders_.Back()->Load(folderNode))
            return false;
    }

    for (xml_node entityNode = node.child("entity"); !entityNode.empty(); entityNode = entityNode.next_sibling("entity"))
    {
        entities_.Push(new  Entity());
        if (!entities_.Back()->Load(entityNode))
            return false;
    }

    return true;
}
Exemple #6
0
bool Entity::Load(const pugi::xml_node& node)
{
    Reset();

    if (strcmp(node.name(), "entity"))
        return false;

    id_ = node.attribute("id").as_int();
    name_ = node.attribute("name").as_string();

    for (xml_node characterMapNode = node.child("character_map"); !characterMapNode.empty(); characterMapNode = characterMapNode.next_sibling("character_map"))
    {
        characterMaps_.Push(new CharacterMap());
        if (!characterMaps_.Back()->Load(characterMapNode))
            return false;
    }

    for (xml_node animationNode = node.child("animation"); !animationNode.empty(); animationNode = animationNode.next_sibling("animation"))
    {
        animations_.Push(new  Animation());
        if (!animations_.Back()->Load(animationNode))
            return false;
    }

    return true;
}
Exemple #7
0
    BOOL STreeList::CreateChildren(pugi::xml_node xmlNode)
    {
        pugi::xml_node xmlHeader = xmlNode.child(L"headerstyle");
        pugi::xml_node xmlTreectrl = xmlNode.child(L"treectrlstyle");
        if(!xmlHeader || !xmlTreectrl) 
            return FALSE;
        m_pHeader = CreateHeader();
        InsertChild(m_pHeader);
        m_pHeader->InitFromXml(xmlHeader);
        m_pHeader->GetEventSet()->subscribeEvent(EventHeaderItemChanging::EventID, Subscriber(&STreeList::OnHeaderSizeChanging,this));
        m_pHeader->GetEventSet()->subscribeEvent(EventHeaderItemSwap::EventID, Subscriber(&STreeList::OnHeaderSwap,this));

        m_pTreeCtrl = CreateMcTreeCtrl();
        InsertChild(m_pTreeCtrl);
        m_pTreeCtrl->InitFromXml(xmlTreectrl);
        m_pTreeCtrl->GetEventSet()->subscribeEvent(EventScroll::EventID,Subscriber(&STreeList::OnScrollEvent,this));

        m_pHeader->InsertItem(0,m_strTreeLabel,m_pTreeCtrl->m_nTreeWidth,ST_NULL,0);
        for(int i=1;i<m_pHeader->GetItemCount();i++)
        {
            int nWid = m_pHeader->GetItemWidth(i);
            m_pTreeCtrl->InsertColumn(i-1,nWid);
        }
        return TRUE;
    }
Exemple #8
0
    BOOL SComboBase::CreateChildren( pugi::xml_node xmlNode )
    {
        SASSERT(m_pSkinBtn);
		m_xmlDropdownStyle.append_copy(xmlNode.child(KStyle_Dropdown));
        //创建edit对象
        if(!m_bDropdown)
        {            
            m_pEdit=new SComboEdit(this);
            SApplication::getSingleton().SetSwndDefAttr(m_pEdit);

            InsertChild(m_pEdit);
            pugi::xml_node xmlEditStyle=xmlNode.child(KStyle_Edit);
            m_pEdit->GetEventSet()->setMutedState(true);
            if(xmlEditStyle)
                m_pEdit->InitFromXml(xmlEditStyle);
            else
                m_pEdit->SSendMessage(WM_CREATE);
            m_pEdit->GetEventSet()->setMutedState(false);
			
            m_pEdit->SetID(IDC_CB_EDIT);
            m_pEdit->SSendMessage(EM_SETEVENTMASK,0 ,ENM_CHANGE );

        }
        return CreateListBox(xmlNode);
    }
void parse_predicates(pugi::xml_node node, config::config & conf) {
    size_t size = node.child("size").text().as_uint();
    //cout << "predicates size: " << size << endl;
    conf.predicates.resize(size);
    
    conf.predicate_distribution = parse_distribution(node.child("distribution"));
    
    for (pugi::xml_node alias_node : node.children("alias")) {
        size_t id = alias_node.attribute("symbol").as_uint();//
        string name = alias_node.text().get();
        //cout << "alias " << id << ", " << name  << endl;
        if (id < 0 || id >= size) {
            cerr << "id " << id << " is out of range" << endl;
            continue;
        }

        conf.predicates[id].alias = name;
    }
    
    for (pugi::xml_node proportion_node : node.children("proportion")) {
        size_t id = proportion_node.attribute("symbol").as_uint();
        double proportion = proportion_node.text().as_double();
        if (id < 0 || id >= size) {
            cerr << "id " << id << " is out of range" << endl;
            continue;
        }
        conf.predicates[id].proportion = proportion;
        conf.predicates[id].size = (size_t) (proportion * conf.nb_edges);
    }
}
//Load/Save
bool j1Render::Load(pugi::xml_node& state)
{
	camera.x = state.child("camera").attribute("width").as_int();
	camera.y = state.child("camera").attribute("height").as_int();

	return true;
}
	void IDMEFExporter::_configure(const pugi::xml_node& n)
	{
		// Closes the export method if any
		close_export_method();
		// XML configuration
		pugi::xml_node export_node = n.child("export");
		pugi::xml_node file_node = n.child("file");
		if (export_node)
		{
			m_export_method = EXP_TCP;
			if (!export_node.attribute("host") || !export_node.attribute("port"))
				throw std::runtime_error("Export specification incomplete");
			std::string host = export_node.attribute("host").value();
			m_host = inet_addr(host.c_str());
			m_port = std::atoi(export_node.attribute("port").value());
		}
		else if (file_node)
		{
			m_export_method = EXP_FILE;
			if (!file_node.attribute("name"))
				throw std::runtime_error("File specification missing name");
			m_filename = file_node.attribute("name").value();
		}
		else
		{
			throw std::runtime_error("No output specified");
		}
		// Opens the export method
		open_export_method();
	}
Exemple #12
0
//Создаем новый _род_ и распихиваем по его полям значения из файла
void LoadRace(pugi::xml_node RaceNode, PlayerKinPtr KinPtr)
{
	pugi::xml_node CurNode;
	PlayerRacePtr TmpRace(new PlayerRace);

	TmpRace->SetRaceNum(RaceNode.attribute("racenum").as_int());
    TmpRace->SetEnabledFlag(RaceNode.attribute("enabled").as_bool());
	TmpRace->SetRaceMenuStr(RaceNode.child("menu").child_value());
	CurNode = RaceNode.child("racename");
	TmpRace->SetRaceItName(CurNode.child("itname").child_value());
	TmpRace->SetRaceHeName(CurNode.child("hename").child_value());
	TmpRace->SetRaceSheName(CurNode.child("shename").child_value());
	TmpRace->SetRacePluralName(CurNode.child("pluralname").child_value());
	//Add race features
	for (CurNode = RaceNode.child("feature"); CurNode; CurNode = CurNode.next_sibling("feature"))
	{
		TmpRace->AddRaceFeature(CurNode.attribute("featnum").as_int());
	}
    //Добавляем родовые места "появления на свет" новых персонажей
	for (CurNode = RaceNode.child("birthplace"); CurNode; CurNode = CurNode.next_sibling("birthplace"))
	{
		TmpRace->AddRaceBirthPlace(CurNode.attribute("id").as_int());
	}
	//Add new race in list
	KinPtr->PlayerRaceList.push_back(TmpRace);
}
void ViewTransform::initialize(pugi::xml_node node)
{
	pugi::xml_text txt;
	txt = node.child("FieldOfView").text();
	if (txt)
		m_fov = txt.as_float();
	txt = node.child("Angle").text();
	if (txt)
		m_angle = txt.as_float();

	pugi::xml_node coordinates_node = node.child("Coordinates");
	txt = coordinates_node.child("x").text();
	if (txt)
		m_position.x = txt.as_float();
	txt = coordinates_node.child("y").text();
	if (txt)
		m_position.y = txt.as_float();
	txt = coordinates_node.child("z").text();
	if (txt)
		m_position.z = txt.as_float();


	m_view_matrix = glm::rotate(m_view_matrix,glm::radians(m_angle),glm::vec3(1,0,0));
	m_view_matrix = glm::translate(m_view_matrix, glm::vec3(m_position.x,m_position.y,m_position.z));

	m_projection_matrix = glm::perspective(glm::radians(m_fov), m_viewport.x/m_viewport.y, 1.f, 1000.f);
void PhysicsManager::initialize(pugi::xml_node node)
{
	m_next_update = g_app->getCurrentTime();

	if (!node)
		return;

	pugi::xml_text txt;

	txt = node.child("UpdatePerSecond").text();
	if (txt)
		m_timestep = 1.f/(txt.as_float());


	pugi::xml_node iterations = node.child("Iterations");

	txt = iterations.child("Velocity").text();
	if (txt)
		m_velocity_iterations = txt.as_uint();

	txt = iterations.child("Position").text();
	if (txt)
		m_position_iterations = txt.as_uint();

	txt = node.child("PixelPhysicsRatio").text();
	if (txt)
		m_pixel_physics_ratio = txt.as_float();
}
distribution parse_distribution(pugi::xml_node node) {
    distribution dist;
    if (!node.empty()) {
        string type = node.attribute("type").value();
        if (type == "uniform") {
            size_t min = node.child("min").text().as_uint();
            size_t max = node.child("max").text().as_uint();
            dist.type = DISTRIBUTION::UNIFORM;
            dist.arg1 = min;
            dist.arg2 = max;
        } else if (type == "zipfian") {
            size_t n = node.child("n").text().as_uint();
            double alpha = node.child("alpha").text().as_double();
            dist.type = DISTRIBUTION::ZIPFIAN;
            dist.arg1 = n;
            dist.arg2 = alpha;
        } else if (type == "normal" or type == "gaussian") {
            double mean = node.child("mu").text().as_double();
            double stddev = node.child("sigma").text().as_double();
            dist.type = DISTRIBUTION::NORMAL;
            dist.arg1 = mean;
            dist.arg2 = stddev;
        }
    }
    return dist;
}
Exemple #16
0
//Создаем новую расу и заполняем ее поля значениями из файлда
void LoadKin(pugi::xml_node KinNode)
{
	pugi::xml_node CurNode;
	PlayerKinPtr TmpKin(new PlayerKin);

	//Parse kin's parameters
	TmpKin->KinNum = KinNode.attribute("kinnum").as_int();
    TmpKin->Enabled = KinNode.attribute("enabled").as_bool();
	CurNode = KinNode.child("menu");
	TmpKin->KinMenuStr = CurNode.child_value();
	CurNode = KinNode.child("kinname");
	TmpKin->KinItName = CurNode.child("itname").child_value();
	TmpKin->KinHeName = CurNode.child("hename").child_value();
	TmpKin->KinSheName = CurNode.child("shename").child_value();
	TmpKin->KinPluralName = CurNode.child("pluralname").child_value();

	//Parce kin races
	CurNode = KinNode.child("kinraces");
	for (CurNode = CurNode.child("race"); CurNode; CurNode = CurNode.next_sibling("race"))
	{
		LoadRace(CurNode, TmpKin);
	}
	//Add new kin in kin list
	PlayerRace::PlayerKinList.push_back(TmpKin);
}
void Init::parseDispersion(const pugi::xml_node &node)
{
    
    cout << "Dispersion:" << endl;
    string filename = node.child_value("filename");
    string filetype = node.child_value("filetype");
    
    SpinWaveDispersion Dispersion;
    Dispersion.setFilename(filename);
    
    SpinWaveDispersion::Options PrintOptions;
    string temp;
    bool value;
    
    temp = node.child("filetype").child_value("printposition");
    value = boost::lexical_cast<bool, std::string>(temp);
    PrintOptions = SpinWaveDispersion::Options::PrintPosition;
    cout << "print position: "<< value << endl;
    Dispersion.setOptions(PrintOptions,value);
    
    temp = node.child("filetype").child_value("printfrequency");
    value = boost::lexical_cast<bool, std::string>(temp);
    PrintOptions = SpinWaveDispersion::Options::PrintFrequency;
    cout << "print frequency: "<< value << endl;
    Dispersion.setOptions(PrintOptions,value);
    
    temp = node.child("filetype").child_value("printintensity");
    value = boost::lexical_cast<bool, std::string>(temp);
    PrintOptions = SpinWaveDispersion::Options::PrintIntensity;
    cout << "print intensity: "<< value << endl;
    Dispersion.setOptions(PrintOptions,value);
    
    pugi::xml_node lines = node.child("lines");
    for (pugi::xml_node group = lines.child("group");group; group = group.next_sibling("group"))
    {
        double x0,y0,z0,x1,y1,z1,NumberPoints;
        
        NumberPoints = stringToDouble(group.child_value("numberpoints"));
        x0 = stringToDouble(group.child("firstpoint").child_value("x"));
        y0 = stringToDouble(group.child("firstpoint").child_value("y"));
        z0 = stringToDouble(group.child("firstpoint").child_value("z"));
        x1 = stringToDouble(group.child("lastpoint").child_value("x"));
        y1 = stringToDouble(group.child("lastpoint").child_value("y"));
        z1 = stringToDouble(group.child("lastpoint").child_value("z"));
        
        cout << x0 << " " << y0 << " " << z0 << " " << x1 << " " << y1 << "  " << z1 << endl;
        
        PointsAlongLine Line;
        Line.setFirstPoint(x0,y0,z0);
        Line.setFinalPoint(x1,y1,z1);
        Line.setNumberPoints(NumberPoints);
        Dispersion.setPoints(Line.getPoints());
    }
    
    Dispersion.setGenie(builder.createElement());
    Dispersion.save();
}
Exemple #18
0
eIG::eIG(pugi::xml_node& node) {

	//RouteID
	this->RouteID = node.child("RouteID").text().as_int();
	//TerrainName
	this->TerrainName = node.child("TerrainName").text().as_string();
	//FeatureID
	this->FeatureID = node.child("FeatureID").text().as_int();
}
Exemple #19
0
// Called before render is available
bool j1Map::Awake(pugi::xml_node& node)
{
	LOG("Loading Map Parser");
	bool ret = true;

	folder.create(node.child("folder").child_value());
	map.create(node.child("data").attribute("file").as_string());

	return ret;
}
 void addResponseNodes(pugi::xml_node& xml, const CoreMessage& message) const {
     const CoreResponse response = dynamic_cast<const CoreResponse&>(message);
     xml.append_child().set_name("errorCode");
     xml.child("errorCode").append_child(pugi::node_pcdata).set_value(response.errorCode().c_str());
     xml.append_child().set_name("errorMessage");
     xml.child("errorMessage").append_child(pugi::node_pcdata).set_value(response.errorMessage().c_str());
     xml.append_child().set_name("successful");
     std::string success = boost::lexical_cast<std::string>(response.isSuccessful());
     xml.child("successful").append_child(pugi::node_pcdata).set_value(success.c_str());
 }
Exemple #21
0
 virtual void getView(int position, SWindow * pItem, pugi::xml_node xmlTemplate)
 {
     int nViewType = getItemViewType(position);
     if(pItem->GetChildrenCount() == 0)
     {
         pugi::xml_node xmlItem;
         switch(nViewType)
         {
         case VT_GROUP: xmlItem = xmlTemplate.child(L"item_group");break;
         case VT_DATA: xmlItem = xmlTemplate.child(L"item_data");break;
         }
         pItem->InitFromXml(xmlItem);
     }
     if(nViewType == VT_GROUP)
     {
         SToggle * pSwitch=pItem->FindChildByID2<SToggle>(R.id.tgl_tv_expand);
         pSwitch->SetToggle(position==0?m_bCurrentExpand:m_bExpiredExpand);
         pSwitch->GetEventSet()->subscribeEvent(EVT_CMD,Subscriber(&CStudentAdapter::OnBtnGroupExpand,this));
         pItem->FindChildByID(R.id.txt_group)->SetWindowText(TR(GETSTRING(position==0?R.string.current_student:R.string.expired_student),L""));
         pItem->GetEventSet()->subscribeEvent(EVT_ITEMPANEL_DBCLICK,Subscriber(&CStudentAdapter::OnGroupDblClick,this));
         SCheckBox *pGroupCheck = pItem->FindChildByID2<SCheckBox>(R.id.chk_select_group);
         pGroupCheck->GetEventSet()->subscribeEvent(EVT_STATECHANGED,Subscriber(&CStudentAdapter::OnGroupSelectCheckChanged,this));
         pGroupCheck->GetEventSet()->setMutedState(true);
         pGroupCheck->SetCheck(position==0?m_bAllCurrentChecked:m_bAllExpiredChecked);
         pGroupCheck->GetEventSet()->setMutedState(false);
     }else
     {
         int nBaseCurrent = 1;
         int nBaseExpired = 1 + (m_bCurrentExpand?m_stuCurrent.GetCount():0) + 1;
         if(position< nBaseExpired)
         {//current student
             StudentInfo & stuInfo = m_stuCurrent[position-nBaseCurrent];
             SCheckBox *pCheckBox = pItem->FindChildByID2<SCheckBox>(R.id.txt_nick);
             pCheckBox->GetEventSet()->subscribeEvent(EVT_STATECHANGED,Subscriber(&CStudentAdapter::OnStudentCheckChanged,this));
             pCheckBox->GetEventSet()->setMutedState(true);
             pCheckBox->SetCheck(stuInfo.bChecked);
             pCheckBox->GetEventSet()->setMutedState(false);
             pCheckBox->SetWindowText(SStringT().Format(_T("%s(%u)"),stuInfo.strNick,stuInfo.imid));
             pItem->FindChildByID(R.id.txt_loyal_degree)->SetWindowText(SStringT().Format(_T("%d"),stuInfo.nLoyalDegree));
             pItem->FindChildByID(R.id.txt_time_span)->SetWindowText(stuInfo.tm1.Format(_T("%Y/%m/%d") + SStringT(_T(" - ")) + stuInfo.tm2.Format(_T("%Y/%m/%d"))));
         }else
         {//expired student
             StudentInfo & stuInfo = m_stuExpired[position-nBaseExpired];
             SCheckBox *pCheckBox = pItem->FindChildByID2<SCheckBox>(R.id.txt_nick);
             pCheckBox->GetEventSet()->subscribeEvent(EVT_STATECHANGED,Subscriber(&CStudentAdapter::OnStudentCheckChanged,this));
             pCheckBox->GetEventSet()->setMutedState(true);
             pCheckBox->SetCheck(stuInfo.bChecked);
             pCheckBox->GetEventSet()->setMutedState(false);
             pCheckBox->SetWindowText(SStringT().Format(_T("%s(%u)"),stuInfo.strNick,stuInfo.imid));
             pItem->FindChildByID(R.id.txt_loyal_degree)->SetWindowText(SStringT().Format(_T("%d"),stuInfo.nLoyalDegree));
             pItem->FindChildByID(R.id.txt_time_span)->SetWindowText(stuInfo.tm1.Format(_T("%Y/%m/%d") + SStringT(_T(" - ")) + stuInfo.tm2.Format(_T("%Y/%m/%d"))));
         }
     }
 }
bool TestingScene::awake(pugi::xml_node& config)
{
	bool ret = true;

	entityTextureName.assign("texture/");
	entityTextureName.append(config.child("entity_texture").first_attribute().as_string());

	mapName.assign(config.child("map_name").first_attribute().as_string());

	return ret;
}
Exemple #23
0
///This node parses the Trace node. This node contains all of the information
/// necessary for the users to do trace analysis. The only critical node here
/// is the WaveformRange node. If the Trace node exists then this node must
/// also exist.
void MapNodeXmlParser::ParseFilterNode(const pugi::xml_node &node, ChannelConfiguration &config,
                                       const bool &isVerbose) {
    config.SetTriggerFilterParameters(TrapFilterParameters(
            node.child("Trigger").attribute("l").as_double(DefaultConfig::filterL),
            node.child("Trigger").attribute("g").as_double(DefaultConfig::filterG),
            node.child("Trigger").attribute("t").as_double(DefaultConfig::filterT)));
    config.SetEnergyFilterParameters(TrapFilterParameters(
            node.child("Energy").attribute("l").as_double(DefaultConfig::filterL),
            node.child("Energy").attribute("g").as_double(DefaultConfig::filterG),
            node.child("Energy").attribute("t").as_double(DefaultConfig::filterT)));
}
ePhysicalObjects::ePhysicalObjects(pugi::xml_node& node) {
	//GlobalID
	this->GlobalID = node.child("GlobalID").text().as_int();
	//Name
	this->Name = node.child("Name").text().as_string();
	//RoadInfo
	pugi::xml_node RoadInfoNode = node.child("RoadInfo");
	this->RoadInfo = ePointRoadInfo(RoadInfoNode);
	//Type
	this->Type = node.child("Type").text().as_int();
	//Value
	this->Value = node.child("Value").text().as_string();
}
ePhysicalBuilding::ePhysicalBuilding(pugi::xml_node& node) {
	//GlobalID
	this->GlobalID = node.child("GlobalID").text().as_int();
	//Type
	this->Type = node.child("Type").text().as_int();
	//Name
	this->Name = node.child("Name").text().as_string();
	//Width
	this->Width = node.child("Width").text().as_double();
	//RoadInfo
	pugi::xml_node RoadInfoNode = node.child("RoadInfo");
	this->RoadInfo = eLineRoadInfo(RoadInfoNode);
}
Exemple #26
0
void Unit::deserialize(const pugi::xml_node &node)
{
    pugi::xml_node meshNode = node.child("node");
    mesh = the::node::ptr_cast<the::animesh>(the::node::load(meshNode, dataPath));
    mesh->orderSort();
    for (pugi::xml_node child = node.child("transition"); child; child = child.next_sibling("transition"))
    {
        TransitionPtr t = std::make_shared<Transition>();
        t->setAnimation(dataPath + child.attribute("animation").value());
        //t->setAudio(dataPath + child.attribute("sound").value());
        t->setLoop(child.attribute("looped").as_bool());
        addTransition(child.attribute("name").value(), t);
    }
}
/**
	Parses the given xml node to get the last name and firstname or abreviation
	of a name.
	@param node: xml node to parse, should be a contrib node with a 'name' or 'string-name' as a child
	@return CName object containing the parsed data
*/
CName AuthorParser::parseName(pugi::xml_node &node)
{
	//Select the 'name' item
	pugi::xml_node nameNode=node.child("name");
	if(!nameNode){
		nameNode=node.child("string-name");
		if(!nameNode){
				return CName("", "");
		}
	}
	//Select firstname and surname
	string authorLastname=nameNode.child("surname").child_value();
	string authorFirstname=nameNode.child("given-names").child_value();
	return CName(authorFirstname, authorLastname);
}
Exemple #28
0
bool j1Render::SaveData(pugi::xml_node& renderSaveData)
{
	bool ret = true;
	if (renderSaveData.child("camera") == NULL)
	{
		renderSaveData.append_child("camera").append_attribute("coordX").set_value(camera.x);
		renderSaveData.child("camera").append_attribute("coordY").set_value(camera.y);
	}
	else
	{
		renderSaveData.child("camera").attribute("coordX").set_value(camera.x);
		renderSaveData.child("camera").attribute("coordY").set_value(camera.y);
	}
	return ret;
}
// Load Game State
bool j1Render::Load(pugi::xml_node& data)
{
	camera.x = data.child("camera").attribute("x").as_int();
	camera.y = data.child("camera").attribute("y").as_int();

	return true;
}
Exemple #30
0
void InputConfig::loadFromXML(pugi::xml_node node, int playerNum)
{
	this->clear();

	setPlayerNum(playerNum);

	for(pugi::xml_node input = node.child("input"); input; input = input.next_sibling("input"))
	{
		std::string name = input.attribute("name").as_string();
		std::string type = input.attribute("type").as_string();
		InputType typeEnum = stringToInputType(type);

		if(typeEnum == TYPE_COUNT)
		{
			std::cout << "ERROR - input type \"" << type << "\" is invalid! Skipping input \"" << name << "\".\n";
			continue;
		}

		int id = input.attribute("id").as_int();
		int value = input.attribute("value").as_int();

		if(value == 0)
			std::cout << "WARNING: InputConfig value is 0 for " << type << " " << id << "!\n";

		mNameMap[toLower(name)] = Input(mDeviceId, typeEnum, id, value, true);
	}
}