⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m_menu.c

📁 Nxdoom真的满好用的
💻 C
📖 第 1 页 / 共 3 页
字号:
	if (c < 0 || c >= HU_FONTSIZE)	    w += 4;	else	    w += SHORT (hu_font[c]->width);    }		    return w;}////      Find string height from hu_font chars//int M_StringHeight(char* string){    int             i;    int             h;    int             height = SHORT(hu_font[0]->height);	    h = height;    for (i = 0;i < strlen(string);i++)	if (string[i] == '\n')	    h += height;		    return h;}////      Write a string using the hu_font//voidM_WriteText( int		x,  int		y,  char*		string){    int		w;    char*	ch;    int		c;    int		cx;    int		cy;		    ch = string;    cx = x;    cy = y;	    while(1)    {	c = *ch++;	if (!c)	    break;	if (c == '\n')	{	    cx = x;	    cy += 12;	    continue;	}			c = toupper(c) - HU_FONTSTART;	if (c < 0 || c>= HU_FONTSIZE)	{	    cx += 4;	    continue;	}			w = SHORT (hu_font[c]->width);	if (cx+w > SCREENWIDTH)	    break;	V_DrawPatchDirect(cx, cy, 0, hu_font[c]);	cx+=w;    }}//// CONTROL PANEL////// M_Responder//boolean M_Responder (event_t* ev){    int             ch;    int             i;    static  int     joywait = 0;    static  int     mousewait = 0;    static  int     mousey = 0;    static  int     lasty = 0;    static  int     mousex = 0;    static  int     lastx = 0;	    ch = -1;	    if (ev->type == ev_joystick && joywait < I_GetTime())    {	if (ev->data3 == -1)	{	    ch = KEY_UPARROW;	    joywait = I_GetTime() + 5;	}	else if (ev->data3 == 1)	{	    ch = KEY_DOWNARROW;	    joywait = I_GetTime() + 5;	}			if (ev->data2 == -1)	{	    ch = KEY_LEFTARROW;	    joywait = I_GetTime() + 2;	}	else if (ev->data2 == 1)	{	    ch = KEY_RIGHTARROW;	    joywait = I_GetTime() + 2;	}			if (ev->data1&1)	{	    ch = KEY_ENTER;	    joywait = I_GetTime() + 5;	}	if (ev->data1&2)	{	    ch = KEY_BACKSPACE;	    joywait = I_GetTime() + 5;	}    }    else    {	if (ev->type == ev_mouse && mousewait < I_GetTime())	{	    mousey += ev->data3;	    if (mousey < lasty-30)	    {		ch = KEY_DOWNARROW;		mousewait = I_GetTime() + 5;		mousey = lasty -= 30;	    }	    else if (mousey > lasty+30)	    {		ch = KEY_UPARROW;		mousewait = I_GetTime() + 5;		mousey = lasty += 30;	    }			    mousex += ev->data2;	    if (mousex < lastx-30)	    {		ch = KEY_LEFTARROW;		mousewait = I_GetTime() + 5;		mousex = lastx -= 30;	    }	    else if (mousex > lastx+30)	    {		ch = KEY_RIGHTARROW;		mousewait = I_GetTime() + 5;		mousex = lastx += 30;	    }			    if (ev->data1&1)	    {		ch = KEY_ENTER;		mousewait = I_GetTime() + 15;	    }				    if (ev->data1&2)	    {		ch = KEY_BACKSPACE;		mousewait = I_GetTime() + 15;	    }	}	else	    if (ev->type == ev_keydown)	    {		ch = ev->data1;	    }    }        if (ch == -1)	return false;        // Save Game string input    if (saveStringEnter)    {	switch(ch)	{	  case KEY_BACKSPACE:	    if (saveCharIndex > 0)	    {		saveCharIndex--;		savegamestrings[saveSlot][saveCharIndex] = 0;	    }	    break;					  case KEY_ESCAPE:	    saveStringEnter = 0;	    strcpy(&savegamestrings[saveSlot][0],saveOldString);	    break;					  case KEY_ENTER:	    saveStringEnter = 0;	    if (savegamestrings[saveSlot][0])		M_DoSave(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 &&		saveCharIndex < SAVESTRINGSIZE-1 &&		M_StringWidth(savegamestrings[saveSlot]) <		(SAVESTRINGSIZE-2)*8)	    {		savegamestrings[saveSlot][saveCharIndex++] = ch;		savegamestrings[saveSlot][saveCharIndex] = 0;	    }	    break;	}	return true;    }        // Take care of any messages that need input    if (messageToPrint)    {	if (messageNeedsInput == true &&	    !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE))	    return false;			menuactive = messageLastMenuActive;	messageToPrint = 0;	if (messageRoutine)	    messageRoutine(ch);				menuactive = false;	S_StartSound(NULL,sfx_swtchx);	return true;    }	    if (devparm && ch == KEY_F1)    {	G_ScreenShot ();	return true;    }		        // F-Keys    if (!menuactive)	switch(ch)	{	  case KEY_MINUS:         // Screen size down	    if (automapactive || chat_on)		return false;	    M_SizeDisplay(0);	    S_StartSound(NULL,sfx_stnmov);	    return true;					  case KEY_EQUALS:        // Screen size up	    if (automapactive || chat_on)		return false;	    M_SizeDisplay(1);	    S_StartSound(NULL,sfx_stnmov);	    return true;					  case KEY_F1:            // Help key	    M_StartControlPanel ();	    if ( gamemode == retail )	      currentMenu = &ReadDef2;	    else	      currentMenu = &ReadDef1;	    	    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 ();	    currentMenu = &SoundDef;	    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	    usegamma++;	    if (usegamma > 4)		usegamma = 0;	    players[consoleplayer].message = gammamsg[usegamma];	    I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE));	    return true;					}        // Pop-up menu?    if (!menuactive)    {	if (ch == KEY_ESCAPE)	{	    M_StartControlPanel ();	    S_StartSound(NULL,sfx_swtchn);	    return true;	}	return false;    }        // Keys usable within menu    switch (ch)    {      case KEY_DOWNARROW:	do	{	    if (itemOn+1 > currentMenu->numitems-1)		itemOn = 0;	    else itemOn++;	    S_StartSound(NULL,sfx_pstop);	} while(currentMenu->menuitems[itemOn].status==-1);	return true;		      case KEY_UPARROW:	do	{	    if (!itemOn)		itemOn = currentMenu->numitems-1;	    else itemOn--;	    S_StartSound(NULL,sfx_pstop);	} while(currentMenu->menuitems[itemOn].status==-1);	return true;      case KEY_LEFTARROW:	if (currentMenu->menuitems[itemOn].routine &&	    currentMenu->menuitems[itemOn].status == 2)	{	    S_StartSound(NULL,sfx_stnmov);	    currentMenu->menuitems[itemOn].routine(0);	}	return true;		      case KEY_RIGHTARROW:	if (currentMenu->menuitems[itemOn].routine &&	    currentMenu->menuitems[itemOn].status == 2)	{	    S_StartSound(NULL,sfx_stnmov);	    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		S_StartSound(NULL,sfx_stnmov);	    }	    else	    {		currentMenu->menuitems[itemOn].routine(itemOn);		S_StartSound(NULL,sfx_pistol);	    }	}	return true;		      case KEY_ESCAPE:	currentMenu->lastOn = itemOn;	M_ClearMenus ();	S_StartSound(NULL,sfx_swtchx);	return true;		      case KEY_BACKSPACE:	currentMenu->lastOn = itemOn;	if (currentMenu->prevMenu)	{	    currentMenu = currentMenu->prevMenu;	    itemOn = currentMenu->lastOn;	    S_StartSound(NULL,sfx_swtchn);	}	return true;	      default:	for (i = itemOn+1;i < currentMenu->numitems;i++)	    if (currentMenu->menuitems[i].alphaKey == ch)	    {		itemOn = i;		S_StartSound(NULL,sfx_pstop);		return true;	    }	for (i = 0;i <= itemOn;i++)	    if (currentMenu->menuitems[i].alphaKey == ch)	    {		itemOn = i;		S_StartSound(NULL,sfx_pstop);		return true;	    }	break;	    }    return false;}//// M_StartControlPanel//void M_StartControlPanel (void){    // intro might call this repeatedly    if (menuactive)	return;        menuactive = 1;    currentMenu = &MainDef;         // JDC    itemOn = currentMenu->lastOn;   // JDC}//// M_Drawer// Called after the view has been rendered,// but before it has been blitted.//void M_Drawer (void){    static short	x;    static short	y;    short		i;    short		max;    char		string[40];    int			start;    inhelpscreens = false;        // Horiz. & Vertically center string and print it.    if (messageToPrint)    {	start = 0;	y = 100 - M_StringHeight(messageString)/2;	while(*(messageString+start))	{	    for (i = 0;i < strlen(messageString+start);i++)		if (*(messageString+start+i) == '\n')		{		    memset(string,0,40);		    strncpy(string,messageString+start,i);		    start += i+1;		    break;		}					    if (i == strlen(messageString+start))	    {		strcpy(string,messageString+start);		start += i;	    }					    x = 160 - M_StringWidth(string)/2;	    M_WriteText(x,y,string);	    y += SHORT(hu_font[0]->height);	}	return;    }    if (!menuactive)	return;    if (currentMenu->routine)	currentMenu->routine();         // call Draw routine        // DRAW MENU    x = currentMenu->x;    y = currentMenu->y;    max = currentMenu->numitems;    for (i=0;i<max;i++)    {	if (currentMenu->menuitems[i].name[0])	    V_DrawPatchDirect (x,y,0,			       W_CacheLumpName(currentMenu->menuitems[i].name ,PU_CACHE));	y += LINEHEIGHT;    }        // DRAW SKULL    V_DrawPatchDirect(x + SKULLXOFF,currentMenu->y - 5 + itemOn*LINEHEIGHT, 0,		      W_CacheLumpName(skullName[whichSkull],PU_CACHE));}//// M_ClearMenus//void M_ClearMenus (void){    menuactive = 0;    // if (!netgame && usergame && paused)    //       sendpause = true;}//// M_SetupNextMenu//void M_SetupNextMenu(menu_t *menudef){    currentMenu = menudef;    itemOn = currentMenu->lastOn;}//// M_Ticker//void M_Ticker (void){    if (--skullAnimCounter <= 0)    {	whichSkull ^= 1;	skullAnimCounter = 8;    }}//// M_Init//void M_Init (void){    currentMenu = &MainDef;    menuactive = 0;    itemOn = currentMenu->lastOn;    whichSkull = 0;    skullAnimCounter = 10;    screenSize = screenblocks - 3;    messageToPrint = 0;    messageString = NULL;    messageLastMenuActive = menuactive;    quickSaveSlot = -1;    // Here we could catch other version dependencies,    //  like HELP1/2, and four episodes.      switch ( gamemode )    {      case commercial:	// This is used because DOOM 2 had only one HELP        //  page. I use CREDIT as second page now, but	//  kept this hack for educational purposes.	MainMenu[readthis] = MainMenu[quitdoom];	MainDef.numitems--;	MainDef.y += 8;	NewDef.prevMenu = &MainDef;	ReadDef1.routine = M_DrawReadThis1;	ReadDef1.x = 330;	ReadDef1.y = 165;	ReadMenu1[0].routine = M_FinishReadThis;	break;      case shareware:	// Episode 2 and 3 are handled,	//  branching to an ad screen.      case registered:	// We need to remove the fourth episode.	EpiDef.numitems--;	break;      case retail:	// We are fine.      default:	break;    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -