コード例 #1
0
ファイル: g_demo.c プロジェクト: directhex/doom64
dboolean G_CheckDemoStatus(void) {
    if(endDemo) {
        demorecording = false;
        fputc(DEMOMARKER, demofp);
        CON_Printf(WHITE, "G_CheckDemoStatus: Demo recorded\n");
        fclose(demofp);
        endDemo = false;
        return false;
    }

    if(demoplayback) {
        if(singledemo) {
            I_Quit();
        }

        netdemo         = false;
        netgame         = false;
        deathmatch      = false;
        playeringame[1] = playeringame[2] = playeringame[3] = 0;
        respawnparm     = false;
        respawnitem     = false;
        fastparm        = false;
        nomonsters      = false;
        consoleplayer   = 0;
        gameaction      = ga_exitdemo;
        endDemo         = false;

        G_ReloadDefaults();
        return true;
    }

    return false;
}
コード例 #2
0
ファイル: m_menu.c プロジェクト: ComputerNerd/cgdoom
void M_QuitResponse(int ch)
{
    if (ch != 'y')
		return;

    I_Quit ();
}
コード例 #3
0
void I_GetEvent(void)
{
    extern void I_HandleKeyboardEvent(SDL_Event *sdlevent);
    extern void I_HandleMouseEvent(SDL_Event *sdlevent);
    SDL_Event sdlevent;

    SDL_PumpEvents();

    while (SDL_PollEvent(&sdlevent))
    {
        switch (sdlevent.type)
        {
            case SDL_KEYDOWN:
                if (ToggleFullScreenKeyShortcut(&sdlevent.key.keysym))
                {
                    I_ToggleFullScreen();
                    break;
                }
                // deliberate fall-though

            case SDL_KEYUP:
		I_HandleKeyboardEvent(&sdlevent);
                break;

            case SDL_MOUSEBUTTONDOWN:
            case SDL_MOUSEBUTTONUP:
            case SDL_MOUSEWHEEL:
                if (usemouse && !nomouse && window_focused)
                {
                    I_HandleMouseEvent(&sdlevent);
                }
                break;

            case SDL_QUIT:
                if (screensaver_mode)
                {
                    I_Quit();
                }
                else
                {
                    event_t event;
                    event.type = ev_quit;
                    D_PostEvent(&event);
                }
                break;

            case SDL_WINDOWEVENT:
                if (sdlevent.window.windowID == SDL_GetWindowID(screen))
                {
                    HandleWindowEvent(&sdlevent.window);
                }
                break;

            default:
                break;
        }
    }
}
コード例 #4
0
ファイル: fe_frontend.c プロジェクト: dotfloat/restrife
//
// Handle gamepad/joystick buttons
//
static void FE_HandleJoyButtons(int joybuttons)
{
    femenuitem_t *mi = &(currentFEMenu->items[currentFEMenu->itemon]);
    int i;

    // exiting?
    if(frontend_state == FE_STATE_EXITING)
    {
        if(joybmenu_confirm >= 0 && (joybuttons & (1 << joybmenu_confirm)))
            I_Quit();
        else if(joybuttons)
        {
            frontend_state = FE_STATE_MAINMENU;
            I_StartVoice(NULL);
        }
        return;
    }
    else if(frontend_state != FE_STATE_MAINMENU)
        return; // no joy input handled here except in main menu state

	for(i = 0; i < JOY_NUM_BUTTONS + 16; i++)
    {
        if(!(joybuttons & (1 << i)))
            continue;

        i_seejoysticks = true;
        i_seemouses = false;

        if(i == joybmenu_back)
        {
            FE_PopMenu(false);
        }
        else if(i == joybmenu_up)
        {
            FE_HandleMenuUp();
        }
        else if(i == joybmenu_down)
        {
            FE_HandleMenuDown();
        }
        else if(i == joybmenu_left)
        {
            FE_HandleMenuLeft(mi);
        }
        else if(i == joybmenu_right)
        {
            FE_HandleMenuRight(mi);
        }
        else if(i == joybmenu_forward)
        {
            FE_HandleMenuForward(mi);
        }
    }
}
コード例 #5
0
ファイル: d_main.c プロジェクト: gamebytes/doomretro
static void D_FirstUse(void)
{
    LPCWSTR msg = L"Thank you for downloading DOOM RETRO!\n\n"
                  L"Please note that, as with all DOOM source ports, no actual map data is "
                  L"distributed with DOOM RETRO.\n\n"
                  L"In the dialog box that follows, please navigate to where an official "
                  L"release of DOOM or DOOM II has been installed and select an \u201cIWAD "
                  L"file\u201d that DOOM RETRO requires (such as DOOM.WAD or "
                  L"DOOM2.WAD). Additional \u201cPWAD files\u201d may also be selected by "
                  L"CTRL-clicking on them.";

    if (MessageBoxW(NULL, msg, L"DOOM RETRO", MB_ICONINFORMATION | MB_OKCANCEL) == IDCANCEL)
        I_Quit(false);
}
コード例 #6
0
ファイル: fe_frontend.c プロジェクト: dotfloat/restrife
//
// Handle a keydown event
//
static void FE_HandleKey(SDL_Event *ev)
{
    femenuitem_t *mi = &(currentFEMenu->items[currentFEMenu->itemon]);

    int key = TranslateKey(&(ev->key.keysym));

    // exiting state
    if(frontend_state == FE_STATE_EXITING)
    {
        if(key == key_menu_confirm)
            I_Quit();
        else
        {
            frontend_state = FE_STATE_MAINMENU;
            I_StartVoice(NULL);
        }
        return;
    }

    // key input state
    if(frontend_state == FE_STATE_KEYINPUT)
    {
        if(FE_SetKeybinding(fe_kbitem, key))
            frontend_state = FE_STATE_MAINMENU;
        return;
    }

    // mouse button input state
    if(frontend_state == FE_STATE_MBINPUT)
    {
        if(key == KEY_BACKSPACE)
            FE_ClearMouseButton(fe_kbitem);
        return;
    }

    if(key == key_menu_forward)
    {
        FE_HandleMenuForward(mi);
    }
    else if(key == key_menu_left)
    {
        FE_HandleMenuLeft(mi);
    }
    else if(key == key_menu_right)
    {
        FE_HandleMenuRight(mi);
    }
    else if(key == key_menu_up)
    {
        FE_HandleMenuUp();
    }
    else if(key == key_menu_down)
    {
        FE_HandleMenuDown();
    }
    else if(key == key_menu_activate)
    {
        FE_PopMenu(false);
    }
    else
    {
        char ch;

        // jump to item by first letter
		if(!ev->key.keysym.sym || ev->key.keysym.sym >= 0x7f)
            return;

		ch = (char)(ev->key.keysym.sym & 0x7f);
        ch = tolower(ch);

        if(isalnum(ch))
        {
            int n = currentFEMenu->itemon;
            do
            {
                ++n;
                if(currentFEMenu->items[n].type == FE_MITEM_END)
                    n = 0;

                if(FE_IsSelectable(&(currentFEMenu->items[n])))
                {
                    if(tolower(currentFEMenu->items[n].description[0]) == ch)
                    {
                        if(n != currentFEMenu->itemon)
                        {
                            S_StartSound(NULL, sfx_pstop);
                            if(merchantOn)
                                FE_MerchantSetState(S_MRGT_00);
                        }
                        currentFEMenu->itemon = n;
                        break;
                    }
                }
            }
            while(n != currentFEMenu->itemon);
        }
    }
}
コード例 #7
0
ファイル: i_system.c プロジェクト: ComputerNerd/cgdoom
void I_StartTic (void)
{
    static event_t event = {(evtype_t)0,0,0,0};
    static int iOldKey = 0;
    int iKey = PRGM_GetKey();
    int iFilter = 1;
    switch(iKey)
    {
    case KEY_PRGM_POWER:CGCheat();break;
    case 32:R_SetViewSizeChange(-1);break;
    case 42:R_SetViewSizeChange(1);break;
    case 25:CGSwitchClip();break;
    case 65:CGFreeMem();break;
    case 58:CGRefreshSwitch();break;
        break;

    default:iFilter = 0;
    }
    if(iFilter)
    {
        while(PRGM_GetKey());
        return;
    }
    if(iKey == iOldKey)
    {
        return;
    }
    if(iOldKey)
    {
        event.type= ev_keyup;
        D_PostEvent(&event);
    }
    iOldKey = iKey;
    if(!iKey)
    {
        return;
    }
    event.type= ev_keydown;
    switch(iKey)
    {
    case KEY_PRGM_LEFT:event.data1 = KEY_LEFTARROW;break;
    case KEY_PRGM_RIGHT:event.data1 = KEY_RIGHTARROW;break;
    case KEY_PRGM_UP:event.data1 = KEY_UPARROW;break;
    case KEY_PRGM_DOWN:event.data1 = KEY_DOWNARROW;break;
    case KEY_PRGM_RETURN:event.data1 = ' ';break;
    case KEY_PRGM_ALPHA:event.data1 = KEY_RCTRL;break;
    case KEY_PRGM_MENU:I_Quit();break;
    case KEY_PRGM_F1:event.data1 = '1';break;
    case KEY_PRGM_F2:event.data1 = '2';break;
    case KEY_PRGM_F3:event.data1 = '3';break;
    case KEY_PRGM_F4:event.data1 = '4';break;
    case KEY_PRGM_F5:event.data1 = '5';break;
    case KEY_PRGM_F6:event.data1 = '6';break;
    case KEY_PRGM_SHIFT:event.data1 = '7';break;
    case KEY_PRGM_EXIT:event.data1 = KEY_TAB;break;
    case KEY_PRGM_OPTN:event.data1 = KEY_PAUSE;break;
    case 61:event.data1 = KEY_SRIGHTARROW;break;
    case 71:event.data1 = KEY_SLEFTARROW;break;
    default:return;
    }
    D_PostEvent(&event);
}
コード例 #8
0
ファイル: g_game.c プロジェクト: ProfessorKaos64/Doom64EX
static CMD(Quit) {
    I_Quit();
}
コード例 #9
0
ファイル: net_gui.c プロジェクト: kevans91/strife-ve
//
// haleyjd 20141022: [SVE] Alternate waiting on Steam clients
//
void NET_WaitForSteamLaunch(void)
{
    boolean isServer = (net_SteamNodeType == NET_STEAM_SERVER);
    const char *strConn = "Connecting Netgame";
    char numConn[64];
    char pressStr[64];
    char pressStr2[64];
    int strConnWidth, pressStrWidth, pressStrX, numConnWidth;
    const char *keyActivateName = GetNameForKey(key_menu_activate);
    const char *keyForwardName  = GetNameForKey(key_menu_forward);

    if(!keyActivateName)
        keyActivateName = "key_menu_activate";
    if(!keyForwardName)
        keyForwardName  = "key_menu_forward";

    M_snprintf(pressStr, sizeof(pressStr), "(Press %s to cancel%c",
               keyActivateName, isServer ? ',' : ')');
    if(isServer)
    {
        M_snprintf(pressStr2, sizeof(pressStr2), "%s to start now)",
                   keyForwardName);
    }
    strConnWidth  = V_BigFontStringWidth(strConn);
    pressStrWidth = M_StringWidth(pressStr);
    pressStrX     = (SCREENWIDTH - pressStrWidth) / 2;

    expected_nodes = net_SteamNumNodes;

    while(net_waiting_for_launch)
    {
        event_t *ev;

        CheckAutoLaunch();

        I_StartTic();
        
        while((ev = D_PopEvent()))
        {
            switch(ev->type)
            {
            case ev_keydown:
                if(ev->data1 == key_menu_activate)
                    I_Quit();
                if(ev->data1 == key_menu_forward && isServer)
                    StartGame(NULL, NULL);
                break;
            default:
                break;
            }
        }

        if(use3drenderer)
            RB_ClearBuffer(GLCB_COLOR);

        M_snprintf(numConn, sizeof(numConn), "%d of %d nodes connected",
                   NumConnected(), net_SteamNumNodes);
        numConnWidth = M_StringWidth(numConn);

        V_DrawFilledBox(0, 0, SCREENWIDTH, SCREENHEIGHT, 0);
        V_WriteBigText(strConn, (SCREENWIDTH - strConnWidth)/2, 60);
        M_WriteText((SCREENWIDTH - numConnWidth)/2, 100, numConn);
        M_WriteText(pressStrX, 112, pressStr);
        if(isServer)
            M_WriteText(pressStrX+12, 124, pressStr2);

        NET_CL_Run();
        NET_SV_Run();

        if(!net_client_connected)
            I_Error("Lost connection to server");

        I_FinishUpdate();
        I_Sleep(100);        
    }
}
コード例 #10
0
ファイル: d_main.c プロジェクト: Logan-A/SRB2-Public
//
// D_SRB2Main
//
void D_SRB2Main(void)
{
	INT32 p;
	char srb2[82]; // srb2 title banner
	char title[82];

	INT32 pstartmap = 1;
	boolean autostart = false;

	// keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined (_WIN32_WCE) && !defined(NOTERMIOS)
	if (setvbuf(stderr, NULL, _IOFBF, 1000))
		DEBPRINT("setvbuf didnt work\n");
#endif

#ifdef GETTEXT
	// initialise locale code
	M_StartupLocale();
#endif

	// get parameters from a response file (eg: srb2 @parms.txt)
	M_FindResponseFile();

	// MAINCFG is now taken care of where "OBJCTCFG" is handled
	G_LoadGameSettings();

	// identify the main IWAD file to use
	IdentifyVersion();

#if !defined (_WIN32_WCE) && !defined(NOTERMIOS)
	setbuf(stdout, NULL); // non-buffered output
#endif

#if defined (_WIN32_WCE) //|| defined (_DEBUG) || defined (GP2X)
	devparm = !M_CheckParm("-nodebug");
#else
	devparm = M_CheckParm("-debug");
#endif

	// for dedicated server
#if !defined (_WINDOWS) //already check in win_main.c
	dedicated = M_CheckParm("-dedicated") != 0;
#endif

	strcpy(title, "Sonic Robo Blast 2");
	strcpy(srb2, "Sonic Robo Blast 2");
	D_MakeTitleString(srb2);

#ifdef PC_DOS
	D_Titlebar(srb2, title);
#else
	CONS_Printf("SRB2"VERSIONSTRING"\n");
#endif

#if defined (__OS2__) && !defined (SDL)
	// set PM window title
	snprintf(pmData->title, sizeof (pmData->title),
		"Sonic Robo Blast 2" VERSIONSTRING ": %s",
		title);
	pmData->title[sizeof (pmData->title) - 1] = '\0';
#endif

	if (devparm)
		CONS_Printf("%s", M_GetText("Development mode ON.\n"));

	// default savegame
	strcpy(savegamename, SAVEGAMENAME"%u.ssg");

	{
		const char *userhome = D_Home(); //Alam: path to home

		if (!userhome)
		{
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined (DC) && !defined (PSP) && !defined(GP2X)
			I_Error("%s", M_GetText("Please set $HOME to your home directory\n"));
#elif defined (_WIN32_WCE) && 0
			if (dedicated)
				snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/d"CONFIGFILENAME);
			else
				snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/"CONFIGFILENAME);
#else
			if (dedicated)
				snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME);
			else
				snprintf(configfile, sizeof configfile, CONFIGFILENAME);
#endif
		}
		else
		{
			// use user specific config file
#ifdef DEFAULTDIR
			snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
			snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home);
			if (dedicated)
				snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home);
			else
				snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2home);

			// can't use sprintf since there is %u in savegamename
			strcatbf(savegamename, srb2home, PATHSEP);

			I_mkdir(srb2home, 0700);
#else
			snprintf(srb2home, sizeof srb2home, "%s", userhome);
			snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
			if (dedicated)
				snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome);
			else
				snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome);

			// can't use sprintf since there is %u in savegamename
			strcatbf(savegamename, userhome, PATHSEP);
#endif
		}

		configfile[sizeof configfile - 1] = '\0';

#ifdef _arch_dreamcast
	strcpy(downloaddir, "/ram"); // the dreamcast's TMP
#endif
	}

	if (M_CheckParm("-password") && M_IsNextParm())
	{
		const char *pw = M_GetNextParm();
		strncpy(adminpassword, pw, 8);
		if (strlen(pw) < 8)
		{
			size_t z;
			for (z = strlen(pw); z < 8; z++)
				adminpassword[z] = 'a';
		}
	}
	else
	{
		size_t z;
		srand((unsigned int)time(NULL));
		for (z = 0; z < 8; z++)
			adminpassword[z] = (char)(rand() & 127);
	}
	adminpassword[8] = '\0';

	// add any files specified on the command line with -file wadfile
	// to the wad list
	if (!(M_CheckParm("-connect")))
	{
		if (M_CheckParm("-file"))
		{
			// the parms after p are wadfile/lump names,
			// until end of parms or another - preceded parm
			while (M_IsNextParm())
			{
				const char *s = M_GetNextParm();

				if (s) // Check for NULL?
				{
					if (!W_VerifyNMUSlumps(s))
						modifiedgame = true;
					D_AddFile(s);
				}
			}
		}
	}

	// get map from parms

	if (M_CheckParm("-server") || dedicated)
		netgame = server = true;

	if (M_CheckParm("-warp") && M_IsNextParm())
	{
		pstartmap = atoi(M_GetNextParm());
		if (!M_CheckParm("-server"))
			modifiedgame = true;
		autostart = true;
		savemoddata = false;
	}

	CONS_Printf("%s", M_GetText("Z_Init: Init zone memory allocation daemon. \n"));
	Z_Init();

	// adapt tables to SRB2's needs, including extra slots for dehacked file support
	P_PatchInfoTables();

	CONS_Printf("%s", M_GetText("W_Init: Init WADfiles.\n"));

	//---------------------------------------------------- READY TIME
	// we need to check for dedicated before initialization of some subsystems

	CONS_Printf("I_StartupTimer...\n");
	I_StartupTimer();

	// Make backups of some SOCcable tables.
	P_BackupTables();

	// load wad, including the main wad file
	if (!W_InitMultipleFiles(startupwadfiles))
#ifdef _DEBUG
		CONS_Error(M_GetText("A WAD file was not found or not valid\n"));
#else
		I_Error("%s", M_GetText("A WAD file was not found or not valid\n"));
#endif
	D_CleanFile();

	// Check MD5s of autoloaded files
	W_VerifyFileMD5(0, "1f698dd35bcedb04631568a84a97d72b"); // srb2.srb
	W_VerifyFileMD5(1, "86ae3f9179c64358d1c88060e41bd415"); // zones.dta
	W_VerifyFileMD5(2, "f699d4702b9b505db621e5ad5af4f352"); // sonic.plr
	W_VerifyFileMD5(3, "dfbbc38080485c70a84a57bb734ceee9"); // tails.plr
	W_VerifyFileMD5(4, "1ea958e2aee87b6995226a120ba3eaac"); // knux.plr
	W_VerifyFileMD5(5, "8f702416c15060cd3c53c71b91116914"); // rings.wpn
	W_VerifyFileMD5(6, "6b1cf9b41e41a46ac58606dc6e7c9e05"); // drill.dta
	W_VerifyFileMD5(7, "8d080c050ecf03691562aa7b60156fec"); // soar.dta

	// don't check music.dta because people like to modify it, and it doesn't matter if they do
	// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.


	mainwads = 8; // there are 8 wads not to unload

/* TODO: incorporate this!
	CONS_Printf("%s", "===========================================================================\n"
	"                       Sonic Robo Blast II!\n"
	"                       by Sonic Team Junior\n"
	"                       http://www.srb2.org\n"
	"      This is a modified version. Go to our site for the original.\n"
	"===========================================================================\n");
*/

	// Check and print which version is executed.
	CONS_Printf("%s", "===========================================================================\n"
	"                   We hope you enjoy this game as\n"
	"                     much as we did making it!\n"
	"                            ...wait. =P\n"
	"===========================================================================\n");

	cht_Init();

	//---------------------------------------------------- READY SCREEN
	// we need to check for dedicated before initialization of some subsystems

	CONS_Printf("I_StartupGraphics...\n");
	I_StartupGraphics();

	//--------------------------------------------------------- CONSOLE
	// setup loading screen
	SCR_Startup();

	// we need the font of the console
	CONS_Printf("%s", M_GetText("HU_Init: Setting up heads up display.\n"));
	HU_Init();

	COM_Init();
	// libogc has a CON_Init function, we must rename SRB2's CON_Init in WII/libogc
#ifndef _WII
	CON_Init();
#else
	CON_InitWii();
#endif

	D_RegisterServerCommands();
	D_RegisterClientCommands(); // be sure that this is called before D_CheckNetGame
	R_RegisterEngineStuff();
	S_RegisterSoundStuff();

	I_RegisterSysCommands();

	//--------------------------------------------------------- CONFIG.CFG
	M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"

	if (!M_CheckParm("-resetdata"))
		G_LoadGameData();

#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
	VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
