‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
hud_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\lui_shared;
5 #using scripts\shared\system_shared;
6 
7 #insert scripts\shared\shared.gsh;
8 
9 #namespace hud;
10 
11 ‪REGISTER_SYSTEM( "hud", &‪__init__, undefined )
12 
13 /*
14 
15 // Edge relative placement values for rect->h_align and rect->v_align
16 #define HORIZONTAL_ALIGN_SUBLEFT 0 // left edge of a 4:3 screen (safe area not included)
17 #define HORIZONTAL_ALIGN_LEFT 1 // left viewable (safe area) edge
18 #define HORIZONTAL_ALIGN_CENTER 2 // center of the screen (reticle)
19 #define HORIZONTAL_ALIGN_RIGHT 3 // right viewable (safe area) edge
20 #define HORIZONTAL_ALIGN_FULLSCREEN 4 // disregards safe area
21 #define HORIZONTAL_ALIGN_NOSCALE 5 // uses exact parameters - neither adjusts for safe area nor scales for screen size
22 #define HORIZONTAL_ALIGN_TO640 6 // scales a real-screen resolution x down into the 0 - 640 range
23 #define HORIZONTAL_ALIGN_CENTER_SAFEAREA 7 // center of the safearea
24 #define HORIZONTAL_ALIGN_MAX HORIZONTAL_ALIGN_CENTER_SAFEAREA
25 #define HORIZONTAL_ALIGN_DEFAULT HORIZONTAL_ALIGN_SUBLEFT
26 
27 #define VERTICAL_ALIGN_SUBTOP 0 // top edge of the 4:3 screen (safe area not included)
28 #define VERTICAL_ALIGN_TOP 1 // top viewable (safe area) edge
29 #define VERTICAL_ALIGN_CENTER 2 // center of the screen (reticle)
30 #define VERTICAL_ALIGN_BOTTOM 3 // bottom viewable (safe area) edge
31 #define VERTICAL_ALIGN_FULLSCREEN 4 // disregards safe area
32 #define VERTICAL_ALIGN_NOSCALE 5 // uses exact parameters - neither adjusts for safe area nor scales for screen size
33 #define VERTICAL_ALIGN_TO480 6 // scales a real-screen resolution y down into the 0 - 480 range
34 #define VERTICAL_ALIGN_CENTER_SAFEAREA 7 // center of the save area
35 #define VERTICAL_ALIGN_MAX VERTICAL_ALIGN_CENTER_SAFEAREA
36 #define VERTICAL_ALIGN_DEFAULT VERTICAL_ALIGN_SUBTOP
37 
38 static const char *g_he_font[] =
39 {
40  "default", // HE_FONT_DEFAULT
41  "bigfixed", // HE_FONT_BIGFIXED
42  "smallfixed", // HE_FONT_SMALLFIXED
43  "objective", // HE_FONT_OBJECTIVE
44 };
45 
46 
47 // These values correspond to the defines in q_shared.h
48 static const char *g_he_alignx[] =
49 {
50  "left", // HE_ALIGN_LEFT
51  "center", // HE_ALIGN_CENTER
52  "right", // HE_ALIGN_RIGHT
53 };
54 
55 
56 static const char *g_he_aligny[] =
57 {
58  "top", // HE_ALIGN_TOP
59  "middle", // HE_ALIGN_MIDDLE
60  "bottom", // HE_ALIGN_BOTTOM
61 };
62 
63 
64 // These values correspond to the defines in menudefinition.h
65 static const char *g_he_horzalign[] =
66 {
67  "subleft", // HORIZONTAL_ALIGN_SUBLEFT
68  "left", // HORIZONTAL_ALIGN_LEFT
69  "center", // HORIZONTAL_ALIGN_CENTER
70  "right", // HORIZONTAL_ALIGN_RIGHT
71  "fullscreen", // HORIZONTAL_ALIGN_FULLSCREEN
72  "noscale", // HORIZONTAL_ALIGN_NOSCALE
73  "alignto640", // HORIZONTAL_ALIGN_TO640
74  "center_safearea", // HORIZONTAL_ALIGN_CENTER_SAFEAREA
75 };
76 function cassert( ARRAY_COUNT( g_he_horzalign ) == HORIZONTAL_ALIGN_MAX + 1 );
77 
78 
79 static const char *g_he_vertalign[] =
80 {
81  "subtop", // VERTICAL_ALIGN_SUBTOP
82  "top", // VERTICAL_ALIGN_TOP
83  "middle", // VERTICAL_ALIGN_CENTER
84  "bottom", // VERTICAL_ALIGN_BOTTOM
85  "fullscreen", // VERTICAL_ALIGN_FULLSCREEN
86  "noscale", // VERTICAL_ALIGN_NOSCALE
87  "alignto480", // VERTICAL_ALIGN_TO480
88  "center_safearea", // VERTICAL_ALIGN_CENTER_SAFEAREA
89 };
90 function cassert( ARRAY_COUNT( g_he_vertalign ) == VERTICAL_ALIGN_MAX + 1 );
91 */
92 
93 #precache( "material", "progress_bar_bg" );
94 #precache( "material", "progress_bar_fg" );
95 #precache( "material", "progress_bar_fill" );
96 #precache( "material", "score_bar_bg" );
97 
98 function ‪__init__()
99 {
101 }
102 
103 function ‪init()
104 {
105  level.uiParent = spawnstruct();
106  level.uiParent.horzAlign = "left";
107  level.uiParent.vertAlign = "top";
108  level.uiParent.alignX = "left";
109  level.uiParent.alignY = "top";
110  level.uiParent.x = 0;
111  level.uiParent.y = 0;
112  level.uiParent.width = 0;
113  level.uiParent.height = 0;
114  level.uiParent.children = [];
115 
116  level.fontHeight = 12;
117 
118  foreach( team in level.teams )
119  {
120  level.hud[team] = spawnstruct();
121  }
122 
123  // we can, of course, separate out the following constants for splitscreen.
124  // primary progress bars are for things like capturing flags or planting bombs - big, important things that happen as you play a gametype
125  level.primaryProgressBarY = -61; // from center
126  level.primaryProgressBarX = 0;
127  level.primaryProgressBarHeight = 9; //28; // this is the height and width of the whole progress bar, including the outline. the part that actually moves is 2 pixels smaller.
128  level.primaryProgressBarWidth = 120;
129  level.primaryProgressBarTextY = -75;
130  level.primaryProgressBarTextX = 0;
131  level.primaryProgressBarFontSize = 1.4;
132 
133  if ( level.splitscreen )
134  {
135  // (x offset avoids overlapping radar on top left screen)
136  level.primaryProgressBarX = 20;
137  level.primaryProgressBarTextX = 20;
138 
139  level.primaryProgressBarY = 15;
140  level.primaryProgressBarTextY = 0;
141  level.primaryProgressBarHeight = 2;
142  }
143 
144  // supplydrop
145  level.secondaryProgressBarY = -85; // from center
146  level.secondaryProgressBarX = 0;
147  level.secondaryProgressBarHeight = 9; //28; // this is the height and width of the whole progress bar, including the outline. the part that actually moves is 2 pixels smaller.
148  level.secondaryProgressBarWidth = 120;
149  level.secondaryProgressBarTextY = -100;
150  level.secondaryProgressBarTextX = 0;
151  level.secondaryProgressBarFontSize = 1.4;
152 
153  if ( level.splitscreen )
154  {
155  // (x offset avoids overlapping radar on top left screen)
156  level.secondaryProgressBarX = 20;
157  level.secondaryProgressBarTextX = 20;
158 
159  level.secondaryProgressBarY = 15;
160  level.secondaryProgressBarTextY = 0;
161  level.secondaryProgressBarHeight = 2;
162  }
163 
164  level.teamProgressBarY = 32; // 205;
165  level.teamProgressBarHeight = 14;
166  level.teamProgressBarWidth = 192;
167  level.teamProgressBarTextY = 8; // 155;
168  level.teamProgressBarFontSize = 1.65;
169 
170  SetDvar( "ui_generic_status_bar", 0 );
171 
172  if ( level.splitscreen )
173  {
174  level.lowerTextYAlign = "BOTTOM";
175  level.lowerTextY = -42;
176  level.lowerTextFontSize = 1.4;
177  }
178  else
179  {
180  level.lowerTextYAlign = "CENTER";
181  level.lowerTextY = 40;
182  level.lowerTextFontSize = 1.4;
183  }
184 }
185 
186 
188 {
189  self.baseFontScale = self.fontScale;
190  self.maxFontScale = self.fontScale * 2;
191  self.inFrames = 1.5;
192  self.outFrames = 3;
193 }
194 
195 
196 function ‪font_pulse(player)
197 {
198  self notify ( "fontPulse" );
199  self endon ( "fontPulse" );
200  self endon( "death" );
201 
202  player endon("disconnect");
203  player endon("joined_team");
204  player endon("joined_spectators");
205 
206  /*scaleRange = self.maxFontScale - self.baseFontScale;
207 
208  while ( self.fontScale < self.maxFontScale )
209  {
210  self.fontScale = min( self.maxFontScale, self.fontScale + (scaleRange / self.inFrames) );
211  WAIT_SERVER_FRAME;
212  }
213 
214  while ( self.fontScale > self.baseFontScale )
215  {
216  self.fontScale = max( self.baseFontScale, self.fontScale - (scaleRange / self.outFrames) );
217  WAIT_SERVER_FRAME;
218  }*/
219 
220  if ( self.outFrames == 0 )
221  {
222  self.fontScale = 0.01;
223  }
224  else
225  {
226  self.fontScale = self.fontScale;
227  }
228 
229  if ( self.inFrames > 0 )
230  {
231  self ChangeFontScaleOverTime( self.inFrames * 0.05 );
232  self.fontScale = self.maxFontScale;
233  wait self.inFrames * 0.05;
234  }
235  else
236  {
237  self.fontScale = self.maxFontScale;
238  self.alpha = 0;
239  self FadeOverTime( self.outFrames * 0.05 );
240  self.alpha = 1;
241  }
242 
243  if ( self.outFrames > 0 )
244  {
245  self ChangeFontScaleOverTime( self.outFrames * 0.05 );
246  self.fontScale = self.baseFontScale;
247  }
248 }
249 
250 function ‪fade_to_black_for_x_sec( startwait, blackscreenwait, fadeintime, fadeouttime, shaderName )
251 {
252  // self endon( "death" ); // do not set an end on death as this will affect fading and may get stuck with a black screen
253  self endon( "disconnect" );
254 
255  wait startwait;
256 
257  ‪lui::screen_fade_out( fadeintime, shaderName );
258 
259  wait blackscreenwait;
260 
261  ‪lui::screen_fade_in( fadeouttime, shaderName );
262 }
263 
264 function ‪screen_fade_in( fadeintime )
265 {
266  ‪lui::screen_fade_in( fadeintime );
267 }
‪on_start_gametype
‪function on_start_gametype(func, obj)
Definition: callbacks_shared.csc:285
‪screen_fade_in
‪function screen_fade_in(fadeintime)
Definition: hud_shared.gsc:264
‪font_pulse_init
‪function font_pulse_init()
Definition: hud_shared.gsc:187
‪__init__
‪function __init__()
Definition: hud_shared.gsc:98
‪font_pulse
‪function font_pulse(player)
Definition: hud_shared.gsc:196
‪fade_to_black_for_x_sec
‪function fade_to_black_for_x_sec(startwait, blackscreenwait, fadeintime, fadeouttime, shaderName)
Definition: hud_shared.gsc:250
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪screen_fade_out
‪function screen_fade_out(n_time, str_color)
Definition: lui_shared.csc:396
‪init
‪function init()
Definition: hud_shared.gsc:103