当前位置: 首页>>代码示例>>C++>>正文


C++ FitIniFile::readIdLong方法代码示例

本文整理汇总了C++中FitIniFile::readIdLong方法的典型用法代码示例。如果您正苦于以下问题:C++ FitIniFile::readIdLong方法的具体用法?C++ FitIniFile::readIdLong怎么用?C++ FitIniFile::readIdLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FitIniFile的用法示例。


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

示例1: init

void LogisticsVehicle::init(FitIniFile& file)
{
	componentCount = 0;
	file.seekBlock("ObjectType");
	char tmp[256];
	file.readIdString("AppearanceName", tmp, 255);
	fileName = tmp;
	file.seekBlock("General");
	file.readIdLong("DescIndex", chassisNameID);
	file.readIdFloat("CurTonnage", maxWeight);
	char tmpWeightClass[256];
	cLoadString(IDS_VEHICLE_CLASS, tmpWeightClass, 256);
	mechClass = tmpWeightClass;
	if(NO_ERROR != file.readIdLong("HouseID", houseID))
	{
		houseID = -1;
	}
	if(NO_ERROR != file.readIdLong("EncyclopediaID", encyclopediaID))
	{
		encyclopediaID = IDS_VEHICLE_DESCRIPTION_0;
	}
	file.seekBlock("VehicleDynamics");
	file.readIdFloat("MaxVelocity", speed);
	PSTR parts[5] = { "Front", "Left", "Right", "Rear", "Turret" };
	baseArmor = 0;
	uint8_t pts;
	int32_t i;
	for(i = 0; i < 5; i++)
	{
		file.seekBlock(parts[i]);
		file.readIdUChar("MaxArmorPoints", pts);
		baseArmor += pts;
		file.readIdUChar("CurInternalStructure", pts);
		baseArmor += pts;
	}
	file.seekBlock("InventoryInfo");
	file.readIdUChar("NumWeapons", pts);
	char blockName[256];
	for(i = 4; i < 4 + pts; i++)
	{
		sprintf(blockName, "Item:%ld", i);
		if(NO_ERROR == file.seekBlock(blockName))
		{
			uint8_t fitID;
			file.readIdUChar("MasterID", fitID);
			LogisticsComponent* pComponent = LogisticsData::instance->getComponent(fitID);
			if(pComponent)
			{
				components[componentCount].component = pComponent;
				components[componentCount].xCoord = 0;
				components[componentCount].yCoord = 0;
				componentCount++;
			}
		}
	}
}
开发者ID:BobrDobr69,项目名称:mechcommander2,代码行数:56,代码来源:logisticsvariant.cpp

示例2: init

void MechListBoxItem::init( FitIniFile& file )
{
	if ( !s_templateItem )
	{
		s_templateItem = new MechListBoxItem( NULL, 0 );
		file.seekBlock( "MainBox" );

		long width, height;

		file.readIdLong( "Width", width );
		file.readIdLong( "Height", height );

		((aObject*)s_templateItem)->init( 0, 0, width, height );

		memset( s_templateItem->animationIDs, 0, sizeof(long) * 9  );

		// rects
		s_templateItem->line.init( &file, "Rect1" );
		s_templateItem->outline.init( &file, "Rect0" );

		long curAnim = 0;
		// statics
		s_templateItem->weightIcon.init( &file, "Static0" );
		assignAnimation( file, curAnim );
	
		s_templateItem->mechIcon.init( &file, "Static1" );
		assignAnimation( file, curAnim );
		s_templateItem->costIcon.init( &file, "Static2" );
		assignAnimation( file, curAnim );

		// texts
		s_templateItem->chassisName.init( &file, "Text0" );
		assignAnimation( file, curAnim );
		s_templateItem->weightText.init( &file, "Text1" );
		assignAnimation( file, curAnim );
		s_templateItem->countText.init( &file, "Text2" );
		assignAnimation( file, curAnim );
		s_templateItem->variantName.init( &file, "Text3" );
		assignAnimation( file, curAnim );
		s_templateItem->costText.init( &file, "Text4" );
		assignAnimation( file, curAnim );

		char blockName[64];
		for ( int i = 0; i < 4; i++ )
		{
			sprintf( blockName, "OrangeAnimation%ld", i );
			s_templateItem->animations[1][i].init( &file, blockName );
			sprintf( blockName, "Animation%ld", i );
			s_templateItem->animations[0][i].init( &file, blockName );
		}
		
	}

}
开发者ID:Ariemeth,项目名称:MechCommander2HD,代码行数:54,代码来源:MechListBox.cpp