#endif

	// set user default mode or mode set at cmdline
	SCR_CheckDefaultMode();

	wipegamestate = gamestate;

	P_InitMapHeaders();
	savedata.lives = 0; // flag this as not-used

	//------------------------------------------------ COMMAND LINE PARAMS

	// Initialize CD-Audio
	if (M_CheckParm("-usecd") && !dedicated)
		I_InitCD();

	if (M_CheckParm("-nodownloading"))
		COM_BufAddText("downloading 0\n");

	CONS_Printf("%s", M_GetText("M_Init: Init miscellaneous info.\n"));
	M_Init();

	CONS_Printf("%s", M_GetText("R_Init: Init SRB2 refresh daemon - "));
	R_Init();

	// setting up sound
	CONS_Printf("%s", M_GetText("S_Init: Setting up sound.\n"));
	if (M_CheckParm("-nosound"))
		nosound = true;
	if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
		nomidimusic = nodigimusic = true;
	else
	{
		if (M_CheckParm("-nomidimusic"))
			nomidimusic = true; ; // WARNING: DOS version initmusic in I_StartupSound
		if (M_CheckParm("-nodigmusic"))
			nodigimusic = true; // WARNING: DOS version initmusic in I_StartupSound
	}
	I_StartupSound();
	I_InitMusic();
	S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);

	CONS_Printf("%s", M_GetText("ST_Init: Init status bar.\n"));
	ST_Init();

	if (M_CheckParm("-internetserver"))
		CV_SetValue(&cv_internetserver, 1);

	// init all NETWORK
	CONS_Printf("%s", M_GetText("D_CheckNetGame: Checking network game status.\n"));
	if (D_CheckNetGame())
		autostart = true;

	// check for a driver that wants intermission stats
	// start the apropriate game based on parms
	if (M_CheckParm("-record") && M_IsNextParm())
	{
		G_RecordDemo(M_GetNextParm());
		autostart = true;
	}

	p = M_CheckParm("-timetic");
	if (p)
		CV_Set(&cv_timetic, "On");

	if (!autostart)
		M_PushSpecialParameters(); // push all "+" parameters at the command buffer

	// demo doesn't need anymore to be added with D_AddFile()
	p = M_CheckParm("-playdemo");
	if (!p)
		p = M_CheckParm("-timedemo");
	if (p && M_IsNextParm())
	{
		char tmp[MAX_WADPATH];
		// add .lmp to identify the EXTERNAL demo file
		// it is NOT possible to play an internal demo using -playdemo,
		// rather push a playdemo command.. to do.

		strcpy(tmp, M_GetNextParm());
		// get spaced filename or directory
		while (M_IsNextParm())
		{
			strcat(tmp, " ");
			strcat(tmp, M_GetNextParm());
		}

		FIL_DefaultExtension(tmp, ".lmp");

		CONS_Printf(M_GetText("Playing demo %s.\n"), tmp);

		if (M_CheckParm("-playdemo"))
		{
			singledemo = true; // quit after one demo
			G_DeferedPlayDemo(tmp);
		}
		else
			G_TimeDemo(tmp);

		G_SetGamestate(GS_NULL);
		wipegamestate = GS_NULL;
		return;
	}

	if (M_CheckParm("-ultimatemode"))
	{
		autostart = true;
		ultimatemode = true;
	}

	if (autostart || netgame || M_CheckParm("+connect") || M_CheckParm("-connect"))
	{
		gameaction = ga_nothing;

		CV_ClearChangedFlags();

		// Do this here so if you run SRB2 with eg +timelimit 5, the time limit counts
		// as having been modified for the first game.
		M_PushSpecialParameters(); // push all "+" parameter at the command buffer

		if (M_CheckParm("-gametype") && M_IsNextParm())
		{
			// from Command_Map_f
			INT32 j;
			INT16 newgametype = -1;
			const char *sgametype = M_GetNextParm();

			for (j = 0; gametype_cons_t[j].strvalue; j++)
				if (!strcasecmp(gametype_cons_t[j].strvalue, sgametype))
				{
					if (gametype_cons_t[j].value == GTF_TEAMMATCH)
					{
						newgametype = GT_MATCH;
						CV_SetValue(&cv_matchtype, 1);
					}
					else if (gametype_cons_t[j].value == GTF_CLASSICRACE)
					{
						newgametype = GT_RACE;
						CV_SetValue(&cv_racetype, 1);
					}
					else if (gametype_cons_t[j].value == GTF_HIDEANDSEEK)
					{
						newgametype = GT_TAG;
						CV_SetValue(&cv_tagtype, 1);
					}
					else
						newgametype = (INT16)gametype_cons_t[j].value;

					break;
				}
			if (!gametype_cons_t[j].strvalue) // reached end of the list with no match
			{
				j = atoi(sgametype); // assume they gave us a gametype number, which is okay too
				if (j >= 0 && j < NUMGAMETYPES)
					newgametype = (INT16)j;
			}

			if (newgametype != -1)
			{
				j = gametype;
				gametype = newgametype;
				D_GameTypeChanged(j);
			}
		}

		if (server && !M_CheckParm("+map") && !M_CheckParm("+connect")
			&& !M_CheckParm("-connect"))
		{
			D_MapChange(pstartmap, gametype, ultimatemode, 1, 0, false, false);
		}
	}
	else
		F_StartIntro(); // Tails 03-03-2002

	if (dedicated && server)
	{
		pagename = "TITLESKY";
		levelstarttic = gametic;
		G_SetGamestate(GS_LEVEL);
		if (!P_SetupLevel(gamemap, false))
			I_Quit(); // fail so reset game stuff
	}
}
コード例 #11
0
ファイル: d_main.c プロジェクト: M-Code/chocolate-doom
//
// This cycles through the demo sequences.
// FIXME - version dependend demo numbers?
//
// [STRIFE] Modified for the opening slideshow and the exit screen
//
void D_DoAdvanceDemo (void)
{
    players[consoleplayer].playerstate = PST_LIVE;  // not reborn
    advancedemo = false;
    usergame = false;               // no save / end game here
    paused = false;
    gameaction = ga_nothing;
    
    // villsa 09/12/10: [STRIFE] converted pagetics to ticrate
    switch (demosequence)
    {
    case -5: // exit the game
        I_Quit();
        return;
    case -4: // show exit screen
        menuactive = false;
        pagetic = 3*TICRATE;
        gamestate = GS_DEMOSCREEN;
        pagename = DEH_String("PANEL7");
        S_StartMusic(mus_fast);
        if(isdemoversion)
            demosequence = -3; // show Velocity logo
        else
            demosequence = -5; // exit
        return;
    case -3: // show Velocity logo for demo version
        pagetic = 6*TICRATE;
        gamestate = GS_DEMOSCREEN;
        pagename = DEH_String("vellogo");
        demosequence = -5; // exit
        return;
    case -2: // title screen
        pagetic = 6*TICRATE;
        gamestate = GS_DEMOSCREEN;
        pagename = DEH_String("TITLEPIC");
        S_StartMusic(mus_logo);
        demosequence = -1; // start intro cinematic
        return;
    case -1: // start of intro cinematic
        pagetic = 10;
        gamestate = GS_DEMOSCREEN;
        pagename = DEH_String("PANEL0");
        S_StartSound(NULL, sfx_rb2act);
        wipegamestate = -1;
        break;
    case 0: // Rogue logo
        pagetic = 4*TICRATE;
        gamestate = GS_DEMOSCREEN;
        pagename = DEH_String("RGELOGO");
        wipegamestate = -1;
        break;
    case 1:
        pagetic = 7*TICRATE;              // The comet struck our planet without
        gamestate = GS_DEMOSCREEN;        // warning.We lost our paradise in a 
        pagename = DEH_String("PANEL1");  // single, violent stroke.
        I_StartVoice(DEH_String("pro1")); 
        S_StartMusic(mus_intro);
        break;
    case 2:
        pagetic = 9*TICRATE;              // The impact released a virus which 
        gamestate = GS_DEMOSCREEN;        // swept through the land and killed 
        pagename = DEH_String("PANEL2");  // millions. They turned out to be 
        I_StartVoice(DEH_String("pro2")); // the lucky ones...
        break;
    case 3:
        pagetic = 12*TICRATE;             // For those that did not die became 
        gamestate = GS_DEMOSCREEN;        // mutations of humanity. Some became
        pagename = DEH_String("PANEL3");  // fanatics who heard the voice of a
        I_StartVoice(DEH_String("pro3")); // malignant God in their heads, and 
        break;                            // called themselves the Order.
    case 4:
        pagetic = 11*TICRATE;             // Those of us who were deaf to this
        pagename = DEH_String("PANEL4");  // voice suffer horribly and are 
        gamestate = GS_DEMOSCREEN;        // forced to serve these ruthless
        I_StartVoice(DEH_String("pro4")); // psychotics, who wield weapons more
        break;                            // powerful than anything we can muster.
    case 5:
        pagetic = 10*TICRATE;             // They destroy our women and children,
        gamestate = GS_DEMOSCREEN;        // so that we must hide them underground,
        pagename = DEH_String("PANEL5");  // and live like animals in constant
        I_StartVoice(DEH_String("pro5")); // fear for our lives.
        break;
    case 6:                               // But there are whispers of discontent.
        pagetic = 16*TICRATE;             // If we organize, can we defeat our
        gamestate = GS_DEMOSCREEN;        // masters? Weapons are being stolen,
        pagename = DEH_String("PANEL6");  // soldiers are being trained. A 
        I_StartVoice(DEH_String("pro6")); // Movement is born! Born of lifelong 
        break;                            // STRIFE!
    case 7: // titlepic again - unused...
        pagetic = 9*TICRATE;
        gamestate = GS_DEMOSCREEN;
        pagename = DEH_String("TITLEPIC");
        wipegamestate = -1;
        break;
    case 8: // demo
        ClearTmp();
        pagetic = 9*TICRATE;
        G_DeferedPlayDemo(DEH_String("demo1"));
        break;
    case 9: // velocity logo? - unused...
        pagetic = 6*TICRATE;
        gamestate = GS_DEMOSCREEN;
        pagename = DEH_String("vellogo");
        wipegamestate = -1;
        break;
    case 10: // credits
        gamestate = GS_DEMOSCREEN;
        pagetic = 12*TICRATE;
        pagename = DEH_String("CREDIT");
        wipegamestate = -1;
        break;
    default:
        break;
    }

    ++demosequence;

    if(demosequence > 11)
        demosequence = -2;
    if(demosequence == 7 || demosequence == 9)
        ++demosequence;
}
コード例 #12
0
ファイル: net_gui.c プロジェクト: fielder/chocolate-doom
static void EscapePressed(TXT_UNCAST_ARG(widget), void *unused)
{
    TXT_Shutdown();
    I_Quit();
}
コード例 #13
0
void I_GetEvent(void)
{
    SDL_Event sdlevent;
    event_t event;

    // possibly not needed
    
    SDL_PumpEvents();

    // put event-grabbing stuff in here
    
    while (SDL_PollEvent(&sdlevent))
    {
        // ignore mouse events when the window is not focused

        if (!window_focused 
         && (sdlevent.type == SDL_MOUSEMOTION
          || sdlevent.type == SDL_MOUSEBUTTONDOWN
          || sdlevent.type == SDL_MOUSEBUTTONUP))
        {
            continue;
        }

        if (screensaver_mode && sdlevent.type == SDL_QUIT)
        {
            I_Quit();
        }

        // process event
        
        switch (sdlevent.type)
        {
            case SDL_KEYDOWN:
                event.type = ev_keydown;
                event.data1 = TranslateKey(&sdlevent.key.keysym);

                // If Vanilla keyboard mapping enabled, the keyboard
                // scan code is used to give the character typed.
                // This does not change depending on keyboard layout.
                // If you have a German keyboard, pressing 'z' will
                // give 'y', for example.  It is desirable to be able
                // to fix this so that people with non-standard 
                // keyboard mappings can type properly.  If vanilla
                // mode is disabled, use the properly translated 
                // version.

                if (vanilla_keyboard_mapping)
                {
                    event.data2 = event.data1;
                }
                else
                {
                    event.data2 = sdlevent.key.keysym.unicode;
                }

                if (event.data1 != 0)
                {
                    D_PostEvent(&event);
                }
                break;

            case SDL_KEYUP:
                event.type = ev_keyup;
                event.data1 = TranslateKey(&sdlevent.key.keysym);

                if (event.data1 != 0)
                {
                    D_PostEvent(&event);
                }
                break;

                /*
            case SDL_MOUSEMOTION:
                event.type = ev_mouse;
                event.data1 = MouseButtonState();
                event.data2 = AccelerateMouse(sdlevent.motion.xrel);
                event.data3 = -AccelerateMouse(sdlevent.motion.yrel);
                D_PostEvent(&event);
                break;
                */

            case SDL_MOUSEBUTTONDOWN:
		if (usemouse && !nomouse)
		{
                    event.type = ev_mouse;
                    event.data1 = MouseButtonState();
                    event.data2 = event.data3 = 0;
                    D_PostEvent(&event);
		}
                break;

            case SDL_MOUSEBUTTONUP:
		if (usemouse && !nomouse)
		{
                    event.type = ev_mouse;
                    event.data1 = MouseButtonState();
                    event.data2 = event.data3 = 0;
                    D_PostEvent(&event);
		}
                break;

            case SDL_QUIT:
                // bring up the "quit doom?" prompt
                S_StartSound(NULL,sfx_swtchn);
                M_QuitDOOM(0);
                break;

            case SDL_ACTIVEEVENT:
                // need to update our focus state
                UpdateFocus();
                break;

            case SDL_VIDEOEXPOSE:
                palette_to_set = true;
                break;

            default:
                break;
        }
    }
}
コード例 #14
0
ファイル: MN_MENU.C プロジェクト: OpenSourcedGames/Heretic
boolean MN_Responder(event_t *event)
{
	int key;
	int i;
	MenuItem_t *item;
	extern boolean automapactive;
	static boolean shiftdown;
	extern void D_StartTitle(void);
	extern void G_CheckDemoStatus(void);
	char *textBuffer;

	if(event->data1 == KEY_RSHIFT)
	{
		shiftdown = (event->type == ev_keydown);
	}
	if(event->type != ev_keydown)
	{
		return(false);
	}
	key = event->data1;
	if(InfoType)
	{
		if(shareware)
		{
			InfoType = (InfoType+1)%5;
		}
		else
		{
			InfoType = (InfoType+1)%4;
		}
		if(key == KEY_ESCAPE)
		{
			InfoType = 0;
		}
		if(!InfoType)
		{
			paused = false;
			MN_DeactivateMenu();
			SB_state = -1; //refresh the statbar
			BorderNeedRefresh = true;
		}
		S_StartSound(NULL, sfx_dorcls);
		return(true); //make the info screen eat the keypress
	}

	if(ravpic && key == KEY_F1)
	{
		G_ScreenShot();
		return(true);
	}

	if(askforquit)
	{
		switch(key)
		{
			case 'y':
				if(askforquit)
				{
					switch(typeofask)
					{
						case 1:
							G_CheckDemoStatus();
							I_Quit();
							break;
						case 2:
							players[consoleplayer].messageTics = 0;
								//set the msg to be cleared
							players[consoleplayer].message = NULL;
							typeofask = 0;
							askforquit = false;
							paused = false;
							I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE));
							D_StartTitle(); // go to intro/demo mode.
							break;
						case 3:
							P_SetMessage(&players[consoleplayer], "QUICKSAVING....", false);
							FileMenuKeySteal = true;
							SCSaveGame(quicksave-1);
							askforquit = false;
							typeofask = 0;
							BorderNeedRefresh = true;
							return true;
						case 4:
							P_SetMessage(&players[consoleplayer], "QUICKLOADING....", false);
							SCLoadGame(quickload-1);
							askforquit = false;
							typeofask = 0;
							BorderNeedRefresh = true;
							return true;
						default:
							return true; // eat the 'y' keypress
					}
				}
				return false;
			case 'n':
			case KEY_ESCAPE:
				if(askforquit)
				{
					players[consoleplayer].messageTics = 1; //set the msg to be cleared
					askforquit = false;
					typeofask = 0;
					paused = false;
					UpdateState |= I_FULLSCRN;
					BorderNeedRefresh = true;
					return true;
				}
				return false;
		}
		return false; // don't let the keys filter thru
	}
	if(MenuActive == false && !chatmodeon)
	{
		switch(key)
		{
			case KEY_MINUS:
				if(automapactive)
				{ // Don't screen size in automap
					return(false);
				}
				SCScreenSize(LEFT_DIR);
				S_StartSound(NULL, sfx_keyup);
				BorderNeedRefresh = true;
				UpdateState |= I_FULLSCRN;
				return(true);
			case KEY_EQUALS:
				if(automapactive)
				{ // Don't screen size in automap
					return(false);
				}
				SCScreenSize(RIGHT_DIR);
				S_StartSound(NULL, sfx_keyup);
				BorderNeedRefresh = true;
				UpdateState |= I_FULLSCRN;
				return(true);
#ifndef __NeXT__
			case KEY_F1: // help screen
				SCInfo(0); // start up info screens
				MenuActive = true;
				return(true);
			case KEY_F2: // save game
				if(gamestate == GS_LEVEL && !demoplayback)
				{
					MenuActive = true;
					FileMenuKeySteal = false;
					MenuTime = 0;
					CurrentMenu = &SaveMenu;
					CurrentItPos = CurrentMenu->oldItPos;
					if(!netgame && !demoplayback)
					{
						paused = true;
					}
					S_StartSound(NULL, sfx_dorcls);
					slottextloaded = false; //reload the slot text, when needed
				}
				return true;
			case KEY_F3: // load game
				if(SCNetCheck(2))
				{
					MenuActive = true;
					FileMenuKeySteal = false;
					MenuTime = 0;
					CurrentMenu = &LoadMenu;
					CurrentItPos = CurrentMenu->oldItPos;
					if(!netgame && !demoplayback)
					{
						paused = true;
					}
					S_StartSound(NULL, sfx_dorcls);
					slottextloaded = false; //reload the slot text, when needed
				}
				return true;
			case KEY_F4: // volume
				MenuActive = true;
				FileMenuKeySteal = false;
				MenuTime = 0;
				CurrentMenu = &Options2Menu;
				CurrentItPos = CurrentMenu->oldItPos;
				if(!netgame && !demoplayback)
				{
					paused = true;
				}
				S_StartSound(NULL, sfx_dorcls);
				slottextloaded = false; //reload the slot text, when needed
				return true;
			case KEY_F5: // F5 isn't used in Heretic. (detail level)
				return true;
			case KEY_F6: // quicksave
				if(gamestate == GS_LEVEL && !demoplayback)
				{
					if(!quicksave || quicksave == -1)
					{
						MenuActive = true;
						FileMenuKeySteal = false;
						MenuTime = 0;
						CurrentMenu = &SaveMenu;
						CurrentItPos = CurrentMenu->oldItPos;
						if(!netgame && !demoplayback)
						{
							paused = true;
						}
						S_StartSound(NULL, sfx_dorcls);
						slottextloaded = false; //reload the slot text, when needed
						quicksave = -1;
						P_SetMessage(&players[consoleplayer],
							"CHOOSE A QUICKSAVE SLOT", true);
					}
					else
					{
						askforquit = true;
						typeofask = 3;
						if(!netgame && !demoplayback)
						{
							paused = true;
						}
						S_StartSound(NULL, sfx_chat);
					}
				}
				return true;
			case KEY_F7: // endgame
				if(gamestate == GS_LEVEL && !demoplayback)
				{
					S_StartSound(NULL, sfx_chat);
					SCEndGame(0);
				}
				return true;
			case KEY_F8: // toggle messages
				SCMessages(0);
				return true;
			case KEY_F9: // quickload
				if(!quickload || quickload == -1)
				{
					MenuActive = true;
					FileMenuKeySteal = false;
					MenuTime = 0;
					CurrentMenu = &LoadMenu;
					CurrentItPos = CurrentMenu->oldItPos;
					if(!netgame && !demoplayback)
					{
						paused = true;
					}
					S_StartSound(NULL, sfx_dorcls);
					slottextloaded = false; //reload the slot text, when needed
					quickload = -1;
					P_SetMessage(&players[consoleplayer],
						"CHOOSE A QUICKLOAD SLOT", true);
				}
				else
				{
					askforquit = true;
					if(!netgame && !demoplayback)
					{
						paused = true;
					}
					typeofask = 4;
					S_StartSound(NULL, sfx_chat);
				}
				return true;
			case KEY_F10: // quit
				if(gamestate == GS_LEVEL)
				{
					SCQuitGame(0);
					S_StartSound(NULL, sfx_chat);
				}
				return true;
			case KEY_F11: // F11 - gamma mode correction
				usegamma++;
				if(usegamma > 4)
				{
					usegamma = 0;
				}
				I_SetPalette((byte *)W_CacheLumpName("PLAYPAL", PU_CACHE));
				return true;
#endif
		}

	}

	if(MenuActive == false)
	{
		if(key == KEY_ESCAPE || gamestate == GS_DEMOSCREEN || demoplayback)
		{
			MN_ActivateMenu();
			return(true);
		}
		return(false);
	}
	if(!FileMenuKeySteal)
	{
		item = &CurrentMenu->items[CurrentItPos];
		switch(key)
		{
			case KEY_DOWNARROW:
				do
				{
					if(CurrentItPos+1 > CurrentMenu->itemCount-1)
					{
						CurrentItPos = 0;
					}
					else
					{
						CurrentItPos++;
					}
				} while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
				S_StartSound(NULL, sfx_switch);
				return(true);
				break;
			case KEY_UPARROW:
				do
				{
					if(CurrentItPos == 0)
					{
						CurrentItPos = CurrentMenu->itemCount-1;
					}
					else
					{
						CurrentItPos--;
					}
				} while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
				S_StartSound(NULL, sfx_switch);
				return(true);
				break;
			case KEY_LEFTARROW:
				if(item->type == ITT_LRFUNC && item->func != NULL)
				{
					item->func(LEFT_DIR);
					S_StartSound(NULL, sfx_keyup);
				}
				return(true);
				break;
			case KEY_RIGHTARROW:
				if(item->type == ITT_LRFUNC && item->func != NULL)
				{
					item->func(RIGHT_DIR);
					S_StartSound(NULL, sfx_keyup);
				}
				return(true);
				break;
			case KEY_ENTER:
				if(item->type == ITT_SETMENU)
				{
					SetMenu(item->menu);
				}
				else if(item->func != NULL)
				{
					CurrentMenu->oldItPos = CurrentItPos;
					if(item->type == ITT_LRFUNC)
					{
						item->func(RIGHT_DIR);
					}
					else if(item->type == ITT_EFUNC)
					{
						if(item->func(item->option))
						{
							if(item->menu != MENU_NONE)
							{
								SetMenu(item->menu);
							}
						}
					}
				}
				S_StartSound(NULL, sfx_dorcls);
				return(true);
				break;
			case KEY_ESCAPE:
				MN_DeactivateMenu();
				return(true);
			case KEY_BACKSPACE:
				S_StartSound(NULL, sfx_switch);
				if(CurrentMenu->prevMenu == MENU_NONE)
				{
					MN_DeactivateMenu();
				}
				else
				{
					SetMenu(CurrentMenu->prevMenu);
				}
				return(true);
			default:
				for(i = 0; i < CurrentMenu->itemCount; i++)
				{
					if(CurrentMenu->items[i].text)
					{
						if(toupper(key)
							== toupper(CurrentMenu->items[i].text[0]))
						{
							CurrentItPos = i;
							return(true);
						}
					}
				}
				break;
		}
		return(false);
	}
	else
	{ // Editing file names
		textBuffer = &SlotText[currentSlot][slotptr];
		if(key == KEY_BACKSPACE)
		{
			if(slotptr)
			{
				*textBuffer-- = 0;
				*textBuffer = ASCII_CURSOR;
				slotptr--;
			}
			return(true);
		}
		if(key == KEY_ESCAPE)
		{
			memset(SlotText[currentSlot], 0, SLOTTEXTLEN+2);
			strcpy(SlotText[currentSlot], oldSlotText);
			SlotStatus[currentSlot]--;
			MN_DeactivateMenu();
			return(true);
		}
		if(key == KEY_ENTER)
		{
			SlotText[currentSlot][slotptr] = 0; // clear the cursor
			item = &CurrentMenu->items[CurrentItPos];
			CurrentMenu->oldItPos = CurrentItPos;
			if(item->type == ITT_EFUNC)
			{
				item->func(item->option);
				if(item->menu != MENU_NONE)
				{
					SetMenu(item->menu);
				}
			}
			return(true);
		}
		if(slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE)
		{
			if((key >= 'a' && key <= 'z'))
			{
				*textBuffer++ = key-32;
				*textBuffer = ASCII_CURSOR;
				slotptr++;
				return(true);
			}
			if(((key >= '0' && key <= '9') || key == ' '
				|| key == ',' || key == '.' || key == '-')
				&& !shiftdown)
			{
				*textBuffer++ = key;
				*textBuffer = ASCII_CURSOR;
				slotptr++;
				return(true);
			}
			if(shiftdown && key == '1')
			{
				*textBuffer++ = '!';
				*textBuffer = ASCII_CURSOR;
				slotptr++;
				return(true);
			}
		}
		return(true);
	}
	return(false);
}
コード例 #15
0
ファイル: fe_frontend.c プロジェクト: dotfloat/restrife
//
// Handle events for the frontend.
//
static void FE_Responder(void)
{
    SDL_Event ev;
    int joybuttons;

    FE_UpdateFocus();

    if(FE_InModalNetState())
        return;

    // [SVE] svillarreal
#ifdef _USE_STEAM_
    if(!I_SteamOverlayActive())
    {
#endif
    // run joybind responders?
    if(frontend_state == FE_STATE_JBINPUT)
    {
        FE_JoyBindResponder();
        return;
    }
    else if(frontend_state == FE_STATE_JAINPUT)
    {
        FE_JoyAxisResponder();
        return;
    }

    // poll gamepad
    if((joybuttons = I_JoystickGetButtons()))
        FE_HandleJoyButtons(joybuttons);

    FE_HandleJoyAxes();

    // [SVE] svillarreal
#ifdef _USE_STEAM_
    }
#endif

    while(SDL_PollEvent(&ev))
    {
        switch(ev.type)
        {
        case SDL_KEYDOWN:
            FE_HandleKey(&ev);
            break;
        case SDL_MOUSEBUTTONDOWN:
            i_seemouses = true;
            i_seejoysticks = false;
            if(frontend_state == FE_STATE_MBINPUT)
            {
                // rebind mouse button
                FE_SetMouseButton(fe_kbitem, &ev);
                break;
            }
            switch(ev.button.button)
            {
            case SDL_BUTTON_LEFT:
                FE_HandleLeftMouseButtonDown(&ev);
                break;
            case SDL_BUTTON_RIGHT:
                FE_HandleRightMouseButtonDown(&ev);
                break;
            default:
                break;
            }
            break;
        case SDL_MOUSEMOTION:
            i_seemouses = true;
            i_seejoysticks = false;
            FE_HandleMouseMotion(&ev);
            break;
        case SDL_QUIT:
            I_Quit();
            break;
		case SDL_WINDOWEVENT:
			if (ev.window.type == SDL_WINDOWEVENT_FOCUS_GAINED ||
				ev.window.type == SDL_WINDOWEVENT_FOCUS_LOST)
				FE_UpdateFocus();
            break;
        default:
            break;
        }
    }
}
コード例 #16
0
ファイル: d_main.c プロジェクト: gamebytes/doomretro
//
// D_DoomMainSetup
//
// CPhipps - the old contents of D_DoomMain, but moved out of the main
//  line of execution so its stack space can be freed
static void D_DoomMainSetup(void)
{
    int     p;
    char    file[256];
    int     temp;
    int     choseniwad;

    SDL_Init(0);

    M_FindResponseFile();

    iwadfile = D_FindIWAD();

    modifiedgame = false;

    nomonsters = M_CheckParm("-nomonsters");
    respawnparm = M_CheckParm("-respawn");
    fastparm = M_CheckParm("-fast");
    devparm = M_CheckParm("-devparm");
    if (M_CheckParm("-altdeath"))
        deathmatch = 2;
    else if (M_CheckParm("-deathmatch"))
        deathmatch = 1;

    M_SetConfigDir();

    // turbo option
    p = M_CheckParm("-turbo");
    if (p)
    {
        int        scale = 200;
        extern int forwardmove[2];
        extern int sidemove[2];

        if (p < myargc - 1)
            scale = atoi(myargv[p + 1]);
        if (scale < 10)
            scale = 10;
        if (scale > 400)
            scale = 400;
        forwardmove[0] = forwardmove[0] * scale / 100;
        forwardmove[1] = forwardmove[1] * scale / 100;
        sidemove[0] = sidemove[0] * scale / 100;
        sidemove[1] = sidemove[1] * scale / 100;
    }

    // init subsystems
    V_Init();

    // Load configuration files before initialising other subsystems.
    M_LoadDefaults();

    if (!M_FileExists("doomretro.wad"))
        if (!M_FileExists("doomretro.wad.temp"))
            I_Error("Can't find doomretro.wad.");

    if (iwadfile)
    {
        if (D_AddFile(iwadfile))
            if (runcount < RUNCOUNT_MAX)
                runcount++;
    }
    else 
    {
        if (!runcount)
            D_FirstUse();

        rename("doomretro.wad", "doomretro.wad.temp");

        do
        {
            choseniwad = D_ChooseIWAD();

            if (choseniwad == -1)
            {
                rename("doomretro.wad.temp", "doomretro.wad");
                I_Quit(false);
            }
            else if (!choseniwad)
                PlaySound((LPCTSTR)SND_ALIAS_SYSTEMHAND, NULL, SND_ALIAS_ID | SND_ASYNC);

        } while (!choseniwad);

        rename("doomretro.wad.temp", "doomretro.wad");

        if (runcount < RUNCOUNT_MAX)
            runcount++;
    }
    M_SaveDefaults();

    if (!W_MergeFile("doomretro.wad"))
        if (!W_MergeFile("doomretro.wad.temp"))
            I_Error("Can't find doomretro.wad.");

    if (W_CheckNumForName("BLD2A0") < 0 ||
        W_CheckNumForName("MEDBA0") < 0 ||
        W_CheckNumForName("STBAR2") < 0)
        I_Error("Wrong version of doomretro.wad.");

    p = M_CheckParmsWithArgs("-file", "-pwad", 1);
    if (p > 0)
    {
        for (p = p + 1; p < myargc && myargv[p][0] != '-'; ++p)
        {
            char *filename = uppercase(D_TryFindWADByName(myargv[p]));

            if (W_MergeFile(filename))
            {
                modifiedgame = true;
                if (D_CheckFilename(filename, "NERVE.WAD"))
                    nerve = true;
            }
        }
    }

    if (FREEDOOM && W_CheckNumForName("FREEDM") < 0 && !modifiedgame)
        I_Error("FREEDOOM requires a BOOM-compatible source port, and is therefore"
                "unable to be opened by DOOM RETRO.");

    DMENUPIC = (W_CheckNumForName("DMENUPIC") >= 0);
    M_DOOM = (W_CheckMultipleLumps("M_DOOM") > 1);
    M_EPISOD = (W_CheckMultipleLumps("M_EPISOD") > 1);
    M_GDHIGH = (W_CheckMultipleLumps("M_GDHIGH") > 1);
    M_GDLOW = (W_CheckMultipleLumps("M_GDLOW") > 1);
    M_LOADG = (W_CheckMultipleLumps("M_LOADG") > 1);
    M_LSCNTR = (W_CheckMultipleLumps("M_LSCNTR") > 1);
    M_MSENS = (W_CheckMultipleLumps("M_MSENS") > 1);
    M_MSGOFF = (W_CheckMultipleLumps("M_MSGOFF") > 1);
    M_MSGON = (W_CheckMultipleLumps("M_MSGON") > 1);
    M_NEWG = (W_CheckMultipleLumps("M_NEWG") > 1);
    M_NMARE = (W_CheckMultipleLumps("M_NMARE") > 1);
    M_OPTTTL = (W_CheckMultipleLumps("M_OPTTTL") > 1);
    M_PAUSE = (W_CheckMultipleLumps("M_PAUSE") > 1);
    M_SAVEG = (W_CheckMultipleLumps("M_SAVEG") > 1);
    M_SKILL = (W_CheckMultipleLumps("M_SKILL") > 1);
    M_SKULL1 = (W_CheckMultipleLumps("M_SKULL1") > 1);
    M_SVOL = (W_CheckMultipleLumps("M_SVOL") > 1);
    STARMS = (W_CheckMultipleLumps("STARMS") > 2);
    STBAR = (W_CheckMultipleLumps("STBAR") > 2);
    STCFN034 = (W_CheckMultipleLumps("STCFN034") > 1);
    STCFN039 = (W_CheckMultipleLumps("STCFN039") > 1);
    STCFN121 = (W_CheckMultipleLumps("STCFN121") > 1);
    STYSNUM0 = (W_CheckMultipleLumps("STYSNUM0") > 1);
    TITLEPIC = (W_CheckNumForName("TITLEPIC") >= 0);
    WISCRT2 = (W_CheckMultipleLumps("WISCRT2") > 1);

    bfgedition = (DMENUPIC && W_CheckNumForName("M_ACPT") >= 0);

    // Generate the WAD hash table. Speed things up a bit.
    W_GenerateHashTable();

    D_IdentifyVersion();
    InitGameVersion();
    D_SetGameDescription();
    D_SetSaveGameDir();

    // Check for -file in shareware
    if (modifiedgame)
    {
        // These are the lumps that will be checked in IWAD,
        // if any one is not present, execution will be aborted.
        char name[23][9] =
        {
            "e2m1", "e2m2", "e2m3", "e2m4", "e2m5", "e2m6", "e2m7", "e2m8", "e2m9",
            "e3m1", "e3m3", "e3m3", "e3m4", "e3m5", "e3m6", "e3m7", "e3m8", "e3m9",
            "dphoof", "bfgga0", "heada1", "cybra1", "spida1d1"
        };
        int i;

        if (gamemode == shareware)
            I_Error("You cannot use -FILE with the shareware version.\n"
                    "Please purchase the full version.");

        // Check for fake IWAD with right name,
        // but w/o all the lumps of the registered version.
        if (gamemode == registered)
            for (i = 0; i < 23; i++)
                if (W_CheckNumForName(name[i]) < 0)
                    I_Error("This is not the registered version.");
    }

    // get skill / episode / map from parms
    startskill = sk_medium;
    startepisode = 1;
    startmap = 1;
    autostart = false;

    p = M_CheckParmWithArgs("-skill", 1);
    if (p)
    {
        temp = myargv[p + 1][0] - '1';
        if (temp >= sk_baby && temp <= sk_nightmare)
        {
            startskill = (skill_t)temp;
            autostart = true;
        }
    }

    p = M_CheckParmWithArgs("-episode", 1);
    if (p)
    {
        temp = myargv[p + 1][0] - '0';
        if ((gamemode == shareware && temp == 1)
            || (temp >= 1
                && ((gamemode == registered && temp <= 3)
                    || (gamemode == retail && temp <= 4))))
        {
            startepisode = temp;
            startmap = 1;
            autostart = true;
        }
    }

    p = M_CheckParmWithArgs("-expansion", 1);
    if (p)
    {
        temp = myargv[p + 1][0] - '0';
        if (gamemode == commercial && temp <= (nerve ? 2 : 1))
        {
            gamemission = (temp == 1 ? doom2 : pack_nerve);
            selectedexpansion = temp - 1;
            startepisode = 1;
            startmap = 1;
            autostart = true;
        }
    }

    timelimit = 0;

    p = M_CheckParmWithArgs("-timer", 1);
    if (p)
        timelimit = atoi(myargv[p + 1]);

    p = M_CheckParm("-avg");
    if (p)
        timelimit = 20;

    p = M_CheckParmWithArgs("-warp", 1);
    if (p)
    {
        static char lumpname[6];

        if (gamemode == commercial)
        {
            if (strlen(myargv[p + 1]) == 5 &&
                toupper(myargv[p + 1][0]) == 'M' &&
                toupper(myargv[p + 1][1]) == 'A' &&
                toupper(myargv[p + 1][2]) == 'P')
                startmap = (myargv[p + 1][3] - '0') * 10 + myargv[p + 1][4] - '0';
            else
                startmap = atoi(myargv[p + 1]);

            sprintf(lumpname, "MAP%02i", startmap);
        }
        else
        {
            if (strlen(myargv[p + 1]) == 4 &&
                toupper(myargv[p + 1][0]) == 'E' &&
                toupper(myargv[p + 1][2]) == 'M')
            {
                startepisode = myargv[p + 1][1] - '0';
                startmap = myargv[p + 1][3] - '0';
            }
            else
            {
                startepisode = myargv[p + 1][0] - '0';

                if (p + 2 < myargc)
                    startmap = myargv[p + 2][0] - '0';
                else
                    startmap = 1;
            }

            sprintf(lumpname, "E%iM%i", startepisode, startmap);
        }

        if (W_CheckNumForName(lumpname) >= 0)
            autostart = true;
    }

    p = M_CheckParmWithArgs("-loadgame", 1);
    if (p)
        startloadgame = atoi(myargv[p + 1]);
    else
        startloadgame = -1;

    if (mouseSensitivity < MOUSESENSITIVITY_MIN || mouseSensitivity > MOUSESENSITIVITY_MAX)
        mouseSensitivity = MOUSESENSITIVITY_DEFAULT;
    if (mouseSensitivity == MOUSESENSITIVITY_MIN)
        mouseSensitivity = -5;
    gamepadSensitivity = (!mouseSensitivity ? 0.0f :
                          (2.0f + mouseSensitivity / (float)MOUSESENSITIVITY_MAX));

    if (sfxVolume < SFXVOLUME_MIN || sfxVolume > SFXVOLUME_MAX)
        sfxVolume = SFXVOLUME_DEFAULT;

    if (musicVolume < MUSICVOLUME_MIN || musicVolume > MUSICVOLUME_MAX)
        musicVolume = MUSICVOLUME_DEFAULT;

    if (screensize < SCREENSIZE_MIN || screensize > SCREENSIZE_MAX)
        screensize = SCREENSIZE_DEFAULT;
    if (widescreen && !fullscreen)
    {
        widescreen = false;
        screensize = SCREENSIZE_MAX;
    }
    if (!widescreen)
        hud = true;
    if (fullscreen && screensize == SCREENSIZE_MAX)
    {
        widescreen = true;
        screensize = SCREENSIZE_MAX - 1;
    }
    if (widescreen)
    {
        returntowidescreen = true;
        widescreen = false;
    }

    if (screenwidth && screenheight
        && (screenwidth < SCREENWIDTH || screenheight < SCREENHEIGHT * 3 / 4))
    {
        screenwidth = SCREENWIDTH;
        screenheight = SCREENWIDTH * 3 / 4;
    }

    if (windowwidth < SCREENWIDTH || windowheight < SCREENWIDTH * 3 / 4)
    {
        windowwidth = SCREENWIDTH;
        windowheight = SCREENWIDTH * 3 / 4;
    }

    if (gammalevel < GAMMALEVEL_MIN || gammalevel > GAMMALEVEL_MAX)
        gammalevel = GAMMALEVEL_DEFAULT;
    gammalevelindex = 0;
    while (gammalevelindex < GAMMALEVELS)
        if (gammalevels[gammalevelindex++] == gammalevel)
            break;
    if (gammalevelindex == GAMMALEVELS)
    {
        gammalevelindex = 0;
        while (gammalevels[gammalevelindex++] != GAMMALEVEL_DEFAULT);
    }
    gammalevelindex--;

    if (bloodsplats < BLOODSPLATS_MIN || bloodsplats > BLOODSPLATS_MAX)
        bloodsplats = BLOODSPLATS_DEFAULT;
    bloodSplatSpawner = ((bloodsplats == UNLIMITED ? P_SpawnBloodSplat : 
                         (bloodsplats ? P_SpawnBloodSplat2 : P_SpawnBloodSplat3)));

    if (pixelwidth < PIXELWIDTH_MIN || pixelwidth > PIXELWIDTH_MAX)
        pixelwidth = PIXELWIDTH_DEFAULT;
    while (SCREENWIDTH % pixelwidth)
        pixelwidth--;
    if (pixelheight < PIXELHEIGHT_MIN || pixelheight > PIXELHEIGHT_MAX)
        pixelheight = PIXELHEIGHT_DEFAULT;
    while (SCREENHEIGHT % pixelheight)
        pixelheight--;

    M_Init();

    R_Init();

    P_Init();

    I_Init();

    S_Init((int)(sfxVolume * (127.0f / 15.0f)), (int)(musicVolume * (127.0f / 15.0f)));

    D_CheckNetGame();

    HU_Init();

    ST_Init();

    AM_Init();

    if (startloadgame >= 0)
    {
        M_StringCopy(file, P_SaveGameFile(startloadgame), sizeof(file));
        G_LoadGame(file);
    }

    if (gameaction != ga_loadgame)
    {
        if (autostart || netgame)
            G_DeferredInitNew(startskill, startepisode, startmap);
        else
            D_StartTitle();                     // start up intro loop
    }
}
コード例 #17
0
ファイル: i_video.c プロジェクト: gstark31897/chocolate-doom
void I_GetEvent(void)
{
    SDL_Event sdlevent;
    event_t event;

    // possibly not needed
    
    SDL_PumpEvents();

    // put event-grabbing stuff in here
    
    while (SDL_PollEvent(&sdlevent))
    {
        // ignore mouse events when the window is not focused

        if (!window_focused 
         && (sdlevent.type == SDL_MOUSEMOTION
          || sdlevent.type == SDL_MOUSEBUTTONDOWN
          || sdlevent.type == SDL_MOUSEBUTTONUP))
        {
            continue;
        }

        if (screensaver_mode && sdlevent.type == SDL_QUIT)
        {
            I_Quit();
        }

        UpdateShiftStatus(&sdlevent);

        // process event
        
        switch (sdlevent.type)
        {
            case SDL_KEYDOWN:
                // data1 has the key pressed, data2 has the character
                // (shift-translated, etc)
                event.type = ev_keydown;
                event.data1 = TranslateKey(&sdlevent.key.keysym);
                event.data2 = GetTypedChar(&sdlevent);

                if (event.data1 != 0)
                {
                    D_PostEvent(&event);
                }
                break;

            case SDL_KEYUP:
                event.type = ev_keyup;
                event.data1 = TranslateKey(&sdlevent.key.keysym);

                // data2 is just initialized to zero for ev_keyup.
                // For ev_keydown it's the shifted Unicode character
                // that was typed, but if something wants to detect
                // key releases it should do so based on data1
                // (key ID), not the printable char.

                event.data2 = 0;

                if (event.data1 != 0)
                {
                    D_PostEvent(&event);
                }
                break;

                /*
            case SDL_MOUSEMOTION:
                event.type = ev_mouse;
                event.data1 = mouse_button_state;
                event.data2 = AccelerateMouse(sdlevent.motion.xrel);
                event.data3 = -AccelerateMouse(sdlevent.motion.yrel);
                D_PostEvent(&event);
                break;
                */

            case SDL_MOUSEBUTTONDOWN:
		if (usemouse && !nomouse)
		{
                    UpdateMouseButtonState(sdlevent.button.button, true);
		}
                break;

            case SDL_MOUSEBUTTONUP:
		if (usemouse && !nomouse)
		{
                    UpdateMouseButtonState(sdlevent.button.button, false);
		}
                break;

            case SDL_QUIT:
                event.type = ev_quit;
                D_PostEvent(&event);
                break;

            case SDL_ACTIVEEVENT:
                // need to update our focus state
                UpdateFocus();
                break;

            case SDL_VIDEOEXPOSE:
                palette_to_set = true;
                break;

            case SDL_RESIZABLE:
                need_resize = true;
                resize_w = sdlevent.resize.w;
                resize_h = sdlevent.resize.h;
                last_resize_time = SDL_GetTicks();
                break;

            default:
                break;
        }
    }
}
コード例 #18
0
boolean MN_Responder(event_t * event)
{
    int charTyped;
    int key;
    int i;
    MenuItem_t *item;
    extern boolean automapactive;
    extern void D_StartTitle(void);
    extern void G_CheckDemoStatus(void);
    char *textBuffer;

    // In testcontrols mode, none of the function keys should do anything
    // - the only key is escape to quit.

    if (testcontrols)
    {
        if (event->type == ev_quit
         || (event->type == ev_keydown
          && (event->data1 == key_menu_activate
           || event->data1 == key_menu_quit)))
        {
            I_Quit();
            return true;
        }

        return false;
    }

    // "close" button pressed on window?
    if (event->type == ev_quit)
    {
        // First click on close = bring up quit confirm message.
        // Second click = confirm quit.

        if (!MenuActive && askforquit && typeofask == 1)
        {
            G_CheckDemoStatus();
            I_Quit();
        }
        else
        {
            SCQuitGame(0);
            S_StartSound(NULL, sfx_chat);
        }
        return true;
    }

    // Allow the menu to be activated from a joystick button if a button
    // is bound for joybmenu.
    if (event->type == ev_joystick)
    {
        if (joybmenu >= 0 && (event->data1 & (1 << joybmenu)) != 0)
        {
            MN_ActivateMenu();
            return true;
        }
    }

    if (event->type != ev_keydown)
    {
        return false;
    }

    key = event->data1;
    charTyped = event->data2;

    if (InfoType)
    {
        if (gamemode == shareware)
        {
            InfoType = (InfoType + 1) % 5;
        }
        else
        {
            InfoType = (InfoType + 1) % 4;
        }
        if (key == KEY_ESCAPE)
        {
            InfoType = 0;
        }
        if (!InfoType)
        {
            paused = false;
            MN_DeactivateMenu();
            SB_state = -1;      //refresh the statbar
            BorderNeedRefresh = true;
        }
        S_StartSound(NULL, sfx_dorcls);
        return (true);          //make the info screen eat the keypress
    }

    if ((ravpic && key == KEY_F1) ||
        (key != 0 && key == key_menu_screenshot))
    {
        G_ScreenShot();
        return (true);
    }

    if (askforquit)
    {
        if (key == key_menu_confirm)
        {
            switch (typeofask)
            {
                case 1:
                    G_CheckDemoStatus();
                    I_Quit();
                    return false;

                case 2:
                    players[consoleplayer].messageTics = 0;
                    //set the msg to be cleared
                    players[consoleplayer].message = NULL;
                    paused = false;
                    I_SetPalette(W_CacheLumpName
                                 ("PLAYPAL", PU_CACHE));
                    D_StartTitle();     // go to intro/demo mode.
                    break;

                case 3:
                    P_SetMessage(&players[consoleplayer],
                                 "QUICKSAVING....", false);
                    FileMenuKeySteal = true;
                    SCSaveGame(quicksave - 1);
                    BorderNeedRefresh = true;
                    break;

                case 4:
                    P_SetMessage(&players[consoleplayer],
                                 "QUICKLOADING....", false);
                    SCLoadGame(quickload - 1);
                    BorderNeedRefresh = true;
                    break;

                default:
                    break;
            }

            askforquit = false;
            typeofask = 0;

            return true;
        }
        else if (key == key_menu_abort || key == KEY_ESCAPE)
        {
            players[consoleplayer].messageTics = 1;  //set the msg to be cleared
            askforquit = false;
            typeofask = 0;
            paused = false;
            UpdateState |= I_FULLSCRN;
            BorderNeedRefresh = true;
            return true;
        }

        return false;           // don't let the keys filter thru
    }

    if (!MenuActive && !chatmodeon)
    {
        if (key == key_menu_decscreen)
        {
            if (automapactive)
            {               // Don't screen size in automap
                return (false);
            }
            SCScreenSize(LEFT_DIR);
            S_StartSound(NULL, sfx_keyup);
            BorderNeedRefresh = true;
            UpdateState |= I_FULLSCRN;
            return (true);
        }
        else if (key == key_menu_incscreen)
        {
            if (automapactive)
            {               // Don't screen size in automap
                return (false);
            }
            SCScreenSize(RIGHT_DIR);
            S_StartSound(NULL, sfx_keyup);
            BorderNeedRefresh = true;
            UpdateState |= I_FULLSCRN;
            return (true);
        }
        else if (key == key_menu_help)           // F1
        {
            SCInfo(0);      // start up info screens
            MenuActive = true;
            return (true);
        }
        else if (key == key_menu_save)           // F2 (save game)
        {
            if (gamestate == GS_LEVEL && !demoplayback)
            {
                MenuActive = true;
                FileMenuKeySteal = false;
                MenuTime = 0;
                CurrentMenu = &SaveMenu;
                CurrentItPos = CurrentMenu->oldItPos;
                if (!netgame && !demoplayback)
                {
                    paused = true;
                }
                S_StartSound(NULL, sfx_dorcls);
                slottextloaded = false;     //reload the slot text, when needed
            }
            return true;
        }
        else if (key == key_menu_load)           // F3 (load game)
        {
            if (SCNetCheck(2))
            {
                MenuActive = true;
                FileMenuKeySteal = false;
                MenuTime = 0;
                CurrentMenu = &LoadMenu;
                CurrentItPos = CurrentMenu->oldItPos;
                if (!netgame && !demoplayback)
                {
                    paused = true;
                }
                S_StartSound(NULL, sfx_dorcls);
                slottextloaded = false;     //reload the slot text, when needed
            }
            return true;
        }
        else if (key == key_menu_volume)         // F4 (volume)
        {
            MenuActive = true;
            FileMenuKeySteal = false;
            MenuTime = 0;
            CurrentMenu = &Options2Menu;
            CurrentItPos = CurrentMenu->oldItPos;
            if (!netgame && !demoplayback)
            {
                paused = true;
            }
            S_StartSound(NULL, sfx_dorcls);
            slottextloaded = false; //reload the slot text, when needed
            return true;
        }
        else if (key == key_menu_detail)          // F5 (detail)
        {
            // F5 isn't used in Heretic. (detail level)
            return true;
        }
        else if (key == key_menu_qsave)           // F6 (quicksave)
        {
            if (gamestate == GS_LEVEL && !demoplayback)
            {
                if (!quicksave || quicksave == -1)
                {
                    MenuActive = true;
                    FileMenuKeySteal = false;
                    MenuTime = 0;
                    CurrentMenu = &SaveMenu;
                    CurrentItPos = CurrentMenu->oldItPos;
                    if (!netgame && !demoplayback)
                    {
                        paused = true;
                    }
                    S_StartSound(NULL, sfx_dorcls);
                    slottextloaded = false; //reload the slot text, when needed
                    quicksave = -1;
                    P_SetMessage(&players[consoleplayer],
                                 "CHOOSE A QUICKSAVE SLOT", true);
                }
                else
                {
                    askforquit = true;
                    typeofask = 3;
                    if (!netgame && !demoplayback)
                    {
                        paused = true;
                    }
                    S_StartSound(NULL, sfx_chat);
                }
            }
            return true;
        }
        else if (key == key_menu_endgame)         // F7 (end game)
        {
            if (gamestate == GS_LEVEL && !demoplayback)
            {
                S_StartSound(NULL, sfx_chat);
                SCEndGame(0);
            }
            return true;
        }
        else if (key == key_menu_messages)        // F8 (toggle messages)
        {
            SCMessages(0);
            return true;
        }
        else if (key == key_menu_qload)           // F9 (quickload)
        {
            if (!quickload || quickload == -1)
            {
                MenuActive = true;
                FileMenuKeySteal = false;
                MenuTime = 0;
                CurrentMenu = &LoadMenu;
                CurrentItPos = CurrentMenu->oldItPos;
                if (!netgame && !demoplayback)
                {
                    paused = true;
                }
                S_StartSound(NULL, sfx_dorcls);
                slottextloaded = false;     //reload the slot text, when needed
                quickload = -1;
                P_SetMessage(&players[consoleplayer],
                             "CHOOSE A QUICKLOAD SLOT", true);
            }
            else
            {
                askforquit = true;
                if (!netgame && !demoplayback)
                {
                    paused = true;
                }
                typeofask = 4;
                S_StartSound(NULL, sfx_chat);
            }
            return true;
        }
        else if (key == key_menu_quit)            // F10 (quit)
        {
            if (gamestate == GS_LEVEL)
            {
                SCQuitGame(0);
                S_StartSound(NULL, sfx_chat);
            }
            return true;
        }
        else if (key == key_menu_gamma)           // F11 (gamma correction)
        {
            usegamma++;
            if (usegamma > 4)
            {
                usegamma = 0;
            }
            I_SetPalette((byte *) W_CacheLumpName("PLAYPAL", PU_CACHE));
            return true;
        }

    }

    if (!MenuActive)
    {
        if (key == key_menu_activate || gamestate == GS_DEMOSCREEN || demoplayback)
        {
            MN_ActivateMenu();
            return (true);
        }
        return (false);
    }
    if (!FileMenuKeySteal)
    {
        item = &CurrentMenu->items[CurrentItPos];

        if (key == key_menu_down)            // Next menu item
        {
            do
            {
                if (CurrentItPos + 1 > CurrentMenu->itemCount - 1)
                {
                    CurrentItPos = 0;
                }
                else
                {
                    CurrentItPos++;
                }
            }
            while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
            S_StartSound(NULL, sfx_switch);
            return (true);
        }
        else if (key == key_menu_up)         // Previous menu item
        {
            do
            {
                if (CurrentItPos == 0)
                {
                    CurrentItPos = CurrentMenu->itemCount - 1;
                }
                else
                {
                    CurrentItPos--;
                }
            }
            while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
            S_StartSound(NULL, sfx_switch);
            return (true);
        }
        else if (key == key_menu_left)       // Slider left
        {
            if (item->type == ITT_LRFUNC && item->func != NULL)
            {
                item->func(LEFT_DIR);
                S_StartSound(NULL, sfx_keyup);
            }
            return (true);
        }
        else if (key == key_menu_right)      // Slider right
        {
            if (item->type == ITT_LRFUNC && item->func != NULL)
            {
                item->func(RIGHT_DIR);
                S_StartSound(NULL, sfx_keyup);
            }
            return (true);
        }
        else if (key == key_menu_forward)    // Activate item (enter)
        {
            if (item->type == ITT_SETMENU)
            {
                SetMenu(item->menu);
            }
            else if (item->func != NULL)
            {
                CurrentMenu->oldItPos = CurrentItPos;
                if (item->type == ITT_LRFUNC)
                {
                    item->func(RIGHT_DIR);
                }
                else if (item->type == ITT_EFUNC)
                {
                    if (item->func(item->option))
                    {
                        if (item->menu != MENU_NONE)
                        {
                            SetMenu(item->menu);
                        }
                    }
                }
            }
            S_StartSound(NULL, sfx_dorcls);
            return (true);
        }
        else if (key == key_menu_activate)     // Toggle menu
        {
            MN_DeactivateMenu();
            return (true);
        }
        else if (key == key_menu_back)         // Go back to previous menu
        {
            S_StartSound(NULL, sfx_switch);
            if (CurrentMenu->prevMenu == MENU_NONE)
            {
                MN_DeactivateMenu();
            }
            else
            {
                SetMenu(CurrentMenu->prevMenu);
            }
            return (true);
        }
        else if (charTyped != 0)
        {
            // Jump to menu item based on first letter:

            for (i = 0; i < CurrentMenu->itemCount; i++)
            {
                if (CurrentMenu->items[i].text)
                {
                    if (toupper(charTyped)
                        == toupper(DEH_String(CurrentMenu->items[i].text)[0]))
                    {
                        CurrentItPos = i;
                        return (true);
                    }
                }
            }
        }

        return (false);
    }
    else
    {                           // Editing file names
#ifndef USE_VIRTUALKEYBOARD
        textBuffer = &SlotText[currentSlot][slotptr];
        if (key == KEY_BACKSPACE)
        {
            if (slotptr)
            {
                *textBuffer-- = 0;
                *textBuffer = ASCII_CURSOR;
                slotptr--;
            }
            return (true);
        }
        if (key == KEY_ESCAPE)
        {
            memset(SlotText[currentSlot], 0, SLOTTEXTLEN + 2);
            M_StringCopy(SlotText[currentSlot], oldSlotText,
                         sizeof(SlotText[currentSlot]));
            SlotStatus[currentSlot]--;
            MN_DeactivateMenu();
            return (true);
        }
        if (key == KEY_ENTER)
        {
            SlotText[currentSlot][slotptr] = 0; // clear the cursor
            item = &CurrentMenu->items[CurrentItPos];
            CurrentMenu->oldItPos = CurrentItPos;
            if (item->type == ITT_EFUNC)
            {
                item->func(item->option);
                if (item->menu != MENU_NONE)
                {
                    SetMenu(item->menu);
                }
            }
            return (true);
        }
        if (slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE)
        {
            if (isalpha(charTyped))
            {
                *textBuffer++ = toupper(charTyped);
                *textBuffer = ASCII_CURSOR;
                slotptr++;
                return (true);
            }
            if (isdigit(charTyped) || charTyped == ' '
              || charTyped == ',' || charTyped == '.' || charTyped == '-'
              || charTyped == '!')
            {
                *textBuffer++ = charTyped;
                *textBuffer = ASCII_CURSOR;
                slotptr++;
                return (true);
            }
        }
#else
        if (key == KEY_BBUTTON)
        {
            memset(SlotText[currentSlot], 0, SLOTTEXTLEN + 2);
            M_StringCopy(SlotText[currentSlot], oldSlotText,
                         sizeof(SlotText[currentSlot]));
            SlotStatus[currentSlot]--;
            MN_DeactivateMenu();
            return (true);
        }
        if (key == KEY_ABUTTON)
        {
            SlotText[currentSlot][slotptr] = 0; // clear the cursor
            item = &CurrentMenu->items[CurrentItPos];
            CurrentMenu->oldItPos = CurrentItPos;
            if (item->type == ITT_EFUNC)
            {
                item->func(item->option);
                if (item->menu != MENU_NONE)
                {
                    SetMenu(item->menu);
                }
            }
            return (true);
        }
#endif
        return (true);
    }
    return (false);
}
コード例 #19
0
//
// D_SRB2Main
//
void D_SRB2Main(void)
{
    INT32 p;
    char srb2[82]; // srb2 title banner
    char title[82];

    INT32 pstartmap = 1;
    boolean autostart = false;

    // keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined (_WIN32_WCE) && !defined(NOTERMIOS)
    if (setvbuf(stderr, NULL, _IOFBF, 1000))
        I_OutputMsg("setvbuf didnt work\n");
#endif

#ifdef GETTEXT
    // initialise locale code
    M_StartupLocale();
#endif

    // get parameters from a response file (eg: srb2 @parms.txt)
    M_FindResponseFile();

    // MAINCFG is now taken care of where "OBJCTCFG" is handled
    G_LoadGameSettings();

    // Test Dehacked lists
    DEH_Check();

    // identify the main IWAD file to use
    IdentifyVersion();

#if !defined (_WIN32_WCE) && !defined(NOTERMIOS)
    setbuf(stdout, NULL); // non-buffered output
#endif

#if defined (_WIN32_WCE) //|| defined (_DEBUG) || defined (GP2X)
    devparm = !M_CheckParm("-nodebug");
#else
    devparm = M_CheckParm("-debug");
#endif

    // for dedicated server
#if !defined (_WINDOWS) //already check in win_main.c
    dedicated = M_CheckParm("-dedicated") != 0;
#endif

    strcpy(title, "Sonic Robo Blast 2");
    strcpy(srb2, "Sonic Robo Blast 2");
    D_MakeTitleString(srb2);

#ifdef PC_DOS
    D_Titlebar(srb2, title);
#endif

#if defined (__OS2__) && !defined (SDL)
    // set PM window title
    snprintf(pmData->title, sizeof (pmData->title),
             "Sonic Robo Blast 2" VERSIONSTRING ": %s",
             title);
    pmData->title[sizeof (pmData->title) - 1] = '\0';
#endif

    if (devparm)
        CONS_Printf(M_GetText("Development mode ON.\n"));

    // default savegame
    strcpy(savegamename, SAVEGAMENAME"%u.ssg");

    {
        const char *userhome = D_Home(); //Alam: path to home

        if (!userhome)
        {
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined (DC) && !defined (PSP) && !defined(GP2X)
            I_Error("Please set $HOME to your home directory\n");
#elif defined (_WIN32_WCE) && 0
            if (dedicated)
                snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/d"CONFIGFILENAME);
            else
                snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/"CONFIGFILENAME);
#else
            if (dedicated)
                snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME);
            else
                snprintf(configfile, sizeof configfile, CONFIGFILENAME);
#endif
        }
        else
        {
            // use user specific config file
#ifdef DEFAULTDIR
            snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
            snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home);
            if (dedicated)
                snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home);
            else
                snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2home);

            // can't use sprintf since there is %u in savegamename
            strcatbf(savegamename, srb2home, PATHSEP);

            I_mkdir(srb2home, 0700);
