Skip to content

Commit ed45055

Browse files
Slightly improved handling of character selection
1 parent 8ba2dee commit ed45055

File tree

5 files changed

+38
-41
lines changed

5 files changed

+38
-41
lines changed

src/cmd.ts

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ async function parseCommand() {
268268
.usage('$0 <command> [argument] [option]')
269269
.help()
270270
.alias('help', 'h')
271+
.alias('help', '?')
271272
.alias('version', 'V')
272273
.demandCommand(1)
273274
.strict()

src/utils/audioGenerate.ts

+30-23
Original file line numberDiff line numberDiff line change
@@ -140,30 +140,33 @@ async function askToUserCharaId(
140140
.filter((el) => el[1])
141141
.map((el) => el[0]);
142142
const selectedCharaArray: number[] = [];
143-
const questionBuilder = async (position: string) => {
143+
const questionBuilder = async (position: string, canBack: boolean = false) => {
144144
return (
145145
await prompts({
146146
type: 'select',
147147
name: 'value',
148148
message: `Select singing chara for '${position}' position`,
149-
choices: liveCanUseCharaArray
150-
// .filter((entry) => selectedCharaArray.includes(entry) === false) // to eliminate duplicates
151-
.map((entry) => ({
152-
title:
153-
entry +
154-
': ' +
155-
db.masterDb.text_data.find(
156-
(texEntry: any) => texEntry.id === 6 && texEntry.category === 6 && texEntry.index === entry,
157-
).text,
158-
description:
159-
'CV: ' +
160-
db.masterDb.text_data.find(
161-
(texEntry: any) => texEntry.id === 7 && texEntry.category === 7 && texEntry.index === entry,
162-
).text,
163-
value: entry,
164-
disabled: false,
165-
selected: false,
166-
})),
149+
choices: [
150+
...liveCanUseCharaArray
151+
// .filter((entry) => selectedCharaArray.includes(entry) === false) // to eliminate duplicates
152+
.map((entry) => ({
153+
title:
154+
entry +
155+
': ' +
156+
db.masterDb.text_data.find(
157+
(texEntry: any) => texEntry.id === 6 && texEntry.category === 6 && texEntry.index === entry,
158+
).text,
159+
description:
160+
'CV: ' +
161+
db.masterDb.text_data.find(
162+
(texEntry: any) => texEntry.id === 7 && texEntry.category === 7 && texEntry.index === entry,
163+
).text,
164+
value: entry,
165+
disabled: false,
166+
selected: false,
167+
})),
168+
{ title: '=== Go Back ===', value: -1, disabled: !canBack, selected: false },
169+
],
167170
})
168171
).value;
169172
};
@@ -198,7 +201,6 @@ async function askToUserCharaId(
198201
retObj[position] = argParsed[i]!;
199202
selectedCharaArray.push(argParsed[i]!);
200203
}
201-
202204
return retObj;
203205
} else {
204206
console.log(`Available positions: ${availablePositionArray.map((el) => chalk.bold.green(el)).join(', ')}`);
@@ -212,9 +214,14 @@ async function askToUserCharaId(
212214
right3: null,
213215
};
214216
for (let i = 0; i < availablePositionArray.length; i++) {
215-
const rsp = await questionBuilder(availablePositionArray[i]!);
216-
selectedCharaArray.push(rsp);
217-
retObj[availablePositionArray[i]!] = rsp;
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');
224+
}
218225
}
219226
return retObj;
220227
}

src/utils/exit.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ async function pressAnyKeyToExit(errorCode: number): Promise<void> {
2222
});
2323
}
2424

25-
async function pressAnyKeyToContinue(): Promise<void> {
26-
process.stdout.write('Press any key to continue ...');
25+
async function pressAnyKeyToContinue(printText: boolean = true): Promise<void> {
26+
printText ? process.stdout.write('Press any key to continue ...') : null;
2727
return new Promise((resolve) => {
2828
readline.emitKeypressEvents(process.stdin);
2929
process.stdin.setRawMode(true);
3030
process.stdin.resume();
3131
process.stdin.once('data', () => {
3232
process.stdin.setRawMode(false);
3333
process.stdin.pause();
34-
process.stdout.write(`\n`);
34+
printText ? process.stdout.write(`\n`) : null;
3535
resolve(); // Promiseを解決
3636
});
3737
});

src/utils/httpServer.ts

+4-13
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,13 @@ async function main() {
1111
const app = new Hono();
1212
const port = 54348;
1313

14-
// カスタム静的ファイルミドルウェア
1514
app.use('/*', async (c, next) => {
1615
const requestPath = c.req.path;
1716
const normalizedPath = requestPath.replace(/^\/+/, '').replace(/\/+/g, '/');
1817
const filePath = path.join('./output', normalizedPath);
19-
2018
if (await bun.file(filePath).exists()) {
2119
try {
22-
const file = bun.file(filePath);
23-
if (await file.exists()) {
24-
const mimeType = getMimeType(path.extname(filePath)) || 'text/plain';
25-
// logger.trace(file, mimeType);
26-
return new Response(file);
27-
}
20+
return new Response(bun.file(filePath));
2821
} catch (error) {
2922
logger.warn(`Error serving file: ${filePath}`, error);
3023
}
@@ -34,17 +27,15 @@ async function main() {
3427
return c.notFound();
3528
});
3629

37-
// サーバー起動
3830
const server = bun.serve({
3931
port,
4032
fetch: app.fetch,
4133
});
4234

43-
const targetUrl = `http://localhost:${port}/db/handbook.html`;
44-
logger.debug(`HTTP server running at ${targetUrl}`);
45-
await open(targetUrl);
35+
logger.debug(`HTTP server running at localhost:${port}`);
36+
await open(`http://localhost:${port}/db/handbook.html`);
4637
logger.debug('Press any key to close the server...');
47-
await exitUtils.pressAnyKeyToContinue();
38+
await exitUtils.pressAnyKeyToContinue(false);
4839
server.stop();
4940
}
5041

src/utils/reaper.ts

-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ async function tr5StealthLimiter_runPlugin(
217217
await tr5StealthLimiter_preparePost(preparePreResult);
218218
}
219219

220-
function showDoNotTouchText() {}
221-
222220
export default {
223221
reaperCleaning,
224222
tr5StealthLimiter_runPlugin,

0 commit comments

Comments
 (0)