‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
hud_message_shared.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\hud_message_shared;
5 #using scripts\shared\hud_util_shared;
6 #using scripts\shared\music_shared;
7 #using scripts\shared\system_shared;
8 #using scripts\shared\util_shared;
9 
10 #insert scripts\shared\shared.gsh;
11 
12 #precache( "string", "MENU_POINTS" );
13 #precache( "string", "MP_WAITING_FOR_PLAYERS_SHOUTCASTER" );
14 #precache( "eventstring", "faction_popup" );
15 
16 #namespace hud_message;
17 
18 ‪REGISTER_SYSTEM( "hud_message", &‪__init__, undefined )
19 
20 function ‪__init__()
21 {
23 }
24 
25 function ‪init()
26 {
29 }
30 
31 
33 {
34  self thread ‪hintMessageDeathThink();
35  self thread ‪lowerMessageThink();
36 
37  self thread ‪initNotifyMessage();
38  self thread ‪initCustomGametypeHeader();
39 }
40 
42 {
43  if ( isdefined( self.customGametypeHeader ) )
44  {
45  self.customGametypeHeader Destroy();
46  }
47 
48  if ( isdefined( self.customGametypeSubHeader ) )
49  {
50  self.customGametypeSubHeader Destroy();
51  }
52 }
53 
55 {
56  // Header
57  font = "default";
58  titleSize = 2.5;
59  self.customGametypeHeader = ‪hud::createFontString( font, titleSize );
60  self.customGametypeHeader ‪hud::setPoint( "TOP", undefined, 0, 30 );
61  self.customGametypeHeader.glowAlpha = 1;
62  self.customGametypeHeader.hideWhenInMenu = true;
63  self.customGametypeHeader.archived = false;
64  self.customGametypeHeader.color = ( 1, 1, 0.6 );
65  self.customGametypeHeader.alpha = 1;
66 
67  // SubHeader
68  titleSize = 2.0;
69  self.customGametypeSubHeader = ‪hud::createFontString( font, titleSize );
70  self.customGametypeSubHeader ‪hud::setParent( self.customGametypeHeader );
71  self.customGametypeSubHeader ‪hud::setPoint( "TOP", "BOTTOM", 0, 0 );
72  self.customGametypeSubHeader.glowAlpha = 1;
73  self.customGametypeSubHeader.hideWhenInMenu = true;
74  self.customGametypeSubHeader.archived = false;
75  self.customGametypeSubHeader.color = ( 1, 1, 0.6 );
76  self.customGametypeSubHeader.alpha = 1;
77 }
78 
79 function ‪hintMessage( hintText, duration )
80 {
81  notifyData = spawnstruct();
82 
83  notifyData.notifyText = hintText;
84  notifyData.duration = duration;
85 
86  ‪notifyMessage( notifyData );
87 }
88 
89 function ‪hintMessagePlayers( players, hintText, duration )
90 {
91  notifyData = spawnstruct();
92  notifyData.notifyText = hintText;
93  notifyData.duration = duration;
94 
95  for ( i = 0; i < players.size; i++ )
96  {
97  players[ i ] ‪notifyMessage( notifyData );
98  }
99 }
100 
102 {
103  self LUINotifyEvent( &"faction_popup", 1, game["strings"][team + "_name"] );
104  ‪hud_message::oldNotifyMessage( undefined, undefined, undefined, undefined );
105 }
106 
108 {
109  if( !SessionModeIsZombiesGame() )
110  {
111  if ( self IsSplitscreen() )
112  {
113  titleSize = 2.0;
114  textSize = 1.4;
115  iconSize = 24;
116  font = "big";
117  point = "TOP";
118  relativePoint = "BOTTOM";
119  yOffset = 30;
120  xOffset = 30;
121  }
122  else
123  {
124  titleSize = 2.5;
125  textSize = 1.75;
126  iconSize = 30;
127  font = "big";
128  point = "TOP";
129  relativePoint = "BOTTOM";
130  yOffset = 0;
131  xOffset = 0;
132  }
133  }
134  else
135  {
136  if ( self IsSplitscreen() )
137  {
138  titleSize = 2.0;
139  textSize = 1.4;
140  iconSize = 24;
141  font = "big";
142  point = "TOP";
143  relativePoint = "BOTTOM";
144  yOffset = 30;
145  xOffset = 30;
146  }
147  else
148  {
149  titleSize = 2.5;
150  textSize = 1.75;
151  iconSize = 30;
152  font = "big";
153  point = "BOTTOM LEFT";
154  relativePoint = "TOP";
155  yOffset = 0;
156  xOffset = 0;
157  }
158  }
159 
160 
161 
162  self.notifyTitle = ‪hud::createFontString( font, titleSize );
163  self.notifyTitle ‪hud::setPoint( point, undefined, xOffset, yOffset );
164  self.notifyTitle.glowAlpha = 1;
165  self.notifyTitle.hideWhenInMenu = true;
166  self.notifyTitle.archived = false;
167  self.notifyTitle.alpha = 0;
168 
169  self.notifyText = ‪hud::createFontString( font, textSize );
170  self.notifyText ‪hud::setParent( self.notifyTitle );
171  self.notifyText ‪hud::setPoint( point, relativePoint, 0, 0 );
172  self.notifyText.glowAlpha = 1;
173  self.notifyText.hideWhenInMenu = true;
174  self.notifyText.archived = false;
175  self.notifyText.alpha = 0;
176 
177  self.notifyText2 = ‪hud::createFontString( font, textSize );
178  self.notifyText2 ‪hud::setParent( self.notifyTitle );
179  self.notifyText2 ‪hud::setPoint( point, relativePoint, 0, 0 );
180  self.notifyText2.glowAlpha = 1;
181  self.notifyText2.hideWhenInMenu = true;
182  self.notifyText2.archived = false;
183  self.notifyText2.alpha = 0;
184 
185  self.notifyIcon = ‪hud::createIcon( "white", iconSize, iconSize );
186  self.notifyIcon ‪hud::setParent( self.notifyText2 );
187  self.notifyIcon ‪hud::setPoint( point, relativePoint, 0, 0 );
188  self.notifyIcon.hideWhenInMenu = true;
189  self.notifyIcon.archived = false;
190  self.notifyIcon.alpha = 0;
191 
192  self.doingNotify = false;
193  self.notifyQueue = [];
194 }
195 
196 function ‪oldNotifyMessage( titleText, notifyText, iconName, glowColor, sound, duration )
197 {
198  if ( level.wagerMatch && !level.teamBased )
199  return;
200 
201  notifyData = spawnstruct();
202 
203  notifyData.titleText = titleText;
204  notifyData.notifyText = notifyText;
205  notifyData.iconName = iconName;
206  notifyData.sound = sound;
207  notifyData.duration = duration;
208 
209  self.startMessageNotifyQueue[ self.startMessageNotifyQueue.size ] = notifyData;
210 
211  self notify( "received award" );
212 }
213 
214 function ‪notifyMessage( notifyData )
215 {
216  self endon ( "death" );
217  self endon ( "disconnect" );
218 
219  if ( !isdefined( self.messageNotifyQueue ) )
220  {
221  self.messageNotifyQueue = [];
222  }
223 
224  self.messageNotifyQueue[ self.messageNotifyQueue.size ] = notifyData;
225 
226  self notify( "received award" );
227 }
228 function ‪playNotifyLoop(duration)
229 {
230  ‪playNotifyLoop = ‪spawn ( "script_origin" , (0, 0, 0));
231  ‪playNotifyLoop PlayLoopSound ( "uin_notify_data_loop" );
232 
233  duration = duration - 4;
234 
235  if (duration < 1)
236  {
237  duration = 1;
238  }
239 
240  wait (duration);
241  ‪playNotifyLoop Delete();
242 }
243 
244 function ‪showNotifyMessage( notifyData, duration )
245 {
246  self endon("disconnect");
247 
248  self.doingNotify = true;
249 
251 
252  self notify ( "notifyMessageBegin", duration );
253 
254  self thread ‪resetOnCancel();
255 
256  if ( isdefined( notifyData.sound ) )
257  {
258  self playLocalSound( notifyData.sound );
259  }
260 // else
261 // {
262 // //self playLocalSound( "uin_notify_data" );
263 // if ( notifyData.loopSound)
264 // {
265 // self thread playNotifyLoop(duration);
266 // }
267 //
268 // }
269 
270  if ( isdefined( notifyData.musicState ) )
271  self music::setmusicstate( notifyData.music );
272 
273  if ( isdefined( notifyData.leaderSound ) )
274  {
275  if( isdefined( level.globallogic_audio_dialog_on_player_override ) )//TODO T7 - remove once globallogic_audio is shared
276  {
277  self [[ level.globallogic_audio_dialog_on_player_override ]]( notifyData.leaderSound );
278  }
279  }
280 
281  if ( isdefined( notifyData.glowColor ) )
282  glowColor = notifyData.glowColor;
283  else
284  glowColor = (0.0, 0.0, 0.0);
285 
286  if ( isdefined( notifyData.color ) )
287  color = notifyData.color;
288  else
289  color = (1.0, 1.0, 1.0);
290 
291  anchorElem = self.notifyTitle;
292 
293  if ( isdefined( notifyData.titleText ) )
294  {
295  if ( isdefined( notifyData.titleLabel ) )
296  self.notifyTitle.label = notifyData.titleLabel;
297  else
298  self.notifyTitle.label = &"";
299 
300  ‪if ( isdefined( notifyData.titleLabel ) && !isdefined( notifyData.titleIsString ) )
301  self.notifyTitle setValue( notifyData.titleText );
302  else
303  self.notifyTitle setText( notifyData.titleText );
304  self.notifyTitle setCOD7DecodeFX( 200, int(duration*1000), 600 );
305  self.notifyTitle.glowColor = glowColor;
306  self.notifyTitle.color = color;
307  self.notifyTitle.alpha = 1;
308  }
309 
310  if ( isdefined( notifyData.notifyText ) )
311  {
312  if ( isdefined( notifyData.textLabel ) )
313  self.notifyText.label = notifyData.textLabel;
314  else
315  self.notifyText.label = &"";
316 
317  if ( isdefined( notifyData.textLabel ) && !isdefined( notifyData.textIsString ) )
318  self.notifyText setValue( notifyData.notifyText );
319  else
320  self.notifyText setText( notifyData.notifyText );
321  self.notifyText setCOD7DecodeFX( 100, int(duration*1000), 600 );
322  self.notifyText.glowColor = glowColor;
323  self.notifyText.color = color;
324  self.notifyText.alpha = 1;
325  anchorElem = self.notifyText;
326  }
327 
328  if ( isdefined( notifyData.notifyText2 ) )
329  {
330  if ( self IsSplitscreen() )
331  {
332  if ( isdefined( notifyData.text2Label ) )
333  self iPrintLnBold( notifyData.text2Label, notifyData.notifyText2 );
334  else
335  self iPrintLnBold( notifyData.notifyText2 );
336  }
337  else
338  {
339  self.notifyText2 ‪hud::setParent( anchorElem );
340 
341  if ( isdefined( notifyData.text2Label ) )
342  self.notifyText2.label = notifyData.text2Label;
343  else
344  self.notifyText2.label = &"";
345 
346  self.notifyText2 setText( notifyData.notifyText2 );
347  self.notifyText2 setPulseFX( 100, int(duration*1000), 1000 );
348  self.notifyText2.glowColor = glowColor;
349  self.notifyText2.color = color;
350  self.notifyText2.alpha = 1;
351  anchorElem = self.notifyText2;
352  }
353  }
354 
355  if ( isdefined( notifyData.iconName ) )
356  {
357  iconWidth= 60;
358  iconHeight= 60;
359 
360  if (isdefined(notifyData.iconWidth))
361  {
362  iconWidth= notifyData.iconWidth;
363  }
364  if (isdefined(notifyData.iconHeight))
365  {
366  iconHeight= notifyData.iconHeight;
367  }
368 
369  self.notifyIcon ‪hud::setParent( anchorElem );
370  self.notifyIcon setShader( notifyData.iconName, iconWidth, iconHeight );
371  self.notifyIcon.alpha = 0;
372  self.notifyIcon fadeOverTime( 1.0 );
373  self.notifyIcon.alpha = 1;
374 
375  ‪waitRequireVisibility( duration );
376 
377  self.notifyIcon fadeOverTime( 0.75 );
378  self.notifyIcon.alpha = 0;
379  }
380  else
381  {
382  ‪waitRequireVisibility( duration );
383  }
384 
385  self notify ( "notifyMessageDone" );
386  self.doingNotify = false;
387 }
388 
389 // waits for waitTime, plus any time required to let flashbangs go away.
390 function ‪waitRequireVisibility( waitTime )
391 {
392  interval = .05;
393 
394  while ( !self ‪canReadText() )
395  wait interval;
396 
397  while ( waitTime > 0 )
398  {
399  wait interval;
400  if ( self ‪canReadText() )
401  waitTime -= interval;
402  }
403 }
404 
405 
406 function ‪canReadText()
407 {
408  if ( self ‪util::is_flashbanged() )
409  return false;
410 
411  return true;
412 }
413 
414 
415 function ‪resetOnDeath()
416 {
417  self endon ( "notifyMessageDone" );
418  self endon ( "disconnect" );
419  level endon ( "game_ended" );
420  self waittill ( "death" );
421 
422  ‪resetNotify();
423 }
424 
425 
427 {
428  self notify ( "resetOnCancel" );
429  self endon ( "resetOnCancel" );
430  self endon ( "notifyMessageDone" );
431  self endon ( "disconnect" );
432 
433  level waittill ( "cancel_notify" );
434 
435  ‪resetNotify();
436 }
437 
438 
439 function ‪resetNotify()
440 {
441  self.notifyTitle.alpha = 0;
442  self.notifyText.alpha = 0;
443  self.notifyText2.alpha = 0;
444  self.notifyIcon.alpha = 0;
445  self.doingNotify = false;
446 }
447 
448 
450 {
451  self endon ( "disconnect" );
452 
453  for ( ;; )
454  {
455  self waittill ( "death" );
456 
457  if ( isdefined( self.‪hintMessage ) )
458  self.hintMessage ‪hud::destroyElem();
459  }
460 }
461 
463 {
464  self endon ( "disconnect" );
465 
466  messageTextY = level.lowerTextY;
467  if ( self IsSplitscreen() )
468  messageTextY = level.lowerTextY - 50;
469 
470  self.lowerMessage = ‪hud::createFontString( "default", level.lowerTextFontSize );
471  self.lowerMessage ‪hud::setPoint( "CENTER", level.lowerTextYAlign, 0, messageTextY );
472  self.lowerMessage setText( "" );
473  self.lowerMessage.archived = false;
474 
475  timerFontSize = 1.5;
476  if ( self IsSplitscreen() )
477  timerFontSize = 1.4;
478 
479  self.lowerTimer = ‪hud::createFontString( "default", timerFontSize );
480  self.lowerTimer ‪hud::setParent( self.lowerMessage );
481  self.lowerTimer ‪hud::setPoint( "TOP", "BOTTOM", 0, 0 );
482  self.lowerTimer setText( "" );
483  self.lowerTimer.archived = false;
484 }
485 
487 {
488  if ( level.cumulativeRoundScores )
489  {
490  self setValue( getTeamScore( team ) );
491  }
492  else
493  {
494  self setValue( ‪util::get_rounds_won( team ) );
495  }
496 }
497 
498 function ‪isInTop( players, topN )
499 {
500  for ( i = 0 ; i < topN; i++ )
501  {
502  if ( isdefined( players[i] ) && ( self == players[i] ) )
503  {
504  return true;
505  }
506  }
507 
508  return false;
509 }
510 
511 function ‪destroyHudElem( hudElem )
512 {
513  if( isdefined( hudElem ) )
514  hudElem ‪hud::destroyElem();
515 }
516 
518 {
519  if ( !isdefined( self.waitingForPlayersText ) )
520  {
521  self.waitingForPlayersText = ‪hud::createFontString( "objective", 2.5 );
522  self.waitingForPlayersText ‪hud::setPoint( "CENTER", "CENTER", 0, -80 );
523  self.waitingForPlayersText.sort = 1001;
524  self.waitingForPlayersText setText( &"MP_WAITING_FOR_PLAYERS_SHOUTCASTER" );
525  self.waitingForPlayersText.foreground = false;
526  self.waitingForPlayersText.hidewheninmenu = true;
527  }
528 }
529 
531 {
532  if ( isdefined( self.waitingForPlayersText ) )
533  {
534  ‪destroyHudElem( self.waitingForPlayersText );
535  self.waitingForPlayersText = undefined;
536  }
537 }
538 
540 {
541  pendingNotifies = true;
542  timeWaited = 0;
543  while( pendingNotifies && timeWaited < 12 )
544  {
545  pendingNotifies = false;
546  players = GetPlayers();
547  for( i = 0; i < players.size; i++ )
548  {
549  if( isdefined( players[i].notifyQueue ) && players[i].notifyQueue.size > 0 )
550  {
551  pendingNotifies = true;
552  }
553  }
554  if( pendingNotifies )
555  wait .2;
556  timeWaited += .2;
557  }
558 }
‪destroyHudElem
‪function destroyHudElem(hudElem)
Definition: hud_message_shared.gsc:511
‪notifyMessage
‪function notifyMessage(notifyData)
Definition: hud_message_shared.gsc:214
‪get_rounds_won
‪function get_rounds_won(team)
Definition: util_shared.gsc:2145
‪on_player_connect
‪function on_player_connect()
Definition: hud_message_shared.gsc:32
‪canReadText
‪function canReadText()
Definition: hud_message_shared.gsc:406
‪isInTop
‪function isInTop(players, topN)
Definition: hud_message_shared.gsc:498
‪on_start_gametype
‪function on_start_gametype(func, obj)
Definition: callbacks_shared.csc:285
‪setPoint
‪function setPoint(point, relativePoint, xOffset, yOffset, moveTime)
Definition: hud_util_shared.gsc:53
‪setShoutcasterWaitingMessage
‪function setShoutcasterWaitingMessage()
Definition: hud_message_shared.gsc:517
‪destroyElem
‪function destroyElem()
Definition: hud_util_shared.gsc:755
‪initNotifyMessage
‪function initNotifyMessage()
Definition: hud_message_shared.gsc:107
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪if
‪if(on_off)
Definition: util_shared.csc:908
‪setParent
‪function setParent(element)
Definition: hud_util_shared.gsc:10
‪on_disconnect
‪function on_disconnect()
Definition: _wager.gsc:88
‪init
‪function init()
Definition: hud_message_shared.gsc:25
‪resetOnDeath
‪function resetOnDeath()
Definition: hud_message_shared.gsc:415
‪clearShoutcasterWaitingMessage
‪function clearShoutcasterWaitingMessage()
Definition: hud_message_shared.gsc:530
‪__init__
‪function __init__()
Definition: hud_message_shared.gsc:20
‪on_player_disconnect
‪function on_player_disconnect()
Definition: hud_message_shared.gsc:41
‪showNotifyMessage
‪function showNotifyMessage(notifyData, duration)
Definition: hud_message_shared.gsc:244
‪createFontString
‪function createFontString(font, fontScale)
Definition: hud_util_shared.gsc:334
‪resetOnCancel
‪function resetOnCancel()
Definition: hud_message_shared.gsc:426
‪hintMessagePlayers
‪function hintMessagePlayers(players, hintText, duration)
Definition: hud_message_shared.gsc:89
‪is_flashbanged
‪function is_flashbanged()
Definition: util_shared.gsc:1983
‪waitTillNotifiesDone
‪function waitTillNotifiesDone()
Definition: hud_message_shared.gsc:539
‪playNotifyLoop
‪function playNotifyLoop(duration)
Definition: hud_message_shared.gsc:228
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪showInitialFactionPopup
‪function showInitialFactionPopup(team)
Definition: hud_message_shared.gsc:101
‪setMatchScoreHUDElemForTeam
‪function setMatchScoreHUDElemForTeam(team)
Definition: hud_message_shared.gsc:486
‪hintMessageDeathThink
‪function hintMessageDeathThink()
Definition: hud_message_shared.gsc:449
‪hintMessage
‪function hintMessage(hintText, duration)
Definition: hud_message_shared.gsc:79
‪oldNotifyMessage
‪function oldNotifyMessage(titleText, notifyText, iconName, glowColor, sound, duration)
Definition: hud_message_shared.gsc:196
‪initCustomGametypeHeader
‪function initCustomGametypeHeader()
Definition: hud_message_shared.gsc:54
‪on_connect
‪function on_connect()
Definition: _arena.gsc:20
‪waitRequireVisibility
‪function waitRequireVisibility(waitTime)
Definition: hud_message_shared.gsc:390
‪createIcon
‪function createIcon(shader, width, height)
Definition: hud_util_shared.gsc:417
‪lowerMessageThink
‪function lowerMessageThink()
Definition: hud_message_shared.gsc:462
‪resetNotify
‪function resetNotify()
Definition: hud_message_shared.gsc:439