示例3: isCorrectVersionSaveGame

bool LogisticsSaveDialog::isCorrectVersionSaveGame( char* fileName )
{
	FullPathFileName path;
	path.init( savePath, fileName, ".fit" );

	FitIniFile file;

	if ( NO_ERR != file.open( (char*)(const char*)path ) )
	{
		char errorStr[256];
		sprintf( errorStr, "couldn't open file %s", path );
		STOP((errorStr));
	}

	
	long result = file.seekBlock( "Version" );
	if (result != NO_ERR)
		return false;

	long testVersionNum = 0;
	result = file.readIdLong( "VersionNumber", testVersionNum );
	if ( (result == NO_ERR) && (testVersionNum == SaveGameVersionNumber))
		return true;

	return false;
}
开发者ID:Ariemeth,项目名称:MechCommander2HD,代码行数:26,代码来源:LogisticsDialog.cpp

示例4: readCampaignNameFromFile

void LogisticsSaveDialog::readCampaignNameFromFile( char* fileName, char* resultName, long len )
{
	FullPathFileName path;
	path.init( campaignPath, fileName, ".fit" );

	FitIniFile file;

	if ( NO_ERR != file.open( (char*)(const char*)path ) )
	{
		char errorStr[256];
		sprintf( errorStr, "couldn't open file %s", path );
		Assert( 0, 0, errorStr );
	}

	
	long result = file.seekBlock( "Campaign" );
	Assert( result == NO_ERR, 0, "Coudln't find the mission settings block in the mission file" );

	resultName[0] = 0;
	long lName = 0;

	result = file.readIdLong( "NameID", lName );
	if ( result == NO_ERR )
	{
		cLoadString( lName, resultName, len );
	}
	else
	{
		result = file.readIdString( "CampaignName", resultName, len );
		Assert( result == NO_ERR, 0, "couldn't find the missionName" );
	}
}
开发者ID:Ariemeth,项目名称:MechCommander2HD,代码行数:32,代码来源:LogisticsDialog.cpp

示例5: init

void aTextListItem::init( FitIniFile& file, const char* blockName )
{
	file.seekBlock( blockName );

	long x, y, width, height;

	file.readIdLong( "XLocation", x );
	file.readIdLong( "YLocation", y );
	file.readIdLong( "Width", width );
	file.readIdLong( "Height", height );

	aObject::init( x, y, width, height );

	long color;
	file.readIdLong( "Color", color );
	setColor( color );
}
开发者ID:Ariemeth,项目名称:MechCommander2HD,代码行数:17,代码来源:ALISTBOX.CPP

示例6: sReadIdInteger

