Пример #1
0
void KeyerConfigure::SetPorts( TiXmlElement *e )
{
   for ( TiXmlElement * c = e->FirstChildElement(); c; c = c->NextSiblingElement() )
   {
      if ( checkElementName( c, "Port" ) )
      {
         // attribs name, type, port
         std::string n;
         std::string t;
         if ( GetStringAttribute( c, "name", n ) == TIXML_SUCCESS
              && GetStringAttribute( c, "type", t ) == TIXML_SUCCESS )
         {
            // should all this live inside PortConfig?
            PortConfig::PortType pt;
            if ( t == "Windows" )
            {
               pt = PortConfig::eptWindows;
            }
            else
               if ( t == "MinosControl" )
               {
                  pt = PortConfig::eptMinosControl;
               }
               else
               {
                  // error...
                  continue;
               }
            PortConfig p( n, pt );
            portmap[ n ] = p;
         }
      }
   }
}
Пример #2
0
void KeyerConfigure::SetEnable( TiXmlElement *e )
{
   //attribs Keyer, Port - refer to names of KeyerConfig, PortConfig
   std::string k;
   std::string p;
   if ( GetStringAttribute( e, "keyer", k ) == TIXML_SUCCESS
        && GetStringAttribute( e, "port", p ) == TIXML_SUCCESS )
      createKeyer( keyermap[ k ], portmap[ p ] );
}
Пример #3
0
void Nena::Utility::MayaReader::ImportSkinCluster(XMLNode *clusterNode)
{
	::UINT32 result = 0;

	::std::string clusterName; GetNameAttribute(clusterNode, clusterName, result);
	::UINT32 skinCount; GetCountAttribute(clusterNode, skinCount, result);

	Data::SkinCluster *clusterData = new Data::SkinCluster();
	Root->GetHandles()->push_back(clusterData);
	clusterData->m_type = Data::IItem::kSkinCluster;
	clusterData->m_name = clusterName;

	XMLNode *skinNode = clusterNode->first_node("Skin"); while (skinNode)
	{
		Data::SkinCluster::Skin *skin = new Data::SkinCluster::Skin;
		clusterData->Geometries.push_back(skin);
		Root->GetHandles()->push_back(skin);

		::UINT32 skinIndex; GetIndexAttribute(skinNode, skinIndex, result);
		::std::string skinName; GetNameAttribute(skinNode, skinName, result);
		::UINT32 componentCount; GetCountAttribute(skinNode, componentCount, result);

		skin->m_name = skinName;
		skin->m_type = Data::IItem::kSkin;
		skin->ComponentCount = componentCount;
		skin->Components = new Data::SkinCluster::Skin::Component[componentCount];

		XMLNode *componentNode = skinNode->first_node("Component"); while (componentNode)
		{
			::UINT32 componentIndex; GetIndexAttribute(componentNode, componentIndex, result);
			::UINT32 influenceCount; GetCountAttribute(componentNode, influenceCount, result);

			skin->Components[componentIndex].InfluenceCount = influenceCount;
			skin->Components[componentIndex].Influences = new Data::SkinCluster::Skin::Component::Influence[influenceCount];

			XMLNode *influenceNode = componentNode->first_node("Influence"); while (influenceNode)
			{
				::UINT32 influenceIndex; GetIndexAttribute(influenceNode, influenceIndex, result);
				::FLOAT influenceWeight; GetFloatAttribute(influenceNode, "Weight", influenceWeight, result);
				::std::string fullPath; GetStringAttribute(influenceNode, "Full-Path", fullPath, result);
				::std::string partialPath; GetStringAttribute(influenceNode, "Partial-Path", partialPath, result);

				skin->Components[componentIndex].Influences[influenceIndex].Weight = influenceWeight;
				skin->Components[componentIndex].Influences[influenceIndex].FullPath = fullPath;
				skin->Components[componentIndex].Influences[influenceIndex].PartialPath = partialPath;

				influenceNode = influenceNode->next_sibling("Influence");
			}

			componentNode = componentNode->next_sibling("Component");
		}

		skinNode = skinNode->next_sibling("Skin");
	}
}
Пример #4
0
void KeyerConfigure::SetMorseCode( TiXmlElement *e )
{
   /*
      int codeinc;
      void procCodeParam(const std::string &pname, const std::string &pvalue )
      {
         MORSELETTER[ codeinc ] = toupper( pname[ 0 ] );
    
         for ( int i = 0; i < 8 && pvalue[ i ] && pvalue[ i ] != ' '; i++ )
         {
            if ( pvalue[ i ] == '.' )
               MORSECODE[ codeinc ][ i ] = 0x40;
            if ( pvalue[ i ] == '-' )
               MORSECODE[ codeinc ][ i ] = 0x80;
         }
         codeinc++;
      }
      void defineCode( const ParamTable &code )
      {
         memset( MORSELETTER, 0, MORSESIZE );
         memset( MORSECODE, 0, MORSESIZE * 8 );
         codeinc = 0;
         code.forEachParam( 0, 0, procCodeParam );
      }
   */
   for ( TiXmlElement * c = e->FirstChildElement(); c; c = c->NextSiblingElement() )
   {
      if ( checkElementName( c, "Key" ) )
      {
         std::string character;
         std::string code;
         if ( GetStringAttribute( c, "character", character ) == TIXML_SUCCESS
              && GetStringAttribute( c, "code", code ) == TIXML_SUCCESS )
         {
            std::string proccode;
            for ( int i = 0; i < 8 && code[ i ] && code[ i ] != ' '; i++ )
            {
               if ( code[ i ] == '.' )
                  proccode += '\x40';
               if ( code[ i ] == '-' )
                  proccode += '\x80';
            }
            MORSECODE[ character[ 0 ] ] = proccode;
         }
      }
   }
}
Пример #5
0
void Nena::Utility::MayaReader::ImportPolygons(XMLNode *shapeNode, Data::Shape *shapeData)
{
	::UINT32 result = 0;
	::UINT32 bntnIndex = 0;
	::UINT32 polygonsCount = 0;
	XMLNode *polygonsNode = shapeNode->first_node("Polygons");
	GetCountAttribute(polygonsNode, polygonsCount, result);

	shapeData->Polygons.resize(polygonsCount);

	XMLNode *polygonNode = polygonsNode->first_node("Polygon");
	while (polygonNode)
	{
		::UINT32 vertexCount = 0; ::UINT32 polygonIndex;
		GetCountAttribute(polygonNode, vertexCount, result);
		GetIndexAttribute(polygonNode, polygonIndex, result);

		shapeData->Polygons[polygonIndex] = new Data::Shape::Polygon;
		shapeData->Polygons[polygonIndex]->Vertices = new Data::Shape::Polygon::Vertex[vertexCount];
		shapeData->Polygons[polygonIndex]->VertexCount = vertexCount;

		XMLNode *vertexNode = polygonNode->first_node("Vertex");
		while (vertexNode)
		{
			::UINT32 vertexIndex, pointIndex, normalIndex, texcoordsCount;
			GetIndexAttribute(vertexNode, vertexIndex, result);
			GetUIntAttribute(vertexNode, "Point-Index", pointIndex, result);
			GetUIntAttribute(vertexNode, "Normal-Index", normalIndex, result);
			GetCountAttribute(vertexNode, texcoordsCount, result);

			shapeData->Polygons[polygonIndex]->Vertices[vertexIndex].PointIndex = pointIndex;
			shapeData->Polygons[polygonIndex]->Vertices[vertexIndex].NormalIndex = normalIndex;
			shapeData->Polygons[polygonIndex]->Vertices[vertexIndex].BinormalIndex = bntnIndex;
			shapeData->Polygons[polygonIndex]->Vertices[vertexIndex].TangentIndex = bntnIndex;
			shapeData->Polygons[polygonIndex]->Vertices[vertexIndex].TexcoordCount = texcoordsCount;
			shapeData->Polygons[polygonIndex]->Vertices[vertexIndex].Texcoords = new Data::Shape::Polygon::Vertex::Tex[texcoordsCount];

			::UINT32 texIndex = 0;
			XMLNode *texNode = vertexNode->first_node("Tex");
			while (texNode)
			{

				::std::string uvSetName; ::UINT32 uvIndex;
				GetStringAttribute(texNode, "UV-Set", uvSetName, result);
				GetUIntAttribute(texNode, "UV-Index", uvIndex, result);

				shapeData->Polygons[polygonIndex]->Vertices[vertexIndex].Texcoords[texIndex].UVIndex = uvIndex;
				shapeData->Polygons[polygonIndex]->Vertices[vertexIndex].Texcoords[texIndex].UVSet = uvSetName;

				texNode = texNode->next_sibling("Tex");
			}

			vertexNode = vertexNode->next_sibling("Vertex");
			bntnIndex++;
		}

		polygonNode = polygonNode->next_sibling("Polygon");
	}
}
Пример #6
0
static int GetStringAttribute( TiXmlElement *e, const std::string &name, std::string &s, const std::string &def )
{
   int ret = GetStringAttribute( e, name, s );
   if ( ret == TIXML_NO_ATTRIBUTE )
   {
      s = def;
   }
   return ret;
}
Пример #7
0
///=====================================================
/// 
///=====================================================
bool GetBoolAttribute(const XMLNode& node, const std::string& attributeName, bool defaultValue /*= false*/){
	std::string attr = GetStringAttribute(node, attributeName, defaultValue == true ? "1" : "0");
	if (attr == "1" || attr == "true")
		return true;
	if (attr == "0" || attr == "false")
		return false;

	return defaultValue;
}
Пример #8
0
///=====================================================
/// 
///=====================================================
TeleportBehavior::TeleportBehavior(const std::string& name, const XMLNode& behaviorNode) :
BaseAIBehavior(name, BehaviorType::Attack, behaviorNode),
m_healthThreshold(0.0f),
m_chance(0.0f),
m_phrase("casts Teleport"),
m_numUses(-1){
	m_healthThreshold = GetFloatAttribute(behaviorNode, "healthThreshold", m_healthThreshold);
	m_chance = GetFloatAttribute(behaviorNode, "chance", m_chance);
	m_phrase = GetStringAttribute(behaviorNode, "phrase", m_phrase);
	m_numUses = GetIntAttribute(behaviorNode, "numUses", m_numUses);
}
Пример #9
0
	int
	GetIntAttribute(const wxXmlNode& node, const wxString& name, const wxString& def)
	{
		wxString value = GetStringAttribute(node, name, def);
		long l;
		if (!value.ToLong(&l, 0))
		{
			THROW("Attribute \"%s\" in element <%s> is not an integer.", name.c_str(), node.GetName().c_str());
		}
		return l;
	}
