Esempio n. 1
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;
}
Esempio n. 2
0
bool CCampaignData::Save(CString pathName)
{
	FitIniFile fitFile;
	int32_t result = fitFile.create(pathName.GetBuffer(0));
	if(result != NO_ERROR)
	{
		return false;
	}
	fitFile.writeBlock("Campaign");
	fitFile.writeIdBoolean("NameUseResourceString", m_NameUseResourceString);
	if(!m_NameUseResourceString)
	{
		fitFile.writeIdString("CampaignName", m_Name.GetBuffer(0));
	}
	else
	{
		fitFile.writeIdLong("NameID", m_NameResourceStringID);
	}
	fitFile.writeIdLong("CBills", m_CBills);
	fitFile.writeIdString("FinalVideo", m_FinalVideo.GetBuffer(0));
	fitFile.writeIdLong("GroupCount", m_GroupList.Count());
	CGroupList::EIterator it;
	int32_t index;
	for(it = m_GroupList.Begin(), index = 0; !it.IsDone(); it++, index += 1)
	{
		ECharString blockName;
		blockName.Format("Group%d", index);
		fitFile.writeBlock(blockName.Data());
		(*it).Save(fitFile, blockName.Data());
	}
	fitFile.close();
	return true;
}
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);
}
Esempio n. 4
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();
}	
Esempio n. 5
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);
}
Esempio n. 6
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);
}
Esempio n. 7
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 );
		}
	}
}
Esempio n. 8
0
void OptionsGraphics::init(long xOffset, long yOffset)
{
	FullPathFileName path;
	path.init( artPath, "mcl_options_combobox0", ".fit" );
	FitIniFile file;
	if ( NO_ERR !=file.open( path ) )
	{
		char error[256];
		sprintf( error, "couldn't open file %s", path );
		Assert( 0, 0, error );
		return;	
	}

	getButton( MSG_RESET )->setMessageOnRelease();

	resolutionList.init( &file, "PlayerNameComboBox" );
	resolutionList.move( globalX(), globalY() );
	resolutionList.move( xOffset, yOffset );
	resolutionList.ListBox().setOrange( true );

	for ( int i = IDS_RESOLUTION0; i < IDS_RESOLUTION9 + 1; i++ )
	{
		if ( 1!=gos_GetMachineInformation( gos_Info_ValidMode, 
			Environment.FullScreenDevice, 
			resModes[i-IDS_RESOLUTION0].xRes, 
			resModes[i-IDS_RESOLUTION0].yRes,
			resModes[i-IDS_RESOLUTION0].bitDepth) )
		{
			availableMode[i-IDS_RESOLUTION0] = false;
		}
		else
		{
			char cstr[256];
			cLoadString (i, cstr, 255 );
			resolutionList.AddItem( cstr, 0xffffffff );
		}
	}

	file.close();

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

	getButton( MSG_RESET )->setMessageOnRelease();

	cardList.init( &file, "PlayerNameComboBox" );
	cardList.move( globalX(), globalY() );
	cardList.move( xOffset, yOffset );
	cardList.ListBox().setOrange( true );

	DWORD numDevices = 0;
	numDevices = gos_GetMachineInformation( gos_Info_NumberDevices );

	//Theoretically impossible but config would probably like to know if it happens!
	if (numDevices <= 0)
		STOP(("GameOS said there were no video cards in the system!"));

	long usableCardCount = 0;
	for (i=0;i<numDevices;i++)
	{
		DWORD minTextureRam = 6291456;

		//If we are a Voodoo 2, we may be a 4/8 or a 4/4.  Try allowing a 4/4 to run
		// and see what happens!!  NO good has come of this!
		/*
		if ((gos_GetMachineInformation(gos_Info_GetDeviceVendorID,i) == 0x121a) &&
			(gos_GetMachineInformation(gos_Info_GetDeviceDeviceID,i) == 0x0002))
			minTextureRam = 4096000;
		*/

		if (gos_GetMachineInformation(gos_Info_GetDeviceLocalMemory, i) >= minTextureRam)
		{
			char *deviceName = (char*)gos_GetMachineInformation( gos_Info_GetDeviceName, i);
		
			//Save name to other string here.
			cardList.AddItem( deviceName, 0xffffffff );

			if ( Environment.FullScreenDevice == i )
				cardList.SelectItem( usableCardCount );

			usableCardCount++;
		}
	}

//ALL of this is a lie.  Code is now correct but I would ignore this.
// Sorry Heidi!
// -fs

//Turns out, its the same for both.

//Environment.Renderer tells you what device you are currently using as follows:
//	If the value is 0 or 1 you are using the default device or the primary display adapter (One and the same always)
//	If the value is 2 you are using the second video card.
//	If the value is 3 you are using BLADE software renderer.

//If you set the values to any of the above, you will switch to that device.


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


	move( xOffset, yOffset );

	helpTextArrayID = 1;



	
}
Esempio n. 9
0
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 ");
		}
		break;
		case TERRAINOBJECT_TYPE:
		{
			objType = new TerrainObjectType;
			objType->setObjTypeNum(objTypeNum);
			if(isMiscTerrObj)
				((TerrainObjectTypePtr)objType)->initMiscTerrObj(objTypeNum);
			else if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init TerrainObject type ");
		}
		break;
		case WEAPONBOLT_TYPE:
		{
			objType = new WeaponBoltType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init WeaponBolt type ");
		}
		break;
		case TURRET_TYPE:
		{
			objType = new TurretType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Turret type ");
		}
		break;
		case EXPLOSION_TYPE:
		{
			objType = new ExplosionType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Explosion type ");
		}
		break;
		case FIRE_TYPE:
		{
			objType = new FireType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Fire type ");
		}
		break;
		case GATE_TYPE:
		{
			objType = new GateType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Gate type ");
		}
		break;
		case ARTILLERY_TYPE:
		{
			objType = new ArtilleryType;
			objType->setObjTypeNum(objTypeNum);
			if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR)
				Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Artillery type ");
		}
		break;
		default:
			//return(nullptr);
			//Fatal(OBJECT_TYPE_NUMBER_UNDEFINED, " ObjectTypeManager.load: undefined objType ");
			NODEFAULT;
	}
	if(noCacheOut)
	{
		//---------------------------------------------------
		// Do NOT EVER cache this object type out.  FXs, etc.
		// This means I'm preloading it!!
		objType->makeLovable();
		if(objType->getExplosionObject() > 0)
			load(objType->getExplosionObject());
	}
	table[objTypeNum] = objType;
	return(objType);
}
Esempio n. 10
0
void MPLoadMap::seedFromCampaign()
{
		char searchStr[255];
		cLoadString( IDS_AUTOSAVE_NAME, searchStr, 255 );
		EString finalStr;
		finalStr =  "*.fit";
		FullPathFileName findPath;
		findPath.init( savePath, finalStr, ".fit" );

		EString newestFile;
		long	groupCount = -1;
		long	missionCount = -1;
		FitIniFile tmpFile;

		WIN32_FIND_DATA	findResult;
		HANDLE searchHandle = FindFirstFile(findPath,&findResult); 
		 if ( searchHandle != INVALID_HANDLE_VALUE )
		 {
			do
			{
				if ((findResult.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
				{
					FullPathFileName path;
					path.init( savePath, findResult.cFileName, ".fit" );
 					tmpFile.open( path  );

					 if ( NO_ERR == tmpFile.seekBlock( "General" ) )
					 {
						 long group, missions;

						tmpFile.readIdLong( "Group ", group );
						if ( group > groupCount )
						{
							groupCount = group;
							tmpFile.readIdLong( "CompletedMissions", missions );
							missionCount = missions;
							newestFile = findResult.cFileName;
						}
						else if ( group == groupCount )
						{
							tmpFile.readIdLong( "CompletedMissions", missions );
							if ( missions > missionCount )
								missionCount = missions;
							newestFile = findResult.cFileName;
						}
					 }

					tmpFile.close();


				}
			} while (FindNextFile(searchHandle,&findResult) != 0);
		 }

		 FindClose(searchHandle);

		 if ( newestFile.Length() )
		 {
			 findPath.init( savePath, newestFile, ".fit" );
			 FitIniFile file;
			 long group;
			 long missions;
			 char campaignFileName[256];
			 campaignFileName[0] = 0;
			 if ( NO_ERR == file.open( findPath ) )
			 {
				 if ( NO_ERR == file.seekBlock( "General" ) )
				 {
					file.readIdLong( "Group ", group );
					file.readIdLong( "CompletedMissions", missions );
					file.readIdString( "CampaignFile", campaignFileName, 255 );
				 }
			 }

			 if ( strlen( campaignFileName ) && ( group || missions ) )
			 {
				FitIniFile campaignFile;
				if ( NO_ERR == campaignFile.open( campaignFileName ) )
				{
					for ( int i = 0; i < group+1; i++ )
					{
						char blockName[64];
						sprintf( blockName,  "Group%ld", i );
						if ( NO_ERR == campaignFile.seekBlock( blockName ) )
						{
							long count = missions;
							if ( i < group )
							{
								campaignFile.readIdLong( "MissionCount", count );
							}

							for ( int j = 0; j < count; j++ )
							{
								sprintf( blockName, "Group%ldMission%ld", i, j );
								if ( NO_ERR == campaignFile.seekBlock( blockName ) )
								{
									char tmpFileName[255];
									campaignFile.readIdString( "FileName", tmpFileName, 255 );

									aLocalizedListItem* pEntry = new aLocalizedListItem();
									*pEntry = templateItem;
									pEntry->resize( mapList.width() - mapList.getScrollBarWidth() - 20, pEntry->height());
									pEntry->setHiddenText( tmpFileName );
									char displayName[256];
									getMapNameFromFile( tmpFileName, displayName, 255 );
									pEntry->setText( displayName );
									pEntry->sizeToText();
									mapList.AddItem( pEntry );
								}
							}
						}
					}
				}
			 }
		 }
}
Esempio n. 11
0
//---------------------------------------------------------------------------
void __stdcall InitializeGameEngine()
{
	gosResourceHandle = gos_OpenResourceDLL("mc2res.dll");
	char temp[256];
	cLoadString(IDS_FLOAT_HELP_FONT, temp, 255);
	PSTR pStr = strstr(temp, ",");
	if(pStr)
	{
		gosFontScale = atoi(pStr + 2);
		*pStr = 0;
	}
	char path [256];
	strcpy(path, "assets\\graphics\\");
	strcat(path, temp);
	gosFontHandle = gos_LoadFont(path);
	//-------------------------------------------------------------
	// Find the CDPath in the registry and save it off so I can
	// look in CD Install Path for files.
	//Changed for the shared source release, just set to current directory
	//uint32_t maxPathLength = 1023;
	//gos_LoadDataFromRegistry("CDPath", CDInstallPath, &maxPathLength);
	//if (!maxPathLength)
	// strcpy(CDInstallPath,"..\\");
	strcpy(CDInstallPath, ".\\");
	cLoadString(IDS_MC2_FILEMISSING, FileMissingString, 511);
	cLoadString(IDS_MC2_CDMISSING, CDMissingString, 1023);
	cLoadString(IDS_MC2_MISSING_TITLE, MissingTitleString, 255);
	//--------------------------------------------------------------
	// Start the SystemHeap and globalHeapList
	globalHeapList = new HeapList;
	gosASSERT(globalHeapList != nullptr);
	globalHeapList->init();
	globalHeapList->update(); //Run Instrumentation into GOS Debugger Screen
	systemHeap = new UserHeap;
	gosASSERT(systemHeap != nullptr);
	systemHeap->init(systemHeapSize, "SYSTEM");
	float doubleClickThreshold = 0.2f;
	int32_t dragThreshold = .016667;
	//--------------------------------------------------------------
	// Read in System.CFG
	FitIniFile systemFile;
#ifdef _DEBUG
	int32_t systemOpenResult =
#endif
		systemFile.open("system.cfg");
#ifdef _DEBUG
	if(systemOpenResult != NO_ERROR)
	{
		char Buffer[256];
		gos_GetCurrentPath(Buffer, 256);
		STOP(("Cannot find \"system.cfg\" file in %s", Buffer));
	}
#endif
	{
#ifdef _DEBUG
		int32_t systemBlockResult =
#endif
			systemFile.seekBlock("systemHeap");
		gosASSERT(systemBlockResult == NO_ERROR);
		{
			int32_t result = systemFile.readIdULong("systemHeapSize", systemHeapSize);
			result;
			gosASSERT(result == NO_ERROR);
		}
#ifdef _DEBUG
		int32_t systemPathResult =
#endif
			systemFile.seekBlock("systemPaths");
		gosASSERT(systemPathResult == NO_ERROR);
		{
			int32_t result = systemFile.readIdString("terrainPath", terrainPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("artPath", artPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("fontPath", fontPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("savePath", savePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("spritePath", spritePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("shapesPath", shapesPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("soundPath", soundPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("objectPath", objectPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("cameraPath", cameraPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("tilePath", tilePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("missionPath", missionPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("warriorPath", warriorPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("profilePath", profilePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("interfacepath", interfacePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("moviepath", moviePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("CDsoundPath", CDsoundPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("CDmoviepath", CDmoviePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("tglPath", tglPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("texturePath", texturePath, 79);
			gosASSERT(result == NO_ERROR);
		}
#ifdef _DEBUG
		int32_t fastFileResult =
#endif
			systemFile.seekBlock("FastFiles");
		gosASSERT(fastFileResult == NO_ERROR);
		{
			int32_t result = systemFile.readIdLong("NumFastFiles", maxFastFiles);
			if(result != NO_ERROR)
				maxFastFiles = 0;
			if(maxFastFiles)
			{
				fastFiles = (FastFile**)malloc(maxFastFiles * sizeof(FastFile*));
				memset(fastFiles, 0, maxFastFiles * sizeof(FastFile*));
				int32_t fileNum = 0;
				char fastFileId[10];
				char fileName[100];
				sprintf(fastFileId, "File%d", fileNum);
				while(systemFile.readIdString(fastFileId, fileName, 99) == NO_ERROR)
				{
					bool result = FastFileInit(fileName);
					if(!result)
						STOP(("Unable to startup fastfiles. Probably an old one in the directory!!"));
					fileNum++;
					sprintf(fastFileId, "File%d", fileNum);
				}
			}
		}
	}
	systemFile.close();
	//--------------------------------------------------------------
	// Read in Prefs.cfg
	bool fullScreen = false;
	FitIniFilePtr prefs = new FitIniFile;
#ifdef _DEBUG
	int32_t prefsOpenResult =
#endif
		prefs->open("prefs.cfg");
	gosASSERT(prefsOpenResult == NO_ERROR);
	{
#ifdef _DEBUG
		int32_t prefsBlockResult =
#endif
			prefs->seekBlock("MechCommander2");
		gosASSERT(prefsBlockResult == NO_ERROR);
		{
			int32_t filterSetting;
			int32_t result = prefs->readIdLong("FilterState", filterSetting);
			if(result == NO_ERROR)
			{
				switch(filterSetting)
				{
					default:
					case 0:
						FilterState = gos_FilterNone;
						break;
					case 1:
						FilterState = gos_FilterBiLinear;
						break;
					case 2:
						FilterState = gos_FilterTriLinear;
						break;
				}
			}
			result = prefs->readIdLong("TerrainTextureRes", TERRAIN_TXM_SIZE);
			if(result != NO_ERROR)
				TERRAIN_TXM_SIZE = 64;
			result = prefs->readIdLong("ObjectTextureRes", ObjectTextureSize);
			if(result != NO_ERROR)
				ObjectTextureSize = 128;
			result = prefs->readIdLong("Brightness", gammaLevel);
			if(result != NO_ERROR)
				gammaLevel = 0;
			// store volume settings in global variable since soundsystem
			// does not exist yet. These will be set in SoundSystem::init()
			result = prefs->readIdLong("DigitalMasterVolume", DigitalMasterVolume);
			if(result != NO_ERROR)
				DigitalMasterVolume = 255;
			result = prefs->readIdLong("MusicVolume", MusicVolume);
			if(result != NO_ERROR)
				MusicVolume = 64;
			result = prefs->readIdLong("RadioVolume", RadioVolume);
			if(result != NO_ERROR)
				RadioVolume = 64;
			result = prefs->readIdLong("SFXVolume", sfxVolume);
			if(result != NO_ERROR)
				sfxVolume = 64;
			result = prefs->readIdFloat("DoubleClickThreshold", doubleClickThreshold);
			if(result != NO_ERROR)
				doubleClickThreshold = 0.2f;
			result = prefs->readIdLong("DragThreshold", dragThreshold);
			if(result != NO_ERROR)
				dragThreshold = .016667;
			result = prefs->readIdULong("BaseVertexColor", BaseVertexColor);
			if(result != NO_ERROR)
				BaseVertexColor = 0x00000000;
			result = prefs->readIdBoolean("FullScreen", fullScreen);
			if(result != NO_ERROR)
				fullScreen = true;
			result = prefs->readIdLong("Rasterizer", renderer);
			if(result != NO_ERROR)
				renderer = 0;
			if((renderer < 0) || (renderer > 3))
				renderer = 0;
		}
	}
	prefs->close();
	delete prefs;
	prefs = nullptr;
	//-------------------------------
	// Used to output debug stuff!
	// Mondo COOL!
	// simply do this in the code and stuff goes to the file called mc2.output
	// DEBUG_STREAM << thing_you_want_to_output
	//
	// IMPORTANT NOTE:
	Stuff::InitializeClasses();
	MidLevelRenderer::InitializeClasses(8192 * 4, 1024, 0, 0, true);
	gosFX::InitializeClasses();
	gos_PushCurrentHeap(MidLevelRenderer::Heap);
	MidLevelRenderer::TGAFilePool* pool = new MidLevelRenderer::TGAFilePool("data\\Effects\\");
	MidLevelRenderer::MLRTexturePool::Instance = new MidLevelRenderer::MLRTexturePool(pool);
	MidLevelRenderer::MLRSortByOrder* cameraSorter = new MidLevelRenderer::MLRSortByOrder(MidLevelRenderer::MLRTexturePool::Instance);
	theClipper = new MidLevelRenderer::MLRClipper(0, cameraSorter);
	gos_PopCurrentHeap();
	//------------------------------------------------------
	// Start the GOS FX.
	gos_PushCurrentHeap(gosFX::Heap);
	gosFX::EffectLibrary::Instance = new gosFX::EffectLibrary();
	Check_Object(gosFX::EffectLibrary::Instance);
	FullPathFileName effectsName;
	effectsName.init(effectsPath, "mc2.fx", "");
	File effectFile;
	int32_t result = effectFile.open(effectsName);
	if(result != NO_ERROR)
		STOP(("Could not find MC2.fx"));
	int32_t effectsSize = effectFile.fileSize();
	puint8_t effectsData = (puint8_t)systemHeap->Malloc(effectsSize);
	effectFile.read(effectsData, effectsSize);
	effectFile.close();
	effectStream = new Stuff::MemoryStream(effectsData, effectsSize);
	gosFX::EffectLibrary::Instance->Load(effectStream);
	gosFX::LightManager::Instance = new gosFX::LightManager();
	gos_PopCurrentHeap();
	systemHeap->Free(effectsData);
	//------------------------------------------------
	// Fire up the MC Texture Manager.
	mcTextureManager = new MC_TextureManager;
	mcTextureManager->start();
	//Startup the vertex array pool
	mcTextureManager->startVertices(500000);
	//--------------------------------------------------
	// Setup Mouse Parameters from Prefs.CFG
	userInput = new UserInput;
	userInput->init();
	userInput->setMouseDoubleClickThreshold(doubleClickThreshold);
	userInput->setMouseDragThreshold(dragThreshold);
	userInput->initMouseCursors("cursors");
	userInput->setMouseCursor(mState_NORMAL);
	userInput->mouseOn();
	// now the sound system
	soundSystem = new GameSoundSystem;
	soundSystem->init();
	((SoundSystem*)soundSystem)->init("sound");
	sndSystem = soundSystem; // for things in the lib that use sound
	soundSystem->playDigitalMusic(LOGISTICS_LOOP);
	pLogData = new LogisticsData;
	pLogData->init();
	pMechlopedia = new Mechlopedia;
	pMechlopedia->init();
	pMechlopedia->begin();
}
Esempio n. 12
0
void MissionBegin::beginMPlayer()
{
	// already set up
	if(multiplayerScreens[0][1])
		return;
	//multiplayer setup screens
	MPConnectionType*		pMPConnectionType = nullptr;
	placeHolderScreen = nullptr;
	MPGameBrowser*		pMPGameBrowser = nullptr;
	MPParameterScreen*		pMPParameterScreen = nullptr;
	char path[512];
	FitIniFile file;
	// initalize MPConnectionType
	pMPConnectionType = new MPConnectionType;
	strcpy(path, artPath);
	strcat(path, "mcl_mp_connectiontype.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pMPConnectionType->init(&file);
	file.close();
	// initalize MPPlaceHolderScreen
	placeHolderScreen = new MPPlaceHolderScreen;
	// initalize MPParameterScreen
	pMPParameterScreen = new MPParameterScreen;
	strcpy(path, artPath);
	strcat(path, "mcl_mp_param.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pMPParameterScreen->init(&file);
	file.close();
	// initalize MPGameBrowser
	pMPGameBrowser = new MPGameBrowser;
	strcpy(path, artPath);
	strcat(path, "mcl_mp_lanbrowser.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pMPGameBrowser->init(&file);
	file.close();
	// initalize MP prefs
	MPPrefs* pMPPrefs = new MPPrefs;
	strcpy(path, artPath);
	strcat(path, "mcl_mp_playerprefs.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pMPPrefs->init(file);
	file.close();
	LoadScreenWrapper* pMLoadScreen = new LoadScreenWrapper;
	strcpy(path, artPath);
	strcat(path, "mcl_loadingscreen.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pMLoadScreen->init(file);
	file.close();
	pMPConnectionType->ppConnectionScreen = (PVOID*)(&(screens[1][1]));
	pMPConnectionType->pLocalBrowserScreen = pMPGameBrowser;
	pMPConnectionType->pDirectTcpipScreen = pMPGameBrowser;
	pMPConnectionType->pMPPlaceHolderScreen = placeHolderScreen;
	multiplayerScreens[0][1] = pMPConnectionType;
	multiplayerScreens[1][1] = pMPGameBrowser;
	multiplayerScreens[2][1] = pMPParameterScreen;
	multiplayerScreens[3][1] = pMLoadScreen;
	multiplayerScreens[2][0] = pMPPrefs;
	pMPPrefs->initColors();
	{
		for(size_t i = 0; i < 4; i++)
		{
			for(size_t j = 0; j < 4; j++)
			{
				if(multiplayerScreens[i][j])
				{
					if(multiplayerScreens[i][j]->getButton(MB_MSG_NEXT))
						multiplayerScreens[i][j]->getButton(MB_MSG_NEXT)->setPressFX(-1);
					if(multiplayerScreens[i][j]->getButton(MB_MSG_PREV))
						multiplayerScreens[i][j]->getButton(MB_MSG_PREV)->setPressFX(-1);
					if(multiplayerScreens[i][j]->getButton(MB_MSG_MAINMENU))
						multiplayerScreens[i][j]->getButton(MB_MSG_MAINMENU)->setPressFX(LOG_MAINMENUBUTTON);
				}
			}
		}
	}
}
Esempio n. 13
0
void MissionBegin::begin()
{
	bReadyToLoad = 0;
	initABL();
	//-----------------------------------------------
	// Tutorial Data
	animationRunning = false;
	timeLeftToScroll = 0.0f;
	targetButtonId = 0;
	buttonNumFlashes = 0;
	buttonFlashTime = 0.0f;
	//---------------------------------------------
	//Load up the Logistics Brain for Tutorials.
	// OK if brain file is NOT there!!
	FullPathFileName brainFileName;
	PCSTR  brainfile = LogisticsData::instance->getCurrentABLScript();
	if(brainfile)
		brainFileName.init(missionPath, brainfile, ".abl");
	if(brainfile && fileExists(brainFileName))
	{
		int32_t numErrors, numLinesProcessed;
		logisticsScriptHandle = ABLi_preProcess(brainFileName, &numErrors, &numLinesProcessed);
		gosASSERT(logisticsScriptHandle >= 0);
		logisticsBrain = new ABLModule;
		gosASSERT(logisticsBrain != nullptr);
#ifdef _DEBUG
		int32_t brainErr =
#endif
			logisticsBrain->init(logisticsScriptHandle);
		gosASSERT(brainErr == NO_ERROR);
		logisticsBrain->setName("Logistics");
	}
	else
	{
		logisticsScriptHandle = 0;
		logisticsBrain = nullptr;
	}
	//---------------------------------------------
	uint32_t localRenderer = prefs.renderer;
	if(prefs.renderer != 0 && prefs.renderer != 3)
		localRenderer = 0;
	bool localFullScreen = prefs.fullScreen;
	bool localWindow = !prefs.fullScreen;
	if(Environment.fullScreen && prefs.fullScreen)
		localFullScreen = false;
	if(prefs.renderer == 3)
		gos_SetScreenMode(800, 600, 16, 0, 0, 0, true, localFullScreen, 0, localWindow, 0, localRenderer);
	else if(prefs.bitDepth)
		gos_SetScreenMode(800, 600, 32, prefs.renderer, 0, 0, 0, localFullScreen, 0, localWindow, 0, localRenderer);
	else
		gos_SetScreenMode(800, 600, 16, prefs.renderer, 0, 0, 0, localFullScreen, 0, localWindow, 0, localRenderer);
	if(mainMenu)    // already initialized
	{
		curScreenX = 0;
		curScreenY = 1;
		if(LogisticsData::instance->skipLogistics())
		{
			if(LogisticsData::instance->showChooseMission())
			{
				curScreenX = 3;
				curScreenY = 1;
				screens[3][1] = singlePlayerScreens[0][1];
			}
		}
		if(screens[curScreenX][curScreenY])
		{
			screens[curScreenX][curScreenY]->beginFadeIn(1.0);
			screens[curScreenX][curScreenY]->begin();
		}
		Mission::initTGLForLogistics();
		bDone = 0;
		return;
	}
	MissionSelectionScreen*		pMissionSelectionScreen;
	MechBayScreen*				pMechBayScreen;
	PilotReadyScreen*			pPilotSelectionScreen;
	MechLabScreen*				pMechLabScreen;
	MechPurchaseScreen*			pPurchaseMechScreen;
	MissionBriefingScreen*		pBriefingScreen;
	LoadScreenWrapper*			pLoadScreen;
	pMissionSelectionScreen = nullptr;
	pMechBayScreen = nullptr;
	pPilotSelectionScreen = nullptr;
	pMechLabScreen = nullptr;
	pPurchaseMechScreen = nullptr;
	pBriefingScreen = nullptr;
	pLoadScreen = nullptr;
	bDone = 0;
	// initialize the main menu
	mainMenu = new MainMenu;
	char path[256];
	strcpy(path, artPath);
	strcat(path, "mcl_mm.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;
	}
	mainMenu->init(file);
	mainMenu->setDrawBackground(true);
	mainMenu->begin();
	file.close();
	// initialize mission selection
	pMissionSelectionScreen = new MissionSelectionScreen();
	strcpy(path, artPath);
	strcat(path, "mcl_cm_layout.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pMissionSelectionScreen->init(&file);
	file.close();
	// initialize mission briefing
	pBriefingScreen = new MissionBriefingScreen();
	strcpy(path, artPath);
	strcat(path, "mcl_mn.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pBriefingScreen->init(&file);
	file.close();
	// initialize mech bay
	strcpy(path, artPath);
	strcat(path, "mcl_mb_layout.fit");
	pMechBayScreen = new MechBayScreen();
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	// initialize animations, these are held in the mech bay file
	pMechBayScreen->init(&file);
	file.seekBlock("DownAnim");
	downAnim.init(&file, "");
	file.seekBlock("UpAnim");
	upAnim.init(&file, "");
	file.seekBlock("NextAnim");
	leftAnim.init(&file, "");
	file.seekBlock("BackAnim");
	rightAnim.init(&file, "");
	file.close();
	// initialize pilot ready
	strcpy(path, artPath);
	strcat(path, "mcl_pr_layout.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	// initialize pilot ready
	pPilotSelectionScreen = new PilotReadyScreen;
	pPilotSelectionScreen->init(&file);
	file.close();
	// initalize purchase pilot
	pPurchaseMechScreen = new MechPurchaseScreen;
	strcpy(path, artPath);
	strcat(path, "mcl_m$.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pPurchaseMechScreen->init(file);
	file.close();
	// initialize mech lab
	pMechLabScreen = new MechLabScreen;
	strcpy(path, artPath);
	strcat(path, "mcl_mc.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pMechLabScreen->init(file);
	file.close();
	// initialize mech lab
	pLoadScreen = new LoadScreenWrapper;
	strcpy(path, artPath);
	strcat(path, "mcl_loadingscreen.fit");
	if(NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	pLoadScreen->init(file);
	file.close();
	singlePlayerScreens[0][1] = pMissionSelectionScreen;
	singlePlayerScreens[1][1] = pBriefingScreen;
	singlePlayerScreens[2][1] = pMechBayScreen;
	singlePlayerScreens[3][1] = pPilotSelectionScreen;
	singlePlayerScreens[2][0] = pPurchaseMechScreen;
	singlePlayerScreens[2][2] = pMechLabScreen;
	singlePlayerScreens[4][1] = pLoadScreen;
	for(size_t i = 0; i < 4; i++)
	{
		for(size_t j = 0; j < 4; j++)
		{
			if(singlePlayerScreens[i][j])
			{
				/*if (  singlePlayerScreens[i][j]->getButton(MB_MSG_NEXT) )
					singlePlayerScreens[i][j]->getButton(MB_MSG_NEXT)->setPressFX( -1 );

				if ( singlePlayerScreens[i][j]->getButton(MB_MSG_PREV) )
					singlePlayerScreens[i][j]->getButton(MB_MSG_PREV)->setPressFX( -1 );*/
				if(singlePlayerScreens[i][j]->getButton(MB_MSG_MAINMENU))
					singlePlayerScreens[i][j]->getButton(MB_MSG_MAINMENU)->setPressFX(LOG_MAINMENUBUTTON);
			}
		}
	}
	for(i = 0; i < 5/*dim screen X*/; i += 1)
	{
		int32_t j;
		for(j = 0; j < 3/*dim screen Y*/; j += 1)
		{
			screens[i][j] = singlePlayerScreens[i][j];
		}
	}
	pMissionSelectionScreen->begin();
}
Esempio n. 14
0
void MissionResults::begin()
{

	if ( soundSystem )
		soundSystem->stopSupportSample();


	if ( !MPlayer )
	{
		char path[256];
		FitIniFile file;

		if ( !LogisticsData::instance->skipSalvageScreen() )
		{
			pSalvageScreen = new SalvageMechScreen();
			strcpy( path, artPath );
			strcat( path, "mcui_mr_layout.fit" );
			
			if ( NO_ERR != file.open( path ) )
			{
				char error[256];
				sprintf( error, "couldn't open file %s", path );
				Assert( 0, 0, error );
				return;
			}
			pSalvageScreen->init( &file );
			file.close();	
			bDone = false;
		}
			
		if ( !LogisticsData::instance->skipPilotReview() )
		{
		
			strcpy( path, artPath );
			strcat( path, "mcui_mr_layout.fit" );

			pPilotScreen = new PilotReviewScreen();
			if ( NO_ERR != file.open( path ) )
			{
				char error[256];
				sprintf( error, "couldn't open file %s", path );
				Assert( 0, 0, error );
				return;
			}
			pPilotScreen->init( &file );
			bDone = 0;
			if ( !LogisticsData::instance->skipSalvageScreen() )
				bPilotStarted = 0;
			else
				bPilotStarted = 1;
		}
	}
	else
	{
		if ( !mpStats.staticCount )
		{
			mpStats.init();

		}

		if ( mpStats.getStatus() != LogisticsScreen::RUNNING )
			mpStats.begin();

		bDone = false;
	}
}
Esempio n. 15
0
int MechLabScreen::init( FitIniFile& file )
{
	if ( saveDlg )// already initialized
		return -1;

	ComponentListItem::init( file );

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

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

	componentListBox.setHighlightFX( -1 ); // want to do this by hand.
	
	saveDlg = new LogisticsVariantDialog;
	acceptDlg = new LogisticsAcceptVariantDialog;

	FitIniFile saveFile;
	FullPathFileName path;
	path.init( artPath, "MCL_SV", ".fit" );

	if ( NO_ERR != saveFile.open( path ) )
	{
		Assert( 0, 0, "couldn't open MCL_SV.fit" );
		return -1;
	}

	saveDlg->init( saveFile );
	saveFile.close();

	path.init( artPath, "mcl_sv_acceptchanges", ".fit" );

	if ( NO_ERR != saveFile.open( path ) )
	{
		Assert( 0, 0, "couldn't open MCL_SV.fit" );
		return -1;
	}

	acceptDlg->init( saveFile );


	payloadIcon.init( &file, "PayloadUnit" );	  

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

	for ( i= 0; i < buttonCount; i++ )
	{
		switch( buttons[i].getID() )
		{
			case	COMPONENT_FORM_WEAPON_ENERGY:
			case	COMPONENT_FORM_WEAPON_BALLISTIC:
			case	COMPONENT_FORM_WEAPON_MISSILE:
			case	COMPONENT_FORM_JUMPJET:
				break;

			default:
				{
				buttons[i].setMessageOnRelease();
				buttons[i].setPressFX(LOG_CLICKONBUTTON );
				}

				
		}	
	}

	file.seekBlock( "ComboBox0" );
	long xLoc, yLoc;
	file.readIdLong( "XLocation", xLoc );
	file.readIdLong( "YLocation", yLoc );
	char fileName[256];
	file.readIdString( "FileName", fileName, 255 );

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

	FitIniFile comboFile;

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


	variantList.init( &comboFile, "VariantComboBox" );
	variantList.setReadOnly( true );
	variantList.ListBox().setOrange(true);
	variantList.setParent( this );
	variantList.setHelpID( IDS_HELP_MC_VARIANT_DROP_DOWN_LIST_BOX );

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

	getButton( COMPONENT_FORM_WEAPON_ENERGY )->setPressFX( LOG_VIDEOBUTTONS );
	getButton( COMPONENT_FORM_WEAPON_BALLISTIC )->setPressFX( LOG_VIDEOBUTTONS );
	getButton( COMPONENT_FORM_WEAPON_MISSILE )->setPressFX( LOG_VIDEOBUTTONS );
	getButton( COMPONENT_FORM_JUMPJET )->setPressFX( LOG_VIDEOBUTTONS );

	getButton( COMPONENT_FORM_WEAPON_ENERGY )->setHighlightFX( LOG_DIGITALHIGHLIGHT );
	getButton( COMPONENT_FORM_WEAPON_BALLISTIC )->setHighlightFX( LOG_DIGITALHIGHLIGHT );
	getButton( COMPONENT_FORM_WEAPON_MISSILE )->setHighlightFX( LOG_DIGITALHIGHLIGHT );
	getButton( COMPONENT_FORM_JUMPJET )->setHighlightFX( LOG_DIGITALHIGHLIGHT );


	
	// initialize the selection rectangles
	for ( i = 0; i < 5; i++ )
	{
		for ( int j = 0; j < 2; j++ )
		{
			sprintf( fileName, "mcl_mc_%ldby%ld_selection.tga", j+1, i+1 );
			path.init( artPath, fileName, ".tga" );

			if ( fileExists( path ) )
			{
				selRects[j][i].setTexture( path );
				selRects[j][i].resize( (j+1) * LogisticsComponent::XICON_FACTOR, (i+1) * LogisticsComponent::YICON_FACTOR );
				// now need to set the UV's
				selRects[j][i].setUVs( 0, 0, selRects[j][i].width(), selRects[j][i].height()  );
			}

		}
	}

	path.init( artPath, "mcl_mc_jumpjets_selection", ".tga" );
	selJumpJetRect.setTexture( path );
	selJumpJetRect.resize( 2 * LogisticsComponent::XICON_FACTOR, 2 * LogisticsComponent::YICON_FACTOR );
	// now need to set the UV's
	selJumpJetRect.setUVs( 0, 0, selJumpJetRect.width(), selJumpJetRect.height()  );

	return true;
}