]> icculus.org git repositories - divverent/nexuiz.git/blob - data/menuqc/custom/creategame/mods.qc
rename menu directories
[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         for( lSearchSize = search_getsize( lSearchHandle ), lSearchCounter = 0;
27         lSearchCounter < lSearchSize; ++lSearchCounter ) {
28                 local float     lHandle;
29                 local string    lFilename;
30
31                 local string    lModName;
32                 local string    lModPath;
33                 local string    lLine;
34
35                 lFilename = search_getfilename( lSearchHandle, lSearchCounter );
36                 lHandle = fopen( lFilename, FILE_READ );
37                 if( lHandle < 0 ) {
38                         print( "Menu: Couldn't open modinfo file '", lFilename, "'\n" );
39                         continue;
40                 }
41
42                 lModPath = String_Create();
43                 lModName = String_Create();
44                 while( 1 ) {
45                         lLine = fgets( lHandle );
46                         if( !validstring( lLine ) )
47                                 break;
48
49                         lModPath = String_Set( lModPath, lLine );
50
51                         lLine = fgets( lHandle );
52                         if( !validstring( lLine ) )
53                                 break;
54
55                         lModName = String_Set( lModName, lLine );
56
57                         String_EntitySet( self, valueList, strcat( self.valueList, lModPath, " " ) );
58                         String_EntitySet( self, descList, strcat( self.descList, lModName, " " ) );
59                 }
60                 String_Free( lModPath );
61                 String_Free( lModName );
62
63                 fclose( lHandle );
64         }
65
66         search_end( lSearchHandle );
67 };
68
69 void() Item_DataLink_Nex_ModSwitch_Spawn =
70 {
71         local string lTemp1, lTemp2;
72
73         String_EntityCreate( self, valueList );
74         String_EntityCreate( self, descList );
75
76         _IDLNMS_Build();
77
78         lTemp1 = self.descList;
79         lTemp2 = self.valueList;
80         Item_DataLink_TextSwitch_Spawn();
81         String_Free( lTemp1 );
82         String_Free( lTemp2 );
83 };
84