📄 menu.c
字号:
break;
#endif
case MENU_VIDEO_RESOLUTION:
if (vid_menudrawfn)
{
menu_definition[i].type = MENU_SELECTABLE; // full usage
}
else
{
menu_definition[i].type = MENU_INVISIBLE; // ignore completely
}
break;
}
// find first and last valid index
if (menu_definition[i].type == MENU_SELECTABLE) // selectable
{
if (menu_first_index == 0)
{
menu_first_index = i;
}
menu_last_index = i;
}
i++;
}
}
void M_Menu_Draw (menu_definition_t *menu_definition, int *current_index)
{
qpic_t *p;
int i, last_valid_index;
int y;
// Adjust ignore flags to current situation
M_Menu_DrawCheck(menu_definition);
// check selection for cursor drawing
if (*current_index < menu_first_index)
{
*current_index = menu_first_index;
}
else if (*current_index > menu_last_index)
{
*current_index = menu_last_index;
}
else
{
last_valid_index = 0;
i = 1;
while (menu_definition[i].funcno != 0)
{
// check cursor
if (menu_definition[i].type == MENU_SELECTABLE) // selectable
{
last_valid_index = i;
if (*current_index == 0) // nothing choosen, then use first valid selection
{
*current_index = i;
}
}
else if (i == *current_index) // incorrect selection, jump back to last valid selection
{
*current_index = last_valid_index;
}
i++;
}
}
// Left side plaque and title
if (menu_definition[0].type)
{
switch (menu_definition[0].type)
{
case MENU_OPTIONS:
M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
p = Draw_CachePic ("gfx/p_option.lmp");
M_DrawPic ( (320-p->width)/2, 4, p);
break;
}
}
// display menu with cursor
y = 32;
i = 1;
while (menu_definition[i].funcno != 0)
{
if (menu_definition[i].type != MENU_INVISIBLE) // drawable menu point
{
if (i == *current_index) // draw cursor
{
M_DrawCharacter (200, y, 12+((int)(realtime*4)&1));
}
y = M_DrawFunction(&menu_definition[i], y);
}
i++;
}
}
// 2002-01-31 New menu system by Maddes end
// 2002-01-31 New menu system by Maddes start
/*
void M_Options_Key (int k)
{
switch (k)
{
case K_ESCAPE:
M_Menu_Main_f ();
break;
case K_ENTER:
m_entersound = true;
switch (options_cursor)
{
case 0:
M_Menu_Keys_f ();
break;
case 1:
m_state = m_none;
Con_ToggleConsole_f ();
break;
case 2:
Cbuf_AddText ("exec default.cfg\n");
break;
case 13: // 2001-12-16 M_LOOK cvar by Heffo/Maddes
M_Menu_Video_f ();
break;
default:
M_AdjustSliders (1);
break;
}
return;
case K_UPARROW:
S_LocalSound ("misc/menu1.wav");
options_cursor--;
if (options_cursor < 0)
options_cursor = OPTIONS_ITEMS-1;
break;
case K_DOWNARROW:
S_LocalSound ("misc/menu1.wav");
options_cursor++;
if (options_cursor >= OPTIONS_ITEMS)
options_cursor = 0;
break;
case K_LEFTARROW:
M_AdjustSliders (-1);
break;
case K_RIGHTARROW:
M_AdjustSliders (1);
break;
}
if (options_cursor == 13 && vid_menudrawfn == NULL) // 2001-12-16 M_LOOK cvar by Heffo/Maddes
{
if (k == K_UPARROW)
options_cursor = 12; // 2001-12-16 M_LOOK cvar by Heffo/Maddes
else
options_cursor = 0;
}
#ifdef _WIN32
if ((options_cursor == 14) && (modestate != MS_WINDOWED)) // 2001-12-16 M_LOOK cvar by Heffo/Maddes
{
if (k == K_UPARROW)
options_cursor = 13; // 2001-12-16 M_LOOK cvar by Heffo/Maddes
else
options_cursor = 0;
}
#endif
}
*/
void M_ExecFunction (menu_definition_t *menu_definition, int key)
{
qboolean m_changesound;
int dir;
// determine direction for sliders
dir = 0;
switch (key)
{
case K_RIGHTARROW:
case K_ENTER:
dir = 1;
break;
case K_LEFTARROW:
dir = -1;
break;
}
// execute function
m_changesound = false;
switch (menu_definition->funcno)
{
case MENU_MAIN:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = NULL;
M_Menu_Main_f ();
}
break;
// Options menu
case MENU_OPTIONS:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = m_menu_options;
current_cursor = &options_cursor;
m_entersound = true;
}
break;
case MENU_CUSTOMIZE_CONTROLS:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = NULL;
M_Menu_Keys_f ();
}
break;
case MENU_GO_TO_CONSOLE:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = NULL;
m_state = m_none;
Con_ToggleConsole_f ();
}
break;
case MENU_LOAD_DEFAULT_CFG:
if (key == K_ENTER)
{
Cbuf_AddText ("exec default.cfg\n");
m_changesound = true;
}
break;
case MENU_VIDEO_RESOLUTION:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = NULL;
M_Menu_Video_f ();
}
break;
// Control options menu
case MENU_CONTROL_OPTIONS:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = m_menu_control_options;
current_cursor = &control_options_cursor;
m_entersound = true;
}
break;
case MENU_MOUSESPEED:
if (dir != 0)
{
sensitivity->value += dir * 0.5;
if (sensitivity->value < 1)
sensitivity->value = 1;
if (sensitivity->value > 11)
sensitivity->value = 11;
Cvar_SetValue (sensitivity, sensitivity->value);
m_changesound = true;
}
break;
case MENU_ALWAYS_RUN:
if (dir != 0)
{
if (cl_forwardspeed->value > 200)
{
Cvar_Set (cl_forwardspeed, "200");
Cvar_Set (cl_backspeed, "200");
}
else
{
Cvar_Set (cl_forwardspeed, "400");
Cvar_Set (cl_backspeed, "400");
}
m_changesound = true;
}
break;
case MENU_LOOKSPRING:
if (dir != 0)
{
Cvar_SetValue (lookspring, !lookspring->value);
m_changesound = true;
}
break;
case MENU_LOOKSTRAFE:
if (dir != 0)
{
Cvar_SetValue (lookstrafe, !lookstrafe->value);
m_changesound = true;
}
break;
case MENU_MOUSELOOK:
if (dir != 0)
{
Cvar_SetValue (m_look, !m_look->value);
m_changesound = true;
}
break;
case MENU_INVERT_MOUSE:
if (dir != 0)
{
Cvar_SetValue (m_pitch, -m_pitch->value);
m_changesound = true;
}
break;
#ifdef _WIN32
case MENU_USE_MOUSE:
if (dir != 0)
{
Cvar_SetValue (_windowed_mouse, !_windowed_mouse->value);
m_changesound = true;
}
break;
#endif
// Sound options menu
case MENU_SOUND_OPTIONS:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = m_menu_sound_options;
current_cursor = &sound_options_cursor;
m_entersound = true;
}
break;
case MENU_CD_VOLUME:
if (dir != 0)
{
#ifdef _WIN32
bgmvolume->value += dir * 1.0;
#else
bgmvolume->value += dir * 0.1;
#endif
if (bgmvolume->value < 0)
bgmvolume->value = 0;
if (bgmvolume->value > 1)
bgmvolume->value = 1;
Cvar_SetValue (bgmvolume, bgmvolume->value);
m_changesound = true;
}
break;
case MENU_SOUND_VOLUME:
if (dir != 0)
{
volume->value += dir * 0.1;
if (volume->value < 0)
volume->value = 0;
if (volume->value > 1)
volume->value = 1;
Cvar_SetValue (volume, volume->value);
m_changesound = true;
}
break;
// External data menu
case MENU_EXTERNAL_DATA:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = m_menu_external_data;
current_cursor = &external_data_cursor;
m_entersound = true;
}
break;
case MENU_EXTERNAL_ENT:
if (dir != 0)
{
Cvar_SetValue (external_ent, !external_ent->value);
m_changesound = true;
}
break;
case MENU_EXTERNAL_VIS:
if (dir != 0)
{
Cvar_SetValue (external_vis, !external_vis->value);
m_changesound = true;
}
break;
#ifdef GLQUAKE
case MENU_EXTERNAL_LIT:
if (dir != 0)
{
Cvar_SetValue (external_lit, !external_lit->value);
m_changesound = true;
}
break;
#endif
// Client options menu
case MENU_CLIENT_OPTIONS:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = m_menu_client_options;
current_cursor = &client_options_cursor;
m_entersound = true;
}
break;
case MENU_CL_ENTITIES_MIN:
if (dir != 0)
{
Cvar_SetValue (cl_entities_min, cl_entities_min->value + dir * 50);
m_changesound = true;
}
break;
case MENU_CL_ENTITIES_TEMP_MIN:
if (dir != 0)
{
Cvar_SetValue (cl_entities_min_temp, cl_entities_min_temp->value + dir * 32);
m_changesound = true;
}
break;
case MENU_CL_ENTITIES_STATIC_MIN:
if (dir != 0)
{
Cvar_SetValue (cl_entities_min_static, cl_entities_min_static->value + dir * 32);
m_changesound = true;
}
break;
case MENU_CL_COMPATIBILITY:
if (dir != 0)
{
Cvar_SetValue (cl_compatibility, !cl_compatibility->value);
m_changesound = true;
}
break;
// Server options menu
case MENU_SERVER_OPTIONS:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = m_menu_server_options;
current_cursor = &server_options_cursor;
m_entersound = true;
}
break;
case MENU_SV_ENTITIES:
if (dir != 0)
{
Cvar_SetValue (sv_entities, sv_entities->value + dir * 50);
m_changesound = true;
}
break;
case MENU_SV_ENTITIES_TEMP:
if (dir != 0)
{
Cvar_SetValue (sv_entities_temp, sv_entities_temp->value + dir * 32);
m_changesound = true;
}
break;
case MENU_SV_ENTITIES_STATIC:
if (dir != 0)
{
Cvar_SetValue (sv_entities_static, sv_entities_static->value + dir * 32);
m_changesound = true;
}
break;
case MENU_SV_ENTITIES_COPY_TO_CL:
if (key == K_ENTER)
{
Cvar_SetValue (cl_entities_min, sv_entities->value);
Cvar_SetValue (cl_entities_min_temp, sv_entities_temp->value);
Cvar_SetValue (cl_entities_min_static, sv_entities_static->value);
m_changesound = true;
}
break;
case MENU_PR_ZONE_MIN_STRINGS:
if (dir != 0)
{
Cvar_SetValue (pr_zone_min_strings, pr_zone_min_strings->value + dir * 32);
m_changesound = true;
}
break;
case MENU_BUILTIN_REMAP:
if (dir != 0)
{
Cvar_SetValue (pr_builtin_remap, !pr_builtin_remap->value);
m_changesound = true;
}
break;
case MENU_SV_COMPATIBILITY:
if (dir != 0)
{
Cvar_SetValue (sv_compatibility, !sv_compatibility->value);
m_changesound = true;
}
break;
case MENU_NVS_ENABLE:
if (dir != 0)
{
Cvar_SetValue (nvs_svc_enable, !nvs_svc_enable->value);
m_changesound = true;
}
break;
// Video options menu
case MENU_VIDEO_OPTIONS:
if (key == K_ENTER || key == K_ESCAPE)
{
current_menu = m_menu_video_options;
current_cursor = &video_options_cursor;
m_entersound = true;
}
break;
case MENU_SCREENSIZE:
if (dir != 0)
{
scr_viewsize->value += dir * 10;
if (scr_viewsize->value < 30)
scr_viewsize->value = 30;
if (scr_viewsize->value > 120)
scr_viewsize->value = 120;
Cvar_SetValue (scr_viewsize, scr_viewsize->value);
m_changesound = true;
}
break;
case MENU_BRIGHTNESS:
if (dir != 0)
{
v_gamma->value -= dir * 0.05;
if (v_gamma->value < 0.5)
v_gamma->value = 0.5;
if (v_gamma->value > 1)
v_gamma->value = 1;
Cvar_SetValue (v_gamma, v_gamma->value);
m_changesound = true;
}
break;
case MENU_CON_ALPHA:
if (dir != 0)
{
Cvar_SetValue (con_alpha, con_alpha->value - dir * 0.1);
m_changesound = true;
}
break;
case MENU_CON_HEIGHT:
if (dir != 0)
{
Cvar_SetValue (scr_conheight, scr_conheight->value + dir * 0.1);
m_changesound = true;
}
break;
case MENU_SHOW_FPS:
if (dir != 0)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -