static int NehGameType;
enum m_state_e m_state;
-char m_return_reason[128];
void M_Menu_Main_f(cmd_state_t *cmd);
void M_Menu_SinglePlayer_f(cmd_state_t *cmd);
static qbool m_entersound; ///< play after drawing a frame, so caching won't disrupt the sound
-void M_Update_Return_Reason(const char *s)
-{
- strlcpy(m_return_reason, s, sizeof(m_return_reason));
- if (s)
- Con_DPrintf("%s\n", s);
-}
-
#define StartingGame (m_multiplayer_cursor == 1)
#define JoiningGame (m_multiplayer_cursor == 0)
{
if(mode == 0)
return; // the menu is off, and we want it off
- M_Menu_Main_f (&cmd_client);
+ M_Menu_Main_f (cmd_local);
}
else
{
strlcpy(keystring, "???", sizeof(keystring));
else
{
- char tinystr[2];
+ char tinystr[TINYSTR_LEN];
keystring[0] = 0;
for (j = 0;j < NUMKEYS;j++)
{
{
if (j > 0)
strlcat(keystring, " or ", sizeof(keystring));
- strlcat(keystring, Key_KeynumToString (keys[j], tinystr, sizeof(tinystr)), sizeof(keystring));
+ strlcat(keystring, Key_KeynumToString (keys[j], tinystr, TINYSTR_LEN), sizeof(keystring));
}
}
}
{
char line[80];
int keys[NUMKEYS];
- char tinystr[2];
+ char tinystr[TINYSTR_LEN];
if (bind_grab)
{ // defining a key
}
else //if (k != '`')
{
- dpsnprintf(line, sizeof(line), "bind \"%s\" \"%s\"\n", Key_KeynumToString(k, tinystr, sizeof(tinystr)), bindnames[keys_cursor][0]);
+ dpsnprintf(line, sizeof(line), "bind \"%s\" \"%s\"\n", Key_KeynumToString(k, tinystr, TINYSTR_LEN), bindnames[keys_cursor][0]);
Cbuf_InsertText (cmd, line);
}
// this is the number of the default mode (640x480) in the list above
int video_resolutions_hardcoded_count = sizeof(video_resolutions_hardcoded) / sizeof(*video_resolutions_hardcoded) - 1;
-#define VIDEO_ITEMS 11
+#define VIDEO_ITEMS 10
static int video_cursor = 0;
-static int video_cursor_table[VIDEO_ITEMS] = {68, 88, 96, 104, 112, 120, 128, 136, 144, 152, 168};
+static int video_cursor_table[VIDEO_ITEMS] = {68, 88, 96, 104, 112, 120, 128, 136, 144, 152};
static int menu_video_resolution;
video_resolution_t *video_resolutions;
case 'Y':
case 'y':
- Host_Quit_f(cmd);
+ host.state = host_shutdown;
break;
default:
lanConfig_port = 26000;
dpsnprintf(lanConfig_portname, sizeof(lanConfig_portname), "%u", (unsigned int) lanConfig_port);
- M_Update_Return_Reason("");
+ cl_connect_status[0] = '\0';
}
if (lanConfig_cursor == 3)
M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [lanConfig_cursor], 10+((int)(host.realtime*4)&1));
- if (*m_return_reason)
- M_Print(basex, 168, m_return_reason);
+ if (*cl_connect_status)
+ M_Print(basex, 168, cl_connect_status);
}
//=============================================================================
/* SLIST MENU */
-static int slist_cursor;
+static unsigned slist_cursor;
+static unsigned slist_visible;
void M_Menu_ServerList_f(cmd_state_t *cmd)
{
m_state = m_slist;
m_entersound = true;
slist_cursor = 0;
- M_Update_Return_Reason("");
+ cl_connect_status[0] = '\0';
if (lanConfig_cursor == 2)
Net_SlistQW_f(cmd);
else
static void M_ServerList_Draw (void)
{
- int n, y, visible, start, end, statnumplayers, statmaxplayers;
+ unsigned n, y, start, end, statnumplayers, statmaxplayers;
cachepic_t *p;
const char *s;
char vabuf[1024];
M_Background(640, vid_conheight.integer);
// scroll the list as the cursor moves
ServerList_GetPlayerStatistics(&statnumplayers, &statmaxplayers);
- s = va(vabuf, sizeof(vabuf), "%i/%i masters %i/%i servers %i/%i players", masterreplycount, masterquerycount, serverreplycount, serverquerycount, statnumplayers, statmaxplayers);
+ s = va(vabuf, sizeof(vabuf), "%u/%u masters %u/%u servers %u/%u players", masterreplycount, masterquerycount, serverreplycount, serverquerycount, statnumplayers, statmaxplayers);
M_PrintRed((640 - strlen(s) * 8) / 2, 32, s);
- if (*m_return_reason)
- M_Print(16, menu_height - 8, m_return_reason);
+ if (*cl_connect_status)
+ M_Print(16, menu_height - 8, cl_connect_status);
y = 48;
- visible = (int)((menu_height - 16 - y) / 8 / 2);
- start = bound(0, slist_cursor - (visible >> 1), serverlist_viewcount - visible);
- end = min(start + visible, serverlist_viewcount);
+ slist_visible = (menu_height - 16 - y) / 8 / 2;
+ start = min(slist_cursor - min(slist_cursor, slist_visible >> 1), serverlist_viewcount - min(serverlist_viewcount, slist_visible));
+ end = min(start + slist_visible, serverlist_viewcount);
p = Draw_CachePic ("gfx/p_multi");
M_DrawPic((640 - Draw_GetPicWidth(p)) / 2, 4, "gfx/p_multi");
Net_Slist_f(cmd);
break;
+ case K_PGUP:
+ slist_cursor -= slist_visible - 2;
case K_UPARROW:
case K_LEFTARROW:
S_LocalSound ("sound/misc/menu1.wav");
slist_cursor--;
- if (slist_cursor < 0)
+ if (slist_cursor >= serverlist_viewcount)
slist_cursor = serverlist_viewcount - 1;
break;
+ case K_PGDN:
+ slist_cursor += slist_visible - 2;
case K_DOWNARROW:
case K_RIGHTARROW:
S_LocalSound ("sound/misc/menu1.wav");
slist_cursor = 0;
break;
+ case K_HOME:
+ S_LocalSound ("sound/misc/menu1.wav");
+ slist_cursor = 0;
+ break;
+
+ case K_END:
+ S_LocalSound ("sound/misc/menu1.wav");
+ slist_cursor = serverlist_viewcount - 1;
+ break;
+
case K_ENTER:
S_LocalSound ("sound/misc/menu2.wav");
if (serverlist_viewcount)
m_state = m_modlist;
m_entersound = true;
modlist_cursor = 0;
- M_Update_Return_Reason("");
+ cl_connect_status[0] = '\0';
ModList_RebuildList();
}
for (y = 0; y < modlist_numenabled; y++)
M_PrintRed(432, 48 + y * 8, modlist[modlist_enabled[y]].dir);
- if (*m_return_reason)
- M_Print(16, menu_height - 8, m_return_reason);
+ if (*cl_connect_status)
+ M_Print(16, menu_height - 8, cl_connect_status);
// scroll the list as the cursor moves
y = 48;
visible = (int)((menu_height - 16 - y) / 8 / 2);
void M_KeyEvent (int key, int ascii, qbool downevent)
{
- cmd_state_t *cmd = &cmd_client;
+ cmd_state_t *cmd = cmd_local;
if (!downevent)
return;
switch (m_state)
va_start (argptr, format);
dpvsnprintf (errorstring, sizeof(errorstring), format, argptr);
va_end (argptr);
+
+ if (host.framecount < 3)
+ Sys_Error("Menu_Error: %s\n", errorstring);
+
Con_Printf( "Menu_Error: %s\n", errorstring );
if( !processingError ) {
R_SelectScene( RST_CLIENT );
// Let video start at least
- if(host.state != host_init)
- Host_AbortCurrentFrame();
+ Host_AbortCurrentFrame();
}
static void MVM_begin_increase_edicts(prvm_prog_t *prog)
for (i=0 ; i<prog->num_edicts ; i++)
{
ent = PRVM_EDICT_NUM(i);
- if (ent->priv.required->free)
+ if (ent->free)
continue;
active++;
}
static void MP_Init (void)
{
prvm_prog_t *prog = MVM_prog;
- PRVM_Prog_Init(prog, &cmd_client);
+ PRVM_Prog_Init(prog, cmd_local);
prog->edictprivate_size = 0; // no private struct used
prog->name = "menu";
{
int m;
m = ((Cmd_Argc(cmd) < 2) ? -1 : atoi(Cmd_Argv(cmd, 1)));
- Host_StartVideo();
+ CL_StartVideo();
if(MR_ToggleMenu)
MR_ToggleMenu(m);
}
-static qbool menu_active;
-
-static void MR_Start_f(cmd_state_t *cmd)
-{
- if(menu_active || cls.state == ca_dedicated)
- return;
- MR_Init();
-
-}
-
void MR_Init_Commands(void)
{
// set router console commands
Cvar_RegisterVariable (&forceqmenu);
Cvar_RegisterVariable (&menu_options_colorcontrol_correctionvalue);
Cvar_RegisterVariable (&menu_progs);
- Cmd_AddCommand(CF_CLIENT, "menu_start", MR_Start_f, "initialize the menu system");
Cmd_AddCommand(CF_CLIENT, "menu_restart", MR_Restart_f, "restart menu system (reloads menu.dat)");
Cmd_AddCommand(CF_CLIENT, "togglemenu", Call_MR_ToggleMenu_f, "opens or closes menu");
}
MR_SetRouting (true);
else
MR_SetRouting (false);
- menu_active = true;
}