DI-Guy C++ SDK Reference  13.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyView.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2014 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************
8  **
9  *t diguyView
10  **
11  *b Link against: libdiguy
12  */
13 
14 #ifndef __diguyView_H
15 #define __diguyView_H
16 
17 #ifdef SWIG
18 %module diguyView
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #ifdef CPLUSPLUS_ONLY
24 
25 class bdiScenarioView;
26 class diguyView;
27 class diguyViewCamera;
28 class diguyViewFog;
29 class diguyViewLight;
30 
31 #include <stdio.h> // for NULL
32 #include <diguy_constants.h>
33 #include <diguy_typedefs.h>
34 
35 
36 #endif /* CPLUSPLUS_ONLY */
37 
38 
39 #include <declspec_diguy.h>
40 
41 /****************************************************************************/
42 class BDI_DECLSPEC_diguy diguyView
43 {
44 
45 public:
46 
47  /*l
48  *b Description:
49  **
50  ** Returns the name of the object. This pointer will
51  ** never be NULL.
52  **
53  *b Returns:
54  **
55  ** name of the view
56  **
57  *b Callable From:
58  **
59  *- - C++
60  *- - Script
61  */
62  const char* get_name();
63 
64  /*l
65  *b Description:
66  **
67  ** Returns the type name of the object. This pointer will
68  ** never be NULL.
69  **
70  *b Returns:
71  **
72  ** type name of the object
73  **
74  *b Callable From:
75  **
76  *- - C++
77  *- - Script
78  */
79  const char* get_type_name();
80 
81  /*l
82  *b Description:
83  **
84  ** Shows the view.
85  **
86  *b Returns:
87  **
88  ** 0 on success, -1 on failure
89  **
90  *b Callable From:
91  **
92  *- - C++
93  *- - Script
94  *- - Decision Bead
95  */
96  int show();
97 
98  /*l
99  *b Description:
100  **
101  ** Hides the view.
102  **
103  *b Returns:
104  **
105  ** 0 on success, -1 on failure
106  **
107  *b Callable From:
108  **
109  *- - C++
110  *- - Script
111  *- - Decision Bead
112  */
113  int hide();
114 
115  /*l
116  *b Returns:
117  **
118  ** Returns 1 if the view is showing, 0 if not.
119  **
120  *b Callable From:
121  **
122  *- - C++
123  *- - Script
124  *- - Decision Bead
125  */
126  int is_showing();
127 
128  /*l
129  *b Description:
130  **
131  ** Returns the window title of the view. This pointer will
132  ** never be NULL.
133  **
134  *b Returns:
135  **
136  ** window title of the view
137  **
138  *b Callable From:
139  **
140  *- - C++
141  *- - Script
142  */
143  const char* get_window_title();
144 
145  /*l
146  *b Description:
147  **
148  ** This function sets the window title of the view.
149  **
150  *b Arguments:
151  **
152  *a window_title - new window title
153  **
154  *b Returns:
155  **
156  ** 0 on success, -1 on failure
157  **
158  *b Callable From:
159  **
160  *- - C++
161  *- - Script
162  */
163  int set_window_title(const char* window_title);
164 
165  /*l
166  *b Description:
167  **
168  ** This function returns a pointer to the view camera.
169  **
170  *b Callable From:
171  **
172  *- - C++
173  *- - Script
174  **
175  *b Returns:
176  **
177  ** pointer of type diguyViewCamera; should never be NULL
178  */
179  diguyViewCamera* get_camera();
180 
181  /*l
182  *b Description:
183  **
184  ** This function returns a pointer to the view fog.
185  **
186  *b Returns:
187  **
188  ** pointer of type diguyViewFog; should never be NULL
189  **
190  *b Callable From:
191  **
192  *- - C++
193  *- - Script
194  */
195  diguyViewFog* get_fog();
196 
197  /*l
198  *b Description:
199  **
200  ** This function returns a pointer to the view lights.
201  **
202  *b Arguments:
203  **
204  *a number - number of light to be found
205  **
206  *b Returns:
207  **
208  ** pointer of type diguyViewLight; can be NULL if light at
209  ** specified index doesn't exist
210  **
211  *b Callable From:
212  **
213  *- - C++
214  *- - Script
215  */
216  diguyViewLight* get_light(int number = 0);
217 
218 
219 /*****************************************************************************/
225  /*l
226  *b Description:
227  **
228  ** Sets the width of the view, in pixels.
229  **
230  *b Arguments:
231  **
232  *a width - new width of view, in pixels
233  **
234  *b Returns:
235  **
236  ** 0 on success, -1 on failure
237  **
238  *b Callable From:
239  **
240  *- - C++
241  *- - Script
242  */
243  int set_width(int width);
244 
245  /*l
246  *b Returns:
247  **
248  ** width in pixels of the view
249  **
250  *b Callable From:
251  **
252  *- - C++
253  *- - Script
254  */
255  int get_width();
256 
257  /*l
258  *b Description:
259  **
260  ** Sets the height of the view, in pixels. Increasing height value
261  ** moves the view window bottom edge lower.
262  **
263  *b Arguments:
264  **
265  *a width - new height of view, in pixels
266  **
267  *b Returns:
268  **
269  ** 0 on success, -1 on failure
270  **
271  *b Callable From:
272  **
273  *- - C++
274  *- - Script
275  */
276  int set_height(int height);
277 
278  /*l
279  *b Returns:
280  **
281  ** height in pixels of the view
282  **
283  *b Callable From:
284  **
285  *- - C++
286  *- - Script
287  */
288  int get_height();
289 
290  /*l
291  *b Description:
292  **
293  ** Sets the current x position of the view window relative to the
294  ** left-hand edge of the screen.
295  **
296  *b Arguments:
297  **
298  *a x - new x coordinate of view
299  **
300  *b Returns:
301  **
302  ** 0 on success, -1 on failure
303  **
304  *b Callable From:
305  **
306  *- - C++
307  *- - Script
308  */
309  int set_x(int x);
310 
311  /*l
312  *b Returns:
313  **
314  ** current x coordinate of the view window; see set_x()
315  **
316  *b Callable From:
317  **
318  *- - C++
319  *- - Script
320  */
321  int get_x();
322 
323  /*l
324  *b Description:
325  **
326  ** Sets the current y position of the view window relative to the
327  ** upper edge of the screen. Increasing y moves the view window
328  ** lower.
329  **
330  *b Arguments:
331  **
332  *a y - new y coordinate of view
333  **
334  *b Returns:
335  **
336  ** 0 on success, -1 on failure
337  **
338  *b Callable From:
339  **
340  *- - C++
341  *- - Script
342  */
343  int set_y(int y);
344 
345  /*l
346  *b Returns:
347  **
348  ** current y coordinate of the view window; see set_y()
349  **
350  *b Callable From:
351  **
352  *- - C++
353  *- - Script
354  */
355  int get_y();
356 
357 
358 /*****************************************************************************/
364  /*l
365  *b Description:
366  **
367  ** This is an enumeration of the different callbacks
368  ** that can be registered with add_callback() and
369  ** add_callback_script().
370  **
371  *b Usable From:
372  **
373  *- - C++
374  *- - Script
375  */
376  enum {
377  CALLBACK_ID_SHOW = 1,
378  CALLBACK_ID_HIDE,
379  CALLBACK_ID_WINDOW_TITLE_CHANGED,
380  CALLBACK_ID_WINDOW_GEOMETRY_CHANGED
381  };
382 
383 #ifdef CPLUSPLUS_ONLY
384 
385  /*l
386  *b Description:
387  **
388  ** This function adds a user callback.
389  **
390  *b Arguments:
391  **
392  *a callback - pointer to function with prototype
393  *a diguyViewCallback (typedefed above)
394  *a callback_id - integer id of when this callback is to be called
395  *a callback_params - not currently used; pass NULL
396  *a callback_user_data - pointer for user's own use; DI-Guy will
397  *a do nothing to the contents of this pointer
398  *a beyond passing it back when the callback is
399  *a invoked
400  **
401  ** callback_id should be one of the following values:
402  **
403  *i CALLBACK_ID_SHOW
404  **
405  ** This callback will be called whenever the view is
406  ** to be shown, whether due to a call to the diguyView::show()
407  ** function above or due to the result of a decision
408  ** or script.
409  **
410  ** There are no parameters for this callback.
411  **
412  *i CALLBACK_ID_HIDE
413  **
414  ** This callback will be called whenever the view is
415  ** to be hidden, whether due to a call to the diguyView::hide()
416  ** function above or due to the result of a decision
417  ** or script.
418  **
419  ** There are no parameters for this callback.
420  **
421  *i CALLBACK_ID_WINDOW_TITLE_CHANGED
422  **
423  ** This callback will be called whenever the view's
424  ** window title has been changed.
425  **
426  ** There are no parameters for this callback.
427  **
428  *i Callback Return Values:
429  **
430  ** Callbacks return a value of type diguyCallbackReturn,
431  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
432  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
433  ** of the function will not be called; the callback is asserting
434  ** that it has done everything necessary for the function call.
435  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
436  ** handler for the function will be called after the callback.
437  **
438  *b Returns:
439  **
440  ** 0 on success, -1 on failure
441  **
442  *b Returns:
443  **
444  ** 0 on success, -1 on failure
445  **
446  *b Callable From:
447  **
448  *- - C++
449  */
450  int add_callback(int callback_id,
451  diguyViewCallback* callback,
452  void* callback_params = 0,
453  void* callback_user_data = 0);
454 
455  /*l
456  *b Description:
457  **
458  ** This function removes a user callback. All callbacks matching
459  ** the specified callback_id and callback function will be removed.
460  **
461  *b Arguments:
462  **
463  *a callback_id - integer id of when this callback is to be called
464  *a callback - pointer to function with prototype
465  *a diguyCharacterCallback (typedefed above)
466  **
467  *b Returns:
468  **
469  ** 0 on success, -1 on failure
470  */
471  int remove_callback(int callback_id,
472  diguyViewCallback* callback);
473 
474  /*l
475  *b Description:
476  **
477  ** This function removes a user callback. All callbacks matching
478  ** the specified callback_id and callback_user_data pointer will
479  ** be removed.
480  **
481  *b Arguments:
482  **
483  *a callback_id - integer id of when this callback is to be called
484  *a callback_user_data - pointer for user's own use
485  **
486  *b Returns:
487  **
488  ** 0 on success, -1 on failure
489  */
490  int remove_callback_with_user_data(int callback_id,
491  void* callback_user_data);
492 
493 #endif /* CPLUSPLUS_ONLY */
494 
495  /*l
496  *b Description:
497  **
498  ** This function adds a user callback script. Callback scripts can
499  ** be removed with remove_callback_script().
500  **
501  ** See diguyCharacter::add_callback_script() for an example
502  ** of use.
503  **
504  *b Arguments:
505  **
506  *a callback_id - integer id of the callback
507  *a callback_script - script text of callback to be added
508  *a callback_script_type - the type of script contained in
509  *a callback_script
510  **
511  ** If NULL is passed for callback_script_type, a default script type
512  ** will be derived based on the default script interpreter of the
513  ** scenario.
514  **
515  *i Lua specific:
516  **
517  ** When the script is called, the object for which it is being called
518  ** will be in the callback_object global.
519  **
520  ** To pass NULL when calling from a lua script, use nil.
521  **
522  *b Returns:
523  **
524  ** 0 on success, -1 on failure
525  **
526  *b Callable From:
527  **
528  *- - C++
529  *- - Script
530  */
531  int add_callback_script(int callback_id,
532  const char* callback_script,
533  const char* callback_script_type = NULL);
534 
535  /*l
536  *b Description:
537  **
538  ** This function removes a user callback script previously added with
539  ** add_callback_script().
540  **
541  ** See diguyCharacter::remove_callback_script() for an example
542  ** of use.
543  **
544  *b Arguments:
545  **
546  *a callback_id - integer id of the callback
547  *a callback_script - script text of callback previously added
548  *a callback_script_type - the type of script contained in
549  *a callback_script
550  **
551  ** If NULL is passed for callback_script, all callback
552  ** scripts whose ids match callback_id and whose types match
553  ** callback_script_type will be removed.
554  **
555  ** If NULL is passed for callback_script_type, a default script type
556  ** will be derived based on the default script interpreter of the
557  ** scenario.
558  **
559  *i Lua specific:
560  **
561  ** To pass NULL when calling from a lua script, use nil.
562  **
563  *b Returns:
564  **
565  ** 0 on success, -1 on failure
566  **
567  *b Callable From:
568  **
569  *- - C++
570  *- - Script
571  */
572  int remove_callback_script(int callback_id,
573  const char* callback_script,
574  const char* callback_script_type = NULL);
575 
576 
582 #ifdef CPLUSPLUS_ONLY
583 
584  bdiScenarioView* get_scripted_object() {return m_scripted_object;}
585 
586 private:
587 
588  /*l
589  ** A private constructor.
590  */
591  diguyView(bdiScenarioView* view);
592 
593  /*l
594  ** A pointer to internal data.
595  */
596  bdiScenarioView* m_scripted_object;
597 
598  friend class bdiScenarioView;
599 
600 #endif /* CPLUSPLUS_ONLY */
601 
602 };
603 
604 #endif /* __diguyView_H */
605