]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/custom/messagebox.qc
I did not want to do that. Sorry, disk space. Some admin better get rid of that mess.
[divverent/nexuiz.git] / data / qcsrc / menu / custom / messagebox.qc
1 // Property of Alientrap/AK
2 // custom/messagebox.qc
3
4 var event Nex_MessageBox_LeftEvent = __NULL__;
5 var event Nex_MessageBox_RightEvent = __NULL__;
6
7 void( string pTitle, string pText, string pLeftButton, string pRightButton, event pLeftEvent, event pRightEvent )
8 Nex_MessageBox =
9 {
10         local entity lItem;
11
12         lItem = Menu_GetItem( "MessageBoxWnd::Layout::Title::Caption" );
13         String_EntitySet( lItem, normal, pTitle );
14         // reset its size since this one has to be centered and AlignCenter takes care of everything
15         //lItem.size = '0 0 0';
16
17         lItem = Menu_GetItem( "MessageBoxWnd::Layout::Text" );
18         String_EntitySet( lItem, text, pText );
19         lItem.size = '0 0 0';
20
21         lItem = Menu_GetItem( "MessageBoxWnd::Layout::Buttons::Left" );
22         String_EntitySet( lItem, normal, pLeftButton );
23         lItem.size = '0 0 0';
24         // select the left button since it has to be available
25         Menu_Select( lItem, false );
26
27         lItem = Menu_GetItem( "MessageBoxWnd::Layout::Buttons::Right" );
28         String_EntitySet( lItem, normal, pRightButton );
29         lItem.size = '0 0 0';
30         if( strlen( pRightButton ) != 0 ) {
31                 // select the right button since we prefer it (standard scheme is Yes No or Ok Cancel)
32                 Menu_Select( lItem, false );
33
34                 if( lItem.flag & FLAG_HIDDEN ) {
35                         lItem.flag = lItem.flag - FLAG_HIDDEN;
36                 }
37         } else {
38                 lItem.flag = lItem.flag | FLAG_HIDDEN;
39         }
40
41         Nex_MessageBox_LeftEvent = pLeftEvent;
42         Nex_MessageBox_RightEvent = pRightEvent;
43
44         lItem = Menu_GetItem( "MessageBoxWnd" );
45         if( lItem.flag & FLAG_HIDDEN ) {
46                 lItem.flag = lItem.flag - FLAG_HIDDEN;
47         }
48 };
49
50 void() Nex_MessageBox_Hide =
51 {
52         local entity lEntity;
53
54         lEntity = Menu_GetItem( "MessageBoxWnd" );
55         if( !(lEntity.flag & FLAG_HIDDEN) ) {
56                 lEntity.flag = lEntity.flag + FLAG_HIDDEN;
57                 Menu_Reselect( false );
58         }
59 }
60
61 void() Nex_MessageBox_LeftButton =
62 {
63         if( Nex_MessageBox_LeftEvent ) {
64                 Nex_MessageBox_LeftEvent();
65         }
66         Nex_MessageBox_Hide();
67 };
68
69 void() Nex_MessageBox_RightButton =
70 {
71         if( Nex_MessageBox_RightEvent ) {
72                 Nex_MessageBox_RightEvent();
73         }
74         Nex_MessageBox_Hide();
75 };
76
77 bool( float pKey, float pAscii ) Nex_MessageBox_Key =
78 {
79         if( pKey == K_ESCAPE ) {
80                 // escape == right button!
81                 Nex_MessageBox_RightButton();
82                 return true;
83         }
84         return false;
85 };