refactor: resturcture files so that lincensing info can be bundled properly
This commit is contained in:
parent
699ba74840
commit
1aa284311f
484 changed files with 119 additions and 179 deletions
21
src/helpers.ts
Normal file
21
src/helpers.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
export function getCanvas(): Canvas {
|
||||
if (!(canvas instanceof Canvas) || !canvas.ready) {
|
||||
throw new Error(getGame().i18n.localize("DS4.ErrorCanvasIsNotInitialized"));
|
||||
}
|
||||
return canvas;
|
||||
}
|
||||
|
||||
export function getGame(): Game {
|
||||
if (!(game instanceof Game)) {
|
||||
throw new Error("Game is not initialized yet."); // Cannot localize this as we would need to access game to do this.
|
||||
}
|
||||
return game;
|
||||
}
|
||||
|
||||
export function getGameSafe(): Game | undefined {
|
||||
return game instanceof Game ? game : undefined;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue