]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - menu.c
Fix setinfo.
[xonotic/darkplaces.git] / menu.c
diff --git a/menu.c b/menu.c
index d1311ca35d85823bd840614e3b2b6fd02e1ec136..05abaa862f882875be716803c007c33bb36b31b0 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -18,9 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 */
 #include "quakedef.h"
-#ifdef CONFIG_CD
 #include "cdaudio.h"
-#endif
 #include "image.h"
 #include "progsvm.h"
 
@@ -414,7 +412,7 @@ void M_Menu_Main_f (void)
                MAIN_ITEMS = 5;
 
        // check if the game data is missing and use a different main menu if so
-       m_missingdata = !forceqmenu.integer && Draw_CachePic (s)->tex == r_texture_notexture;
+       m_missingdata = !forceqmenu.integer && !Draw_IsPicLoaded(Draw_CachePic_Flags(s, CACHEPICFLAG_FAILONMISSING));
        if (m_missingdata)
                MAIN_ITEMS = 2;
 
@@ -458,7 +456,7 @@ static void M_Main_Draw (void)
                int y1, y2, y3;
                M_Background(640, 480);
                p = Draw_CachePic ("gfx/menu/tb-transfusion");
-               M_DrawPic (640/2 - p->width/2, 40, "gfx/menu/tb-transfusion");
+               M_DrawPic (640/2 - Draw_GetPicWidth(p)/2, 40, "gfx/menu/tb-transfusion");
                y2 = 120;
                // 8 rather than MAIN_ITEMS to skip a number and not miss the last option
                for (y1 = 1; y1 <= 8; y1++)
@@ -479,7 +477,7 @@ static void M_Main_Draw (void)
        M_Background(320, 200);
        M_DrawPic (16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/ttl_main");
-       M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_main");
+       M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/ttl_main");
 // Nehahra
        if (gamemode == GAME_NEHAHRA)
        {
@@ -758,7 +756,7 @@ static void M_SinglePlayer_Draw (void)
        // Some mods don't have a single player mode
        if (gamemode == GAME_GOODVSBAD2 || gamemode == GAME_BATTLEMECH)
        {
-               M_DrawPic ((320 - p->width) / 2, 4, "gfx/ttl_sgl");
+               M_DrawPic ((320 - Draw_GetPicWidth(p)) / 2, 4, "gfx/ttl_sgl");
 
                M_DrawTextBox (60, 8 * 8, 23, 4);
                if (gamemode == GAME_GOODVSBAD2)
@@ -771,7 +769,7 @@ static void M_SinglePlayer_Draw (void)
        {
                int             f;
 
-               M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_sgl");
+               M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/ttl_sgl");
                M_DrawPic (72, 32, "gfx/sp_menu");
 
                f = (int)(realtime * 10)%6;
@@ -925,7 +923,7 @@ static void M_Load_Draw (void)
        M_Background(320, 200);
 
        p = Draw_CachePic ("gfx/p_load");
-       M_DrawPic ( (320-p->width)/2, 4, "gfx/p_load" );
+       M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/p_load" );
 
        for (i=0 ; i< MAX_SAVEGAMES; i++)
                M_Print(16, 32 + 8*i, m_filenames[i]);
@@ -943,7 +941,7 @@ static void M_Save_Draw (void)
        M_Background(320, 200);
 
        p = Draw_CachePic ("gfx/p_save");
-       M_DrawPic ( (320-p->width)/2, 4, "gfx/p_save");
+       M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/p_save");
 
        for (i=0 ; i<MAX_SAVEGAMES ; i++)
                M_Print(16, 32 + 8*i, m_filenames[i]);
@@ -1052,7 +1050,7 @@ static void M_Transfusion_Episode_Draw (void)
        M_Background(640, 480);
 
        p = Draw_CachePic ("gfx/menu/tb-episodes");
-       M_DrawPic (640/2 - p->width/2, 40, "gfx/menu/tb-episodes");
+       M_DrawPic (640/2 - Draw_GetPicWidth(p)/2, 40, "gfx/menu/tb-episodes");
        for (y = 0; y < EPISODE_ITEMS; y++){
                M_DrawPic (0, 160 + y * 40, va(vabuf, sizeof(vabuf), "gfx/menu/episode%i", y+1));
        }
@@ -1110,7 +1108,7 @@ static void M_Transfusion_Skill_Draw (void)
        M_Background(640, 480);
 
        p = Draw_CachePic ("gfx/menu/tb-difficulty");
-       M_DrawPic(640/2 - p->width/2, 40, "gfx/menu/tb-difficulty");
+       M_DrawPic(640/2 - Draw_GetPicWidth(p)/2, 40, "gfx/menu/tb-difficulty");
 
        for (y = 0; y < SKILL_ITEMS; y++)
        {
@@ -1215,7 +1213,7 @@ static void M_MultiPlayer_Draw (void)
        {
                M_Background(640, 480);
                p = Draw_CachePic ("gfx/menu/tb-online");
-               M_DrawPic (640/2 - p->width/2, 140, "gfx/menu/tb-online");
+               M_DrawPic (640/2 - Draw_GetPicWidth(p)/2, 140, "gfx/menu/tb-online");
                for (f = 1; f <= MULTIPLAYER_ITEMS; f++)
                        M_DrawPic (0, 180 + f*40, va(vabuf, sizeof(vabuf), "gfx/menu/online%i", f));
                M_DrawPic (0, 220 + m_multiplayer_cursor * 40, va(vabuf, sizeof(vabuf), "gfx/menu/online%iselected", m_multiplayer_cursor + 1));
@@ -1225,7 +1223,7 @@ static void M_MultiPlayer_Draw (void)
 
        M_DrawPic (16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/p_multi");
-       M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi");
+       M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/p_multi");
        M_DrawPic (72, 32, "gfx/mp_menu");
 
        f = (int)(realtime * 10)%6;
@@ -1344,7 +1342,7 @@ static void M_Setup_Draw (void)
 
        M_DrawPic (16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/p_multi");
-       M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi");
+       M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/p_multi");
 
        M_Print(64, 40, "Your name");
        M_DrawTextBox (160, 32, 16, 1);
@@ -1415,7 +1413,7 @@ static void M_Setup_Draw (void)
                                }
                                menuplyr_translated[i] = palette_bgra_transparent[j];
                        }
-                       Draw_NewPic("gfx/menuplyr", menuplyr_width, menuplyr_height, true, (unsigned char *)menuplyr_translated);
+                       Draw_NewPic("gfx/menuplyr", menuplyr_width, menuplyr_height, (unsigned char *)menuplyr_translated, TEXTYPE_BGRA, TEXF_CLAMP);
                }
                M_DrawPic(160, 48, "gfx/bigbox");
                M_DrawPic(172, 56, "gfx/menuplyr");
@@ -1627,46 +1625,46 @@ static void M_Menu_Options_AdjustSliders (int dir)
        else if (options_cursor == optnum++) Cvar_SetValueQuick(&bgmvolume, bound(0, bgmvolume.value + dir * 0.0625, 1));
 }
 
-static int optnum;
-static int opty;
-static int optcursor;
+static int m_optnum;
+static int m_opty;
+static int m_optcursor;
 
 static void M_Options_PrintCommand(const char *s, int enabled)
 {
-       if (opty >= 32)
+       if (m_opty >= 32)
        {
-               if (optnum == optcursor)
-                       DrawQ_Fill(menu_x + 48, menu_y + opty, 320, 8, optnum == optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
-               M_ItemPrint(0 + 48, opty, s, enabled);
+               if (m_optnum == m_optcursor)
+                       DrawQ_Fill(menu_x + 48, menu_y + m_opty, 320, 8, m_optnum == m_optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
+               M_ItemPrint(0 + 48, m_opty, s, enabled);
        }
-       opty += 8;
-       optnum++;
+       m_opty += 8;
+       m_optnum++;
 }
 
 static void M_Options_PrintCheckbox(const char *s, int enabled, int yes)
 {
-       if (opty >= 32)
+       if (m_opty >= 32)
        {
-               if (optnum == optcursor)
-                       DrawQ_Fill(menu_x + 48, menu_y + opty, 320, 8, optnum == optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
-               M_ItemPrint(0 + 48, opty, s, enabled);
-               M_DrawCheckbox(0 + 48 + (int)strlen(s) * 8 + 8, opty, yes);
+               if (m_optnum == m_optcursor)
+                       DrawQ_Fill(menu_x + 48, menu_y + m_opty, 320, 8, m_optnum == m_optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
+               M_ItemPrint(0 + 48, m_opty, s, enabled);
+               M_DrawCheckbox(0 + 48 + (int)strlen(s) * 8 + 8, m_opty, yes);
        }
-       opty += 8;
-       optnum++;
+       m_opty += 8;
+       m_optnum++;
 }
 
 static void M_Options_PrintSlider(const char *s, int enabled, float value, float minvalue, float maxvalue)
 {
-       if (opty >= 32)
+       if (m_opty >= 32)
        {
-               if (optnum == optcursor)
-                       DrawQ_Fill(menu_x + 48, menu_y + opty, 320, 8, optnum == optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
-               M_ItemPrint(0 + 48, opty, s, enabled);
-               M_DrawSlider(0 + 48 + (int)strlen(s) * 8 + 8, opty, value, minvalue, maxvalue);
+               if (m_optnum == m_optcursor)
+                       DrawQ_Fill(menu_x + 48, menu_y + m_opty, 320, 8, m_optnum == m_optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
+               M_ItemPrint(0 + 48, m_opty, s, enabled);
+               M_DrawSlider(0 + 48 + (int)strlen(s) * 8 + 8, m_opty, value, minvalue, maxvalue);
        }
-       opty += 8;
-       optnum++;
+       m_opty += 8;
+       m_optnum++;
 }
 
 static void M_Options_Draw (void)
@@ -1678,12 +1676,12 @@ static void M_Options_Draw (void)
 
        M_DrawPic(16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/p_option");
-       M_DrawPic((320-p->width)/2, 4, "gfx/p_option");
+       M_DrawPic((320-Draw_GetPicWidth(p))/2, 4, "gfx/p_option");
 
-       optnum = 0;
-       optcursor = options_cursor;
+       m_optnum = 0;
+       m_optcursor = options_cursor;
        visible = (int)((menu_height - 32) / 8);
-       opty = 32 - bound(0, optcursor - (visible >> 1), max(0, OPTIONS_ITEMS - visible)) * 8;
+       m_opty = 32 - bound(0, m_optcursor - (visible >> 1), max(0, OPTIONS_ITEMS - visible)) * 8;
 
        M_Options_PrintCommand( "    Customize controls", true);
        M_Options_PrintCommand( "         Go to console", true);
@@ -1701,9 +1699,7 @@ static void M_Options_Draw (void)
        M_Options_PrintSlider(  "            Brightness", true, v_contrast.value, 1, 2);
        M_Options_PrintSlider(  "                 Gamma", true, v_gamma.value, 0.5, 3);
        M_Options_PrintSlider(  "          Sound Volume", snd_initialized.integer, volume.value, 0, 1);
-#ifdef CONFIG_CD
        M_Options_PrintSlider(  "          Music Volume", cdaudioinitialized.integer, bgmvolume.value, 0, 1);
-#endif
        M_Options_PrintCommand( "     Customize Effects", true);
        M_Options_PrintCommand( "       Effects:  Quake", true);
        M_Options_PrintCommand( "       Effects: Normal", true);
@@ -1887,12 +1883,12 @@ static void M_Options_Effects_Draw (void)
 
        M_DrawPic(16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/p_option");
-       M_DrawPic((320-p->width)/2, 4, "gfx/p_option");
+       M_DrawPic((320-Draw_GetPicWidth(p))/2, 4, "gfx/p_option");
 
-       optcursor = options_effects_cursor;
-       optnum = 0;
+       m_optcursor = options_effects_cursor;
+       m_optnum = 0;
        visible = (int)((menu_height - 32) / 8);
-       opty = 32 - bound(0, optcursor - (visible >> 1), max(0, OPTIONS_EFFECTS_ITEMS - visible)) * 8;
+       m_opty = 32 - bound(0, m_optcursor - (visible >> 1), max(0, OPTIONS_EFFECTS_ITEMS - visible)) * 8;
 
        M_Options_PrintCheckbox("             Particles", true, cl_particles.integer);
        M_Options_PrintCheckbox(" Quake-style Particles", true, cl_particles_quake.integer);
@@ -2034,12 +2030,12 @@ static void M_Options_Graphics_Draw (void)
 
        M_DrawPic(16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/p_option");
-       M_DrawPic((320-p->width)/2, 4, "gfx/p_option");
+       M_DrawPic((320-Draw_GetPicWidth(p))/2, 4, "gfx/p_option");
 
-       optcursor = options_graphics_cursor;
-       optnum = 0;
+       m_optcursor = options_graphics_cursor;
+       m_optnum = 0;
        visible = (int)((menu_height - 32) / 8);
-       opty = 32 - bound(0, optcursor - (visible >> 1), max(0, OPTIONS_GRAPHICS_ITEMS - visible)) * 8;
+       m_opty = 32 - bound(0, m_optcursor - (visible >> 1), max(0, OPTIONS_GRAPHICS_ITEMS - visible)) * 8;
 
        M_Options_PrintSlider(  "      Corona Intensity", true, r_coronas.value, 0, 4);
        M_Options_PrintCheckbox("      Use Only Coronas", true, gl_flashblend.integer);
@@ -2122,8 +2118,6 @@ static void M_Menu_Options_ColorControl_AdjustSliders (int dir)
 
        optnum = 1;
        if (options_colorcontrol_cursor == optnum++)
-               Cvar_SetValueQuick (&v_hwgamma, !v_hwgamma.integer);
-       else if (options_colorcontrol_cursor == optnum++)
        {
                Cvar_SetValueQuick (&v_color_enable, 0);
                Cvar_SetValueQuick (&v_gamma, bound(1, v_gamma.value + dir * 0.125, 5));
@@ -2216,7 +2210,8 @@ static void M_Menu_Options_ColorControl_AdjustSliders (int dir)
 static void M_Options_ColorControl_Draw (void)
 {
        int visible;
-       float x, c, s, t, u, v;
+       float x, s, t, u, v;
+       float c[3];
        cachepic_t      *p, *dither;
 
        dither = Draw_CachePic_Flags ("gfx/colorcontrol/ditherpattern", CACHEPICFLAG_NOCLAMP);
@@ -2225,16 +2220,15 @@ static void M_Options_ColorControl_Draw (void)
 
        M_DrawPic(16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/p_option");
-       M_DrawPic((320-p->width)/2, 4, "gfx/p_option");
+       M_DrawPic((320-Draw_GetPicWidth(p))/2, 4, "gfx/p_option");
 
-       optcursor = options_colorcontrol_cursor;
-       optnum = 0;
+       m_optcursor = options_colorcontrol_cursor;
+       m_optnum = 0;
        visible = (int)((menu_height - 32) / 8);
-       opty = 32 - bound(0, optcursor - (visible >> 1), max(0, OPTIONS_COLORCONTROL_ITEMS - visible)) * 8;
+       m_opty = 32 - bound(0, m_optcursor - (visible >> 1), max(0, OPTIONS_COLORCONTROL_ITEMS - visible)) * 8;
 
        M_Options_PrintCommand( "     Reset to defaults", true);
-       M_Options_PrintCheckbox("Hardware Gamma Control", vid_hardwaregammasupported.integer, v_hwgamma.integer);
-       M_Options_PrintSlider(  "                 Gamma", !v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, v_gamma.value, 1, 5);
+       M_Options_PrintSlider(  "                 Gamma", !v_color_enable.integer, v_gamma.value, 1, 5);
        M_Options_PrintSlider(  "              Contrast", !v_color_enable.integer, v_contrast.value, 1, 5);
        M_Options_PrintSlider(  "            Brightness", !v_color_enable.integer, v_brightness.value, 0, 0.8);
        M_Options_PrintCheckbox("  Color Level Controls", true, v_color_enable.integer);
@@ -2242,50 +2236,53 @@ static void M_Options_ColorControl_Draw (void)
        M_Options_PrintSlider(  "          Black: Green", v_color_enable.integer, v_color_black_g.value, 0, 0.8);
        M_Options_PrintSlider(  "          Black: Blue ", v_color_enable.integer, v_color_black_b.value, 0, 0.8);
        M_Options_PrintSlider(  "          Black: Grey ", v_color_enable.integer, (v_color_black_r.value + v_color_black_g.value + v_color_black_b.value) / 3, 0, 0.8);
-       M_Options_PrintSlider(  "           Grey: Red  ", v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, v_color_grey_r.value, 0, 0.95);
-       M_Options_PrintSlider(  "           Grey: Green", v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, v_color_grey_g.value, 0, 0.95);
-       M_Options_PrintSlider(  "           Grey: Blue ", v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, v_color_grey_b.value, 0, 0.95);
-       M_Options_PrintSlider(  "           Grey: Grey ", v_color_enable.integer && vid_hardwaregammasupported.integer && v_hwgamma.integer, (v_color_grey_r.value + v_color_grey_g.value + v_color_grey_b.value) / 3, 0, 0.95);
+       M_Options_PrintSlider(  "           Grey: Red  ", v_color_enable.integer, v_color_grey_r.value, 0, 0.95);
+       M_Options_PrintSlider(  "           Grey: Green", v_color_enable.integer, v_color_grey_g.value, 0, 0.95);
+       M_Options_PrintSlider(  "           Grey: Blue ", v_color_enable.integer, v_color_grey_b.value, 0, 0.95);
+       M_Options_PrintSlider(  "           Grey: Grey ", v_color_enable.integer, (v_color_grey_r.value + v_color_grey_g.value + v_color_grey_b.value) / 3, 0, 0.95);
        M_Options_PrintSlider(  "          White: Red  ", v_color_enable.integer, v_color_white_r.value, 1, 5);
        M_Options_PrintSlider(  "          White: Green", v_color_enable.integer, v_color_white_g.value, 1, 5);
        M_Options_PrintSlider(  "          White: Blue ", v_color_enable.integer, v_color_white_b.value, 1, 5);
        M_Options_PrintSlider(  "          White: Grey ", v_color_enable.integer, (v_color_white_r.value + v_color_white_g.value + v_color_white_b.value) / 3, 1, 5);
 
-       opty += 4;
-       DrawQ_Fill(menu_x, menu_y + opty, 320, 4 + 64 + 8 + 64 + 4, 0, 0, 0, 1, 0);opty += 4;
+       m_opty += 4;
+       DrawQ_Fill(menu_x, menu_y + m_opty, 320, 4 + 64 + 8 + 64 + 4, 0, 0, 0, 1, 0);m_opty += 4;
        s = (float) 312 / 2 * vid.width / vid_conwidth.integer;
        t = (float) 4 / 2 * vid.height / vid_conheight.integer;
-       DrawQ_SuperPic(menu_x + 4, menu_y + opty, dither, 312, 4, 0,0, 1,0,0,1, s,0, 1,0,0,1, 0,t, 1,0,0,1, s,t, 1,0,0,1, 0);opty += 4;
-       DrawQ_SuperPic(menu_x + 4, menu_y + opty, NULL  , 312, 4, 0,0, 0,0,0,1, 1,0, 1,0,0,1, 0,1, 0,0,0,1, 1,1, 1,0,0,1, 0);opty += 4;
-       DrawQ_SuperPic(menu_x + 4, menu_y + opty, dither, 312, 4, 0,0, 0,1,0,1, s,0, 0,1,0,1, 0,t, 0,1,0,1, s,t, 0,1,0,1, 0);opty += 4;
-       DrawQ_SuperPic(menu_x + 4, menu_y + opty, NULL  , 312, 4, 0,0, 0,0,0,1, 1,0, 0,1,0,1, 0,1, 0,0,0,1, 1,1, 0,1,0,1, 0);opty += 4;
-       DrawQ_SuperPic(menu_x + 4, menu_y + opty, dither, 312, 4, 0,0, 0,0,1,1, s,0, 0,0,1,1, 0,t, 0,0,1,1, s,t, 0,0,1,1, 0);opty += 4;
-       DrawQ_SuperPic(menu_x + 4, menu_y + opty, NULL  , 312, 4, 0,0, 0,0,0,1, 1,0, 0,0,1,1, 0,1, 0,0,0,1, 1,1, 0,0,1,1, 0);opty += 4;
-       DrawQ_SuperPic(menu_x + 4, menu_y + opty, dither, 312, 4, 0,0, 1,1,1,1, s,0, 1,1,1,1, 0,t, 1,1,1,1, s,t, 1,1,1,1, 0);opty += 4;
-       DrawQ_SuperPic(menu_x + 4, menu_y + opty, NULL  , 312, 4, 0,0, 0,0,0,1, 1,0, 1,1,1,1, 0,1, 0,0,0,1, 1,1, 1,1,1,1, 0);opty += 4;
-
-       c = menu_options_colorcontrol_correctionvalue.value; // intensity value that should be matched up to a 50% dither to 'correct' quake
+       DrawQ_SuperPic(menu_x + 4, menu_y + m_opty, dither, 312, 4, 0,0, 1,0,0,1, s,0, 1,0,0,1, 0,t, 1,0,0,1, s,t, 1,0,0,1, 0);m_opty += 4;
+       DrawQ_SuperPic(menu_x + 4, menu_y + m_opty, NULL  , 312, 4, 0,0, 0,0,0,1, 1,0, 1,0,0,1, 0,1, 0,0,0,1, 1,1, 1,0,0,1, 0);m_opty += 4;
+       DrawQ_SuperPic(menu_x + 4, menu_y + m_opty, dither, 312, 4, 0,0, 0,1,0,1, s,0, 0,1,0,1, 0,t, 0,1,0,1, s,t, 0,1,0,1, 0);m_opty += 4;
+       DrawQ_SuperPic(menu_x + 4, menu_y + m_opty, NULL  , 312, 4, 0,0, 0,0,0,1, 1,0, 0,1,0,1, 0,1, 0,0,0,1, 1,1, 0,1,0,1, 0);m_opty += 4;
+       DrawQ_SuperPic(menu_x + 4, menu_y + m_opty, dither, 312, 4, 0,0, 0,0,1,1, s,0, 0,0,1,1, 0,t, 0,0,1,1, s,t, 0,0,1,1, 0);m_opty += 4;
+       DrawQ_SuperPic(menu_x + 4, menu_y + m_opty, NULL  , 312, 4, 0,0, 0,0,0,1, 1,0, 0,0,1,1, 0,1, 0,0,0,1, 1,1, 0,0,1,1, 0);m_opty += 4;
+       DrawQ_SuperPic(menu_x + 4, menu_y + m_opty, dither, 312, 4, 0,0, 1,1,1,1, s,0, 1,1,1,1, 0,t, 1,1,1,1, s,t, 1,1,1,1, 0);m_opty += 4;
+       DrawQ_SuperPic(menu_x + 4, menu_y + m_opty, NULL  , 312, 4, 0,0, 0,0,0,1, 1,0, 1,1,1,1, 0,1, 0,0,0,1, 1,1, 1,1,1,1, 0);m_opty += 4;
+
+       c[0] = menu_options_colorcontrol_correctionvalue.value; // intensity value that should be matched up to a 50% dither to 'correct' quake
+       c[1] = c[0];
+       c[2] = c[1];
+       VID_ApplyGammaToColor(c, c);
        s = (float) 48 / 2 * vid.width / vid_conwidth.integer;
        t = (float) 48 / 2 * vid.height / vid_conheight.integer;
        u = s * 0.5;
        v = t * 0.5;
-       opty += 8;
+       m_opty += 8;
        x = 4;
-       DrawQ_Fill(menu_x + x, menu_y + opty, 64, 48, c, 0, 0, 1, 0);
-       DrawQ_SuperPic(menu_x + x + 16, menu_y + opty + 16, dither, 16, 16, 0,0, 1,0,0,1, s,0, 1,0,0,1, 0,t, 1,0,0,1, s,t, 1,0,0,1, 0);
-       DrawQ_SuperPic(menu_x + x + 32, menu_y + opty + 16, dither, 16, 16, 0,0, 1,0,0,1, u,0, 1,0,0,1, 0,v, 1,0,0,1, u,v, 1,0,0,1, 0);
+       DrawQ_Fill(menu_x + x, menu_y + m_opty, 64, 48, c[0], 0, 0, 1, 0);
+       DrawQ_SuperPic(menu_x + x + 16, menu_y + m_opty + 16, dither, 16, 16, 0,0, 1,0,0,1, s,0, 1,0,0,1, 0,t, 1,0,0,1, s,t, 1,0,0,1, 0);
+       DrawQ_SuperPic(menu_x + x + 32, menu_y + m_opty + 16, dither, 16, 16, 0,0, 1,0,0,1, u,0, 1,0,0,1, 0,v, 1,0,0,1, u,v, 1,0,0,1, 0);
        x += 80;
-       DrawQ_Fill(menu_x + x, menu_y + opty, 64, 48, 0, c, 0, 1, 0);
-       DrawQ_SuperPic(menu_x + x + 16, menu_y + opty + 16, dither, 16, 16, 0,0, 0,1,0,1, s,0, 0,1,0,1, 0,t, 0,1,0,1, s,t, 0,1,0,1, 0);
-       DrawQ_SuperPic(menu_x + x + 32, menu_y + opty + 16, dither, 16, 16, 0,0, 0,1,0,1, u,0, 0,1,0,1, 0,v, 0,1,0,1, u,v, 0,1,0,1, 0);
+       DrawQ_Fill(menu_x + x, menu_y + m_opty, 64, 48, 0, c[1], 0, 1, 0);
+       DrawQ_SuperPic(menu_x + x + 16, menu_y + m_opty + 16, dither, 16, 16, 0,0, 0,1,0,1, s,0, 0,1,0,1, 0,t, 0,1,0,1, s,t, 0,1,0,1, 0);
+       DrawQ_SuperPic(menu_x + x + 32, menu_y + m_opty + 16, dither, 16, 16, 0,0, 0,1,0,1, u,0, 0,1,0,1, 0,v, 0,1,0,1, u,v, 0,1,0,1, 0);
        x += 80;
-       DrawQ_Fill(menu_x + x, menu_y + opty, 64, 48, 0, 0, c, 1, 0);
-       DrawQ_SuperPic(menu_x + x + 16, menu_y + opty + 16, dither, 16, 16, 0,0, 0,0,1,1, s,0, 0,0,1,1, 0,t, 0,0,1,1, s,t, 0,0,1,1, 0);
-       DrawQ_SuperPic(menu_x + x + 32, menu_y + opty + 16, dither, 16, 16, 0,0, 0,0,1,1, u,0, 0,0,1,1, 0,v, 0,0,1,1, u,v, 0,0,1,1, 0);
+       DrawQ_Fill(menu_x + x, menu_y + m_opty, 64, 48, 0, 0, c[2], 1, 0);
+       DrawQ_SuperPic(menu_x + x + 16, menu_y + m_opty + 16, dither, 16, 16, 0,0, 0,0,1,1, s,0, 0,0,1,1, 0,t, 0,0,1,1, s,t, 0,0,1,1, 0);
+       DrawQ_SuperPic(menu_x + x + 32, menu_y + m_opty + 16, dither, 16, 16, 0,0, 0,0,1,1, u,0, 0,0,1,1, 0,v, 0,0,1,1, u,v, 0,0,1,1, 0);
        x += 80;
-       DrawQ_Fill(menu_x + x, menu_y + opty, 64, 48, c, c, c, 1, 0);
-       DrawQ_SuperPic(menu_x + x + 16, menu_y + opty + 16, dither, 16, 16, 0,0, 1,1,1,1, s,0, 1,1,1,1, 0,t, 1,1,1,1, s,t, 1,1,1,1, 0);
-       DrawQ_SuperPic(menu_x + x + 32, menu_y + opty + 16, dither, 16, 16, 0,0, 1,1,1,1, u,0, 1,1,1,1, 0,v, 1,1,1,1, u,v, 1,1,1,1, 0);
+       DrawQ_Fill(menu_x + x, menu_y + m_opty, 64, 48, c[0], c[1], c[2], 1, 0);
+       DrawQ_SuperPic(menu_x + x + 16, menu_y + m_opty + 16, dither, 16, 16, 0,0, 1,1,1,1, s,0, 1,1,1,1, 0,t, 1,1,1,1, s,t, 1,1,1,1, 0);
+       DrawQ_SuperPic(menu_x + x + 32, menu_y + m_opty + 16, dither, 16, 16, 0,0, 1,1,1,1, u,0, 1,1,1,1, 0,v, 1,1,1,1, u,v, 1,1,1,1, 0);
 }
 
 
@@ -2302,7 +2299,6 @@ static void M_Options_ColorControl_Key (int k, int ascii)
                switch (options_colorcontrol_cursor)
                {
                case 0:
-                       Cvar_SetValueQuick(&v_hwgamma, 1);
                        Cvar_SetValueQuick(&v_gamma, 1);
                        Cvar_SetValueQuick(&v_contrast, 1);
                        Cvar_SetValueQuick(&v_brightness, 0);
@@ -2615,7 +2611,7 @@ static void M_Keys_Draw (void)
        M_Background(320, 48 + 8 * numcommands);
 
        p = Draw_CachePic ("gfx/ttl_cstm");
-       M_DrawPic ( (320-p->width)/2, 4, "gfx/ttl_cstm");
+       M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/ttl_cstm");
 
        if (bind_grab)
                M_Print(12, 32, "Press a key or button for this action");
@@ -2883,7 +2879,7 @@ static void M_Menu_Video_FindResolution(int w, int h, float a)
                        if (menu_video_resolutions[i].height == h && menu_video_resolutions[menu_video_resolution].height == h)
                        {
                                // if the new mode would be a worse match in pixel aspect, skip it
-                               if (abs(menu_video_resolutions[i].pixelheight - a) > abs(menu_video_resolutions[menu_video_resolution].pixelheight - a))
+                               if (fabs(menu_video_resolutions[i].pixelheight - a) > fabs(menu_video_resolutions[menu_video_resolution].pixelheight - a))
                                        continue;
                                // if it is equal in everything, skip it (prefer earlier modes)
                                if (menu_video_resolutions[i].pixelheight == a && menu_video_resolutions[menu_video_resolution].pixelheight == a)
@@ -2926,7 +2922,7 @@ static void M_Video_Draw (void)
 
        M_DrawPic(16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/vidmodes");
-       M_DrawPic((320-p->width)/2, 4, "gfx/vidmodes");
+       M_DrawPic((320-Draw_GetPicWidth(p))/2, 4, "gfx/vidmodes");
 
        t = 0;
 
@@ -2941,12 +2937,7 @@ static void M_Video_Draw (void)
        M_Print(96, video_cursor_table[t] + 8, va(vabuf, sizeof(vabuf), "Type: %s", menu_video_resolutions[menu_video_resolution].type));
        t++;
 
-       // Bits per pixel
-       M_Print(16, video_cursor_table[t], "        Bits per pixel");
-       M_Print(220, video_cursor_table[t], (vid_bitsperpixel.integer == 32) ? "32" : "16");
-       t++;
-
-       // Bits per pixel
+       // Antialiasing
        M_Print(16, video_cursor_table[t], "          Antialiasing");
        M_DrawSlider(220, video_cursor_table[t], vid_samples.value, 1, 32);
        t++;
@@ -2979,7 +2970,7 @@ static void M_Video_Draw (void)
        M_DrawSlider(220, video_cursor_table[t], gl_picmip.value, 3, 0);
        t++;
 
-       M_ItemPrint(16, video_cursor_table[t], "   Texture Compression", vid.support.arb_texture_compression);
+       M_ItemPrint(16, video_cursor_table[t], "   Texture Compression", true);
        M_DrawCheckbox(220, video_cursor_table[t], gl_texturecompression.integer);
        t++;
 
@@ -3014,8 +3005,6 @@ static void M_Menu_Video_AdjustSliders (int dir)
                                break;
                }
        }
-       else if (video_cursor == t++)
-               Cvar_SetValueQuick (&vid_bitsperpixel, (vid_bitsperpixel.integer == 32) ? 16 : 32);
        else if (video_cursor == t++)
                Cvar_SetValueQuick (&vid_samples, bound(1, vid_samples.value * (dir > 0 ? 2 : 0.5), 32));
        else if (video_cursor == t++)
@@ -3368,7 +3357,7 @@ static void M_LanConfig_Draw (void)
 
        M_DrawPic (16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/p_multi");
-       basex = (320-p->width)/2;
+       basex = (320-Draw_GetPicWidth(p))/2;
        M_DrawPic (basex, 4, "gfx/p_multi");
 
        if (StartingGame)
@@ -3992,7 +3981,7 @@ void M_GameOptions_Draw (void)
 
        M_DrawPic (16, 4, "gfx/qplaque");
        p = Draw_CachePic ("gfx/p_multi");
-       M_DrawPic ( (320-p->width)/2, 4, "gfx/p_multi");
+       M_DrawPic ( (320-Draw_GetPicWidth(p))/2, 4, "gfx/p_multi");
 
        M_DrawTextBox (152, 32, 10, 1);
        M_Print(160, 40, "begin game");
@@ -4136,7 +4125,7 @@ void M_GameOptions_Draw (void)
                        M_Print(x, 146, " More than 255 players??");
                        M_Print(x, 154, "  First, question your  ");
                        M_Print(x, 162, "   sanity, then email   ");
-                       M_Print(x, 170, " lordhavoc@ghdigital.com");
+                       M_Print(x, 170, "darkplacesengine@gmail.com");
                }
                else
                        m_serverInfoMessage = false;
@@ -4411,7 +4400,7 @@ void M_Menu_ServerList_f (void)
 
 static void M_ServerList_Draw (void)
 {
-       int n, y, visible, start, end, numplayers, maxplayers;
+       int n, y, visible, start, end, statnumplayers, statmaxplayers;
        cachepic_t *p;
        const char *s;
        char vabuf[1024];
@@ -4422,8 +4411,8 @@ static void M_ServerList_Draw (void)
        else
                M_Background(640, vid_conheight.integer);
        // scroll the list as the cursor moves
-       ServerList_GetPlayerStatistics(&numplayers, &maxplayers);
-       s = va(vabuf, sizeof(vabuf), "%i/%i masters %i/%i servers %i/%i players", masterreplycount, masterquerycount, serverreplycount, serverquerycount, numplayers, maxplayers);
+       ServerList_GetPlayerStatistics(&statnumplayers, &statmaxplayers);
+       s = va(vabuf, sizeof(vabuf), "%i/%i masters %i/%i servers %i/%i 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);
@@ -4433,7 +4422,7 @@ static void M_ServerList_Draw (void)
        end = min(start + visible, serverlist_viewcount);
 
        p = Draw_CachePic ("gfx/p_multi");
-       M_DrawPic((640 - p->width) / 2, 4, "gfx/p_multi");
+       M_DrawPic((640 - Draw_GetPicWidth(p)) / 2, 4, "gfx/p_multi");
        if (end > start)
        {
                for (n = start;n < end;n++)
@@ -4533,21 +4522,27 @@ static void ModList_RebuildList(void)
 {
        int i,j;
        stringlist_t list;
+       const char *description;
 
        stringlistinit(&list);
        listdirectory(&list, fs_basedir, "");
        stringlistsort(&list, true);
        modlist_count = 0;
        modlist_numenabled = fs_numgamedirs;
-       for (i = 0;i < list.numstrings;i++)
+       for (i = 0;i < list.numstrings && modlist_count < MODLIST_TOTALSIZE;i++)
        {
-               if (modlist_count >= MODLIST_TOTALSIZE) break;
-               // check all dirs to see if they "appear" to be mods
+               // quickly skip names with dot characters - generally these are files, not directories
+               if (strchr(list.strings[i], '.')) continue;
+
                // reject any dirs that are part of the base game
                if (gamedirname1 && !strcasecmp(gamedirname1, list.strings[i])) continue;
                //if (gamedirname2 && !strcasecmp(gamedirname2, list.strings[i])) continue;
-               if (FS_CheckNastyPath (list.strings[i], true)) continue;
-               if (!FS_CheckGameDir(list.strings[i])) continue;
+
+               // check if we can get a description of the gamedir (from modinfo.txt),
+               // or if the directory is valid but has no description (fs_checkgamedir_missing)
+               // otherwise this isn't a valid gamedir
+               description = FS_CheckGameDir(list.strings[i]);
+               if (description == NULL || description == fs_checkgamedir_missing) continue;
 
                strlcpy (modlist[modlist_count].dir, list.strings[i], sizeof(modlist[modlist_count].dir));
                //check currently loaded mods
@@ -4663,7 +4658,7 @@ static void M_ModList_Draw (void)
        end = min(start + visible, modlist_count);
 
        p = Draw_CachePic ("gfx/p_option");
-       M_DrawPic((640 - p->width) / 2, 4, "gfx/p_option");
+       M_DrawPic((640 - Draw_GetPicWidth(p)) / 2, 4, "gfx/p_option");
        if (end > start)
        {
                for (n = start;n < end;n++)
@@ -4881,7 +4876,7 @@ void M_Draw (void)
                        drop1 = Draw_CachePic ("gfx/menu/blooddrop1");
                        drop2 = Draw_CachePic ("gfx/menu/blooddrop2");
                        drop3 = Draw_CachePic ("gfx/menu/blooddrop3");
-                       for (scale_x = 0; scale_x <= vid_conwidth.integer; scale_x += p->width) {
+                       for (scale_x = 0; scale_x <= vid_conwidth.integer; scale_x += Draw_GetPicWidth(p)) {
                                for (scale_y = -scale_y_repeat; scale_y <= vid_conheight.integer; scale_y += scale_y_repeat) {
                                        DrawQ_Pic (scale_x + 21, scale_y_repeat * .5 + scale_y + scale_y_rate * scale_y_repeat, drop3, 0, 0, 1, 1, 1, 1, 0);
                                        DrawQ_Pic (scale_x +  116, scale_y_repeat + scale_y + scale_y_rate * scale_y_repeat, drop1, 0, 0, 1, 1, 1, 1, 0);
@@ -5018,6 +5013,11 @@ static void M_NewMap(void)
 {
 }
 
+static int M_GetServerListEntryCategory(const serverlist_entry_t *entry)
+{
+       return 0;
+}
+
 void M_Shutdown(void)
 {
        // reset key_dest
@@ -5307,6 +5307,8 @@ static void MP_Draw (void)
 
        // FIXME: this really shouldnt error out lest we have a very broken refdef state...?
        // or does it kill the server too?
+       PRVM_G_FLOAT(OFS_PARM0) = vid.width;
+       PRVM_G_FLOAT(OFS_PARM1) = vid.height;
        prog->ExecuteProgram(prog, PRVM_menufunction(m_draw),"m_draw() required");
 
        // TODO: imo this should be moved into scene, too [1/27/2008 Andreas]
@@ -5330,6 +5332,24 @@ static void MP_NewMap(void)
                prog->ExecuteProgram(prog, PRVM_menufunction(m_newmap),"m_newmap() required");
 }
 
+const serverlist_entry_t *serverlist_callbackentry = NULL;
+static int MP_GetServerListEntryCategory(const serverlist_entry_t *entry)
+{
+       prvm_prog_t *prog = MVM_prog;
+       serverlist_callbackentry = entry;
+       if (PRVM_menufunction(m_gethostcachecategory))
+       {
+               prog->globals.fp[OFS_PARM0] = (prvm_vec_t) -1;
+               prog->ExecuteProgram(prog, PRVM_menufunction(m_gethostcachecategory),"m_gethostcachecategory(float entry) required");
+               serverlist_callbackentry = NULL;
+               return prog->globals.fp[OFS_RETURN];
+       }
+       else
+       {
+               return 0;
+       }
+}
+
 static void MP_Shutdown (void)
 {
        prvm_prog_t *prog = MVM_prog;
@@ -5380,6 +5400,9 @@ static void MP_Init (void)
 
        // call the prog init
        prog->ExecuteProgram(prog, PRVM_menufunction(m_init),"m_init() required");
+
+       // Once m_init was called, we consider menuqc code fully initialized.
+       prog->inittime = realtime;
 }
 
 //============================================================================
@@ -5390,6 +5413,7 @@ void (*MR_Draw) (void);
 void (*MR_ToggleMenu) (int mode);
 void (*MR_Shutdown) (void);
 void (*MR_NewMap) (void);
+int (*MR_GetServerListEntryCategory) (const serverlist_entry_t *entry);
 
 void MR_SetRouting(qboolean forceold)
 {
@@ -5402,6 +5426,7 @@ void MR_SetRouting(qboolean forceold)
                MR_ToggleMenu = M_ToggleMenu;
                MR_Shutdown = M_Shutdown;
                MR_NewMap = M_NewMap;
+               MR_GetServerListEntryCategory = M_GetServerListEntryCategory;
                M_Init();
        }
        else
@@ -5412,6 +5437,7 @@ void MR_SetRouting(qboolean forceold)
                MR_ToggleMenu = MP_ToggleMenu;
                MR_Shutdown = MP_Shutdown;
                MR_NewMap = MP_NewMap;
+               MR_GetServerListEntryCategory = MP_GetServerListEntryCategory;
                MP_Init();
        }
 }
@@ -5451,7 +5477,7 @@ void MR_Init(void)
        res_count = VID_SortModes(res, res_count, false, false, true);
        if(res_count)
        {
-               video_resolutions_count = res_count;
+               video_resolutions_count = (int)res_count;
                video_resolutions = (video_resolution_t *) Mem_Alloc(cls.permanentmempool, sizeof(*video_resolutions) * (video_resolutions_count + 1));
                memset(&video_resolutions[video_resolutions_count], 0, sizeof(video_resolutions[video_resolutions_count]));
                for(i = 0; i < res_count; ++i)