Skip to content

Commit 1fd7b61

Browse files
committed
fix: fixed background and music order in project.json
1 parent 4a1b901 commit 1fd7b61

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

packages/background/index.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ const DEFAULT_BACKGROUND_FILE = path.join(
1616
)
1717

1818
const getFiles = () => {
19-
return file.readdirSync(DIST_DIR)
19+
const ret = file.readdirSync(DIST_DIR)
20+
ret.unshift(
21+
ret.splice(
22+
ret.findIndex(
23+
(e) => e === config.module.background.operator_bg_png
24+
),
25+
1
26+
)[0]
27+
)
28+
return ret
2029
}
2130

2231
export let files = getFiles()

packages/project-json/index.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,27 @@ import { getLangs } from '@aklive2d/charword-table'
1010
const DIST_DIR = path.join(import.meta.dirname, config.dir_name.dist)
1111

1212
export const build = (namesToBuild) => {
13+
const err = []
1314
const names = !namesToBuild.length ? Object.keys(operators) : namesToBuild
1415
console.log('Generating assets for', names.length, 'operators')
16+
const musicMapping = []
17+
// sort music mapping based on background file order
18+
for (const item of backgrounds) {
19+
if (musics.musicFileMapping[item]) {
20+
musicMapping.push(item)
21+
} else {
22+
err.push(
23+
`Music folder doesn't contain music for ${item} background.`
24+
)
25+
}
26+
}
1527
for (const name of names) {
1628
const { voiceLangs, subtitleLangs } = getLangs(name)
1729
load(name, {
1830
backgrounds,
1931
voiceLangs,
2032
subtitleLangs,
21-
music: Object.keys(musics.musicFileMapping),
33+
music: musicMapping,
2234
})
2335
file.symlink(
2436
path.join(
@@ -28,6 +40,7 @@ export const build = (namesToBuild) => {
2840
path.join(getDistDir(name), config.module.project_json.preview_jpg)
2941
)
3042
}
43+
return err
3144
}
3245

3346
const getDistDir = (name) => {

packages/project-json/runner.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { envParser } from '@aklive2d/libs'
1+
import { envParser, error } from '@aklive2d/libs'
22
import { build } from './index.js'
33

44
async function main() {
5+
let err = []
56
const { mode, name } = envParser.parse({
67
mode: {
78
type: 'string',
@@ -16,11 +17,12 @@ async function main() {
1617
})
1718
switch (mode) {
1819
case 'build':
19-
build(name)
20+
err = build(name)
2021
break
2122
default:
2223
throw new Error(`Unknown mode: ${mode}`)
2324
}
25+
error.handle(err)
2426
}
2527

2628
main()

0 commit comments

Comments
 (0)