Skip to content

Commit 642a7e8

Browse files
Update version to 0.2.0 and add deepmerge dependency; enhance character selection logic
1 parent 6da78d0 commit 642a7e8

File tree

5 files changed

+99
-13
lines changed

5 files changed

+99
-13
lines changed

bun.lock

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"clear": "^0.1.0",
1515
"cli-progress": "^3.12.0",
1616
"clui": "^0.3.6",
17+
"deepmerge": "^4.3.1",
1718
"figlet": "^1.8.0",
1819
"fluent-ffmpeg": "^2.1.3",
1920
"hono": "^4.7.7",
@@ -236,6 +237,8 @@
236237

237238
"deep-extend": ["[email protected]", "", {}, "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA=="],
238239

240+
"deepmerge": ["[email protected]", "", {}, "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="],
241+
239242
"default-browser": ["[email protected]", "", { "dependencies": { "bundle-name": "^4.1.0", "default-browser-id": "^5.0.0" } }, "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg=="],
240243

241244
"default-browser-id": ["[email protected]", "", {}, "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA=="],

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uma-db-stuff",
3-
"version": "0.1.2",
3+
"version": "0.2.0",
44
"description": "A set of experimental scripts to process Umamusume Pretty Derby game assets and database files",
55
"author": "daydreamer-json <[email protected]> (https://github.com/daydreamer-json)",
66
"license": "AGPL-3.0-or-later",
@@ -45,6 +45,7 @@
4545
"clear": "^0.1.0",
4646
"cli-progress": "^3.12.0",
4747
"clui": "^0.3.6",
48+
"deepmerge": "^4.3.1",
4849
"figlet": "^1.8.0",
4950
"fluent-ffmpeg": "^2.1.3",
5051
"hono": "^4.7.7",

src/utils/audioGenerate.ts

+85-10
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import assetsUtils from './assets';
1717
import mathUtils from './math';
1818
import reaperUtils from './reaper';
1919
import subProcessUtils from './subProcess';
20-
import * as TypesAssetCsvStructure from '../types/AssetCsvStructure';
2120
import configEmbed from './configEmbed';
21+
import exitUtils from './exit';
22+
import * as TypesAssetCsvStructure from '../types/AssetCsvStructure';
2223
const execPromise = util.promisify(child_process.exec);
2324

2425
async function askToUserLiveId(): Promise<number> {
@@ -51,6 +52,17 @@ async function askToUserLiveId(): Promise<number> {
5152
})),
5253
})
5354
).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+
);
5466
if (!db.live_data.find((entry: { [key: string]: any }) => entry.music_id === liveId)) {
5567
throw new Error(`live '${liveId}' not found`);
5668
}
@@ -203,7 +215,6 @@ async function askToUserCharaId(
203215
}
204216
return retObj;
205217
} else {
206-
console.log(`Available positions: ${availablePositionArray.map((el) => chalk.bold.green(el)).join(', ')}`);
207218
const retObj: Record<string, number | null> = {
208219
left3: null,
209220
left2: null,
@@ -213,15 +224,79 @@ async function askToUserCharaId(
213224
right2: null,
214225
right3: null,
215226
};
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;
224273
}
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');
225300
}
226301
return retObj;
227302
}

src/utils/configEmbed.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import semver from 'semver';
22

33
export default {
44
APPLICATION_NAME: 'uma-db-stuff',
5-
VERSION_NUMBER: semver.valid('0.1.2'),
5+
VERSION_NUMBER: semver.valid('0.2.0'),
66
};

src/utils/configUser.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import bun from 'bun';
22
import path from 'node:path';
33
import YAML from 'yaml';
4+
import deepmerge from 'deepmerge';
45

56
type Freeze<T> = Readonly<{
67
[P in keyof T]: T[P] extends object ? Freeze<T[P]> : T[P];
@@ -26,6 +27,7 @@ type ConfigType = AllRequired<{
2627
};
2728
};
2829
audio: {
30+
useCheersInst: boolean; // Whether to include audience cheers in the live audio
2931
targetLoudness: number; // Target for volume normalization during winning live audio generation
3032
volumeCompensation: {
3133
//! Probably still does not work
@@ -53,6 +55,7 @@ const initialConfig: ConfigType = {
5355
},
5456
},
5557
audio: {
58+
useCheersInst: false,
5659
targetLoudness: -7.2,
5760
volumeCompensation: {
5861
inst: 0.0,
@@ -71,7 +74,11 @@ if ((await bun.file(filePath).exists()) === false) {
7174

7275
let config: ConfigType = await (async () => {
7376
const rawFileData: ConfigType = YAML.parse(await bun.file(filePath).text()) as ConfigType;
74-
return rawFileData;
77+
const mergedConfig = deepmerge(initialConfig, rawFileData);
78+
if (JSON.stringify(rawFileData) !== JSON.stringify(mergedConfig)) {
79+
await bun.write(filePath, YAML.stringify(mergedConfig, null, 2));
80+
}
81+
return mergedConfig;
7582
})();
7683

7784
export default {

0 commit comments

Comments
 (0)