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_GetFilteredByIndex( 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 lItem = Menu_GetItem( "Picture" );
31 String_EntitySet( lItem, picture, lInfo.picture );
33 lItem = Menu_GetItem( "Name" );
34 String_EntitySet( lItem, text, lInfo.normal );
36 lItem = Menu_GetItem( "Description" );
37 String_EntitySet( lItem, text, lInfo.text );
39 lItem = Menu_GetItem( "::Data::Server::Map::Cycle" );
40 DataLink_Nex_MapList_SetFirst( lItem, lInfo.normal, lInfo.link );
43 void() Nex_MapSelector_Synchronize =
46 local entity lSelector;
48 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
49 lSelector = Menu_GetItem( "::Data::Server::Map::Selector" );
51 if( lCycle.stepValue == 0.0 ) {
52 Raise_DataEvent( lCycle, ITEM_DATA_RESET );
55 local entity lMapInfo;
57 lPath = Util_GetAltStringItem( lCycle.valueList, 0 );
58 lMapInfo = Nex_MapDB_GetByPath( lPath );
61 if( lMapInfo == null_entity ) {
62 Raise_DataEvent( lCycle, ITEM_DATA_RESET );
64 lSelector._realValue = Nex_MapDB_GetFilteredIndex( lMapInfo );
65 Raise_DataEvent( lSelector, ITEM_DATALINK_SET );
70 // more concrete functions
71 void() Nex_Action_MapSelector_Next =
75 lItem = Menu_GetItem( "::Data::Server::Map::Selector" );
76 Raise_DataEvent( lItem, ITEM_DATALINK_GET );
77 lItem._realValue = lItem._realValue + 1;
78 Raise_DataEvent( lItem, ITEM_DATALINK_SET );
81 void() Nex_Action_MapSelector_Prev =
85 lItem = Menu_GetItem( "::Data::Server::Map::Selector" );
86 Raise_DataEvent( lItem, ITEM_DATALINK_GET );
87 lItem._realValue = lItem._realValue - 1;
88 Raise_DataEvent( lItem, ITEM_DATALINK_SET );
91 // TODO: Make MaxPlayers real Data items (no container with correct set behavior)
92 void() Nex_Action_Map_Start =
95 local string exit_cfg;
98 lItem = Menu_GetItem( "::Data::Server::MaxPlayers" );
99 cmd( "maxplayers \"" );
103 lItem = Menu_GetItem( "::Data::Server::Map::Cycle" );
104 Raise_DataEvent( lItem, ITEM_DATA_SEND );
106 // if an old exit cfg file was set up, exec it
107 // to reset old values before starting the server
108 exit_cfg = cvar_string("exit_cfg");
115 // exec the game reset cfg and then the mapcfg
116 cmd( "exec game_reset.cfg \nwait \nexec \"maps/" );
117 cmd( String_Normal( Util_GetAltStringItem( lItem.valueList, 0 ) ) );
120 // force the menu to hide
124 // cycle list edit features
125 void() Nex_Action_Cycle_Add =
132 lList = Menu_GetItem( "::Data::Server::Map::List" );
133 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
135 lName = DataLink_Nex_MapList_GetCurrentName( lList );
136 lPath = DataLink_Nex_MapList_GetCurrentPath( lList );
138 if( lCycle.stepValue == 1.0 ) {
139 DataLink_Nex_MapList_InsertEntryAfter( lCycle, lName, lPath );
141 DataLink_Nex_MapList_SetFirst( lCycle, lName, lPath );
144 String_Free( lName );
145 String_Free( lPath );
147 lCycle._realValue = lCycle._realValue + 1;
148 Raise_DataEvent( lCycle, ITEM_DATALINK_SET );
150 Nex_MapSelector_Synchronize();
153 void() Nex_Action_Cycle_Remove =
157 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
158 DataLink_Nex_MapList_DeleteEntry( lCycle );
160 Nex_MapSelector_Synchronize();
163 void() Nex_Action_Cycle_MoveUp =
167 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
168 DataLink_Nex_MapList_MoveEntryUp( lCycle );
170 lCycle._realValue = lCycle._realValue - 1;
171 Raise_DataEvent( lCycle, ITEM_DATALINK_SET );
173 Nex_MapSelector_Synchronize();
176 void() Nex_Action_Cycle_MoveDown =
180 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
181 DataLink_Nex_MapList_MoveEntryDown( lCycle );
183 lCycle._realValue = lCycle._realValue + 1;
184 Raise_DataEvent( lCycle, ITEM_DATALINK_SET );
186 Nex_MapSelector_Synchronize();
189 void() Nex_Action_Cycle_Clear =
193 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
194 DataLink_Nex_MapList_Clear( lCycle );
196 Nex_MapSelector_Synchronize();
200 void() Nex_Action_Maplist_ChangeMapType = {
201 local entity lMapQuery;
202 local entity lOldSelf;
204 lMapQuery = Menu_GetItem( "::Data::Server::Map::Query" );
206 Raise_DataEvent( self._target, ITEM_DATALINK_SET );
208 Nex_MapDB_FilterMaps( lMapQuery.value );
211 self = Menu_GetItem( "::Data::Server::Map::Selector" );
212 Item_DataLink_Nex_MapList_InitWithMapList();
213 self = Menu_GetItem( "::Data::Server::Map::List" );
214 Item_DataLink_Nex_MapList_InitWithMapList();
220 entity( float pType ) Nex_Management_GetFileList =
224 return Menu_GetItem( "::Data::Management::FileList::Weapon" );
226 return Menu_GetItem( "::Data::Management::FileList::Game" );
228 return Menu_GetItem( "::Data::Management::FileList::MapList" );
234 entity( float pType ) Nex_Management_GetContainer =
238 return Menu_GetItem( "::Data::Weapon" );
240 return Menu_GetItem( "::Data::Game" );
242 return Menu_GetItem( "::Data::Server::Map::Cycle" );
248 float() Nex_Management_GetType =
250 local entity lTypeData;
252 lTypeData = Menu_GetItem( "::Data::Management::ConfigType" );
253 return stof( lTypeData.value );
256 string() Nex_Management_GetTypeName =
258 local entity lTypeSwitch;
260 lTypeSwitch = Menu_GetItem( "::Data::Management::ConfigType::Switch" );
261 Raise_DataEvent( lTypeSwitch, ITEM_DATALINK_GET );
262 return String_Zone( lTypeSwitch.value );
265 void( float pType ) Nex_Management_SetType =
269 local entity lTypeData;
271 lTypeData = Menu_GetItem( "::Data::Management::ConfigType" );
272 String_EntitySet( lTypeData, value, ftos( pType ) );
273 Raise_DataEvent( lTypeData, ITEM_DATALINK_SET );
275 // update the filename
276 /*lItem = Menu_GetItem( "::Data::Management::Filename::Text" );
277 String_EntitySet( lItem, value, "" );
278 Raise_DataEvent( lItem, ITEM_DATALINK_SET );*/
280 lItem = Menu_GetItem( "FileList" );
281 lList = Nex_Management_GetFileList( pType );
282 String_EntitySet( lItem, target, lList.name );
285 void() Nex_Action_CopyToFilename =
289 if( !self._target ) {
293 Raise_DataEvent( self._target, ITEM_DATALINK_GET );
295 lItem = Menu_GetItem( "::Data::Management::Filename::Text" );
296 String_EntitySet( lItem, value, self._target.value );
297 Raise_DataEvent( lItem, ITEM_DATALINK_SET );
300 void() Nex_Update_Management_SyncData =
302 if( self._realValue < Timer_Time && self._realValue > 0.0 ) {
303 Raise_DataEvent( Nex_Management_GetContainer( Nex_Management_GetType() ), ITEM_DATA_SYNC );
304 self._realValue = 0.0;
308 void() Nex_Action_Management_Refresh =
312 lItem = Menu_GetItem( "::Data::Management::FileList" );
313 Raise_DataEvent( lItem, ITEM_DATA_SYNC );
316 void() Nex_Action_Management_LoadConfig =
318 local entity lFileList;
319 local entity lFilenameData;
320 local entity lSyncItem;
322 lFileList = Nex_Management_GetFileList( Nex_Management_GetType() );
323 lFilenameData = Menu_GetItem( "::Data::Management::Filename" );
325 cmd( strcat( "exec \"", lFileList.selected, lFilenameData.value, ".", lFileList.normal, "\"\n" ) );
327 lSyncItem = Menu_GetItem( "CreateGame::Panel::Management::SyncCategory" );
328 lSyncItem._realValue = Timer_Time;
331 void() Nex_Action_Management_Load =
334 local string lQuestion;
337 lItem = Menu_GetItem( "::Data::Management::Filename" );
338 if( lItem.value == "" ) {
339 Nex_MessageBox( "Loading", "You must specify a filename!", "Ok", "", Util_NullFunction, Util_NullFunction );
343 lTitle = String_Zone( strcat( "Loading ", String_Normal( Nex_Management_GetTypeName() ) ) );
344 lQuestion = String_Zone( strcat( "Do you want to load '", lItem.value, "'?" ) );
345 Nex_MessageBox( lTitle, lQuestion, "Yes", "No", Nex_Action_Management_LoadConfig, Util_NullFunction );
346 String_Free( lQuestion );
347 String_Free( lTitle );
350 void() Nex_Action_Management_SaveConfig =
353 local entity lFileList;
354 local entity lFilename;
355 local entity lContainer;
358 lType = Nex_Management_GetType();
359 lFileList = Nex_Management_GetFileList( lType );
360 lContainer = Nex_Management_GetContainer( lType );
361 lFilename = Menu_GetItem( "::Data::Management::Filename" );
362 if( lFilename.value == "" ) {
363 Nex_MessageBox( "Saving", "You must specify a filename!", "Ok", "", Util_NullFunction, Util_NullFunction );
366 lHandle = fopen( strcat( lFileList.selected, lFilename.value, ".", lFileList.normal ), FILE_WRITE );
372 Data_ExecString_BeginUse();
373 Raise_DataEvent( lContainer, ITEM_DATA_SAVE_EXECSTRING );
375 fputs( lHandle, Data_ExecString );
377 Data_ExecString_EndUse();
381 Nex_Action_Management_Refresh();
384 void() Nex_Action_Management_Save =
386 local entity lFileList;
387 local entity lFilename;
390 lFileList = Nex_Management_GetFileList( Nex_Management_GetType() );
391 lFilename = Menu_GetItem( "::Data::Management::Filename" );
393 lHandle = fopen( strcat( lFileList.selected, "/", lFilename.value, ".", lFileList.normal ), FILE_READ );
395 if( lHandle == ERR_CANNOTOPEN ) {
396 Nex_Action_Management_SaveConfig();
397 } else if( lHandle > 0 ) {
398 local string lQuestion;
403 lTitle = String_Zone( strcat( "Saving ", String_Normal( Nex_Management_GetTypeName() ) ) );
404 lQuestion = String_Zone( strcat( "Do you want to overwrite '", lFilename.value, "'?" ) );
405 Nex_MessageBox( lTitle, lQuestion, "Yes", "No", Nex_Action_Management_SaveConfig, Util_NullFunction );
406 String_Free( lQuestion );
407 String_Free( lTitle );
411 void() Nex_Action_Management_TypeWeapon =
413 Nex_Management_SetType( 0 );
416 void() Nex_Action_Management_TypeGame =
418 Nex_Management_SetType( 1 );
421 void() Nex_Action_Management_TypeMapList =
423 Nex_Management_SetType( 2 );