‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
scriptbundle_shared.gsc
Go to the documentation of this file.
1 #using scripts\shared\lui_shared;
2 #using scripts\shared\util_shared;
3 
4 #insert scripts\shared\shared.gsh;
5 
6 /* Script Bundles */
7 
8 #namespace scriptbundle;
9 
11 {
12  var ‪_s; // struct that holds gdt data for object
13  var ‪_o_bundle; // reference to parent bundle object
14  var ‪_e; // entity associated with this bundle object
15 
17  {
18  }
19 
21  {
22  }
23 
24  function ‪init( s_objdef, o_bundle, e_ent )
25  {
26  ‪_s = s_objdef;
27  ‪_o_bundle = o_bundle;
28  ‪_e = e_ent;
29  }
30 
31  function ‪log( str_msg )
32  {
33  /# PrintLn( [[ ‪_o_bundle ]] -> ‪get_type() + " " + [[ ‪_o_bundle ]] -> ‪get_name() + ": (" + ‪STR_DEFAULT( ‪_s.name, "no name" ) + ") " + str_msg ); #/
34  }
35 
36  function ‪error( condition, str_msg )
37  {
38  if ( condition )
39  {
40  str_msg = "[ " + [[ ‪_o_bundle ]] -> ‪get_name() + " ] " + ‪STR_DEFAULT( ‪_s.name, "no name" ) + ": " + str_msg;
41 
42  if ( [[‪_o_bundle]]->‪is_testing() )
43  {
45  }
46  else
47  {
48  AssertMsg( str_msg );
49  }
50 
51  thread [[‪_o_bundle]]->on_error();
52  return true;
53  }
54 
55  return false;
56  }
57 
58  function ‪warning( condition, str_msg )
59  {
60  if ( condition )
61  {
62  str_msg = "[ " + [[ ‪_o_bundle ]] -> ‪get_name() + " ] " + ‪STR_DEFAULT( ‪_s.name, "no name" ) + ": " + str_msg;
63 
65 
66  return true;
67  }
68 
69  return false;
70  }
71 
72  function ‪get_ent()
73  {
74  return ‪_e;
75  }
76 }
77 
78 class cScriptBundleBase
79 {
80  var ‪_s; // struct that holds gdt data for bundle
81  var ‪_str_name; // name of bundle
83 
85 
86  function ‪on_error( e ) { } // IMPLEMENT IN DERIVED CLASS
87 
89  {
90  ‪_a_objects = [];
91  ‪_testing = false;
92  }
93 
95  {
96  }
97 
98  function ‪init( str_name, s, b_testing )
99  {
100  ‪_s = s;
101  ‪_str_name = str_name;
102  ‪_testing = b_testing;
103  }
104 
105  function ‪get_type()
106  {
107  return ‪_s.type;
108  }
109 
110  function ‪get_name()
111  {
112  return ‪_str_name;
113  }
114 
115  function ‪get_vm()
116  {
117  return ‪_s.vmtype;
118  }
119 
120  function ‪get_objects()
121  {
122  return ‪_s.objects;
123  }
124 
125  function ‪is_testing()
126  {
127  return ‪_testing;
128  }
129 
130  function ‪add_object( o_object )
131  {
132  ‪ARRAY_ADD( ‪_a_objects, o_object );
133  }
134 
135  function ‪remove_object( o_object )
136  {
137  ArrayRemoveValue( ‪_a_objects, o_object );
138  }
139 
140  function ‪log( str_msg )
141  {
142  /# PrintLn( ‪_s.type + " " + ‪_str_name + ": " + str_msg ); #/
143  }
144 
145  function ‪error( condition, str_msg )
146  {
147  if ( condition )
148  {
149  if ( ‪_testing )
150  {
152  }
153  else
154  {
155  AssertMsg( ‪_s.type + " " + ‪_str_name + ": " + str_msg );
156  }
157 
158  thread [[self]]->on_error();
159  return true;
160  }
161 
162  return false;
163  }
164 
165  function ‪warning( condition, str_msg )
166  {
167  if ( condition )
168  {
169  if ( ‪_testing )
170  {
171  ‪scriptbundle::warning_on_screen( "[ " + ‪_str_name + " ]: " + str_msg );
172  }
173 
174  return true;
175  }
176 
177  return false;
178  }
179 }
180 
181 function ‪error_on_screen( str_msg )
182 {
183  if ( str_msg != "" )
184  {
185  if ( !isdefined( level.scene_error_hud ) )
186  {
187  level.scene_error_hud = level.players[0] OpenLUIMenu( "HudElementText" );
188  level.players[0] SetLuiMenuData( level.scene_error_hud, "alignment", ‪LUI_HUDELEM_ALIGNMENT_CENTER );
189  level.players[0] SetLuiMenuData( level.scene_error_hud, "x", 0 );
190  level.players[0] SetLuiMenuData( level.scene_error_hud, "y", 10 );
191  level.players[0] SetLuiMenuData( level.scene_error_hud, "width", ‪SCREEN_WIDTH );
192  level.players[0] ‪lui::set_color( level.scene_error_hud, ‪RED );
193  }
194 
195  level.players[0] SetLuiMenuData( level.scene_error_hud, "text", str_msg );
196  self thread ‪_destroy_error_on_screen();
197  }
198 }
199 
201 {
202  level notify( "_destroy_error_on_screen" );
203  level endon( "_destroy_error_on_screen" );
204 
205  self ‪util::waittill_notify_or_timeout( "stopped", 5 );
206 
207  level.players[0] CloseLuiMenu( level.scene_error_hud );
208  level.scene_error_hud = undefined;
209 }
210 
211 function ‪warning_on_screen( str_msg )
212 {
213 }
214 
216 {
217  level notify( "_destroy_warning_on_screen" );
218  level endon( "_destroy_warning_on_screen" );
219 
220  self ‪util::waittill_notify_or_timeout( "stopped", 10 );
221 
222  level.players[0] CloseLuiMenu( level.scene_warning_hud );
223  level.scene_warning_hud = undefined;
224 }
‪get_objects
‪function get_objects()
Definition: scriptbundle_shared.gsc:120
‪warning_on_screen
‪function warning_on_screen(str_msg)
Definition: scriptbundle_shared.gsc:211
‪cScriptBundleObjectBase
Definition: scriptbundle_shared.csc:7
‪warning
‪function warning(condition, str_msg)
Definition: scriptbundle_shared.gsc:165
‪LUI_HUDELEM_ALIGNMENT_CENTER
‪#define LUI_HUDELEM_ALIGNMENT_CENTER
Definition: shared.gsh:152
‪SCREEN_WIDTH
‪#define SCREEN_WIDTH
Definition: shared.gsh:200
‪error
‪function error(condition, str_msg)
Definition: scriptbundle_shared.gsc:145
‪cScriptBundleObjectBase::_e
‪var _e
Definition: scriptbundle_shared.gsc:14
‪is_testing
‪function is_testing()
Definition: scriptbundle_shared.gsc:125
‪cScriptBundleObjectBase::warning
‪function warning(condition, str_msg)
Definition: scriptbundle_shared.gsc:58
‪_testing
‪var _testing
Definition: scriptbundle_shared.gsc:84
‪cScriptBundleObjectBase::_s
‪var _s
Definition: scriptbundle_shared.csc:9
‪get_vm
‪function get_vm()
Definition: scriptbundle_shared.gsc:115
‪cScriptBundleObjectBase::constructor
‪constructor()
Definition: scriptbundle_shared.gsc:16
‪RED
‪#define RED
Definition: shared.gsh:175
‪log
‪function log(str_msg)
Definition: scriptbundle_shared.gsc:140
‪set_color
‪function set_color(menu, color)
Definition: lui_shared.csc:537
‪add_object
‪function add_object(o_object)
Definition: scriptbundle_shared.gsc:130
‪get_name
‪function get_name()
Definition: scriptbundle_shared.gsc:110
‪cScriptBundleObjectBase::_o_bundle
‪var _o_bundle
Definition: scriptbundle_shared.csc:10
‪cScriptBundleObjectBase::log
‪function log(str_msg)
Definition: scriptbundle_shared.gsc:31
‪waittill_notify_or_timeout
‪function waittill_notify_or_timeout(msg, timer)
Definition: util_shared.csc:473
‪cScriptBundleObjectBase::init
‪function init(s_objdef, o_bundle, e_ent)
Definition: scriptbundle_shared.gsc:24
‪ARRAY_ADD
‪#define ARRAY_ADD(__array, __item)
Definition: shared.gsh:304
‪_s
‪class cScriptBundleObjectBase _s
‪cScriptBundleObjectBase::error
‪function error(condition, str_msg)
Definition: scriptbundle_shared.gsc:36
‪_str_name
‪var _str_name
Definition: scriptbundle_shared.gsc:81
‪on_error
‪function on_error(e)
Definition: scriptbundle_shared.gsc:86
‪cScriptBundleObjectBase::destructor
‪destructor()
Definition: scriptbundle_shared.gsc:20
‪constructor
‪constructor()
Definition: scriptbundle_shared.gsc:88
‪cScriptBundleObjectBase::get_ent
‪function get_ent()
Definition: scriptbundle_shared.gsc:72
‪_destroy_warning_on_screen
‪function _destroy_warning_on_screen()
Definition: scriptbundle_shared.gsc:215
‪destructor
‪destructor()
Definition: scriptbundle_shared.gsc:94
‪error_on_screen
‪function error_on_screen(str_msg)
Definition: scriptbundle_shared.gsc:181
‪STR_DEFAULT
‪#define STR_DEFAULT(__var, __def)
Definition: shared.gsh:298
‪get_type
‪function get_type()
Definition: scriptbundle_shared.gsc:105
‪init
‪function init(str_name, s, b_testing)
Definition: scriptbundle_shared.gsc:98
‪_a_objects
‪var _a_objects
Definition: scriptbundle_shared.gsc:82
‪remove_object
‪function remove_object(o_object)
Definition: scriptbundle_shared.gsc:135
‪_destroy_error_on_screen
‪function _destroy_error_on_screen()
Definition: scriptbundle_shared.gsc:200