示例#1
0
void M_QuickSave(void)
{
	if (multiplayer)
	{
		S_Sound (CHAN_INTERFACE, "player/male/grunt1", 1, ATTN_NONE);
		M_ClearMenus ();
		return;
	}

	if (!usergame)
	{
		S_Sound (CHAN_INTERFACE, "player/male/grunt1", 1, ATTN_NONE);
		M_ClearMenus ();
		return;
	}

	if (gamestate != GS_LEVEL)
		return;

	if (quickSaveSlot < 0)
	{
		M_StartControlPanel();
		M_ReadSaveStrings();
		M_SetupNextMenu(&SaveDef);
		quickSaveSlot = -2; 	// means to pick a slot now
		return;
	}
	sprintf (tempstring, GStrings(QSPROMPT), savegamestrings[quickSaveSlot]);
	M_StartMessage (tempstring, M_QuickSaveResponse, true);
}
示例#2
0
//
// D_PageTicker
// Handles timing for warped projection
//
void D_PageTicker(void)
{
    if (!menuactive)
    {
        if (--pagetic < 0)
            D_AdvanceDemo();
        if (!TITLEPIC)
            M_StartControlPanel();
    }
}
示例#3
0
void M_QuickLoad(void)
{
	/*if (netgame)
	{
		M_StartMessage(QLOADNET,NULL,false);
		return;
	}*/

	if (quickSaveSlot < 0)
	{
		M_StartControlPanel();
		M_LoadGame (0);
		return;
	}
	sprintf(tempstring,GStrings(QLPROMPT),savegamestrings[quickSaveSlot]);
	M_StartMessage(tempstring,M_QuickLoadResponse,true);
}
void M_QuickSave(void)
{
	if (!::g->usergame)
	{
		S_StartSound(NULL,sfx_oof);
		return;
	}

	if (::g->gamestate != GS_LEVEL)
		return;

	if (::g->quickSaveSlot < 0)
	{
		M_StartControlPanel();
		M_ReadSaveStrings();
		M_SetupNextMenu(&::g->SaveDef);
		::g->quickSaveSlot = -2;	// means to pick a slot now
		return;
	}
	sprintf(::g->tempstring,QSPROMPT,::g->savegamestrings[::g->quickSaveSlot]);
	M_StartMessage(::g->tempstring,M_QuickSaveResponse,true);
}
示例#5
0
文件: p_dialog.c 项目: derek57/WIP
//
// P_DialogStart
//
// villsa [STRIFE] New function
//
void P_DialogStart(player_t *player)
{
    int i = 0;
    int pic;
    int rnd = 0;
    char* byetext;
    int jumptoconv;

    if(menuactive || netgame)
        return;

    // are we facing towards our NPC?
    P_AimLineAttack(player->mo, player->mo->angle, (128*FRACUNIT));
    if(!linetarget)
    {
        P_AimLineAttack(player->mo, player->mo->angle + (ANG90/16), (128*FRACUNIT));
        if(!linetarget)
            P_AimLineAttack(player->mo, player->mo->angle - (ANG90/16), (128*FRACUNIT));
    }

    if(!linetarget)
       return;

    // already in combat, can't talk to it
    if(linetarget->flags & MF_NODIALOG)
       return;

    // set pointer to the character talking
    dialogtalker = linetarget;

    // play a sound
    if(player == &players[consoleplayer])
       S_StartSound(0, sfx_radio);

    linetarget->target = player->mo;         // target the player
    dialogtalker->reactiontime = 2;          // set reactiontime
    dialogtalkerangle = dialogtalker->angle; // remember original angle

    // face talker towards player
    A_FaceTarget(dialogtalker);

    // face towards NPC's direction
    player->mo->angle = R_PointToAngle2(player->mo->x,
                                        player->mo->y,
                                        dialogtalker->x,
                                        dialogtalker->y);
    // set pointer to player talking
    dialogplayer = player;

    // haleyjd 09/08/10: get any stored dialog state from this object
    jumptoconv = linetarget->miscdata;

    // check item requirements
    while(1)
    {
        int i = 0;
        currentdialog = P_DialogFind(linetarget->type, jumptoconv);

        // dialog's jumptoconv equal to 0? There's nothing to jump to.
        if(currentdialog->jumptoconv == 0)
            break;

        // villsa 09/08/10: converted into for loop
        for(i = 0; i < MDLG_MAXITEMS; i++)
        {
            // if the item is non-zero, the player must have at least one in his
            // or her inventory
            if(currentdialog->checkitem[i] != 0 &&
                P_PlayerHasItem(dialogplayer, currentdialog->checkitem[i]) < 1)
                break;
        }

        if(i < MDLG_MAXITEMS) // didn't find them all? this is our dialog!
            break;

        jumptoconv = currentdialog->jumptoconv;
    }

    M_DialogDimMsg(20, 28, currentdialog->text, false);
    dialogtext = P_DialogGetMsg(currentdialog->text);

    // get states
    dialogtalkerstates = P_DialogGetStates(linetarget->type);

    // have talker greet the player
    if(dialogtalkerstates->greet)
        P_SetMobjState(dialogtalker, dialogtalkerstates->greet);

    // get talker's name
    if(currentdialog->name[0])
        dialogname = currentdialog->name;
    else
    {
        // use a fallback:
        if(mobjinfo[linetarget->type].name)
            dialogname = DEH_String(mobjinfo[linetarget->type].name); // mobjtype name
        else
            dialogname = DEH_String("Person"); // default name - like Joe in Doom 3 :P
    }

    // setup number of choices to choose from
    for(i = 0; i < MDLG_MAXCHOICES; i++)
    {
        if(!currentdialog->choices[i].giveitem)
            break;
    }

    // set number of choices to menu
    dialogmenu.numitems = i + 1;

    rnd = M_Random() % 3;

    // setup dialog menu
    M_StartControlPanel();
    menupause = false;
    menuindialog = true;
    menupausetime = gametic + 17;
    currentMenu = &dialogmenu;

    if(i >= dialogmenu.lastOn)
        itemOn = dialogmenu.lastOn;
    else
        itemOn = 0;

    // get backdrop
    pic = W_CheckNumForName(currentdialog->backpic);
    dialogbgpiclumpnum = pic;
    if(pic != -1)
        V_DrawPatchDirect(0, 0, W_CacheLumpNum(pic, PU_CACHE));

    // get voice
    I_StartVoice(currentdialog->voice);

    // get bye text
    switch(rnd)
    {
    case 2:
        byetext = DEH_String("BYE!");
        break;
    case 1:
        byetext = DEH_String("Thanks, Bye!");
        break;
    default:
    case 0:
        byetext = DEH_String("See you later!");
        break;
    }

    DEH_snprintf(dialoglastmsgbuffer, sizeof(dialoglastmsgbuffer),
                 "%d) %s", i + 1, byetext);
}
示例#6
0
void P_StartConversation (AActor *npc, AActor *pc)
{
	FStrifeDialogueReply *reply;
	menuitem_t item;
	const char *toSay;
	int i, j;

	pc->momx = pc->momy = 0;	// Stop moving
	pc->player->momx = pc->player->momy = 0;

	if (pc->player - players != consoleplayer)
		return;

	ConversationPC = pc;
	ConversationNPC = npc;

	CurNode = npc->Conversation;

	if (pc->player == &players[consoleplayer])
	{
		S_Sound (CHAN_VOICE, "misc/chat", 1, ATTN_NONE);
	}

	npc->reactiontime = 2;
	if (!(npc->flags & MF_FRIENDLY) && !(npc->flags4 & MF4_NOHATEPLAYERS))
	{
		npc->target = pc;
	}
	ConversationNPCAngle = npc->angle;
	A_FaceTarget (npc);
	pc->angle = R_PointToAngle2 (pc->x, pc->y, npc->x, npc->y);

	// Check if we should jump to another node
	while (CurNode->ItemCheck[0] != NULL)
	{
		if (CheckStrifeItem (CurNode->ItemCheck[0]) &&
			CheckStrifeItem (CurNode->ItemCheck[1]) &&
			CheckStrifeItem (CurNode->ItemCheck[2]))
		{
			int root = FindNode (ConversationNPC->GetDefault()->Conversation);
			CurNode = StrifeDialogues[root + CurNode->ItemCheckNode - 1];
		}
		else
		{
			break;
		}
	}

	if (CurNode->SpeakerVoice != 0)
	{
		S_SoundID (npc, CHAN_VOICE, CurNode->SpeakerVoice, 1, ATTN_NORM);
	}

	// Set up the menu
	ConversationMenu.PreDraw = DrawConversationMenu;
	ConversationMenu.EscapeHandler = CleanupConversationMenu;

	// Format the speaker's message.
	toSay = CurNode->Dialogue;
	if (strncmp (toSay, "RANDOM_", 7) == 0)
	{
		for (i = 0; i < NUM_RANDOM_TALKERS; ++i)
		{
			if (strcmp (RandomLines[i][0], toSay + 7) == 0)
			{
				toSay = RandomLines[i][1 + (pr_randomspeech() % NUM_RANDOM_LINES)];
				break;
			}
		}
	}
	DialogueLines = V_BreakLines (screen->GetWidth()/CleanXfac-24*2, toSay);

	// Fill out the possible choices
	ShowGold = false;
	item.type = numberedmore;
	item.e.mfunc = PickConversationReply;
	for (reply = CurNode->Children, i = 1; reply != NULL; reply = reply->Next)
	{
		if (reply->Reply == NULL)
		{
			continue;
		}
		ShowGold |= reply->NeedsGold;
		reply->ReplyLines = V_BreakLines (320-50-10, reply->Reply);
		for (j = 0; reply->ReplyLines[j].width != -1; ++j)
		{
			item.label = reply->ReplyLines[j].string;
			item.b.position = j == 0 ? i : 0;
			item.c.extra = reply;
			ConversationItems.Push (item);
		}
		++i;
	}
	item.label = RandomGoodbyes[pr_randomspeech() % NUM_RANDOM_GOODBYES];
	item.b.position = i;
	item.c.extra = NULL;
	ConversationItems.Push (item);

	// Determine where the top of the reply list should be positioned.
	i = (gameinfo.gametype & GAME_Raven) ? 9 : 8;
	ConversationMenu.y = MIN<int> (140, 192 - ConversationItems.Size() * i);
	for (i = 0; DialogueLines[i].width != -1; ++i)
	{ }
	i = 44 + i * 10;
	if (ConversationMenu.y - 100 < i - screen->GetHeight() / CleanYfac / 2)
	{
		ConversationMenu.y = i - screen->GetHeight() / CleanYfac / 2 + 100;
	}
	ConversationMenu.indent = 50;

	// Finish setting up the menu
	ConversationMenu.items = &ConversationItems[0];
	ConversationMenu.numitems = ConversationItems.Size();
	if (CurNode != PrevNode)
	{ // Only reset the selection if showing a different menu.
		ConversationMenu.lastOn = 0;
		PrevNode = CurNode;
	}
	ConversationMenu.DontDim = true;

	// And open the menu
	M_StartControlPanel (false);
	OptionsActive = true;
	menuactive = MENU_OnNoPause;
	ConversationPauseTic = gametic + 20;
	M_SwitchMenu (&ConversationMenu);
}
示例#7
0
//
// G_Responder
// Get info needed to make ticcmd_ts for the players.
//
BOOL G_Responder (event_t *ev)
{
	// any other key pops up menu if in demos
	// [RH] But only if the key isn't bound to a "special" command
	if (gameaction == ga_nothing &&
		(demoplayback || gamestate == GS_DEMOSCREEN))
	{
		const char *cmd = C_GetBinding (ev->data1);

		if (ev->type == ev_keydown)
		{

			if (!cmd || (
				strnicmp (cmd, "menu_", 5) &&
				stricmp (cmd, "toggleconsole") &&
				stricmp (cmd, "sizeup") &&
				stricmp (cmd, "sizedown") &&
				stricmp (cmd, "togglemap") &&
				stricmp (cmd, "spynext") &&
				stricmp (cmd, "chase") &&
				stricmp (cmd, "+showscores") &&
				stricmp (cmd, "bumpgamma") &&
				stricmp (cmd, "screenshot")))
			{
				S_Sound (CHAN_VOICE, "switches/normbutn", 1, ATTN_NONE);
				M_StartControlPanel ();
				return true;
			}
			else
			{
				return C_DoKey (ev);
			}
		}
		if (cmd && cmd[0] == '+')
			return C_DoKey (ev);

		return false;
	}

	if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION)
	{
		if (HU_Responder (ev))
			return true;		// chat ate the event
		if (ST_Responder (ev))
			return true;		// status window ate it
		if (!viewactive)
			if (AM_Responder (ev))
				return true;	// automap ate it
	}
	else if (gamestate == GS_FINALE)
	{
		if (F_Responder (ev))
			return true;		// finale ate the event
	}

	switch (ev->type)
	{
	  case ev_keydown:
		if (C_DoKey (ev))
			return true;
		break;

	  case ev_keyup:
		C_DoKey (ev);
		break;

	  // [Toke - Mouse] New mouse code
	  case ev_mouse:
		zdoomsens = (float)(mouse_sensitivity / 10);

		if (mouse_type == 0)
		{
			if (dynres_state == 0)
			{
				mousex = ev->data2 * (mouse_sensitivity + 5) / 10; // [Toke - Mouse] Marriage of origonal and zdoom mouse code, functions like doom2.exe code
				mousey = ev->data3 * (mouse_sensitivity + 5) / 10;
			}
			else if (dynres_state == 1)
			{
				mousexleft = ev->data2;
				mousexleft = -mousexleft;
				mousex = pow((ev->data2 * (mouse_sensitivity + 5) / 10), dynresval);

				if (ev->data2 < 0)
				{
					mousexleft = pow((mousexleft * (mouse_sensitivity + 5) / 10), dynresval);
					mousex = -mousexleft;
				}

				mouseydown = ev->data3;
				mouseydown = -mouseydown;
				mousey = pow((ev->data3 * (mouse_sensitivity + 5) / 10), dynresval);

				if (ev->data3 < 0)
				{
					mouseydown = pow((mouseydown * (mouse_sensitivity + 5) / 10), dynresval);
					mousey = -mouseydown;
				}
			}
		}
		else if (mouse_type == 1)
		{
			if (dynres_state == 0)
			{
				mousex = ev->data2 * (zdoomsens); // [Toke - Mouse] Zdoom mouse code
				mousey = ev->data3 * (zdoomsens);
			}
			else if (dynres_state == 1)
			{
				mousexleft = ev->data2;
				mousexleft = -mousexleft;
				mousex = pow((ev->data2 * (zdoomsens)), dynresval);

				if (ev->data2 < 0)
				{
					mousexleft = pow((mousexleft * (zdoomsens)), dynresval);
					mousex = -mousexleft;
				}

				mouseydown = ev->data3;
				mouseydown = -mouseydown;
				mousey = pow((ev->data3 * (zdoomsens)), dynresval);

				if (ev->data3 < 0)
				{
					mouseydown = pow((mouseydown * (zdoomsens)), dynresval);
					mousey = -mouseydown;
				}
			}
		}

		if (displaymouse == 1)
			Printf(PRINT_MEDIUM, "(%d %d) ", mousex, mousey);

		break;

	  case ev_joystick:
		joyxmove = ev->data2;
		joyymove = ev->data3;
		break;

	}

	// [RH] If the view is active, give the automap a chance at
	// the events *last* so that any bound keys get precedence.

	if (gamestate == GS_LEVEL && viewactive)
		return AM_Responder (ev);

	if (ev->type == ev_keydown ||
		ev->type == ev_mouse ||
		ev->type == ev_joystick)
		return true;
	else
		return false;
}
示例#8
0
文件: menu.cpp 项目: nano-bot/zdoom
bool M_Responder (event_t *ev)
{
    int ch = 0;
    bool keyup = false;
    int mkey = NUM_MKEYS;
    bool fromcontroller = true;

    if (chatmodeon)
    {
        return false;
    }

    if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off)
    {
        // There are a few input sources we are interested in:
        //
        // EV_KeyDown / EV_KeyUp : joysticks/gamepads/controllers
        // EV_GUI_KeyDown / EV_GUI_KeyUp : the keyboard
        // EV_GUI_Char : printable characters, which we want in string input mode
        //
        // This code previously listened for EV_GUI_KeyRepeat to handle repeating
        // in the menus, but that doesn't work with gamepads, so now we combine
        // the multiple inputs into buttons and handle the repetition manually.
        if (ev->type == EV_GUI_Event)
        {
            fromcontroller = false;
            if (ev->subtype == EV_GUI_KeyRepeat)
            {
                // We do our own key repeat handling but still want to eat the
                // OS's repeated keys.
                return true;
            }
            else if (ev->subtype == EV_GUI_BackButtonDown || ev->subtype == EV_GUI_BackButtonUp)
            {
                mkey = MKEY_Back;
                keyup = ev->subtype == EV_GUI_BackButtonUp;
            }
            else if (ev->subtype != EV_GUI_KeyDown && ev->subtype != EV_GUI_KeyUp)
            {
                // do we want mouse input?
                if (ev->subtype >= EV_GUI_FirstMouseEvent && ev->subtype <= EV_GUI_LastMouseEvent)
                {
                    if (!m_use_mouse)
                        return true;
                }

                // pass everything else on to the current menu
                return DMenu::CurrentMenu->Responder(ev);
            }
            else if (DMenu::CurrentMenu->TranslateKeyboardEvents())
            {
                ch = ev->data1;
                keyup = ev->subtype == EV_GUI_KeyUp;
                switch (ch)
                {
                case GK_BACK:
                    mkey = MKEY_Back;
                    break;
                case GK_ESCAPE:
                    mkey = MKEY_Back;
                    break;
                case GK_RETURN:
                    mkey = MKEY_Enter;
                    break;
                case GK_UP:
                    mkey = MKEY_Up;
                    break;
                case GK_DOWN:
                    mkey = MKEY_Down;
                    break;
                case GK_LEFT:
                    mkey = MKEY_Left;
                    break;
                case GK_RIGHT:
                    mkey = MKEY_Right;
                    break;
                case GK_BACKSPACE:
                    mkey = MKEY_Clear;
                    break;
                case GK_PGUP:
                    mkey = MKEY_PageUp;
                    break;
                case GK_PGDN:
                    mkey = MKEY_PageDown;
                    break;
                default:
                    if (!keyup)
                    {
                        return DMenu::CurrentMenu->Responder(ev);
                    }
                    break;
                }
            }
        }
        else if (menuactive != MENU_WaitKey && (ev->type == EV_KeyDown || ev->type == EV_KeyUp))
        {
            keyup = ev->type == EV_KeyUp;

            ch = ev->data1;
            switch (ch)
            {
            case KEY_JOY1:
            case KEY_PAD_A:
                mkey = MKEY_Enter;
                break;

            case KEY_JOY2:
            case KEY_PAD_B:
                mkey = MKEY_Back;
                break;

            case KEY_JOY3:
            case KEY_PAD_X:
                mkey = MKEY_Clear;
                break;

            case KEY_JOY5:
            case KEY_PAD_LSHOULDER:
                mkey = MKEY_PageUp;
                break;

            case KEY_JOY6:
            case KEY_PAD_RSHOULDER:
                mkey = MKEY_PageDown;
                break;

            case KEY_PAD_DPAD_UP:
            case KEY_PAD_LTHUMB_UP:
            case KEY_JOYAXIS1MINUS:
            case KEY_JOYPOV1_UP:
                mkey = MKEY_Up;
                break;

            case KEY_PAD_DPAD_DOWN:
            case KEY_PAD_LTHUMB_DOWN:
            case KEY_JOYAXIS1PLUS:
            case KEY_JOYPOV1_DOWN:
                mkey = MKEY_Down;
                break;

            case KEY_PAD_DPAD_LEFT:
            case KEY_PAD_LTHUMB_LEFT:
            case KEY_JOYAXIS2MINUS:
            case KEY_JOYPOV1_LEFT:
                mkey = MKEY_Left;
                break;

            case KEY_PAD_DPAD_RIGHT:
            case KEY_PAD_LTHUMB_RIGHT:
            case KEY_JOYAXIS2PLUS:
            case KEY_JOYPOV1_RIGHT:
                mkey = MKEY_Right;
                break;
            }
        }

        if (mkey != NUM_MKEYS)
        {
            if (keyup)
            {
                MenuButtons[mkey].ReleaseKey(ch);
                return false;
            }
            else
            {
                MenuButtons[mkey].PressKey(ch);
                MenuButtonOrigin[mkey] = fromcontroller;
                if (mkey <= MKEY_PageDown)
                {
                    MenuButtonTickers[mkey] = KEY_REPEAT_DELAY;
                }
                DMenu::CurrentMenu->MenuEvent(mkey, fromcontroller);
                return true;
            }
        }
        return DMenu::CurrentMenu->Responder(ev) || !keyup;
    }
    else if (MenuEnabled)
    {
        if (ev->type == EV_KeyDown)
        {
            // Pop-up menu?
            if (ev->data1 == KEY_ESCAPE)
            {
                M_StartControlPanel(true);
                M_SetMenu(NAME_Mainmenu, -1);
                return true;
            }
            // If devparm is set, pressing F1 always takes a screenshot no matter
            // what it's bound to. (for those who don't bother to read the docs)
            if (devparm && ev->data1 == KEY_F1)
            {
                G_ScreenShot(NULL);
                return true;
            }
            return false;
        }
        else if (ev->type == EV_GUI_Event && ev->subtype == EV_GUI_LButtonDown &&
                 ConsoleState != c_down && m_use_mouse)
        {
            M_StartControlPanel(true);
            M_SetMenu(NAME_Mainmenu, -1);
            return true;
        }
    }
    return false;
}
示例#9
0
boolean cht_Responder(event_t *ev)
{
	static player_t *plyr;

	if (ev->type == ev_keydown && 0x00 <= ev->data1 && ev->data1 <= 0xFF) // SRB2CBTODO: && 0x00 <= ev->data1 && ev->data1 <= 0xFF?
	{
		plyr = &players[consoleplayer];

		// devmode cheat
		if (cht_CheckCheat(&cheat_bulmer, (char)ev->data1))
		{
			sfxenum_t sfxid;
			const char *emoticon;
			byte mrandom;

			/*
			Shows a picture of David Bulmer with one the following messages:
			"*B^C", "*B^D", "*B^I", "*B^J", "*B^L", "*B^O", "*B^P", "*B^S", "*B^X"
			Accompany each emoticon with sound clip.
			*/

			M_StartControlPanel();
			M_SetupNextMenu(&ReadDef2);

			mrandom = M_Random();

			if (mrandom < 64)
			{
				emoticon = "*B^O";
				sfxid = sfx_beeoh;
			}
			else if (mrandom < 128)
			{
				emoticon = "*B^L";
				sfxid = sfx_beeel;
			}
			else if (mrandom < 192)
			{
				emoticon = "*B^J";
				sfxid = sfx_beejay;
			}
			else
			{
				emoticon = "*B^D";
				sfxid = sfx_beedee;
			}

			HU_DoCEcho(emoticon);
			COM_BufExecute();
			S_StartSound(0, sfxid);
		}
		else if (cht_CheckCheat(&cheat_poksoc, (char)ev->data1))
		{
			sfxenum_t sfxid;
			byte mrandom = M_Random();

			/*
			Plays one of these sounds:
			"You cheating, lying GIT!"
			"Hey... are you my Grandma?"
			"PIIIKKAAA!"
			"You little bugger!"
			"Oxy-pad, Oxy-pad, Oxy-pad, Ox--eeaygggh!"
			"(Eggman's Japanese) That's not fair, now two of your players have to die!"
			*/

			if (mrandom < 48)
				sfxid = sfx_poksoc1;
			else if (mrandom < 96)
				sfxid = sfx_poksoc2;
			else if (mrandom < 144)
				sfxid = sfx_poksoc3;
			else if (mrandom < 192)
				sfxid = sfx_poksoc4;
			else if (mrandom < 240)
				sfxid = sfx_poksoc5;
			else
				sfxid = sfx_poksoc6;

			S_StartSound(0, sfxid);
		}
		else if (cht_CheckCheat(&cheat_apl, (char)ev->data1))
		{
			sfxenum_t sfxid;
			byte mrandom = M_Random();

			/*
			Plays one of these sounds:
			"You do realize those are prohibited on planes, right?"
			"IT'S A HUNKY DUNKY SUPER SIZE BIG FAT REALLY REALLY BIG BOMB!"
			"Let's order a pizza!"
			"Tails, you made the engines quit!
			"Buggery! What happened out here?!"
			"Oh no! A GigaDoomBot!"
			*/

			if (mrandom < 48)
				sfxid = sfx_apl1;
			else if (mrandom < 96)
				sfxid = sfx_apl2;
			else if (mrandom < 144)
				sfxid = sfx_apl3;
			else if (mrandom < 192)
				sfxid = sfx_apl4;
			else if (mrandom < 240)
				sfxid = sfx_apl5;
			else
				sfxid = sfx_apl6;

			S_StartSound(0, sfxid);
		}
		else if (cht_CheckCheat(&cheat_ultimate, (char)ev->data1)) // SRB2CBTODO: USE THIS FOR OTHER COOL STUFF!
		{
			// Plays the ring sound effect, then begins a single player game at ultimate difficulty.
			S_StartSound(0, sfx_itemup);
			ultmode = true;
			startmap = spstage_start;
			M_SetupNextMenu(&PlayerDef);
		}
	}
	return false;
}
示例#10
0
//
// M_Responder
//
qboolean M_Responder (event_t* ev)
{
	int             ch;
	int             i;

	ch = -1;

	if (ev->type == ev_joystick && ::g->joywait < I_GetTime())
	{
		if (ev->data3 == -1)
		{
			ch = KEY_UPARROW;
			::g->joywait = I_GetTime() + 5;
		}
		else if (ev->data3 == 1)
		{
			ch = KEY_DOWNARROW;
			::g->joywait = I_GetTime() + 5;
		}

		if (ev->data2 == -1)
		{
			ch = KEY_LEFTARROW;
			::g->joywait = I_GetTime() + 2;
		}
		else if (ev->data2 == 1)
		{
			ch = KEY_RIGHTARROW;
			::g->joywait = I_GetTime() + 2;
		}

		if (ev->data1&1)
		{
			ch = KEY_ENTER;
			::g->joywait = I_GetTime() + 5;
		}
		if (ev->data1&2)
		{
			ch = KEY_BACKSPACE;
			::g->joywait = I_GetTime() + 5;
		}
	}
	else
	{
		if (ev->type == ev_mouse && ::g->mousewait < I_GetTime())
		{
			::g->mmenu_mousey += ev->data3;
			if (::g->mmenu_mousey < ::g->lasty-30)
			{
				ch = KEY_DOWNARROW;
				::g->mousewait = I_GetTime() + 5;
				::g->mmenu_mousey = ::g->lasty -= 30;
			}
			else if (::g->mmenu_mousey > ::g->lasty+30)
			{
				ch = KEY_UPARROW;
				::g->mousewait = I_GetTime() + 5;
				::g->mmenu_mousey = ::g->lasty += 30;
			}

			::g->mmenu_mousex += ev->data2;
			if (::g->mmenu_mousex < ::g->lastx-30)
			{
				ch = KEY_LEFTARROW;
				::g->mousewait = I_GetTime() + 5;
				::g->mmenu_mousex = ::g->lastx -= 30;
			}
			else if (::g->mmenu_mousex > ::g->lastx+30)
			{
				ch = KEY_RIGHTARROW;
				::g->mousewait = I_GetTime() + 5;
				::g->mmenu_mousex = ::g->lastx += 30;
			}

			if (ev->data1&1)
			{
				ch = KEY_ENTER;
				::g->mousewait = I_GetTime() + 15;
			}

			if (ev->data1&2)
			{
				ch = KEY_BACKSPACE;
				::g->mousewait = I_GetTime() + 15;
			}
		} else 
	if (ev->type == ev_keydown)
		{
			ch = ev->data1;
		}
	}

	if (ch == -1)
		return false;


	// Save Game string input
	if (::g->saveStringEnter)
	{
		switch(ch)
		{
		case KEY_BACKSPACE:
			if (::g->saveCharIndex > 0)
			{
				::g->saveCharIndex--;
				::g->savegamestrings[::g->saveSlot][::g->saveCharIndex] = 0;
			}
			break;

		case KEY_ESCAPE:
			::g->saveStringEnter = 0;
			strcpy(&::g->savegamestrings[::g->saveSlot][0],::g->saveOldString);
			break;

		case KEY_ENTER:
			::g->saveStringEnter = 0;
			if (::g->savegamestrings[::g->saveSlot][0])
				M_DoSave(::g->saveSlot);
			break;

		default:
			ch = toupper(ch);
			if (ch != 32)
				if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE)
					break;
			if (ch >= 32 && ch <= 127 &&
				::g->saveCharIndex < SAVESTRINGSIZE-1 &&
				M_StringWidth(::g->savegamestrings[::g->saveSlot]) <
				(SAVESTRINGSIZE-2)*8)
			{
				::g->savegamestrings[::g->saveSlot][::g->saveCharIndex++] = ch;
				::g->savegamestrings[::g->saveSlot][::g->saveCharIndex] = 0;
			}
			break;
		}
		return true;
	}

	// Take care of any messages that need input
	if (::g->messageToPrint)
	{
		if (::g->messageNeedsInput == true &&
			!(ch == KEY_ENTER || ch == KEY_BACKSPACE || ch == KEY_ESCAPE))
			return false;

		::g->menuactive = ::g->messageLastMenuActive;
		::g->messageToPrint = 0;
		if (::g->messageRoutine)
			::g->messageRoutine(ch);

		S_StartSound(NULL,sfx_swtchx);
		return true;
	}
