Skip to content
Snippets Groups Projects
Commit 4df82232 authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

fix: #fe patch typewriter activation handling

parent f67c4af2
No related branches found
No related tags found
No related merge requests found
...@@ -428,15 +428,8 @@ export default class FightScene extends Phaser.Scene { ...@@ -428,15 +428,8 @@ export default class FightScene extends Phaser.Scene {
} }
createAndBindTypewriter() { createAndBindTypewriter() {
this.typewriter ??= new Typewriter(); this.typewriter ??= new Typewriter(this.game.device.os.desktop);
this.typewriter.setActive(true); this.typewriter.setActive(true);
if (this.game.device.os.desktop) {
this.typewriter.setHidden(true);
this.typewriter.setShiftModeHoldable();
} else {
this.typewriter.setHidden(false);
this.typewriter.setShiftModeOneShot();
}
this.typewriter.getGameTime = this.getGameTime.bind(this); this.typewriter.getGameTime = this.getGameTime.bind(this);
this.typewriter.onSubmit = async (inputStatus) => { this.typewriter.onSubmit = async (inputStatus) => {
if (inputStatus.began_at === null) return; if (inputStatus.began_at === null) return;
......
...@@ -113,15 +113,17 @@ const hackPhysicalKeyboardKeyUp = function (event: KeyboardEvent) { ...@@ -113,15 +113,17 @@ const hackPhysicalKeyboardKeyUp = function (event: KeyboardEvent) {
class Typewriter { class Typewriter {
inputStatus: InputStatus; inputStatus: InputStatus;
keyboard: Keyboard; keyboard: Keyboard;
desktop: boolean;
onChange: (inputStatus: InputStatus) => unknown; onChange: (inputStatus: InputStatus) => unknown;
onSubmit: (inputStatus: InputStatus) => unknown; onSubmit: (inputStatus: InputStatus) => unknown;
getGameTime: () => number; // NOTE: sigh. getGameTime: () => number; // NOTE: sigh.
constructor() { constructor(desktop: boolean) {
this.onChange = () => {}; this.onChange = () => {};
this.onSubmit = () => {}; this.onSubmit = () => {};
this.desktop = desktop;
this.inputStatus = { this.inputStatus = {
began_at: null, began_at: null,
ended_at: null, ended_at: null,
...@@ -133,8 +135,8 @@ class Typewriter { ...@@ -133,8 +135,8 @@ class Typewriter {
this.keyboard = new Keyboard({ this.keyboard = new Keyboard({
// debug: true, // debug: true,
physicalKeyboardHighlight: true, // physicalKeyboardHighlight: true,
physicalKeyboardHighlightPress: true, // physicalKeyboardHighlightPress: true,
// autoUseTouchEvents: true, // autoUseTouchEvents: true,
newLineOnEnter: true, newLineOnEnter: true,
disableCaretPositioning: true, disableCaretPositioning: true,
...@@ -160,6 +162,12 @@ class Typewriter { ...@@ -160,6 +162,12 @@ class Typewriter {
onChange: this.keyboardOnChangeHandler.bind(this), onChange: this.keyboardOnChangeHandler.bind(this),
} as KeyboardOptions); } as KeyboardOptions);
if (this.desktop) {
this.setShiftModeHoldable();
} else {
this.setShiftModeOneShot();
}
this.keyboard.physicalKeyboard.handleHighlightKeyUp = this.keyboard.physicalKeyboard.handleHighlightKeyUp =
hackPhysicalKeyboardKeyUp; hackPhysicalKeyboardKeyUp;
} }
...@@ -227,18 +235,14 @@ class Typewriter { ...@@ -227,18 +235,14 @@ class Typewriter {
setActive(active: boolean) { setActive(active: boolean) {
// disables physical kbd on desktop // disables physical kbd on desktop
this.keyboard.setOptions({ this.keyboard.setOptions({
physicalKeyboardHighlight: active, physicalKeyboardHighlight: active && this.desktop,
physicalKeyboardHighlightPress: active, physicalKeyboardHighlightPress: active && this.desktop,
} as KeyboardOptions); } as KeyboardOptions);
// hides virtual kbd on mobile // hides virtual kbd on mobile
this.setHidden(!active); this.keyboard.keyboardDOM.hidden = !(active && !this.desktop);
// NOTE: this is not really disabled at event level, but events can't be triggered // NOTE: this is not really disabled at event level, but events can't be triggered
} }
setHidden(hidden: boolean) {
this.keyboard.keyboardDOM.hidden = hidden;
}
setShiftModeHoldable() { setShiftModeHoldable() {
this.keyboard.setOptions({ this.keyboard.setOptions({
onKeyPress: (key: string) => { onKeyPress: (key: string) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment