mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-29 04:07:09 +00:00
bac6c22973
* eslint config + packages * updated eslint config * fix the issue eslint adding ;;;; at interfaces * first round with eslint --fix . * removed config for unused export * Revert "first round with eslint --fix ." This reverts commit 77a88e0895f7c3389cb223651b90d918af778fe9. * removed config for camelCase * for real this time, first round of eslint --fix . * halfway to manual eslint fix * eslint done * added "how to setup" the hook to eslint --fix each new file before commit (if wanted) * removed eslintrc config file duplicat * fix human error + ignore build folder + merge overrides * added curly brace style + eslint * applied double quote linter rule * added lefthook * test precommit * test precommit * test precommit * test precommit * test precommit * test precommit * test precommit * github action to run eslint * added node_modules to ignore eslint * different action for typescript * no need for different glob (default src) * node 20 * node 20 * removed no longer needed install file * remove hooks part from README * eslint fixes --------- Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt>
82 lines
2.5 KiB
TypeScript
82 lines
2.5 KiB
TypeScript
export const legacyCompatibleImages: string[] = [];
|
|
|
|
export class SceneBase extends Phaser.Scene {
|
|
constructor(config?: string | Phaser.Types.Scenes.SettingsConfig) {
|
|
super(config);
|
|
}
|
|
|
|
getCachedUrl(url: string): string {
|
|
const manifest = this.game["manifest"];
|
|
if (manifest) {
|
|
const timestamp = manifest[`/${url}`];
|
|
if (timestamp) {
|
|
url += `?t=${timestamp}`;
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
|
|
loadImage(key: string, folder: string, filename?: string) {
|
|
if (!filename) {
|
|
filename = `${key}.png`;
|
|
}
|
|
this.load.image(key, this.getCachedUrl(`images/${folder}/${filename}`));
|
|
if (folder.startsWith("ui")) {
|
|
legacyCompatibleImages.push(key);
|
|
folder = folder.replace("ui", "ui/legacy");
|
|
this.load.image(`${key}_legacy`, this.getCachedUrl(`images/${folder}/${filename}`));
|
|
}
|
|
}
|
|
|
|
loadSpritesheet(key: string, folder: string, size: integer, filename?: string) {
|
|
if (!filename) {
|
|
filename = `${key}.png`;
|
|
}
|
|
this.load.spritesheet(key, this.getCachedUrl(`images/${folder}/${filename}`), { frameWidth: size, frameHeight: size });
|
|
if (folder.startsWith("ui")) {
|
|
legacyCompatibleImages.push(key);
|
|
folder = folder.replace("ui", "ui/legacy");
|
|
this.load.spritesheet(`${key}_legacy`, this.getCachedUrl(`images/${folder}/${filename}`), { frameWidth: size, frameHeight: size });
|
|
}
|
|
}
|
|
|
|
loadAtlas(key: string, folder: string, filenameRoot?: string) {
|
|
if (!filenameRoot) {
|
|
filenameRoot = key;
|
|
}
|
|
if (folder) {
|
|
folder += "/";
|
|
}
|
|
this.load.atlas(key, this.getCachedUrl(`images/${folder}${filenameRoot}.png`), this.getCachedUrl(`images/${folder}/${filenameRoot}.json`));
|
|
if (folder.startsWith("ui")) {
|
|
legacyCompatibleImages.push(key);
|
|
folder = folder.replace("ui", "ui/legacy");
|
|
this.load.atlas(`${key}_legacy`, this.getCachedUrl(`images/${folder}${filenameRoot}.png`), this.getCachedUrl(`images/${folder}/${filenameRoot}.json`));
|
|
}
|
|
}
|
|
|
|
loadSe(key: string, folder?: string, filenames?: string | string[]) {
|
|
if (!filenames) {
|
|
filenames = `${key}.wav`;
|
|
}
|
|
if (!folder) {
|
|
folder = "";
|
|
} else {
|
|
folder += "/";
|
|
}
|
|
if (!Array.isArray(filenames)) {
|
|
filenames = [ filenames ];
|
|
}
|
|
for (const f of filenames as string[]) {
|
|
this.load.audio(key, this.getCachedUrl(`audio/se/${folder}${f}`));
|
|
}
|
|
}
|
|
|
|
loadBgm(key: string, filename?: string) {
|
|
if (!filename) {
|
|
filename = `${key}.mp3`;
|
|
}
|
|
this.load.audio(key, this.getCachedUrl(`audio/bgm/${filename}`));
|
|
}
|
|
}
|