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 \"", lItem.value, "\"\n" );
101 lItem = Menu_GetItem( "::Data::Server::Map::Cycle" );
102 Raise_DataEvent( lItem, ITEM_DATA_SEND );
104 // if an old exit cfg file was set up, exec it
105 // to reset old values before starting the server
106 exit_cfg = cvar_string("exit_cfg");
109 cmd( "exec ", exit_cfg, "\n" );
111 // exec the game reset cfg and then the mapcfg
112 cmd( "exec game_reset.cfg \nwait \nexec \"maps/", String_Normal( Util_GetAltStringItem( lItem.valueList, 0 ) ), ".mapcfg\"\n" );
114 // force the menu to hide
118 // cycle list edit features
119 void() Nex_Action_Cycle_Add =
126 lList = Menu_GetItem( "::Data::Server::Map::List" );
127 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
129 lName = DataLink_Nex_MapList_GetCurrentName( lList );
130 lPath = DataLink_Nex_MapList_GetCurrentPath( lList );
132 if( lCycle.stepValue == 1.0 ) {
133 DataLink_Nex_MapList_InsertEntryAfter( lCycle, lName, lPath );
135 DataLink_Nex_MapList_SetFirst( lCycle, lName, lPath );
138 String_Free( lName );
139 String_Free( lPath );
141 lCycle._realValue = lCycle._realValue + 1;
142 Raise_DataEvent( lCycle, ITEM_DATALINK_SET );
144 Nex_MapSelector_Synchronize();
147 void() Nex_Action_Cycle_Remove =
151 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
152 DataLink_Nex_MapList_DeleteEntry( lCycle );
154 Nex_MapSelector_Synchronize();
157 void() Nex_Action_Cycle_MoveUp =
161 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
162 DataLink_Nex_MapList_MoveEntryUp( lCycle );
164 lCycle._realValue = lCycle._realValue - 1;
165 Raise_DataEvent( lCycle, ITEM_DATALINK_SET );
167 Nex_MapSelector_Synchronize();
170 void() Nex_Action_Cycle_MoveDown =
174 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
175 DataLink_Nex_MapList_MoveEntryDown( lCycle );
177 lCycle._realValue = lCycle._realValue + 1;
178 Raise_DataEvent( lCycle, ITEM_DATALINK_SET );
180 Nex_MapSelector_Synchronize();
183 void() Nex_Action_Cycle_Clear =
187 lCycle = Menu_GetItem( "::Data::Server::Map::Cycle" );
188 DataLink_Nex_MapList_Clear( lCycle );
190 Nex_MapSelector_Synchronize();
194 void() Nex_Action_Maplist_ChangeMapType = {
195 local entity lMapQuery;
196 local entity lOldSelf;
198 lMapQuery = Menu_GetItem( "::Data::Server::Map::Query" );
200 Raise_DataEvent( self._target, ITEM_DATALINK_SET );
202 Nex_MapDB_FilterMaps( lMapQuery.value );
205 self = Menu_GetItem( "::Data::Server::Map::Selector" );
206 Item_DataLink_Nex_MapList_InitWithMapList();
207 self = Menu_GetItem( "::Data::Server::Map::List" );
208 Item_DataLink_Nex_MapList_InitWithMapList();
214 entity( float pType ) Nex_Management_GetFileList =
218 return Menu_GetItem( "::Data::Management::FileList::Weapon" );
220 return Menu_GetItem( "::Data::Management::FileList::Game" );
222 return Menu_GetItem( "::Data::Management::FileList::MapList" );
228 entity( float pType ) Nex_Management_GetContainer =
232 return Menu_GetItem( "::Data::Weapon" );
234 return Menu_GetItem( "::Data::Game" );
236 return Menu_GetItem( "::Data::Server::Map::Cycle" );
242 float() Nex_Management_GetType =
244 local entity lTypeData;
246 lTypeData = Menu_GetItem( "::Data::Management::ConfigType" );
247 return stof( lTypeData.value );
250 string() Nex_Management_GetTypeName =
252 local entity lTypeSwitch;
254 lTypeSwitch = Menu_GetItem( "::Data::Management::ConfigType::Switch" );
255 Raise_DataEvent( lTypeSwitch, ITEM_DATALINK_GET );
256 return String_Zone( lTypeSwitch.value );
259 void( float pType ) Nex_Management_SetType =
263 local entity lTypeData;
265 lTypeData = Menu_GetItem( "::Data::Management::ConfigType" );
266 String_EntitySet( lTypeData, value, ftos( pType ) );
267 Raise_DataEvent( lTypeData, ITEM_DATALINK_SET );
269 // update the filename
270 /*lItem = Menu_GetItem( "::Data::Management::Filename::Text" );
271 String_EntitySet( lItem, value, "" );
272 Raise_DataEvent( lItem, ITEM_DATALINK_SET );*/
274 lItem = Menu_GetItem( "FileList" );
275 lList = Nex_Management_GetFileList( pType );
276 String_EntitySet( lItem, target, lList.name );
279 void() Nex_Action_CopyToFilename =
283 if( !self._target ) {
287 Raise_DataEvent( self._target, ITEM_DATALINK_GET );
289 lItem = Menu_GetItem( "::Data::Management::Filename::Text" );
290 String_EntitySet( lItem, value, self._target.value );
291 Raise_DataEvent( lItem, ITEM_DATALINK_SET );
294 void() Nex_Update_Management_SyncData =
296 if( self._realValue < Timer_Time && self._realValue > 0.0 ) {
297 Raise_DataEvent( Nex_Management_GetContainer( Nex_Management_GetType() ), ITEM_DATA_SYNC );
298 self._realValue = 0.0;
302 void() Nex_Action_Management_Refresh =
306 lItem = Menu_GetItem( "::Data::Management::FileList" );
307 Raise_DataEvent( lItem, ITEM_DATA_SYNC );
310 void() Nex_Action_Management_LoadConfig =
312 local entity lFileList;
313 local entity lFilenameData;
314 local entity lSyncItem;
316 lFileList = Nex_Management_GetFileList( Nex_Management_GetType() );
317 lFilenameData = Menu_GetItem( "::Data::Management::Filename" );
319 cmd( strcat( "exec \"", lFileList.selected, lFilenameData.value, ".", lFileList.normal, "\"\n" ) );
321 lSyncItem = Menu_GetItem( "CreateGame::Panel::Management::SyncCategory" );
322 lSyncItem._realValue = Timer_Time;
325 void() Nex_Action_Management_Load =
328 local string lQuestion;
331 lItem = Menu_GetItem( "::Data::Management::Filename" );
332 if( lItem.value == "" ) {
333 Nex_MessageBox( "Loading", "You must specify a filename!", "Ok", "", Util_NullFunction, Util_NullFunction );
337 lTitle = String_Zone( strcat( "Loading ", String_Normal( Nex_Management_GetTypeName() ) ) );
338 lQuestion = String_Zone( strcat( "Do you want to load '", lItem.value, "'?" ) );
339 Nex_MessageBox( lTitle, lQuestion, "Yes", "No", Nex_Action_Management_LoadConfig, Util_NullFunction );
340 String_Free( lQuestion );
341 String_Free( lTitle );
344 void() Nex_Action_Management_SaveConfig =
347 local entity lFileList;
348 local entity lFilename;
349 local entity lContainer;
352 lType = Nex_Management_GetType();
353 lFileList = Nex_Management_GetFileList( lType );
354 lContainer = Nex_Management_GetContainer( lType );
355 lFilename = Menu_GetItem( "::Data::Management::Filename" );
356 if( lFilename.value == "" ) {
357 Nex_MessageBox( "Saving", "You must specify a filename!", "Ok", "", Util_NullFunction, Util_NullFunction );
360 lHandle = fopen( strcat( lFileList.selected, lFilename.value, ".", lFileList.normal ), FILE_WRITE );
366 Data_ExecString_BeginUse();
367 Raise_DataEvent( lContainer, ITEM_DATA_SAVE_EXECSTRING );
369 fputs( lHandle, Data_ExecString );
371 Data_ExecString_EndUse();
375 Nex_Action_Management_Refresh();
378 void() Nex_Action_Management_Save =
380 local entity lFileList;
381 local entity lFilename;
384 lFileList = Nex_Management_GetFileList( Nex_Management_GetType() );
385 lFilename = Menu_GetItem( "::Data::Management::Filename" );
387 lHandle = fopen( strcat( lFileList.selected, "/", lFilename.value, ".", lFileList.normal ), FILE_READ );
389 if( lHandle == ERR_CANNOTOPEN ) {
390 Nex_Action_Management_SaveConfig();
391 } else if( lHandle > 0 ) {
392 local string lQuestion;
397 lTitle = String_Zone( strcat( "Saving ", String_Normal( Nex_Management_GetTypeName() ) ) );
398 lQuestion = String_Zone( strcat( "Do you want to overwrite '", lFilename.value, "'?" ) );
399 Nex_MessageBox( lTitle, lQuestion, "Yes", "No", Nex_Action_Management_SaveConfig, Util_NullFunction );
400 String_Free( lQuestion );
401 String_Free( lTitle );
405 void() Nex_Action_Management_TypeWeapon =
407 Nex_Management_SetType( 0 );
410 void() Nex_Action_Management_TypeGame =
412 Nex_Management_SetType( 1 );
415 void() Nex_Action_Management_TypeMapList =
417 Nex_Management_SetType( 2 );