diff --git a/srcjs/stendhal/ui/ViewPort.ts b/srcjs/stendhal/ui/ViewPort.ts index b41c129e7f..52e6e7db01 100644 --- a/srcjs/stendhal/ui/ViewPort.ts +++ b/srcjs/stendhal/ui/ViewPort.ts @@ -81,12 +81,22 @@ export class ViewPort { * Hidden singleton constructor. */ private constructor() { - const element = document.getElementById("gamewindow")! as HTMLCanvasElement; + const element = this.getElement() as HTMLCanvasElement; this.ctx = element.getContext("2d")!; this.width = element.width; this.height = element.height; } + /** + * Retrieves the viewport element. + * + * @return + * Viewport `HTMLElement`. + */ + public getElement(): HTMLElement { + return document.getElementById("gamewindow")!; + } + draw() { var startTime = new Date().getTime(); @@ -442,7 +452,7 @@ export class ViewPort { var x = pos.canvasRelativeX + stendhal.ui.gamewindow.offsetX; var y = pos.canvasRelativeY + stendhal.ui.gamewindow.offsetY; var entity = stendhal.zone.entityAt(x, y); - document.getElementById("gamewindow")!.style.cursor = entity.getCursor(x, y); + this.getElement().style.cursor = entity.getCursor(x, y); } /**