]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - menu.c
fixed some very ewww bugs (a few .c files made their way into the .o lists)
[xonotic/darkplaces.git] / menu.c
diff --git a/menu.c b/menu.c
index 926ad05f0bea6e57043aa7c665c7632f7c6889c7..23fbafcd2feeae2dfd5920e693855412b236662f 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -1955,56 +1955,76 @@ void M_Keys_Key (int k)
 
 #define VIDEO_ITEMS 5
 
-int video_cursor;
+int video_cursor = 0;
+int video_cursor_table[] = {56, 68, 80, 92, 116};
+// note: if modes are added to the beginning of this list, update the
+// video_resolution = x; in M_Menu_Video_f below
+unsigned short video_resolutions[][2] = {{320,240}, {400,300}, {512,384}, {640,480}, {800,600}, {1024,768}, {1152,864}, {1280,960}, {1280,1024}, {1600,1200}, {1792,1344}, {1920,1440}, {2048,1536}};
+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]))
+       {
+               // may need to update this number if mode list changes
+               video_resolution = 4;
+               Cvar_SetValueQuick (&vid_width, video_resolutions[video_resolution][0]);
+               Cvar_SetValueQuick (&vid_height, video_resolutions[video_resolution][1]);
+       }
 }
 
 
 void M_Video_Draw (void)
 {
        cachepic_t      *p;
-       float y;
        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");
 
-       y = 40;
-
        // Resolution
-       M_Print(16, y, "            Resolution");
-       switch (vid_width.integer)
-       {
-               case 512: string = "512x384"; break;
-               case 800: string = "800x600"; break;
-               case 1024: string = "1024x768"; break;
-               case 1280: string = "1280x960"; break;
-               default: string = "640x480";
-       }
-       M_Print (220, y, string);
-       y += 8;
+       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, y, "        Bits per pixel");
-       if (vid_bitsperpixel.integer == 32)
-               M_Print (220, y, "32");
-       else
-               M_Print (220, y, "16");
-       y += 8;
+       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);
 
-       M_Print(16, y, "            Fullscreen");M_DrawCheckbox(220, y, vid_fullscreen.integer);y += 8;
-       M_Print(16, y, "               Stencil");M_DrawCheckbox(220, y, vid_stencil.integer);y += 8;
+       // Stencil
+       M_Print(16, video_cursor_table[3], "               Stencil");
+       M_DrawCheckbox(220, video_cursor_table[3], vid_stencil.integer);
 
-       M_Print(220, y, "Apply");
+       // "Apply" button
+       M_Print(220, video_cursor_table[4], "Apply");
 
        // Cursor
-       M_DrawCharacter(200, 40 + video_cursor*8, 12+((int)(realtime*4)&1));
+       M_DrawCharacter(200, video_cursor_table[video_cursor], 12+((int)(realtime*4)&1));
 }
 
 
@@ -2017,46 +2037,22 @@ void M_Menu_Video_AdjustSliders (int dir)
                // Resolution
                case 0:
                {
-                       int new_width, new_height;
-                       if (dir < 0)
-                               switch (vid_width.integer)
-                               {
-                                       case 1280: new_width = 1024; break;
-                                       case 1024: new_width = 800; break;
-                                       case 640: new_width = 512; break;
-                                       case 512: new_width = 1280; break;
-                                       default: new_width = 640;
-                               }
+                       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
-                               switch (vid_width.integer)
-                               {
-                                       case 1280: new_width = 512; break;
-                                       case 1024: new_width = 1280; break;
-                                       case 800: new_width = 1024; break;
-                                       case 640: new_width = 800; break;
-                                       default: new_width = 640;
-                               }
-                       
-                       switch (new_width)
-                       {
-                               case 1280: new_height = 960; break;
-                               case 1024: new_height = 768; break;
-                               case 800: new_height = 600; break;
-                               case 512: new_height = 384; break;
-                               default: new_height = 480;
-                       }
+                               video_resolution = new_resolution;
 
-                       Cvar_SetValueQuick (&vid_width, new_width);
-                       Cvar_SetValueQuick (&vid_height, new_height);
+                       Cvar_SetValueQuick (&vid_width, video_resolutions[video_resolution][0]);
+                       Cvar_SetValueQuick (&vid_height, video_resolutions[video_resolution][1]);
                        break;
                }
 
                // Bits per pixel
                case 1:
-                       if (vid_bitsperpixel.integer == 32)
-                               Cvar_SetValueQuick (&vid_bitsperpixel, 16);
-                       else
-                               Cvar_SetValueQuick (&vid_bitsperpixel, 32);
+                       Cvar_SetValueQuick (&vid_bitsperpixel, (vid_bitsperpixel.integer == 32) ? 16 : 32);
                        break;
                case 2:
                        Cvar_SetValueQuick (&vid_fullscreen, !vid_fullscreen.integer);
@@ -2067,11 +2063,6 @@ void M_Menu_Video_AdjustSliders (int dir)
        }
 }
 
-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_Video_Key (int key)
 {
@@ -2181,7 +2172,7 @@ int               msgNumber;
 int            m_quit_prevstate;
 qboolean       wasInMenus;
 
-char *quitMessage [] = 
+char *quitMessage [] =
 {
 /* .........1.........2.... */
 /*
@@ -2209,12 +2200,12 @@ char *quitMessage [] =
   "   big loser in life.   ",
   "  Press N to stay proud ",
   "    and successful!     ",
+
   "   If you press Y to    ",
   "  quit, I will summon   ",
   "  Satan all over your   ",
   "      hard drive!       ",
+
   "  Um, Asmodeus dislikes ",
   " his children trying to ",
   " quit. Press Y to return",
@@ -2711,11 +2702,15 @@ level_t         transfusionlevels[] =
        {"e1m1",                "Cradle to Grave"},
        {"e1m2",                "Wrong Side of the Tracks"},
        {"e1m7",                "Altar of Stone"},
-       {"e4m8",                "The Hall Of Epiphany"},
+       {"e2m8",                "The Lair of Shial"},
+       {"e3m7",                "The Pit of Cerberus"},
+       {"e4m8",                "The Hall of the Epiphany"},
+       {"e4m9",                "Mall of the Dead"},
 
        {"dm1",                 "Monolith Building 11"},
        {"dm2",                 "Power!"},
        {"dm3",                 "Area 15"},
+       {"e6m1",                "Welcome to Your Life"},
        {"e6m8",                "Beauty and the Beast"},
 
        {"cpbb01",              "Crypt of Despair"},
@@ -2744,12 +2739,12 @@ level_t         transfusionlevels[] =
 episode_t      transfusionepisodes[] =
 {
        {"Blood", 0, 8},
-       {"Blood Single Player", 8, 4},
-       {"Plasma Pack", 12, 4},
-       {"Cryptic Passage", 16, 2},
-       {"Blood 2", 18, 5},
-       {"Transfusion", 23, 6},
-       {"Conversions", 29, 5}
+       {"Blood Single Player", 8, 7},
+       {"Plasma Pack", 15, 5},
+       {"Cryptic Passage", 20, 2},
+       {"Blood 2", 22, 5},
+       {"Transfusion", 27, 6},
+       {"Conversions", 33, 5}
 };
 
 gamelevels_t sharewarequakegame = {"Shareware Quake", quakelevels, quakeepisodes, 2};