X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fmapvoting.qc;h=e94d6a68aa786786f9babdf009e71deeb5b64259;hp=b4fb97603075cfebcd6d2d0baed9e46336bbc7f2;hb=cdd81c92fb9f69a9b7c3a9cebec4a656cb8d099b;hpb=92f380c831a67868ddde14db32e0d73700ed7d09 diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index b4fb97603..e94d6a68a 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -12,6 +12,8 @@ float mv_ownvote; float mv_detail; float mv_timeout; float mv_maps_mask; +float mv_top2_time; +float mv_top2_alpha; vector mv_mousepos; float mv_selection; @@ -19,13 +21,13 @@ float mv_selection; string MapVote_FormatMapItem(float id, string map, float count, float maxwidth, vector fontsize) { string pre, post; - pre = strcat(ftos(id+1), ". "); + pre = sprintf("%d. ", id+1); if(mv_detail) { if(count == 1) - post = strcat(" (1 vote)"); + post = _(" (1 vote)"); else - post = strcat(" (", ftos(count), " votes)"); + post = sprintf(_(" (%d votes)"), count); } else post = ""; @@ -34,8 +36,10 @@ string MapVote_FormatMapItem(float id, string map, float count, float maxwidth, return strcat(pre, map, post); } -vector MapVote_RGB(float id) +vector MapVote_RGB(float id, float count) { + if(count < 0) + return '1 1 1'; if(id == mv_ownvote) return '0 1 0'; else if (id == mv_selection) @@ -53,47 +57,47 @@ void MapVote_DrawMapItem(vector pos, float isize, float tsize, string map, strin isize -= hud_fontsize_y; // respect the text when calculating the image size - rgb = MapVote_RGB(id); + 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 - drawfont = hud_font; pos_y = pos_y + img_size_y; label = MapVote_FormatMapItem(id, map, count, tsize, hud_fontsize); text_size = stringwidth(label, false, hud_fontsize); - + + float alpha; + if (count < 0 && mv_top2_alpha) + alpha = mv_top2_alpha; + else + alpha = 1; + pos_x -= text_size*0.5; - drawstring(pos, label, hud_fontsize, rgb, 1, DRAWFLAG_NORMAL); + drawstring(pos, label, hud_fontsize, rgb, alpha, DRAWFLAG_NORMAL); pos_x = pos_x + text_size*0.5 - img_size_x*0.5; pos_y = pos_y - img_size_y; - pos += hud_border_thickness * '1 1 0'; - img_size -= (hud_border_thickness * 2) * '1 1 0'; + pos += autocvar_scoreboard_border_thickness * '1 1 0'; + img_size -= (autocvar_scoreboard_border_thickness * 2) * '1 1 0'; if(pic == "") { - drawfill(pos, img_size, '.5 .5 .5', .7, DRAWFLAG_NORMAL); + drawfill(pos, img_size, '.5 .5 .5', .7 * alpha, DRAWFLAG_NORMAL); } else { - drawpic(pos, pic, img_size, '1 1 1', 1, DRAWFLAG_NORMAL); + drawpic(pos, pic, img_size, '1 1 1', alpha, DRAWFLAG_NORMAL); } - - drawpic(pos + '1 0 0', strcat("gfx/hud/num_", ftos(id+1)), (img_size_y / 5) * '1 1 0', '1 1 1', 0.6, DRAWFLAG_NORMAL); - if(id == mv_ownvote || pic == "") - { - drawborderlines(hud_border_thickness, pos, img_size, rgb, 1, DRAWFLAG_NORMAL); - drawpic(pos + '1 0 0', strcat("gfx/hud/num_", ftos(id+1)), (img_size_y / 5) * '1 1 0', rgb, 0.6, DRAWFLAG_NORMAL); - } + if(id == mv_ownvote) + drawborderlines(autocvar_scoreboard_border_thickness, pos, img_size, rgb, alpha, DRAWFLAG_NORMAL); else - { - drawborderlines(hud_border_thickness, pos, img_size, '0 0 0', 1, DRAWFLAG_NORMAL); - drawpic(pos + '1 0 0', strcat("gfx/hud/num_", ftos(id+1)), (img_size_y / 5) * '1 1 0', '1 1 1', 0.6, DRAWFLAG_NORMAL); - } + drawborderlines(autocvar_scoreboard_border_thickness, pos, img_size, '0 0 0', alpha, DRAWFLAG_NORMAL); + + if(id == mv_selection && count >= 0) + drawfill(pos, img_size, '1 1 1', 0.1, DRAWFLAG_NORMAL); } void MapVote_DrawAbstain(vector pos, float isize, float tsize, float count, float id) @@ -102,12 +106,11 @@ void MapVote_DrawAbstain(vector pos, float isize, float tsize, float count, floa float text_size; string label; - rgb = MapVote_RGB(id); + rgb = MapVote_RGB(id, count); - drawfont = hud_font; pos_y = pos_y + hud_fontsize_y; - label = MapVote_FormatMapItem(id, "Don't care", count, tsize, hud_fontsize); + label = MapVote_FormatMapItem(id, _("Don't care"), count, tsize, hud_fontsize); text_size = stringwidth(label, false, hud_fontsize); @@ -177,32 +180,29 @@ void MapVote_Draw() xmin = vid_conwidth*0.05; // 5% border must suffice xmax = vid_conwidth - xmin; ymin = 20; - i = cvar("con_chatpos"); //*cvar("con_chatsize"); + i = autocvar_con_chatpos; //*autocvar_con_chatsize; if(i < 0) - ymax = vid_conheight + (i - cvar("con_chat")) * cvar("con_chatsize"); + ymax = vid_conheight + (i - autocvar_con_chat) * autocvar_con_chatsize; if(i >= 0 || ymax < (vid_conheight*0.5)) ymax = vid_conheight - ymin; - drawfont = hud_bigfont; hud_fontsize = HUD_GetFontsize("hud_fontsize"); pos_y = ymin; pos_z = 0; //pos_x = center - stringwidth("Vote for a map", false) * 0.5 * 24; - pos_x = center - stringwidth("Vote for a map", false, '12 0 0'); + pos_x = center - stringwidth(_("Vote for a map"), false, '12 0 0'); drawstring(pos, "Vote for a map", '24 24 0', '1 1 1', 1, DRAWFLAG_NORMAL); pos_y += 26; i = ceil(max(0, mv_timeout - time)); - map = strcat(ftos(i), " seconds left"); + map = sprintf(_("%d seconds left"), i); //pos_x = center - stringwidth(map, false) * 0.5 * 16; pos_x = center - stringwidth(map, false, '8 0 0'); drawstring(pos, map, '16 16 0', '0 1 0', 1, DRAWFLAG_NORMAL); pos_y += 22; pos_x = xmin; - drawfont = hud_font; - // base for multi-column stuff... ymin = pos_y; if(mv_abstain) @@ -227,11 +227,12 @@ void MapVote_Draw() pos_y += (dist_y - isize) / 2; ymax -= isize; + if (mv_top2_time) + mv_top2_alpha = max(0.2, 1 - (time - mv_top2_time)*(time - mv_top2_time)); + for(i = 0; i < mv_num_maps; ++i) { tmp = mv_votes[i]; // FTEQCC bug: too many array accesses in the function call screw it up - if(tmp < 0) - continue; map = mv_maps[i]; if(mv_preview[i]) MapVote_DrawMapItem(pos + MapVote_GridVec(dist, i, columns), isize, tsize, map, mv_pics[i], tmp, i); @@ -249,7 +250,7 @@ void MapVote_Draw() MapVote_DrawAbstain(pos, isize, xmax - xmin, tmp, i); } - drawpic(mv_mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL); + drawpic(mv_mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), '32 32 0', '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL); } void Cmd_MapVote_MapDownload(float argc) @@ -259,7 +260,7 @@ void Cmd_MapVote_MapDownload(float argc) if(argc != 2 || !mv_pk3list) { - print("mv_mapdownload: ^3You're not supposed to use this command on your own!\n"); + print(_("mv_mapdownload: ^3You're not supposed to use this command on your own!\n")); return; } @@ -269,19 +270,16 @@ void Cmd_MapVote_MapDownload(float argc) break; if(!pak || pak.sv_entnum != id) { - print("^1Error:^7 Couldn't find pak index.\n"); + print(_("^1Error:^7 Couldn't find pak index.\n")); return; } - //print(strcat("^3Adding: ", ftos(id), " - ", pak.message, " - ")); - if(PreviewExists(pak.message)) { mv_preview[id] = true; - //print("^2Found...\n"); return; } else { - print("Requesting preview...\n"); + print(_("Requesting preview...\n")); localcmd(strcat("\ncmd mv_getpic ", ftos(id), "\n")); } } @@ -331,9 +329,6 @@ void MapVote_Init() precache_sound ("misc/invshot.wav"); - registercmd("+showscores"); - registercmd("-showscores"); - mv_active = 1; mv_mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight; @@ -383,7 +378,6 @@ void MapVote_Init() mv_preview[i] = false; - //print(strcat("RECV: ", map, " in ", pk3, "\n")); MapVote_CheckPic(map, pk3, i); } else @@ -448,6 +442,8 @@ void MapVote_UpdateMask() for(i = 0, power = 1; i < mv_num_maps; ++i, power *= 2) if not(mv_maps_mask & power) mv_votes[i] = -1; + + mv_top2_time = time; } void MapVote_UpdateVotes()