mirror of
https://github.com/nzp-team/glquake.git
synced 2024-11-21 19:41:21 +00:00
Add pause menu, fix world text overlap
This commit is contained in:
parent
0d32a12615
commit
96a7b5d33d
8 changed files with 341 additions and 23 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
*/*.o
|
||||
*/*.d
|
||||
build/*
|
||||
*.sh
|
||||
|
|
BIN
nzportable.3dsx
BIN
nzportable.3dsx
Binary file not shown.
BIN
nzportable.elf
BIN
nzportable.elf
Binary file not shown.
|
@ -533,15 +533,15 @@ void HUD_WorldText(int alpha)
|
|||
|
||||
if (!strcmp("location", key)) // search for location key
|
||||
{
|
||||
Draw_ColoredString(4, vid.height/2 + 42, value, 255, 255, 255, alpha, 1);
|
||||
Draw_ColoredString(4, vid.height/2 + 32, value, 255, 255, 255, alpha, 1);
|
||||
}
|
||||
if (!strcmp("date", key)) // search for date key
|
||||
{
|
||||
Draw_ColoredString(4, vid.height/2 + 52, value, 255, 255, 255, alpha, 1);
|
||||
Draw_ColoredString(4, vid.height/2 + 42, value, 255, 255, 255, alpha, 1);
|
||||
}
|
||||
if (!strcmp("person", key)) // search for person key
|
||||
{
|
||||
Draw_ColoredString(4, vid.height/2 + 62, value, 255, 255, 255, alpha, 1);
|
||||
Draw_ColoredString(4, vid.height/2 + 52, value, 255, 255, 255, alpha, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ void HUD_Rounds (void)
|
|||
Draw_ColoredString(vid.width/2 - (strlen("Round")*16)/2, 80, "Round", 255, 0, 0, value, 2);
|
||||
|
||||
HUD_WorldText(value2);
|
||||
Draw_ColoredString(4, vid.height/2 + 32, "'Nazi Zombies'", 255, 255, 255, value2, 1);
|
||||
Draw_ColoredString(4, vid.height/2 + 22, "'Nazi Zombies'", 255, 255, 255, value2, 1);
|
||||
|
||||
value -= cl.time * 0.4;
|
||||
value2 += cl.time * 0.4;
|
||||
|
@ -631,7 +631,7 @@ void HUD_Rounds (void)
|
|||
// Hold world text for a few seconds
|
||||
else if (textstate == 2) {
|
||||
HUD_WorldText(255);
|
||||
Draw_ColoredString(4, vid.height/2 + 32, "'Nazi Zombies'", 255, 255, 255, 255, 1);
|
||||
Draw_ColoredString(4, vid.height/2 + 22, "'Nazi Zombies'", 255, 255, 255, 255, 1);
|
||||
|
||||
value2 += cl.time * 0.4;
|
||||
|
||||
|
@ -643,7 +643,7 @@ void HUD_Rounds (void)
|
|||
// Fade worldtext out, finally.
|
||||
else if (textstate == 3) {
|
||||
HUD_WorldText(value2);
|
||||
Draw_ColoredString(4, vid.height/2 + 32, "'Nazi Zombies'", 255, 255, 255, value2, 1);
|
||||
Draw_ColoredString(4, vid.height/2 + 22, "'Nazi Zombies'", 255, 255, 255, value2, 1);
|
||||
|
||||
value2 -= cl.time * 0.4;
|
||||
|
||||
|
|
|
@ -848,6 +848,7 @@ Fills a box of pixels with a single color
|
|||
void Draw_Fill (int x, int y, int w, int h, int r, int g, int b, int a)
|
||||
{
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glEnable (GL_ALPHA_TEST);
|
||||
glColor4f (r/255, g/255, b/255, a/255);
|
||||
|
||||
glBegin (GL_QUADS);
|
||||
|
@ -859,6 +860,7 @@ void Draw_Fill (int x, int y, int w, int h, int r, int g, int b, int a)
|
|||
|
||||
glEnd ();
|
||||
glColor4f (1,1,1,1);
|
||||
glDisable (GL_ALPHA_TEST);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
}
|
||||
//=============================================================================
|
||||
|
@ -1734,8 +1736,13 @@ int GL_LoadTexture32 (char *identifier, int width, int height, byte *data, qbool
|
|||
{
|
||||
if (!strcmp (identifier, glt->identifier))
|
||||
{
|
||||
if (width != glt->width || height != glt->height)
|
||||
Sys_Error ("GL_LoadTexture: cache mismatch");
|
||||
if (width != glt->width || height != glt->height) {
|
||||
// naievil -- fixme: this means we have a memory leak somewhere, was sys_error
|
||||
// OR that two different people used the same texture name
|
||||
// which is actually possible
|
||||
Con_Printf("GL_LoadTexture: cache mismatch for %s\n", identifier);
|
||||
break;
|
||||
}
|
||||
return gltextures[i].texnum;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -694,10 +694,10 @@ void Key_Event (int key, qboolean down)
|
|||
Key_Message (key);
|
||||
break;
|
||||
case key_menu:
|
||||
case key_menu_pause:
|
||||
M_Keydown (key);
|
||||
break;
|
||||
case key_game:
|
||||
break;
|
||||
case key_console:
|
||||
M_ToggleMenu_f ();
|
||||
break;
|
||||
|
@ -746,7 +746,7 @@ void Key_Event (int key, qboolean down)
|
|||
//
|
||||
// if not a consolekey, send to the interpreter no matter what mode is
|
||||
//
|
||||
if ( (key_dest == key_menu && menubound[key])
|
||||
if ( ((key_dest == key_menu || key_dest == key_menu_pause) && menubound[key])
|
||||
|| (key_dest == key_console && !consolekeys[key])
|
||||
|| (key_dest == key_game && ( !con_forcedup || !consolekeys[key] ) ) )
|
||||
{
|
||||
|
@ -781,6 +781,7 @@ void Key_Event (int key, qboolean down)
|
|||
Key_Message (key);
|
||||
break;
|
||||
case key_menu:
|
||||
case key_menu_pause:
|
||||
M_Keydown (key);
|
||||
break;
|
||||
|
||||
|
|
333
source/menu.c
333
source/menu.c
|
@ -24,6 +24,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "winquake.h"
|
||||
#endif
|
||||
|
||||
extern cvar_t r_wateralpha;
|
||||
extern cvar_t r_vsync;
|
||||
extern cvar_t in_disable_analog;
|
||||
extern cvar_t in_analog_strafe;
|
||||
extern cvar_t in_x_axis_adjust;
|
||||
extern cvar_t in_y_axis_adjust;
|
||||
extern cvar_t crosshair;
|
||||
extern cvar_t r_dithering;
|
||||
//extern cvar_t r_retro;
|
||||
extern cvar_t waypoint_mode;
|
||||
|
||||
extern int loadingScreen;
|
||||
extern char* loadname2;
|
||||
extern char* loadnamespec;
|
||||
|
@ -46,8 +57,31 @@ achievement_list_t achievement_list[MAX_ACHIEVEMENTS];
|
|||
void (*vid_menudrawfn)(void);
|
||||
void (*vid_menukeyfn)(int key);
|
||||
|
||||
enum {m_none, m_main, m_singleplayer, m_load, m_save, m_custommaps, m_setup, m_net, m_options, m_video, m_keys, m_quit, m_serialconfig, m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_slist} m_state;
|
||||
|
||||
enum
|
||||
{
|
||||
m_none,
|
||||
m_main,
|
||||
m_paused_menu,
|
||||
m_singleplayer,
|
||||
m_load,
|
||||
m_save,
|
||||
m_custommaps,
|
||||
m_setup,
|
||||
m_net,
|
||||
m_options,
|
||||
m_video,
|
||||
m_keys,
|
||||
m_help,
|
||||
m_quit,
|
||||
m_restart,
|
||||
m_exit,
|
||||
m_serialconfig,
|
||||
m_modemconfig,
|
||||
m_lanconfig,
|
||||
m_gameoptions,
|
||||
m_search,
|
||||
m_slist,
|
||||
} m_state;
|
||||
void M_Menu_Main_f (void);
|
||||
void M_Menu_SinglePlayer_f (void);
|
||||
void M_Menu_CustomMaps_f (void);
|
||||
|
@ -197,10 +231,9 @@ void M_ToggleMenu_f (void)
|
|||
{
|
||||
m_entersound = true;
|
||||
|
||||
// naievil -- fixme don't have pause yet
|
||||
if (key_dest == key_menu /*|| key_dest == key_menu_pause*/)
|
||||
if (key_dest == key_menu || key_dest == key_menu_pause)
|
||||
{
|
||||
if (m_state != m_main /*&& m_state != m_paused_menu*/)
|
||||
if (m_state != m_main && m_state != m_paused_menu)
|
||||
{
|
||||
M_Menu_Main_f ();
|
||||
return;
|
||||
|
@ -215,9 +248,7 @@ void M_ToggleMenu_f (void)
|
|||
}
|
||||
else if (sv.active && (svs.maxclients > 1 || key_dest == key_game))
|
||||
{
|
||||
Con_Printf("Draw pause here\n");
|
||||
// naievil -- fixme
|
||||
//M_Paused_Menu_f();
|
||||
M_Paused_Menu_f();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -226,6 +257,116 @@ void M_ToggleMenu_f (void)
|
|||
}
|
||||
|
||||
|
||||
int M_Paused_Cusor;
|
||||
#define Max_Paused_Iteams 5
|
||||
|
||||
void M_Paused_Menu_f ()
|
||||
{
|
||||
key_dest = key_menu_pause;
|
||||
m_state = m_paused_menu;
|
||||
m_entersound = true;
|
||||
loadingScreen = 0;
|
||||
loadscreeninit = false;
|
||||
M_Paused_Cusor = 0;
|
||||
}
|
||||
|
||||
static void M_Paused_Menu_Draw ()
|
||||
{
|
||||
// Fill black to make everything easier to see
|
||||
Draw_FillByColor(0, 0, vid.width, vid.height, 0, 0, 0, 102);
|
||||
|
||||
// Header
|
||||
Draw_ColoredString(10, 10, "PAUSED", 255, 255, 255, 255, 2);
|
||||
|
||||
if ((M_Paused_Cusor == 0))
|
||||
Draw_ColoredString(10, 135, "Resume", 255, 0, 0, 255, 1);
|
||||
else
|
||||
Draw_ColoredString(10, 135, "Resume", 255, 255, 255, 255, 1);
|
||||
|
||||
if ((M_Paused_Cusor == 1))
|
||||
Draw_ColoredString(10, 145, "Restart", 255, 0, 0, 255, 1);
|
||||
else
|
||||
Draw_ColoredString(10, 145, "Restart", 255, 255, 255, 255, 1);
|
||||
|
||||
if ((M_Paused_Cusor == 2))
|
||||
Draw_ColoredString(10, 155, "Settings", 255, 0, 0, 255, 1);
|
||||
else
|
||||
Draw_ColoredString(10, 155, "Settings", 255, 255, 255, 255, 1);
|
||||
|
||||
if (waypoint_mode.value) {
|
||||
if ((M_Paused_Cusor == 3))
|
||||
Draw_ColoredString(10, 165, "Save Waypoints", 255, 0, 0, 255, 1);
|
||||
else
|
||||
Draw_ColoredString(10, 165, "Save Waypoints", 255, 255, 255, 255, 1);
|
||||
} else {
|
||||
if ((M_Paused_Cusor == 3))
|
||||
Draw_ColoredString(10, 165, "Achievements", 255, 0, 0, 255, 1);
|
||||
else
|
||||
Draw_ColoredString(10, 165, "Achievements", 255, 255, 255, 255, 1);
|
||||
}
|
||||
|
||||
if ((M_Paused_Cusor == 4))
|
||||
Draw_ColoredString(10, 175, "Main Menu", 255, 0, 0, 255, 1);
|
||||
else
|
||||
Draw_ColoredString(10, 175, "Main Menu", 255, 255, 255, 255, 1);
|
||||
}
|
||||
|
||||
static void M_Paused_Menu_Key (int key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case K_ESCAPE:
|
||||
case K_AUX2:
|
||||
S_LocalSound ("sounds/menu/enter.wav");
|
||||
Cbuf_AddText("togglemenu\n");
|
||||
break;
|
||||
|
||||
case K_DOWNARROW:
|
||||
S_LocalSound ("sounds/menu/navigate.wav");
|
||||
if (++M_Paused_Cusor >= Max_Paused_Iteams)
|
||||
M_Paused_Cusor = 0;
|
||||
break;
|
||||
|
||||
case K_UPARROW:
|
||||
S_LocalSound ("sounds/menu/navigate.wav");
|
||||
if (--M_Paused_Cusor < 0)
|
||||
M_Paused_Cusor = Max_Paused_Iteams - 1;
|
||||
break;
|
||||
|
||||
case K_ENTER:
|
||||
case K_AUX1:
|
||||
m_entersound = true;
|
||||
|
||||
switch (M_Paused_Cusor)
|
||||
{
|
||||
case 0:
|
||||
key_dest = key_game;
|
||||
m_state = m_none;
|
||||
break;
|
||||
case 1:
|
||||
M_Menu_Restart_f();
|
||||
break;
|
||||
case 2:
|
||||
M_Menu_Options_f();
|
||||
key_dest = key_menu_pause;
|
||||
break;
|
||||
case 3:
|
||||
if (waypoint_mode.value) {
|
||||
Cbuf_AddText("impulse 101\n");
|
||||
}
|
||||
/*else
|
||||
M_Menu_Achievement_f();
|
||||
*/ // naievil -- fixme: do not have achievements
|
||||
key_dest = key_menu_pause;
|
||||
break;
|
||||
case 4:
|
||||
M_Menu_Exit_f();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/* MAIN MENU */
|
||||
|
||||
|
@ -306,6 +447,143 @@ void M_Main_Key (int key)
|
|||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/* RESTART MENU */
|
||||
|
||||
qboolean wasInMenus;
|
||||
|
||||
|
||||
char *restartMessage [] =
|
||||
{
|
||||
|
||||
" Are you sure you want",
|
||||
" to restart this game? ", //msg:0
|
||||
" ",
|
||||
" A :Yes B : No "
|
||||
};
|
||||
|
||||
|
||||
void M_Menu_Restart_f (void)
|
||||
{
|
||||
wasInMenus = (key_dest == key_menu_pause);
|
||||
key_dest = key_menu_pause;
|
||||
m_state = m_restart;
|
||||
m_entersound = true;
|
||||
}
|
||||
|
||||
|
||||
void M_Restart_Key (int key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case K_ESCAPE:
|
||||
case K_AUX2:
|
||||
case 'n':
|
||||
case 'N':
|
||||
m_state = m_paused_menu;
|
||||
m_entersound = true;
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
case 'y':
|
||||
case K_ENTER:
|
||||
case K_AUX1:
|
||||
key_dest = key_game;
|
||||
m_state = m_none;
|
||||
// Cbuf_AddText ("restart\n"); // nai -- old, now do soft reset
|
||||
PR_ExecuteProgram (pr_global_struct->Soft_Restart);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void M_Restart_Draw (void)
|
||||
{
|
||||
m_state = m_paused_menu;
|
||||
m_recursiveDraw = true;
|
||||
M_Draw ();
|
||||
m_state = m_restart;
|
||||
|
||||
M_DrawTextBox (56, 76, 24, 4);
|
||||
M_Print (64, 84, restartMessage[0]);
|
||||
M_Print (64, 92, restartMessage[1]);
|
||||
M_Print (64, 100, restartMessage[2]);
|
||||
M_Print (64, 108, restartMessage[3]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/* EXIT MENU */
|
||||
|
||||
|
||||
char *exitMessage [] =
|
||||
{
|
||||
|
||||
" Are you sure you want ",
|
||||
"to quit to the Main Menu?", //msg:0
|
||||
" ",
|
||||
" A :Yes B : No "
|
||||
};
|
||||
|
||||
|
||||
void M_Menu_Exit_f (void)
|
||||
{
|
||||
wasInMenus = (key_dest == key_menu_pause);
|
||||
key_dest = key_menu_pause;
|
||||
m_state = m_exit;
|
||||
m_entersound = true;
|
||||
}
|
||||
|
||||
|
||||
void M_Exit_Key (int key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case K_ESCAPE:
|
||||
case K_AUX2:
|
||||
case 'n':
|
||||
case 'N':
|
||||
m_state = m_paused_menu;
|
||||
m_entersound = true;
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
case 'y':
|
||||
case K_ENTER:
|
||||
case K_AUX1:
|
||||
Cbuf_AddText("disconnect\n");
|
||||
CL_ClearState ();
|
||||
M_Menu_Main_f();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void M_Exit_Draw (void)
|
||||
{
|
||||
m_state = m_paused_menu;
|
||||
m_recursiveDraw = true;
|
||||
M_Draw ();
|
||||
m_state = m_exit;
|
||||
|
||||
M_DrawTextBox (56, 76, 24, 4);
|
||||
M_Print (64, 84, exitMessage[0]);
|
||||
M_Print (64, 92, exitMessage[1]);
|
||||
M_Print (64, 100, exitMessage[2]);
|
||||
M_Print (64, 108, exitMessage[3]);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/* SINGLE PLAYER MENU */
|
||||
|
||||
|
@ -760,7 +1038,6 @@ int options_cursor;
|
|||
|
||||
void M_Menu_Options_f (void)
|
||||
{
|
||||
key_dest = key_menu;
|
||||
m_state = m_options;
|
||||
m_entersound = true;
|
||||
}
|
||||
|
@ -971,8 +1248,12 @@ void M_Options_Key (int k)
|
|||
M_AdjustSliders (1);
|
||||
break;
|
||||
|
||||
case K_ESCAPE:
|
||||
case K_AUX2:
|
||||
M_Menu_Main_f();
|
||||
if (key_dest == key_menu_pause)
|
||||
M_Paused_Menu_f();
|
||||
else
|
||||
M_Menu_Main_f ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1017,7 +1298,6 @@ int bind_grab;
|
|||
|
||||
void M_Menu_Keys_f (void)
|
||||
{
|
||||
key_dest = key_menu;
|
||||
m_state = m_keys;
|
||||
m_entersound = true;
|
||||
}
|
||||
|
@ -1140,6 +1420,10 @@ void M_Keys_Key (int k)
|
|||
|
||||
switch (k)
|
||||
{
|
||||
case K_ESCAPE:
|
||||
case K_AUX2:
|
||||
M_Menu_Options_f();
|
||||
break;
|
||||
|
||||
case K_LEFTARROW:
|
||||
case K_UPARROW:
|
||||
|
@ -1684,6 +1968,7 @@ void M_GameOptions_Key (int key)
|
|||
break;
|
||||
|
||||
case K_ENTER:
|
||||
case K_AUX1:
|
||||
S_LocalSound ("misc/menu2.wav");
|
||||
if (gameoptions_cursor == 0)
|
||||
{
|
||||
|
@ -1729,7 +2014,7 @@ void M_Init (void)
|
|||
|
||||
void M_Draw (void)
|
||||
{
|
||||
if (m_state == m_none || key_dest != key_menu)
|
||||
if (m_state == m_none || key_dest != key_menu && key_dest != key_menu_pause)
|
||||
return;
|
||||
|
||||
if (!m_recursiveDraw)
|
||||
|
@ -1758,6 +2043,10 @@ void M_Draw (void)
|
|||
case m_none:
|
||||
break;
|
||||
|
||||
case m_paused_menu:
|
||||
M_Paused_Menu_Draw();
|
||||
break;
|
||||
|
||||
case m_main:
|
||||
M_Main_Draw ();
|
||||
break;
|
||||
|
@ -1782,6 +2071,14 @@ void M_Draw (void)
|
|||
M_Quit_Draw ();
|
||||
break;
|
||||
|
||||
case m_restart:
|
||||
M_Restart_Draw ();
|
||||
break;
|
||||
|
||||
case m_exit:
|
||||
M_Exit_Draw ();
|
||||
break;
|
||||
|
||||
case m_gameoptions:
|
||||
M_GameOptions_Draw ();
|
||||
break;
|
||||
|
@ -1813,6 +2110,10 @@ void M_Keydown (int key)
|
|||
case m_none:
|
||||
return;
|
||||
|
||||
case m_paused_menu:
|
||||
M_Paused_Menu_Key (key);
|
||||
break;
|
||||
|
||||
case m_main:
|
||||
M_Main_Key (key);
|
||||
return;
|
||||
|
@ -1829,6 +2130,10 @@ void M_Keydown (int key)
|
|||
M_Keys_Key (key);
|
||||
return;
|
||||
|
||||
case m_restart:
|
||||
M_Restart_Key (key);
|
||||
return;
|
||||
|
||||
case m_video:
|
||||
M_Video_Key (key);
|
||||
return;
|
||||
|
@ -1837,6 +2142,10 @@ void M_Keydown (int key)
|
|||
M_Quit_Key (key);
|
||||
return;
|
||||
|
||||
case m_exit:
|
||||
M_Exit_Key (key);
|
||||
return;
|
||||
|
||||
case m_gameoptions:
|
||||
M_GameOptions_Key (key);
|
||||
return;
|
||||
|
|
|
@ -229,7 +229,7 @@ void Sys_SetKeys(u32 keys, u32 state){
|
|||
if( keys & KEY_SELECT)
|
||||
Key_Event(K_SELECT, state);
|
||||
if( keys & KEY_START)
|
||||
Key_Event(K_ENTER, state);
|
||||
Key_Event(K_ESCAPE, state);
|
||||
if( keys & KEY_DUP)
|
||||
Key_Event(K_UPARROW, state);
|
||||
if( keys & KEY_DDOWN)
|
||||
|
|
Loading…
Reference in a new issue