‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
hud_util_shared.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\lui_shared;
4 #using scripts\shared\util_shared;
5 
6 #insert scripts\shared\shared.gsh;
7 
8 #namespace hud;
9 
10 function ‪setParent( element )
11 {
12  if ( isdefined( self.parent ) && self.parent == element )
13  return;
14 
15  if ( isdefined( self.parent ) )
16  self.parent ‪removeChild( self );
17 
18  self.parent = element;
19  self.parent ‪addChild( self );
20 
21  if ( isdefined( self.point ) )
22  self ‪setPoint( self.point, self.relativePoint, self.xOffset, self.yOffset );
23  else
24  self ‪setPoint( "TOP" );
25 }
26 
27 function ‪getParent()
28 {
29  return self.parent;
30 }
31 
32 function ‪addChild( element )
33 {
34  element.index = self.children.size;
35  self.children[self.children.size] = element;
36 }
37 
38 function ‪removeChild( element )
39 {
40  element.parent = undefined;
41 
42  if ( self.children[self.children.size-1] != element )
43  {
44  self.children[element.index] = self.children[self.children.size-1];
45  self.children[element.index].index = element.index;
46  }
47  self.children[self.children.size-1] = undefined;
48 
49  element.index = undefined;
50 }
51 
52 
53 function ‪setPoint( point, relativePoint, xOffset, yOffset, moveTime )
54 {
55  if ( !isdefined( moveTime ) )
56  moveTime = 0;
57 
58  element = self ‪getParent();
59 
60  if ( moveTime )
61  self moveOverTime( moveTime );
62 
63  if ( !isdefined( xOffset ) )
64  xOffset = 0;
65  self.xOffset = xOffset;
66 
67  if ( !isdefined( yOffset ) )
68  yOffset = 0;
69  self.yOffset = yOffset;
70 
71  self.point = point;
72 
73  self.alignX = "center";
74  self.alignY = "middle";
75 
76  switch( point )
77  {
78  case "CENTER":
79  break;
80 
81  case "TOP":
82  self.alignY = "top";
83  break;
84 
85  case "BOTTOM":
86  self.alignY = "bottom";
87  break;
88 
89  case "LEFT":
90  self.alignX = "left";
91  break;
92 
93  case "RIGHT":
94  self.alignX = "right";
95  break;
96 
97  case "TOPRIGHT":
98  case "TOP_RIGHT":
99  self.alignY = "top";
100  self.alignX = "right";
101  break;
102 
103  case "TOPLEFT":
104  case "TOP_LEFT":
105  self.alignY = "top";
106  self.alignX = "left";
107  break;
108 
109  case "TOPCENTER":
110  self.alignY = "top";
111  self.alignX = "center";
112  break;
113 
114  case "BOTTOM RIGHT":
115  case "BOTTOM_RIGHT":
116  self.alignY = "bottom";
117  self.alignX = "right";
118  break;
119 
120  case "BOTTOM LEFT":
121  case "BOTTOM_LEFT":
122  self.alignY = "bottom";
123  self.alignX = "left";
124  break;
125 
126  default:
127  /# println( "^3Warning: unknown point passed to setPoint(): " + point ); #/
128  break;
129  }
130 
131  if ( !isdefined( relativePoint ) )
132  relativePoint = point;
133 
134  self.relativePoint = relativePoint;
135 
136  relativeX = "center";
137  relativeY = "middle";
138 
139  switch( relativePoint )
140  {
141  case "CENTER":
142  break;
143 
144  case "TOP":
145  relativeY = "top";
146  break;
147 
148  case "BOTTOM":
149  relativeY = "bottom";
150  break;
151 
152  case "LEFT":
153  relativeX = "left";
154  break;
155 
156  case "RIGHT":
157  relativeX = "right";
158  break;
159 
160  case "TOPRIGHT":
161  case "TOP_RIGHT":
162  relativeY = "top";
163  relativeX = "right";
164  break;
165 
166  case "TOPLEFT":
167  case "TOP_LEFT":
168  relativeY = "top";
169  relativeX = "left";
170  break;
171 
172  case "TOPCENTER":
173  relativeY = "top";
174  relativeX = "center";
175  break;
176 
177  case "BOTTOM RIGHT":
178  case "BOTTOM_RIGHT":
179  relativeY = "bottom";
180  relativeX = "right";
181  break;
182 
183  case "BOTTOM LEFT":
184  case "BOTTOM_LEFT":
185  relativeY = "bottom";
186  relativeX = "left";
187  break;
188 
189  default:
190  /# println( "^3Warning: unknown relativePoint passed to setPoint(): " + relativePoint ); #/
191  break;
192  }
193 
194  if ( element == level.uiParent )
195  {
196  self.horzAlign = relativeX;
197  self.vertAlign = relativeY;
198  }
199  else
200  {
201  self.horzAlign = element.horzAlign;
202  self.vertAlign = element.vertAlign;
203  }
204 
205 
206  if ( relativeX == element.alignX )
207  {
208  offsetX = 0;
209  xFactor = 0;
210  }
211  else if ( relativeX == "center" || element.alignX == "center" )
212  {
213  offsetX = int(element.width / 2);
214  if ( relativeX == "left" || element.alignX == "right" )
215  xFactor = -1;
216  else
217  xFactor = 1;
218  }
219  else
220  {
221  offsetX = element.width;
222  if ( relativeX == "left" )
223  xFactor = -1;
224  else
225  xFactor = 1;
226  }
227  self.x = element.x + (offsetX * xFactor);
228 
229  if ( relativeY == element.alignY )
230  {
231  offsetY = 0;
232  yFactor = 0;
233  }
234  else if ( relativeY == "middle" || element.alignY == "middle" )
235  {
236  offsetY = int(element.height / 2);
237  if ( relativeY == "top" || element.alignY == "bottom" )
238  yFactor = -1;
239  else
240  yFactor = 1;
241  }
242  else
243  {
244  offsetY = element.height;
245  if ( relativeY == "top" )
246  yFactor = -1;
247  else
248  yFactor = 1;
249  }
250  self.y = element.y + (offsetY * yFactor);
251 
252  self.x += self.xOffset;
253  self.y += self.yOffset;
254 
255  switch ( self.elemType )
256  {
257  case "bar":
258  ‪setPointBar( point, relativePoint, xOffset, yOffset );
259  //self.bar setPoint( point, relativePoint, xOffset, yOffset );
260  self.barFrame ‪setParent( self ‪getParent() );
261  self.barFrame ‪setPoint( point, relativePoint, xOffset, yOffset );
262  break;
263  }
264 
265  self ‪updateChildren();
266 }
267 
268 
269 function ‪setPointBar( point, relativePoint, xOffset, yOffset )
270 {
271  self.bar.horzAlign = self.horzAlign;
272  self.bar.vertAlign = self.vertAlign;
273 
274  self.bar.alignX = "left";
275  self.bar.alignY = self.alignY;
276  self.bar.y = self.y;
277 
278  if ( self.alignX == "left" )
279  self.bar.x = self.x;
280  else if ( self.alignX == "right" )
281  self.bar.x = self.x - self.width;
282  else
283  self.bar.x = self.x - int(self.width / 2);
284 
285  if ( self.alignY == "top" )
286  self.bar.y = self.y;
287  else if ( self.alignY == "bottom" )
288  self.bar.y = self.y;
289 
290  self ‪updateBar( self.bar.frac );
291 }
292 
293 
294 function ‪updateBar( barFrac, rateOfChange )
295 {
296  if ( self.elemType == "bar" )
297  ‪updateBarScale( barFrac, rateOfChange );
298 }
299 
300 
301 function ‪updateBarScale( barFrac, rateOfChange ) // rateOfChange is optional and is in "(entire bar lengths) per second"
302 {
303  barWidth = int(self.width * barFrac + 0.5); // (+ 0.5 rounds)
304 
305  if ( !barWidth )
306  barWidth = 1;
307 
308  self.bar.frac = barFrac;
309  self.bar setShader( self.bar.shader, barWidth, self.height );
310 
311  assert( barWidth <= self.width, "barWidth <= self.width: " + barWidth + " <= " + self.width + " - barFrac was " + barFrac );
312 
313  //if barWidth is bigger than self.width then we are drawing more than 100%
314  if ( isdefined( rateOfChange ) && barWidth < self.width )
315  {
316  if ( rateOfChange > 0 )
317  {
318  //printLn( "scaling from: " + barWidth + " to " + self.width + " at " + ((1 - barFrac) / rateOfChange) );
319  assert( ((1 - barFrac) / rateOfChange) > 0, "barFrac: " + barFrac + "rateOfChange: " + rateOfChange );
320  self.bar scaleOverTime( (1 - barFrac) / rateOfChange, self.width, self.height );
321  }
322  else if ( rateOfChange < 0 )
323  {
324  //printLn( "scaling from: " + barWidth + " to " + 0 + " at " + (barFrac / (-1 * rateOfChange)) );
325  assert( (barFrac / (-1 * rateOfChange)) > 0, "barFrac: " + barFrac + "rateOfChange: " + rateOfChange );
326  self.bar scaleOverTime( barFrac / (-1 * rateOfChange), 1, self.height );
327  }
328  }
329  self.bar.rateOfChange = rateOfChange;
330  self.bar.lastUpdateTime = getTime();
331 }
332 
333 
334 function ‪createFontString( font, fontScale )
335 {
336  fontElem = newClientHudElem( self );
337  fontElem.elemType = "font";
338  fontElem.font = font;
339  fontElem.fontscale = fontScale;
340  fontElem.x = 0;
341  fontElem.y = 0;
342  fontElem.width = 0;
343  fontElem.height = int(level.fontHeight * fontScale);
344  fontElem.xOffset = 0;
345  fontElem.yOffset = 0;
346  fontElem.children = [];
347  fontElem ‪setParent( level.uiParent );
348  fontElem.hidden = false;
349  return fontElem;
350 }
351 
352 
353 function ‪createServerFontString( font, fontScale, team )
354 {
355  if ( isdefined( team ) )
356  fontElem = newTeamHudElem( team );
357  else
358  fontElem = newHudElem();
359 
360  fontElem.elemType = "font";
361  fontElem.font = font;
362  fontElem.fontscale = fontScale;
363  fontElem.x = 0;
364  fontElem.y = 0;
365  fontElem.width = 0;
366  fontElem.height = int(level.fontHeight * fontScale);
367  fontElem.xOffset = 0;
368  fontElem.yOffset = 0;
369  fontElem.children = [];
370  fontElem ‪setParent( level.uiParent );
371  fontElem.hidden = false;
372 
373  return fontElem;
374 }
375 
376 function ‪createServerTimer( font, fontScale, team )
377 {
378  if ( isdefined( team ) )
379  timerElem = newTeamHudElem( team );
380  else
381  timerElem = newHudElem();
382  timerElem.elemType = "timer";
383  timerElem.font = font;
384  timerElem.fontscale = fontScale;
385  timerElem.x = 0;
386  timerElem.y = 0;
387  timerElem.width = 0;
388  timerElem.height = int(level.fontHeight * fontScale);
389  timerElem.xOffset = 0;
390  timerElem.yOffset = 0;
391  timerElem.children = [];
392  timerElem ‪setParent( level.uiParent );
393  timerElem.hidden = false;
394 
395  return timerElem;
396 }
397 
398 function ‪createClientTimer( font, fontScale )
399 {
400  timerElem = newClientHudElem( self );
401  timerElem.elemType = "timer";
402  timerElem.font = font;
403  timerElem.fontscale = fontScale;
404  timerElem.x = 0;
405  timerElem.y = 0;
406  timerElem.width = 0;
407  timerElem.height = int(level.fontHeight * fontScale);
408  timerElem.xOffset = 0;
409  timerElem.yOffset = 0;
410  timerElem.children = [];
411  timerElem ‪setParent( level.uiParent );
412  timerElem.hidden = false;
413 
414  return timerElem;
415 }
416 
417 function ‪createIcon( shader, width, height )
418 {
419  iconElem = newClientHudElem( self );
420  iconElem.elemType = "icon";
421  iconElem.x = 0;
422  iconElem.y = 0;
423  iconElem.width = width;
424  iconElem.height = height;
425  iconElem.xOffset = 0;
426  iconElem.yOffset = 0;
427  iconElem.children = [];
428  iconElem ‪setParent( level.uiParent );
429  iconElem.hidden = false;
430 
431  if ( isdefined( shader ) )
432  iconElem setShader( shader, width, height );
433 
434  return iconElem;
435 }
436 
437 
438 function ‪createServerIcon( shader, width, height, team )
439 {
440  if ( isdefined( team ) )
441  iconElem = newTeamHudElem( team );
442  else
443  iconElem = newHudElem();
444  iconElem.elemType = "icon";
445  iconElem.x = 0;
446  iconElem.y = 0;
447  iconElem.width = width;
448  iconElem.height = height;
449  iconElem.xOffset = 0;
450  iconElem.yOffset = 0;
451  iconElem.children = [];
452  iconElem ‪setParent( level.uiParent );
453  iconElem.hidden = false;
454 
455  if ( isdefined( shader ) )
456  iconElem setShader( shader, width, height );
457 
458  return iconElem;
459 }
460 
461 
462 function ‪createServerBar( color, width, height, flashFrac, team, selected )
463 {
464  if ( isdefined( team ) )
465  barElem = newTeamHudElem( team );
466  else
467  barElem = newHudElem();
468  barElem.x = 0;
469  barElem.y = 0;
470  barElem.frac = 0;
471  barElem.color = color;
472  barElem.sort = -2;
473  barElem.shader = "progress_bar_fill";
474  barElem setShader( "progress_bar_fill", width, height );
475  barElem.hidden = false;
476  if ( isdefined( flashFrac ) )
477  {
478  barElem.flashFrac = flashFrac;
479 // barElem thread flashThread();
480  }
481 
482  if ( isdefined( team ) )
483  barElemFrame = newTeamHudElem( team );
484  else
485  barElemFrame = newHudElem();
486  barElemFrame.elemType = "icon";
487  barElemFrame.x = 0;
488  barElemFrame.y = 0;
489  barElemFrame.width = width;
490  barElemFrame.height = height;
491  barElemFrame.xOffset = 0;
492  barElemFrame.yOffset = 0;
493  barElemFrame.bar = barElem;
494  barElemFrame.barFrame = barElemFrame;
495  barElemFrame.children = [];
496  barElemFrame.sort = -1;
497  barElemFrame.color = (1,1,1);
498  barElemFrame ‪setParent( level.uiParent );
499  if ( isdefined( selected ) )
500  barElemFrame setShader( "progress_bar_fg_sel", width, height );
501  else
502  barElemFrame setShader( "progress_bar_fg", width, height );
503  barElemFrame.hidden = false;
504 
505  if ( isdefined( team ) )
506  barElemBG = newTeamHudElem( team );
507  else
508  barElemBG = newHudElem();
509  barElemBG.elemType = "bar";
510  barElemBG.x = 0;
511  barElemBG.y = 0;
512  barElemBG.width = width;
513  barElemBG.height = height;
514  barElemBG.xOffset = 0;
515  barElemBG.yOffset = 0;
516  barElemBG.bar = barElem;
517  barElemBG.barFrame = barElemFrame;
518  barElemBG.children = [];
519  barElemBG.sort = -3;
520  barElemBG.color = (0,0,0);
521  barElemBG.alpha = 0.5;
522  barElemBG ‪setParent( level.uiParent );
523  barElemBG setShader( "progress_bar_bg", width, height );
524  barElemBG.hidden = false;
525 
526  return barElemBG;
527 }
528 
529 function ‪createBar( color, width, height, flashFrac )
530 {
531  barElem = newClientHudElem( self );
532  barElem.x = 0 ;
533  barElem.y = 0;
534  barElem.frac = 0;
535  barElem.color = color;
536  barElem.sort = -2;
537  barElem.shader = "progress_bar_fill";
538  barElem setShader( "progress_bar_fill", width, height );
539  barElem.hidden = false;
540  if ( isdefined( flashFrac ) )
541  {
542  barElem.flashFrac = flashFrac;
543 // barElem thread flashThread();
544  }
545 
546  barElemFrame = newClientHudElem( self );
547  barElemFrame.elemType = "icon";
548  barElemFrame.x = 0;
549  barElemFrame.y = 0;
550  barElemFrame.width = width;
551  barElemFrame.height = height;
552  barElemFrame.xOffset = 0;
553  barElemFrame.yOffset = 0;
554  barElemFrame.bar = barElem;
555  barElemFrame.barFrame = barElemFrame;
556  barElemFrame.children = [];
557  barElemFrame.sort = -1;
558  barElemFrame.color = (1,1,1);
559  barElemFrame ‪setParent( level.uiParent );
560 // barElemFrame setShader( "progress_bar_fg", width, height );
561  barElemFrame.hidden = false;
562 
563  barElemBG = newClientHudElem( self );
564  barElemBG.elemType = "bar";
565  if ( !level.splitScreen )
566  {
567  barElemBG.x = -2;
568  barElemBG.y = -2;
569  }
570  barElemBG.width = width;
571  barElemBG.height = height;
572  barElemBG.xOffset = 0;
573  barElemBG.yOffset = 0;
574  barElemBG.bar = barElem;
575  barElemBG.barFrame = barElemFrame;
576  barElemBG.children = [];
577  barElemBG.sort = -3;
578  barElemBG.color = (0,0,0);
579  barElemBG.alpha = 0.5;
580  barElemBG ‪setParent( level.uiParent );
581  if ( !level.splitScreen )
582  barElemBG setShader( "progress_bar_bg", width + 4, height + 4 );
583  else
584  barElemBG setShader( "progress_bar_bg", width + 0, height + 0 );
585  barElemBG.hidden = false;
586 
587  return barElemBG;
588 }
589 
591 {
592  frac = self.bar.frac;
593  if (isdefined(self.bar.rateOfChange))
594  {
595  frac += (getTime() - self.bar.lastUpdateTime) * self.bar.rateOfChange;
596  ‪if (frac > 1) frac = 1;
597  if (frac < 0) frac = 0;
598  }
599  return frac;
600 }
601 
603 {
604  bar = ‪createBar( (1, 1, 1), level.primaryProgressBarWidth, level.primaryProgressBarHeight );
605  if ( level.splitScreen )
606  bar ‪setPoint("TOP", undefined, level.primaryProgressBarX, level.primaryProgressBarY);
607  else
608  bar ‪setPoint("CENTER", undefined, level.primaryProgressBarX, level.primaryProgressBarY);
609 
610  return bar;
611 }
613 {
614  text = ‪createFontString( "objective", level.primaryProgressBarFontSize );
615  if ( level.splitScreen )
616  text ‪setPoint("TOP", undefined, level.primaryProgressBarTextX, level.primaryProgressBarTextY);
617  else
618  text ‪setPoint("CENTER", undefined, level.primaryProgressBarTextX, level.primaryProgressBarTextY);
619 
620  text.sort = -1;
621  return text;
622 }
623 
625 {
626  secondaryProgressBarHeight = GetDvarInt( "scr_secondaryProgressBarHeight", level.secondaryProgressBarHeight );
627  secondaryProgressBarX = GetDvarInt( "scr_secondaryProgressBarX", level.secondaryProgressBarX );
628  secondaryProgressBarY = GetDvarInt( "scr_secondaryProgressBarY", level.secondaryProgressBarY );
629 
630  bar = ‪createBar( (1, 1, 1), level.secondaryProgressBarWidth, secondaryProgressBarHeight );
631  if ( level.splitScreen )
632  bar ‪setPoint("TOP", undefined, secondaryProgressBarX, secondaryProgressBarY);
633  else
634  bar ‪setPoint("CENTER", undefined, secondaryProgressBarX, secondaryProgressBarY);
635 
636  return bar;
637 }
638 
640 {
641  secondaryProgressBarTextX = GetDvarInt( "scr_btx", level.secondaryProgressBarTextX );
642  secondaryProgressBarTextY = GetDvarInt( "scr_bty", level.secondaryProgressBarTextY );
643 
644  text = ‪createFontString( "objective", level.primaryProgressBarFontSize );
645  if ( level.splitScreen )
646  text ‪setPoint("TOP", undefined, secondaryProgressBarTextX, secondaryProgressBarTextY);
647  else
648  text ‪setPoint("CENTER", undefined, secondaryProgressBarTextX, secondaryProgressBarTextY);
649 
650  text.sort = -1;
651  return text;
652 }
653 
654 function ‪createTeamProgressBar( team )
655 {
656  bar = ‪createServerBar( (1,0,0), level.teamProgressBarWidth, level.teamProgressBarHeight, undefined, team );
657  bar ‪setPoint("TOP", undefined, 0, level.teamProgressBarY);
658  return bar;
659 }
661 {
662  text = ‪createServerFontString( "default", level.teamProgressBarFontSize, team );
663  text ‪setPoint("TOP", undefined, 0, level.teamProgressBarTextY);
664  return text;
665 }
666 
667 
668 function ‪setFlashFrac( flashFrac )
669 {
670  self.bar.flashFrac = flashFrac;
671 }
672 
673 function ‪hideElem()
674 {
675  if ( self.hidden )
676  return;
677 
678  self.hidden = true;
679 
680  if ( self.alpha != 0 )
681  self.alpha = 0;
682 
683  if ( self.elemType == "bar" || self.elemType == "bar_shader" )
684  {
685  self.bar.hidden = true;
686  if ( self.bar.alpha != 0 )
687  self.bar.alpha = 0;
688 
689  self.barFrame.hidden = true;
690  if ( self.barFrame.alpha != 0 )
691  self.barFrame.alpha = 0;
692  }
693 }
694 
695 function ‪showElem()
696 {
697  if ( !self.hidden )
698  return;
699 
700  self.hidden = false;
701 
702  if ( self.elemType == "bar" || self.elemType == "bar_shader" )
703  {
704  if ( self.alpha != .5 )
705  self.alpha = .5;
706 
707  self.bar.hidden = false;
708  if ( self.bar.alpha != 1 )
709  self.bar.alpha = 1;
710 
711  self.barFrame.hidden = false;
712  if ( self.barFrame.alpha != 1 )
713  self.barFrame.alpha = 1;
714  }
715  else
716  {
717  if ( self.alpha != 1 )
718  self.alpha = 1;
719  }
720 }
721 
722 
723 function ‪flashThread()
724 {
725  self endon ( "death" );
726 
727  if ( !self.hidden )
728  self.alpha = 1;
729 
730  while(1)
731  {
732  if ( self.frac >= self.flashFrac )
733  {
734  if ( !self.hidden )
735  {
736  self fadeOverTime(0.3);
737  self.alpha = .2;
738  wait(0.35);
739  self fadeOverTime(0.3);
740  self.alpha = 1;
741  }
742  wait(0.7);
743  }
744  else
745  {
746  if ( !self.hidden && self.alpha != 1 )
747  self.alpha = 1;
748 
750  }
751  }
752 }
753 
754 
755 function ‪destroyElem()
756 {
757  tempChildren = [];
758 
759  for ( index = 0; index < self.children.size; index++ )
760  {
761  if ( isdefined( self.children[index] ) )
762  tempChildren[tempChildren.size] = self.children[index];
763  }
764 
765  for ( index = 0; index < tempChildren.size; index++ )
766  tempChildren[index] ‪setParent( self ‪getParent() );
767 
768  if ( self.elemType == "bar" || self.elemType == "bar_shader" )
769  {
770  self.bar ‪destroy();
771  self.barFrame ‪destroy();
772  }
773 
774  self ‪destroy();
775 }
776 
777 function ‪setIconShader( shader )
778 {
779  self setShader( shader, self.width, self.height );
780 }
781 
782 function ‪setWidth( width )
783 {
784  self.width = width;
785 }
786 
787 
788 function ‪setHeight( height )
789 {
790  self.height = height;
791 }
792 
793 function ‪setSize( width, height )
794 {
795  self.width = width;
796  self.height = height;
797 }
798 
800 {
801  for ( index = 0; index < self.children.size; index++ )
802  {
803  child = self.children[index];
804  child ‪setPoint( child.point, child.relativePoint, child.xOffset, child.yOffset );
805  }
806 }
807 
808 function ‪createLoadoutIcon( player, verIndex, horIndex, xpos, ypos )
809 {
810  iconsize = 32;
811  if ( player IsSplitscreen() )
812  {
813  iconsize = 22;
814  }
815 
816  ypos = ypos - (90 + iconsize * (3 - verIndex));
817  xpos = xpos - (10 + iconsize * horIndex);
818 
819  icon = ‪createIcon( "white", iconsize, iconsize );
820  icon ‪setPoint( "BOTTOM RIGHT", "BOTTOM RIGHT", xpos, ypos );
821  icon.horzalign = "user_right";
822  icon.vertalign = "user_bottom";
823  icon.archived = false;
824  icon.foreground = false;
825 
826  return icon;
827 }
828 
829 function ‪setLoadoutIconCoords( player, verIndex, horIndex, xpos, ypos )
830 {
831  iconsize = 32;
832  if ( player IsSplitscreen() )
833  {
834  iconsize = 22;
835  }
836 
837  ypos = ypos - (90 + iconsize * (3 - verIndex));
838  xpos = xpos - (10 + iconsize * horIndex);
839 
840  self ‪setPoint( "BOTTOM RIGHT", "BOTTOM RIGHT", xpos, ypos );
841  self.horzalign = "user_right";
842  self.vertalign = "user_bottom";
843  self.archived = false;
844  self.foreground = false;
845  self.alpha = 1;
846 }
847 
848 function ‪setLoadoutTextCoords( xCoord)
849 {
850  self ‪setPoint( "RIGHT", "LEFT", xCoord, 0 );
851 }
852 
853 function ‪createLoadoutText( icon, xCoord )
854 {
855  text = ‪createFontString( "small", 1 );
856  text ‪setParent( icon );
857  text ‪setPoint( "RIGHT", "LEFT", xCoord, 0 );
858  text.archived = false;
859  text.alignX = "right";
860  text.alignY = "middle";
861  text.foreground = false;
862 
863  return text;
864 }
865 
866 function ‪showLoadoutAttribute( iconElem, icon, alpha, textElem, text )
867 {
868  iconsize = 32;
869 
870  iconElem.alpha = alpha;
871  if ( alpha )
872  iconElem setShader( icon, iconsize, iconsize );
873 
874  if ( isdefined( textElem ) )
875  {
876  textElem.alpha = alpha;
877  if ( alpha )
878  textElem setText( text );
879  }
880 }
881 
882 function ‪hideLoadoutAttribute( iconElem, fadeTime, textElem, hideTextOnly )
883 {
884  if ( isdefined( fadeTime ) )
885  {
886  if ( !isdefined( hideTextOnly ) || !hideTextOnly )
887  {
888  iconElem fadeOverTime( fadeTime );
889  }
890  if ( isdefined( textElem ) )
891  {
892  textElem fadeOverTime( fadeTime );
893  }
894  }
895 
896  if ( !isdefined( hideTextOnly ) || !hideTextOnly )
897  iconElem.alpha = 0;
898 
899  if ( isdefined( textElem ) )
900  textElem.alpha = 0;
901 }
902 
903 
904 function ‪showPerks( )
905 {
906  self LUINotifyEvent( &"show_perk_notification", 0 );
907 }
908 
909 function ‪showPerk( index, perk, ypos )
910 {
911  // don't want the hud elements when the game is over
912  assert( game["state"] != "postgame" );
913 
914  if ( !isdefined( self.perkicon ) )
915  {
916  self.perkicon = [];
917  self.perkname = [];
918  }
919 
920  if ( !isdefined( self.perkicon[ index ] ) )
921  {
922  assert( !isdefined( self.perkname[ index ] ) );
923 
924  self.perkicon[ index ] = ‪createLoadoutIcon( self, index, 0, 200, ypos );
925  self.perkname[ index ] = ‪createLoadoutText( self.perkicon[ index ], 160 );
926  }
927  else
928  {
929  self.perkicon[ index ] ‪setLoadoutIconCoords( self, index, 0, 200, ypos );
930  self.perkname[ index ] ‪setLoadoutTextCoords( 160 );
931 
932  }
933 
934  if ( perk == "perk_null" || perk == "weapon_null" || perk == "specialty_null" )
935  {
936  alpha = 0;
937  }
938  else
939  {
940  assert( isdefined( level.perkNames[ perk ] ), perk );
941 
942  alpha = 1;
943  }
944 
945  ‪showLoadoutAttribute( self.perkicon[ index ], perk, alpha, self.perkname[ index ], level.perkNames[ perk ] );
946 
947  self.perkicon[ index ] moveOverTime( 0.3 );
948  self.perkicon[ index ].x = -5;
949  self.perkicon[ index ].hidewheninmenu = true;
950 
951  self.perkname[ index ] moveOverTime( 0.3 );
952  self.perkname[ index ].x = -40;
953  self.perkname[ index ].hidewheninmenu = true;
954 }
955 
956 function ‪hidePerk( index, fadeTime, hideTextOnly )
957 {
958  if ( !isdefined (fadeTime ) )
959  fadeTime = 0.05;
960 
961  if ( level.perksEnabled == 1)
962  {
963  if ( game["state"] == "postgame" )
964  {
965  // If there has been no regualr killcams (hardcore) before the final killcam
966  // perkicon will not be set up and will fail this assert )
967  if ( isdefined( self.perkicon ) )
968  {
969  // perk icons should have been deleted in globallogic_ui::freeGameplayHudElems()
970  assert( !isdefined( self.perkicon[ index ] ) );
971  assert( !isdefined( self.perkname[ index ] ) );
972  }
973  return;
974  }
975  assert( isdefined( self.perkicon[ index ] ) );
976  assert( isdefined( self.perkname[ index ] ) );
977 
978  if ( isdefined( self.perkicon ) && isdefined( self.perkicon[ index ] ) && isdefined( self.perkname ) && isdefined( self.perkname[ index ] ) )
979  {
980  ‪hideLoadoutAttribute( self.perkicon[ index ], fadeTime, self.perkname[ index ], hideTextOnly );
981  }
982  }
983 }
984 
985 function ‪showKillstreak( index, killstreak, xpos, ypos )
986 {
987  // don't want the hud elements when the game is over
988  assert( game["state"] != "postgame" );
989 
990  if ( !isdefined( self.killstreakIcon ) )
991  self.killstreakIcon = [];
992 
993  if ( !isdefined( self.killstreakIcon[ index ] ) )
994  {
995  // Since the perks are being displayed before the killstreaks, we use 3 as our vertical index.
996  // This might have to be changed/modified if we add some other details as part of the loadout
997  // self.killstreak.size - 1 - index would be the horizontal index since we want to display the killstreaks from left to right
998  self.killstreakIcon[ index ] = ‪createLoadoutIcon( self, 3, self.killstreak.size - 1 - index, xpos, ypos );
999  }
1000 
1001  if ( killstreak == "killstreak_null" || killstreak == "weapon_null" )
1002  {
1003  alpha = 0;
1004  }
1005  else
1006  {
1007  assert( isdefined( level.killstreakIcons[ killstreak ] ), killstreak );
1008 
1009  alpha = 1;
1010  }
1011 
1012  ‪showLoadoutAttribute( self.killstreakIcon[ index ], level.killstreakIcons[ killstreak ], alpha );
1013 }
1014 
1015 function ‪hideKillstreak( index, fadetime )
1016 {
1018  {
1019  if ( game["state"] == "postgame" )
1020  {
1021  // killstreak icons should have been deleted in globallogic_ui::freeGameplayHudElems()
1022  assert( !isdefined( self.killstreakIcon[ index ] ) );
1023  return;
1024  }
1025  assert( isdefined( self.killstreakIcon[ index ] ) );
1026 
1027  ‪hideLoadoutAttribute( self.killstreakIcon[ index ], fadetime );
1028  }
1029 }
1030 
1032 {
1033  self.x = 11;
1034  self.y = 120;
1035  self.horzAlign = "user_left";
1036  self.vertAlign = "user_top";
1037 
1038  self.alignX = "left";
1039  self.alignY = "top";
1040 }
1041 
‪createPrimaryProgressBarText
‪function createPrimaryProgressBarText()
Definition: hud_util_shared.gsc:612
‪createServerBar
‪function createServerBar(color, width, height, flashFrac, team, selected)
Definition: hud_util_shared.gsc:462
‪showKillstreak
‪function showKillstreak(index, killstreak, xpos, ypos)
Definition: hud_util_shared.gsc:985
‪createBar
‪function createBar(color, width, height, flashFrac)
Definition: hud_util_shared.gsc:529
‪is_killstreaks_enabled
‪function is_killstreaks_enabled()
Definition: util_shared.gsc:1978
‪showPerks
‪function showPerks()
Definition: hud_util_shared.gsc:904
‪updateChildren
‪function updateChildren()
Definition: hud_util_shared.gsc:799
‪createServerIcon
‪function createServerIcon(shader, width, height, team)
Definition: hud_util_shared.gsc:438
‪showPerk
‪function showPerk(index, perk, ypos)
Definition: hud_util_shared.gsc:909
‪createLoadoutText
‪function createLoadoutText(icon, xCoord)
Definition: hud_util_shared.gsc:853
‪hideLoadoutAttribute
‪function hideLoadoutAttribute(iconElem, fadeTime, textElem, hideTextOnly)
Definition: hud_util_shared.gsc:882
‪setPoint
‪function setPoint(point, relativePoint, xOffset, yOffset, moveTime)
Definition: hud_util_shared.gsc:53
‪createTeamProgressBar
‪function createTeamProgressBar(team)
Definition: hud_util_shared.gsc:654
‪destroyElem
‪function destroyElem()
Definition: hud_util_shared.gsc:755
‪setSize
‪function setSize(width, height)
Definition: hud_util_shared.gsc:793
‪if
‪if(on_off)
Definition: util_shared.csc:908
‪setParent
‪function setParent(element)
Definition: hud_util_shared.gsc:10
‪createTeamProgressBarText
‪function createTeamProgressBarText(team)
Definition: hud_util_shared.gsc:660
‪setIconShader
‪function setIconShader(shader)
Definition: hud_util_shared.gsc:777
‪hideElem
‪function hideElem()
Definition: hud_util_shared.gsc:673
‪removeChild
‪function removeChild(element)
Definition: hud_util_shared.gsc:38
‪hidePerk
‪function hidePerk(index, fadeTime, hideTextOnly)
Definition: hud_util_shared.gsc:956
‪createPrimaryProgressBar
‪function createPrimaryProgressBar()
Definition: hud_util_shared.gsc:602
‪setWidth
‪function setWidth(width)
Definition: hud_util_shared.gsc:782
‪createFontString
‪function createFontString(font, fontScale)
Definition: hud_util_shared.gsc:334
‪updateBar
‪function updateBar(barFrac, rateOfChange)
Definition: hud_util_shared.gsc:294
‪updateBarScale
‪function updateBarScale(barFrac, rateOfChange)
Definition: hud_util_shared.gsc:301
‪setLoadoutIconCoords
‪function setLoadoutIconCoords(player, verIndex, horIndex, xpos, ypos)
Definition: hud_util_shared.gsc:829
‪setLoadoutTextCoords
‪function setLoadoutTextCoords(xCoord)
Definition: hud_util_shared.gsc:848
‪createSecondaryProgressBarText
‪function createSecondaryProgressBarText()
Definition: hud_util_shared.gsc:639
‪createSecondaryProgressBar
‪function createSecondaryProgressBar()
Definition: hud_util_shared.gsc:624
‪hideKillstreak
‪function hideKillstreak(index, fadetime)
Definition: hud_util_shared.gsc:1015
‪getParent
‪function getParent()
Definition: hud_util_shared.gsc:27
‪showElem
‪function showElem()
Definition: hud_util_shared.gsc:695
‪createServerFontString
‪function createServerFontString(font, fontScale, team)
Definition: hud_util_shared.gsc:353
‪getCurrentFraction
‪function getCurrentFraction()
Definition: hud_util_shared.gsc:590
‪flashThread
‪function flashThread()
Definition: hud_util_shared.gsc:723
‪setHeight
‪function setHeight(height)
Definition: hud_util_shared.gsc:788
‪createServerTimer
‪function createServerTimer(font, fontScale, team)
Definition: hud_util_shared.gsc:376
‪showLoadoutAttribute
‪function showLoadoutAttribute(iconElem, icon, alpha, textElem, text)
Definition: hud_util_shared.gsc:866
‪createClientTimer
‪function createClientTimer(font, fontScale)
Definition: hud_util_shared.gsc:398
‪destroy
‪function destroy(watcher, owner)
Definition: _decoy.gsc:108
‪setPointBar
‪function setPointBar(point, relativePoint, xOffset, yOffset)
Definition: hud_util_shared.gsc:269
‪addChild
‪function addChild(element)
Definition: hud_util_shared.gsc:32
‪createLoadoutIcon
‪function createLoadoutIcon(player, verIndex, horIndex, xpos, ypos)
Definition: hud_util_shared.gsc:808
‪createIcon
‪function createIcon(shader, width, height)
Definition: hud_util_shared.gsc:417
‪setFlashFrac
‪function setFlashFrac(flashFrac)
Definition: hud_util_shared.gsc:668
‪WAIT_SERVER_FRAME
‪#define WAIT_SERVER_FRAME
Definition: shared.gsh:265
‪setGamemodeInfoPoint
‪function setGamemodeInfoPoint()
Definition: hud_util_shared.gsc:1031