Пример #10
0
void Nena::Utility::MayaReader::ImportCurves(
	XMLNode *transformNode, Data::Transform *transformData
	)
{
	::UINT32 type = 0;
	::UINT32 result = 0;
	::UINT32 keyCount = 0;
	::std::string curveName;
	XMLNode *curveNode, *keyNode;

	curveNode = transformNode->first_node("Curve");
	if (curveNode) transformData->Curves = new ::std::vector<Data::Transform::Curve *>();

	while (curveNode)
	{
		GetCountAttribute(curveNode, keyCount, result);
		GetUIntAttribute(curveNode, "Type", type, result);
		GetStringAttribute(curveNode, "Name", curveName, result);

		Data::Transform::Curve *curveData = new Data::Transform::Curve();
		transformData->Curves->push_back(curveData);
		//Root->GetHandles()->push_back(curveData);

		curveData->m_name = curveName;
		curveData->m_type = Data::IItem::kAnimationCurve;
		curveData->Type = type;
		curveData->KeyCount = keyCount;
		curveData->Keys = new Data::Transform::Curve::Key[keyCount];

		keyNode = curveNode->first_node("Key");
		while (keyNode)
		{
			::UINT32 keyIndex;
			GetIndexAttribute(keyNode, keyIndex, result);

			GetFloatAttribute(keyNode, "Time", curveData->Keys[keyIndex].Time, result);
			GetFloatAttribute(keyNode, "Value", curveData->Keys[keyIndex].Value, result);
			GetFloatAttribute(keyNode, "InX", curveData->Keys[keyIndex].In.x, result);
			GetFloatAttribute(keyNode, "InY", curveData->Keys[keyIndex].In.y, result);
			GetFloatAttribute(keyNode, "OutX", curveData->Keys[keyIndex].Out.x, result);
			GetFloatAttribute(keyNode, "OutY", curveData->Keys[keyIndex].Out.y, result);
			GetUIntAttribute(keyNode, "InType", curveData->Keys[keyIndex].InTangent, result);
			GetUIntAttribute(keyNode, "OutType", curveData->Keys[keyIndex].OutTangent, result);

			keyNode = keyNode->next_sibling("Key");
		}

		curveNode = curveNode->next_sibling("Curve");
	}
}
Пример #11
0
void KeyerConfigure::SetKeyers( TiXmlElement *e )
{
   /*
      void procKeyerParam( void *self, const std::string &pname, int pvalue )
      {
         lineMonitor * lm = ( lineMonitor * ) self;
         lm->procParam( pname, pvalue );
      }
   */
   for ( TiXmlElement * c = e->FirstChildElement(); c; c = c->NextSiblingElement() )
   {
      if ( checkElementName( c, "Keyer" ) )
      {
         // attribs name PipTone EnablePip StartDelay AutoRepeat PipStartDelay PlayPTTDelay
         std::string name;
         int PipTone;
         int PipLength;
         bool EnablePip;
         int StartDelay;
         int AutoRepeatDelay;
         bool EnableAutoRepeat;
         int PipStartDelay;
         int PlayPTTDelay;
         int voxHangTime;
         int pipVolume;
         int ClipRecord;

         if ( GetStringAttribute( c, "name", name ) == TIXML_SUCCESS )
         {
            GetIntAttribute( c, "pipTone", PipTone, 1000 );
            GetIntAttribute( c, "pipLength", PipLength, 250 );
            GetBoolAttribute( c, "enablePip", EnablePip, false );
            GetIntAttribute( c, "pipStartDelay", PipStartDelay, 0 );
            GetIntAttribute( c, "pipVolume", pipVolume, 80 );
            GetIntAttribute( c, "startDelay", StartDelay, 0 );
            GetIntAttribute( c, "autoRepeat", AutoRepeatDelay, 6 );
            GetBoolAttribute( c, "enableAutoRepeat", EnableAutoRepeat, false );
            GetIntAttribute( c, "playPTTDelay", PlayPTTDelay, 0 );
            GetIntAttribute( c, "voxHangTime", voxHangTime, 0 );
            GetIntAttribute( c, "clipRecord", ClipRecord, 0 );

            KeyerConfig k( name, PipTone, pipVolume, PipLength, EnablePip, StartDelay,
                           AutoRepeatDelay, EnableAutoRepeat, PipStartDelay, PlayPTTDelay, voxHangTime,
                           ClipRecord );
            keyermap[ name ] = k;
         }
      }
   }
}
Пример #12
0
static int GetBoolAttribute( TiXmlElement *e, const std::string &name, bool &b )
{
   std::string val;
   int ret = GetStringAttribute( e, name, val );
   if ( ret == TIXML_SUCCESS )
   {
      if ( val[ 0 ] == 't' || val[ 0 ] == 'T' || val[ 0 ] == 'y' || val[ 0 ] == 'Y' || val[ 0 ] == '1' )
      {
         b = true;
      }
      else
      {
         b = false;
      }
   }
   return ret;
}
Пример #13
0
	bool
	GetBoolAttribute(const wxXmlNode& node, const wxString& name, const wxString& def)
	{
		wxString value = GetStringAttribute(node, name, def);
		if (value == wxT("true"))
		{
			return true;
		}
		else if (value == wxT("false"))
		{
			return false;
		}
		else
		{
			THROW("Attribute \"%s\" in element <%s> is not a boolean.", name.c_str(), node.GetName().c_str());
		}
	}