/*
	if (::g->devparm && ch == KEY_F1)
	{
		G_ScreenShot ();
		return true;
	}

	// F-Keys
	if (!::g->menuactive)
		switch(ch)
	{
		case KEY_MINUS:         // Screen size down
			if (::g->automapactive || ::g->chat_on)
				return false;
			//M_SizeDisplay(0);
			S_StartSound(NULL,sfx_stnmov);
			return true;

		case KEY_EQUALS:        // Screen size up
			if (::g->automapactive || ::g->chat_on)
				return false;
			//M_SizeDisplay(1);
			S_StartSound(NULL,sfx_stnmov);
			return true;

		case KEY_F1:            // Help key
			M_StartControlPanel ();

			if ( ::g->gamemode == retail )
				::g->currentMenu = &::g->ReadDef2;
			else
				::g->currentMenu = &::g->ReadDef1;

			::g->itemOn = 0;
			S_StartSound(NULL,sfx_swtchn);
			return true;

		case KEY_F2:            // Save
			M_StartControlPanel();
			S_StartSound(NULL,sfx_swtchn);
			M_SaveGame(0);
			return true;

		case KEY_F3:            // Load
			M_StartControlPanel();
			S_StartSound(NULL,sfx_swtchn);
			M_LoadGame(0);
			return true;

		case KEY_F4:            // Sound Volume
			M_StartControlPanel ();
			::g->currentMenu = &::g->SoundDef;
			::g->itemOn = sfx_vol;
			S_StartSound(NULL,sfx_swtchn);
			return true;

		case KEY_F5:            // Detail toggle
			M_ChangeDetail(0);
			S_StartSound(NULL,sfx_swtchn);
			return true;

		case KEY_F6:            // Quicksave
			S_StartSound(NULL,sfx_swtchn);
			M_QuickSave();
			return true;

		case KEY_F7:            // End game
			S_StartSound(NULL,sfx_swtchn);
			M_EndGame(0);
			return true;

		case KEY_F8:            // Toggle messages
			M_ChangeMessages(0);
			S_StartSound(NULL,sfx_swtchn);
			return true;

		case KEY_F9:            // Quickload
			S_StartSound(NULL,sfx_swtchn);
			M_QuickLoad();
			return true;

		case KEY_F10:           // Quit DOOM
			S_StartSound(NULL,sfx_swtchn);
			M_QuitDOOM(0);
			return true;

		case KEY_F11:           // gamma toggle
			::g->usegamma++;
			if (::g->usegamma > 4)
				::g->usegamma = 0;
			::g->players[::g->consoleplayer].message = gammamsg[::g->usegamma];
			I_SetPalette ((byte*)W_CacheLumpName ("PLAYPAL",PU_CACHE_SHARED));
			return true;

	}
*/

	// Pop-up menu?
	if (!::g->menuactive)
	{
		if (ch == KEY_ESCAPE && ( ::g->gamestate == GS_LEVEL || ::g->gamestate == GS_INTERMISSION || ::g->gamestate == GS_FINALE  ) )
		{
			M_StartControlPanel ();

			S_StartSound(NULL,sfx_swtchn);
			return true;
		}
		
		return false;
	}

	// Keys usable within menu
	switch (ch)
	{
	case KEY_DOWNARROW:
		do
		{
			if (::g->itemOn+1 > ::g->currentMenu->numitems-1)
				::g->itemOn = 0;
			else ::g->itemOn++;
			S_StartSound(NULL,sfx_pstop);
		} while(::g->currentMenu->menuitems[::g->itemOn].status==-1);
		return true;

	case KEY_UPARROW:
		do
		{
			if (!::g->itemOn)
				::g->itemOn = ::g->currentMenu->numitems-1;
			else ::g->itemOn--;
			S_StartSound(NULL,sfx_pstop);
		} while(::g->currentMenu->menuitems[::g->itemOn].status==-1);
		return true;

	case KEY_LEFTARROW:
		if (::g->currentMenu->menuitems[::g->itemOn].routine &&
			::g->currentMenu->menuitems[::g->itemOn].status == 2)
		{
			S_StartSound(NULL,sfx_stnmov);
			::g->currentMenu->menuitems[::g->itemOn].routine(0);
		}
		return true;

	case KEY_RIGHTARROW:
		if (::g->currentMenu->menuitems[::g->itemOn].routine &&
			::g->currentMenu->menuitems[::g->itemOn].status == 2)
		{
			S_StartSound(NULL,sfx_stnmov);
			::g->currentMenu->menuitems[::g->itemOn].routine(1);
		}
		return true;

	case KEY_ENTER:
		if (::g->currentMenu->menuitems[::g->itemOn].routine &&
			::g->currentMenu->menuitems[::g->itemOn].status)
		{
			::g->currentMenu->lastOn = ::g->itemOn;
			if (::g->currentMenu->menuitems[::g->itemOn].status == 2)
			{
				::g->currentMenu->menuitems[::g->itemOn].routine(1);      // right arrow
				S_StartSound(NULL,sfx_stnmov);
			}
			else
			{
				::g->currentMenu->menuitems[::g->itemOn].routine(::g->itemOn);
				S_StartSound(NULL,sfx_pistol);
			}
		}
		return true;

	case KEY_ESCAPE:
	case KEY_BACKSPACE:
		::g->currentMenu->lastOn = ::g->itemOn;
		if (::g->currentMenu->prevMenu)
		{
			::g->currentMenu = ::g->currentMenu->prevMenu;
			::g->itemOn = ::g->currentMenu->lastOn;
			S_StartSound(NULL,sfx_swtchn);
		} else if ( ::g->currentMenu == &::g->MainDef && ( !::g->demoplayback && ::g->gamestate != GS_DEMOSCREEN ) ) {
			M_ClearMenus();
			::g->paused = false;
		}
		return true;

	default:
		for (i = ::g->itemOn+1;i < ::g->currentMenu->numitems;i++)
			if (::g->currentMenu->menuitems[i].alphaKey == ch)
			{
				::g->itemOn = i;
				S_StartSound(NULL,sfx_pstop);
				return true;
			}
			for (i = 0;i <= ::g->itemOn;i++)
				if (::g->currentMenu->menuitems[i].alphaKey == ch)
				{
					::g->itemOn = i;
					S_StartSound(NULL,sfx_pstop);
					return true;
				}
				break;

	}

	return false;
}
示例#11
0
//
// M_Responder
//
boolean M_Responder (event_t* ev)
{
    int             ch;
    int             i;
	
    ch = -1;
	
	if (ev->type == ev_keydown)
		ch = ev->data1;
    
    if (ch == -1)
		return false;

    // Take care of any messages that need input
    if (messageToPrint)
    {
	if (messageNeedsInput == true &&
	    !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE))
	    return false;
		
	menuactive = (boolean)messageLastMenuActive;
	messageToPrint = 0;
	if (messageRoutine)
	    messageRoutine(ch);
			
	menuactive = false;
	return true;
    }
	
    // F-Keys
    if (!menuactive)
	switch(ch)
	{
	  case KEY_F1:            // Boss key
	    M_StartControlPanel ();

	    if ( gamemode == retail )
	      currentMenu = &ReadDef2;
	    else
	      currentMenu = &ReadDef1;
	    
	    itemOn = 0;
	    return true;
				
	  case KEY_F2:            // Quicksave
	    //M_QuickSave();
	    return true;
				
	  case KEY_F3:            // Quickload
	    //M_QuickLoad();
	    return true;
	}
    // Pop-up menu?
    if (!menuactive)
    {
		if (ch == KEY_ESCAPE)
		{
			M_StartControlPanel ();
			return true;
		}
			return false;
    }

    
    // Keys usable within menu
    switch (ch)
    {
      case KEY_DOWNARROW:
	do
	{
	    if (itemOn+1 > currentMenu->numitems-1)
		itemOn = 0;
	    else itemOn++;
	} while(currentMenu->menuitems[itemOn].status==-1);
	return true;
		
      case KEY_UPARROW:
	do
	{
	    if (!itemOn)
		itemOn = currentMenu->numitems-1;
	    else itemOn--;
	} while(currentMenu->menuitems[itemOn].status==-1);
	return true;

      case KEY_LEFTARROW:
	if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2)
	{
	    currentMenu->menuitems[itemOn].routine(0);
	}
	return true;
		
      case KEY_RIGHTARROW:
	if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2)
	{
	    currentMenu->menuitems[itemOn].routine(1);
	}
	return true;

      case KEY_ENTER:
	if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status)
	{
	    currentMenu->lastOn = itemOn;
	    if (currentMenu->menuitems[itemOn].status == 2)
			currentMenu->menuitems[itemOn].routine(1);      // right arrow
	    else
			currentMenu->menuitems[itemOn].routine(itemOn);
	}
	return true;
		
      case KEY_ESCAPE:
	currentMenu->lastOn = itemOn;
	M_ClearMenus ();
	return true;
		
      case KEY_BACKSPACE:
	currentMenu->lastOn = itemOn;
	if (currentMenu->prevMenu)
	{
	    currentMenu = currentMenu->prevMenu;
	    itemOn = currentMenu->lastOn;
	}
	return true;
	
      default:
	for (i = itemOn+1;i < currentMenu->numitems;i++)
	    if (currentMenu->menuitems[i].alphaKey == ch)
	    {
			itemOn = (short)i;
			return true;
	    }
	for (i = 0;i <= itemOn;i++)
	    if (currentMenu->menuitems[i].alphaKey == ch)
	    {
			itemOn = (short)i;
            return true;
        }
        break;

    }

    return false;
}