]> icculus.org git repositories - divverent/nexuiz.git/blob - data/source/custom/messagebox.qc
give menu source its own directory
[divverent/nexuiz.git] / data / source / 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
25         lItem = Menu_GetItem( "MessageBoxWnd::Layout::Buttons::Right" );
26         String_EntitySet( lItem, normal, pRightButton );
27         lItem.size = '0 0 0';
28         if( strlen( pRightButton ) == 0 ) {
29                 lItem.flag = lItem.flag | FLAG_HIDDEN;
30         } else if( lItem.flag & FLAG_HIDDEN ) {
31                 lItem.flag = lItem.flag - FLAG_HIDDEN;
32         }
33
34         Nex_MessageBox_LeftEvent = pLeftEvent;
35         Nex_MessageBox_RightEvent = pRightEvent;
36
37         lItem = Menu_GetItem( "MessageBoxWnd" );
38         if( lItem.flag & FLAG_HIDDEN )
39                 lItem.flag = lItem.flag - FLAG_HIDDEN;
40
41         Menu_Select( Menu_GetItem( "MessageBoxWnd::Layout::Buttons::Right" ), false );
42 };
43
44 void() Nex_MessageBox_Hide =
45 {
46         local entity lEntity;
47
48         lEntity = Menu_GetItem( "MessageBoxWnd" );
49         if( !(lEntity.flag & FLAG_HIDDEN) ) {
50                 lEntity.flag = lEntity.flag + FLAG_HIDDEN;
51                 Menu_Reselect( false );
52         }
53 }
54
55 void() Nex_MessageBox_LeftButton =
56 {
57         if( Nex_MessageBox_LeftEvent ) {
58                 Nex_MessageBox_LeftEvent();
59         }
60         Nex_MessageBox_Hide();
61 };
62
63 void() Nex_MessageBox_RightButton =
64 {
65         if( Nex_MessageBox_RightEvent ) {
66                 Nex_MessageBox_RightEvent();
67         }
68         Nex_MessageBox_Hide();
69 };
70
71 bool( float pKey, float pAscii ) Nex_MessageBox_Key =
72 {
73         if( pKey == K_ESCAPE ) {
74                 // escape == right button!
75                 Nex_MessageBox_RightButton();
76                 return true;
77         }
78         return false;
79 };