static long sReadIdInteger(FitIniFile &missionFile, const char *varName, int &value) {
	long result = 0;
	long tmpLong;
	result = missionFile.readIdLong((char *)varName, tmpLong);
	if (NO_ERR != result) {
		//assert(false);
	} else {
		value = tmpLong;
	}
	return result;
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例7: sReadIdInteger

static int32_t sReadIdInteger(FitIniFile& missionFile, PCSTR varName, int32_t& value)
{
	int32_t result = 0;
	int32_t tmpLong;
	result = missionFile.readIdLong((PSTR)varName, tmpLong);
	if(NO_ERROR != result)
	{
		//assert(false);
	}
	else
	{
		value = tmpLong;
	}
	return result;
}
开发者ID:BobrDobr69,项目名称:mechcommander2,代码行数:15,代码来源:campaigndata.cpp

示例8: initColorTables

//----------------------------------------------------------------------------------
void initColorTables (void)
{
	FullPathFileName colorPath;
	colorPath.init(cameraPath,"colors",".fit");

	FitIniFile colorFile;
	long result = colorFile.open(colorPath);
	gosASSERT(result == NO_ERR);

	result = colorFile.seekBlock("Main");
	gosASSERT(result == NO_ERR);

	result = colorFile.readIdLong("NumTables",numColorRGBTables);
	gosASSERT(result == NO_ERR);

	colorRGBLookup = (DWORD **)systemHeap->Malloc(sizeof(DWORD *) * numColorRGBTables);
	gosASSERT(colorRGBLookup != NULL);

	memset(colorRGBLookup,0,sizeof(DWORD *) * numColorRGBTables);

	for (long i=0;i<numColorRGBTables;i++)
	{
		char tableBlock[256];
		sprintf(tableBlock,"Table%d",i);

		result = colorFile.seekBlock(tableBlock);
		gosASSERT(result == NO_ERR);

		colorRGBLookup[i] = (DWORD *)systemHeap->Malloc(sizeof(DWORD) * MAX_COLOR_ENTRIES);
		gosASSERT(colorRGBLookup[i] != NULL);

		DWORD *table = colorRGBLookup[i];

		for (long j=0;j<MAX_COLOR_ENTRIES;j++)
		{
			char colorBlock[256];
			sprintf(colorBlock,"Color%d",j);

			result = colorFile.readIdULong(colorBlock,table[j]);
			gosASSERT(result == NO_ERR);
		}
	}

	colorFile.close();
}	
开发者ID:,项目名称:,代码行数:46,代码来源:

示例9: init

void ForceGroupBar::init( FitIniFile& file, StaticInfo* pCoverIcon )
{

	if ( NO_ERR != file.seekBlock( "Fonts" ) )
		Assert( 0, 0, "couldn't find the font block" );

	if ( !ForceGroupIcon::gosFontHandle )
		ForceGroupIcon::gosFontHandle = new aFont;

	long fontID;
	file.readIdLong( "IconFont", fontID );
	ForceGroupIcon::gosFontHandle->init( fontID );

	
	swapResolutions();

	for ( int i = 0; i < 16; i++ )
		ForceGroupIcon::init( file, i );

	s_coverIcon = pCoverIcon;
}
开发者ID:wolfman-x,项目名称:mechcommander2,代码行数:21,代码来源:forcegroupbar.cpp

示例10: init

//---------------------------------------------------------------------------
long GateType::init (FilePtr objFile, unsigned long fileSize)
{
	long result = 0;
	
	FitIniFile bldgFile;
	result = bldgFile.open(objFile,fileSize);
	if (result != NO_ERR)
		return(result);
	
	//------------------------------------------------------------------
	// Read in the data needed for the Gates
	result = bldgFile.seekBlock("GateData");
	if (result != NO_ERR)
		return(result);

	result = bldgFile.readIdULong("DmgLevel",dmgLevel);
	if (result != NO_ERR)
		return(result);

	bldgFile.readIdULong("BlownEffectId",blownEffectId);
	if (result != NO_ERR)
		blownEffectId = -1;
		
	bldgFile.readIdULong("NormalEffectId",normalEffectId);
	if (result != NO_ERR)
		normalEffectId = -1;
		
	bldgFile.readIdULong("DamageEffectId",damageEffectId);
	if (result != NO_ERR)
		damageEffectId = -1;

	result = bldgFile.readIdLong("BasePixelOffsetX",basePixelOffsetX);
	if (result != NO_ERR)
		basePixelOffsetX = 0;
	
	result = bldgFile.readIdLong("BasePixelOffsetY",basePixelOffsetY);
	if (result != NO_ERR)	
		basePixelOffsetY = 0;

	result = bldgFile.readIdFloat("ExplosionRadius",explRad);
	if (result != NO_ERR)
		explRad = 0.0;
		
	result = bldgFile.readIdFloat("ExplosionDamage",explDmg);
	if (result != NO_ERR)
		explDmg = 0.0;

	result = bldgFile.readIdFloat("OpenRadius",openRadius);
	if (result != NO_ERR)
		return(result);

	result = bldgFile.readIdFloat("LittleExtent",littleExtent);
	if (result != NO_ERR)
		littleExtent = 20.0;

	result = bldgFile.readIdLong ("BuildingName", gateTypeName);
	if (result != NO_ERR)
		gateTypeName = IDS_BLDOBJ_NAME;

	result = bldgFile.readIdLong( "BuildingDescription", buildingDescriptionID );
	if ( result != NO_ERR )
			buildingDescriptionID = -1;


	result = bldgFile.readIdBoolean("BlocksLineOfFire",blocksLineOfFire);
	if (result != NO_ERR)
		blocksLineOfFire = FALSE;

	//------------------------------------------------------------------
	// Initialize the base object Type from the current file.
	result = ObjectType::init(&bldgFile);
	return(result);
}
开发者ID:Echelon9,项目名称:mechcommander2-open,代码行数:74,代码来源:gate.cpp

示例11: load

ObjectTypePtr ObjectTypeManager::load(ObjectTypeNumber objTypeNum, bool noCacheOut, bool forceLoad)
{
	//-----------------------------------------------------------------------
	// NOTE: This function attempts to load the objectType into the table. If
	// the object type is ALREADY loaded, it simply returns nullptr (indicating
	// it's already been loaded, so no problem). Otherwise, it returns the
	// newly loaded object type. What I'm say'n here is--this function
	// CANNOT fatal out, because any calling function will want to know
	// if the object type had to be loaded or not. However, it will fatal
	// if it's unable to load the object type from the packet file.
	//--------------------------------------------------------
	// If we are going to disk to get the object, be sure the
	// frame length knows to force itself into load mode.
	dynamicFrameTiming = false;
	if((objTypeNum < 0) || (objTypeNum >= numObjectTypes))
		Fatal(objTypeNum, " ObjectTypeManager.load: bad objTypeNum ");
	if(objTypeNum == 0)		//First Object always nullptr!
		return nullptr;
	if(!forceLoad && get(objTypeNum, false))
		return(nullptr);
	bool isMiscTerrObj = false;
	int32_t objectTypeNum = -1;
	ObjectTypePtr objType = nullptr;
	if((objTypeNum == bridgeTypeHandle) ||
			(objTypeNum == forestTypeHandle) ||
			(objTypeNum == wallHeavyTypeHandle) ||
			(objTypeNum == wallMediumTypeHandle) ||
			(objTypeNum == wallLightTypeHandle))
	{
		//----------------------------------------------------------
		// MiscTerrainObject "hack" to maintain MC1 compatibility...
		objectTypeNum = TERRAINOBJECT_TYPE;
		isMiscTerrObj = true;
	}
	else if(objectFile->seekPacket(objTypeNum) == NO_ERROR)
	{
		if(objTypeNum == 268)
		{
			gosASSERT(objTypeNum == 268);
		}
		//--------------------------------------------------------
		// All new code here.  This will ask the objectType it is
		// loading what kind of objectType it is and create it
		// based on that instead of objTypeNum.
		FitIniFile objTypeFile;
		int32_t result = objTypeFile.open(objectFile, objectFile->getPacketSize());
		if(result != NO_ERROR)
			Fatal(objTypeNum, " ObjectTypeManager.load: can't create object ");
		result = objTypeFile.seekBlock("ObjectClass");
		if(result != NO_ERROR)
			Fatal(objTypeNum, " ObjectTypeManager.load: can't create object ");
		result = objTypeFile.readIdLong("ObjectTypeNum", objectTypeNum);
		if(result != NO_ERROR)
			Fatal(objTypeNum, " ObjectTypeManager.load: can't create object ");
		objTypeFile.close();
		objectFile->seekPacket(objTypeNum);
	}
	else
		Fatal(objTypeNum, " ObjectTypeManager.load: can't create object ");
	//-----------------------------------------------------
	// Now that we know what type it is, let's create it...
	switch(objectTypeNum)
	{
		case CRAPPY_OBJECT:
			//----------------------------------------------
			// In theory we can't ever get here.
			// Because we did our jobs correctly!!
			Fatal(CANT_LOAD_INVALID_OBJECT, " ObjectTypeManager.load: can't create object ");
			break;
		case BATTLEMECH_TYPE:
		{
			objType = new BattleMechType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Mech type ");
		}
		break;
		case VEHICLE_TYPE:
		{
			objType = new GroundVehicleType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Vehicle type ");
		}
		break;
		case TREEBUILDING_TYPE:
		case BUILDING_TYPE:
		{
			objType = new BuildingType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Building type ");
		}
		break;
		case TREE_TYPE:
		{
			objType = new TerrainObjectType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init TerrainObject:Tree type ");
//.........这里部分代码省略.........
开发者ID:BobrDobr69,项目名称:mechcommander2,代码行数:101,代码来源:objtype.cpp

示例12: init

void aButton::init( FitIniFile& buttonFile, const char* str, HGOSFONT3D font )
{
	textureHandle = 0;

	long result = buttonFile.seekBlock( str );
	if ( result != NO_ERR )
	{
		char errorStr[256];
		sprintf(  errorStr, "couldn't find button %s", str );
		Assert( 0, 0, errorStr );
		return;
	}


	buttonFile.readIdLong( "ID", data.ID );
	buttonFile.readIdString("FileName", data.fileName, 32 );

	buttonFile.readIdLong( "HelpCaption", helpHeader );
	buttonFile.readIdLong( "HelpDesc", helpID );
	buttonFile.readIdLong( "TextID", data.textID );
	buttonFile.readIdLong( "TextNormal", data.textColors[0] );
	buttonFile.readIdLong( "TextPressed", data.textColors[1] );
	buttonFile.readIdLong( "TextDisabled", data.textColors[2] );
	buttonFile.readIdBoolean( "Toggle", toggleButton );
	buttonFile.readIdBoolean( "outline", data.outline );
	long fontID;
	buttonFile.readIdLong( "Font", fontID );
	if ( fontID )
		data.textFont = aFont::loadFont( fontID, data.textSize );
	else
		data.textFont = 0;


	long x, y, width, height;

	buttonFile.readIdLong( "XLocation", x );
	buttonFile.readIdLong( "YLocation", y );
		
	buttonFile.readIdLong( "Width", width );
	buttonFile.readIdLong( "Height", height );

	buttonFile.readIdLong( "HelpCaption", helpHeader );
	buttonFile.readIdLong( "HelpDesc", helpID );

	buttonFile.readIdBoolean( "texturesRotated", data.textureRotated );

	if ( NO_ERR != buttonFile.readIdLong( "Alignment", data.textAlign ) )
		data.textAlign = 2;
	
	location[0].x = location[1].x = x;
	location[0].y = location[3].y = y;
	location[2].x = location[3].x = x + width;
	location[1].y = location[2].y = y + height;

	for ( int j = 0; j < 4; j++ )
	{
		location[j].argb = 0xffffffff;
		location[j].frgb = 0;
		location[j].rhw = .5;
		location[j].u = 0.f;
		location[j].v = 0.f;
		location[j].z = 0.f;
	}
		
	
	if ( 0 == textureHandle && data.fileName && strlen( data.fileName ) )
	{
		char file[256];
		strcpy( file, artPath );
		strcat( file, data.fileName );
		_strlwr( file );
		if ( !strstr( data.fileName, ".tga" ) )
			strcat( file, ".tga" );
		
		int ID = mcTextureManager->loadTexture( file, gos_Texture_Alpha, 0, 0, 0x2 );
		int gosID = mcTextureManager->get_gosTextureHandle( ID );
		TEXTUREPTR textureData;
		gos_LockTexture( gosID, 0, 0, 	&textureData );
		gos_UnLockTexture( gosID );

		textureHandle = ID;
		data.fileWidth = textureData.Width;
		data.fileHeight = data.fileWidth;
	}

	if ( NO_ERR != buttonFile.readIdLong( "UNormal", data.stateCoords[0][0] ) )
		data.stateCoords[0][0] = -1.f;

	if ( NO_ERR != buttonFile.readIdLong( "VNormal", data.stateCoords[0][1] ) )
		data.stateCoords[0][1] = -1.f;


	if ( NO_ERR != buttonFile.readIdLong( "UPressed", data.stateCoords[1][0] ) )
		data.stateCoords[1][0] = -1.f;

	if ( NO_ERR != buttonFile.readIdLong( "VPressed", data.stateCoords[1][1] ) )
		data.stateCoords[1][1] = -1.f;

	if ( NO_ERR != buttonFile.readIdLong( "UDisabled", data.stateCoords[2][0] ) )
		data.stateCoords[2][0] = -1.f;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例13: init

int MPPrefs::init( FitIniFile& file )
{
	LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );

	for ( int i = 0; i < buttonCount; i++ )
	{
		if ( buttons[i].getID() != MP_PREFS_BASE &&
			buttons[i].getID() != MP_PREFS_STRIPE )
			buttons[i].setMessageOnRelease( );

		int id = buttons[i].getID();
		if ( id != MB_MSG_NEXT && id != MB_MSG_PREV && id != MB_MSG_MAINMENU )
		{
			buttons[i].setPressFX( LOG_VIDEOBUTTONS );
			buttons[i].setHighlightFX( LOG_DIGITALHIGHLIGHT );
			buttons[i].setDisabledFX( LOG_WRONGBUTTON );
		}
	}

	file.seekBlock( "ComboBoxes" );
	long count = 0;
	file.readIdLong( "ComboBoxCount", count );
	char blockName[256];

	const char* headers[3] = {"PlayerNameComboBox", "UnitNameComboBox", "UnitInsigniaComboBox" };
	for ( i = 0;  i< count; i++ )
	{
		sprintf( blockName, "ComboBox%ld",  i );
		file.seekBlock( blockName );
		file.readIdString( "FileName", blockName, 255);

		long tmpX;
		long tmpY;
		file.readIdLong( "XLocation", tmpX );
		file.readIdLong( "YLocation", tmpY );

		FitIniFile tmpFile;
		FullPathFileName path;
		path.init( artPath, blockName, ".fit" );
		
		if ( NO_ERR != tmpFile.open( path ) )
		{
			char error[256];
			sprintf( error, "couldn't open file %s", path );
			Assert( 0, 0, error );
			return -1;
		}

		comboBox[i].moveTo( tmpX, tmpY );

		comboBox[i].init( &tmpFile, headers[i] );
		comboBox[i].ListBox().setOrange(true );

		comboBox[0].EditBox().limitEntry( 24 );
		comboBox[1].EditBox().limitEntry( 24 );

		if ( i == 2 )
		{
			insigniaBmp.init( &tmpFile, "Static0" );
			//insigniaBmp.move( comboBox[i].globalX(), comboBox[i].globalY() );
			comboBox[i].addChild( &insigniaBmp );
		}

		comboBox[i].EditBox().allowIME( 0 );
	}


	comboBox[2].EditBox().setReadOnly(true);
	

	camera.init( rects[2].left(), rects[2].top(), rects[2].right(), rects[2].bottom() );

	status = NEXT;


	return 0;
}
开发者ID:Ariemeth,项目名称:MechCommander2HD,代码行数:77,代码来源:mpprefs.cpp

示例14: init

void LogisticsScreen::init(FitIniFile& file, PCSTR staticName, PCSTR textName, PCSTR rectName,
						   PCSTR buttonName, PCSTR editName, PCSTR animObjectName, uint32_t neverFlush)
{
	clear();
	char blockName[256];
	// init statics
	if(staticName)
	{
		sprintf(blockName, "%s%c", staticName, 's');
		if(NO_ERROR == file.seekBlock(blockName))
		{
			file.readIdLong("staticCount", staticCount);
			if(staticCount)
			{
				statics = new aObject[staticCount];
				char blockName[128];
				for(size_t i = 0; i < staticCount; i++)
				{
					sprintf(blockName, "%s%ld", staticName, i);
					statics[i].init(&file, blockName);
				}
			}
		}
	}
	if(rectName)
	{
		// init rects
		sprintf(blockName, "%s%c", rectName, 's');
		if(NO_ERROR == file.seekBlock(blockName))
		{
			file.readIdLong("rectCount", rectCount);
			if(rectCount)
			{
				rects = new aRect[rectCount];
				char blockName[128];
				for(size_t i = 0; i < rectCount; i++)
				{
					sprintf(blockName, "%s%ld", rectName, i);
					rects[i].init(&file, blockName);
				}
			}
		}
	}
	// init buttons
	if(buttonName)
	{
		sprintf(blockName, "%s%c", buttonName, 's');
		if(NO_ERROR == file.seekBlock(blockName))
		{
			file.readIdLong("buttonCount", buttonCount);
			if(buttonCount)
			{
				char blockName[128];
				buttons = new aAnimButton[buttonCount];
				for(size_t i = 0; i < buttonCount; i++)
				{
					sprintf(blockName, "%s%ld", buttonName, i);
					buttons[i].init(file, blockName);
					addChild(&buttons[i]);
				}
			}
		}
	}
	// init texts
	if(textName)
	{
		sprintf(blockName, "%s%c", textName, 's');
		if(NO_ERROR == file.seekBlock(blockName))
		{
			if(NO_ERROR != file.readIdLong("TextEntryCount", textCount))
				file.readIdLong("TextCount", textCount);
			if(textCount)
			{
				textObjects = new aText[textCount];
				char blockName[64];
				for(size_t i = 0; i < textCount; i++)
				{
					sprintf(blockName, "%s%ld", textName, i);
					textObjects[i].init(&file, blockName);
				}
			}
		}
	}
	if(editName)
	{
		sprintf(blockName, "%s%c", editName, 's');
		if(NO_ERROR == file.seekBlock(blockName))
		{
			if(NO_ERROR != file.readIdLong("EditCount", editCount))
				file.readIdLong("EditCount", editCount);
			if(editCount)
			{
				edits = new aEdit[editCount];
				char blockName[64];
				for(size_t i = 0; i < editCount; i++)
				{
					sprintf(blockName, "%s%ld", editName, i);
					edits[i].init(&file, blockName);
				}
			}
//.........这里部分代码省略.........
开发者ID:BobrDobr69,项目名称:mechcommander2,代码行数:101,代码来源:logisticsscreen.cpp

示例15: init

void StaticInfo::init( FitIniFile& file, char* blockName, long hiResOffsetX, long hiResOffsetY, DWORD neverFlush )
{
	memset( location, 0, sizeof( location ) );
	char fileName[256];
	textureHandle = 0;
	textureWidth = 0; 
	
	if ( NO_ERR != file.seekBlock( blockName ) )
	{
		char errBuffer[256];
		sprintf( errBuffer, "couldn't find static block %s", blockName );
		Assert( 0, 0, errBuffer );
		return;
	}

	long x, y, width, height;
	file.readIdLong( "XLocation", x );
	file.readIdLong( "YLocation", y );

	x += hiResOffsetX;
	y += hiResOffsetY;

	file.readIdLong( "Width", width );
	file.readIdLong( "Height", height );

	file.readIdString( "FileName", fileName, 32 );

	if ( !textureHandle )
	{
		FullPathFileName fullPath;
		_strlwr( fileName );
		fullPath.init( artPath, fileName, ".tga" );
		int ID = mcTextureManager->loadTexture( fullPath, gos_Texture_Alpha, 0, 0, 0x2 );
		textureHandle = ID;
		unsigned long gosID = mcTextureManager->get_gosTextureHandle( ID );
		TEXTUREPTR textureData;
		gos_LockTexture( gosID, 0, 0, 	&textureData );
		textureWidth = textureData.Width;
		gos_UnLockTexture( gosID );
	}

	bool bRotated = 0;

	file.readIdLong( "UNormal", u );
	file.readIdLong( "VNormal", v );
	file.readIdLong( "UWidth", uWidth );
	file.readIdLong( "VHeight", vHeight );
	file.readIdBoolean( "texturesRotated", bRotated );

	for ( int k = 0; k < 4; k++ )
	{
		location[k].argb = 0xffffffff;
		location[k].frgb = 0;
		location[k].x = x;
		location[k].y = y;
		location[k].z = 0.f;
		location[k].rhw = .5;
		location[k].u = (float)u/(float)textureWidth + (.1f / (float)textureWidth);
		location[k].v = (float)v/(float)textureWidth + (.1f / (float)textureWidth);
	}

	location[3].x = location[2].x = x + width;
	location[2].y = location[1].y = y + height;

	location[2].u = location[3].u = ((float)(u + uWidth))/((float)textureWidth) + (.1f / (float)textureWidth);
	location[1].v = location[2].v = ((float)(v + vHeight))/((float)textureWidth) + (.1f / (float)textureWidth);

	if ( bRotated )
	{

		location[0].u = (u + uWidth)/(float)textureWidth + (.1f / (float)textureWidth);;
		location[1].u = u/(float)textureWidth + (.1f / (float)textureWidth);;
		location[2].u = u/(float)textureWidth + (.1f / (float)textureWidth);
		location[3].u = (u + uWidth)/(float)textureWidth + (.1f / (float)textureWidth);

		location[0].v = v/(float)textureWidth + (.1f / (float)textureWidth);;
		location[1].v = v/(float)textureWidth + (.1f / (float)textureWidth);;
		location[2].v = (v + vHeight)/(float)textureWidth + (.1f / (float)textureWidth);;
		location[3].v = (v + vHeight)/(float)textureWidth + (.1f / (float)textureWidth);;
	}

}
开发者ID:wolfman-x,项目名称:mechcommander2,代码行数:82,代码来源:utilities.cpp


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