📄 menu.c
字号:
Cvar_SetValue (cl_showfps, !cl_showfps->value);
m_changesound = true;
}
break;
#ifdef GLQUAKE
case MENU_GL_MAXDEPTH:
if (dir != 0)
{
Cvar_SetValue (gl_maxdepth, gl_maxdepth->value + dir * 256);
m_changesound = true;
}
break;
#endif
}
if (m_changesound)
{
S_LocalSound ("misc/menu3.wav");
}
}
void M_Menu_Key (menu_definition_t *menu_definition, int *current_index, int key)
{
qboolean m_movesound;
m_movesound = false;
switch (key)
{
case K_UPARROW:
case K_DOWNARROW:
if (menu_first_index != 0
&& menu_first_index != menu_last_index)
{
int dir;
int old_index;
if (key == K_UPARROW)
{
dir = -1;
}
else
{
dir = 1;
}
old_index = *current_index;
do
{
*current_index += dir;
if (*current_index < menu_first_index)
{
*current_index = menu_last_index;
}
else if (*current_index > menu_last_index)
{
*current_index = menu_first_index;
}
}
while (menu_definition[*current_index].type != MENU_SELECTABLE);
if (*current_index != old_index)
{
m_movesound = true;
}
}
break;
case K_ESCAPE:
M_ExecFunction(&menu_definition[0], key);
break;
default:
if (*current_index > 0)
{
M_ExecFunction(&menu_definition[*current_index], key);
}
}
if (m_movesound)
{
S_LocalSound ("misc/menu1.wav");
}
}
// 2002-01-31 New menu system by Maddes start
//=============================================================================
/* KEYS MENU */
char *bindnames[][2] =
{
{"+attack", "attack"},
{"impulse 10", "change weapon"},
{"+jump", "jump / swim up"},
{"+forward", "walk forward"},
{"+back", "backpedal"},
{"+left", "turn left"},
{"+right", "turn right"},
{"+speed", "run"},
{"+moveleft", "step left"},
{"+moveright", "step right"},
{"+strafe", "sidestep"},
{"+lookup", "look up"},
{"+lookdown", "look down"},
{"centerview", "center view"},
{"+mlook", "mouse look"},
{"+klook", "keyboard look"},
{"+moveup", "swim up"},
{"+movedown", "swim down"}
};
#define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0]))
int keys_cursor;
int bind_grab;
void M_Menu_Keys_f (void)
{
key_dest = key_menu;
m_state = m_keys;
m_entersound = true;
}
void M_FindKeysForCommand (char *command, int *twokeys)
{
int count;
int j;
int l;
char *b;
twokeys[0] = twokeys[1] = -1;
l = strlen(command);
count = 0;
for (j=0 ; j<256 ; j++)
{
b = keybindings[j];
if (!b)
continue;
if (!strncmp (b, command, l) )
{
twokeys[count] = j;
count++;
if (count == 2)
break;
}
}
}
void M_UnbindCommand (char *command)
{
int j;
int l;
char *b;
l = strlen(command);
for (j=0 ; j<256 ; j++)
{
b = keybindings[j];
if (!b)
continue;
if (!strncmp (b, command, l) )
Key_SetBinding (j, "");
}
}
void M_Keys_Draw (void)
{
int i; //, l // 2001-12-10 Reduced compiler warnings by Jeff Ford
int keys[2];
char *name;
int x, y;
qpic_t *p;
p = Draw_CachePic ("gfx/ttl_cstm.lmp");
M_DrawPic ( (320-p->width)/2, 4, p);
if (bind_grab)
M_Print (12, 32, "Press a key or button for this action");
else
M_Print (18, 32, "Enter to change, backspace to clear");
// search for known bindings
for (i=0 ; i<NUMCOMMANDS ; i++)
{
y = 48 + 8*i;
M_Print (16, y, bindnames[i][1]);
// l = strlen (bindnames[i][0]); // 2001-12-10 Reduced compiler warnings by Jeff Ford
M_FindKeysForCommand (bindnames[i][0], keys);
if (keys[0] == -1)
{
M_Print (140, y, "???");
}
else
{
name = Key_KeynumToString (keys[0]);
M_Print (140, y, name);
x = strlen(name) * 8;
if (keys[1] != -1)
{
M_Print (140 + x + 8, y, "or");
M_Print (140 + x + 32, y, Key_KeynumToString (keys[1]));
}
}
}
if (bind_grab)
M_DrawCharacter (130, 48 + keys_cursor*8, '=');
else
M_DrawCharacter (130, 48 + keys_cursor*8, 12+((int)(realtime*4)&1));
}
void M_Keys_Key (int k)
{
char cmd[80];
int keys[2];
if (bind_grab)
{ // defining a key
S_LocalSound ("misc/menu1.wav");
if (k == K_ESCAPE)
{
bind_grab = false;
}
else if (k != '`')
{
sprintf (cmd, "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]);
Cbuf_InsertText (cmd);
}
bind_grab = false;
return;
}
switch (k)
{
case K_ESCAPE:
M_Menu_Options_f ();
break;
case K_LEFTARROW:
case K_UPARROW:
S_LocalSound ("misc/menu1.wav");
keys_cursor--;
if (keys_cursor < 0)
keys_cursor = NUMCOMMANDS-1;
break;
case K_DOWNARROW:
case K_RIGHTARROW:
S_LocalSound ("misc/menu1.wav");
keys_cursor++;
if (keys_cursor >= NUMCOMMANDS)
keys_cursor = 0;
break;
case K_ENTER: // go into bind mode
M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
S_LocalSound ("misc/menu2.wav");
if (keys[1] != -1)
M_UnbindCommand (bindnames[keys_cursor][0]);
bind_grab = true;
break;
case K_BACKSPACE: // delete bindings
case K_DEL: // delete bindings
S_LocalSound ("misc/menu2.wav");
M_UnbindCommand (bindnames[keys_cursor][0]);
break;
}
}
//=============================================================================
/* VIDEO MENU */
void M_Menu_Video_f (void)
{
key_dest = key_menu;
m_state = m_video;
m_entersound = true;
}
void M_Video_Draw (void)
{
(*vid_menudrawfn) ();
}
void M_Video_Key (int key)
{
(*vid_menukeyfn) (key);
}
//=============================================================================
/* HELP MENU */
int help_page;
#define NUM_HELP_PAGES 6
void M_Menu_Help_f (void)
{
key_dest = key_menu;
m_state = m_help;
m_entersound = true;
help_page = 0;
}
void M_Help_Draw (void)
{
M_DrawPic (0, 0, Draw_CachePic ( va("gfx/help%i.lmp", help_page)) );
}
void M_Help_Key (int key)
{
switch (key)
{
case K_ESCAPE:
M_Menu_Main_f ();
break;
case K_UPARROW:
case K_RIGHTARROW:
m_entersound = true;
if (++help_page >= NUM_HELP_PAGES)
help_page = 0;
break;
case K_DOWNARROW:
case K_LEFTARROW:
m_entersound = true;
if (--help_page < 0)
help_page = NUM_HELP_PAGES-1;
break;
}
}
//=============================================================================
/* QUIT MENU */
int msgNumber;
int m_quit_prevstate;
qboolean wasInMenus;
#ifndef _WIN32
char *quitMessage [] =
{
/* .........1.........2.... */
" Are you gonna quit ",
" this game just like ",
" everything else? ",
" ",
" Milord, methinks that ",
" thou art a lowly ",
" quitter. Is this true? ",
" ",
" Do I need to bust your ",
" face open for trying ",
" to quit? ",
" ",
" Man, I oughta smack you",
" for trying to quit! ",
" Press Y to get ",
" smacked out. ",
" Press Y to quit like a ",
" big loser in life. ",
" Press N to stay proud ",
" and successful! ",
" If you press Y to ",
" quit, I will summon ",
" Satan all over your ",
" hard drive! ",
" Um, Asmodeus dislikes ",
" his children trying to ",
" quit. Press Y to return",
" to your Tinkertoys. ",
" If you quit now, I'll ",
" throw a blanket-party ",
" for you next time! ",
" "
};
#endif
void M_Menu_Quit_f (void)
{
if (m_state == m_quit)
return;
wasInMenus = (key_dest == key_menu);
key_dest = key_menu;
m_quit_prevstate = m_state;
m_state = m_quit;
m_entersound = true;
msgNumber = rand()&7;
}
void M_Quit_Key (int key)
{
switch (key)
{
case K_ESCAPE:
case 'n':
case 'N':
if (wasInMenus)
{
m_state = m_quit_prevstate;
m_entersound = true;
}
else
{
key_dest = key_game;
m_state = m_none;
}
break;
case 'Y':
case 'y':
key_dest = key_console;
Host_Quit_f ();
break;
default:
break;
}
}
void M_Quit_Draw (void)
{
if (wasInMenus)
{
m_state = m_quit_prevstate;
m_recursiveDraw = true;
M_Draw ();
m_state = m_quit;
}
#ifdef _WIN32
M_DrawTextBox (0, 0, 38, 23);
M_PrintWhite (16, 12, " Quake version 1.09 by id Software\n\n");
M_PrintWhite (16, 28, "Programming Art \n");
M_Print (16, 36, " John Carmack Adrian Carmack\n");
M_Print (16, 44, " Michael Abrash Kevin Cloud\n");
M_Print (16, 52, " John Cash Paul Steed\n");
M_Print (16, 60, " Dave 'Zoid' Kirsch\n");
M_PrintWhite (16, 68, "Design Biz\n");
M_Print (16, 76, " John Romero Jay Wilbur\n");
M_Print (16, 84, " Sandy Petersen Mike Wilson\n");
M_Print (16, 92, " American McGee Donna Jackson\n");
M_Print (16, 100, " Tim Willits Todd Hollenshead\n");
M_PrintWhite (16, 108, "Support Projects\n");
M_Print (16, 116, " Barrett Alexander Shawn Green\n");
M_PrintWhite (16, 124, "Sound Effects\n");
M_Print (16, 132, " Trent Reznor and Nine Inch Nails\n\n");
M_PrintWhite (16, 140, "Quake is a trademark of Id Software,\n");
M_PrintWhite (16, 148, "inc., (c)1996 Id Software, inc. All\n");
M_PrintWhite (16, 156, "rights reserved. NIN logo is a\n");
M_PrintWhite (16, 164, "registered trademark licensed to\n");
M_PrintWhite (16, 172, "Nothing Interactive, Inc. All rights\n");
M_PrintWhite (16, 180, "reserved. Press y to exit\n");
#else
M_DrawTextBox (56, 76, 24, 4);
M_Print (64, 84, quitMessage[msgNumber*4+0]);
M_Print (64, 92, quitMessage[msgNumber*4+1]);
M_Print (64, 100, quitMessage[msgNumber*4+2]);
M_Print (64, 108, quitMessage[msgNumber*4+3]);
#endif
}
//=============================================================================
/* SERIAL CONFIG MENU */
int serialConfig_cursor;
int serialConfig_cursor_table[] = {48, 64, 80, 96, 112, 132};
#define NUM_SERIALCONFIG_CMDS 6
static int ISA_uarts[] = {0x3f8,0x2f8,0x3e8,0x2e8};
static int ISA_IRQs[] = {4,3,4,3};
int serialConfig_baudrate[] = {9600,14400,19200,28800,38400,57600};
int serialConfig_comport;
int serialConfig_irq ;
int serialConfig_baud;
char serialConfig_phone[16];
void M_Menu_SerialConfig_f (void)
{
int n;
int port;
int baudrate;
qboolean useModem;
key_dest = key_menu;
m_state = m_serialconfig;
m_entersound = true;
if (JoiningGame && SerialConfig)
serialConfig_cursor = 4;
else
serialConfig_cursor = 5;
(*GetComPortConfig) (0, &port, &serialConfig_irq, &baudrate, &useModem);
// map uart's port to COMx
for (n = 0; n < 4; n++)
if (ISA_uarts[n] == port)
break;
if (n == 4)
{
n = 0;
serialConfig_irq = 4;
}
serialConfig_comport = n + 1;
// map baudrate to index
for (n = 0; n < 6; n++)
if (serialConfig_baudrate[n] == baudrate)
break;
if (n == 6)
n = 5;
serialConfig_baud = n;
m_return_onerror = false;
m_return_reason[0] = 0;
}
void M_SerialConfig_Draw (void)
{
qpic_t *p;
int basex;
char *startJoin;
char *directModem;
M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic ("gfx/p_multi.lmp");
basex = (320-p->width)/2;
M_DrawPic (basex, 4, p);
if (StartingGame)
startJoin = "New Game";
else
startJoin = "Join Game";
if (SerialConfig)
directModem = "Modem";
else
directModem = "Direct Connect";
M_Print (basex, 32, va ("%s - %s", startJoin, directModem));
basex += 8;
M_Print (basex, serialConfig_cursor_table[0], "Port");
M_DrawTextBox (160, 40, 4, 1);
M_Print (168, serialConfig_cursor_table[0], va("COM%u", serialConfig_comport));
M_Print (basex, serialConfig_cursor_table[1], "IRQ");
M_DrawTextBox (160, serialConfig_cursor_table[1]-8, 1, 1);
M_Print (168, serialConfig_cursor_table[1], va("%u", serialConfig_irq));
M_Print (basex, serialConfig_cursor_table[2], "Baud");
M_DrawTextBox (160, serialConfig_cursor_table[2]-8, 5, 1);
M_Print (168, serialConfig_cursor_table[2], va("%u", serialConfig_baudrate[serialConfig_baud]));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -