X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=menu.c;h=90a85ba68cd71e6d30a54edf0c467b9bc88cd50a;hb=ef6014027abab4b524993e33b2698426d259804a;hp=9b17c584b76b6d4977076ffeb1efd907ff08d868;hpb=e888f3e74c64c1d3bdbc603b4d95a7a513a750ea;p=xonotic%2Fdarkplaces.git diff --git a/menu.c b/menu.c index 9b17c584..90a85ba6 100644 --- a/menu.c +++ b/menu.c @@ -33,7 +33,7 @@ static cvar_t forceqmenu = { 0, "forceqmenu", "0", "enables the quake menu inste static int NehGameType; enum m_state_e m_state; -char m_return_reason[32]; +char m_return_reason[128]; void M_Menu_Main_f (void); void M_Menu_SinglePlayer_f (void); @@ -107,11 +107,11 @@ static void M_ModList_Key (int key, int ascii); static qboolean m_entersound; ///< play after drawing a frame, so caching won't disrupt the sound -void M_Update_Return_Reason(char *s) +void M_Update_Return_Reason(const char *s) { strlcpy(m_return_reason, s, sizeof(m_return_reason)); if (s) - Con_Printf("%s\n", s); + Con_DPrintf("%s\n", s); } #define StartingGame (m_multiplayer_cursor == 1) @@ -121,8 +121,8 @@ void M_Update_Return_Reason(char *s) #define NumberOfNehahraDemos 34 typedef struct nehahrademonames_s { - char *name; - char *desc; + const char *name; + const char *desc; } nehahrademonames_t; static nehahrademonames_t NehahraDemos[NumberOfNehahraDemos] = @@ -167,8 +167,8 @@ static float menu_x, menu_y, menu_width, menu_height; static void M_Background(int width, int height) { - menu_width = bound(1, width, vid_conwidth.integer); - menu_height = bound(1, height, vid_conheight.integer); + menu_width = bound(1.0f, (float)width, vid_conwidth.value); + menu_height = bound(1.0f, (float)height, vid_conheight.value); menu_x = (vid_conwidth.integer - menu_width) * 0.5; menu_y = (vid_conheight.integer - menu_height) * 0.5; //DrawQ_Fill(menu_x, menu_y, menu_width, menu_height, 0, 0, 0, 0.5, 0); @@ -187,30 +187,30 @@ static void M_DrawCharacter (float cx, float cy, int num) char temp[2]; temp[0] = num; temp[1] = 0; - DrawQ_String_Font(menu_x + cx, menu_y + cy, temp, 1, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_MENU); + DrawQ_String(menu_x + cx, menu_y + cy, temp, 1, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_MENU); } static void M_PrintColored(float cx, float cy, const char *str) { - DrawQ_String_Font(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0, NULL, false, FONT_MENU); + DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0, NULL, false, FONT_MENU); } static void M_Print(float cx, float cy, const char *str) { - DrawQ_String_Font(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_MENU); + DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_MENU); } static void M_PrintRed(float cx, float cy, const char *str) { - DrawQ_String_Font(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 0, 0, 1, 0, NULL, true, FONT_MENU); + DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 0, 0, 1, 0, NULL, true, FONT_MENU); } static void M_ItemPrint(float cx, float cy, const char *str, int unghosted) { if (unghosted) - DrawQ_String_Font(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_MENU); + DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_MENU); else - DrawQ_String_Font(menu_x + cx, menu_y + cy, str, 0, 8, 8, 0.4, 0.4, 0.4, 1, 0, NULL, true, FONT_MENU); + DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 0.4, 0.4, 0.4, 1, 0, NULL, true, FONT_MENU); } static void M_DrawPic(float cx, float cy, const char *picname) @@ -270,23 +270,23 @@ static void M_DrawTextBox(float x, float y, float width, float height) /* ================ -M_ToggleMenu_f +M_ToggleMenu ================ */ -void M_ToggleMenu_f (void) +void M_ToggleMenu(int mode) { m_entersound = true; if ((key_dest != key_menu && key_dest != key_menu_grabbed) || m_state != m_main) { - if(Cmd_Argc() == 2 && !strcmp(Cmd_Argv(1), "1")) - return; + if(mode == 0) + return; // the menu is off, and we want it off M_Menu_Main_f (); } else { - if(Cmd_Argc() == 2 && !strcmp(Cmd_Argv(1), "0")) - return; + if(mode == 1) + return; // the menu is on, and we want it on key_dest = key_game; m_state = m_none; } @@ -817,12 +817,13 @@ static int loadable[MAX_SAVEGAMES]; static void M_ScanSaves (void) { - int i, j, len; + int i, j; + size_t len; char name[MAX_OSPATH]; char buf[SAVEGAME_COMMENT_LENGTH + 256]; const char *t; qfile_t *f; - int version; +// int version; for (i=0 ; iline1);y += 8; - M_PrintColored(0, y, serverlist_viewlist[n]->line2);y += 8; + M_PrintColored(0, y, entry->line1);y += 8; + M_PrintColored(0, y, entry->line2);y += 8; } } else if (realtime - masterquerytime > 10) @@ -4456,7 +4440,7 @@ static void M_ServerList_Key(int k, int ascii) case K_ENTER: S_LocalSound ("sound/misc/menu2.wav"); if (serverlist_viewcount) - Cbuf_AddText(va("connect \"%s\"\n", serverlist_viewlist[slist_cursor]->info.cname)); + Cbuf_AddText(va("connect \"%s\"\n", ServerList_GetViewEntry(slist_cursor)->info.cname)); break; default: @@ -4486,7 +4470,6 @@ typedef struct modlist_entry_s static int modlist_cursor; //static int modlist_viewcount; -#define MODLIST_TOTALSIZE 256 static int modlist_count = 0; static modlist_entry_t modlist[MODLIST_TOTALSIZE]; @@ -4694,7 +4677,7 @@ static void M_ModList_Key(int k, int ascii) static void M_KeyEvent(int key, int ascii, qboolean downevent); static void M_Draw(void); -void M_ToggleMenu_f(void); +void M_ToggleMenu(int mode); static void M_Shutdown(void); void M_Init (void) @@ -5033,6 +5016,10 @@ void M_KeyEvent (int key, int ascii, qboolean downevent) } +void M_NewMap(void) +{ +} + void M_Shutdown(void) { // reset key_dest @@ -5046,7 +5033,7 @@ void M_Restart(void) //============================================================================ // Menu prog handling -static char *m_required_func[] = { +static const char *m_required_func[] = { "m_init", "m_keydown", "m_draw", @@ -5142,16 +5129,26 @@ void MP_Draw (void) R_SelectScene( RST_CLIENT ); } -void MP_ToggleMenu_f (void) +void MP_ToggleMenu(int mode) { PRVM_Begin; PRVM_SetProg(PRVM_MENUPROG); + prog->globals.generic[OFS_PARM0] = (float) mode; PRVM_ExecuteProgram(prog->funcoffsets.m_toggle,"m_toggle() required"); PRVM_End; } +void MP_NewMap(void) +{ + PRVM_Begin; + PRVM_SetProg(PRVM_MENUPROG); + if (prog->funcoffsets.m_newmap) + PRVM_ExecuteProgram(prog->funcoffsets.m_newmap,"m_newmap() required"); + PRVM_End; +} + void MP_Shutdown (void) { PRVM_Begin; @@ -5212,8 +5209,9 @@ void MP_Restart(void) void (*MR_KeyEvent) (int key, int ascii, qboolean downevent); void (*MR_Draw) (void); -void (*MR_ToggleMenu_f) (void); +void (*MR_ToggleMenu) (int mode); void (*MR_Shutdown) (void); +void (*MR_NewMap) (void); void MR_SetRouting(qboolean forceold) { @@ -5225,8 +5223,9 @@ void MR_SetRouting(qboolean forceold) // set menu router function pointers MR_KeyEvent = M_KeyEvent; MR_Draw = M_Draw; - MR_ToggleMenu_f = M_ToggleMenu_f; + MR_ToggleMenu = M_ToggleMenu; MR_Shutdown = M_Shutdown; + MR_NewMap = M_NewMap; // init if(!m_init) @@ -5242,8 +5241,9 @@ void MR_SetRouting(qboolean forceold) // set menu router function pointers MR_KeyEvent = MP_KeyEvent; MR_Draw = MP_Draw; - MR_ToggleMenu_f = MP_ToggleMenu_f; + MR_ToggleMenu = MP_ToggleMenu; MR_Shutdown = MP_Shutdown; + MR_NewMap = MP_NewMap; if(!mp_init) { @@ -5263,9 +5263,11 @@ void MR_Restart(void) void Call_MR_ToggleMenu_f(void) { + int m; + m = ((Cmd_Argc() < 2) ? -1 : atoi(Cmd_Argv(1))); Host_StartVideo(); - if(MR_ToggleMenu_f) - MR_ToggleMenu_f(); + if(MR_ToggleMenu) + MR_ToggleMenu(m); } void MR_Init_Commands(void)