@@ -17,8 +17,9 @@ import assetsUtils from './assets';
17
17
import mathUtils from './math' ;
18
18
import reaperUtils from './reaper' ;
19
19
import subProcessUtils from './subProcess' ;
20
- import * as TypesAssetCsvStructure from '../types/AssetCsvStructure' ;
21
20
import configEmbed from './configEmbed' ;
21
+ import exitUtils from './exit' ;
22
+ import * as TypesAssetCsvStructure from '../types/AssetCsvStructure' ;
22
23
const execPromise = util . promisify ( child_process . exec ) ;
23
24
24
25
async function askToUserLiveId ( ) : Promise < number > {
@@ -51,6 +52,17 @@ async function askToUserLiveId(): Promise<number> {
51
52
} ) ) ,
52
53
} )
53
54
) . value ;
55
+ if ( ! argvUtils . getArgv ( ) . liveId ) process . stdout . write ( '\x1b[1A\x1b[2K' ) ;
56
+ console . log (
57
+ 'Selected live track: ' +
58
+ liveId +
59
+ ': ' +
60
+ chalk . bold . green (
61
+ db . text_data . find (
62
+ ( texEntry : any ) => texEntry . id === 16 && texEntry . category === 16 && texEntry . index === liveId ,
63
+ ) . text ,
64
+ ) ,
65
+ ) ;
54
66
if ( ! db . live_data . find ( ( entry : { [ key : string ] : any } ) => entry . music_id === liveId ) ) {
55
67
throw new Error ( `live '${ liveId } ' not found` ) ;
56
68
}
@@ -203,7 +215,6 @@ async function askToUserCharaId(
203
215
}
204
216
return retObj ;
205
217
} else {
206
- console . log ( `Available positions: ${ availablePositionArray . map ( ( el ) => chalk . bold . green ( el ) ) . join ( ', ' ) } ` ) ;
207
218
const retObj : Record < string , number | null > = {
208
219
left3 : null ,
209
220
left2 : null ,
@@ -213,15 +224,79 @@ async function askToUserCharaId(
213
224
right2 : null ,
214
225
right3 : null ,
215
226
} ;
216
- for ( let i = 0 ; i < availablePositionArray . length ; i ++ ) {
217
- const rsp = await questionBuilder ( availablePositionArray [ i ] ! , i > 0 ) ;
218
- if ( rsp !== - 1 ) {
219
- selectedCharaArray . push ( rsp ) ;
220
- retObj [ availablePositionArray [ i ] ! ] = rsp ;
221
- } else {
222
- i -= 2 ;
223
- process . stdout . write ( '\x1b[1A\x1b[2K\x1b[1A\x1b[2K' ) ;
227
+ while ( true ) {
228
+ const positionTargetIndex : number = (
229
+ await prompts (
230
+ {
231
+ type : 'select' ,
232
+ name : 'value' ,
233
+ message : `Map the chara to each position` ,
234
+ choices : ( ( ) => {
235
+ const _ = [
236
+ ...availablePositionArray . map ( ( str , index ) => ( {
237
+ title :
238
+ chalk . bold . cyan (
239
+ str . padEnd ( mathUtils . arrayMax ( availablePositionArray . map ( ( _ ) => _ . length ) ) , ' ' ) ,
240
+ ) +
241
+ ' - ' +
242
+ ( ! retObj [ str ]
243
+ ? chalk . bold . red ( 'Chara not selected' )
244
+ : `${ chalk . green ( retObj [ str ] ) } : ${ chalk . bold . green (
245
+ db . masterDb . text_data . find (
246
+ ( texEntry : any ) =>
247
+ texEntry . id === 6 && texEntry . category === 6 && texEntry . index === retObj [ str ] ,
248
+ ) . text ,
249
+ ) } `) ,
250
+ value : index ,
251
+ } ) ) ,
252
+ ] ;
253
+ if ( availablePositionArray . map ( ( str ) => retObj [ str ] ) . filter ( ( el ) => el === null ) . length === 0 ) {
254
+ _ . push ( {
255
+ title : chalk . bold . yellow ( '=== Finish selecting ===' ) ,
256
+ value : - 1 ,
257
+ } ) ;
258
+ }
259
+ return _ ;
260
+ } ) ( ) ,
261
+ } ,
262
+ {
263
+ onCancel : async ( ) => {
264
+ process . stdout . write ( '\x1b[1A\x1b[2K' ) ;
265
+ await exitUtils . pressAnyKeyToExit ( 1 ) ;
266
+ } ,
267
+ } ,
268
+ )
269
+ ) . value ;
270
+ process . stdout . write ( '\x1b[1A\x1b[2K' ) ;
271
+ if ( positionTargetIndex === - 1 ) {
272
+ break ;
224
273
}
274
+ retObj [ availablePositionArray [ positionTargetIndex ] ! ] = (
275
+ await prompts ( {
276
+ type : 'select' ,
277
+ name : 'value' ,
278
+ message : `Select singing chara for '${ availablePositionArray [ positionTargetIndex ] } ' position` ,
279
+ choices : [
280
+ ...liveCanUseCharaArray
281
+ // .filter((entry) => selectedCharaArray.includes(entry) === false) // to eliminate duplicates
282
+ . map ( ( entry ) => ( {
283
+ title :
284
+ entry +
285
+ ': ' +
286
+ db . masterDb . text_data . find (
287
+ ( texEntry : any ) => texEntry . id === 6 && texEntry . category === 6 && texEntry . index === entry ,
288
+ ) . text ,
289
+ description :
290
+ 'CV: ' +
291
+ db . masterDb . text_data . find (
292
+ ( texEntry : any ) => texEntry . id === 7 && texEntry . category === 7 && texEntry . index === entry ,
293
+ ) . text ,
294
+ value : entry ,
295
+ } ) ) ,
296
+ ] ,
297
+ } )
298
+ ) . value ;
299
+ process . stdout . write ( '\x1b[1A\x1b[2K' ) ;
225
300
}
226
301
return retObj ;
227
302
}
0 commit comments