X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=menu.c;h=b4ee44b8e00d5337cd97930656e5dbaa979d794b;hb=66ae08799675241ffa3cc3bcaa211fddcd63387c;hp=fe2097a98d51b7ea81544ca905beb1239eceb4cd;hpb=78da49ba852ed63b1079cc1ab8545e82c4abd78e;p=xonotic%2Fdarkplaces.git diff --git a/menu.c b/menu.c index fe2097a9..b4ee44b8 100644 --- a/menu.c +++ b/menu.c @@ -18,9 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "quakedef.h" +#include "image.h" -void (*vid_menudrawfn)(void); -void (*vid_menukeyfn)(int key); #define TYPE_DEMO 1 #define TYPE_GAME 2 @@ -46,6 +45,7 @@ void M_Menu_Main_f (void); void M_Menu_LanConfig_f (void); void M_Menu_GameOptions_f (void); void M_Menu_Search_f (void); +void M_Menu_InetSearch_f (void); void M_Menu_ServerList_f (void); void M_Main_Draw (void); @@ -64,6 +64,7 @@ void M_Main_Draw (void); void M_LanConfig_Draw (void); void M_GameOptions_Draw (void); void M_Search_Draw (void); +void M_InetSearch_Draw (void); void M_ServerList_Draw (void); void M_Main_Key (int key); @@ -82,6 +83,7 @@ void M_Main_Key (int key); void M_LanConfig_Key (int key); void M_GameOptions_Key (int key); void M_Search_Key (int key); +void M_InetSearch_Key (int key); void M_ServerList_Key (int key); qboolean m_entersound; // play after drawing a frame, so caching @@ -170,12 +172,12 @@ void M_DrawCharacter (float cx, float cy, int num) DrawQ_String(menu_x + cx, menu_y + cy, temp, 1, 8, 8, 1, 1, 1, 1, 0); } -void M_Print (float cx, float cy, char *str) +void M_Print (float cx, float cy, const char *str) { DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0); } -void M_PrintWhite (float cx, float cy, char *str) +void M_PrintWhite (float cx, float cy, const char *str) { DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0); } @@ -853,7 +855,7 @@ void M_MultiPlayer_Draw (void) if (ipxAvailable || tcpipAvailable) return; - M_PrintWhite ((320/2) - ((27*8)/2), 148, "No Communications Available"); + M_PrintWhite ((320/2) - ((27*8)/2), 168, "No Communications Available"); } @@ -968,7 +970,7 @@ void M_MenuPlayerTranslate (qbyte *translation, int top, int bottom) M_BuildTranslationTable (menuplyr_top*16, menuplyr_bottom*16); for (i = 0;i < menuplyr_width * menuplyr_height;i++) - trans[i] = d_8to24table[translation[pixels[i]]]; + trans[i] = palette_complete[translation[pixels[i]]]; Draw_NewPic("gfx/menuplyr.lmp", menuplyr_width, menuplyr_height, true, (qbyte *)trans); } @@ -1385,7 +1387,7 @@ void M_Options_Draw (void) M_Print(16, y, " Customize controls");y += 8; M_Print(16, y, " Go to console");y += 8; M_Print(16, y, " Reset to defaults");y += 8; - M_ItemPrint(16, y, " Video Options", vid_menudrawfn != NULL);y += 8; + M_Print(16, y, " Video Options");y += 8; M_Print(16, y, " Effects Options");y += 8; M_Print(16, y, " 2D Resolution");M_DrawSlider(220, y, scr_2dresolution.value);y += 8; M_Print(16, y, " Screen size");M_DrawSlider(220, y, (scr_viewsize.value - 30) /(120 - 30));y += 8; @@ -1439,8 +1441,7 @@ void M_Options_Key (int k) Cbuf_AddText ("exec default.cfg\n"); break; case 3: - if (vid_menudrawfn) - M_Menu_Video_f (); + M_Menu_Video_f (); break; case 4: M_Menu_Options_Effects_f (); @@ -1659,6 +1660,8 @@ char *transfusionbindnames[][2] = { {"+forward", "walk forward"}, {"+back", "backpedal"}, +{"+left", "turn left"}, +{"+right", "turn right"}, {"+moveleft", "step left"}, {"+moveright", "step right"}, {"+jump", "jump / swim up"}, @@ -1950,23 +1953,165 @@ void M_Keys_Key (int k) //============================================================================= /* VIDEO MENU */ +#define VIDEO_ITEMS 5 + +int video_cursor = 0; +int video_cursor_table[] = {56, 68, 80, 92, 116}; +unsigned short video_resolutions[][2] = {{512,384}, {640,480}, {800,600}, {1024,768}, {1280,960}}; +int video_resolution; + +extern int current_vid_fullscreen; +extern int current_vid_width; +extern int current_vid_height; +extern int current_vid_bitsperpixel; +extern int current_vid_stencil; + + void M_Menu_Video_f (void) { key_dest = key_menu; m_state = m_video; m_entersound = true; + + // Look for the current resolution + for (video_resolution = 0; video_resolution < (int) (sizeof (video_resolutions) / sizeof (video_resolutions[0])); video_resolution++) + { + if (video_resolutions[video_resolution][0] == current_vid_width && + video_resolutions[video_resolution][1] == current_vid_height) + break; + } + + // Default to 800x600 if we didn't find it + if (video_resolution == sizeof (video_resolutions) / sizeof (video_resolutions[0])) + { + video_resolution = 2; + Cvar_SetValueQuick (&vid_width, video_resolutions[video_resolution][0]); + Cvar_SetValueQuick (&vid_height, video_resolutions[video_resolution][1]); + } } void M_Video_Draw (void) { - (*vid_menudrawfn) (); + cachepic_t *p; + const char* string; + + M_DrawPic(16, 4, "gfx/qplaque.lmp"); + p = Draw_CachePic("gfx/vidmodes.lmp"); + M_DrawPic((320-p->width)/2, 4, "gfx/vidmodes.lmp"); + + // Resolution + M_Print(16, video_cursor_table[0], " Resolution"); + string = va("%dx%d", video_resolutions[video_resolution][0], video_resolutions[video_resolution][1]); + M_Print (220, video_cursor_table[0], string); + + // Bits per pixel + M_Print(16, video_cursor_table[1], " Bits per pixel"); + M_Print (220, video_cursor_table[1], (vid_bitsperpixel.integer == 32) ? "32" : "16"); + + // Fullscreen + M_Print(16, video_cursor_table[2], " Fullscreen"); + M_DrawCheckbox(220, video_cursor_table[2], vid_fullscreen.integer); + + // Stencil + M_Print(16, video_cursor_table[3], " Stencil"); + M_DrawCheckbox(220, video_cursor_table[3], vid_stencil.integer); + + // "Apply" button + M_Print(220, video_cursor_table[4], "Apply"); + + // Cursor + M_DrawCharacter(200, video_cursor_table[video_cursor], 12+((int)(realtime*4)&1)); +} + + +void M_Menu_Video_AdjustSliders (int dir) +{ + S_LocalSound ("misc/menu3.wav"); + + switch (video_cursor) + { + // Resolution + case 0: + { + int new_resolution = video_resolution + dir; + if (new_resolution < 0) + video_resolution = sizeof (video_resolutions) / sizeof (video_resolutions[0]) - 1; + else if (new_resolution > (int) (sizeof (video_resolutions) / sizeof (video_resolutions[0]) - 1)) + video_resolution = 0; + else + video_resolution = new_resolution; + + Cvar_SetValueQuick (&vid_width, video_resolutions[video_resolution][0]); + Cvar_SetValueQuick (&vid_height, video_resolutions[video_resolution][1]); + break; + } + + // Bits per pixel + case 1: + Cvar_SetValueQuick (&vid_bitsperpixel, (vid_bitsperpixel.integer == 32) ? 16 : 32); + break; + case 2: + Cvar_SetValueQuick (&vid_fullscreen, !vid_fullscreen.integer); + break; + case 3: + Cvar_SetValueQuick (&vid_stencil, !vid_stencil.integer); + break; + } } void M_Video_Key (int key) { - (*vid_menukeyfn) (key); + switch (key) + { + case K_ESCAPE: + // vid_shared.c has a copy of the current video config. We restore it + Cvar_SetValueQuick(&vid_fullscreen, current_vid_fullscreen); + Cvar_SetValueQuick(&vid_width, current_vid_width); + Cvar_SetValueQuick(&vid_height, current_vid_height); + Cvar_SetValueQuick(&vid_bitsperpixel, current_vid_bitsperpixel); + Cvar_SetValueQuick(&vid_stencil, current_vid_stencil); + + S_LocalSound ("misc/menu1.wav"); + M_Menu_Options_f (); + break; + + case K_ENTER: + m_entersound = true; + switch (video_cursor) + { + case 4: + Cbuf_AddText ("vid_restart\n"); + M_Menu_Options_f (); + break; + default: + M_Menu_Video_AdjustSliders (1); + } + break; + + case K_UPARROW: + S_LocalSound ("misc/menu1.wav"); + video_cursor--; + if (video_cursor < 0) + video_cursor = VIDEO_ITEMS-1; + break; + + case K_DOWNARROW: + S_LocalSound ("misc/menu1.wav"); + video_cursor++; + if (video_cursor >= VIDEO_ITEMS) + video_cursor = 0; + break; + + case K_LEFTARROW: + M_Menu_Video_AdjustSliders (-1); + break; + + case K_RIGHTARROW: + M_Menu_Video_AdjustSliders (1); + break; + } } //============================================================================= @@ -2148,8 +2293,8 @@ void M_Quit_Draw (void) /* LAN CONFIG MENU */ int lanConfig_cursor = -1; -int lanConfig_cursor_table [] = {72, 92, 124}; -#define NUM_LANCONFIG_CMDS 3 +int lanConfig_cursor_table [] = {72, 92, 112, 144}; +#define NUM_LANCONFIG_CMDS 4 int lanConfig_port; char lanConfig_portname[6]; @@ -2213,9 +2358,10 @@ void M_LanConfig_Draw (void) if (JoiningGame) { M_Print (basex, lanConfig_cursor_table[1], "Search for local games..."); - M_Print (basex, 108, "Join game at:"); - M_DrawTextBox (basex+8, lanConfig_cursor_table[2]-8, 22, 1); - M_Print (basex+16, lanConfig_cursor_table[2], lanConfig_joinname); + M_Print (basex, lanConfig_cursor_table[2], "Search for internet games..."); + M_Print (basex, 128, "Join game at:"); + M_DrawTextBox (basex+8, lanConfig_cursor_table[3]-8, 22, 1); + M_Print (basex+16, lanConfig_cursor_table[3], lanConfig_joinname); } else { @@ -2228,11 +2374,11 @@ void M_LanConfig_Draw (void) if (lanConfig_cursor == 0) M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*4)&1)); - if (lanConfig_cursor == 2) - M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*4)&1)); + if (lanConfig_cursor == 3) + M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [3], 10+((int)(realtime*4)&1)); if (*m_return_reason) - M_PrintWhite (basex, 148, m_return_reason); + M_PrintWhite (basex, 168, m_return_reason); } @@ -2268,18 +2414,21 @@ void M_LanConfig_Key (int key) M_ConfigureNetSubsystem (); - if (lanConfig_cursor == 1) + if (lanConfig_cursor == 1 || lanConfig_cursor == 2) { if (StartingGame) { M_Menu_GameOptions_f (); break; } - M_Menu_Search_f(); + if (lanConfig_cursor == 1) + M_Menu_Search_f(); + else + M_Menu_InetSearch_f(); break; } - if (lanConfig_cursor == 2) + if (lanConfig_cursor == 3) { m_return_state = m_state; m_return_onerror = true; @@ -2298,7 +2447,7 @@ void M_LanConfig_Key (int key) lanConfig_portname[strlen(lanConfig_portname)-1] = 0; } - if (lanConfig_cursor == 2) + if (lanConfig_cursor == 3) { if (strlen(lanConfig_joinname)) lanConfig_joinname[strlen(lanConfig_joinname)-1] = 0; @@ -2309,7 +2458,7 @@ void M_LanConfig_Key (int key) if (key < 32 || key > 127) break; - if (lanConfig_cursor == 2) + if (lanConfig_cursor == 3) { l = strlen(lanConfig_joinname); if (l < 21) @@ -2332,7 +2481,7 @@ void M_LanConfig_Key (int key) } } - if (StartingGame && lanConfig_cursor == 2) + if (StartingGame && lanConfig_cursor == 3) { if (key == K_UPARROW) lanConfig_cursor = 1; @@ -2546,8 +2695,12 @@ level_t transfusionlevels[] = {"bb6", "Twin Fortress"}, {"bb7", "Midgard"}, {"bb8", "Fun With Heads"}, + {"e1m1", "Cradle to Grave"}, + {"e1m2", "Wrong Side of the Tracks"}, {"e1m7", "Altar of Stone"}, + {"e3m7", "The Pit of Cerberus"}, + {"e4m8", "The Hall of the Epiphany"}, {"dm1", "Monolith Building 11"}, {"dm2", "Power!"}, @@ -2564,21 +2717,28 @@ level_t transfusionlevels[] = {"crypt", "The Crypt"}, {"bb3_2k1", "Bodies Infusion"}, - {"dranzbb6", "Black Coffee"}, + {"dcamp", "DeathCamp"}, + {"highnoon", "HighNoon"}, {"qbb1", "The Confluence"}, {"qbb2", "KathartiK"}, {"qbb3", "Caleb's Woodland Retreat"}, + + {"dranzbb6", "Black Coffee"}, + {"fragm", "Frag'M"}, + {"maim", "Maim"}, {"qe1m7", "The House of Chthon"}, {"simple", "Dead Simple"} }; episode_t transfusionepisodes[] = { - {"Blood", 0, 10}, - {"Plasma Pack", 10, 4}, - {"Cryptic Passage", 14, 2}, - {"Blood 2", 16, 5}, - {"Custom", 21, 7} + {"Blood", 0, 8}, + {"Blood Single Player", 8, 5}, + {"Plasma Pack", 13, 4}, + {"Cryptic Passage", 17, 2}, + {"Blood 2", 19, 5}, + {"Transfusion", 24, 6}, + {"Conversions", 30, 5} }; gamelevels_t sharewarequakegame = {"Shareware Quake", quakelevels, quakeepisodes, 2}; @@ -2586,7 +2746,7 @@ gamelevels_t registeredquakegame = {"Quake", quakelevels, quakeepisodes, 7}; gamelevels_t hipnoticgame = {"Scourge of Armagon", hipnoticlevels, hipnoticepisodes, 6}; gamelevels_t roguegame = {"Dissolution of Eternity", roguelevels, rogueepisodes, 4}; gamelevels_t nehahragame = {"Nehahra", nehahralevels, nehahraepisodes, 4}; -gamelevels_t transfusiongame = {"Transfusion", transfusionlevels, transfusionepisodes, 5}; +gamelevels_t transfusiongame = {"Transfusion", transfusionlevels, transfusionepisodes, 7}; typedef struct { @@ -2760,7 +2920,7 @@ void M_GameOptions_Draw (void) M_Print (x, 146, " More than 64 players?? "); M_Print (x, 154, " First, question your "); M_Print (x, 162, " sanity, then email "); - M_Print (x, 170, " havoc@gamevisions.com "); + M_Print (x, 170, " havoc@telefragged.com "); } else { @@ -2953,6 +3113,7 @@ void M_Menu_Search_f (void) void M_Search_Draw (void) { + const char* string; cachepic_t *p; int x; @@ -2980,7 +3141,11 @@ void M_Search_Draw (void) return; } - M_PrintWhite ((320/2) - ((22*8)/2), 64, "No Quake servers found"); + if (gamemode == GAME_TRANSFUSION) + string = "No Transfusion servers found"; + else + string = "No Quake servers found"; + M_PrintWhite ((320/2) - ((22*8)/2), 64, string); if ((realtime - searchCompleteTime) < 3.0) return; @@ -2992,6 +3157,32 @@ void M_Search_Key (int key) { } +//============================================================================= +/* INTERNET SEARCH MENU */ + +void M_Menu_InetSearch_f (void) +{ + key_dest = key_menu; + m_state = m_search; + m_entersound = false; + slistSilent = true; + slistLocal = false; + searchComplete = false; + NET_InetSlist_f(); + +} + + +void M_InetSearch_Draw (void) +{ + M_Search_Draw (); // it's the same one, so why bother? +} + + +void M_InetSearch_Key (int key) +{ +} + //============================================================================= /* SLIST MENU */ @@ -3047,7 +3238,7 @@ void M_ServerList_Draw (void) M_DrawCharacter (0, 32 + slist_cursor*8, 12+((int)(realtime*4)&1)); if (*m_return_reason) - M_PrintWhite (16, 148, m_return_reason); + M_PrintWhite (16, 168, m_return_reason); }