示例#1
0
/*!
 * Load a savegame and start into the game loop
 * Game data should be initialised afterwards, so that startGameLoop is not necessary anymore.
 */
static bool initSaveGameLoad(void)
{
	// NOTE: always setGameMode correctly before *any* loading routines!
	SetGameMode(GS_NORMAL);
	screen_RestartBackDrop();
	// load up a save game
	if (!loadGameInit(saveGameName))
	{
		// FIXME: we really should throw up a error window, but we can't (easily) so I won't.
		debug(LOG_ERROR, "Trying to load Game %s failed!", saveGameName);
		debug(LOG_POPUP, "Failed to load a save game! It is either corrupted or a unsupported format.\n\nRestarting main menu.");
		// FIXME: If we bomb out on a in game load, then we would crash if we don't do the next two calls
		// Doesn't seem to be a way to tell where we are in game loop to determine if/when we should do the two calls.
		gameLoopStatus = GAMECODE_FASTEXIT;	// clear out all old data
		stopGameLoop();
		startTitleLoop(); // Restart into titleloop
		SetGameMode(GS_TITLE_SCREEN);
		return false;
	}

	screen_StopBackDrop();
	closeLoadingScreen();

	// Trap the cursor if cursor snapping is enabled
	if (war_GetTrapCursor())
	{
		wzGrabMouse();
	}
	if (challengeActive)
	{
		addMissionTimerInterface();
	}

	return true;
}
示例#2
0
/*!
 * Shutdown/cleanup after the game loop
 * Would stop the timer
 */
static void stopGameLoop(void)
{
	if (gameLoopStatus != GAMECODE_NEWLEVEL)
	{
		clearBlueprints();
		initLoadingScreen(true); // returning to f.e. do a loader.render not active
		pie_EnableFog(false); // dont let the normal loop code set status on
		fogStatus = 0;
		if (gameLoopStatus != GAMECODE_LOADGAME)
		{
			if (!levReleaseAll())
			{
				debug(LOG_ERROR, "levReleaseAll failed!");
			}
		}
		closeLoadingScreen();
		reloadMPConfig();
	}

	// Disable cursor trapping
	if (war_GetTrapCursor())
	{
		wzReleaseMouse();
	}

	gameInitialised = false;
}
示例#3
0
/*!
 * Run the code inside the titleloop
 */
static void runTitleLoop(void)
{
	switch (titleLoop())
	{
		case TITLECODE_CONTINUE:
			break;
		case TITLECODE_QUITGAME:
			debug(LOG_MAIN, "TITLECODE_QUITGAME");
			stopTitleLoop();
			wzQuit();
			break;
		case TITLECODE_SAVEGAMELOAD:
			{
				debug(LOG_MAIN, "TITLECODE_SAVEGAMELOAD");
				initLoadingScreen(true);
				// Restart into gameloop and load a savegame, ONLY on a good savegame load!
				stopTitleLoop();
				if (!initSaveGameLoad())
				{
					// we had a error loading savegame (corrupt?), so go back to title screen?
					stopGameLoop();
					startTitleLoop();
					changeTitleMode(TITLE);
				}
				closeLoadingScreen();
			break;
			}
		case TITLECODE_STARTGAME:
			debug(LOG_MAIN, "TITLECODE_STARTGAME");
			initLoadingScreen(true);
			stopTitleLoop();
			startGameLoop(); // Restart into gameloop
			closeLoadingScreen();
			break;
		case TITLECODE_SHOWINTRO:
			debug(LOG_MAIN, "TITLECODE_SHOWINTRO");
			seq_ClearSeqList();
			seq_AddSeqToList("titles.ogg", NULL, NULL, false);
			seq_AddSeqToList("devastation.ogg", NULL, "devastation.txa", false);
			seq_StartNextFullScreenVideo();
			break;
		default:
			debug(LOG_ERROR, "Unknown code returned by titleLoop");
			break;
	}
}
示例#4
0
/*!
 * Preparations before entering the title (mainmenu) loop
 * Would start the timer in an event based mainloop
 */