#else
            snprintf(srb2home, sizeof srb2home, "%s", userhome);
            snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
            if (dedicated)
                snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome);
            else
                snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome);

            // can't use sprintf since there is %u in savegamename
            strcatbf(savegamename, userhome, PATHSEP);
#endif
        }

        configfile[sizeof configfile - 1] = '\0';

#ifdef _arch_dreamcast
        strcpy(downloaddir, "/ram"); // the dreamcast's TMP
#endif
    }

    // rand() needs seeded regardless of password
    srand((unsigned int)time(NULL));

    if (M_CheckParm("-password") && M_IsNextParm())
        D_SetPassword(M_GetNextParm());
    else
    {
        size_t z;
        char junkpw[25];
        for (z = 0; z < 24; z++)
            junkpw[z] = (char)(rand() & 64)+32;
        junkpw[24] = '\0';
        D_SetPassword(junkpw);
    }

    // add any files specified on the command line with -file wadfile
    // to the wad list
    if (!(M_CheckParm("-connect")))
    {
        if (M_CheckParm("-file"))
        {
            // the parms after p are wadfile/lump names,
            // until end of parms or another - preceded parm
            while (M_IsNextParm())
            {
                const char *s = M_GetNextParm();

                if (s) // Check for NULL?
                {
                    if (!W_VerifyNMUSlumps(s))
                        G_SetGameModified(true);
                    D_AddFile(s);
                }
            }
        }
    }

    // get map from parms

    if (M_CheckParm("-server") || dedicated)
        netgame = server = true;

    if (M_CheckParm("-warp") && M_IsNextParm())
    {
        const char *word = M_GetNextParm();
        if (fastncmp(word, "MAP", 3))
            pstartmap = M_MapNumber(word[3], word[4]);
        else
            pstartmap = atoi(word);
        // Don't check if lump exists just yet because the wads haven't been loaded!
        // Just do a basic range check here.
        if (pstartmap < 1 || pstartmap > NUMMAPS)
            I_Error("Cannot warp to map %d (out of range)\n", pstartmap);
        else
        {
            if (!M_CheckParm("-server"))
                G_SetGameModified(true);
            autostart = true;
        }
    }

    CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n");
    Z_Init();

    // adapt tables to SRB2's needs, including extra slots for dehacked file support
    P_PatchInfoTables();

    //---------------------------------------------------- READY TIME
    // we need to check for dedicated before initialization of some subsystems

    CONS_Printf("I_StartupTimer()...\n");
    I_StartupTimer();

    // Make backups of some SOCcable tables.
    P_BackupTables();

    // Setup default unlockable conditions
    M_SetupDefaultConditionSets();

    // load wad, including the main wad file
    CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
    if (!W_InitMultipleFiles(startupwadfiles))