Пример #14
0
///=====================================================
/// 
///=====================================================
Item::Item(const XMLNode& itemNode, OpenGLRenderer* renderer) :
Entity(itemNode, renderer),
m_type(Undefined),
m_equippedSlot(Unequippable),
m_damageReductionPercent(0.0f),
m_numUses(1),
m_healing(0),
m_damage(0, 0){
	m_name = GetStringAttribute(itemNode, "name");

	std::string itemType = GetStringAttribute(itemNode, "type");

	m_damageReductionPercent = GetFloatAttribute(itemNode, "damageReductionPercent", m_damageReductionPercent);
	m_numUses = GetIntAttribute(itemNode, "numUses", m_numUses);
	m_healing = GetIntAttribute(itemNode, "healing", m_healing);
	m_damage = IntVec2(GetIntAttribute(itemNode, "minDamage", m_damage.x), GetIntAttribute(itemNode, "maxDamage", m_damage.y));

	RGBAchars defaultColor = RGBAchars::WHITE;
	char defaultGlyph = ':';

	if (itemType == "Weapon"){
		m_type = ItemType::Weapon;
	}
	else if (itemType == "Armor"){
		m_type = ItemType::Armor;
	}
	else if (itemType == "Consumable"){
		m_type = ItemType::Consumable;
	}
	else{ //unknown item
		assert(false);
	}

	if (m_type != ItemType::Undefined){
		defaultColor = ITEM_COLOR_TABLE[m_type];
		defaultGlyph = ITEM_SYMBOL_TABLE[m_type];
	}


	std::string itemEquipSlot = GetStringAttribute(itemNode, "equip");

	if (itemEquipSlot == "Weapon"){
		m_equippedSlot = EquipmentSlot::WeaponSlot;
	}
	else if (itemEquipSlot == "Chest"){
		m_equippedSlot = EquipmentSlot::Chest;
	}
	else if (itemEquipSlot == "Head"){
		m_equippedSlot = EquipmentSlot::Head;
	}
	else if (itemEquipSlot == "Ring"){
		m_equippedSlot = EquipmentSlot::Ring;
	}
	else if (itemEquipSlot == "Hands"){
		m_equippedSlot = EquipmentSlot::Hands;
	}
	else if (itemEquipSlot == "Feet"){
		m_equippedSlot = EquipmentSlot::Feet;
	}
	else if (itemEquipSlot == "Legs"){
		m_equippedSlot = EquipmentSlot::Legs;
	}

	m_glyph = GetCharAttribute(itemNode, "glyph", defaultGlyph);
	m_color = GetColorAttribute(itemNode, "color", defaultColor);

	m_textRenderer.SetInputString(std::string(1, m_glyph));
	m_textRenderer.SetInputStringColor(m_color);
}
Пример #15
0
void Nena::Utility::MayaReader::GetSpaceAttribute(XMLNode *node, ::std::string &space, ::UINT32 &result)
{
	GetStringAttribute(node, "Space", space, result);
}
Пример #16
0
void Nena::Utility::MayaReader::GetNameAttribute(XMLNode *node, ::std::string &name, ::UINT32 &result)
{ 
	GetStringAttribute(node, "Name", name, result);
}
Пример #17
0
/// 载入系统邮件参数
void MailList::LoadSysMailList(TiXmlElement* pElem,tagMailParam* ptgMailParam)	
{
	for (TiXmlElement* pChildElem=pElem->FirstChildElement(); pChildElem!=NULL; 
		pChildElem=pChildElem->NextSiblingElement())
	{
		if (!stricmp(pChildElem->Value(),"BaseParam"))
		{
			//主题
			ptgMailParam->strSubject = GetStringAttribute(pChildElem, "subject");
			ptgMailParam->strText = GetStringAttribute(pChildElem, "text");
			ptgMailParam->strExText = GetStringAttribute(pChildElem, "extext");
			ptgMailParam->strWriter = GetStringAttribute(pChildElem, "writer");			

		} 
		else if(!stricmp(pChildElem->Value(), "Receiver"))
		{
			//邮件内容
			string strReceiver = GetStringAttribute(pChildElem, "name");
			if (strReceiver.size()>0)
			{
				ptgMailParam->strReceiverList.push_back(strReceiver); 
			}			
		}
// 		else if(!stricmp(pChildElem->Value(), "Good"))
// 		{
// 			//物品
// 			tagSGoods* ptgSGoods = new tagSGoods;
// 			ptgSGoods->lIndex = GetDwordAttribute(pChildElem, "id");
// 			ptgSGoods->lNum = GetDwordAttribute(pChildElem, "num");
// 			ptgMailParam->lSGoods.push_back(ptgSGoods);
// 		}
		else if (!stricmp(pChildElem->Value(), "Gold"))
		{
			ptgMailParam->lGold = GetDwordAttribute(pChildElem, "value");
		}

		else if (!stricmp(pChildElem->Value(), "Time"))
		{
			tagTimer* ptgTimer = new tagTimer;
			struct tm* timeinfo  = new tm;			
			LoadSysMailTimeConfig(pChildElem, timeinfo);
			ptgTimer->lIntev = GetDwordAttribute(pChildElem, "intev");
			ptgTimer->lCount = GetDwordAttribute(pChildElem, "count");
			ptgTimer->lTimer = (long)mktime(timeinfo);	
			ptgMailParam->ltgTimer.push_back(ptgTimer);
			SAFE_DELETE(timeinfo);
		}
		else if (!stricmp(pChildElem->Value(), "Condition"))
		{
			tagMailCondition* pMailCondition = new tagMailCondition;
			pMailCondition->strName = GetStringAttribute(pChildElem, "name");
			pMailCondition->lValue = GetDwordAttribute(pChildElem, "value");
			pMailCondition->strOperator = GetStringAttribute(pChildElem, "cmpfun");			
			ptgMailParam->lMailCondition.push_back(pMailCondition);
		}
		else if (!stricmp(pChildElem->Value(), "Event"))
		{
			tagMailEvent* ptgMailEvent = new tagMailEvent;
			ptgMailEvent->strEventName= GetStringAttribute(pChildElem, "name");
			LoadSysMailEventTime(pChildElem, ptgMailEvent);
			ptgMailParam->ltgMailEvent.push_back(ptgMailEvent);
		}
	}	
}