Esempio n. 1
0
void MainMenu::begin()
{
	status = RUNNING;
	promptToQuit = 0;
	beginAnim.begin();
	beginFadeIn( 0 );
	endAnim.end();
	background.beginFadeIn( 0 );
	endResult = RUNNING;
	musicStarted = false;
	bLoadSingle = 0;
	bLoadCampaign = 0;
	promptToDisconnect = 0; 
	bLegal = 0;

	// no host left dlg, sometimes we get this begin call 2x's due to netlib weirdness
	if ( !introMovie )
	{
			while (mc2IsInMouseTimer)
				;

			//ONLY set the mouse BLT data at the end of each update.  NO MORE FLICKERING THEN!!!
			// BLOCK THREAD WHILE THIS IS HAPPENING
			mc2IsInDisplayBackBuffer = true;

			mc2UseAsyncMouse = prefs.asyncMouse;
			if ( !mc2UseAsyncMouse)
				MouseTimerKill();

			mc2IsInDisplayBackBuffer = false;

			AsynFunc = NULL;

			//Force mouse Cursors to smaller or larger depending on new video mode.
			userInput->initMouseCursors("cursors");
			userInput->mouseOn();
			userInput->setMouseCursor( mState_LOGISTICS );

			DWORD 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;


			// make sure we get into 800 x 600 mode
			if ( Environment.screenWidth != 800 )
			{
			
				if (prefs.renderer == 3)
					gos_SetScreenMode(800,600,16,0,0,0,true,localFullScreen,0,localWindow,0,localRenderer);
				else
					gos_SetScreenMode(800,600,16,prefs.renderer,0,0,0,localFullScreen ,0,localWindow,0,localRenderer);
			}


	}
}
Esempio n. 2
0
//----------------------------------------------------------------------------------
void Logistics::start (long startMode)
{
	bMissionLoaded  = 0;
	userInput->setMouseCursor( mState_LOGISTICS );
//	userInput->mouseOn();

	DWORD 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;

	switch (startMode)
	{
		case log_RESULTS: // pull out results later...
			active = true;
			//Heading back to logistics now.  Change screen back to 800x600
			if (prefs.renderer == 3)
				gos_SetScreenMode(800,600,16,0,0,0,true,localFullScreen,0,localWindow,0,localRenderer);
			else
				gos_SetScreenMode(800,600,16,prefs.renderer,0,0,0,localFullScreen,0,localWindow,0,localRenderer);

			lastMissionResult = scenarioResult;
			if ( !missionResults )
			{
				LogisticsData::instance->init();
				missionResults = new MissionResults;
				missionResults->init();
			}

			if ( scenarioResult == mis_PLAYER_WIN_BIG || MPlayer )
			{
				LogisticsData::instance->removeMechsInForceGroup();
				if ( !MPlayer )
					LogisticsData::instance->setMissionCompleted( );

				// if mission is over, play video then quit when  done
				if ( LogisticsData::instance->campaignOver() && !MPlayer && !LogisticsData::instance->isSingleMission() )
				{
					mission->destroy();
					playFullScreenVideo( LogisticsData::instance->getFinalVideo() );
					setLogisticsState(log_SPLASH);
					missionBegin->beginSplash();
					userInput->mouseOn();
					char tmp[256];
					cLoadString( IDS_FINAL_MISSION, tmp, 255 );
					FullPathFileName path;
					path.init( savePath, tmp, ".fit" );
					FitIniFile file;
					file.create( path );
					LogisticsData::instance->save(file);
					active = true;
				}
				else if ( LogisticsData::instance->isSingleMission() && !MPlayer )
				{
					missionBegin->beginSplash();
					logisticsState = log_SPLASH;
				}
				else
				{
			
					missionResults->begin();
					logisticsState = log_RESULTS;
				}

			}
			else if ( !justStartMission )
			{
				missionResults->bDone = true;
				logisticsState = log_RESULTS;
			}
			else // end the game
				quitGame = true;

			break;
		case log_SPLASH:
		{
			if (aborted) {
				if (prefs.renderer == 3)
					gos_SetScreenMode(800,600,16,0,0,0,true,localFullScreen,0,localWindow,0,localRenderer);
				else
					gos_SetScreenMode(800,600,16,prefs.renderer,0,0,0,localFullScreen,0,localWindow,0,localRenderer);

				if ( missionBegin )
					missionBegin->beginSplash();

				if ( MPlayer )
				{
					delete MPlayer;
					MPlayer = NULL;
				}
			}
			
			initializeLogData();
			
			bool bTestScript = false;
			if ( bTestScript )
			{
				FitIniFile loadFile;
				loadFile.open( "data\\missions\\save.fit" );
				LogisticsData::instance->load( loadFile );
				FitIniFile saveFile;
				saveFile.open("data\\missions\\save.fit", CREATE);
				LogisticsData::instance->save( saveFile );
		
			}

			active = TRUE;
			setLogisticsState(log_SPLASH);

			if ( !missionBegin )
			{
				missionBegin = new MissionBegin;
				missionBegin->beginSplash();
				missionBegin->init();
			}

		}
		break;

		case log_ZONE:
		{
			logisticsData.init();
			if ( !missionBegin )
			{
				missionBegin = new MissionBegin;
				missionBegin->init();
			}

			missionBegin->beginZone();
			active = TRUE;
			setLogisticsState( log_SPLASH );
			userInput->mouseOn();
			userInput->setMouseCursor( mState_NORMAL );

		}
		break;
	}
}	
Esempio n. 3
0
//---------------------------------------------------------------------------
void InitializeGameEngine()
{
	//---------------------------------------------------------------------
	float doubleClickThreshold = 0.2f;
	long dragThreshold = 10;

	Environment.Key_Exit=-1; // so escape doesn't kill your app

	//--------------------------------------------------------------
	// Read in System.CFG
	FitIniFilePtr systemFile = new FitIniFile;

#ifdef _DEBUG
	long systemOpenResult = 
#endif
		systemFile->open("system.cfg");
		   
#ifdef _DEBUG
	if( systemOpenResult != NO_ERR)
	{
		char Buffer[256];
		gos_GetCurrentPath( Buffer, 256 );
		STOP(( "Cannot find \"system.cfg\" file in %s",Buffer ));
	}
#endif

	{
#ifdef _DEBUG
		long systemBlockResult = 
#endif
			systemFile->seekBlock("systemHeap");
		gosASSERT(systemBlockResult == NO_ERR);
		{
			long result = systemFile->readIdULong("systemHeapSize",systemHeapSize);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdULong("guiHeapSize",guiHeapSize);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdULong("logisticsHeapSize",logisticsHeapSize);
			gosASSERT(result == NO_ERR);
		}

#ifdef _DEBUG
		long systemPathResult = 
#endif
			systemFile->seekBlock("systemPaths");
		gosASSERT(systemPathResult == NO_ERR);
		{
			long result = systemFile->readIdString("terrainPath",terrainPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("artPath",artPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("fontPath",fontPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("savePath",savePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("spritePath",spritePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("shapesPath",shapesPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("soundPath",soundPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("objectPath",objectPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("cameraPath",cameraPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("tilePath",tilePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("missionPath",missionPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("warriorPath",warriorPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("profilePath",profilePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("interfacepath",interfacePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("moviepath",moviePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("CDsoundPath",CDsoundPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("CDmoviepath",CDmoviePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("CDspritePath",CDspritePath,79);
			gosASSERT(result == NO_ERR);
		}

#ifdef _DEBUG
		long fastFileResult = 
#endif
			systemFile->seekBlock("FastFiles");
		gosASSERT(fastFileResult == NO_ERR);
		{
			long result = systemFile->readIdLong("NumFastFiles",maxFastFiles);
			if (result != NO_ERR)
				maxFastFiles = 0;

			if (maxFastFiles)
			{
				fastFiles = (FastFile **)malloc(maxFastFiles*sizeof(FastFile *));
				memset(fastFiles,0,maxFastFiles*sizeof(FastFile *));

				long fileNum = 0;
				char fastFileId[10];
				char fileName[100];
				sprintf(fastFileId,"File%d",fileNum);
	
				while (systemFile->readIdString(fastFileId,fileName,99) == NO_ERR)
				{
					FastFileInit(fileName);
					fileNum++;
					sprintf(fastFileId,"File%d",fileNum);
					numFastFiles++;
				}
			}
		}
		
		long result = systemFile->seekBlock("UseMusic");
		if (result == NO_ERR)
			useMusic = TRUE;
		else
			useMusic = FALSE;
			
		result = systemFile->seekBlock("UseSound");
		if (result == NO_ERR)
		{
			useSound = TRUE;
		}
		else
		{
			useSound = FALSE;
			useMusic = FALSE;
		}
	}

	systemFile->close();
	delete systemFile;
	systemFile = NULL;

	//--------------------------------------------------------------
	// Read in Prefs.cfg
	FitIniFilePtr prefs = new FitIniFile;

#ifdef _DEBUG
	long prefsOpenResult = 
#endif
		prefs->open("prefs.cfg");

	gosASSERT (prefsOpenResult == NO_ERR);
	{
#ifdef _DEBUG
		long prefsBlockResult = 
#endif
			prefs->seekBlock("MechCommander2");
		gosASSERT(prefsBlockResult == NO_ERR);
		{
			long filterSetting;
			long result = prefs->readIdLong("FilterState",filterSetting);
			if (result == NO_ERR)
			{
				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_ERR)
				TERRAIN_TXM_SIZE = 64;

			result = prefs->readIdLong("Resolution",resolution);
			if (result != NO_ERR)
				resolution = 0;

			result = prefs->readIdLong("ObjectTextureRes",ObjectTextureSize);
			if (result != NO_ERR)
				ObjectTextureSize = 128;

			result = prefs->readIdLong("Difficulty",GameDifficulty);
			if (result != NO_ERR)
				GameDifficulty = 1;

			result = prefs->readIdLong("Brightness",gammaLevel);
			if (result != NO_ERR)
				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_ERR)
				DigitalMasterVolume = 255;

			result = prefs->readIdLong("MusicVolume",MusicVolume);
			if (result != NO_ERR)
				MusicVolume = 64;

			result = prefs->readIdLong("RadioVolume",RadioVolume);
			if (result != NO_ERR)
				RadioVolume = 64;

			result = prefs->readIdLong("SFXVolume",SFXVolume);
			if (result != NO_ERR)
				SFXVolume = 64;

			result = prefs->readIdFloat("DoubleClickThreshold",doubleClickThreshold);
			if (result != NO_ERR)
				doubleClickThreshold = 0.2f;

			result = prefs->readIdLong("DragThreshold",dragThreshold);
			if (result != NO_ERR)
				dragThreshold = 10;
				
			result = prefs->readIdULong("BaseVertexColor",BaseVertexColor);
			if (result != NO_ERR)
				BaseVertexColor = 0x00000000;
				
			result = prefs->readIdBoolean("UnlimitedAmmo",useUnlimitedAmmo);
			if (result != NO_ERR)
				useUnlimitedAmmo = true;
				
			result = prefs->readIdBoolean("RealLOS",useRealLOS);
			if (result != NO_ERR)
				useRealLOS = true;
		}
	}
	
	prefs->close();
	
	delete prefs;
	prefs = NULL;
	//---------------------------------------------------------------------

	switch (resolution)
	{
		case 0:			//640by480
			gos_SetScreenMode(640,480);
			break;

		case 1:			//800by600
			gos_SetScreenMode(800,600);
			break;

		case 2:			//1024by768
			gos_SetScreenMode(1024,768);
			break;

		case 3:			//1280by1024
			gos_SetScreenMode(1280,1024);
			break;

		case 4:			//1600by1200
			gos_SetScreenMode(1600,1200);
			break;
	}

	//--------------------------------------------------
	// Setup Mouse Parameters from Prefs.CFG
	//userInput = new UserInput;
	//userInput->init();
	//userInput->setMouseDoubleClickThreshold(doubleClickThreshold);
	//userInput->setMouseDragThreshold(dragThreshold);
	//--------------------------------------------------

	gosResourceHandle = gos_OpenResourceDLL("mc2res.dll");

	gosFontHandle = gos_LoadFont("assets\\graphics\\arial8.tga");

	globalFloatHelp = new FloatHelp [MAX_FLOAT_HELPS];

	//
	//----------------------------------
	// Start associated stuff.
	//----------------------------------
	Stuff::InitializeClasses();
	
	//--------------------------------------------------------------
	// Start the GUI Heap.
	systemHeap = new UserHeap;
	gosASSERT(systemHeap != NULL);
	
	systemHeap->init(systemHeapSize,"SYSTEM");
	
	//--------------------------------------------------------------
	// Start the GUI Heap.
	guiHeap = new UserHeap;
	gosASSERT(guiHeap != NULL);
	
	guiHeap->init(guiHeapSize,"GUI");
	
	//------------------------------------------------
	// Fire up the MC Texture Manager.
	mcTextureManager = new MC_TextureManager;
	mcTextureManager->start();

	//--------------------------------------------------------------
	// Load up the mouse cursors
	//userInput->initMouseCursors("cursors");
	//userInput->mouseOff();
	//userInput->setMouseCursor(mState_NORMAL);

	//------------------------------------------------
	// Give the Sound System a Whirl!
	//soundSystem = new GameSoundSystem;
	//soundSystem->init();
	//((SoundSystem *)soundSystem)->init("sound");
	
	//---------------------------------------------------------
	// Start the Mission, Scenario and Logistics classes here
	logistics = new Logistics;
	logistics->start(log_SPLASH);				//Always start with logistics in Splash Screen Mode
}
Esempio n. 4
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();
}