#ifdef _DEBUG
        CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
#else
        I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
#endif
    D_CleanFile();

#if 1 // md5s last updated 3/15/14
    // Yes, you read that right, that's the day of release.
    // Aren't we batshit insane?

    // Check MD5s of autoloaded files
    W_VerifyFileMD5(0, "ac309fb3c7d4b5b685e2cd26beccf0e8"); // srb2.srb/srb2.wad
    W_VerifyFileMD5(1, "a894044b555dfcc71865cee16a996e88"); // zones.dta
    W_VerifyFileMD5(2, "4c410c1de6e0440cc5b2858dcca80c3e"); // player.dta
    W_VerifyFileMD5(3, "85901ad4bf94637e5753d2ac2c03ea26"); // rings.dta
    W_VerifyFileMD5(4, "c529930ee5aed6dbe33625dc8075520b"); // patch.dta

    // don't check music.dta because people like to modify it, and it doesn't matter if they do
    // ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
#endif

    mainwads = 5; // there are 5 wads not to unload

    cht_Init();

    //---------------------------------------------------- READY SCREEN
    // we need to check for dedicated before initialization of some subsystems

    CONS_Printf("I_StartupGraphics()...\n");
    I_StartupGraphics();

    //--------------------------------------------------------- CONSOLE
    // setup loading screen
    SCR_Startup();

    // we need the font of the console
    CONS_Printf("HU_Init(): Setting up heads up display.\n");
    HU_Init();

    COM_Init();
    // libogc has a CON_Init function, we must rename SRB2's CON_Init in WII/libogc
#ifndef _WII
    CON_Init();
#else
    CON_InitWii();
#endif

    D_RegisterServerCommands();
    D_RegisterClientCommands(); // be sure that this is called before D_CheckNetGame
    R_RegisterEngineStuff();
    S_RegisterSoundStuff();

    I_RegisterSysCommands();

    //--------------------------------------------------------- CONFIG.CFG
    M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"

    G_LoadGameData();

#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
    VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
#endif

    // set user default mode or mode set at cmdline
    SCR_CheckDefaultMode();

    wipegamestate = gamestate;

    P_InitMapHeaders();
    savedata.lives = 0; // flag this as not-used

    //------------------------------------------------ COMMAND LINE PARAMS

    // Initialize CD-Audio
    if (M_CheckParm("-usecd") && !dedicated)
        I_InitCD();

    if (M_CheckParm("-noupload"))
        COM_BufAddText("downloading 0\n");

    CONS_Printf("M_Init(): Init miscellaneous info.\n");
    M_Init();

    CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n");
    R_Init();

    // setting up sound
    CONS_Printf("S_Init(): Setting up sound.\n");
    if (M_CheckParm("-nosound"))
        nosound = true;
    if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
        nomidimusic = nodigimusic = true;
    else
    {
        if (M_CheckParm("-nomidimusic"))
            nomidimusic = true; ; // WARNING: DOS version initmusic in I_StartupSound
        if (M_CheckParm("-nodigmusic"))
            nodigimusic = true; // WARNING: DOS version initmusic in I_StartupSound
    }
    I_StartupSound();
    I_InitMusic();
    S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);

    CONS_Printf("ST_Init(): Init status bar.\n");
    ST_Init();

    if (M_CheckParm("-room"))
    {
        if (!M_IsNextParm())
            I_Error("usage: -room <room_id>\nCheck the Master Server's webpage for room ID numbers.\n");

#ifdef UPDATE_ALERT
        GetMODVersion_Console();
#endif

        ms_RoomId = atoi(M_GetNextParm());
    }

    // init all NETWORK
    CONS_Printf("D_CheckNetGame(): Checking network game status.\n");
    if (D_CheckNetGame())
        autostart = true;

    // check for a driver that wants intermission stats
    // start the apropriate game based on parms
    if (M_CheckParm("-metal"))
    {
        G_RecordMetal();
        autostart = true;
    }
    else if (M_CheckParm("-record") && M_IsNextParm())
    {
        G_RecordDemo(M_GetNextParm());
        autostart = true;
    }

    // user settings come before "+" parameters.
    if (dedicated)
        COM_ImmedExecute(va("exec \"%s"PATHSEP"adedserv.cfg\"\n", srb2home));
    else
        COM_ImmedExecute(va("exec \"%s"PATHSEP"autoexec.cfg\" -noerror\n", srb2home));

    if (!autostart)
        M_PushSpecialParameters(); // push all "+" parameters at the command buffer

    // demo doesn't need anymore to be added with D_AddFile()
    p = M_CheckParm("-playdemo");
    if (!p)
        p = M_CheckParm("-timedemo");
    if (p && M_IsNextParm())
    {
        char tmp[MAX_WADPATH];
        // add .lmp to identify the EXTERNAL demo file
        // it is NOT possible to play an internal demo using -playdemo,
        // rather push a playdemo command.. to do.

        strcpy(tmp, M_GetNextParm());
        // get spaced filename or directory
        while (M_IsNextParm())
        {
            strcat(tmp, " ");
            strcat(tmp, M_GetNextParm());
        }

        FIL_DefaultExtension(tmp, ".lmp");

        CONS_Printf(M_GetText("Playing demo %s.\n"), tmp);

        if (M_CheckParm("-playdemo"))
        {
            singledemo = true; // quit after one demo
            G_DeferedPlayDemo(tmp);
        }
        else
            G_TimeDemo(tmp);

        G_SetGamestate(GS_NULL);
        wipegamestate = GS_NULL;
        return;
    }

    if (M_CheckParm("-ultimatemode"))
    {
        autostart = true;
        ultimatemode = true;
    }

    if (autostart || netgame || M_CheckParm("+connect") || M_CheckParm("-connect"))
    {
        gameaction = ga_nothing;

        CV_ClearChangedFlags();

        // Do this here so if you run SRB2 with eg +timelimit 5, the time limit counts
        // as having been modified for the first game.
        M_PushSpecialParameters(); // push all "+" parameter at the command buffer

        if (M_CheckParm("-gametype") && M_IsNextParm())
        {
            // from Command_Map_f
            INT32 j;
            INT16 newgametype = -1;
            const char *sgametype = M_GetNextParm();

            for (j = 0; gametype_cons_t[j].strvalue; j++)
                if (!strcasecmp(gametype_cons_t[j].strvalue, sgametype))
                {
                    newgametype = (INT16)gametype_cons_t[j].value;
                    break;
                }
            if (!gametype_cons_t[j].strvalue) // reached end of the list with no match
            {
                j = atoi(sgametype); // assume they gave us a gametype number, which is okay too
                if (j >= 0 && j < NUMGAMETYPES)
                    newgametype = (INT16)j;
            }

            if (newgametype != -1)
            {
                j = gametype;
                gametype = newgametype;
                D_GameTypeChanged(j);
            }
        }

        if (server && !M_CheckParm("+map") && !M_CheckParm("+connect")
                && !M_CheckParm("-connect"))
        {
            // Prevent warping to nonexistent levels
            if (W_CheckNumForName(G_BuildMapName(pstartmap)) == LUMPERROR)
                I_Error("Could not warp to %s (map not found)\n", G_BuildMapName(pstartmap));
            // Prevent warping to locked levels
            // ... unless you're in a dedicated server.  Yes, technically this means you can view any level by
            // running a dedicated server and joining it yourself, but that's better than making dedicated server's
            // lives hell.
            else if (!dedicated && M_MapLocked(pstartmap))
                I_Error("You need to unlock this level before you can warp to it!\n");
            else
                D_MapChange(pstartmap, gametype, ultimatemode, true, 0, false, false);
        }
    }
    else if (M_CheckParm("-skipintro"))
    {
        CON_ToggleOff();
        CON_ClearHUD();
        F_StartTitleScreen();
    }
    else
        F_StartIntro(); // Tails 03-03-2002

    if (dedicated && server)
    {
        pagename = "TITLESKY";
        levelstarttic = gametic;
        G_SetGamestate(GS_LEVEL);
        if (!P_SetupLevel(false))
            I_Quit(); // fail so reset game stuff
    }
}
コード例 #20
0
ファイル: i_ffmpeg.c プロジェクト: dotfloat/strife-ve
void I_AVStartVideoStream(const char *filename)
{
    static boolean avInitialized = false;
    SDL_Event ev;

    if(M_CheckParm("-skipmovies") > 0 ||
       M_CheckParm("+connect_lobby") > 0)
    {
        return;
    }
   
    // initialize ffmpeg if it hasn't already
    if(!avInitialized)
    {
        hasAudio = true;

        av_register_all();
        avInitialized = true;

        if( M_CheckParm("-nosound") > 0 ||
            M_CheckParm("-nomusic") > 0 ||
            M_CheckParm("-nosfx") > 0)
        {
            // make sure we don't f**k with SDL_Mixer if sound is disabled
            hasAudio = false;
        }
    }

    globalPts = AV_NOPTS_VALUE;
    
    if(!I_AVLoadVideo(filename))
    {
        // can't find or load the video... oh well..
        return;
    }
    
// [SVE] dotfloat 20141212
#if SDL_VERSION_ATLEAST(2, 0, 0)
    thread = SDL_CreateThread(I_AVIteratePacketsThread, "i_ffmpeg", NULL);
#else
    thread = SDL_CreateThread(I_AVIteratePacketsThread, NULL);
#endif

    I_SetShowCursor(false);

    while((!videoFinished || !audioFinished) && !userExit)
    {
        int joybuttons = I_JoystickGetButtons();

        if(joybuttons > 0 && joybuttons < NUM_VIRTUAL_BUTTONS)
        {
            userExit = true;
            continue;
        }

        while(SDL_PollEvent(&ev))
        {
            switch(ev.type)
            {
                case SDL_KEYDOWN:
                    switch(ev.key.keysym.sym)
                    {
                    case SDLK_ESCAPE:
                    case SDLK_RETURN:
                    case SDLK_SPACE:
                        if(userPressed == false)
                        {
                            userExit = true;
                            userPressed = true;
                        }
                        break;
                    default:
                        break;
                    }
                    break;
                case SDL_KEYUP:
                    userPressed = false;
                    break;
                case SDL_QUIT:
                    I_Quit();
                    break;
                default:
                    break;
            }
        }
        
        if(!I_AVCapFrameRate())
        {
            I_AVDrawVideoStream();
        }
    }
    
    I_AVShutdown();
    I_SetShowCursor(true);

    // make sure everything is unbinded
    RB_UnbindTexture();
}