Skip to content

Commit

Permalink
Refactor font loading in Narrator.ts and optimize tome initialization…
Browse files Browse the repository at this point in the history
… in Wonderlost.ts
  • Loading branch information
Abourass committed Sep 20, 2024
1 parent a4f9c8e commit 4cc0a8f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 42 deletions.
2 changes: 1 addition & 1 deletion dist/submodules/narrator/Narrator.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/wonderlost.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/wonderlost.mjs.map

Large diffs are not rendered by default.

43 changes: 4 additions & 39 deletions src/submodules/narrator/Narrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,45 +238,10 @@ export class Narrator extends Tome {
super({
moduleName: "Narrator",
moduleDescription: "An extremely customizable on screen narrator system",
hooks: new Map([
['ready', async (app, data) => {

await this.setup();
// Load some essential fonts we use in PIXI
await FontsLoader({
custom: {
families: [Narrator.titleFont, Narrator.textFont],
},
});

if (this.DEBUG) {
consola.success(`${this.moduleName} | Fonts loaded`, this);
}

const otherFonts = Narrator.fonts.filter(font =>
font !== Narrator.titleFont && font !== Narrator.textFont
);
// Define a reusable font loading function
const loadFonts = async (fonts: string[]): Promise<void> => {
await FontsLoader({
custom: {
families: fonts,
},
});
};

// Load other fonts asynchronously
await loadFonts(otherFonts);
},
[
'renderScene', async (app, data) => {
if (this.ready) {
this.render()
}
}
]
]
]),
// hooks: new Map([
// ['ready', async () => { await this.setup(); }],
// ['renderScene', async () => { if (this.ready) { this.render() } }]
// ]),
socketFns: new Map([]),
DEBUG
})
Expand Down

0 comments on commit 4cc0a8f

Please sign in to comment.