]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/mapvoting.qc
Merge remote-tracking branch 'origin/samual/serverlist'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / mapvoting.qc
index 769b921a43fd39d3fe5bf2937b0505d542561eed..8caeb01d524064f51c3191440555c0cd814ce0e3 100644 (file)
@@ -28,6 +28,8 @@ string MapVote_FormatMapItem(float id, string map, float count, float maxwidth,
                        post = _(" (1 vote)");
                else if(count >= 0)
                        post = sprintf(_(" (%d votes)"), count);
+               else
+                       post = "";
        }
        else
                post = "";
@@ -50,20 +52,20 @@ vector MapVote_RGB(float id, float count)
 
 void MapVote_DrawMapItem(vector pos, float isize, float tsize, string map, string pic, float count, float id)
 {
-       vector img_size;
+       vector img_size = '0 0 0';
        vector rgb;
        string label;
        float text_size;
-       
+
        isize -= hud_fontsize_y; // respect the text when calculating the image size
 
        rgb = MapVote_RGB(id, count);
-       
+
        img_size_y = isize;
        img_size_x = isize / 0.75; // 4:3 x can be stretched easily, height is defined in isize
 
        pos_y = pos_y + img_size_y;
-       
+
        label = MapVote_FormatMapItem(id, map, count, tsize, hud_fontsize);
 
        text_size = stringwidth(label, false, hud_fontsize);
@@ -76,7 +78,7 @@ void MapVote_DrawMapItem(vector pos, float isize, float tsize, string map, strin
 
        pos_x -= text_size*0.5;
        drawstring(pos, label, hud_fontsize, rgb, theAlpha, DRAWFLAG_NORMAL);
-       
+
        pos_x = pos_x + text_size*0.5 - img_size_x*0.5;
        pos_y = pos_y - img_size_y;
 
@@ -88,7 +90,10 @@ void MapVote_DrawMapItem(vector pos, float isize, float tsize, string map, strin
        }
        else
        {
-               drawpic(pos, pic, img_size, '1 1 1', theAlpha, DRAWFLAG_NORMAL);
+               if(drawgetimagesize(pic) == '0 0 0')
+                       drawpic(pos, draw_UseSkinFor("nopreview_map"), img_size, '1 1 1', theAlpha, DRAWFLAG_NORMAL);
+               else
+                       drawpic(pos, pic, img_size, '1 1 1', theAlpha, DRAWFLAG_NORMAL);
        }
 
        if(id == mv_ownvote)
@@ -105,15 +110,15 @@ void MapVote_DrawAbstain(vector pos, float isize, float tsize, float count, floa
        vector rgb;
        float text_size;
        string label;
-       
+
        rgb = MapVote_RGB(id, count);
 
        pos_y = pos_y + hud_fontsize_y;
-       
+
        label = MapVote_FormatMapItem(id, _("Don't care"), count, tsize, hud_fontsize);
 
        text_size = stringwidth(label, false, hud_fontsize);
-       
+
        pos_x -= text_size*0.5;
        drawstring(pos, label, hud_fontsize, rgb, 1, DRAWFLAG_NORMAL);
 }
@@ -166,15 +171,18 @@ void MapVote_Draw()
        float center;
        float columns, rows;
        float tsize;
-       vector dist;
+       vector dist = '0 0 0';
 
        if(!mv_active)
                return;
 
-       mv_mousepos = mv_mousepos + getmousepos();
+       if (!autocvar_hud_cursormode)
+       {
+               mv_mousepos = mv_mousepos + getmousepos();
 
-       mv_mousepos_x = bound(0, mv_mousepos_x, vid_conwidth);
-       mv_mousepos_y = bound(0, mv_mousepos_y, vid_conheight);
+               mv_mousepos_x = bound(0, mv_mousepos_x, vid_conwidth);
+               mv_mousepos_y = bound(0, mv_mousepos_y, vid_conheight);
+       }
 
        center = (vid_conwidth - 1)/2;
        xmin = vid_conwidth*0.05; // 5% border must suffice
@@ -191,6 +199,7 @@ void MapVote_Draw()
        pos_y = ymin;
        pos_z = 0;
 
+       draw_beginBoldFont();
        map = _("Vote for a map");
        pos_x = center - stringwidth(map, false, '12 0 0');
        drawstring(pos, map, '24 24 0', '1 1 1', 1, DRAWFLAG_NORMAL);
@@ -202,6 +211,7 @@ void MapVote_Draw()
        drawstring(pos, map, '16 16 0', '0 1 0', 1, DRAWFLAG_NORMAL);
        pos_y += 22;
        pos_x = xmin;
+       draw_endBoldFont();
 
        // base for multi-column stuff...
        ymin = pos_y;
@@ -250,7 +260,7 @@ void MapVote_Draw()
                MapVote_DrawAbstain(pos, isize, xmax - xmin, tmp, i);
        }
 
-       drawpic(mv_mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), '32 32 0', '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawpic(mv_mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), '32 32 0', '1 1 1', 1 - autocvar__menu_alpha, DRAWFLAG_NORMAL);
 }
 
 void Cmd_MapVote_MapDownload(float argc)
