Ensure correct button toggling, fix font loading

This commit is contained in:
Florine W. Dekker 2022-11-26 13:17:24 +01:00
parent 9843b24770
commit d2464e5505
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
4 changed files with 5 additions and 15 deletions

View File

@ -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",

View File

@ -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;

View File

@ -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;

View File

@ -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");