Ensure correct button toggling, fix font loading
This commit is contained in:
parent
9843b24770
commit
d2464e5505
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minesweeper",
|
||||
"version": "0.83.1",
|
||||
"version": "0.83.2",
|
||||
"description": "Just Minesweeper!",
|
||||
"author": "Florine W. Dekker",
|
||||
"browser": "dist/bundle.js",
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
import alea from "alea";
|
||||
|
||||
|
||||
/**
|
||||
* Removes focus from the currently active element, if possible.
|
||||
*/
|
||||
export function blurActiveElement(): void {
|
||||
// @ts-ignore
|
||||
document.activeElement?.blur?.();
|
||||
}
|
||||
|
||||
/**
|
||||
* Slices `array` into chunks of `chunkSize` elements each.
|
||||
*
|
||||
|
@ -110,7 +102,7 @@ export function waitForForkAwesome(onSuccess: () => void, onFailure: () => void,
|
|||
const ctx = canvas.getContext("2d")!;
|
||||
const fontSize = 36;
|
||||
const testCharacter = "\uF047";
|
||||
const targetPixelCount = 500;
|
||||
const targetPixelCount = 528; // Found by doing lots of trials
|
||||
|
||||
const ccw = canvas.width = fontSize * 1.5;
|
||||
const cch = canvas.height = fontSize * 1.5;
|
||||
|
|
|
@ -360,8 +360,8 @@ export class Game {
|
|||
|
||||
toggleHref(this.undo, !!this.field?.canUndo());
|
||||
toggleHref(this.redo, !!this.field?.canRedo());
|
||||
toggleHref(this.hint, !this.field?.isOver);
|
||||
toggleHref(this.solve, !this.field?.isOver);
|
||||
toggleHref(this.hint, !!this.field?.hasStarted && !this.field?.isOver);
|
||||
toggleHref(this.solve, !!this.field?.hasStarted && !this.field?.isOver);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -399,6 +399,7 @@ export class Game {
|
|||
);
|
||||
this.display.setField(this.field);
|
||||
this.field.addEventListener(() => this.updateControls());
|
||||
this.updateControls();
|
||||
|
||||
// Start timer for statistics
|
||||
let lastTime: number | null = null;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
const {$} = (window as any).fwdekker;
|
||||
|
||||
import {blurActiveElement} from "./Common";
|
||||
|
||||
|
||||
/**
|
||||
* A modal dialog displayed in HTML.
|
||||
|
@ -100,7 +98,6 @@ export class ModalDialog {
|
|||
* Opens the dialog.
|
||||
*/
|
||||
open(): void {
|
||||
blurActiveElement();
|
||||
setTimeout(() => $("[autofocus]", this.dialog)?.focus(), 100);
|
||||
|
||||
this.dialog.setAttribute("open", "true");
|
||||
|
|
Loading…
Reference in New Issue