1 // Property of Alientrap
2 // custom/creategame.qm
4 // uses target and _target
5 // requires neighbors: Picture, Name, Description
6 void() Nex_MapSelector_UpdateMap =
10 local entity lSelector;
13 lSelector = Menu_GetItem( "::Data::Server::Map::Selector" );
14 Raise_DataEvent( lSelector, ITEM_DATALINK_GET );
15 lIndex = lSelector._realValue;
16 lInfo = Nex_MapDB_GetByIndex( lIndex );
18 if( lInfo == null_entity ) {
19 lItem = Menu_GetItem( "Picture" );
20 String_EntitySet( lItem, picture, "gfx/m_nomap" );
22 lItem = Menu_GetItem( "Name" );
23 String_EntitySet( lItem, text, "No maps found" );
25 lItem = Menu_GetItem( "Description" );
26 String_EntitySet( lItem, text, "---" );
30 // If there is a new selected map, the info panel is updated accordingly
31 if( lIndex != self.minValue ) {
32 self.minValue = lIndex;
34 lItem = Menu_GetItem( "Picture" );
35 String_EntitySet( lItem, picture, lInfo.picture );
37 lItem = Menu_GetItem( "Name" );
38 String_EntitySet( lItem, text, lInfo.normal );
40 lItem = Menu_GetItem( "Description" );
41 String_EntitySet( lItem, text, lInfo.text );
44 lItem = Menu_GetItem( "::Data::Server::Map::Cycle" );
45 DataLink_Nex_MapList_SetFirst( lItem, lInfo.normal, lInfo.link );
48 void() Nex_MapSelector_Synchronize =
51 local entity lSelector;
53 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
54 lSelector = Menu_GetItem( "::Data::Server::Map::Selector" );
56 if( lCycle.stepValue == 0.0 ) {
57 Raise_DataEvent( lCycle, ITEM_DATA_RESET );
60 local entity lMapInfo;
62 lPath = Util_GetAltStringItem( lCycle.valueList, 0 );
63 lMapInfo = Nex_MapDB_GetByPath( lPath );
66 if( lMapInfo == null_entity ) {
67 Raise_DataEvent( lCycle, ITEM_DATA_RESET );
69 lSelector._realValue = Nex_MapDB_GetIndex( lMapInfo );
70 Raise_DataEvent( lSelector, ITEM_DATALINK_SET );
75 // more concrete functions
76 void() Nex_Action_MapSelector_Next =
80 lItem = Menu_GetItem( "::Data::Server::Map::Selector" );
81 Raise_DataEvent( lItem, ITEM_DATALINK_GET );
82 lItem._realValue = lItem._realValue + 1;
83 Raise_DataEvent( lItem, ITEM_DATALINK_SET );
86 void() Nex_Action_MapSelector_Prev =
90 lItem = Menu_GetItem( "::Data::Server::Map::Selector" );
91 Raise_DataEvent( lItem, ITEM_DATALINK_GET );
92 lItem._realValue = lItem._realValue - 1;
93 Raise_DataEvent( lItem, ITEM_DATALINK_SET );
96 // TODO: Make MaxPlayers real Data items (no container with correct set behavior)
97 void() Nex_Action_Map_Start =
100 local string exit_cfg;
103 lItem = Menu_GetItem( "::Data::Server::MaxPlayers" );
104 cmd( "maxplayers \"" );
108 lItem = Menu_GetItem( "::Data::Server::Map::Cycle" );
110 // if an old exit cfg file was set up, exec it
111 // to reset old values before starting the server
112 exit_cfg = cvar_string("exit_cfg");
119 // exec the game reset cfg and then the mapcfg
120 cmd( "exec game_reset.cfg \nwait \nexec \"maps/" );
121 cmd( String_Normal( Util_GetAltStringItem( lItem.valueList, 0 ) ) );
124 Raise_DataEvent( lItem, ITEM_DATA_SEND );
126 // force the menu to hide
130 // cycle list edit features
131 void() Nex_Action_Cycle_Add =
138 lList = Menu_GetItem( "::Data::Server::Map::List" );
139 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
141 lName = DataLink_Nex_MapList_GetCurrentName( lList );
142 lPath = DataLink_Nex_MapList_GetCurrentPath( lList );
144 if( lCycle.stepValue == 1.0 ) {
145 DataLink_Nex_MapList_InsertEntryAfter( lCycle, lName, lPath );
147 DataLink_Nex_MapList_SetFirst( lCycle, lName, lPath );
150 String_Free( lName );
151 String_Free( lPath );
153 lCycle._realValue = lCycle._realValue + 1;
154 Raise_DataEvent( lCycle, ITEM_DATALINK_SET );
156 Nex_MapSelector_Synchronize();
159 void() Nex_Action_Cycle_Remove =
163 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
164 DataLink_Nex_MapList_DeleteEntry( lCycle );
166 Nex_MapSelector_Synchronize();
169 void() Nex_Action_Cycle_MoveUp =
173 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
174 DataLink_Nex_MapList_MoveEntryUp( lCycle );
176 lCycle._realValue = lCycle._realValue - 1;
177 Raise_DataEvent( lCycle, ITEM_DATALINK_SET );
179 Nex_MapSelector_Synchronize();
182 void() Nex_Action_Cycle_MoveDown =
186 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
187 DataLink_Nex_MapList_MoveEntryDown( lCycle );
189 lCycle._realValue = lCycle._realValue + 1;
190 Raise_DataEvent( lCycle, ITEM_DATALINK_SET );
192 Nex_MapSelector_Synchronize();
195 void() Nex_Action_Cycle_Clear =
199 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
200 DataLink_Nex_MapList_Clear( lCycle );
202 Nex_MapSelector_Synchronize();
207 entity( float pType ) Nex_Management_GetFileList =
211 return Menu_GetItem( "::Data::Management::FileList::Weapon" );
213 return Menu_GetItem( "::Data::Management::FileList::Game" );
215 return Menu_GetItem( "::Data::Management::FileList::MapList" );
221 entity( float pType ) Nex_Management_GetContainer =
225 return Menu_GetItem( "::Data::Weapon" );
227 return Menu_GetItem( "::Data::Game" );
229 return Menu_GetItem( "::Data::Server::Map::Cycle" );
235 float() Nex_Management_GetType =
237 local entity lTypeData;
239 lTypeData = Menu_GetItem( "::Data::Management::ConfigType" );
240 return stof( lTypeData.value );
243 string() Nex_Management_GetTypeName =
245 local entity lTypeSwitch;
247 lTypeSwitch = Menu_GetItem( "::Data::Management::ConfigType::Switch" );
248 Raise_DataEvent( lTypeSwitch, ITEM_DATALINK_GET );
249 return String_Zone( lTypeSwitch.value );
252 void( float pType ) Nex_Management_SetType =
256 local entity lTypeData;
258 lTypeData = Menu_GetItem( "::Data::Management::ConfigType" );
259 String_EntitySet( lTypeData, value, ftos( pType ) );
260 Raise_DataEvent( lTypeData, ITEM_DATALINK_SET );
262 // update the filename
263 /*lItem = Menu_GetItem( "::Data::Management::Filename::Text" );
264 String_EntitySet( lItem, value, "" );
265 Raise_DataEvent( lItem, ITEM_DATALINK_SET );*/
267 lItem = Menu_GetItem( "FileList" );
268 lList = Nex_Management_GetFileList( pType );
269 String_EntitySet( lItem, target, lList.name );
272 void() Nex_Action_CopyToFilename =
276 if( !self._target ) {
280 Raise_DataEvent( self._target, ITEM_DATALINK_GET );
282 lItem = Menu_GetItem( "::Data::Management::Filename::Text" );
283 String_EntitySet( lItem, value, self._target.value );
284 Raise_DataEvent( lItem, ITEM_DATALINK_SET );
287 void() Nex_Update_Management_SyncData =
289 if( self._realValue < Timer_Time && self._realValue > 0.0 ) {
290 Raise_DataEvent( Nex_Management_GetContainer( Nex_Management_GetType() ), ITEM_DATA_SYNC );
291 self._realValue = 0.0;
295 void() Nex_Action_Management_Refresh =
299 lItem = Menu_GetItem( "::Data::Management::FileList" );
300 Raise_DataEvent( lItem, ITEM_DATA_SYNC );
303 void() Nex_Action_Management_LoadConfig =
305 local entity lFileList;
306 local entity lFilenameData;
307 local entity lSyncItem;
309 lFileList = Nex_Management_GetFileList( Nex_Management_GetType() );
310 lFilenameData = Menu_GetItem( "::Data::Management::Filename" );
312 cmd( strcat( "exec \"", lFileList.selected, lFilenameData.value, ".", lFileList.normal, "\"\n" ) );
314 lSyncItem = Menu_GetItem( "CreateGame::Panel::Management::SyncCategory" );
315 lSyncItem._realValue = Timer_Time;
318 void() Nex_Action_Management_Load =
321 local string lQuestion;
324 lItem = Menu_GetItem( "::Data::Management::Filename" );
325 if( lItem.value == "" ) {
326 Nex_MessageBox( "Loading", "You must specify a filename!", "Ok", "", Util_NullFunction, Util_NullFunction );
330 lTitle = String_Zone( strcat( "Loading ", String_Normal( Nex_Management_GetTypeName() ) ) );
331 lQuestion = String_Zone( strcat( "Do you want to load '", lItem.value, "'?" ) );
332 Nex_MessageBox( lTitle, lQuestion, "Yes", "No", Nex_Action_Management_LoadConfig, Util_NullFunction );
333 String_Free( lQuestion );
334 String_Free( lTitle );
337 void() Nex_Action_Management_SaveConfig =
340 local entity lFileList;
341 local entity lFilename;
342 local entity lContainer;
345 lType = Nex_Management_GetType();
346 lFileList = Nex_Management_GetFileList( lType );
347 lContainer = Nex_Management_GetContainer( lType );
348 lFilename = Menu_GetItem( "::Data::Management::Filename" );
349 if( lFilename.value == "" ) {
350 Nex_MessageBox( "Saving", "You must specify a filename!", "Ok", "", Util_NullFunction, Util_NullFunction );
353 lHandle = fopen( strcat( lFileList.selected, lFilename.value, ".", lFileList.normal ), FILE_WRITE );
359 Data_ExecString_BeginUse();
360 Raise_DataEvent( lContainer, ITEM_DATA_SAVE_EXECSTRING );
362 fputs( lHandle, Data_ExecString );
364 Data_ExecString_EndUse();
368 Nex_Action_Management_Refresh();
371 void() Nex_Action_Management_Save =
373 local entity lFileList;
374 local entity lFilename;
377 lFileList = Nex_Management_GetFileList( Nex_Management_GetType() );
378 lFilename = Menu_GetItem( "::Data::Management::Filename" );
380 lHandle = fopen( strcat( lFileList.selected, "/", lFilename.value, ".", lFileList.normal ), FILE_READ );
382 if( lHandle == ERR_CANNOTOPEN ) {
383 Nex_Action_Management_SaveConfig();
384 } else if( lHandle > 0 ) {
385 local string lQuestion;
390 lTitle = String_Zone( strcat( "Saving ", String_Normal( Nex_Management_GetTypeName() ) ) );
391 print( lTitle, "\n" );
392 lQuestion = String_Zone( strcat( "Do you want to overwrite '", lFilename.value, "'?" ) );
393 Nex_MessageBox( lTitle, lQuestion, "Yes", "No", Nex_Action_Management_SaveConfig, Util_NullFunction );
394 String_Free( lQuestion );
395 String_Free( lTitle );
399 void() Nex_Action_Management_TypeWeapon =
401 Nex_Management_SetType( 0 );
404 void() Nex_Action_Management_TypeGame =
406 Nex_Management_SetType( 1 );
409 void() Nex_Action_Management_TypeMapList =
411 Nex_Management_SetType( 2 );
415 void() Nex_Action_Maplist_ChangeMapType = {
416 local entity lOldSelf;
419 Nex_Action_TestOnChange();
423 Nex_MapDB_RefreshFiles();
425 self = Menu_GetItem( "::Data::Server::Map::Selector" );
426 Item_DataLink_Nex_MapList_InitWithMapList();
427 //DataLink_Nex_MapList_UpdateRange(self);
428 //Item_DataLink_Nex_MapList_Load();
430 // fixme: need to change which map the map selector is pointing to right now
432 Raise_DataEvent( self, ITEM_DATALINK_GET );
433 if(self._realValue > self.maxValue)
434 self._realValue = self.maxValue;
435 Raise_DataEvent( self, ITEM_DATALINK_SET );
437 //Nex_MapSelector_UpdateMap();
438 //Nex_MapSelector_Synchronize();