Xonotic
util.qc
Go to the documentation of this file.
1 #include "util.qh"
2 #include "dialog.qh"
3 
4 #include "../item.qh"
5 
6 #include "../menu.qh"
8 #include <common/constants.qh>
10 #include <common/util.qh>
11 #include <common/command/_mod.qh>
12 
13 float GL_CheckExtension(string ext)
14 {
15  return strhasword(cvar_string("gl_info_extensions"), ext);
16 }
17 
19 {
20  return GL_CheckExtension("GL_EXT_texture_compression_s3tc");
21 }
22 
24 void forAllDescendants(entity root, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
25 {
26  depthfirst(root, parent, firstChild, nextSibling, funcPre, funcPost, pass);
27 }
28 
31 {
32 }
33 
34 .void(entity) saveCvars;
35 void saveCvarsOf(entity ignore, entity e)
36 {
37  if(e.saveCvars)
38  e.saveCvars(e);
39 }
40 
41 .void(entity) loadCvars;
42 void loadCvarsOf(entity ignore, entity e)
43 {
44  if(e.loadCvars)
45  e.loadCvars(e);
46 }
47 void saveAllCvars(entity root)
48 {
50 }
51 void loadAllCvars(entity root)
52 {
54 }
55 
57 .void(entity me) saveCvars_Multi;
59 {
60  if (me.controlledCvars_Multi)
61  return me.controlledCvars_Multi;
62  return string_null;
63 }
65 {
66  float n, i;
67  string s, cvarname;
68 
69  me.saveCvars_Multi(me);
70  s = cvar_string(me.controlledCvar);
71 
72  n = tokenize_console(me.controlledCvars_Multi);
73  for(i = 0; i < n; ++i)
74  {
75  // cvars prefixed with ! get saved with the inverted value
76  if(substring(argv(i), 0, 1) == "!")
77  {
78  cvarname = substring(argv(i), 1, strlen(argv(i)));
79  cvar_set(cvarname, ((s == "0") ? "1" : "0"));
80  }
81  else
82  {
83  cvarname = argv(i);
84  cvar_set(cvarname, s);
85  }
86 
87  CheckSendCvars(me, cvarname);
88  }
89 }
90 void makeMulti(entity e, string otherCvars)
91 {
92  e.controlledCvars_Multi = otherCvars;
93  e.saveCvars_Multi = e.saveCvars;
94  e.saveCvars = saveCvarsMulti;
95 }
96 
97 .void(entity me) saveCvars_Callback;
99 .void(entity me, entity cb) saveCvars_Callback_func;
101 {
102  me.saveCvars_Callback(me);
103  me.saveCvars_Callback_func(me.saveCvars_Callback_ent, me);
104 }
105 void makeCallback(entity e, entity cbent, void(entity, entity) cbfunc)
106 {
107  e.saveCvars_Callback = e.saveCvars;
108  e.saveCvars = saveCvarsCallback;
109  e.saveCvars_Callback_ent = cbent;
110  e.saveCvars_Callback_func = cbfunc;
111 }
112 
113 .void(entity) draw_setDependent;
126 .float(entity) func_setDependent;
127 .bool disabled;
129 {
130  bool disabled_prev = e.disabled;
131  float f;
132  string s;
133  if(e.func_setDependent)
134  {
135  e.disabled = !(e.func_setDependent(e));
136  }
137  else if(e.cvarString_setDependent)
138  {
139  s = cvar_string(e.cvarString_setDependent);
140  e.disabled = (cvar_string(e.cvarString_setDependent) == e.cvarValue_setDependent);
141  }
142  else
143  {
144  if(e.cvar_setDependent)
145  {
146  f = cvar(e.cvar_setDependent);
147  if(e.cvarMin_setDependent <= e.cvarMax_setDependent)
148  e.disabled = ((f < e.cvarMin_setDependent) || (f > e.cvarMax_setDependent));
149  else
150  e.disabled = ((f >= e.cvarMax_setDependent) && (f <= e.cvarMin_setDependent));
151  }
152  if(e.cvar2_setDependent)
153  {
154  f = cvar(e.cvar2_setDependent);
155  if(e.cvar2Min_setDependent <= e.cvar2Max_setDependent)
156  e.disabled = (e.disabled + ((f < e.cvar2Min_setDependent) || (f > e.cvar2Max_setDependent)) > e.op_setDependent);
157  else
158  e.disabled = (e.disabled + ((f >= e.cvar2Max_setDependent) && (f <= e.cvar2Min_setDependent)) > e.op_setDependent);
159  }
160  if(e.cvar3_setDependent)
161  {
162  f = cvar(e.cvar3_setDependent);
163  if(e.cvar3Min_setDependent <= e.cvar3Max_setDependent)
164  e.disabled = (e.disabled + ((f < e.cvar3Min_setDependent) || (f > e.cvar3Max_setDependent)) > e.op_setDependent);
165  else
166  e.disabled = (e.disabled + ((f >= e.cvar3Max_setDependent) && (f <= e.cvar3Min_setDependent)) > e.op_setDependent);
167  }
168  }
169  if (disabled_prev != e.disabled && e.loadCvars)
170  e.loadCvars(e);
171 }
173 {
175  e.draw_setDependent(e);
176 }
177 .void(entity) draw;
178 void setDependent(entity e, string theCvarName, float theCvarMin, float theCvarMax)
179 {
180  e.draw_setDependent = e.draw;
181  e.cvar_setDependent = theCvarName;
182  e.cvarMin_setDependent = theCvarMin;
183  e.cvarMax_setDependent = theCvarMax;
184  e.cvar2_setDependent = string_null;
185  e.cvar3_setDependent = string_null;
186  e.func_setDependent = func_null;
187  e.draw = setDependent_Draw;
189 }
190 void setDependentStringNotEqual(entity e, string theCvarName, string theCvarValue)
191 {
192  e.draw_setDependent = e.draw;
193  e.cvarString_setDependent = theCvarName;
194  e.cvarValue_setDependent = theCvarValue;
195  e.cvar_setDependent = string_null;
196  e.cvar2_setDependent = string_null;
197  e.cvar3_setDependent = string_null;
198  e.func_setDependent = func_null;
199  e.draw = setDependent_Draw;
201 }
202 void setDependentAND(entity e, string theCvarName, float theCvarMin, float theCvarMax, string theCvar2Name, float theCvar2Min, float theCvar2Max)
203 {
204  e.draw_setDependent = e.draw;
205  e.cvar_setDependent = theCvarName;
206  e.cvarMin_setDependent = theCvarMin;
207  e.cvarMax_setDependent = theCvarMax;
208  e.cvar2_setDependent = theCvar2Name;
209  e.cvar2Min_setDependent = theCvar2Min;
210  e.cvar2Max_setDependent = theCvar2Max;
211  e.cvar3_setDependent = string_null;
212  e.op_setDependent = 0;
213  e.func_setDependent = func_null;
214  e.draw = setDependent_Draw;
216 }
217 void setDependentOR(entity e, string theCvarName, float theCvarMin, float theCvarMax, string theCvar2Name, float theCvar2Min, float theCvar2Max)
218 {
219  e.draw_setDependent = e.draw;
220  e.cvar_setDependent = theCvarName;
221  e.cvarMin_setDependent = theCvarMin;
222  e.cvarMax_setDependent = theCvarMax;
223  e.cvar2_setDependent = theCvar2Name;
224  e.cvar2Min_setDependent = theCvar2Min;
225  e.cvar2Max_setDependent = theCvar2Max;
226  e.cvar3_setDependent = string_null;
227  e.op_setDependent = 1;
228  e.func_setDependent = func_null;
229  e.draw = setDependent_Draw;
231 }
232 void setDependentAND3(entity e, string theCvarName, float theCvarMin, float theCvarMax, string theCvar2Name, float theCvar2Min, float theCvar2Max, string theCvar3Name, float theCvar3Min, float theCvar3Max)
233 {
234  e.draw_setDependent = e.draw;
235  e.cvar_setDependent = theCvarName;
236  e.cvarMin_setDependent = theCvarMin;
237  e.cvarMax_setDependent = theCvarMax;
238  e.cvar2_setDependent = theCvar2Name;
239  e.cvar2Min_setDependent = theCvar2Min;
240  e.cvar2Max_setDependent = theCvar2Max;
241  e.cvar3_setDependent = theCvar3Name;
242  e.cvar3Min_setDependent = theCvar3Min;
243  e.cvar3Max_setDependent = theCvar3Max;
244  e.op_setDependent = 0;
245  e.func_setDependent = func_null;
246  e.draw = setDependent_Draw;
248 }
249 void 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 
257 void 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 
278 {
280 }
281 
282 // URI SYSTEM ////////////////////////////////////////////////////////
283 
289 
291 void 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 
317 {
318  cvar_set("gameversion_min", ftos(100 * floor(cvar("gameversion") / 100)));
319 }
320 
321 void UpdateNotification_URI_Get_Callback(float id, float status, string data)
322 {
323  float n;
324 
325  if(_Nex_ExtResponseSystem_UpdateTo)
326  {
327  LOG_TRACE("error: UpdateNotification_URI_Get_Callback has been called before");
328  return;
329  }
330  if(status != 0)
331  {
332  LOG_TRACEF("error receiving update notification: status is %d", status);
333  return;
334  }
335  if(substring(data, 0, 1) == "<")
336  {
337  LOG_TRACE("error: received HTML instead of an update notification");
338  return;
339  }
340  if(strstrofs(data, "\r", 0) != -1)
341  {
342  LOG_TRACE("error: received carriage returns from update notification server");
343  return;
344  }
345 
346  if(data == "")
347  n = 0;
348  else
349  n = tokenizebyseparator(data, "\n");
350 
351  float i;
352  string s;
353 
354  string un_version = "";
355  string un_tosversion = "";
356  string un_download = "";
357  string un_url = "";
358  string un_bannedservers = "";
359  string un_emergency_pk3s = "";
360  string un_promoted = "";
361  string un_recommended = "";
362  string un_compatexpire = "";
363 
364  for(i = 0; i < n; ++i)
365  {
366  s = substring(argv(i), 2, -1);
367  if(s == "") { continue; } // ignore empty lines
368 
369  switch(substring(argv(i), 0, 1))
370  {
371  case "V":
372  {
373  un_version = s;
374  break;
375  }
376  case "T":
377  {
378  un_tosversion = s;
379  break;
380  }
381  case "C":
382  {
383  un_compatexpire = s;
384  break;
385  }
386  case "D":
387  {
388  un_download = s;
389  break;
390  }
391  case "U":
392  {
393  un_url = s;
394  break;
395  }
396  case "B":
397  {
398  APPEND_TO_STRING(un_bannedservers, " ", s);
399  break;
400  }
401  case "E":
402  {
403  if(cvar("menu_updatecheck_getpacks"))
404  APPEND_TO_STRING(un_emergency_pk3s, " ", s);
405  break;
406  }
407  case "P":
408  {
409  APPEND_TO_STRING(un_promoted, " ", s);
410  break;
411  }
412  case "R":
413  {
414  APPEND_TO_STRING(un_recommended, " ", s);
415  break;
416  }
417  }
418  }
419 
420  if(un_version != "")
421  {
422  if(vercmp(cvar_string("g_xonoticversion"), un_version) < 0)
423  {
424  // update needed
425  _Nex_ExtResponseSystem_UpdateTo = strzone(un_version);
426  if(un_download) { LOG_INFO(_("Update can be downloaded at:"), "\n", un_download); }
427  if(un_url) { _Nex_ExtResponseSystem_UpdateToURL = strzone(un_url); }
429  }
430  else if(cvar_string("g_xonoticversion") == un_version)
431  {
432  if(un_compatexpire != "")
433  {
434  string curdate = strftime(false, "%Y%m%d%H%M%S");
435  if (strcmp(curdate, un_compatexpire) >= 0)
437  }
438  }
439  }
440 
441  if(un_tosversion != "")
442  {
443  _Nex_ExtResponseSystem_NewToS = stof(un_tosversion);
444  }
445 
446  if(un_bannedservers != "")
447  {
448  _Nex_ExtResponseSystem_BannedServers = strzone(un_bannedservers);
450  }
451 
452  if(un_emergency_pk3s != "")
453  {
454  _Nex_ExtResponseSystem_Packs = strzone(un_emergency_pk3s);
455  _Nex_ExtResponseSystem_PacksStep = 1;
456  }
457 
458  if(un_promoted != "")
459  {
462  }
463 
464  if(un_recommended != "")
465  {
468  }
469 }
470 
471 // END OF URI SYSTEM ////////////////////////////////////////////////////////
472 
474 {
475  if(!_Nex_ExtResponseSystem_Queried)
476  {
477  _Nex_ExtResponseSystem_Queried = 1;
478  float startcnt;
479  string uri;
480 
481  cvar_set("cl_startcount", ftos(startcnt = cvar("cl_startcount") + 1));
482 
483  // for privacy, munge the start count a little
484  startcnt = floor((floor(startcnt / 10) + random()) * 10);
485  uri = sprintf("http://update.xonotic.org/checkupdate.txt?version=%s&cnt=%d", uri_escape(cvar_string("g_xonoticversion")), startcnt);
486  uri_get(uri, URI_GET_UPDATENOTIFICATION);
487  }
488 
489  if(_Nex_ExtResponseSystem_PacksStep > 0)
490  {
491  float n, i;
492  float allgood;
493  n = tokenize_console(_Nex_ExtResponseSystem_Packs);
494  allgood = true;
495  for(i = 0; i+1 < n; i += 2)
496  {
497  if(fexists(argv(i+1)))
498  continue;
499  allgood = false;
500  if(_Nex_ExtResponseSystem_PacksStep == 1) // first run
501  localcmd("\ncurl --pak \"", argv(i), "\"\n");
502  }
503  if(allgood)
504  {
505  if(_Nex_ExtResponseSystem_PacksStep == 2)
506  {
507  if(!Menu_Active)
508  cvar_set("_menu_initialized", "0");
509  // HACK: cause m_hide call on next start
510  localcmd("\nmenu_restart\n");
511  }
512  _Nex_ExtResponseSystem_PacksStep = 0;
513  }
514  else
515  _Nex_ExtResponseSystem_PacksStep = 2;
516  }
517 
518 }
519 
520 bool show_propermenu = false;
521 
522 float preMenuInit()
523 {
524  vector sz;
525  vector boxA, boxB;
526 
527  if(random() < 0.1)
528  show_propermenu = true;
529 
530  updateCheck();
531 
534  if(!_MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
535  {
537 
538  sz = eX * 0.025 + eY * 0.025 * (draw_scale.x / draw_scale.y);
539  draw_CenterText('0.5 0.5 0' - 1.25 * sz.y * eY, _("Autogenerating mapinfo for newly added maps..."), sz, '1 1 1', 1, 0);
540 
541  boxA = '0.05 0.5 0' + 0.25 * sz.y * eY;
542  boxB = '0.95 0.5 0' + 1.25 * sz.y * eY;
543  draw_Fill(boxA, boxB - boxA, '1 1 1', 1);
544 
545  boxA += sz * 0.1;
546  boxB -= sz * 0.1;
547  draw_Fill(boxA, boxB - boxA, '0.1 0.1 0.1', 1);
548 
549  boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress;
550  draw_Fill(boxA, boxB - boxA, '0 0 1', 1);
551 
552  return false;
553  }
554  return true;
555 }
556 
559 void postMenuDraw() {}
560 void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize);
561 .entity winnerDialog;
563 {
564  vector fs, sz = '0 0 0', line, mid;
565 
566  updateCheck();
567 
568  if(_Nex_ExtResponseSystem_UpdateTo != "" && !(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)))
569  {
570  // TODO rather turn this into a dialog
571  fs = ((1/draw_scale.x) * eX + (1/draw_scale.y) * eY) * 12;
572  line = eY * fs.y;
573  string l1, l2;
574  if(show_propermenu)
575  l1 = sprintf("Jeff pay 4 new weapons for %s", _Nex_ExtResponseSystem_UpdateTo);
576  else
577  l1 = sprintf(_("Update to %s now!"), _Nex_ExtResponseSystem_UpdateTo);
578  l2 = "http://www.xonotic.org/";
579  if(_Nex_ExtResponseSystem_UpdateToURL)
581 
582  sz_x = draw_TextWidth(" ", 0, fs) + max(
583  draw_TextWidth(l1, 0, fs),
584  draw_TextWidth(l2, 0, fs)
585  );
586  sz_y = 3 * fs.y;
587 
588  draw_alpha = bound(0, sin(time * 0.112 - 0.3) * 10, 1);
589  mid = eX * (0.5 + 0.5 * (1 - sz.x) * cos(time * 0.071))
590  + eY * (0.5 + 0.5 * (1 - sz.y) * sin(time * 0.071));
591 
592  draw_Fill(mid - 0.5 * sz, sz, '1 1 0', 1);
593  draw_CenterText(mid - 1 * line, l1, fs, '1 0 0', 1, 0);
594  draw_CenterText(mid - 0 * line, l2, fs, '0 0 1', 1, 0);
595  }
596 
597  if (!campaign_name_previous)
598  campaign_name_previous = strzone(strcat(campaign_name, "x")); // force unequal
599  if(campaign_name == campaign_name_previous)
600  {
601  if(cvar(strcat("g_campaign", campaign_name, "_won")))
602  {
603  if(!campaign_won_previous)
604  {
605  m_display();
606  DialogOpenButton_Click_withCoords(NULL, main.winnerDialog, '0 0 0', eX * conwidth + eY * conheight);
607  }
608  campaign_won_previous = 1;
609  }
610  else
611  campaign_won_previous = 0;
612  }
613  else
614  {
615  strcpy(campaign_name_previous, campaign_name);
616  campaign_won_previous = cvar(strcat("g_campaign", campaign_name, "_won"));
617  }
618 }
619 
620 string resolvemod(string m)
621 {
622  if(m == "=")
623  return getcurrentmod();
624  else
625  return m;
626 }
627 
629 {
630  float have_dds, have_jpg, have_tga;
631  float can_dds;
632  have_dds = (fexists("dds/particles/particlefont.dds"));
633  have_jpg = (fexists("particles/particlefont.jpg"));
634  have_tga = (fexists("particles/particlefont.tga"));
635  can_dds = GL_Have_TextureCompression();
636  if(have_dds && (have_jpg || have_tga))
637  {
638  // both? Let's only use good quality precompressed files
639  // but ONLY if we actually support it!
640  if(can_dds)
641  {
642  // these builds are meant to have GOOD quality, so let's not compress non-skinframes
643  cvar_set("gl_texturecompression", "0");
644  return 1;
645 
646  //cvar_set("gl_texturecompression", cvar_string("r_texture_dds_load"));
647  //return 2;
648  }
649  else
650  {
651  cvar_set("gl_texturecompression", "0");
652  cvar_set("r_texture_dds_load", "0");
653  return 0;
654  }
655  }
656  else if(have_dds)
657  {
658  // DDS only? We probably always want texture compression
659  cvar_set("gl_texturecompression", "1");
660  cvar_set("r_texture_dds_load", "1");
661  if(!can_dds)
662  LOG_INFO(_("^1ERROR: Texture compression is required but not supported.\n^1Expect visual problems."));
663  return 0;
664  }
665  else
666  {
667  // TGA only? Allow runtime compression
668  if(can_dds)
669  {
670  cvar_set("gl_texturecompression", cvar_string("r_texture_dds_load"));
671  return 2;
672  }
673  else
674  {
675  cvar_set("gl_texturecompression", "0");
676  cvar_set("r_texture_dds_load", "0");
677  return 0;
678  }
679  }
680 }
681 
682 // note: include only those that should be in the menu!
683 #define GAMETYPES \
684  GAMETYPE(MAPINFO_TYPE_DEATHMATCH) \
685  GAMETYPE(MAPINFO_TYPE_TEAM_DEATHMATCH) \
686  GAMETYPE(MAPINFO_TYPE_CTF) \
687  GAMETYPE(MAPINFO_TYPE_CA) \
688  GAMETYPE(MAPINFO_TYPE_FREEZETAG) \
689  GAMETYPE(MAPINFO_TYPE_KEEPAWAY) \
690  GAMETYPE(MAPINFO_TYPE_KEYHUNT) \
691  GAMETYPE(MAPINFO_TYPE_LMS) \
692  GAMETYPE(MAPINFO_TYPE_DOMINATION) \
693  GAMETYPE(MAPINFO_TYPE_NEXBALL) \
694  GAMETYPE(MAPINFO_TYPE_ONSLAUGHT) \
695  GAMETYPE(MAPINFO_TYPE_ASSAULT) \
696  /* GAMETYPE(MAPINFO_TYPE_DUEL) */ \
697  /* GAMETYPE(MAPINFO_TYPE_INVASION) */ \
698 
699 
700 // hidden gametypes come last so indexing always works correctly
701 #define HIDDEN_GAMETYPES \
702  GAMETYPE(MAPINFO_TYPE_RACE) \
703  GAMETYPE(MAPINFO_TYPE_CTS) \
704 
705 
707 {
708  int i = 0;
709  #define GAMETYPE(it) { if (i++ == cnt) return it; }
710  GAMETYPES
712  #undef GAMETYPE
713  return NULL;
714 }
715 
717 {
718  int i = 0;
719  int dev = cvar("developer");
720  #define GAMETYPE(id) ++i;
721  GAMETYPES
722  #undef GAMETYPE
723  #define GAMETYPE(it) { if (dev > 0) ++i; }
725  #undef GAMETYPE
726  return i;
727 }
728 
730 {
731  int i = 0;
732  #define GAMETYPE(id) ++i;
733  GAMETYPES
735  #undef GAMETYPE
736  return i;
737 }
738 
740 {
741  Gametype i = GameType_GetID(cnt);
742  return i ? MapInfo_Type_ToText(i) : "";
743 }
744 
746 {
747  Gametype i = GameType_GetID(cnt);
748  return i ? strcat("gametype_", MapInfo_Type_ToString(i)) : "";
749 }
750 
751 .void(entity) TR;
752 .void(entity, float, float, entity) TD;
753 .void(entity, float) TDempty;
754 .void(entity, float, float) gotoRC;
755 entity makeXonoticTextLabel(float theAlign, string theText);
757 .void(entity, string, string) addValue;
758 .void(entity) configureXonoticTextSliderValues;
759 entity makeXonoticColorpickerString(string theCvar, string theDefaultCvar);
760 entity makeXonoticCheckBoxString(string, string, string, string);
761 entity makeXonoticCheckBox(float, string, string);
762 .bool sendCvars;
763 
764 void dialog_hudpanel_main_checkbox(entity me, string panelname)
765 {
766  entity e;
767 
768  me.TR(me);
769  me.TDempty(me, 1.5);
770  me.TD(me, 1, 2.5, e = makeXonoticCheckBox(0, strzone(strcat("hud_panel_", panelname)), _("Enable")));
771 }
772 
773 void dialog_hudpanel_main_settings(entity me, string panelname)
774 {
775  float i;
776  entity e;
777 
778  me.gotoRC(me, me.currentRow + 1.5, 0);
779  me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("Background:")));
780  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg"))));
781  e.addValue(e, _("Default"), "");
782  e.addValue(e, _("Disable"), "0");
783  e.addValue(e, strzone(strcat("border_", panelname)), strzone(strcat("border_", panelname)));
784  e.configureXonoticTextSliderValues(e);
785  me.TR(me);
786  me.TDempty(me, 0.2);
787  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Color:")));
788  me.TD(me, 2, 2.6, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
789  setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
790  me.TR(me);
791  me.TDempty(me, 0.2);
792  me.TD(me, 1, 1.0, e = makeXonoticCheckBoxString("", "1 1 1", strzone(strcat("hud_panel_", panelname, "_bg_color")), _("Use default")));
793  me.TR(me);
794  me.TDempty(me, 0.2);
795  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Border size:")));
796  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_border"))));
797  e.addValue(e, _("Default"), "");
798  e.addValue(e, _("Disable"), "0");
799  for(i = 1; i <= 10; ++i)
800  e.addValue(e, strzone(ftos_decimals(i * 2, 0)), strzone(ftos(i * 2)));
801  e.configureXonoticTextSliderValues(e);
802  me.TR(me);
803  me.TDempty(me, 0.2);
804  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Alpha:")));
805  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_alpha"))));
806  e.addValue(e, _("Default"), "");
807  for(i = 1; i <= 10; ++i)
808  e.addValue(e, strzone(ftos_decimals(i/10, 1)), strzone(ftos(i/10)));
809  e.configureXonoticTextSliderValues(e);
810  me.TR(me);
811  me.TDempty(me, 0.2);
812  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Team Color:")));
813  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_color_team"))));
814  e.addValue(e, _("Default"), "");
815  e.addValue(e, _("Disable"), "0");
816  for(i = 1; i <= 10; ++i)
817  e.addValue(e, strzone(ftos_decimals(i/10, 1)), strzone(ftos(i/10)));
818  e.configureXonoticTextSliderValues(e);
819  me.TR(me);
820  me.TDempty(me, 0.4);
821  me.TD(me, 1, 3.6, e = makeXonoticCheckBox(0, "hud_configure_teamcolorforced", _("Test team color in configure mode")));
822  me.TR(me);
823  me.TDempty(me, 0.2);
824  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Padding:")));
825  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_padding"))));
826  e.addValue(e, _("Default"), "");
827  for(i = 0; i <= 10; ++i)
828  e.addValue(e, strzone(ftos_decimals(i - 5, 0)), strzone(ftos(i - 5)));
829  e.configureXonoticTextSliderValues(e);
830 }
831 
832 float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
833 {
834  if(startAlpha < targetAlpha)
835  currentAlpha = min(currentAlpha + frametime * 0.5, targetAlpha);
836  else
837  currentAlpha = max(currentAlpha - frametime * 0.5, targetAlpha);
838  return currentAlpha;
839 }
840 
841 void CheckSendCvars(entity me, string cvarnamestring)
842 {
843  if(me.sendCvars)
844  {
846  {
847  LOG_INFOF("Sending cvar: %s -> %s", cvarnamestring, cvar_string(cvarnamestring));
848  cmd(sprintf("\nsendcvar %s\n", cvarnamestring));
849  }
850  }
851 }
string MapInfo_Type_ToString(Gametype t)
Definition: mapinfo.qc:616
ERASEABLE string ftos_decimals(float number, int decimals)
converts a number to a string with the indicated number of decimals
Definition: string.qh:450
string string_null
Definition: nil.qh:9
string campaign_name
const vector eY
Definition: vector.qh:45
int MAPINFO_TYPE_ALL
Definition: mapinfo.qh:26
void Curl_URI_Get_Callback(int id, float status, string data)
Definition: generic.qc:31
float MapInfo_progress
Definition: mapinfo.qh:151
entity() spawn
void depthfirst(entity start,.entity up,.entity downleft,.entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
Definition: util.qc:281
string MapInfo_Type_ToText(Gametype t)
Definition: mapinfo.qc:621
#define strhasword(s, w)
Definition: string.qh:352
ERASEABLE float url_URI_Get_Callback(int id, float status, string data)
Definition: urllib.qc:28
#define strcpy(this, s)
Definition: string.qh:49
const int URI_GET_DISCARD
Definition: urllib.qh:4
void MapInfo_Cache_Create()
Definition: mapinfo.qc:34
#define APPEND_TO_STRING(list, sep, add)
Definition: util.qh:225
const int URI_GET_CURL
Definition: urllib.qh:7
const int URI_GET_UPDATENOTIFICATION
Definition: urllib.qh:9
float cnt
Definition: powerups.qc:24
#define strcmp
Definition: dpextensions.qh:51
string getcurrentmod()
Definition: util.qc:1191
#define LOG_INFOF(...)
Definition: log.qh:71
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
ERASEABLE int vercmp(string v1, string v2)
Definition: string.qh:488
#define NULL
Definition: post.qh:17
float frametime
Definition: csprogsdefs.qc:17
#define LOG_INFO(...)
Definition: log.qh:70
#define LOG_TRACEF(...)
Definition: log.qh:82
#define strstrofs
Definition: dpextensions.qh:42
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define tokenize_console
Definition: dpextensions.qh:24
string prvm_language
Definition: i18n.qh:8
const vector eX
Definition: vector.qh:44
#define LOG_TRACE(...)
Definition: log.qh:81
const int URI_GET_CURL_END
Definition: urllib.qh:8
#define tokenizebyseparator
Definition: dpextensions.qh:21
#define strfree(this)
Definition: string.qh:56
float _MapInfo_FilterGametype(int pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition: mapinfo.qc:162
float time
Definition: csprogsdefs.qc:16
#define pass(name, colormin, colormax)
ERASEABLE bool fexists(string f)
Definition: file.qh:4
void MapInfo_Enumerate()
Definition: mapinfo.qc:115
var void func_null()