static void startTitleLoop(void)
{
	SetGameMode(GS_TITLE_SCREEN);

	initLoadingScreen(true);
	if (!frontendInitialise("wrf/frontend.wrf"))
	{
		debug( LOG_FATAL, "Shutting down after failure" );
		exit(EXIT_FAILURE);
	}
	closeLoadingScreen();
}
示例#5
0
void systemShutdown(void)
{
	if (mod_list)
	{
		free(mod_list);
	}

	shutdownEffectsSystem();
	closeLoadingScreen();
	keyClearMappings();

	// free up all the load functions (all the data should already have been freed)
	resReleaseAll();

	if (!multiShutdown()) // ajl. init net stuff
	{
		debug(LOG_FATAL, "Unable to multiShutdown() cleanly!");
		abort();
	}

	debug(LOG_MAIN, "shutting down audio subsystems");

	debug(LOG_MAIN, "shutting down CD audio");
	cdAudio_Close();

	if ( audio_Disabled() == false && !audio_Shutdown() )
	{
		debug(LOG_FATAL, "Unable to audio_Shutdown() cleanly!");
		abort();
	}

	debug(LOG_MAIN, "shutting down graphics subsystem");
	iV_ShutDown();
	levShutDown();
	widgShutDown();
	fpathShutdown();
	debug(LOG_MAIN, "shutting down everything else");
	pal_ShutDown();		// currently unused stub
	frameShutDown();	// close screen / SDL / resources / cursors / trig
	closeConfig();		// "registry" close
	cleanSearchPath();	// clean PHYSFS search paths
	debug_exit();		// cleanup debug routines
	PHYSFS_deinit();	// cleanup PHYSFS (If failure, state of PhysFS is undefined, and probably badly screwed up.)
	// NOTE: Exception handler is cleaned via atexit(ExchndlShutdown);
}
示例#6
0
bool stageThreeInitialise(void)
{
	STRUCTURE *psStr;
	UDWORD i;
	DROID		*psDroid;

	debug(LOG_WZ, "== stageThreeInitalise ==");
	bTrackingTransporter = false;

	loopMissionState = LMS_NORMAL;

	if(!InitRadar()) 	// After resLoad cause it needs the game palette initialised.
	{
		return false;
	}

	// reset the clock to normal speed
	gameTimeResetMod();

	if (!init3DView())	// Initialise 3d view stuff. After resLoad cause it needs the game palette initialised.
	{
		return false;
	}

	effectResetUpdates();
	initLighting(0, 0, mapWidth, mapHeight);

	if(bMultiPlayer)
	{
		// FIXME Is this really needed?
		debug( LOG_WZ, "multiGameInit()\n" );
		multiGameInit();
		cmdDroidMultiExpBoost(true);
	}

	preProcessVisibility();
	closeLoadingScreen();			// reset the loading screen.

	if (!fpathInitialise())
	{
		return false;
	}

	mapInit();
	clustInitialise();
	gridReset();

	//if mission screen is up, close it.
	if(MissionResUp)
	{
		intRemoveMissionResultNoAnim();
	}

	// determine if to use radar
	for(psStr = apsStructLists[selectedPlayer];psStr;psStr=psStr->psNext){
		if(psStr->pStructureType->type == REF_HQ)
		{
			radarOnScreen = true;
			setHQExists(true,selectedPlayer);
			break;
		}
	}

	// Re-inititialise some static variables.

	driveInitVars(false);
	displayInitVars();
	resizeRadar();

	setAllPauseStates(false);

	/* decide if we have to create teams, ONLY in multiplayer mode!*/
	if (bMultiPlayer && game.alliance == ALLIANCES_TEAMS)
	{
		createTeamAlliances();

		/* Update ally vision for pre-placed structures and droids */
		for(i=0;i<MAX_PLAYERS;i++)
		{
			if(i != selectedPlayer)
			{
				/* Structures */
				for(psStr=apsStructLists[i]; psStr; psStr=psStr->psNext)
				{
					if(aiCheckAlliances(psStr->player,selectedPlayer))
					visTilesUpdate((BASE_OBJECT *)psStr);
				}

				/* Droids */
				for(psDroid=apsDroidLists[i]; psDroid; psDroid=psDroid->psNext)
				{
					if(aiCheckAlliances(psDroid->player,selectedPlayer))
					visTilesUpdate((BASE_OBJECT *)psDroid);
				}
			}
		}
	}

	if (bMultiPlayer)
	{
		loadMultiScripts();
	}

	// ffs JS   (and its a global!)
	if (getLevelLoadType() != GTYPE_SAVE_MIDMISSION)
	{
		eventFireCallbackTrigger((TRIGGER_TYPE)CALL_GAMEINIT);
	}

	return true;
}
示例#7
0
// ////////////////////////////////////////////////////////////////////////////
bool startLimitScreen(void)
{
	addBackdrop();//background

	// load stats...
	if(!bLimiterLoaded)
	{
		initLoadingScreen(true);
		
		if (!resLoad("wrf/limiter_tex.wrf", 501))
		{
			return false;
		}

		if (!resLoad("wrf/piestats.wrf", 502))
		{
			return false;
		}

		if (!resLoad("wrf/limiter_data.wrf", 503))
		{
			return false;
		}

		bLimiterLoaded = true;

		closeLoadingScreen();		
	}

	if (challengeActive)
	{
		// reset the sliders..
		// it's a HACK since the actual limiter structure was cleared in the startMultiOptions function 
		for (unsigned i = 0; i < numStructureStats; ++i)
		{
			asStructLimits[0][i].limit = asStructLimits[0][i].globalLimit;
		}
		
		// turn off the sliders
		sliderEnableDrag(false);
	}
	else
	{
		//enable the sliders
		sliderEnableDrag(true);
	}

	addSideText(FRONTEND_SIDETEXT1,LIMITSX-2,LIMITSY,"LIMITS");	// draw sidetext...

	WIDGET *parent = widgGetFromID(psWScreen, FRONTEND_BACKDROP);

	IntFormAnimated *limitsForm = new IntFormAnimated(parent, false);
	limitsForm->id = IDLIMITS;
	limitsForm->setGeometry(LIMITSX, LIMITSY, LIMITSW, LIMITSH);

	// return button.
	addMultiBut(psWScreen,IDLIMITS,IDLIMITS_RETURN,
					LIMITS_OKX-40,LIMITS_OKY,
	            iV_GetImageWidth(FrontImages, IMAGE_NO),
	            iV_GetImageHeight(FrontImages, IMAGE_NO),
					_("Apply Defaults and Return To Previous Screen"),IMAGE_NO,IMAGE_NO,true);

	// ok button
	addMultiBut(psWScreen,IDLIMITS,IDLIMITS_OK,
					LIMITS_OKX,LIMITS_OKY,
					iV_GetImageWidth(FrontImages,IMAGE_OK),
					iV_GetImageHeight(FrontImages,IMAGE_OK),
					_("Accept Settings"),IMAGE_OK,IMAGE_OK,true);

	// add tab form..
	IntListTabWidget *limitsList = new IntListTabWidget(limitsForm);
	limitsList->setChildSize(BARWIDTH, BARHEIGHT);
	limitsList->setChildSpacing(5, 5);
	limitsList->setGeometry(50, 10, BARWIDTH, 370);

	//Put the buttons on it
	int limitsButtonId = IDLIMITS_ENTRIES_START;

	for (unsigned i = 0; i < numStructureStats; ++i)
	{
		if (asStructLimits[0][i].globalLimit != LOTS_OF)
		{
			W_FORM *button = new W_FORM(limitsList);
			button->id = limitsButtonId;
			button->displayFunction = displayStructureBar;
			button->UserData = i;
			limitsList->addWidgetToLayout(button);
			++limitsButtonId;

			addFESlider(limitsButtonId, limitsButtonId - 1, 290, 11,
						asStructLimits[0][i].globalLimit,
						asStructLimits[0][i].limit);
			++limitsButtonId;
		}
	}

	return true;
}
示例#8
0
// ////////////////////////////////////////////////////////////////////////////
bool startLimitScreen(void)
{
    UDWORD			numButtons = 0;
    UDWORD			i;

    addBackdrop();//background

    // load stats...
    if(!bLimiterLoaded)
    {
        initLoadingScreen(true);

        if (!resLoad("wrf/limiter_tex.wrf", 501))
        {
            return false;
        }

        if (!resLoad("wrf/piestats.wrf", 502))
        {
            return false;
        }

        if (!resLoad("wrf/limiter_data.wrf", 503))
        {
            return false;
        }

        bLimiterLoaded = true;

        closeLoadingScreen();
    }

    if (challengeActive)
    {
        // reset the sliders..
        // it's a HACK since the actual limiter structure was cleared in the startMultiOptions function
        for (i = 0; i < numStructureStats ; ++i)
        {
            asStructLimits[0][i].limit = asStructLimits[0][i].globalLimit;
        }

        // turn off the sliders
        sliderEnableDrag(false);
    }
    else
    {
        //enable the sliders
        sliderEnableDrag(true);
    }

    addSideText(FRONTEND_SIDETEXT1,LIMITSX-2,LIMITSY,"LIMITS");	// draw sidetext...

    W_FORMINIT sFormInit;
    sFormInit.formID	= FRONTEND_BACKDROP;
    sFormInit.id		= IDLIMITS;
    sFormInit.style		= WFORM_PLAIN;
    sFormInit.x			= LIMITSX;
    sFormInit.y			= LIMITSY;
    sFormInit.width		= LIMITSW;
    sFormInit.height	= LIMITSH;
    sFormInit.pDisplay	= intDisplayPlainForm;
    widgAddForm(psWScreen, &sFormInit);

    // return button.
    addMultiBut(psWScreen,IDLIMITS,IDLIMITS_RETURN,
                LIMITS_OKX-40,LIMITS_OKY,
                iV_GetImageWidth(FrontImages,IMAGE_RETURN),
                iV_GetImageHeight(FrontImages,IMAGE_RETURN),
                _("Apply Defaults and Return To Previous Screen"),IMAGE_NO,IMAGE_NO,true);

    // ok button
    addMultiBut(psWScreen,IDLIMITS,IDLIMITS_OK,
                LIMITS_OKX,LIMITS_OKY,
                iV_GetImageWidth(FrontImages,IMAGE_OK),
                iV_GetImageHeight(FrontImages,IMAGE_OK),
                _("Accept Settings"),IMAGE_OK,IMAGE_OK,true);

    // Count the number of minor tabs needed
    numButtons = 0;

    for(i=0; i<numStructureStats; i++ )
    {
        if(useStruct(numButtons,i))
        {
            numButtons++;
        }
    }

    if(numButtons >(4*BUTPERFORM)) numButtons =(4*BUTPERFORM);

    // add tab form..
    sFormInit = W_FORMINIT();
    sFormInit.formID = IDLIMITS;
    sFormInit.id = IDLIMITS_TABS;
    sFormInit.style = WFORM_TABBED;
    sFormInit.x = 50;
    sFormInit.y = 10;
    sFormInit.width = LIMITSW - 100;
    sFormInit.height =LIMITSH - 4;
    sFormInit.numMajor = numForms(numButtons, BUTPERFORM);
    sFormInit.majorPos = WFORM_TABTOP;
    sFormInit.minorPos = WFORM_TABNONE;
    sFormInit.majorSize = OBJ_TABWIDTH+3; //!!
    sFormInit.majorOffset = OBJ_TABOFFSET;
    sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2);			//(DES_TAB_HEIGHT/2)+2;
    sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
    sFormInit.pUserData = &StandardTab;
    sFormInit.pTabDisplay = intDisplayTab;

    // TABFIXME --unsure if needs fixing yet.
    for (i=0; i< sFormInit.numMajor; i++)
    {
        sFormInit.aNumMinors[i] = 1;
    }
    widgAddForm(psWScreen, &sFormInit);

    //Put the buttons on it
    W_FORMINIT sButInit;
    sButInit.formID   = IDLIMITS_TABS;//IDLIMITS;
    sButInit.style	  = WFORM_PLAIN;
    sButInit.width    = BARWIDTH;
    sButInit.height	  = BARHEIGHT;
    sButInit.pDisplay = displayStructureBar;
    sButInit.x		  = 2;
    sButInit.y		  = 5;
    sButInit.id	 	  = IDLIMITS_ENTRIES_START;

    numButtons =0;
    for(i=0; i<numStructureStats ; i++)
    {
        if(useStruct(numButtons,i))
        {
            numButtons++;
            sButInit.UserData= i;

            widgAddForm(psWScreen, &sButInit);
            sButInit.id	++;

            addFESlider(sButInit.id,sButInit.id-1, 290,11,
                        asStructLimits[0][i].globalLimit,
                        asStructLimits[0][i].limit);
            sButInit.id	++;

            if (sButInit.y + BARHEIGHT + 2 > (BUTPERFORM*(BARHEIGHT+2) - 4) )
            {
                sButInit.y = 5;
                sButInit.majorID += 1;
            }
            else
            {
                sButInit.y +=  BARHEIGHT +5;
            }
        }
    }

    return true;
}