]> icculus.org git repositories - divverent/nexuiz.git/blob - data/menuqc/custom/creategame/mods.qc
Add a branch to let me work on a new menu undisturbedly.
[divverent/nexuiz.git] / data / menuqc / custom / creategame / mods.qc
1 // Property of Alientrap/AK
2 // custom/creategame/mods.qc
3
4 /*
5 ===================
6 Item_DataLink_Nex_ModSwitch
7 ===================
8 */
9
10 // first line  filename
11 // second line mod name
12 // repeat
13 void() _IDLNMS_Build =
14 {
15         local float     lSearchHandle;
16         local float     lSearchSize;
17         local float     lSearchCounter;
18
19         lSearchHandle = search_begin( "*.modinfo", true, true );
20         if( lSearchHandle < 0 ) {
21                 String_EntitySet( self, valueList, "'progs.dat'" );
22                 String_EntitySet( self, descList, "'Deathmatch'" );
23                 return;
24         }
25
26         lSearchCounter = 0;
27         for( lSearchSize = search_getsize( lSearchHandle );
28         lSearchCounter < lSearchSize; ++lSearchCounter ) {
29                 local float     lHandle;
30                 local string    lFilename;
31
32                 local string    lModName;
33                 local string    lModPath;
34                 local string    lLine;
35
36                 lFilename = search_getfilename( lSearchHandle, lSearchCounter );
37                 lHandle = fopen( lFilename, FILE_READ );
38                 if( lHandle < 0 ) {
39                         print( "Menu: Couldn't open modinfo file '", lFilename, "'\n" );
40                         continue;
41                 }
42
43                 lModPath = String_Create();
44                 lModName = String_Create();
45                 while( 1 ) {
46                         lLine = fgets( lHandle );
47                         if( !validstring( lLine ) )
48                                 break;
49
50                         lModPath = String_Set( lModPath, lLine );
51
52                         lLine = fgets( lHandle );
53                         if( !validstring( lLine ) )
54                                 break;
55
56                         lModName = String_Set( lModName, lLine );
57
58                         String_EntitySet( self, valueList, strcat( self.valueList, lModPath, " " ) );
59                         String_EntitySet( self, descList, strcat( self.descList, lModName, " " ) );
60                 }
61                 String_Free( lModPath );
62                 String_Free( lModName );
63
64                 fclose( lHandle );
65         }
66
67         search_end( lSearchHandle );
68 };
69
70 void() Item_DataLink_Nex_ModSwitch_Spawn =
71 {
72         local string lTemp1, lTemp2;
73
74         String_EntityCreate( self, valueList );
75         String_EntityCreate( self, descList );
76
77         _IDLNMS_Build();
78
79         lTemp1 = self.descList;
80         lTemp2 = self.valueList;
81         Item_DataLink_TextSwitch_Spawn();
82         String_Free( lTemp1 );
83         String_Free( lTemp2 );
84 };
85