@@ -263,12 +273,12 @@ void Cmd_MapVote_MapDownload(float argc)
                print(_("mv_mapdownload: ^3You're not supposed to use this command on your own!\n"));
                return;
        }
-       
+
        id = stof(argv(1));
        for(pak = mv_pk3list; pak; pak = pak.chain)
                if(pak.sv_entnum == id)
                        break;
-       
+
        if(!pak || pak.sv_entnum != id) {
                print(_("^1Error:^7 Couldn't find pak index.\n"));
                return;
@@ -291,10 +301,10 @@ void MapVote_CheckPK3(string pic, string pk3, float id)
        pak.netname = pk3;
        pak.message = pic;
        pak.sv_entnum = id;
-       
+
        pak.chain = mv_pk3list;
        mv_pk3list = pak;
-       
+
        if(pk3 != "")
        {
                localcmd(strcat("\ncurl --pak ", pk3, "; wait; cl_cmd mv_download ", ftos(id), "\n"));
@@ -330,8 +340,8 @@ void MapVote_Init()
        precache_sound ("misc/invshot.wav");
 
        mv_active = 1;
-
-       mv_mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
+       if(autocvar_hud_cursormode) { setcursormode(1); }
+       else { mv_mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight; }
        mv_selection = -1;
 
        for(n_ssdirs = 0; ; ++n_ssdirs)
@@ -357,10 +367,10 @@ void MapVote_Init()
                mv_maps_mask = ReadByte();
        else
                mv_maps_mask = ReadShort();
-       
+
        // Assume mv_pk3list is world, there should only be 1 mapvote per round
        mv_pk3list = world; // I'm still paranoid!
-       
+
        for(i = 0, power = 1; i < mv_num_maps; ++i, power *= 2)
        {
                mv_votes[i] = 0;
@@ -370,7 +380,7 @@ void MapVote_Init()
                        map = strzone(ReadString());
                        pk3 = strzone(ReadString());
                        j = bound(0, ReadByte(), n_ssdirs - 1);
-       
+
                        mv_maps[i] = map;
                        mv_pk3[i] = pk3;
                        map = strzone(strcat(ssdirs[j], "/", map));
@@ -401,6 +411,13 @@ float MapVote_InputEvent(float bInputType, float nPrimary, float nSecondary)
        if (!mv_active)
                return false;
 
+       if(bInputType == 3)
+       {
+               mv_mousepos_x = nPrimary;
+               mv_mousepos_y = nSecondary;
+               return true;
+       }
+
        if (bInputType != 0)
                return false;
 
@@ -447,13 +464,13 @@ void MapVote_UpdateMask()
        else
                mv_maps_mask = ReadShort();
 
-       if(oldmask & mv_maps_mask != oldmask)
-               if(oldmask & mv_maps_mask == mv_maps_mask)
-                        sound(world, CH_INFO, "misc_invshot.wav", VOL_BASE, ATTN_NONE);
+       if((oldmask & mv_maps_mask) != oldmask)
+               if((oldmask & mv_maps_mask) == mv_maps_mask)
+                        sound(world, CH_INFO, "misc_invshot.wav", VOL_BASE, ATTEN_NONE);
 
        // remove votes that no longer apply
        for(i = 0, power = 1; i < mv_num_maps; ++i, power *= 2)
-               if not(mv_maps_mask & power)
+               if (!(mv_maps_mask & power))
                        mv_votes[i] = -1;
 
        mv_top2_time = time;