|
@@ -177,6 +177,7 @@ class TypingPlayingScreen implements Screen {
|
|
currentIndex: number;
|
|
currentIndex: number;
|
|
inputState: kana.KanaInputState | null;
|
|
inputState: kana.KanaInputState | null;
|
|
isWaiting: boolean;
|
|
isWaiting: boolean;
|
|
|
|
+ skippable: boolean;
|
|
kanjiElement: HTMLElement;
|
|
kanjiElement: HTMLElement;
|
|
kanaController: display.KanaDisplayController;
|
|
kanaController: display.KanaDisplayController;
|
|
romajiController: display.RomajiDisplayController;
|
|
romajiController: display.RomajiDisplayController;
|
|
@@ -189,6 +190,7 @@ class TypingPlayingScreen implements Screen {
|
|
this.currentIndex = -1;
|
|
this.currentIndex = -1;
|
|
this.inputState = null;
|
|
this.inputState = null;
|
|
this.isWaiting = false;
|
|
this.isWaiting = false;
|
|
|
|
+ this.skippable = false;
|
|
this.kanjiElement = util.getElement(this.gameContainer, '.kanji-line');
|
|
this.kanjiElement = util.getElement(this.gameContainer, '.kanji-line');
|
|
this.romajiController = new display.RomajiDisplayController(
|
|
this.romajiController = new display.RomajiDisplayController(
|
|
util.getElement(this.gameContainer, '.romaji-first'),
|
|
util.getElement(this.gameContainer, '.romaji-first'),
|
|
@@ -231,15 +233,21 @@ class TypingPlayingScreen implements Screen {
|
|
this.onStart();
|
|
this.onStart();
|
|
}
|
|
}
|
|
|
|
|
|
- setWaiting(waiting: boolean): void {
|
|
|
|
- this.gameContainer.classList.toggle('waiting', waiting);
|
|
|
|
|
|
+ get currentLine() {
|
|
|
|
+ return this.lines[this.currentIndex];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setWaiting(waiting: boolean, skippable: boolean = false): void {
|
|
this.isWaiting = waiting;
|
|
this.isWaiting = waiting;
|
|
|
|
+ this.skippable = waiting && skippable;
|
|
|
|
+ this.gameContainer.classList.toggle('waiting', this.isWaiting);
|
|
|
|
+ this.gameContainer.classList.toggle('skippable', this.skippable);
|
|
}
|
|
}
|
|
|
|
|
|
onStart(): void {
|
|
onStart(): void {
|
|
this.nextLine();
|
|
this.nextLine();
|
|
if (this.context.track !== null) {
|
|
if (this.context.track !== null) {
|
|
- this.context.track.play();
|
|
|
|
|
|
+ this.context.track.start(0);
|
|
}
|
|
}
|
|
|
|
|
|
this.setWaiting(false);
|
|
this.setWaiting(false);
|
|
@@ -247,7 +255,7 @@ class TypingPlayingScreen implements Screen {
|
|
}
|
|
}
|
|
|
|
|
|
checkComplete(): void {
|
|
checkComplete(): void {
|
|
- let currentLine = this.lines[this.currentIndex];
|
|
|
|
|
|
+ let currentLine = this.currentLine;
|
|
if (
|
|
if (
|
|
currentLine != null &&
|
|
currentLine != null &&
|
|
currentLine.kana == '@' &&
|
|
currentLine.kana == '@' &&
|
|
@@ -276,7 +284,14 @@ class TypingPlayingScreen implements Screen {
|
|
this.scoreController.intervalEnd(true);
|
|
this.scoreController.intervalEnd(true);
|
|
}
|
|
}
|
|
if (this.context.track !== null) {
|
|
if (this.context.track !== null) {
|
|
- this.setWaiting(true);
|
|
|
|
|
|
+ // skippable if the last line was empty and the current line is longer
|
|
|
|
+ // than 3 seconds
|
|
|
|
+ const lastLine = this.lines[this.currentIndex - 1];
|
|
|
|
+ const skippable =
|
|
|
|
+ autoComplete &&
|
|
|
|
+ lastLine !== undefined &&
|
|
|
|
+ lastLine.end! - lastLine.start! > 3;
|
|
|
|
+ this.setWaiting(true, skippable);
|
|
} else {
|
|
} else {
|
|
if (this.currentIndex >= this.lines.length) {
|
|
if (this.currentIndex >= this.lines.length) {
|
|
this.finish();
|
|
this.finish();
|
|
@@ -287,12 +302,18 @@ class TypingPlayingScreen implements Screen {
|
|
handleInput(key: string): void {
|
|
handleInput(key: string): void {
|
|
if (key === 'Escape' || key === 'Backspace') {
|
|
if (key === 'Escape' || key === 'Backspace') {
|
|
this.finish();
|
|
this.finish();
|
|
|
|
+ return;
|
|
} else if (!this.isWaiting) {
|
|
} else if (!this.isWaiting) {
|
|
if (this.inputState !== null && /^[-_ a-z]$/.test(key)) {
|
|
if (this.inputState !== null && /^[-_ a-z]$/.test(key)) {
|
|
if (this.inputState.handleInput(key)) {
|
|
if (this.inputState.handleInput(key)) {
|
|
this.onComplete();
|
|
this.onComplete();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else if (this.skippable && key === 'Tab' && this.context.track !== null) {
|
|
|
|
+ const start = this.currentLine.start!;
|
|
|
|
+ if (start - this.context.track.getTime() > 3) {
|
|
|
|
+ this.context.track.start(start - 1.5);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -337,6 +358,7 @@ class TypingPlayingScreen implements Screen {
|
|
exit(): void {}
|
|
exit(): void {}
|
|
|
|
|
|
transitionExit(): void {
|
|
transitionExit(): void {
|
|
|
|
+ this.gameContainer.classList.remove('skippable');
|
|
this.kanaController.destroy();
|
|
this.kanaController.destroy();
|
|
this.romajiController.destroy();
|
|
this.romajiController.destroy();
|
|
if (this.context.track !== null) {
|
|
if (this.context.track !== null) {
|