• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TdfParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TdfParser的典型用法代码示例。如果您正苦于以下问题:C++ TdfParser类的具体用法?C++ TdfParser怎么用?C++ TdfParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TdfParser类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Parse

	void ShaderDef::Parse(const TdfParser& tdf, bool needNormalMap)
	{
		string path = "map\\terrain\\";

		int numStages = atoi(tdf.SGetValueDef("0", path + "NumTextureStages").c_str());
		bool autoBumpMap = !!atoi(tdf.SGetValueDef("1", path + "AutoBumpmapStages").c_str());
		bool autoSpecular = !!atoi(tdf.SGetValueDef("1", path + "AutoSpecularStages").c_str());
		specularExponent = atof(tdf.SGetValueDef("8", path  + "SpecularExponent").c_str());

		LoadStages(numStages, "texstage", tdf, stages);

		if (needNormalMap) {
			// generate the bumpmap stages from the texture stages?
			if (autoBumpMap)
			{
				for (uint a=0;a<stages.size();a++)
				{
					Stage& st = stages[a];
					if (a && st.operation != Alpha && st.operation != Blend)
						continue;

					normalMapStages.push_back (Stage());

					Stage& bmst = normalMapStages.back();
					bmst.operation = st.operation;
					bmst.sourceName = st.sourceName;
				}
			}
			else {
				// otherwise load them from the bmstage list
				numStages = atoi(tdf.SGetValueDef("0", path + "NumBumpmapStages").c_str());
				LoadStages(numStages, "bmstage", tdf, normalMapStages);
			}
		}
	}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:35,代码来源:TerrainTexture.cpp


示例2: catch

CWeaponDefHandler::CWeaponDefHandler()
{
	std::vector<std::string> tafiles = CFileHandler::FindFiles("weapons/", "*.tdf");
	//std::cout << " getting files from weapons/*.tdf ... " << std::endl;

	TdfParser tasunparser;

	for(unsigned int i=0; i<tafiles.size(); i++)
	{
		try {
			tasunparser.LoadFile(tafiles[i]);
		}catch( TdfParser::parse_error const& e) {
			std::cout << "Exception:"  << e.what() << std::endl; 
		} catch(...) {
			std::cout << "Unknown exception in parse process of " << tafiles[i] <<" caught." << std::endl; 
		}
	}

	std::vector<std::string> weaponlist = tasunparser.GetSectionList("");

	weaponDefs = SAFE_NEW WeaponDef[weaponlist.size()+1];
	for(std::size_t taid=0; taid<weaponlist.size(); taid++)
	{
		ParseTAWeapon(&tasunparser, weaponlist[taid], taid);
	}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:26,代码来源:WeaponDefHandler.cpp


示例3: TdfParser

void CSyncer::ParseUnit(const string& fileName)
{
	TdfParser *p = new TdfParser();

	p->LoadFile(fileName);

	delete p;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:8,代码来源:Syncer.cpp


示例4: OpenTDF

void CReadMap::OpenTDF (const std::string& mapname, TdfParser& parser)
{
	string extension = mapname.substr(mapname.length()-3);
	if (extension == "smf") 
		parser.LoadFile (string("maps/")+mapname.substr(0,mapname.find_last_of('.'))+".smd");
	else if(extension == "sm3")
		parser.LoadFile (string("maps/")+mapname);
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:8,代码来源:ReadMap.cpp


示例5: transform

int CSyncer::ProcessUnits(bool checksum)
{
	if (!populated) {
		//Populate the list of unit files to consider
		files = CFileHandler::FindFiles("units/*.fbi");
		populated = true;
	}

	if (files.size() == 0) {
		return 0;
	}

	string curFile = files.back();
	files.pop_back();

	size_t len = curFile.find_last_of("/")+1;
	string unitName = curFile.substr(len, curFile.size() - 4 - len);
	transform(unitName.begin(), unitName.end(), unitName.begin(), (int (*)(int))tolower);

	string perror("");
	TdfParser *parser = new TdfParser();
	try {
		parser->LoadFile("units/" + unitName + ".fbi");
	} catch (TdfParser::parse_error& pe) {	
		perror = unitName + " (" + string(pe.what()) + ")";
	}

	Unit u;

	if (checksum) {
		u.fbi = CalculateCRC("units/" + unitName + ".fbi");
		u.cob = CalculateCRC("scripts/" + unitName + ".cob");

		//The model filenames has to be figured out from the fbi file
		string modelName = parser->SGetValueDef(unitName, "unitinfo\\Objectname");
		string deadName = parser->SGetValueDef(unitName + "_dead", "unitinfo\\Corpse");

		u.model = CalculateCRC("objects3d/" + modelName + ".3do");
		u.model += CalculateCRC("objects3d/" + deadName + ".3do");
	}

	u.fullName = parser->SGetValueDef("unknown", "unitinfo\\Name");
	if (perror.length() > 0)
		u.fullName = perror;

	units[unitName] = u; 

	delete parser;

	//If we are done, map id numbers to names
	if (files.size() == 0) {
		MapUnitIds();
	}

	return (int)files.size();
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:56,代码来源:Syncer.cpp


示例6: time

	void Log::Open(){
		//char buffer[1000];
		if( Lmagic != 95768){
			Lmagic = 95768;
			First = true;
		}


		time_t now1;
		time(&now1);
		struct tm *now2;
		now2 = localtime(&now1);
		std::string filename = G->info->datapath + slash + "Logs" + slash;

		// DDD MMM DD HH:MM:SS YYYY_X - NTAI.log
		filename += to_string(now2->tm_mon+1)+"-" +to_string(now2->tm_mday) + "-" +to_string(now2->tm_year + 1900) +"-" +to_string(now2->tm_hour) +"_" +to_string(now2->tm_min) +"["+to_string(G->Cached->team)+"]XE10.1.log";

		logFile.open(filename.c_str());
		if(logFile.is_open() == false){
			logFile.close();
			logFile.open(filename.c_str());
			if(logFile.is_open() == false){
				iprint(std::string("Error!!! ") + filename + std::string(" refused to open!"));
				verbose = true;
				return;
			}
		}

		header(" :: NTAI XE10.1 Log File \n :: Programmed and maintained by AF/T.Nowell \n :: Copyright (C) 2004 Tom Nowell/AF \n");
		logFile << " :: Game started: " << now2->tm_mday << "." << now2->tm_mon << "." << 1900 + now2->tm_year << "  " << now2->tm_hour << ":" << now2->tm_min << ":" << now2->tm_sec << std::endl << std::endl <<  std::flush;
		
		
		int size = G->cb->GetFileSize("modinfo.tdf");
		char* c = new char[size];
		if(size > 0){
			G->cb->ReadFile(filename.c_str(),c,size);
			
			TdfParser cp;
			cp.LoadBuffer(c,(std::size_t)size);
			
			std::string tempstr = "";
			cp.SGetValue(tempstr, "MOD\\Name");
			logFile << " :: " << tempstr << std::endl <<  std::flush;
			
			tempstr = "";
			cp.SGetValue(tempstr, "MOD\\Description");
			logFile << " :: " << tempstr << std::endl <<  std::flush;
		}

		if(First == true) logFile << " :: First instance of NTAI" << std::endl;
		
		logFile << std::endl <<  std::flush;
	}
开发者ID:Tarendai,项目名称:ntai,代码行数:53,代码来源:Log.cpp


示例7: LoadAllyTeams

void CGameSetup::LoadAllyTeams(const TdfParser& file)
{
	// i = allyteam index in game (no gaps), a = allyteam index in script
	int i = 0;
	for (int a = 0; a < MAX_TEAMS; ++a) {
		char section[50];
		sprintf(section,"GAME\\ALLYTEAM%i",a);
		string s(section);

		if (!file.SectionExist(s))
			continue;

		AllyTeam data;
		std::map<std::string, std::string> setup = file.GetAllValues(s);

		for (std::map<std::string, std::string>::const_iterator it = setup.begin(); it != setup.end(); ++it)
			data.SetValue(it->first, it->second);

		allyStartingData.push_back(data);

		allyteamRemap[a] = i;
		++i;
	}

	{
		const size_t numAllyTeams = allyStartingData.size();
		for (size_t a = 0; a < numAllyTeams; ++a) {
			allyStartingData[a].allies.resize(numAllyTeams, false);
			allyStartingData[a].allies[a] = true; // each team is allied with itself

			std::ostringstream section;
			section << "GAME\\ALLYTEAM" << a << "\\";

			const size_t numAllies = atoi(file.SGetValueDef("0", section.str() + "NumAllies").c_str());

			for (size_t b = 0; b < numAllies; ++b) {
				std::ostringstream key;
				key << "GAME\\ALLYTEAM" << a << "\\Ally" << b;
				const int other = atoi(file.SGetValueDef("0",key.str()).c_str());
				allyStartingData[a].allies[allyteamRemap[other]] = true;
			}
		}
	}

	unsigned allyCount = 0;
	if (file.GetValue(allyCount, "GAME\\NumAllyTeams") && (allyStartingData.size() != allyCount)) {
		LOG_L(L_WARNING, "Incorrect number of ally teams in GameSetup script");
	}
}
开发者ID:amitamitamitamit,项目名称:spring,代码行数:49,代码来源:GameSetup.cpp


示例8: LoadUnitRestrictions

void CGameSetup::LoadUnitRestrictions(const TdfParser& file)
{
	int numRestrictions;
	file.GetDef(numRestrictions, "0", "GAME\\NumRestrictions");

	for (int i = 0; i < numRestrictions; ++i) {
		char key[100];
		sprintf(key, "GAME\\RESTRICT\\Unit%d", i);
		string resName = file.SGetValueDef("", key);
		sprintf(key, "GAME\\RESTRICT\\Limit%d", i);
		int resLimit;
		file.GetDef(resLimit, "0", key);

		restrictedUnits[resName] = resLimit;
	}
}
开发者ID:niavok,项目名称:spring,代码行数:16,代码来源:GameSetup.cpp


示例9: LoadMutators

void CGameSetup::LoadMutators(const TdfParser& file, std::vector<std::string>& mutatorsList)
{
	for (int a = 0; a < 10; ++a) {
		std::string s = file.SGetValueDef("", IntToString(a, "GAME\\MUTATOR%i"));
		if (s.empty()) break;
		mutatorsList.push_back(s);
	}
}
开发者ID:amitamitamitamit,项目名称:spring,代码行数:8,代码来源:GameSetup.cpp


示例10: LoadStages

	void ShaderDef::LoadStages(int numStages,const char *stagename, const TdfParser& tdf, std::vector<ShaderDef::Stage>& stages)
	{
		for (int a=0;a<numStages;a++)
		{
			string path = "map\\terrain\\";
			char num[10];
			SNPRINTF(num, 10, "%d", a);

			string ts = path + stagename + num + "\\";

			string opstr = tdf.SGetValueDef("mul", ts + "operation");
			struct { StageOp op; const char *str; } tbl[] =
			{
				{ Mul, "mul" },
				{ Add, "add" },
				{ Alpha, "alpha" },
				{ Blend, "blend" },
				{ Mul, 0 },
			};

			StageOp operation = Mul;
			for (int i = 0; tbl[i].str; i++)
			{
				if (opstr == tbl[i].str) {
					operation = tbl[i].op;
					break;
				}
			}

			if (operation == Blend)
			{
				// insert an alpha stage before the blend stage
				stages.push_back(Stage());
				stages.back().sourceName = tdf.SGetValueDef(string(), ts + "blender");
				stages.back().operation = Alpha;
			}

			stages.push_back(Stage());
			stages.back().sourceName = tdf.SGetValueDef(string(), ts + "source");
			stages.back().operation = operation;
			if (stages.back().sourceName.empty())
				throw content_error(ts + " does not have a source texture");
		}
	}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:44,代码来源:TerrainTexture.cpp


示例11: LoadPlayers

void CGameSetup::LoadPlayers(const TdfParser& file, std::set<std::string>& nameList)
{
	numDemoPlayers = 0;
	// i = player index in game (no gaps), a = player index in script
	int i = 0;
	for (int a = 0; a < MAX_PLAYERS; ++a) {
		char section[50];
		sprintf(section, "GAME\\PLAYER%i", a);
		string s(section);

		if (!file.SectionExist(s)) {
			continue;
		}
		PlayerBase data;

		// expects lines of form team=x rather than team=TEAMx
		// team field is relocated in RemapTeams
		std::map<std::string, std::string> setup = file.GetAllValues(s);
		for (std::map<std::string, std::string>::const_iterator it = setup.begin(); it != setup.end(); ++it)
			data.SetValue(it->first, it->second);

		// do checks for sanity
		if (data.name.empty())
			throw content_error(str( boost::format("GameSetup: No name given for Player %i") %a ));
		if (nameList.find(data.name) != nameList.end())
			throw content_error(str(boost::format("GameSetup: Player %i has name %s which is already taken")	%a %data.name.c_str() ));
		nameList.insert(data.name);

		if (data.isFromDemo)
			numDemoPlayers++;

		playerStartingData.push_back(data);
		playerRemap[a] = i;
		++i;
	}

	unsigned playerCount = 0;
	if (file.GetValue(playerCount, "GAME\\NumPlayers") && playerStartingData.size() != playerCount) {
		LOG_L(L_WARNING,
			_STPF_ " players in GameSetup script (NumPlayers says %i)",
			playerStartingData.size(), playerCount);
	}
}
开发者ID:amitamitamitamit,项目名称:spring,代码行数:43,代码来源:GameSetup.cpp


示例12: LoadSkirmishAIs

void CGameSetup::LoadSkirmishAIs(const TdfParser& file, std::set<std::string>& nameList)
{
	// i = AI index in game (no gaps), a = AI index in script
	for (int a = 0; a < MAX_PLAYERS; ++a) {
		char section[50];
		sprintf(section, "GAME\\AI%i\\", a);
		string s(section);

		if (!file.SectionExist(s.substr(0, s.length() - 1))) {
			continue;
		}

		SkirmishAIData data;

		data.team = atoi(file.SGetValueDef("-1", s + "Team").c_str());
		if (data.team == -1) {
			throw content_error("missing AI.Team in GameSetup script");
		}
		data.hostPlayer = atoi(file.SGetValueDef("-1", s + "Host").c_str());
		if (data.hostPlayer == -1) {
			throw content_error("missing AI.Host in GameSetup script");
		}

		data.shortName = file.SGetValueDef("", s + "ShortName");
		if (data.shortName == "") {
			throw content_error("missing AI.ShortName in GameSetup script");
		}

		data.version = file.SGetValueDef("", s + "Version");
		if (file.SectionExist(s + "Options")) {
			data.options = file.GetAllValues(s + "Options");
			std::map<std::string, std::string>::const_iterator kv;
			for (kv = data.options.begin(); kv != data.options.end(); ++kv) {
				data.optionKeys.push_back(kv->first);
			}
		}

		// get the visible name (comparable to player-name)
		std::string name = file.SGetValueDef(data.shortName, s + "Name");
		int instanceIndex = 0;
		std::string name_unique = name;
		while (nameList.find(name_unique) != nameList.end()) {
			name_unique = name + "_" + IntToString(instanceIndex++);
			// so we possibly end up with something like myBot_0, or RAI_2
		}
		data.name = name_unique;
		nameList.insert(data.name);

		skirmishAIStartingData.push_back(data);
	}
}
开发者ID:amitamitamitamit,项目名称:spring,代码行数:51,代码来源:GameSetup.cpp


示例13: content_error

CSensorHandler::CSensorHandler()
{
	TdfParser tdfparser;

	try {
		tdfparser.LoadFile("gamedata/sensors.tdf");
	} catch (content_error) {
		// No need to do anything here, we just continue
		// getting default values from the empty tdfparser.
	}

	tdfparser.GetDef(losMipLevel, "1", "Sensors\\Los\\LosMipLevel");
	//loshandler->losMipLevel = losMipLevel;
	tdfparser.GetDef(airMipLevel, "2", "Sensors\\Los\\AirLosMipLevel");
	//loshandler->airLosMipLevel = airLosMipLevel;

	// losMipLevel is used as index to readmap->mipHeightmap,
	// so the max value is CReadMap::numHeightMipMaps - 1
	if (losMipLevel < 0 || losMipLevel >= 7)
		throw content_error("Sensors\\Los\\LosMipLevel out of bounds. "
				"The minimum value is 0. The maximum value is 6.");

	// airLosMipLevel doesn't have such restrictions, it's just used in various
	// bitshifts with signed integers
	if (airMipLevel < 0 || airMipLevel > 30)
		throw content_error("Sensors\\Los\\AirLosMipLevel out of bounds. "
				"The minimum value is 0. The maximum value is 30.");

	tdfparser.GetDef(losMul, "1", "Sensors\\Los\\LosMul");
	tdfparser.GetDef(airLosMul, "1", "Sensors\\Los\\AirLosMul");
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:31,代码来源:SensorHandler.cpp


示例14: LoadSound

void CUnitDefHandler::LoadSound(TdfParser &tdfparser, GuiSound &gsound, std::string sunname)
{
	soundcategory.GetDef(gsound.name, "", tdfparser.SGetValueDef("", "UNITINFO\\SoundCategory")+"\\"+sunname);
	if(gsound.name.compare("")==0)
		gsound.id = 0;
	else
	{
		CFileHandler file("sounds/"+gsound.name+".wav");
		if(file.FileExists())
			gsound.id = sound->GetWaveId(gsound.name+".wav");
		else
			gsound.id = 0;
	}
	gsound.volume = 5.0f;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:15,代码来源:UnitDefHandler.cpp


示例15: ParseSettings

void CReadMap::ParseSettings(TdfParser& resources)
{	
	gs->sunVector=mapDefParser.GetFloat3(float3(0,1,2),"MAP\\LIGHT\\SunDir");
	gs->sunVector.Normalize();
	gs->sunVector4[0]=gs->sunVector[0];
	gs->sunVector4[1]=gs->sunVector[1];
	gs->sunVector4[2]=gs->sunVector[2];
	gs->sunVector4[3]=0;

	gs->gravity=-atof(mapDefParser.SGetValueDef("130","MAP\\Gravity").c_str())/(GAME_SPEED*GAME_SPEED);

	float3 fogColor=mapDefParser.GetFloat3(float3(0.7,0.7,0.8),"MAP\\ATMOSPHERE\\FogColor");
	FogLand[0]=fogColor[0];
	FogLand[1]=fogColor[1];
	FogLand[2]=fogColor[2];

	mapDefParser.GetDef(skyBox, "", "MAP\\ATMOSPHERE\\SkyBox");
	std::string tmp;
	mapDefParser.GetDef(tmp, "", "MAP\\WATER\\WaterPlaneColor");
	if(tmp.empty())
		hasWaterPlane=0;
	else
	{
		hasWaterPlane = 1;
		waterPlaneColor = mapDefParser.GetFloat3(float3(0.0,0.4,0.0),"MAP\\WATER\\WaterPlaneColor");
	}
	mapDefParser.GetDef(tidalStrength, "0", "MAP\\TidalStrength");

	waterSurfaceColor=mapDefParser.GetFloat3(float3(0.75,0.8,0.85),"MAP\\WATER\\WaterSurfaceColor");
	waterAbsorb=mapDefParser.GetFloat3(float3(0,0,0),"MAP\\WATER\\WaterAbsorb");
	waterBaseColor=mapDefParser.GetFloat3(float3(0,0,0),"MAP\\WATER\\WaterBaseColor");
	waterMinColor=mapDefParser.GetFloat3(float3(0,0,0),"MAP\\WATER\\WaterMinColor");
	mapDefParser.GetDef(waterTexture, "", "MAP\\WATER\\WaterTexture");
	if(waterTexture.empty())	//default water is ocean.jpg in bitmaps, map specific water textures is saved in the map dir
		waterTexture = "bitmaps/"+resources.SGetValueDef("ocean.jpg","resources\\graphics\\maps\\watertex");
	else
		waterTexture = "maps/" + waterTexture;

	ambientColor=mapDefParser.GetFloat3(float3(0.5,0.5,0.5),"MAP\\LIGHT\\GroundAmbientColor");
	sunColor=mapDefParser.GetFloat3(float3(0.5,0.5,0.5),"MAP\\LIGHT\\GroundSunColor");
	mapDefParser.GetDef(shadowDensity, "0.8", "MAP\\LIGHT\\GroundShadowDensity");

	mapDefParser.GetDef(maxMetal,"0.02","MAP\\MaxMetal");
	mapDefParser.GetDef(extractorRadius,"500","MAP\\ExtractorRadius");
	
	mapDefParser.GetDef(voidWater, "0", "MAP\\voidWater");	
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:47,代码来源:ReadMap.cpp


示例16: catch

CSensorHandler::CSensorHandler(void)
{
	TdfParser tdfparser;

	try {
		tdfparser.LoadFile("gamedata/sensors.tdf");
	} catch (content_error) {
		// No need to do anything here, we just continue
		// getting the values from the empty tdfparser.
	}

	tdfparser.GetDef(losMipLevel, "1", "Sensors\\Los\\LosMipLevel");
	//loshandler->losMipLevel = losMipLevel;
	tdfparser.GetDef(airMipLevel, "2", "Sensors\\Los\\AirLosMipLevel");
	//loshandler->airLosMipLevel = airLosMipLevel;

	tdfparser.GetDef(losMul, "1", "Sensors\\Los\\LosMul");
	tdfparser.GetDef(airLosMul, "1", "Sensors\\Los\\AirLosMul");
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:19,代码来源:SensorHandler.cpp


示例17: CreateUIElement

// this function recursively constructs the view hierarchy from a suitable tdf.
void GUIdialogController::CreateUIElement(TdfParser & parser, GUIframe* parent, const string& path)
{
	GUIframe *frame=NULL;
	
	// get properties
	string type=parser.SGetValueDef("none", path+"\\type");
	string identifier=parser.SGetValueDef("", path+"\\id");
	string tooltip=parser.SGetValueDef("", path+"\\tooltip");

	float x=atof(parser.SGetValueDef("-1", path+"\\x").c_str());
	float y=atof(parser.SGetValueDef("-1", path+"\\y").c_str());
	float w=atof(parser.SGetValueDef("-1", path+"\\w").c_str());
	float h=atof(parser.SGetValueDef("-1", path+"\\h").c_str());

	float x2=atof(parser.SGetValueDef("-1", path+"\\x2").c_str());
	float y2=atof(parser.SGetValueDef("-1", path+"\\y2").c_str());

	string caption=parser.SGetValueDef("No Caption", path+"\\caption");

	// scale the frame
	{
		#define ScaleX(a) if(a<=1.0&&a>=0.0) a*=parent->w;
		#define ScaleY(a) if(a<=1.0&&a>=0.0) a*=parent->h;

		ScaleX(x);
		ScaleX(x2);
		ScaleX(w);

		ScaleY(y);
		ScaleY(y2);
		ScaleY(h);

		if(x<0)
		{
			// x is not set, require w and x2
			x=parent->w-x2-w;	
		} 
		else if (w<0)
		{
			if(x2>=0)
				w=parent->w-x2-x;		// w is not set but x2 is
			else
				w=0;		// neither w nor x2 are set; may happen for autosizing buttons
		}

		if(y<0)
		{
			// y is not set, require h and y2
			y=parent->h-y2-h;	
		} 
		else if (h<0)
		{
			if(y2>=0)
				h=parent->h-y2-y;		// w is not set but x2 is
			else
				h=0;		// neither w nor x2 are set
		}

	}

	// create respective control	
	if(type=="none")
	{
		frame=parent;
	}
	else if(type=="buildmenu")
	{
		GUIbuildMenu *bm=new GUIbuildMenu((int)x, (int)y, (int)w, (int)h, makeFunctor((Functor1<UnitDef*>*)0, *this, &GUIdialogController::BuildMenuClicked));
		float num=atof(parser.SGetValueDef("64", path+"\\buildpicsize").c_str());
		ScaleX(num);
		bm->SetBuildPicSize((int)num);
		frame=bm;
	}
	else if(type=="centerbuildmenu")
	{
		GUIbuildMenu *bm=new GUIcenterBuildMenu((int)x, (int)y, (int)w, (int)h, makeFunctor((Functor1<UnitDef*>*)0, *this, &GUIdialogController::BuildMenuClicked));
		float num=atof(parser.SGetValueDef("64", path+"\\buildpicsize").c_str());
		ScaleX(num);
		bm->SetBuildPicSize((int)num);
		frame=bm;
	}
	else if(type=="frame")
	{
		frame=new GUIframe((int)x, (int)y, (int)w, (int)h);
	}
	else if(type=="minimap")
	{
		frame=new GUIminimap();
	}
	else if(type=="tab")
	{
		frame=new GUItab((int)x, (int)y, (int)w, (int)h);
	}
	else if(type=="table")
	{
		GUItable *table=new GUItable((int)x, (int)y, (int)w, (int)h, NULL, makeFunctor((Functor3<GUItable*, int, int>*)0, *this, &GUIdialogController::TableSelection));

		frame=table;
	}
//.........这里部分代码省略.........
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:101,代码来源:GUIcontroller.cpp


示例18: Load

void ClassAliasList::Load(TdfParser& parser, const string& location)
{
    const map<string,string>& lst = parser.GetAllValues (location);

    aliases.insert(lst.begin(), lst.end());
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:6,代码来源:ExplosionGenerator.cpp


示例19: dparser

void CUnitDefHandler::FindTABuildOpt()
{
	TdfParser tdfparser;
      	tdfparser.LoadFile("gamedata/SIDEDATA.TDF");

	std::vector<std::string> sideunits = tdfparser.GetSectionList("CANBUILD");
	for(unsigned int i=0; i<sideunits.size(); i++)
	{
		std::map<std::string, std::string>::iterator it;

		UnitDef *builder=NULL;
		std::transform(sideunits[i].begin(), sideunits[i].end(), sideunits[i].begin(), (int (*)(int))std::tolower);
		std::map<std::string, int>::iterator it1 = unitID.find(sideunits[i]);
		if(it1!= unitID.end())
			builder = &unitDefs[it1->second];

		if(builder)
		{
			std::map<std::string, std::string> buildoptlist = tdfparser.GetAllValues("CANBUILD\\" + sideunits[i]);
			for(it=buildoptlist.begin(); it!=buildoptlist.end(); it++)
			{
				UnitDef *buildopt=0;
				std::transform(it->second.begin(),it->second.end(), it->second.begin(), (int (*)(int))std::tolower);

				if(unitID.find(it->second)!= unitID.end()){
					int num=atoi(it->first.substr(8).c_str());
					builder->buildOptions[num]=it->second;
				}
			}
		}
	}

	std::vector<std::string> files = CFileHandler::FindFiles("download/*.tdf");
	for(unsigned int i=0; i<files.size(); i++)
	{
		TdfParser dparser(files[i]);

		std::vector<std::string> sectionlist = dparser.GetSectionList("");

		for(unsigned int j=0; j<sectionlist.size(); j++)
		{
			UnitDef *builder=NULL;
			std::string un1 = dparser.SGetValueDef("", sectionlist[j] + "\\UNITMENU");
			std::transform(un1.begin(), un1.end(), un1.begin(), (int (*)(int))std::tolower);
			std::map<std::string, int>::iterator it1 = unitID.find(un1);
			if(it1!= unitID.end())
				builder = &unitDefs[it1->second];

			if(builder)
			{
				UnitDef *buildopt=NULL;
				string un2 = dparser.SGetValueDef("", sectionlist[j] + "\\UNITNAME");
				std::transform(un2.begin(), un2.end(), un2.begin(), (int (*)(int))std::tolower);

				if(unitID.find(un2)!= unitID.end()){
					int menu=atoi(dparser.SGetValueDef("", sectionlist[j] + "\\MENU").c_str());
					int button=atoi(dparser.SGetValueDef("", sectionlist[j] + "\\BUTTON").c_str());
					int num=(menu-2)*6+button+1;
					builder->buildOptions[num]=un2;
				} else {
					info->AddLine("couldnt find unit %s",un2.c_str());
				}
			}
		}

	}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:67,代码来源:UnitDefHandler.cpp



注:本文中的TdfParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TeDatabasePortal类代码示例发布时间:2022-05-31
下一篇:
C++ TcpSocket类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap