X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fnet_notice.qc;h=20d1351ebcae9475043db8b86de15a2df2df370d;hb=d865de7a9a17c5a1d9286aec40f68c3530697660;hp=1e1726ae452fe716041d291f30581eb3a1d3cab9;hpb=f52ddede69621c7c9d31983591902f47fd40d7d0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/net_notice.qc b/qcsrc/common/net_notice.qc index 1e1726ae4..20d1351eb 100644 --- a/qcsrc/common/net_notice.qc +++ b/qcsrc/common/net_notice.qc @@ -41,24 +41,30 @@ NET_HANDLE(TE_CSQC_SVNOTICE, bool isNew) return true; } entity cl_notices; -STATIC_INIT(cl_notice) -{ - cl_notices = LL_NEW(); -} void cl_notice_read() { entity _notice = new_pure(sv_notice); _notice.netname = strzone(ReadString()); _notice.alpha = ReadLong() + time; _notice.skin = ReadByte(); + if(!cl_notices) + cl_notices = LL_NEW(); LL_PUSH(cl_notices, _notice); } void cl_notice_run() { + if (!cl_notices) + return; + bool flag = false; LL_EACH(cl_notices, it.alpha > time, { flag = true; break; }); - if (!flag) return; + if (!flag) + { + LL_DELETE(cl_notices); + return; + } + const int M1 = 30; const int M2 = 10; @@ -76,10 +82,18 @@ void cl_notice_run() vector v3 = v1 + '10 10 0'; #define OUT(s, z) MACRO_BEGIN { drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3.y += z + 4; } MACRO_END + float cur_time = 0; + float time_width = 48; OUT(_("^1Server notices:"), 32); LL_EACH(cl_notices, it.alpha > time, { - string s = sprintf(_("^7%s (^3%d sec left)"), it.netname , rint(it.alpha - time)); - OUT(s, 16); + if(it.alpha - cur_time > 0.1) + { + cur_time = it.alpha; + string s = sprintf("^3%d", ceil(cur_time - time)); + drawcolorcodedstring(v3 + eX * 0.5 * (time_width - stringwidth(s, true, '1 1 0' * 16)), s, '1 1 0' * 16, 1, DRAWFLAG_NORMAL); + v3.x = v1.x + 10 + time_width; + } + OUT(it.netname, 16); }); #undef OUT }