]> icculus.org git repositories - divverent/nexuiz.git/blob - scmenu/source/custom/creategame/filelist.qc
-Added a management window to creategame, which allows you to save and load
[divverent/nexuiz.git] / scmenu / source / custom / creategame / filelist.qc
1 // Property of Alientrap/AK
2 // custom/creategame/filelist.qc
3
4 //Item_DataLink_Nex_FileList [Item_DataLink_Switch]
5
6 /*
7 ===================
8 IDLNFL_Sync
9 ===================
10 */
11 void() IDLNFL_Sync = {
12         local float lCount;
13         local float lHandle;
14         local float lMaskStart, lMaskedLength;
15         local float lCounter;
16
17         lHandle = search_begin( strcat( self.selected, "/*.", self.normal ), true, true );
18         if( lHandle < 0 ) {
19                 return;
20         }
21         lCount = search_getsize( lHandle );
22
23         String_EntitySet( self, valueList, "" );
24         String_EntitySet( self, descList, "" );
25
26         lMaskStart = strlen( self.selected ) + 1;
27         lMaskedLength = lMaskStart + strlen( self.normal) + 1;
28         for( lCounter = 0 ; lCounter < lCount ; lCounter++ ) {
29                 local string lFilename;
30
31                 lFilename = search_getfilename( lHandle, lCounter );
32                 self.valueList = Util_AltStringPushBack( self.valueList, lFilename );
33                 self.descList = Util_AltStringPushBack( self.descList, substring( lFilename, lMaskStart, strlen( lFilename ) - lMaskedLength ) );
34         }
35
36         self.minValue = 0.0;
37         if( lCount > 0 ) {
38                 self.stepValue = 1.0;
39                 self.maxValue = lCount - 1;
40         } else {
41                 self.stepValue = 0.0;
42                 self.maxValue = 0.0;
43         }
44 };
45
46 /*
47 ===================
48 Item_DataLink_Nex_FileList_Destroy
49 ===================
50 */
51 void() Item_DataLink_Nex_FileList_Destroy =
52 {
53         String_EntityFree( self, valueList );
54         String_EntityFree( self, normal );
55         String_EntityFree( self, selected );
56
57         Item_DataLink_Switch_Destroy();
58 };
59
60 /*
61 ===================
62 Item_DataLink_Nex_FileList_DataEvent
63 ===================
64 */
65 void( float pEvent ) Item_DataLink_Nex_FileList_DataEvent =
66 {
67         switch( pEvent ) {
68                 case ITEM_DATA_SYNC:
69                         IDLNFL_Sync();
70                         break;
71                 case ITEM_DATA_RESET:
72                         IDLNFL_Sync();
73                         self._realValue = 0.0;
74                         break;
75                 case ITEM_DATALINK_SET:
76                         Item_DataLink_Value_Clamp();
77                         break;
78                 case ITEM_DATALINK_GET:
79                         String_EntitySet( self, value, String_Normal( Util_GetAltStringItem( self.descList, self._realValue ) ) );
80                         break;
81         }
82 };
83
84 /*
85 ===================
86 Item_DataLink_Nex_FileList_Spawn
87 ===================
88 */
89 void() Item_DataLink_Nex_FileList_Spawn =
90 {
91         Item_DataLink_Switch_Init();
92
93         String_EntityCreate( self, valueList );
94         String_EntityZone( self, normal );
95         String_EntityZone( self, selected );
96
97         self._reinit = IDLNFL_Sync;
98         self._destroy = Item_DataLink_Nex_FileList_Destroy;
99         self._dataEvent = Item_DataLink_Nex_FileList_DataEvent;
100 };