Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
util.qc
Go to the documentation of this file.
1#include "util.qh"
2#include "dialog.qh"
3#include "textslider.qh"
4
5#include "../item.qh"
6
7#include "../menu.qh"
9#include <common/constants.qh>
11#include <common/util.qh>
14
15bool GL_CheckExtension(string ext)
16{
17 return strhasword(cvar_string("gl_info_extensions"), ext);
18}
19
21{
22 return GL_CheckExtension("GL_EXT_texture_compression_s3tc");
23}
24
26void forAllDescendants(entity root, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
27{
28 depthfirst(root, parent, firstChild, nextSibling, funcPre, funcPost, pass);
29}
30
33{
34}
35
36.void(entity) saveCvars;
37void saveCvarsOf(entity ignore, entity e)
38{
39 if(e.saveCvars)
40 e.saveCvars(e);
41}
42
43.void(entity) loadCvars;
44void loadCvarsOf(entity ignore, entity e)
45{
46 if(e.loadCvars)
47 e.loadCvars(e);
48}
57
59.void(entity me) saveCvars_Multi;
61{
62 if (me.controlledCvars_Multi)
63 return me.controlledCvars_Multi;
64 return string_null;
65}
67{
68 float n, i;
69 string s, cvarname;
70
71 me.saveCvars_Multi(me);
72 s = cvar_string(me.controlledCvar);
73
74 n = tokenize_console(me.controlledCvars_Multi);
75 for(i = 0; i < n; ++i)
76 {
77 // cvars prefixed with ! get saved with the inverted value
78 if(substring(argv(i), 0, 1) == "!")
79 {
80 cvarname = substring(argv(i), 1, strlen(argv(i)));
81 cvar_set(cvarname, ((s == "0") ? "1" : "0"));
82 }
83 else
84 {
85 cvarname = argv(i);
86 cvar_set(cvarname, s);
87 }
88
89 CheckSendCvars(me, cvarname);
90 }
91}
92void makeMulti(entity e, string otherCvars)
93{
94 e.controlledCvars_Multi = otherCvars;
95 e.saveCvars_Multi = e.saveCvars;
96 e.saveCvars = saveCvarsMulti;
97}
98
99.void(entity me) saveCvars_Callback;
101.void(entity me, entity cb) saveCvars_Callback_func;
103{
104 me.saveCvars_Callback(me);
105 me.saveCvars_Callback_func(me.saveCvars_Callback_ent, me);
106}
107void makeCallback(entity e, entity cbent, void(entity, entity) cbfunc)
108{
109 e.saveCvars_Callback = e.saveCvars;
110 e.saveCvars = saveCvarsCallback;
111 e.saveCvars_Callback_ent = cbent;
112 e.saveCvars_Callback_func = cbfunc;
113}
114
115/* So far this allows for:
116 * A
117 * A AND B
118 * A AND B AND C
119 * A OR B
120 * A OR B OR C
121 * Same but with (NOT A) instead of A
122 * A can be range, function, string exactly equal
123 * Must call setDependent/setDependentNOT/setDependentStringNotEqual first,
124 * ... then setDependentAND/setDependentOR after
125 */
126.void(entity) draw_setDependent;
128{
129 bool disabled_prev = e.disabled;
130 float f;
131 string s;
132 if (e.func_setDependent)
133 {
134 e.disabled = !(e.func_setDependent(e));
135 }
136 else if (e.cvarString_setDependent)
137 {
138 s = cvar_string(e.cvarString_setDependent);
139 e.disabled = (cvar_string(e.cvarString_setDependent) == e.cvarValue_setDependent);
140 }
141 else if (e.cvar1_setDependent)
142 {
143 f = cvar(e.cvar1_setDependent);
144 if (e.op_setDependent & BIT(1)) // NOT
145 e.disabled = (f == e.cvar1Min_setDependent);
146 else
147 {
148 if (e.cvar1Min_setDependent <= e.cvar1Max_setDependent)
149 e.disabled = ((f < e.cvar1Min_setDependent) || (f > e.cvar1Max_setDependent));
150 else
151 e.disabled = ((f >= e.cvar1Max_setDependent) && (f <= e.cvar1Min_setDependent));
152 }
153 }
154 int op = e.op_setDependent & BIT(0);
155 if (e.cvar2_setDependent)
156 {
157 f = cvar(e.cvar2_setDependent);
158 if (e.cvar2Min_setDependent <= e.cvar2Max_setDependent)
159 e.disabled = (e.disabled + ((f < e.cvar2Min_setDependent) || (f > e.cvar2Max_setDependent)) > op);
160 else
161 e.disabled = (e.disabled + ((f >= e.cvar2Max_setDependent) && (f <= e.cvar2Min_setDependent)) > op);
162 }
163 if (e.cvar3_setDependent)
164 {
165 f = cvar(e.cvar3_setDependent);
166 if (e.cvar3Min_setDependent <= e.cvar3Max_setDependent)
167 e.disabled = (e.disabled + ((f < e.cvar3Min_setDependent) || (f > e.cvar3Max_setDependent)) > op);
168 else
169 e.disabled = (e.disabled + ((f >= e.cvar3Max_setDependent) && (f <= e.cvar3Min_setDependent)) > op);
170 }
171 if (disabled_prev != e.disabled && e.loadCvars)
172 e.loadCvars(e);
173}
175{
177 e.draw_setDependent(e);
178}
179.void(entity) draw;
180void setDependent(entity e, string theCvarName, float theCvarMin, float theCvarMax)
181{
182 e.draw_setDependent = e.draw;
183 e.cvar1_setDependent = theCvarName;
184 e.cvar1Min_setDependent = theCvarMin;
185 e.cvar1Max_setDependent = theCvarMax;
186 e.op_setDependent = 0;
187 e.cvarString_setDependent = string_null;
188 e.func_setDependent = func_null;
189 e.draw = setDependent_Draw;
191}
192void setDependentNOT(entity e, string theCvarName, float theCvarValue)
193{
194 e.draw_setDependent = e.draw;
195 e.cvar1_setDependent = theCvarName;
196 e.cvar1Min_setDependent = theCvarValue;
197 e.cvar1Max_setDependent = theCvarValue;
198 e.op_setDependent |= BIT(1); // NOT
199 e.cvarString_setDependent = string_null;
200 e.func_setDependent = func_null;
201 e.draw = setDependent_Draw;
203}
204void setDependentStringNotEqual(entity e, string theCvarName, string theCvarValue)
205{
206 e.draw_setDependent = e.draw;
207 e.cvarString_setDependent = theCvarName;
208 e.cvarValue_setDependent = theCvarValue;
209 e.func_setDependent = func_null;
210 e.draw = setDependent_Draw;
212}
213void setDependentAND(entity e, string theCvarName, float theCvarMin, float theCvarMax)
214{
215 if (e.cvar2_setDependent)
216 {
217 e.cvar3_setDependent = theCvarName;
218 e.cvar3Min_setDependent = theCvarMin;
219 e.cvar3Max_setDependent = theCvarMax;
220 }
221 else
222 {
223 e.cvar2_setDependent = theCvarName;
224 e.cvar2Min_setDependent = theCvarMin;
225 e.cvar2Max_setDependent = theCvarMax;
226 }
227 e.op_setDependent &= ~BIT(0); // AND
228 e.func_setDependent = func_null;
230}
231void setDependentOR(entity e, string theCvarName, float theCvarMin, float theCvarMax)
232{
233 if (e.cvar2_setDependent)
234 {
235 e.cvar3_setDependent = theCvarName;
236 e.cvar3Min_setDependent = theCvarMin;
237 e.cvar3Max_setDependent = theCvarMax;
238 }
239 else
240 {
241 e.cvar2_setDependent = theCvarName;
242 e.cvar2Min_setDependent = theCvarMin;
243 e.cvar2Max_setDependent = theCvarMax;
244 }
245 e.op_setDependent |= BIT(0); // OR
246 e.func_setDependent = func_null;
248}
249void setDependentWeird(entity e, float(entity) func)
250{
251 e.draw_setDependent = e.draw;
252 e.func_setDependent = func;
253 e.draw = setDependent_Draw;
255}
256
257void setZonedTooltip(entity e, string theTooltip, string theCvar)
258{
259 if(theTooltip == "") // no tooltip, use cvar description then
260 {
261 if(theCvar != "" && prvm_language == "en")
262 {
263 string t = cvar_description(theCvar);
264 if(t != "" && t != "custom cvar")
265 theTooltip = t;
266 }
267 }
268 else if(theTooltip == "-") // no cvar description as tooltip
269 {
270 theTooltip = string_null;
271 }
272
273 strfree(e.tooltip);
274 e.tooltip = (theTooltip != "") ? strzone(theTooltip) : string_null;
275}
276
281
282// URI SYSTEM ////////////////////////////////////////////////////////
283
289
291void URI_Get_Callback(float id, float status, string data)
292{
293 if(url_URI_Get_Callback(id, status, data))
294 {
295 // handled
296 }
297 else if (id == URI_GET_DISCARD)
298 {
299 // discard
300 }
301 else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
302 {
303 // sv_cmd curl
304 Curl_URI_Get_Callback(id, status, data);
305 }
306 else if (id == URI_GET_UPDATENOTIFICATION)
307 {
308 UpdateNotification_URI_Get_Callback(id, status, data);
309 }
310 else
311 {
312 LOG_INFOF("Received HTTP request data for an invalid id %d.", id);
313 }
314}
315
316void UpdateNotification_URI_Get_Callback(float id, float status, string data)
317{
318 float n;
319
321 {
322 LOG_TRACE("error: UpdateNotification_URI_Get_Callback has been called before");
323 return;
324 }
325 if(status != 0)
326 {
327 LOG_TRACEF("error receiving update notification: status is %d", status);
328 return;
329 }
330 if(substring(data, 0, 1) == "<")
331 {
332 LOG_TRACE("error: received HTML instead of an update notification");
333 return;
334 }
335 if(strstrofs(data, "\r", 0) != -1)
336 {
337 LOG_TRACE("error: received carriage returns from update notification server");
338 return;
339 }
340
341 if(data == "")
342 n = 0;
343 else
344 n = tokenizebyseparator(data, "\n");
345
346 float i;
347 string s;
348
349 string un_version = "";
350 string un_tosversion = "";
351 string un_download = "";
352 string un_url = "";
353 string un_bannedservers = "";
354 string un_emergency_pk3s = "";
355 string un_promoted = "";
356 string un_recommended = "";
357 string un_compatexpire = "";
358
359 for(i = 0; i < n; ++i)
360 {
361 s = substring(argv(i), 2, -1);
362 if(s == "") { continue; } // ignore empty lines
363
364 switch(substring(argv(i), 0, 1))
365 {
366 case "V":
367 {
368 un_version = s;
369 break;
370 }
371 case "T":
372 {
373 un_tosversion = s;
374 break;
375 }
376 case "C":
377 {
378 un_compatexpire = s;
379 break;
380 }
381 case "D":
382 {
383 un_download = s;
384 break;
385 }
386 case "U":
387 {
388 un_url = s;
389 break;
390 }
391 case "B":
392 {
393 APPEND_TO_STRING(un_bannedservers, " ", s);
394 break;
395 }
396 case "H":
397 {
398 // Hotfix (version-specific pk3 supported in >= 0.8.6)
399 // replaces "E" (missing-file-specific pk3 supported in <= 0.8.5)
400 APPEND_TO_STRING(un_emergency_pk3s, " ", s);
401 break;
402 }
403 case "P":
404 {
405 APPEND_TO_STRING(un_promoted, " ", s);
406 break;
407 }
408 case "R":
409 {
410 APPEND_TO_STRING(un_recommended, " ", s);
411 break;
412 }
413 }
414 }
415
416 if(un_version != "" && vercmp(cvar_string("g_xonoticversion"), un_version) < 0)
417 {
418 // update needed
420 if(un_download) { LOG_INFO(_("Update can be downloaded at:"), "\n", un_download); }
421 if(un_url) { _Nex_ExtResponseSystem_UpdateToURL = strzone(un_url); }
422 }
423
424 if(un_tosversion != "")
425 {
426 _Nex_ExtResponseSystem_NewToS = stof(un_tosversion);
427 }
428
429 if(un_bannedservers != "")
430 {
433 }
434
435 if(un_emergency_pk3s != "")
436 {
437 _Nex_ExtResponseSystem_Packs = strzone(un_emergency_pk3s);
439 }
440
441 if(un_promoted != "")
442 {
445 }
446
447 if(un_recommended != "")
448 {
451 }
452}
453
454// END OF URI SYSTEM ////////////////////////////////////////////////////////
455
457{
459 {
461 cvar_set("cl_startcount", ftos(cvar("cl_startcount") + 1));
462 uri_get("https://update.xonotic.org/checkupdate.txt", URI_GET_UPDATENOTIFICATION);
463 }
464
466 {
467 float n, i;
468 float allgood;
470 allgood = true;
471 for(i = 0; i+1 < n; i += 2)
472 {
473 if(strcmp(argv(i+1), cvar_string("g_xonoticversion"))) // these aren't the versions we're looking for
474 continue;
475 string packfn = whichpack("hotfix-autoexec.cfg");
476 if(packfn) // we have the cfg we're looking for in some pk3
477 {
478 if(!strncmp(packfn, "dlcache/", 8)) // it's in dlcache
479 packfn = substring(packfn, 8, strlen(packfn)); // strip prefix "dlcache/"
480 if(strstrofs(argv(i), packfn, strlen(argv(i)) - strlen(packfn)) > 0) // last chars of url == packfn
481 continue; // the pk3 we're looking for already provides the cfg we're looking for
482 }
483 allgood = false;
484 if(_Nex_ExtResponseSystem_PacksStep == 1) // first run
485 localcmd("\ncurl --pak \"", argv(i), "\"\n");
486 }
487 if(allgood)
488 {
490 {
491 if(!Menu_Active)
492 cvar_set("_menu_initialized", "0");
493 // HACK: cause m_hide call on next start
494 //localcmd("\nmenu_restart\n"); // <= 0.8.5
495 localcmd("\nexec hotfix-autoexec.cfg\n");
496 }
498 }
499 else
501 }
502}
503
505{
506 vector sz;
507 vector boxA, boxB;
508
509 updateCheck();
510
514 {
516
517 sz = eX * 0.025 + eY * 0.025 * (draw_scale.x / draw_scale.y);
518 draw_CenterText('0.5 0.5 0' - 1.25 * sz.y * eY, _("Autogenerating mapinfo for newly added maps..."), sz, '1 1 1', 1, 0);
519
520 boxA = '0.05 0.5 0' + 0.25 * sz.y * eY;
521 boxB = '0.95 0.5 0' + 1.25 * sz.y * eY;
522 draw_Fill(boxA, boxB - boxA, '1 1 1', 1);
523
524 boxA += sz * 0.1;
525 boxB -= sz * 0.1;
526 draw_Fill(boxA, boxB - boxA, '0.1 0.1 0.1', 1);
527
528 boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress;
529 draw_Fill(boxA, boxB - boxA, '0 0 1', 1);
530
531 return false;
532 }
533 return true;
534}
535
539void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize);
542{
543 vector fs, sz = '0 0 0', line, mid;
544
545 updateCheck();
546
548 {
549 // TODO rather turn this into a dialog
550 fs = ((1/draw_scale.x) * eX + (1/draw_scale.y) * eY) * 12;
551 line = eY * fs.y;
552 string l1, l2;
553 l1 = sprintf(_("Update to %s now!"), _Nex_ExtResponseSystem_UpdateTo);
554 l2 = "https://xonotic.org";
557
558 sz_x = draw_TextWidth(" ", 0, fs) + max(
559 draw_TextWidth(l1, 0, fs),
560 draw_TextWidth(l2, 0, fs)
561 );
562 sz_y = 3 * fs.y;
563
564 draw_alpha = bound(0, sin(time * 0.112 - 0.3) * 10, 1);
565 mid = eX * (0.5 + 0.5 * (1 - sz.x) * cos(time * 0.071))
566 + eY * (0.5 + 0.5 * (1 - sz.y) * sin(time * 0.071));
567
568 draw_Fill(mid - 0.5 * sz, sz, '1 1 0', 1);
569 draw_CenterText(mid - 1 * line, l1, fs, '1 0 0', 1, 0);
570 draw_CenterText(mid - 0 * line, l2, fs, '0 0 1', 1, 0);
571 }
572
574 campaign_name_previous = strzone(strcat(campaign_name, "x")); // force unequal
576 {
577 if(cvar(strcat("g_campaign", campaign_name, "_won")))
578 {
580 {
581 m_display();
582 DialogOpenButton_Click_withCoords(NULL, main.winnerDialog, '0 0 0', eX * conwidth + eY * conheight);
583 }
585 }
586 else
588 }
589 else
590 {
592 campaign_won_previous = cvar(strcat("g_campaign", campaign_name, "_won"));
593 }
594}
595
596string resolvemod(string m)
597{
598 if(m == "=")
599 return getcurrentmod();
600 else
601 return m;
602}
603
605{
606 bool have_dds = (fexists("dds/particles/particlefont.dds"));
607 bool have_jpg = (fexists("particles/particlefont.jpg"));
608 bool have_tga = (fexists("particles/particlefont.tga"));
609 bool can_dds = GL_Have_TextureCompression();
610
611 if (!can_dds)
612 cvar_set("gl_texturecompression", "0");
613
614 if(have_dds && (have_jpg || have_tga))
615 {
616 // both? Let's only use good quality precompressed files
617 // but ONLY if we actually support it!
618 // bones_was_here: quality settings moved to effects configs and menu
619 }
620 else if(have_dds)
621 {
622 // DDS only? We _must_ load DDS files!
623 cvar_set("r_texture_dds_load", "1");
624 if(!can_dds)
625 {
626 cvar_set("r_texture_dds_swdecode", "1");
627 LOG_WARN(_("^1ERROR: Texture compression is required but not supported.\n^1Expect visual problems."));
628 }
629 }
630 else
631 {
632 // TGA only? Allow runtime compression
633 }
634}
635
636// note: include only those that should be in the menu!
637#define GAMETYPES \
638 GAMETYPE(MAPINFO_TYPE_DEATHMATCH) \
639 GAMETYPE(MAPINFO_TYPE_TEAM_DEATHMATCH) \
640 GAMETYPE(MAPINFO_TYPE_CTF) \
641 GAMETYPE(MAPINFO_TYPE_CA) \
642 GAMETYPE(MAPINFO_TYPE_FREEZETAG) \
643 GAMETYPE(MAPINFO_TYPE_MAYHEM) \
644 GAMETYPE(MAPINFO_TYPE_TEAM_MAYHEM) \
645 GAMETYPE(MAPINFO_TYPE_KEEPAWAY) \
646 GAMETYPE(MAPINFO_TYPE_TEAM_KEEPAWAY) \
647 GAMETYPE(MAPINFO_TYPE_KEYHUNT) \
648 GAMETYPE(MAPINFO_TYPE_LMS) \
649 GAMETYPE(MAPINFO_TYPE_DOMINATION) \
650 GAMETYPE(MAPINFO_TYPE_NEXBALL) \
651 GAMETYPE(MAPINFO_TYPE_ONSLAUGHT) \
652 GAMETYPE(MAPINFO_TYPE_ASSAULT) \
653 GAMETYPE(MAPINFO_TYPE_SURVIVAL) \
654 /* GAMETYPE(MAPINFO_TYPE_DUEL) */ \
655 /**/
656
657// hidden gametypes come last so indexing always works correctly
658#define HIDDEN_GAMETYPES \
659 GAMETYPE(MAPINFO_TYPE_RACE) \
660 GAMETYPE(MAPINFO_TYPE_CTS) \
661 GAMETYPE(MAPINFO_TYPE_INVASION) \
662 /**/
663
665{
666 int i = 0;
667 #define GAMETYPE(it) { if (i++ == cnt) return it; }
670 #undef GAMETYPE
671 return NULL;
672}
673
675{
676 int i = 0;
677 bool showall = autocvar_menu_create_show_all;
678 #define GAMETYPE(id) ++i;
680 #undef GAMETYPE
681 #define GAMETYPE(it) { if (showall) ++i; }
683 #undef GAMETYPE
684 return i;
685}
686
688{
689 int i = 0;
690 #define GAMETYPE(id) ++i;
693 #undef GAMETYPE
694 return i;
695}
696
698{
700 return i ? MapInfo_Type_ToText(i) : "";
701}
702
704{
706 return i ? strcat("gametype_", MapInfo_Type_ToString(i)) : "";
707}
708
709.void(entity) TR;
710.void(entity, float, float, entity) TD;
711.void(entity, float) TDempty;
712.void(entity, float, float) gotoRC;
713entity makeXonoticTextLabel(float theAlign, string theText);
715.void(entity, string, string) addValue;
716.void(entity) configureXonoticTextSliderValues;
717entity makeXonoticColorpickerString(string theCvar, string theDefaultCvar);
718entity makeXonoticCheckBoxString(string, string, string, string);
719entity makeXonoticCheckBox(float, string, string);
721
722void dialog_hudpanel_main_checkbox(entity me, string panelname)
723{
724 entity e;
725
726 me.TR(me);
727 me.TDempty(me, 1.5);
728 me.TD(me, 1, 2.5, e = makeXonoticCheckBox(0, strzone(strcat("hud_panel_", panelname)), _("Enable")));
729}
730
731void dialog_hudpanel_main_settings(entity me, string panelname)
732{
733 float i;
734 entity e;
735
736 me.gotoRC(me, me.currentRow + 1.5, 0);
737 me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("Background:")));
738 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg"))));
739 e.setValueSpace(e, e.valueSpace * 1.25);
740 e.addValue(e, _("Default"), "");
741 e.addValue(e, _("Disable"), "0");
742 e.addValue(e, strzone(strcat("border_", panelname)), strzone(strcat("border_", panelname)));
743 e.configureXonoticTextSliderValues(e);
744 me.TR(me);
745 me.TDempty(me, 0.2);
746 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Color:")));
747 setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg")), "0");
748 me.TD(me, 2, 2.6, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
749 setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
750 me.TR(me);
751 me.TDempty(me, 0.4);
752 me.TD(me, 1, 3.6, e = makeXonoticCheckBoxString("", "1 1 1", strzone(strcat("hud_panel_", panelname, "_bg_color")), _("Default")));
753 me.TR(me);
754 me.TDempty(me, 0.2);
755 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Border size:")));
756 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_border"))));
757 e.addValue(e, _("Default"), "");
758 e.addValue(e, _("Disable"), "0");
759 for(i = 1; i <= 10; ++i)
760 e.addValue(e, strzone(ftos_decimals(i * 2, 0)), strzone(ftos(i * 2)));
761 e.configureXonoticTextSliderValues(e);
762 me.TR(me);
763 me.TDempty(me, 0.2);
764 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Opacity:")));
765 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_alpha"))));
766 e.addValue(e, _("Default"), "");
767 for(i = 1; i <= 20; ++i)
768 e.addValue(e, strzone(ftos_decimals_percentage(i / 20, 0)), strzone(ftos_mindecimals(i / 20)));
769 e.configureXonoticTextSliderValues(e);
770 me.TR(me);
771 me.TDempty(me, 0.2);
772 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Team color:")));
773 setDependentNOT(e, strzone(strcat("hud_panel_", panelname, "_bg_alpha")), 0);
774 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_color_team"))));
775 e.addValue(e, _("Default"), "");
776 e.addValue(e, _("Disable"), "0");
777 for(i = 1; i <= 10; ++i)
778 e.addValue(e, strzone(ftos_decimals_percentage(i / 10, 0)), strzone(ftos_mindecimals(i / 10)));
779 e.configureXonoticTextSliderValues(e);
780 setDependentNOT(e, strzone(strcat("hud_panel_", panelname, "_bg_alpha")), 0);
781 me.TR(me);
782 me.TDempty(me, 0.4);
783 me.TD(me, 1, 3.6, e = makeXonoticCheckBox(0, "hud_configure_teamcolorforced", _("Test team color in configure mode")));
784 me.TR(me);
785 me.TDempty(me, 0.2);
786 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Padding:")));
787 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_padding"))));
788 e.addValue(e, _("Default"), "");
789 for(i = 0; i <= 10; ++i)
790 e.addValue(e, strzone(ftos_decimals(i - 5, 0)), strzone(ftos(i - 5)));
791 e.configureXonoticTextSliderValues(e);
792
793 string hide_ondeath = strcat("hud_panel_", panelname, "_hide_ondeath");
794 if(cvar_type(hide_ondeath) & CVAR_TYPEFLAG_EXISTS)
795 {
796 me.TR(me);
797 me.TDempty(me, 0.2);
798 me.TD(me, 1, 3.8, e = makeXonoticCheckBox(0, strzone(hide_ondeath), _("Hide on death")));
799 }
800
801 me.gotoRC(me, me.currentRow + 0.5, 0); me.setFirstColumn(me, me.currentColumn);
802}
803
805{
806 return (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1");
807}
808
810{
811 // it doesn't allow clients to connect from different machines
812 localcmd("defer 0.1 \"sv_cmd settemp net_address 127.0.0.1\"\n");
813 localcmd("defer 0.1 \"sv_cmd settemp net_address_ipv6 ::1\"\n");
814}
815
816float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
817{
818 if(startAlpha < targetAlpha)
819 currentAlpha = min(currentAlpha + frametime * 0.5, targetAlpha);
820 else
821 currentAlpha = max(currentAlpha - frametime * 0.5, targetAlpha);
822 return currentAlpha;
823}
824
825void CheckSendCvars(entity me, string cvarnamestring)
826{
827 if(me.sendCvars)
828 {
830 {
831 LOG_INFOF("Sending cvar: %s -> %s", cvarnamestring, cvar_string(cvarnamestring));
832 localcmd(sprintf("\nsendcvar %s\n", cvarnamestring));
833 }
834 }
835}
entity parent
Definition animhost.qc:7
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
string campaign_name
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float cnt
Definition powerups.qc:24
void depthfirst(entity start,.entity up,.entity downleft,.entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
Definition util.qc:393
string getcurrentmod()
Definition util.qc:1327
#define APPEND_TO_STRING(list, sep, add)
Definition util.qh:265
float frametime
float CVAR_TYPEFLAG_EXISTS
float time
#define strstrofs
#define strlen
#define tokenize_console
#define strcmp
#define strncmp
#define tokenizebyseparator
#define pass(name, colormin, colormax)
ERASEABLE bool fexists(string f)
Definition file.qh:4
bool autocvar_menu_create_show_all
void Curl_URI_Get_Callback(int id, float status, string data)
Definition generic.qc:31
string prvm_language
Definition i18n.qh:8
#define main
Definition _all.inc:202
#define LOG_TRACEF(...)
Definition log.qh:77
#define LOG_INFO(...)
Definition log.qh:65
#define LOG_TRACE(...)
Definition log.qh:76
#define LOG_INFOF(...)
Definition log.qh:66
#define LOG_WARN(...)
Definition log.qh:61
string MapInfo_Type_ToString(Gametype t)
Definition mapinfo.qc:656
float _MapInfo_FilterGametype(vector pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition mapinfo.qc:181
void MapInfo_Cache_Create()
Definition mapinfo.qc:53
string MapInfo_Type_ToText(Gametype t)
Definition mapinfo.qc:661
void MapInfo_Enumerate()
Definition mapinfo.qc:134
vector MAPINFO_TYPE_ALL
Definition mapinfo.qh:27
float MapInfo_progress
Definition mapinfo.qh:173
float draw_TextWidth(string theText, float ICanHasKallerz, vector SizeThxBye)
Definition draw.qc:304
void draw_CenterText(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
Definition draw.qc:298
void draw_Fill(vector theOrigin, vector theSize, vector theColor, float theAlpha)
Definition draw.qc:97
vector draw_scale
Definition draw.qh:8
float draw_alpha
Definition draw.qh:9
Gametype GameType_GetID(int cnt)
Definition util.qc:664
void saveCvarsOf(entity ignore, entity e)
Definition util.qc:37
float campaign_won_previous
Definition util.qc:537
void saveAllCvars(entity root)
Definition util.qc:49
void URI_Get_Callback(float id, float status, string data)
engine callback
Definition util.qc:291
entity saveCvars_Callback_ent
Definition util.qc:100
void setDependentWeird(entity e, float(entity) func)
Definition util.qc:249
bool isServerSingleplayer()
Definition util.qc:804
#define GAMETYPES
Definition util.qc:637
void UpdateNotification_URI_Get_Callback(float id, float status, string data)
Definition util.qc:316
entity winnerDialog
Definition util.qc:540
void preMenuDraw()
this is run before the menu is drawn.
Definition util.qc:541
int GameType_GetCount()
Definition util.qc:674
float preMenuInit()
you have to define this for pre-menu initialization.
Definition util.qc:504
void saveCvarsCallback(entity me)
Definition util.qc:102
string _Nex_ExtResponseSystem_Packs
Definition util.qc:287
int GameType_GetTotalCount()
Definition util.qc:687
void makeCallback(entity e, entity cbent, void(entity, entity) cbfunc)
Definition util.qc:107
string _Nex_ExtResponseSystem_UpdateToURL
Definition util.qc:286
void setDependent_Draw(entity e)
Definition util.qc:174
void loadCvarsOf(entity ignore, entity e)
Definition util.qc:44
entity makeXonoticTextLabel(float theAlign, string theText)
Definition textlabel.qc:3
void loadAllCvars(entity root)
Definition util.qc:53
bool sendCvars
Definition util.qc:720
string GameType_GetName(int cnt)
Definition util.qc:697
bool GL_Have_TextureCompression()
Definition util.qc:20
void setDependentStringNotEqual(entity e, string theCvarName, string theCvarValue)
Definition util.qc:204
void postMenuDraw()
this is run just after the menu is drawn (or not).
Definition util.qc:538
entity makeXonoticTextSlider(string)
Definition textslider.qc:10
void setDependentAND(entity e, string theCvarName, float theCvarMin, float theCvarMax)
Definition util.qc:213
string resolvemod(string m)
Definition util.qc:596
string GameType_GetIcon(int cnt)
Definition util.qc:703
string getCvarsMulti(entity me)
Definition util.qc:60
void updateCheck()
Definition util.qc:456
void setDependentOR(entity e, string theCvarName, float theCvarMin, float theCvarMax)
Definition util.qc:231
entity makeXonoticCheckBoxString(string, string, string, string)
float _Nex_ExtResponseSystem_PacksStep
Definition util.qc:288
bool GL_CheckExtension(string ext)
Definition util.qc:15
void forAllDescendants(entity root, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
Definition util.qc:26
void makeMulti(entity e, string otherCvars)
Definition util.qc:92
void CheckSendCvars(entity me, string cvarnamestring)
Definition util.qc:825
void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize)
float _Nex_ExtResponseSystem_Queried
Definition util.qc:284
float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
Definition util.qc:816
void dialog_hudpanel_main_checkbox(entity me, string panelname)
Definition util.qc:722
void setDependentNOT(entity e, string theCvarName, float theCvarValue)
Definition util.qc:192
string _Nex_ExtResponseSystem_UpdateTo
Definition util.qc:285
#define HIDDEN_GAMETYPES
Definition util.qc:658
void SUB_Null_ee(entity e1, entity e2)
Definition util.qc:32
void makeServerSingleplayer()
Definition util.qc:809
void clearTooltip(entity e)
Definition util.qc:277
entity makeXonoticColorpickerString(string theCvar, string theDefaultCvar)
void updateCompression()
Definition util.qc:604
entity makeXonoticCheckBox(float, string, string)
Definition checkbox.qc:28
void setDependent_Check(entity e)
Definition util.qc:127
void dialog_hudpanel_main_settings(entity me, string panelname)
Definition util.qc:731
string campaign_name_previous
Definition util.qc:536
void saveCvarsMulti(entity me)
Definition util.qc:66
string controlledCvars_Multi
Definition util.qc:58
void setDependent(entity e, string theCvarName, float theCvarMin, float theCvarMax)
Definition util.qc:180
void setZonedTooltip(entity e, string theTooltip, string theCvar)
Definition util.qc:257
float _Nex_ExtResponseSystem_BannedServersNeedsRefresh
Definition util.qh:63
float _Nex_ExtResponseSystem_RecommendedServersNeedsRefresh
Definition util.qh:67
string _Nex_ExtResponseSystem_BannedServers
Definition util.qh:62
string _Nex_ExtResponseSystem_PromotedServers
Definition util.qh:64
float _Nex_ExtResponseSystem_NewToS
Definition util.qh:68
string _Nex_ExtResponseSystem_RecommendedServers
Definition util.qh:66
float _Nex_ExtResponseSystem_PromotedServersNeedsRefresh
Definition util.qh:65
void m_display()
Definition menu.qc:949
string controlledCvar
Definition menu.qc:16
void draw_reset_cropped()
Definition menu.qc:110
float conwidth
Definition menu.qh:36
bool Menu_Active
Definition menu.qh:15
const int GAME_ISSERVER
Definition menu.qh:11
const int GAME_CONNECTED
Definition menu.qh:12
int gamestatus
Definition menu.qh:16
float conheight
Definition menu.qh:36
entity nextSibling
Definition menu_cmd.qc:12
entity firstChild
Definition menu_cmd.qc:12
void localcmd(string command,...)
void cvar_set(string name, string value)
float stof(string val,...)
float bound(float min, float value, float max)
string substring(string s, float start, float length)
float cvar(string name)
float cos(float f)
const string cvar_string(string name)
float sin(float f)
float min(float f,...)
string ftos(float f)
string strzone(string s)
string argv(float n)
float max(float f,...)
var void func_null()
string string_null
Definition nil.qh:9
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define NULL
Definition post.qh:14
vector
Definition self.qh:92
ERASEABLE string ftos_decimals(float number, int decimals)
converts a number to a string with the indicated number of decimals
Definition string.qh:469
#define strfree(this)
Definition string.qh:59
#define strhasword(s, w)
Definition string.qh:370
ERASEABLE int vercmp(string v1, string v2)
Definition string.qh:557
#define strcpy(this, s)
Definition string.qh:52
ERASEABLE string ftos_mindecimals(float number)
Converts a number to a string with the minimum number of decimals It assumes that an extreme accuracy...
Definition string.qh:497
ERASEABLE string ftos_decimals_percentage(float number, int decimals)
converts a percentage to a string with the indicated number of decimals
Definition string.qh:480
ERASEABLE float url_URI_Get_Callback(int id, float status, string data)
Definition urllib.qc:28
const int URI_GET_CURL
Definition urllib.qh:7
const int URI_GET_DISCARD
Definition urllib.qh:4
const int URI_GET_CURL_END
Definition urllib.qh:8
const int URI_GET_UPDATENOTIFICATION
Definition urllib.qh:9
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44