]> icculus.org git repositories - btb/d2x.git/blob - ui/keytrap.c
add level component saving functions which use PhysicsFS (didn't commit properly...
[btb/d2x.git] / ui / keytrap.c
1 /* $Id: keytrap.c,v 1.3 2005-01-24 22:19:10 schaffner Exp $ */
2
3 #ifdef HAVE_CONFIG_H
4 #include "conf.h"
5 #endif
6
7 #include <stdlib.h>
8 #include <string.h>
9
10 #include "fix.h"
11 #include "pstypes.h"
12 #include "gr.h"
13 #include "ui.h"
14 #include "key.h"
15
16
17 UI_GADGET_KEYTRAP * ui_add_gadget_keytrap( UI_WINDOW * wnd, int key_to_trap, int (*function_to_call)(void)  )
18 {
19         UI_GADGET_KEYTRAP * keytrap;
20
21         keytrap = (UI_GADGET_KEYTRAP *)ui_gadget_add( wnd, 8, 0, 0, 0, 0 );
22         keytrap->parent = (UI_GADGET *)keytrap;
23
24         keytrap->trap_key = key_to_trap;
25         keytrap->user_function = function_to_call;
26
27         return keytrap;
28
29 }
30
31 void ui_keytrap_do( UI_GADGET_KEYTRAP * keytrap, int keypress )
32 {
33         int result;
34
35         if ( keypress == keytrap->trap_key )
36         {
37                 result = keytrap->user_function();
38         }
39 }