]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/net_notice.qc
#include this
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / net_notice.qc
1 #if defined(CSQC)
2     #include "../dpdefs/csprogsdefs.qc"
3     #include "../client/Defs.qc"
4     #include "../csqcmodellib/cl_model.qh"
5 #elif defined(MENUQC)
6 #elif defined(SVQC)
7     #include "../dpdefs/progsdefs.qc"
8     #include "../dpdefs/dpextensions.qc"
9     #include "constants.qh"
10     #include "net_notice.qh"
11     #include "../server/defs.qh"
12 #endif
13
14 #ifdef SVQC
15 void sv_notice_join_think()
16 {
17     //NextLevel();
18     float argc = tokenizebyseparator(autocvar_sv_join_notices, "|");
19     if(argc > 0)
20     {
21         float i;
22         for(i = argc - 1; i >= 0; --i)
23             sv_notice_to(self.owner, argv(i), autocvar_sv_join_notices_time, false);
24     }
25     remove(self);
26 }
27
28 void sv_notice_join()
29 {
30     // to-do: make sv_join_notices support per-entry times
31     if(autocvar_sv_join_notices == "")
32         return;
33
34     entity n = spawn();
35     n.owner = self;
36     n.think = sv_notice_join_think;
37     n.nextthink = time + 1;
38 }
39
40 void sv_notice_to(entity _to, string _notice, float _howlong, float _modal)
41 {
42         msg_entity = _to;
43         WriteByte(MSG_ONE, SVC_TEMPENTITY);
44         WriteByte(MSG_ONE, TE_CSQC_SVNOTICE);
45         WriteString(MSG_ONE, _notice);
46         WriteLong(MSG_ONE, _howlong);
47         WriteByte(MSG_ONE, _modal);
48 }
49
50 void sv_notice_toall(string _notice, float _howlong, float _modal)
51 {
52     entity _head;
53     FOR_EACH_REALCLIENT(_head)
54         sv_notice_to(_head, _notice, _howlong, _modal);
55
56 }
57
58 #endif // SVQC
59
60 #ifdef CSQC
61 void SUB_Remove()
62 { remove(self); }
63
64 void cl_notice_read()
65 {
66     entity _notice;
67     //float _done;
68     //float _modal;
69     _notice = spawn();
70     _notice.classname = "sv_notice";
71     _notice.netname = strzone(ReadString());
72     _notice.alpha = ReadLong() + time;
73     _notice.skin = ReadByte();
74 }
75
76 float cl_notice_run()
77 {
78     entity _notes;
79     string _notice;
80     float m = false;
81
82     _notes = findchain(classname, "sv_notice");
83     if(!_notes)
84         return false;
85     #define M1 30
86     #define M2 10
87
88     vector v1, v2 = '0 0 0', v3;
89     v1 = '1 1 0' * M1;
90     v2_x = vid_conwidth - (2 * M1);
91     v2_y = vid_conheight - (2 * M1);
92
93     drawfill(v1, v2, '0 0 0', 0.5, DRAWFLAG_NORMAL);
94     v1 = '1 1 0' * (M1 + M2);
95     v2_x = vid_conwidth - (2 * (M1 + M2));
96     v2_y = vid_conheight - (2 * (M1 + M2));
97     drawfill(v1, v2, '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
98     v3 = v1 + '10 10 0';
99
100     #define OUT(s,z) drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3_y += z + 4
101
102     OUT(_("^1Server notices:"), 32);
103
104     //drawcolorcodedstring(v1 + '5 5 0', "^1Server notices:", '32 32 0', 1, DRAWFLAG_NORMAL);
105     while(_notes)
106     {
107
108         _notice = sprintf(_("^7%s (^3%d sec left)"), _notes.netname , rint(_notes.alpha - time));
109         OUT(_notice, 16);
110
111         if(_notes.skin)
112             m = true;
113
114         if(_notes.alpha <= time)
115         {
116             _notes.think = SUB_Remove;
117             _notes.nextthink = time;
118         }
119
120         _notes = _notes.chain;
121     }
122
123     #undef OUT
124     #undef M1
125     #undef M2
126
127     return m;
128 }
129
130 #endif // CSQC