@jtff/miztemplate-lib 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -1
- package/lib/mizlib.js +21 -4
- package/lua/lib/Moose_.lua +487 -77
- package/package.json +1 -1
- package/scripts/inject-scripts.js +374 -359
|
@@ -4,7 +4,7 @@ const prompt = require('prompt');
|
|
|
4
4
|
let _ = require('lodash');
|
|
5
5
|
const {getInstalledPathSync} = require("get-installed-path");
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function createSkel(jtffci, env_mission) {
|
|
8
8
|
const workspacePath = [
|
|
9
9
|
jtffci.config.general.missionFolder,
|
|
10
10
|
"/",
|
|
@@ -61,6 +61,17 @@ function injectScripts(jtffci, env_mission) {
|
|
|
61
61
|
].join(""),
|
|
62
62
|
{ recursive: true }
|
|
63
63
|
);
|
|
64
|
+
fs.mkdirSync([
|
|
65
|
+
workspacePath,
|
|
66
|
+
"/resources/kneeboards/common"
|
|
67
|
+
].join(""),
|
|
68
|
+
{ recursive: true }
|
|
69
|
+
);
|
|
70
|
+
return {workspacePath, destinationMizFilePath};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function injectScripts(jtffci, env_mission) {
|
|
74
|
+
const {workspacePath,destinationMizFilePath} = createSkel(jtffci, env_mission);
|
|
64
75
|
const prompt_properties = [
|
|
65
76
|
{
|
|
66
77
|
name: 'inject_tankers',
|
|
@@ -141,386 +152,390 @@ function injectScripts(jtffci, env_mission) {
|
|
|
141
152
|
console.log(' inject_A2G scripts: ' + (/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_A2G));
|
|
142
153
|
console.log(' inject_mission specific scripts: ' + (/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_mission));
|
|
143
154
|
console.log(' inject_radio_presets scripts: ' + (/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_radio_presets));
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
return await doInject(jtffci, env_mission, workspacePath, destinationMizFilePath, prompt_result);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function doInject(ciObject, sourceMizFileName, workspacePath,destinationMizFilePath, promptResult) {
|
|
160
|
+
// open the miz input file for reading
|
|
161
|
+
const originalMizObject = await ciObject.mizlib.getZipObjectFromMizPath(sourceMizFileName);
|
|
162
|
+
// copie de l'objet pour modification
|
|
163
|
+
let mizObject = originalMizObject;
|
|
164
|
+
// Open the mission Object and mapResource Object for modification
|
|
165
|
+
const missionObject = await ciObject.mizlib.getMissionObjectFromZipObject(mizObject);
|
|
166
|
+
let mapResourceObject = await ciObject.mizlib.getMapResourceObjectFromZipObject(mizObject);
|
|
167
|
+
// prepare settings array
|
|
168
|
+
let settingsArray = [];
|
|
169
|
+
let scriptsArray = [];
|
|
170
|
+
let libsArray = [];
|
|
171
|
+
// insertion des librairies externes dans la file d'attente
|
|
172
|
+
libsArray.push({
|
|
173
|
+
folder: 'lib',
|
|
174
|
+
scriptTitle: 'SplashDamage 2.0',
|
|
175
|
+
scripts: ['Splash_Damage_2_0.lua'],
|
|
176
|
+
timing: 9,
|
|
177
|
+
color: '0x008000ff'
|
|
178
|
+
});
|
|
179
|
+
libsArray.push({
|
|
180
|
+
folder: 'lib',
|
|
181
|
+
scriptTitle: 'Moose',
|
|
182
|
+
scripts: ['Moose_.lua'],
|
|
183
|
+
timing: 10,
|
|
184
|
+
color: '0x008000ff'
|
|
185
|
+
});
|
|
186
|
+
libsArray.push({
|
|
187
|
+
folder: 'lib',
|
|
188
|
+
scriptTitle: 'Mist',
|
|
189
|
+
scripts: ['mist_4_5_107.lua'],
|
|
190
|
+
timing: 12,
|
|
191
|
+
color: '0x008000ff'
|
|
192
|
+
});
|
|
193
|
+
libsArray.push({
|
|
194
|
+
folder: 'lib',
|
|
195
|
+
scriptTitle: 'Hercules',
|
|
196
|
+
scripts: ['Hercules_Cargo.lua'],
|
|
197
|
+
timing: 14,
|
|
198
|
+
color: '0x008000ff'
|
|
199
|
+
});
|
|
200
|
+
libsArray.push({
|
|
201
|
+
folder: 'lib',
|
|
202
|
+
scriptTitle: 'Skynet',
|
|
203
|
+
scripts: ['skynet-iads-compiled.lua'],
|
|
204
|
+
timing: 15,
|
|
205
|
+
color: '0x008000ff'
|
|
206
|
+
});
|
|
207
|
+
// injection des fichiers son Généraux si repertoire resources/sounds/General present
|
|
208
|
+
await ciObject.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'General');
|
|
209
|
+
await ciObject.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'General', true);
|
|
210
|
+
// injection des fichiers son Misc si repertoire resources/sounds/Misc present
|
|
211
|
+
await ciObject.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'Misc');
|
|
212
|
+
await ciObject.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'Misc', true);
|
|
213
|
+
// insertion des Librairies JTFF dans la file d'attente
|
|
214
|
+
settingsArray.push(
|
|
215
|
+
{
|
|
216
|
+
file: "settings-gemman.lua",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
file: "settings-global.lua",
|
|
220
|
+
},
|
|
221
|
+
);
|
|
222
|
+
libsArray.push({
|
|
223
|
+
folder: 'lib',
|
|
224
|
+
scriptTitle: 'GemMan',
|
|
225
|
+
scripts: ['gemman.lua'],
|
|
226
|
+
timing: 17,
|
|
227
|
+
color: '0xffff00ff'
|
|
228
|
+
});
|
|
229
|
+
libsArray.push({
|
|
230
|
+
folder: 'src',
|
|
231
|
+
scriptTitle: 'JTFF Libraries',
|
|
232
|
+
scripts: ['010-root_menus.lua', '020-mission_functions.lua'],
|
|
233
|
+
timing: 18,
|
|
234
|
+
color: '0xffff00ff'
|
|
235
|
+
});
|
|
236
|
+
// traitement de la file d'attente des librairies (injection des triggers et des fichiers lua)
|
|
237
|
+
for ( libscript of libsArray) {
|
|
238
|
+
console.log(['adding library',libscript.scripts.join(' and '),'from',workspacePath + '/.workspace/' + libscript.folder, 'folder...'].join(' '));
|
|
239
|
+
let {tuple, zipObject} = await ciObject.mizlib.injectLuaScriptIntoZipObjectAndUpdateWorkspace(
|
|
240
|
+
workspacePath,
|
|
241
|
+
libscript.folder,
|
|
242
|
+
libscript.scripts,
|
|
243
|
+
libscript.scriptTitle + ' Load',
|
|
244
|
+
mizObject,
|
|
245
|
+
libscript.timing,
|
|
246
|
+
libscript.color,
|
|
247
|
+
true
|
|
248
|
+
);
|
|
249
|
+
missionObject['trig'] = tuple.tObject;
|
|
250
|
+
missionObject['trigrules'] = tuple.trObject;
|
|
251
|
+
mapResourceObject = _.merge(mapResourceObject,tuple.mrObject);
|
|
252
|
+
mizObject = zipObject;
|
|
253
|
+
}
|
|
254
|
+
// injection de la gestion des Set_Clients dans la file d'attente
|
|
255
|
+
scriptsArray.push({
|
|
256
|
+
folder: 'src',
|
|
257
|
+
scriptTitle: 'Set clients',
|
|
258
|
+
scripts: ['110-set_clients.lua'],
|
|
259
|
+
timing: 21,
|
|
260
|
+
color: '0xff0000ff',
|
|
261
|
+
fromLibrary: true
|
|
262
|
+
});
|
|
263
|
+
// injection des Tankers et OndemandTankers dans la file d'attente
|
|
264
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_tankers)) {
|
|
265
|
+
settingsArray.push(
|
|
266
|
+
{
|
|
267
|
+
file: "settings-tankers.lua",
|
|
268
|
+
objectName: "TankersConfig"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
file: "settings-ondemandtankers.lua",
|
|
272
|
+
objectName: "OnDemandTankersConfig"
|
|
273
|
+
},
|
|
274
|
+
);
|
|
275
|
+
scriptsArray.push({
|
|
276
|
+
folder: 'src',
|
|
277
|
+
scriptTitle: 'Tankers',
|
|
278
|
+
scripts: ['120-tankers.lua'],
|
|
279
|
+
timing: 22,
|
|
280
|
+
color: '0xff0000ff',
|
|
281
|
+
fromLibrary: true
|
|
162
282
|
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
283
|
+
}
|
|
284
|
+
// injection des Airboss et Pedros dans la file d'attente
|
|
285
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_airboss)) {
|
|
286
|
+
// injection des fichiers son Airboss
|
|
287
|
+
await ciObject.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'AIRBOSS');
|
|
288
|
+
await ciObject.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'AIRBOSS', true);
|
|
289
|
+
settingsArray.push(
|
|
290
|
+
{
|
|
291
|
+
file: "settings-airboss.lua",
|
|
292
|
+
objectName: "AirBossConfig"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
file: "settings-pedros.lua",
|
|
296
|
+
objectName: "PedrosConfig"
|
|
297
|
+
},
|
|
298
|
+
);
|
|
299
|
+
scriptsArray.push({
|
|
300
|
+
folder: 'src',
|
|
301
|
+
scriptTitle: 'Airboss',
|
|
302
|
+
scripts: ['130-airboss.lua', '135-pedro.lua'],
|
|
303
|
+
timing: 23,
|
|
304
|
+
color: '0xff0000ff',
|
|
305
|
+
fromLibrary: true
|
|
169
306
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
307
|
+
}
|
|
308
|
+
// injection des Beacons dans la file d'attente
|
|
309
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_beacons)) {
|
|
310
|
+
settingsArray.push(
|
|
311
|
+
{
|
|
312
|
+
file: "settings-beacons.lua",
|
|
313
|
+
objectName: "BeaconsConfig"
|
|
314
|
+
},
|
|
315
|
+
);
|
|
316
|
+
scriptsArray.push({
|
|
317
|
+
folder: 'src',
|
|
318
|
+
scriptTitle: 'Beacons',
|
|
319
|
+
scripts: ['140-beacons.lua'],
|
|
320
|
+
timing: 24,
|
|
321
|
+
color: '0xff0000ff',
|
|
322
|
+
fromLibrary: true
|
|
176
323
|
});
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
324
|
+
}
|
|
325
|
+
// injection des AWACS et OnDemandAwacs dans la file d'attente
|
|
326
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_awacs)) {
|
|
327
|
+
settingsArray.push(
|
|
328
|
+
{
|
|
329
|
+
file: "settings-awacs.lua",
|
|
330
|
+
objectName: "AwacsConfig"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
file: "settings-awacsondemand.lua",
|
|
334
|
+
objectName: "AwacsOnDemandConfig"
|
|
335
|
+
},
|
|
336
|
+
);
|
|
337
|
+
scriptsArray.push({
|
|
338
|
+
folder: 'src',
|
|
339
|
+
scriptTitle: 'Awacs',
|
|
340
|
+
scripts: ['150-awacs.lua'],
|
|
341
|
+
timing: 25,
|
|
342
|
+
color: '0xff0000ff',
|
|
343
|
+
fromLibrary: true
|
|
183
344
|
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
345
|
+
}
|
|
346
|
+
// injection des ATIS dans la file d'attente
|
|
347
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_atis)) {
|
|
348
|
+
// injection des fichiers son ATIS
|
|
349
|
+
await ciObject.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'ATIS');
|
|
350
|
+
await ciObject.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'ATIS', true);
|
|
351
|
+
settingsArray.push(
|
|
352
|
+
{
|
|
353
|
+
file: "settings-atis.lua",
|
|
354
|
+
objectName: "AtisConfig"
|
|
355
|
+
},
|
|
356
|
+
);
|
|
357
|
+
scriptsArray.push({
|
|
358
|
+
folder: 'src',
|
|
359
|
+
scriptTitle: 'ATIS',
|
|
360
|
+
scripts: ['160-atis.lua'],
|
|
361
|
+
timing: 26,
|
|
362
|
+
color: '0xff0000ff',
|
|
363
|
+
fromLibrary: true
|
|
190
364
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// injection des fichiers son Misc si repertoire resources/sounds/Misc present
|
|
195
|
-
await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'Misc');
|
|
196
|
-
await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'Misc', true);
|
|
197
|
-
// insertion des Librairies JTFF dans la file d'attente
|
|
365
|
+
}
|
|
366
|
+
// injection des scripts A2A dans la file d'attente
|
|
367
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_A2A)) {
|
|
198
368
|
settingsArray.push(
|
|
199
369
|
{
|
|
200
|
-
file: "settings-
|
|
370
|
+
file: "settings-capzone.lua",
|
|
371
|
+
objectName: "TrainingCAPConfig"
|
|
201
372
|
},
|
|
202
373
|
{
|
|
203
|
-
file: "settings-
|
|
374
|
+
file: "settings-capwarzone.lua",
|
|
375
|
+
objectName: "WarCAPConfig"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
file: "settings-foxzone.lua",
|
|
379
|
+
objectName: "FoxRangesConfig"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
file: "settings-RAT.lua",
|
|
383
|
+
objectName: "RATConfig"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
file: "settings-intercept.lua",
|
|
387
|
+
objectName: "InterceptConfig"
|
|
204
388
|
},
|
|
205
389
|
);
|
|
206
|
-
|
|
207
|
-
folder: '
|
|
208
|
-
scriptTitle: '
|
|
209
|
-
scripts: ['
|
|
210
|
-
timing:
|
|
211
|
-
color: '
|
|
390
|
+
scriptsArray.push({
|
|
391
|
+
folder: 'src',
|
|
392
|
+
scriptTitle: 'Air To Air',
|
|
393
|
+
scripts: ['170-cap_zone_training.lua', '172-cap_zone_war.lua', '173-fox_zone_training.lua', '176-random_air_traffic.lua', '178-training-intercept.lua'],
|
|
394
|
+
timing: 27,
|
|
395
|
+
color: '0xff0000ff',
|
|
396
|
+
fromLibrary: true
|
|
212
397
|
});
|
|
213
|
-
|
|
398
|
+
}
|
|
399
|
+
// injection des CTLD dans la file d'attente
|
|
400
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_Logistics)) {
|
|
401
|
+
// injection des fichiers son CTLD
|
|
402
|
+
await ciObject.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'CTLD');
|
|
403
|
+
await ciObject.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'CTLD', true);
|
|
404
|
+
settingsArray.push(
|
|
405
|
+
{
|
|
406
|
+
file: "settings-logistics.lua",
|
|
407
|
+
objectName: "CTLDConfig"
|
|
408
|
+
},
|
|
409
|
+
);
|
|
410
|
+
scriptsArray.push({
|
|
214
411
|
folder: 'src',
|
|
215
|
-
scriptTitle: '
|
|
216
|
-
scripts: ['
|
|
217
|
-
timing:
|
|
218
|
-
color: '
|
|
412
|
+
scriptTitle: 'Logistics',
|
|
413
|
+
scripts: ['180-logistics.lua'],
|
|
414
|
+
timing: 28,
|
|
415
|
+
color: '0xff0000ff',
|
|
416
|
+
fromLibrary: true
|
|
219
417
|
});
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
418
|
+
}
|
|
419
|
+
// injection des scripts A2G dans la file d'attente
|
|
420
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_A2G)) {
|
|
421
|
+
// injection des fichiers son Range
|
|
422
|
+
await ciObject.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'RANGE');
|
|
423
|
+
await ciObject.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'RANGE', true);
|
|
424
|
+
settingsArray.push(
|
|
425
|
+
{
|
|
426
|
+
file: "settings-ranges.lua",
|
|
427
|
+
objectName: "RangeConfig"
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
file: "settings-sams.lua",
|
|
431
|
+
objectName: "SamsConfig"
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
file: "settings-training_ranges.lua",
|
|
435
|
+
objectName: "TrainingRangeConfig"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
file: "settings-reapers.lua",
|
|
439
|
+
objectName: "OnDemandReapersConfig"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
file: "settings-fac_ranges.lua",
|
|
443
|
+
objectName: "FACRangeConfig"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
file: "settings-skynet.lua",
|
|
447
|
+
objectName: "SkynetConfig"
|
|
448
|
+
},
|
|
449
|
+
);
|
|
239
450
|
scriptsArray.push({
|
|
240
451
|
folder: 'src',
|
|
241
|
-
scriptTitle: '
|
|
242
|
-
scripts: ['
|
|
243
|
-
timing:
|
|
452
|
+
scriptTitle: 'Air To Ground',
|
|
453
|
+
scripts: ['190-ranges.lua', '191-sams.lua', '193-training_ranges.lua', '195-reaper-ondemand.lua', '196-fac_ranges.lua', '199-skynet.lua'],
|
|
454
|
+
timing: 29,
|
|
244
455
|
color: '0xff0000ff',
|
|
245
456
|
fromLibrary: true
|
|
246
457
|
});
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
// injection des Airboss et Pedros dans la file d'attente
|
|
269
|
-
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_airboss)) {
|
|
270
|
-
// injection des fichiers son Airboss
|
|
271
|
-
await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'AIRBOSS');
|
|
272
|
-
await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'AIRBOSS', true);
|
|
273
|
-
settingsArray.push(
|
|
274
|
-
{
|
|
275
|
-
file: "settings-airboss.lua",
|
|
276
|
-
objectName: "AirBossConfig"
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
file: "settings-pedros.lua",
|
|
280
|
-
objectName: "PedrosConfig"
|
|
281
|
-
},
|
|
282
|
-
);
|
|
283
|
-
scriptsArray.push({
|
|
284
|
-
folder: 'src',
|
|
285
|
-
scriptTitle: 'Airboss',
|
|
286
|
-
scripts: ['130-airboss.lua', '135-pedro.lua'],
|
|
287
|
-
timing: 23,
|
|
288
|
-
color: '0xff0000ff',
|
|
289
|
-
fromLibrary: true
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
// injection des Beacons dans la file d'attente
|
|
293
|
-
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_beacons)) {
|
|
294
|
-
settingsArray.push(
|
|
295
|
-
{
|
|
296
|
-
file: "settings-beacons.lua",
|
|
297
|
-
objectName: "BeaconsConfig"
|
|
298
|
-
},
|
|
299
|
-
);
|
|
300
|
-
scriptsArray.push({
|
|
301
|
-
folder: 'src',
|
|
302
|
-
scriptTitle: 'Beacons',
|
|
303
|
-
scripts: ['140-beacons.lua'],
|
|
304
|
-
timing: 24,
|
|
305
|
-
color: '0xff0000ff',
|
|
306
|
-
fromLibrary: true
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
// injection des AWACS et OnDemandAwacs dans la file d'attente
|
|
310
|
-
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_awacs)) {
|
|
311
|
-
settingsArray.push(
|
|
312
|
-
{
|
|
313
|
-
file: "settings-awacs.lua",
|
|
314
|
-
objectName: "AwacsConfig"
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
file: "settings-awacsondemand.lua",
|
|
318
|
-
objectName: "AwacsOnDemandConfig"
|
|
319
|
-
},
|
|
320
|
-
);
|
|
321
|
-
scriptsArray.push({
|
|
322
|
-
folder: 'src',
|
|
323
|
-
scriptTitle: 'Awacs',
|
|
324
|
-
scripts: ['150-awacs.lua'],
|
|
325
|
-
timing: 25,
|
|
326
|
-
color: '0xff0000ff',
|
|
327
|
-
fromLibrary: true
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
// injection des ATIS dans la file d'attente
|
|
331
|
-
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_atis)) {
|
|
332
|
-
// injection des fichiers son ATIS
|
|
333
|
-
await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'ATIS');
|
|
334
|
-
await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'ATIS', true);
|
|
335
|
-
settingsArray.push(
|
|
336
|
-
{
|
|
337
|
-
file: "settings-atis.lua",
|
|
338
|
-
objectName: "AtisConfig"
|
|
339
|
-
},
|
|
340
|
-
);
|
|
341
|
-
scriptsArray.push({
|
|
342
|
-
folder: 'src',
|
|
343
|
-
scriptTitle: 'ATIS',
|
|
344
|
-
scripts: ['160-atis.lua'],
|
|
345
|
-
timing: 26,
|
|
346
|
-
color: '0xff0000ff',
|
|
347
|
-
fromLibrary: true
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
// injection des scripts A2A dans la file d'attente
|
|
351
|
-
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_A2A)) {
|
|
352
|
-
settingsArray.push(
|
|
353
|
-
{
|
|
354
|
-
file: "settings-capzone.lua",
|
|
355
|
-
objectName: "TrainingCAPConfig"
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
file: "settings-capwarzone.lua",
|
|
359
|
-
objectName: "WarCAPConfig"
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
file: "settings-foxzone.lua",
|
|
363
|
-
objectName: "FoxRangesConfig"
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
file: "settings-RAT.lua",
|
|
367
|
-
objectName: "RATConfig"
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
file: "settings-intercept.lua",
|
|
371
|
-
objectName: "InterceptConfig"
|
|
372
|
-
},
|
|
373
|
-
);
|
|
374
|
-
scriptsArray.push({
|
|
375
|
-
folder: 'src',
|
|
376
|
-
scriptTitle: 'Air To Air',
|
|
377
|
-
scripts: ['170-cap_zone_training.lua', '172-cap_zone_war.lua', '173-fox_zone_training.lua', '176-random_air_traffic.lua', '178-training-intercept.lua'],
|
|
378
|
-
timing: 27,
|
|
379
|
-
color: '0xff0000ff',
|
|
380
|
-
fromLibrary: true
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
// injection des CTLD dans la file d'attente
|
|
384
|
-
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_Logistics)) {
|
|
385
|
-
// injection des fichiers son CTLD
|
|
386
|
-
await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'CTLD');
|
|
387
|
-
await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'CTLD', true);
|
|
388
|
-
settingsArray.push(
|
|
389
|
-
{
|
|
390
|
-
file: "settings-logistics.lua",
|
|
391
|
-
objectName: "CTLDConfig"
|
|
392
|
-
},
|
|
393
|
-
);
|
|
394
|
-
scriptsArray.push({
|
|
395
|
-
folder: 'src',
|
|
396
|
-
scriptTitle: 'Logistics',
|
|
397
|
-
scripts: ['180-logistics.lua'],
|
|
398
|
-
timing: 28,
|
|
399
|
-
color: '0xff0000ff',
|
|
400
|
-
fromLibrary: true
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
// injection des scripts A2G dans la file d'attente
|
|
404
|
-
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_A2G)) {
|
|
405
|
-
// injection des fichiers son Range
|
|
406
|
-
await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'RANGE');
|
|
407
|
-
await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'RANGE', true);
|
|
408
|
-
settingsArray.push(
|
|
409
|
-
{
|
|
410
|
-
file: "settings-ranges.lua",
|
|
411
|
-
objectName: "RangeConfig"
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
file: "settings-sams.lua",
|
|
415
|
-
objectName: "SamsConfig"
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
file: "settings-training_ranges.lua",
|
|
419
|
-
objectName: "TrainingRangeConfig"
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
file: "settings-reapers.lua",
|
|
423
|
-
objectName: "OnDemandReapersConfig"
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
file: "settings-fac_ranges.lua",
|
|
427
|
-
objectName: "FACRangeConfig"
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
file: "settings-skynet.lua",
|
|
431
|
-
objectName: "SkynetConfig"
|
|
432
|
-
},
|
|
433
|
-
);
|
|
434
|
-
scriptsArray.push({
|
|
435
|
-
folder: 'src',
|
|
436
|
-
scriptTitle: 'Air To Ground',
|
|
437
|
-
scripts: ['190-ranges.lua', '191-sams.lua', '193-training_ranges.lua', '195-reaper-ondemand.lua', '196-fac_ranges.lua', '199-skynet.lua'],
|
|
438
|
-
timing: 29,
|
|
439
|
-
color: '0xff0000ff',
|
|
440
|
-
fromLibrary: true
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
// injection du script spécifique de mission dans la file d'attente
|
|
444
|
-
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_mission)) {
|
|
445
|
-
scriptsArray.push({
|
|
446
|
-
folder: 'src',
|
|
447
|
-
scriptTitle: 'Mission specific',
|
|
448
|
-
scripts: ['200-mission.lua'],
|
|
449
|
-
timing: 30,
|
|
450
|
-
color: '0xff0000ff',
|
|
451
|
-
fromLibrary: false
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
// traitement de la file d'attente des scripts (injection des triggers et des fichiers lua)
|
|
455
|
-
for ( script of scriptsArray) {
|
|
456
|
-
console.log(['adding script',script.scripts.join(' and '),'from',workspacePath + '/' + script.folder, 'folder...'].join(' '));
|
|
457
|
-
let {tuple, zipObject} = await jtffci.mizlib.injectLuaScriptIntoZipObjectAndUpdateWorkspace(
|
|
458
|
-
workspacePath,
|
|
459
|
-
script.folder,
|
|
460
|
-
script.scripts,
|
|
461
|
-
script.scriptTitle,
|
|
462
|
-
mizObject,
|
|
463
|
-
script.timing,
|
|
464
|
-
script.color,
|
|
465
|
-
script.fromLibrary
|
|
466
|
-
);
|
|
467
|
-
missionObject['trig'] = tuple.tObject;
|
|
468
|
-
missionObject['trigrules'] = tuple.trObject;
|
|
469
|
-
mapResourceObject = _.merge(mapResourceObject,tuple.mrObject);
|
|
470
|
-
mizObject = zipObject;
|
|
471
|
-
}
|
|
472
|
-
// injection des preset radio dans les avions humains
|
|
473
|
-
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_radio_presets)) {
|
|
474
|
-
// injection des preset radio
|
|
475
|
-
fs.mkdirSync(workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true});
|
|
476
|
-
jtffci.mizlib.copyRecursiveSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre);
|
|
477
|
-
// fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true})
|
|
478
|
-
console.log(destinationMizFilePath + ": injecting radio presets declared in resources/radios/" + missionObject.theatre);
|
|
479
|
-
await jtffci.mizlib.injectRadioPresetsFromFolderIntoZipObject(mizObject, workspacePath + '/resources/radios/' + missionObject.theatre);
|
|
480
|
-
}
|
|
481
|
-
// traitement de la file d'attente des settings (injection des triggers et des fichiers lua)
|
|
482
|
-
if (settingsArray.length > 0) {
|
|
483
|
-
console.log(['adding settings files',settingsArray.map(a => a.file).join(' and '),'from',workspacePath + '/settings', 'folder...'].join(' '));
|
|
484
|
-
let {tuple, zipObject} = await jtffci.mizlib.injectLuaScriptIntoZipObjectAndUpdateWorkspace(
|
|
485
|
-
workspacePath,
|
|
486
|
-
'settings',
|
|
487
|
-
settingsArray.map(a => a.file),
|
|
488
|
-
'Mission Settings',
|
|
489
|
-
mizObject,
|
|
490
|
-
15,
|
|
491
|
-
'0xffff00ff',
|
|
492
|
-
false
|
|
493
|
-
);
|
|
494
|
-
missionObject['trig'] = tuple.tObject;
|
|
495
|
-
missionObject['trigrules'] = tuple.trObject;
|
|
496
|
-
mapResourceObject = _.merge(mapResourceObject,tuple.mrObject);
|
|
497
|
-
mizObject = zipObject;
|
|
498
|
-
}
|
|
499
|
-
// réintégration du fichier mission dans l'archive
|
|
500
|
-
await jtffci.mizlib.injectMissionObjectIntoZipObject(
|
|
458
|
+
}
|
|
459
|
+
// injection du script spécifique de mission dans la file d'attente
|
|
460
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_mission)) {
|
|
461
|
+
scriptsArray.push({
|
|
462
|
+
folder: 'src',
|
|
463
|
+
scriptTitle: 'Mission specific',
|
|
464
|
+
scripts: ['200-mission.lua'],
|
|
465
|
+
timing: 30,
|
|
466
|
+
color: '0xff0000ff',
|
|
467
|
+
fromLibrary: false
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
// traitement de la file d'attente des scripts (injection des triggers et des fichiers lua)
|
|
471
|
+
for ( script of scriptsArray) {
|
|
472
|
+
console.log(['adding script',script.scripts.join(' and '),'from',workspacePath + '/' + script.folder, 'folder...'].join(' '));
|
|
473
|
+
let {tuple, zipObject} = await ciObject.mizlib.injectLuaScriptIntoZipObjectAndUpdateWorkspace(
|
|
474
|
+
workspacePath,
|
|
475
|
+
script.folder,
|
|
476
|
+
script.scripts,
|
|
477
|
+
script.scriptTitle,
|
|
501
478
|
mizObject,
|
|
502
|
-
|
|
479
|
+
script.timing,
|
|
480
|
+
script.color,
|
|
481
|
+
script.fromLibrary
|
|
503
482
|
);
|
|
504
|
-
|
|
483
|
+
missionObject['trig'] = tuple.tObject;
|
|
484
|
+
missionObject['trigrules'] = tuple.trObject;
|
|
485
|
+
mapResourceObject = _.merge(mapResourceObject,tuple.mrObject);
|
|
486
|
+
mizObject = zipObject;
|
|
487
|
+
}
|
|
488
|
+
// injection des preset radio dans les avions humains
|
|
489
|
+
if ((/^y\b|o\b|yes\b|oui\b/i).test(promptResult.inject_radio_presets)) {
|
|
490
|
+
// injection des preset radio
|
|
491
|
+
fs.mkdirSync(workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true});
|
|
492
|
+
ciObject.mizlib.copyRecursiveSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre);
|
|
493
|
+
// fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true})
|
|
494
|
+
console.log(destinationMizFilePath + ": injecting radio presets declared in resources/radios/" + missionObject.theatre);
|
|
495
|
+
await ciObject.mizlib.injectRadioPresetsFromFolderIntoZipObject(mizObject, workspacePath + '/resources/radios/' + missionObject.theatre);
|
|
496
|
+
}
|
|
497
|
+
// traitement de la file d'attente des settings (injection des triggers et des fichiers lua)
|
|
498
|
+
if (settingsArray.length > 0) {
|
|
499
|
+
console.log(['adding settings files',settingsArray.map(a => a.file).join(' and '),'from',workspacePath + '/settings', 'folder...'].join(' '));
|
|
500
|
+
let {tuple, zipObject} = await ciObject.mizlib.injectLuaScriptIntoZipObjectAndUpdateWorkspace(
|
|
501
|
+
workspacePath,
|
|
502
|
+
'settings',
|
|
503
|
+
settingsArray.map(a => a.file),
|
|
504
|
+
'Mission Settings',
|
|
505
505
|
mizObject,
|
|
506
|
-
|
|
506
|
+
15,
|
|
507
|
+
'0xffff00ff',
|
|
508
|
+
false
|
|
507
509
|
);
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
510
|
+
missionObject['trig'] = tuple.tObject;
|
|
511
|
+
missionObject['trigrules'] = tuple.trObject;
|
|
512
|
+
mapResourceObject = _.merge(mapResourceObject,tuple.mrObject);
|
|
513
|
+
mizObject = zipObject;
|
|
514
|
+
}
|
|
515
|
+
// réintégration du fichier mission dans l'archive
|
|
516
|
+
await ciObject.mizlib.injectMissionObjectIntoZipObject(
|
|
517
|
+
mizObject,
|
|
518
|
+
{ mission: missionObject }
|
|
519
|
+
);
|
|
520
|
+
await ciObject.mizlib.injectMapResourceObjectIntoZipObject(
|
|
521
|
+
mizObject,
|
|
522
|
+
{ mapResource: mapResourceObject }
|
|
523
|
+
);
|
|
524
|
+
// creation du fichier miz dans l'espace de travail
|
|
525
|
+
// await fs.closeSync(fs.openSync(destinationMizFilePath, 'a'));
|
|
526
|
+
// On fait une sauvegarde dans le folder de destination
|
|
527
|
+
fs.writeFileSync(destinationMizFilePath, await mizObject.generateAsync({
|
|
528
|
+
type: 'nodebuffer',
|
|
529
|
+
streamFiles: true,
|
|
530
|
+
compression: "DEFLATE",
|
|
531
|
+
compressionOptions: {
|
|
532
|
+
level: 9
|
|
533
|
+
}
|
|
534
|
+
}));
|
|
535
|
+
// generation des outils CI JTFF
|
|
536
|
+
await ciObject.deployCIScriptsFromZipObjectIntoWorkspace(workspacePath, mizObject, sourceMizFileName);
|
|
537
|
+
console.log('...Done...');
|
|
538
|
+
return 0;
|
|
524
539
|
}
|
|
525
540
|
|
|
526
|
-
module.exports = injectScripts;
|
|
541
|
+
module.exports = {injectScripts,createSkel, doInject};
|