예제 #1
0
void CMissionDialog::OnMiPurchaseFileBrowseButton() {
	UpdateData(TRUE);
	while (true) {
		CFileDialog selectFileDialog(TRUE,_T("FIT"),_T("*.FIT"),
						 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_NOCHANGEDIR,
						 _T("FIT File (*.FIT)|*.FIT|"));
		selectFileDialog.m_ofn.lpstrInitialDir = missionPath;
		if( selectFileDialog.DoModal()==IDOK ) {
			CString purchasePath = selectFileDialog.GetPathName();
			FitIniFile file;
			long result = 0;
			result = file.open( (char*)(const char*)purchasePath );
			if (NO_ERR != result) {
				AfxMessageBox(IDS_COULDNT_OPEN_PURCHASE_FILE);
			} else {
				long result = 0;
				result = file.seekBlock("Mechs");
				if (NO_ERR != result)
				{
					AfxMessageBox(IDS_NOT_A_VALID_PURCHASE_FILE);
				}
				file.close();
			}
			m_PurchaseFileEdit = selectFileDialog.GetFileTitle();
			break;
		} else {
			break;
		}
	}
	UpdateData(FALSE);
}
예제 #2
0
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" );
	}
}
예제 #3
0
void LogisticsSaveDialog::updateCampaignMissionInfo()
{

	FitIniFile file;
	FullPathFileName path;
	path.init( campaignPath, selectedName, ".fit" );
	if ( NO_ERR != file.open( path ) )
	{
		Assert( 0, 0, "coudln't find the campaign file\n" );
	}

	char fileName[256];

	if ( NO_ERR == file.seekBlock( "Group0Mission0" ) )
	{
		if ( NO_ERR != file.readIdString( "FileName", fileName, 1023 ) )
		{				
			setMission( "" );
		}		
		else
		{
			setMission( fileName );
		}
	}	
	else
		setMission( "" );

}
예제 #4
0
bool CCampaignData::Read(CString pathName) {
	FitIniFile fitFile;
	int result = fitFile.open(pathName.GetBuffer(0));
	if (NO_ERR != result) { assert(false); return false; }

	result = fitFile.seekBlock("Campaign");
	if (NO_ERR != result) { assert(false); }
	result = sReadIdString(fitFile, "CampaignName", m_Name);
	if (NO_ERR == result) { m_NameUseResourceString = false; }
	result = sReadIdInteger(fitFile, "NameID", m_NameResourceStringID);
	if (NO_ERR == result) { m_NameUseResourceString = true; }
	result = sReadIdBoolean(fitFile, "NameUseResourceString", m_NameUseResourceString);
	result = sReadIdInteger(fitFile, "CBills", m_CBills);
	result = sReadIdString(fitFile, "FinalVideo", m_FinalVideo);
	int groupCount = 0;
	result = sReadIdInteger(fitFile, "GroupCount", groupCount);
	if (NO_ERR != result) { return false; }

	int index;
	for (index = 0; groupCount > index; index+=1) {
		ECharString blockName;
		blockName.Format("Group%d", index);
		result = fitFile.seekBlock(blockName.Data());
		if (NO_ERR != result) { assert(false); continue; }
		CGroupData groupData;
		bool bresult = groupData.Read(fitFile, blockName.Data());
		if (true != bresult) { assert(false); continue; }
		m_GroupList.Append(groupData);
	}

	fitFile.close();
	return true;
}
예제 #5
0
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;
}
예제 #6
0
long LightType::init (FilePtr objFile, unsigned long fileSize) {

	long result = 0;
	
	FitIniFile explFile;
	result = explFile.open(objFile,fileSize);
	if (result != NO_ERR)
		return(result);

	result = explFile.seekBlock("LightData");
	if (result != NO_ERR)
		return result;

	result = explFile.readIdBoolean("OneShotFlag",oneShotFlag);
	if (result != NO_ERR)
		return result;

	result = explFile.readIdFloat("AltitudeOffset",altitudeOffset);
	if (result != NO_ERR)
		return result;

	//------------------------------------------------------------------
	// Initialize the base object Type from the current file.
	result = ObjectType::init(&explFile);
	return(result);
}
int	LogisticsMechDisplay::init( )
{
	FitIniFile file;
	FullPathFileName path;
	path.init( artPath, "mcl_mechinfo", ".fit" );
	if ( NO_ERR !=  file.open( path ) )
	{
		Assert( 0, 0, "Couldn't open mcl_mechinfo.fit" );
		return 0;
	}

	LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );
	
	mechCamera.init( rects[1].left(), rects[2].top(),
			rects[2].left(), rects[2].bottom() );

	char blockName[64];
	for ( int i = 0; i < 3; i++ )
	{
		sprintf( blockName, "AttributeMeter%ld", i );
		attributeMeters[i].init( &file, blockName );
	}

	
	componentListBox.init( rects[0].left(), rects[0].top(),
		rects[0].width(), rects[0].height() );


	return 1;


}
예제 #8
0
void HotKeyListItem::init()
{
	if ( s_item )
		return;

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

	s_item->description.init( &file, "Text0" );
	s_item->text.init( &file, "Text1" );

	s_item->animations[0].init( &file, "Animation0" );
	s_item->animations[1].init( &file, "Animation1" );
	s_item->animations[2].init( &file, "Animation2" );

	s_item->rects[0].init( &file, "Rect0" );
	s_item->rects[1].init( &file, "Rect1" );
}
예제 #9
0
void MPGameBrowser::init(FitIniFile* file)
{
	LogisticsScreen::init( *file, "Static", "Text", "Rect", "Button" );

	if ( buttonCount )
	{
		for ( int i = 0; i < buttonCount; i++ )
		{
			buttons[i].setMessageOnRelease();
			if (buttons[i].getID() == 0)
			{
				buttons[i].setID(FIRST_BUTTON_ID + i);
				buttons[i].setPressFX( LOG_VIDEOBUTTONS );
				buttons[i].setHighlightFX( LOG_DIGITALHIGHLIGHT );
				buttons[i].setDisabledFX( LOG_WRONGBUTTON );
			}
		}
	}


	{
		char path[256];
		strcpy( path, artPath );
		strcat( path, "mcl_mp_lanbrowsercombobox0.fit" );
		
		FitIniFile PNfile;
		if ( NO_ERR != PNfile.open( path ) )
		{
			char error[256];
			sprintf( error, "couldn't open file %s", path );
			Assert( 0, 0, error );
			return;
		}
		
		PNfile.seekBlock("GameList"); /*for some reason aListBox::init(...) doesn't do the seekBlock itself*/
		gameList.init(&PNfile, "GameList");

		gameList.SelectItem(0);
		gameList.init( rects[0].left(), rects[0].top(), rects[0].width(), rects[0].height() );
		gameList.setOrange( true );

		templateItem.init(&PNfile, "GameListItem");

		for ( int i = 0; i < 256; i++ )
		{
			items[i] = templateItem;
		}

	}


	hostDlg.init();
}
예제 #10
0
void LogisticsSaveDialog::setMission( const char* fileName)
{
	if ( strlen( fileName ) )
	{

		long textureHandle = MissionBriefingScreen::getMissionTGA( fileName );

		statics[MAP_STATIC].setTexture( textureHandle );
		statics[MAP_STATIC].setUVs( 0, 127, 127, 0);
		statics[MAP_STATIC].setColor( 0xffffffff );

		FullPathFileName path;
		FitIniFile file;

		path.init( missionPath, fileName, ".fit" );

		if ( NO_ERR == file.open( path ) )
		{
			char missionName[256];
			missionName[0] = 0;
			bool bRes = 0;

			file.seekBlock( "MissionSettings" );
			file.readIdBoolean( "MissionNameUseResourceString", bRes );
			if ( bRes )
			{
				unsigned long lRes;
				file.readIdULong( "MissionNameResourceStringID", lRes );
				cLoadString(lRes, missionName, 255);
			}
			else
			{
				file.readIdString("MissionName", missionName, 255);
			}

			textObjects[2].setText(missionName);

		}
		else
		{
			textObjects[2].setText( "" );
		}

	}
	else
	{
		statics[MAP_STATIC].setColor( 0 );
		textObjects[2].setText( "" );

	}

}
int	LogisticsMechDisplay::init( )
{
	FitIniFile file;
	FullPathFileName path;
	//path.init( artPath, "mcl_mechinfo", ".fit" );
	/*//magic 16092011 begin
	if ( Environment.screenWidth == 800 ) 
		path.init( artPath, "mcl_mechinfo", ".fit" );
	if ( Environment.screenWidth == 1280 )
		path.init( artPath, "mcl_mechinfo_1280x1024", ".fit" );
	if ( Environment.screenWidth == 1440 )
		path.init( artPath, "mcl_mechinfo_1440x900", ".fit" );
	//magic 16092011 end*/
	//magic 26092011 begin
	if ( Environment.screenWidth == 1280 )
		path.init( artPath, "mcl_mechinfo_1280x1024", ".fit" );
	else if ( Environment.screenWidth == 1440 )
		path.init( artPath, "mcl_mechinfo_1440x900", ".fit" );
	else
		path.init( artPath, "mcl_mechinfo", ".fit" );

	//magic 26092011 end
	if ( NO_ERR !=  file.open( path ) )
	{
		Assert( 0, 0, "Couldn't open mcl_mechinfo.fit" );
		return 0;
	}

	LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );
	
	mechCamera.init( rects[1].left(), rects[2].top(),
			rects[2].left(), rects[2].bottom() );

	char blockName[64];
	for ( int i = 0; i < 3; i++ )
	{
		sprintf( blockName, "AttributeMeter%ld", i );
		attributeMeters[i].init( &file, blockName );
	}

	
	componentListBox.init( rects[0].left(), rects[0].top(),
		rects[0].width(), rects[0].height() );


	return 1;


}
예제 #12
0
void SplashIntro::init()
{
	FullPathFileName path;
	path.init( artPath, "mcl_splashscreenintro", ".fit" );

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

	LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );
}
예제 #13
0
long mcScrollBar::init ( long xPos, long yPos, long w, long h  )	
{

	FitIniFile file; 
	char path[256];
	strcpy( path, artPath );
	strcat( path, "scrollbar.fit" );
	if ( NO_ERR != file.open( path ) )
	{
		char error[256];
		sprintf( error, "couldn't open file %s", path );
		Assert( 0, 0, error );
	}

	setColor( 0, 0 ); // black background

	color = 0xff002F55; // outline color

	topButton.init( file, "ScrollButton0" );
	
	
	bottomButton.init( file, "ScrollButton1" );
	bottomButton.moveTo( bottomButton.x(), h - bottomButton.height() - 2 );
	
	
	scrollTab.init( file, "ScrollButton2" );
	scrollTab.moveTo( scrollTab.x(), topButton.bottom() + 1 );

	file.seekBlock( "Orange" );
	orangeInfo[0].init( &file, "Normal" );
	orangeInfo[1].init( &file, "Highlight" );
	orangeInfo[2].init( &file, "Pressed" );
	orangeInfo[3].init( &file, "Disabled" );
	
	file.seekBlock( "Green" );
	greenInfo[0].init( &file, "Normal" );
	greenInfo[1].init( &file, "Highlight" );
	greenInfo[2].init( &file, "Pressed" );
	greenInfo[3].init( &file, "Disabled" );
	
	aScrollBar::init( xPos, yPos, w, h );

	scrollTab.setTexture( (unsigned long)0 );

	return 0;

}
예제 #14
0
//----------------------------------------------------------------------------------
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();
}	
예제 #15
0
void MPDirectTcpip::init(FitIniFile* file)
{
	LogisticsScreen::init( *file, "Static", "Text", "Rect", "Button" );

	if ( buttonCount )
	{
		for ( int i = 0; i < buttonCount; i++ )
		{
			if (buttons[i].getID() == 0)
			{
				buttons[i].setID(FIRST_BUTTON_ID + i);
			}
		}
	}


	{
		char path[256];
		strcpy( path, artPath );
		strcat( path, "mcl_mp_tcpip_combobox0.fit" );
		
		FitIniFile PNfile;
		if ( NO_ERR != PNfile.open( path ) )
		{
			char error[256];
			sprintf( error, "couldn't open file %s", path );
			Assert( 0, 0, error );
			return;
		}
		ipAddressComboBox.init(&PNfile, "TCIPNumberComboBox");

		aStyle7TextListItem *pTmp2;
		int i;
		for (i = 0; i < 15; i += 1)
		{
			pTmp2 = new aStyle7TextListItem;
			EString tmpStr;
			tmpStr.Format("Text0");
			pTmp2->init(&PNfile, tmpStr.Data());
			ipAddressComboBox.AddItem(pTmp2);
		}
		ipAddressComboBox.SelectItem(0);
	}
}
예제 #16
0
void MPLoadMap::init(FitIniFile* file)
{
	LogisticsScreen::init( *file, "Static", "Text", "Rect", "Button" );

	if ( buttonCount )
	{
		for ( int i = 0; i < buttonCount; i++ )
		{
			buttons[i].setMessageOnRelease();
			if (buttons[i].getID() == 0)
			{
				buttons[i].setID(FIRST_BUTTON_ID + i);
			}
		}
	}

	file->seekBlock( "EnterAnim" );
	enterAnim.init( file, "" );
	file->seekBlock( "LeaveAnim" );
	exitAnim.init( file, "" );



	{
		char path[256];
		strcpy( path, artPath );
		strcat( path, "mcl_mp_loadmap_list0.fit" );
		
		FitIniFile PNfile;
		if ( NO_ERR != PNfile.open( path ) )
		{
			char error[256];
			sprintf( error, "couldn't open file %s", path );
			Assert( 0, 0, error );
			return;
		}
		PNfile.seekBlock("MapList"); /*for some reason aListBox::init(...) doesn't do the seekBlock itself*/
		mapList.init(&PNfile, "MapList");
		templateItem.init( &PNfile, "Text0" );
	
	}

	mapList.setOrange( true );
}
예제 #17
0
int32_t LogisticsMapInfoDialog::init()
{
	FitIniFile file;
	FullPathFileName path;
	path.init(artPath, "mcl_mp_mapinfo", ".fit");
	if (NO_ERROR != file.open(path))
	{
		char buffer2[512];
		sprintf(buffer2, "couldn't open file %s", (PSTR)path);
		Assert(0, 0, buffer2);
		return false;
	}
	LogisticsScreen::init(file, "Static", "Text", "Rect", "Button", "Edit");
	file.seekBlock("InAnim");
	enterAnim.init(&file, "");
	file.seekBlock("OutAnim");
	exitAnim.init(&file, "");
	return 1;
}
void OptionsScreenWrapper::begin()
{
	isActive = true;
	if (!pOptionsScreen)
	{
		pOptionsScreen = new OptionsXScreen();
		char path[256];
		strcpy(path, artPath);
		strcat(path, "mcl_options.fit");
		FitIniFile file;
		if (NO_ERROR != file.open(path))
		{
			char error[256];
			sprintf(error, "couldn't open file %s", path);
			Assert(0, 0, error);
			return;
		}
		pOptionsScreen->init(&file);
	}
}
예제 #19
0
int MechListBox::init()
{
	if ( MechListBoxItem::s_templateItem )
		return 0;


	char path[256];
	strcpy( path, artPath );
	strcat( path, "mcl_gn_availablemechentry.fit" );
	FitIniFile file;
	if ( NO_ERR != file.open( path ) )
	{
		char errorStr[256];
		sprintf( errorStr, "couldn't open file %s", path );
		Assert( 0, 0, errorStr );
		return -1;
	}

	MechListBoxItem::init( file );
	
	return 0;
}
예제 #20
0
void MPLoadMap::getMapNameFromFile( const char* pFileName, char* missionName, long bufferLength )
{
	FullPathFileName path;
	path.init( missionPath, pFileName, ".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( "MissionSettings" );
	Assert( result == NO_ERR, 0, "Coudln't find the mission settings block in the mission file" );

	missionName[0] = 0;
	bool bRes = 0;

	result = file.readIdBoolean( "MissionNameUseResourceString", bRes );
	//Assert( result == NO_ERR, 0, "couldn't find the MissionNameUseResourceString" );
	if ( bRes )
	{
		unsigned long lRes;
		result = file.readIdULong( "MissionNameResourceStringID", lRes );
		Assert( result == NO_ERR, 0, "couldn't find the MissionNameResourceStringID" );
		cLoadString( lRes, missionName, bufferLength );
	}
	else
	{
		result = file.readIdString( "MissionName", missionName, bufferLength );
		Assert( result == NO_ERR, 0, "couldn't find the missionName" );
	}
}
예제 #21
0
//---------------------------------------------------------------------------
long SoundSystem::init (char *soundFileName)
{
	if (useSound)
	{
		FullPathFileName soundName;
		soundName.init(soundPath,soundFileName,".snd");
		
		FitIniFile soundFile;
		long result = soundFile.open(soundName);
		gosASSERT(result == NO_ERR);

		result = soundFile.seekBlock("SoundSetup");
		gosASSERT(result == NO_ERR);

		result = soundFile.readIdULong("soundHeapSize",soundHeapSize);
		gosASSERT(result == NO_ERR);
		
		result = soundFile.readIdFloat("MaxSoundDistance",maxSoundDistance);
		gosASSERT(result == NO_ERR);

		soundHeap = new UserHeap;
		gosASSERT(soundHeap != NULL);

		result = soundHeap->init(soundHeapSize,"SOUND");
		gosASSERT(result == NO_ERR);

		//-----------------------------------------------------------------------
		// Startup the Sound packet File with the sound Blocks in it.
		// This works by sound ID.  The sound ID is the packet number.
		// When ordered to play a sample, the sound system check to see if that
		// sound ID is in the cache.  If not, it is loaded.  If there is no more
		// room, any idle sounds are flushed in order of priority.
		soundDataFile = new PacketFile;
		gosASSERT(soundDataFile != NULL);
		
		FullPathFileName soundDataPath;
		soundDataPath.init(CDsoundPath,soundFileName,".pak");
		
		result = soundDataFile->open(soundDataPath);
		gosASSERT(result == NO_ERR);
		
		bettyDataFile = new PacketFile;
		gosASSERT(bettyDataFile != NULL);
		
		FullPathFileName bettyDataPath;
		bettyDataPath.init(CDsoundPath,"Betty",".pak");
		
		result = bettyDataFile->open(bettyDataPath);
		gosASSERT(result == NO_ERR);

		numBettySamples = bettyDataFile->getNumPackets();
		
		supportDataFile = new PacketFile;
		gosASSERT(supportDataFile != NULL);
		
		FullPathFileName supportDataPath;
		supportDataPath.init(CDsoundPath,"support",".pak");
		
		result = supportDataFile->open(supportDataPath);
		gosASSERT(result == NO_ERR);

		numSupportSamples = supportDataFile->getNumPackets();
 		//-----------------------------------------------------------------------
		// Load all of the sound Bite data.  Do not load actual packet unless
		// preload field is TRUE.
		result = soundFile.seekBlock("SoundBites");
		gosASSERT(result == NO_ERR);

		result = soundFile.readIdULong("numBites",numSoundBites);
		gosASSERT(result == NO_ERR);

		//-----------------------------------------------------------------------
		// Preallocate SoundBites
		sounds = (SoundBite *)soundHeap->Malloc(sizeof(SoundBite) * numSoundBites);
		gosASSERT(sounds != NULL);
		memset(sounds,0,sizeof(SoundBite) * numSoundBites);
		
		for (long i=0;i<(long)numSoundBites;i++)
		{
			char biteBlock[20];
			sprintf(biteBlock,"SoundBite%d",i);
			
			result = soundFile.seekBlock(biteBlock);
			gosASSERT(result == NO_ERR);
			
			result = soundFile.readIdULong("priority",sounds[i].priority);
			gosASSERT(result == NO_ERR);
			
			result = soundFile.readIdULong("cache",sounds[i].cacheStatus);
			gosASSERT(result == NO_ERR);
			
			result = soundFile.readIdULong("soundId",sounds[i].soundId);
			gosASSERT(result == NO_ERR);
			
			preloadSoundBite(i);		//ALWAYS Preload!!!!!!!!!!!!!

			result = soundFile.readIdFloat("volume",sounds[i].volume);
			gosASSERT(result == NO_ERR);
		}		

		//---------------------------------------------------------------
		// Load the digital Music Data Strings
		result = soundFile.seekBlock("DigitalMusic");
		gosASSERT(result == NO_ERR);
			
		result = soundFile.readIdLong("NumDMS",numDMS);
		gosASSERT(result == NO_ERR);

		result = soundFile.readIdFloat("StreamFadeDownTime",streamFadeDownTime);
		gosASSERT(result == NO_ERR);

		result = soundFile.readIdULong("StreamBitDepth",digitalStreamBitDepth);
		gosASSERT(result == NO_ERR);
			
		result = soundFile.readIdULong("StreamChannels",digitalStreamChannels);
		gosASSERT(result == NO_ERR);

		digitalMusicIds = (char **)soundHeap->Malloc(sizeof(char *) * numDMS);
		gosASSERT(digitalMusicIds != NULL);
			
		digitalMusicLoopFlags = (bool *)soundHeap->Malloc(sizeof(bool)*numDMS);
		gosASSERT(digitalMusicLoopFlags != NULL);

		digitalMusicVolume = (float *)soundHeap->Malloc(sizeof(float) * numDMS);
			
		for (i=0;i<numDMS;i++)
		{
			char digitalMSId[20];
			sprintf(digitalMSId,"DMS%d",i);
			
			char digitalMSBId[20];
			sprintf(digitalMSBId,"DMSLoop%d",i);

			char digitalMSVId[25];
			sprintf(digitalMSVId,"DMSVolume%d",i);
			
			digitalMusicIds[i] = (char *)soundHeap->Malloc(30);
			result = soundFile.readIdString(digitalMSId,digitalMusicIds[i],29);
			gosASSERT(result == NO_ERR);
			
			result = soundFile.readIdBoolean(digitalMSBId,digitalMusicLoopFlags[i]);
			gosASSERT(result == NO_ERR);

			result = soundFile.readIdFloat(digitalMSVId,digitalMusicVolume[i]);
			if (result != NO_ERR)
				digitalMusicVolume[i] = 1.0f;
		}	
		
		soundFile.close();
		
		for (i=0;i<MAX_DIGITAL_SAMPLES+4;i++)
		{
			gosAudio_AllocateChannelSliders(i,gosAudio_Volume | gosAudio_Panning);
		}
	}
	
	digitalMasterVolume = float(DigitalMasterVolume) / 256.0f;
	SFXVolume = float(sfxVolume) / 256.0f;
	musicVolume = float(MusicVolume) / 256.0f;
	radioVolume = float(RadioVolume) / 256.0f;
	bettyVolume = float(BettyVolume) / 256.0f;

	stream1Id = stream2Id = 0;

	return(NO_ERR);
}
예제 #22
0
//-----------------------------
int32_t convertASE2TGL(PSTR file)
{
	//---------------------------------------------------
	// Get all of the .ASE files in the tgl directory.
	char findString[1024];
	char armFileName[1024];
	if (file[0] == '\0')
	{
		sprintf(findString, "%s*.ini", tglPath);
	}
	else
	{
		strcpy(findString, tglPath);
		strcat(findString, file);
	}
	int32_t count = 0;
	WIN32_FIND_DATA findResult;
	HANDLE searchHandle = FindFirstFile(findString, &findResult);
	do
	{
		if ((findResult.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
		{
			//-----------------------------------
			// Search for TGLData
			FullPathFileName iniName;
			iniName.init(tglPath, findResult.cFileName, "");
			FitIniFile iniFile;
			int32_t result = iniFile.open(iniName);
			if (result != NO_ERROR)
				return result;
			// ARM
			IProviderAssetPtr iniAsset =
				armProvider->OpenAsset((PSTR)iniName, AssetType_Physical, ProviderType_Primary);
			iniAsset->AddProperty("Type", "Object Definition");
			iniAsset->AddProperty("Version", "1.0");
			TG_TypeMultiShape* shape = nullptr;
			result					 = iniFile.seekBlock("TGLData");
			if (result == NO_ERROR)
			{
				char fileName[1024];
				result = iniFile.readIdString("FileName", fileName, 1023);
				if (result != NO_ERROR)
				{
					//---------------------------------------------
					// We have LODs -- handle differently
					// We will get animation from LAST LOD loaded
					int32_t i = 0;
					char fileCheck[1024];
					sprintf(fileCheck, "FileName%d", i);
					result = iniFile.readIdString(fileCheck, fileName, 1023);
					while (result == NO_ERROR)
					{
						if (shape)
						{
							delete shape;
							shape = nullptr;
						}
						char aseName[1024];
						sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
						//---------------------------------------------------------------------------------------------
						// Load Base Shape or LOD 0 Shape.
						shape = new TG_TypeMultiShape;
						gosASSERT(shape != nullptr);
						printf("Processing Main Shape %s\n", aseName);
						char lodID[4];
						sprintf(lodID, "%02d", count);
						IProviderRelationshipPtr armLink =
							iniAsset->AddRelationship("LOD Shape", aseName);
						armLink->AddProperty("LOD", lodID);
						shape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
						i++;
						sprintf(fileCheck, "FileName%d", i);
						result = iniFile.readIdString(fileCheck, fileName, 1023);
					}
				}
				char aseName[1024];
				sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
				//---------------------------------------------------------------------------------------------
				// Load Base Shape or LOD 0 Shape.
				shape = new TG_TypeMultiShape;
				gosASSERT(shape != nullptr);
				printf("Processing Main Shape %s\n", aseName);
				IProviderRelationshipPtr armLink = iniAsset->AddRelationship("Main Shape", aseName);
				shape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
				//-------------------------------------------
				// Gotta make the special shadow shape now!!
				// MUST use its own shape or animation below
				// will go straight to HELL!!
				result = iniFile.readIdString("ShadowName", fileName, 1023);
				if (result == NO_ERROR)
				{
					char aseName[1024];
					sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
					//---------------------------------------------------------------------------------------------
					// Load Base Shape or LOD 0 Shape.
					TG_TypeMultiShapePtr shadowShape = new TG_TypeMultiShape;
					gosASSERT(shadowShape != nullptr);
					printf("Processing Shadow Shape %s\n", aseName);
					IProviderRelationshipPtr armLink =
						iniAsset->AddRelationship("Shadow Shape", aseName);
					shadowShape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
					delete shadowShape;
					shadowShape = nullptr;
				}
				int32_t i = 0;
				char animCheck[1024];
				sprintf(animCheck, "Animation:%d", i);
				result = iniFile.seekBlock(animCheck);
				while (result == NO_ERROR) // This thing has animations. Process them!
				{
					char fileName[1024];
					result = iniFile.readIdString("AnimationName", fileName, 1023);
					if (result == NO_ERROR)
					{
						FullPathFileName aseName;
						aseName.init(tglPath, fileName, ".ase");
						TG_AnimateShape* anim = new TG_AnimateShape;
						gosASSERT(mechAnim != nullptr);
						//-----------------------------------------------
						// Skip this one if its already a binary file.
						// Happens ALOT!
						printf("Processing Animation %s\n", aseName);
						IProviderRelationshipPtr armLink =
							iniAsset->AddRelationship("Animation", (PSTR)aseName);
						anim->LoadTGMultiShapeAnimationFromASE(aseName, shape, true);
						delete anim;
						anim = nullptr;
					}
					i++;
					sprintf(animCheck, "Animation:%d", i);
					result = iniFile.seekBlock(animCheck);
				}
				if (!i) // No Animations, BUT they may mean we are a MECH!!!
				{
					if (iniFile.seekBlock("Gestures0") == NO_ERROR)
					{
						// We ARE a mech. Load all of the animations for this
						// mech and write 'em out.
						for (size_t i = 0; i < MaxGestures; i++)
						{
							char name[MAX_PATH];
							_splitpath(findResult.cFileName, nullptr, nullptr, name, nullptr);
							char mechFileName[1024];
							sprintf(
								mechFileName, "%s%s%s.ase", tglPath, name, MechAnimationNames[i]);
							TG_AnimateShape* anim = new TG_AnimateShape;
							gosASSERT(anim != nullptr);
							//-----------------------------------------------
							// Skip this one if its already a binary file.
							// Happens ALOT!
							printf("Processing Animation %s\n", mechFileName);
							IProviderRelationshipPtr armLink =
								iniAsset->AddRelationship("Animation", mechFileName);
							anim->LoadTGMultiShapeAnimationFromASE(mechFileName, shape, true);
							delete anim;
							anim = nullptr;
						}
					}
				}
				if (!i) // No Animations, BUT they may mean we are a MECH!!!
				{
					if (iniFile.seekBlock("Gestures0") == NO_ERROR)
					{
						// We ARE a mech. Load all of the destroyed shapes for
						// this mech and write 'em out.
						for (size_t i = MaxGestures; i < MaxGestures + 2; i++)
						{
							char name[MAX_PATH];
							_splitpath(findResult.cFileName, nullptr, nullptr, name, nullptr);
							char mechFileName[1024];
							sprintf(
								mechFileName, "%s%s%s.ase", tglPath, name, MechAnimationNames[i]);
							//-----------------------------------------------
							shape = new TG_TypeMultiShape;
							gosASSERT(shape != nullptr);
							printf("Processing Animation %s\n", mechFileName);
							IProviderRelationshipPtr armLink =
								iniAsset->AddRelationship("Destroyed Shape", mechFileName);
							shape->LoadTGMultiShapeFromASE(mechFileName, true, armProvider);
							delete shape;
							shape = nullptr;
						}
					}
				}
				if (iniFile.seekBlock("TGLDamage") == NO_ERROR)
				{
					char fileName[1024];
					result = iniFile.readIdString("FileName", fileName, 1023);
					if (result == NO_ERROR)
					{
						if (shape)
						{
							delete shape;
							shape = nullptr;
						}
						char aseName[1024];
						sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
						//---------------------------------------------------------------------------------------------
						// Load Base Shape or LOD 0 Shape.
						shape = new TG_TypeMultiShape;
						gosASSERT(shape != nullptr);
						printf("Processing Damage Shape %s\n", aseName);
						IProviderRelationshipPtr armLink =
							iniAsset->AddRelationship("Damage Shape", aseName);
						shape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
					}
					//-------------------------------------------
					// Gotta make the special shadow shape now!!
					// MUST use its own shape or animation below
					// will go straight to HELL!!
					result = iniFile.readIdString("ShadowName", fileName, 1023);
					if (result == NO_ERROR)
					{
						char aseName[1024];
						sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
						//---------------------------------------------------------------------------------------------
						// Load Base Shape or LOD 0 Shape.
						TG_TypeMultiShapePtr shadowShape = new TG_TypeMultiShape;
						gosASSERT(shadowShape != nullptr);
						printf("Processing Damage Shadow Shape %s\n", aseName);
						IProviderRelationshipPtr armLink =
							iniAsset->AddRelationship("Damage Shadow Shape", aseName);
						shadowShape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
						delete shadowShape;
						shadowShape = nullptr;
					}
				}
			}
			delete shape;
			shape = nullptr;
			iniAsset->Close();
		}
	} while (FindNextFile(searchHandle, &findResult) != 0);
	FindClose(searchHandle);
	return 0;
}
예제 #23
0
void MPHostGame::init()
{
	FullPathFileName path;
	FitIniFile file;
	path.init(artPath, "mcl_mp_hostgamedialog", ".fit");
	if (NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	LogisticsScreen::init(file, "Static", "Text", "Rect", "Button");
	file.seekBlock("InAnim");
	enterAnim.init(&file, "");
	file.seekBlock("OutAnim");
	exitAnim.init(&file, "");
	if (buttonCount)
	{
		for (size_t i = 0; i < buttonCount; i++)
		{
			buttons[i].setMessageOnRelease();
			if (buttons[i].getID() == 0)
			{
				buttons[i].setID(FIRST_BUTTON_ID + i);
			}
		}
	}
	edits[0].limitEntry(24);
	edits[0].allowIME(false);
	/*	int32_t tmpX, tmpY;
		file.seekBlock( "ComboBox0" );
		file.readIdLong( "XLocation", tmpX );
		file.readIdLong( "YLocation", tmpY );


		char tmpStr[256];
		file.readIdString( "FileName", tmpStr, 255 );
		{
			FullPathFileName tmpPath;
			tmpPath.init( artPath, tmpStr, ".fit" );

			FitIniFile PNfile;
			if ( NO_ERROR != PNfile.open( tmpPath ) )
			{
				char error[256];
				sprintf( error, "couldn't open file %s", (PSTR)tmpPath );
				Assert( 0, 0, error );
				return;
			}
			numPlayersDropList.init( &PNfile, "ComboBox0");

			aStyle5TextListItem *pTmp2;
			int32_t i;
			for (i = 2; i < MAX_MC_PLAYERS+1; i += 1)
			{
				pTmp2 = new aStyle5TextListItem;
				pTmp2->init(&PNfile, "Text0");
				char txt[32];
				sprintf( txt, "%ld", i );
				pTmp2->setText( txt );
				pTmp2->sizeToText();
				pTmp2->resize( numPlayersDropList.width() -
	   numPlayersDropList.ListBox().getScrollBarWidth() + 5, pTmp2->height() );
				numPlayersDropList.AddItem(pTmp2);
			}
			numPlayersDropList.SelectItem(0);
		}

		numPlayersDropList.moveTo( tmpX, tmpY );
		numPlayersDropList.ListBox().setOrange( true );
		numPlayersDropList.EditBox().limitEntry( 1 );
		numPlayersDropList.EditBox().setNumeric( 1 );
		numPlayersDropList.setReadOnly( 0 );*/
}
void MissionBriefingScreen::begin()
{
	missionListBox.removeAllItems( true );

	runTime = 0;
	bClicked = 0;

	statics[VIDEO_SCREEN].setColor( 0 );

	memset( objectiveButtons, 0, sizeof ( aObject* ) * MAX_OBJECTIVES );
	// need to set up all pertinent mission info
	EString missionName = LogisticsData::instance->getCurrentMission();


	long tmpMapTextureHandle = getMissionTGA(missionName);
	statics[MAP_INDEX].setTexture( tmpMapTextureHandle );
	statics[MAP_INDEX].setUVs( 0, 127, 127, 0 );
	statics[MAP_INDEX].setColor( 0xffffffff );


	// need to get all the objectives and stuff
	FullPathFileName fitPath;
	fitPath.init(missionPath, missionName, ".fit");
	FitIniFile fitFile;
	fitFile.open( fitPath );

	// put initial divider in list box
	addItem(IDS_MN_DIVIDER, 0xff005392, -1);

	fitFile.seekBlock( "MissionSettings" );

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

	bool bRes;
	result = fitFile.readIdBoolean( "MissionNameUseResourceString", bRes );
	Assert( result == NO_ERR, 0, "couldn't find the MissionNameUseResourceString" );
	if ( bRes )
	{
		unsigned long ulRes;
		result = fitFile.readIdULong( "MissionNameResourceStringID", ulRes );
		Assert( result == NO_ERR, 0, "couldn't find the MissionNameResourceStringID" );
		addItem(ulRes, 0xff005392, -1);
	}
	else
	{
		char missionName[256];
		fitFile.readIdString("MissionName", missionName, 255);
		addLBItem(missionName, 0xff005392, -1);

	}

	addItem(IDS_MN_DIVIDER, 0xff005392, -1);
	addItem( IDS_MN_MISSION_OBJECTIVES, 0xff005392, -1 );
	addItem(IDS_MN_DIVIDER, 0xff005392, -1);

	// put in primary objectives
	fitFile.seekBlock( "Team0Objectives" );
	unsigned long objectiveCount;
	fitFile.readIdULong( "NumObjectives", objectiveCount );
	bool bHasSecondary = 0;
	int count = 0; 

	fitFile.seekBlock( "Terrain" );
	float terrainExtentX;
	float terrainExtentY;
	fitFile.readIdFloat( "TerrainMinX", terrainExtentX );
	if ( !terrainExtentX )
		terrainExtentX = 120 * 128;
	fitFile.readIdFloat( "TerrainMinY", terrainExtentY );
	if ( !terrainExtentY )
		terrainExtentY = 120 * 128;

	CObjectives Objectives(0/*alignment*/);
	/*Note that ObjectManager is probably NULL as these objectives are read, so it's not
	cool to call any of the Status() functions of this instance of objectives (access violation
	may ensue).*/
	Objectives.Read(&fitFile);

	gosASSERT( Objectives.Count() < MAX_OBJECTIVES );

	int buttonCount = 0;

	for ( int j = 1; j < 3; j++ )
	{
		CObjectives::EIterator it = Objectives.Begin();
		buttonCount = 0;
		for ( int i = 0; i < Objectives.Count(); i++, it++ )
		{
			CObjective *pObjective = (*it);
			if ( (!pObjective->IsHiddenTrigger()) && (pObjective->IsActive()) )
			{
				
				if ( pObjective->Priority() == j )
				{
					addObjectiveButton( pObjective->MarkerX(), pObjective->MarkerY(), buttonCount,pObjective->Priority(), fabs(terrainExtentX),
									fabs(terrainExtentY), pObjective->DisplayMarker());

					if ( j == 0 )
					{
						bHasSecondary = true;
						if ( i == 0 )
							addItem( IDS_MN_DIVIDER, 0xff005392, -1 );
					}

					addLBItem( (pObjective->LocalizedDescription()).Data(), 0xffffffff, count );

					objectiveModels[count] = (pObjective->ModelName()).Data();
					modelTypes[count] = pObjective->ModelType();

					modelColors[count][0] = pObjective->ModelBaseColor();
					modelColors[count][1] = pObjective->ModelHighlightColor();
					modelColors[count][2] = pObjective->ModelHighlightColor2();
					modelScales[count] = pObjective->ModelScale();

					count++;
					buttonCount++;
				}
			}
		}
	}
	
	addItem( IDS_MN_DIVIDER, 0xff005392, -1 );

	fitFile.seekBlock( "MissionSettings" );

	char blurb[4096];
	result = fitFile.readIdString("Blurb", blurb, 4095 );

	bool tmpBool = false;
	result = fitFile.readIdBoolean("BlurbUseResourceString", tmpBool);
	if (NO_ERR == result && tmpBool )
	{
		unsigned long tmpInt = 0;
		result = fitFile.readIdULong("BlurbResourceStringID", tmpInt);
		if (NO_ERR == result)
		{
			cLoadString( tmpInt, blurb, 2047 );
		}
	}


	addLBItem( blurb, 0xff005392, -1 );

	int RP = LogisticsData::instance->getCBills();
	char text[32];
	sprintf( text, "%ld ", RP );
	textObjects[RP_INDEX].setText( text );

	// need to find a drop zone, because our designers were never convinced to place
	// 'em explicitly, we need to do it for them
	int i = 1;
	while( true )
	{
		char blockName[32];
		sprintf( blockName, "Part%ld", i );
		i++;
		if ( NO_ERR != fitFile.seekBlock( blockName ) )
			break;
		
		bool bPlayer = 0;
		fitFile.readIdBoolean( "PlayerPart", bPlayer );

		if ( bPlayer )
		{
			float fX;
			float fY;

			fitFile.readIdFloat( "PositionX", fX );
			fitFile.readIdFloat( "PositionY", fY );

			setupDropZone( fX, fY, fabs(terrainExtentX), fabs(terrainExtentY) );
		
			break;
		}
	}

	statics[BUTTON_TEXT].showGUIWindow( 0 );
	status = RUNNING;

}
예제 #25
0
//---------------------------------------------------------------------------
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);
}
예제 #26
0
long GateType::init (FilePtr objFile, unsigned long fileSize, const char* builName)
{
	long result = 0;
	//magic 24022011 begin
	//char tmp1[16]; //magic 29112011 disabled
	//sprintf( tmp1, "%ld", objFile ); //magic 29112011 disabled
	//char tmp2[256];
	//FitIniFile MtestFile;
	//MtestFile.open("data\\vehicle_load.fit", CREATE);
	//MtestFile.writeBlock( tmp1 );
	//MtestFile.writeBlock( vehicleName );
	//MtestFile.close();
	FitIniFile bldgFile;
	FitIniFile objTypeFile;
	
	result = objTypeFile.open(objFile, fileSize);
	if (result != NO_ERR)
	{
		FullPathFileName mFullFileName;
		mFullFileName.init(objectPath, builName, ".fit");
		//FitIniFile objTypeFile;
		//MtestFile.writeBlock( mFullFileName );
		//MtestFile.close();

		long result1 = bldgFile.open(mFullFileName);
		if (result1 != NO_ERR)
		{
			Fatal(objTypeNum, " BuildingType.init1: can't open building file ");
		}
	}
	else
		bldgFile.open(objFile, fileSize);

	objTypeFile.close();

	//magic 24022011 end	
	/*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;

	//magic 09092011 begin
	char s[255];
	result = bldgFile.readIdString("Name",s,254); //magic 09092011
	strcpy_s(buildingName, s);//magic 09092011

	//magic 09092011 end

	//------------------------------------------------------------------
	// Initialize the base object Type from the current file.
	result = ObjectType::init(&bldgFile);
	return(result);
}
예제 #27
0
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;
}
예제 #28
0
int MainMenu::init( FitIniFile& file )
{
	file.seekBlock("Tunes");
	file.readIdLong("TuneId",tuneId);

	LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );

	FullPathFileName name;
	name.init( artPath, "mcl_sp", ".fit" );
	FitIniFile file2;
	if ( NO_ERR != file2.open( name ) )
	{
		char errorStr[256];
		sprintf( errorStr, "couldn't open file %s", (char*)name );
		Assert(0,0,errorStr );
	}

	background.init( file2, "Static", "Text", "Rect", "Button" );

	for ( int i = 0; i < buttonCount; i++ )
	{
		buttons[i].setMessageOnRelease();
		buttons[i].setPressFX(LOG_VIDEOBUTTONS);
		buttons[i].setHighlightFX(LOG_DIGITALHIGHLIGHT);
	}

	beginAnim.initWithBlockName( &file, "InAnim" );
	endAnim.initWithBlockName( &file, "OutAnim" );


	intro.init();

	FullPathFileName path;
	path.init( artPath, "mcl_mp_loadmap", ".fit" );

	FitIniFile mpFile;

	if ( NO_ERR != mpFile.open( path ) )
	{
		char error[256];
		sprintf( error, "couldn't open file %s", path );
		Assert( 0, 0, error );
		return -1;		
	}

	singleLoadDlg.init( &mpFile );

	introMovie = 0;

	path.init( moviePath, "msft", ".bik" );

	RECT movieRect;
	movieRect.top = 0;
	movieRect.left = 0;
	movieRect.right = Environment.screenWidth;
	movieRect.bottom = Environment.screenHeight;

	introMovie = new MC2Movie;
	introMovie->init(path,movieRect,true);

	return 0;
}
예제 #29
0
void MainMenu::update()
{

	if ( bDrawBackground || MPlayer || LogisticsData::instance->isSingleMission() )
	{
		getButton( MM_MSG_SAVE )->disable( true );
	}
	else
		getButton( MM_MSG_SAVE )->disable( false );

	getButton( MM_MSG_MULTIPLAYER )->disable( true );

	if ( introMovie )
	{
		userInput->mouseOff();

		if (userInput->getKeyDown(KEY_SPACE) || userInput->getKeyDown(KEY_ESCAPE) || userInput->getKeyDown(KEY_LMOUSE))
		{
			introMovie->stop();
		}

		bool result = introMovie->update();
		if (result)
		{
			
			//Movie's Over.
			//Whack it.
			delete introMovie;
			introMovie = NULL;
		}

		return;
	}

	if (!musicStarted)
	{
		musicStarted = true;
		soundSystem->setMusicVolume( prefs.MusicVolume );
		soundSystem->playDigitalMusic(tuneId);
	}

	if ( endAnim.isDone() )
	{
		status = endResult;
	}

	if ( bDrawMechlopedia )
	{
		mechlopedia->update();
		if ( mechlopedia->getStatus() == NEXT )
		{
			beginFadeIn( 0 );
			bDrawMechlopedia = 0;
			if ( !bDrawBackground )
				status = NEXT;
		}
		return;
	}

	if ( bOptions )
	{
		OptionsScreenWrapper::status_type result = optionsScreenWrapper->update();
		if (result == OptionsScreenWrapper::opt_DONE)
		{
			optionsScreenWrapper->end();
			bOptions = 0;
		}

		return;
	}

	if ( (bSave || bLoad || bLoadCampaign) && endAnim.isDone() )
	{
		LogisticsSaveDialog::instance()->update();

		if ( LogisticsSaveDialog::instance()->getStatus() == LogisticsScreen::YES 
			&& LogisticsSaveDialog::instance()->isDone() )
		{
			
			char name[1024];
			strcpy( name, savePath );
			strcat( name, LogisticsSaveDialog::instance()->getFileName() );
			int index = strlen( name ) - 4;
			if ( _stricmp( &name[index], ".fit" ) !=0 ) 
				strcat( name, ".fit" );

			
			FitIniFile file;
			if ( bSave )
			{
				// make sure the save game directory exists, if not create it
				CreateDirectory( savePath, NULL );

				if ( NO_ERR != file.createWithCase( name ) )
				{
					char errorStr[1024];
					sprintf( errorStr, "couldn't open the file %s", name );
					Assert( 0, 0, errorStr );
				}
				else
				{
					LogisticsData::instance->save( file );
					LogisticsSaveDialog::instance()->end();
					file.close();
				}
				bSave = bLoad = 0;
				status = NEXT;
				

			}
			else if ( bLoadCampaign )
			{
				LogisticsData::instance->startNewCampaign( LogisticsSaveDialog::instance()->getFileName());
				status = endResult = RESTART;
//				background.beginFadeOut( 1.0f );
//				beginFadeOut( 1.0f );
				bLoadCampaign = 0;
			}
			else
			{
				if ( NO_ERR != file.open( name ) )
				{
					char errorStr[1024];
					sprintf( errorStr, "couldn't open the file %s", name );
					Assert( 0, 0, errorStr );
				}
				else
					LogisticsData::instance->load( file );
				LogisticsSaveDialog::instance()->end();
				bSave = bLoad = 0;
				status = RESTART;
				file.close();

			}
		}
		else if ( LogisticsSaveDialog::instance()->getStatus() == LogisticsScreen::NO &&
			LogisticsSaveDialog::instance()->isDone())
		{
			LogisticsSaveDialog::instance()->end();
			bSave = bLoad = bLoadCampaign = 0 ;
			if ( !bDrawBackground )
				status = NEXT;
			else
			{
				beginAnim.begin();
				endAnim.end();
			}
		}
		return;
	}
	else if ( bLoadSingle && endAnim.isDone())
	{
		singleLoadDlg.update();
		if ( singleLoadDlg.isDone() )
		{
			if ( singleLoadDlg.getStatus() == YES )
			{
				const char* pName = singleLoadDlg.getMapFileName();
				if (pName)
				{
					LogisticsData::instance->setSingleMission( pName );
					status = SKIPONENEXT;
				}
			}

			bLoadSingle = 0;
			beginAnim.begin();
			endAnim.end();
		}
	}

	else if ( promptToQuit )
	{
		LogisticsOKDialog::instance()->update();
		{
			if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::YES )
			{
				soundSystem->playDigitalSample( LOG_EXITGAME );
				gos_TerminateApplication();
				promptToQuit = 0;

			}
			else if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::NO)
			{
				if ( LogisticsOKDialog::instance()->isDone() )
					promptToQuit = 0;
			}

			

		}
	}
	else if ( bLegal )
	{
		LogisticsLegalDialog::instance()->update();
		if ( LogisticsLegalDialog::instance()->isDone() )
		{
			LogisticsLegalDialog::instance()->end();
			bLegal = 0;
		}
	}
	else if ( bHostLeftDlg )
	{
		LogisticsOneButtonDialog::instance()->update();
		if ( LogisticsOneButtonDialog::instance()->isDone() )
		{
			LogisticsOneButtonDialog::instance()->end();
			bHostLeftDlg = 0;
		}

		if ( MPlayer ) // has to be done, but can't be done when initialized
		{
			MPlayer->closeSession();
			delete MPlayer;
			MPlayer = NULL;
		}
	}
	else if ( promptToDisconnect )
	{
		LogisticsOKDialog::instance()->update();
		if ( LogisticsOKDialog::instance()->isDone() )
		{
			if ( YES == LogisticsOKDialog::instance()->getStatus() )
			{
				if ( MPlayer )
				{
					MPlayer->closeSession();
					delete MPlayer;
					MPlayer = NULL;
				}
				long oldRes = endResult;
				endResult = 0;

				handleMessage( oldRes, oldRes );

				setDrawBackground( true );
			}
			else
				handleMessage( NEXT, NEXT );
			
			promptToDisconnect = 0;
		}
	}
	else
	{
		if ( bDrawBackground  )
		{
			if ( !intro.animObjects[0].isDone() )
			{
				intro.update();
				background.update();
				if (userInput->getKeyDown(KEY_ESCAPE) || (Environment.Renderer == 3))
				{
					introOver = true;
					userInput->mouseOn();
					soundSystem->playDigitalSample( LOG_MAINMENUBUTTON );

				}
				else if ( !introOver )
					return;
			}
			else
			{
				background.update();
				if ( !introOver )
					soundSystem->playDigitalSample( LOG_MAINMENUBUTTON );

				introOver = true;
				userInput->mouseOn();

			}
		}

		beginAnim.update();
		endAnim.update();

		LogisticsScreen::update();
		if ( (!bLoadSingle) && userInput->isLeftClick() && !inside( userInput->getMouseX(), userInput->getMouseY() ) )
		{
			handleMessage( 0, MM_MSG_RETURN_TO_GAME );
		}
	}
}
예제 #30
0
int	MainMenu::handleMessage( unsigned long what, unsigned long who )
{
	switch ( who )
	{
		case MM_MSG_NEW_CAMPAIGN:
			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = MM_MSG_NEW_CAMPAIGN;
				promptToDisconnect = true;
			}
			else
			{
				endAnim.begin();
				beginAnim.end();
				bLoadCampaign = true;
				LogisticsSaveDialog::instance()->beginCampaign();
				if ( LogisticsSaveDialog::instance()->isDone() )
				{
					LogisticsData::instance->startNewCampaign( LogisticsSaveDialog::instance()->getFileName());
					status = RESTART;
				}
			}
			break;
		case MM_MSG_SAVE:
			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = who;
				promptToDisconnect = true;
			}
			else
			{
		
				// need to pop dialog here
				LogisticsSaveDialog::instance()->begin();
				endAnim.begin();
				beginAnim.end();
				bSave = true;
			}
			break;

		case MM_MSG_LOAD:

			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = who;
				promptToDisconnect = true;
			}
			else
			{
			
				// need to pop dialog here
				LogisticsSaveDialog::instance()->beginLoad();
				endAnim.begin();
				beginAnim.end();
				bLoad = true;
			}
			break;
		case MM_MSG_MULTIPLAYER:
			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = who;
				promptToDisconnect = true;
			}
			else
			{
				endAnim.begin();
				beginAnim.end();
				endResult = MULTIPLAYERRESTART;
				LogisticsData::instance->startMultiPlayer();
			}
			break;

		case MM_MSG_RETURN_TO_GAME:
			{
			if ( !bDrawBackground )
			{
				endAnim.begin();
				beginAnim.end();
				endResult = NEXT;
				soundSystem->playDigitalSample( LOG_MAINMENUBUTTON );
				soundSystem->playDigitalMusic(LogisticsData::instance->getCurrentMissionTune());
			}
			}
			break;
		case MM_MSG_OPTIONS:
			// need to throw up the options screen here...
			if (!optionsScreenWrapper)
			{
				optionsScreenWrapper = new OptionsScreenWrapper;
				optionsScreenWrapper->init();
			}
			optionsScreenWrapper->begin();

			bOptions = true;
			break;
		case MM_MSG_ENCYCLOPEDIA:
			bDrawMechlopedia = true;
			beginFadeOut(1.0);
			if ( !mechlopedia )
			{
				mechlopedia = new Mechlopedia;
				mechlopedia->init();
			}

			mechlopedia->begin();
			break;
		case MM_MSG_EXIT:
			promptToQuit = 1;
			// may need to set the text here
			LogisticsOKDialog::instance()->setText( IDS_DIALOG_QUIT_PROMPT,
					IDS_DIALOG_NO, IDS_DIALOG_YES );
				
			LogisticsOKDialog::instance()->begin();
			getButton( who )->press( 0 );
			break;

		case MM_MSG_SINGLE_MISSION:

			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = who;
				promptToDisconnect = true;
			}
			else
			{
				bLoadSingle = true;
				endAnim.begin();
				beginAnim.end();
				singleLoadDlg.beginSingleMission();
				getButton( who )->press( 0 );
			}
			break;

		case MM_MSG_LEGAL:
			{
				bLegal = 1;
				// may need to set the text here
				if ( !LogisticsLegalDialog::instance() )
				{
					FullPathFileName path;
					path.init( artPath, "mcl_dialoglegal", ".fit" );
					FitIniFile file;
					file.open( path );
					LogisticsLegalDialog::init( file );
				}
				LogisticsLegalDialog::instance()->setText( IDS_DIALOG_OK,
						IDS_DIALOG_OK, IDS_DIALOG_OK );
				//Needs to be this long for LOC!
				// -fs
				char realText[2048];
				cLoadString(IDS_LAWYER_BABBLE, realText, 2047 );
				char lawyerBabble[2048];
				unsigned long pIDLen = 64;
				char pID[64];
				sprintf( pID, "INVALID ID" );
				gos_LoadDataFromRegistry("PID", pID, &pIDLen);
				sprintf( lawyerBabble, realText, pID );
				LogisticsLegalDialog::instance()->setText( lawyerBabble );
				LogisticsLegalDialog::instance()->begin();
				LogisticsLegalDialog::instance()->setFont( IDS_LAWYER_BABBLE_FONT );				
				getButton( who )->press( 0 );
			}
			break;
		default:
			break;
	}

	return 0;
}