Skip to content

Commit

Permalink
fix: load special effect files lazily
Browse files Browse the repository at this point in the history
With this change, special effect files are only loaded when the preview box is hovered or when the
effect is actually played. Nothing is loaded automatically, not even the metadata. This should help
to improve the experience when using lot's of special effects such as when using the effects from
JB2A.

Closes #209
  • Loading branch information
ghost91- committed Feb 20, 2022
1 parent 64472c2 commit ca4f399
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/fxmaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FXMASTER } from "./config.js";
import { WeatherLayer } from "./weatherEffects/WeatherLayer.js";
import { filterManager } from "./filterEffects/FilterManager.js";
import { executeWhenWorldIsMigratedToLatest, isOnTargetMigration, migrate } from "./migration.js";
import { SpecialsConfig } from "./specialEffects/applications/specials-config.js";
import { SpecialsLayer } from "./specialEffects/SpecialsLayer.js";
import { registerHelpers } from "./helpers.js";
import { registerGetSceneControlButtonsHook } from "./controls.js";
Expand Down Expand Up @@ -188,6 +189,11 @@ Hooks.on("updateSetting", (data) => {
if (data.data.key === "fxmaster.specialEffects") {
parseSpecialEffects();
}
Object.values(ui.windows).forEach((w) => {
if (w instanceof SpecialsConfig) {
w.render(false);
}
});
});

Hooks.on("renderDrawingHUD", (hud, html, data) => {
Expand Down
2 changes: 1 addition & 1 deletion src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ export const registerSettings = function () {
});
};

export const debouncedReload = foundry.utils.debounce(() => {
const debouncedReload = foundry.utils.debounce(() => {
window.location.reload();
}, 100);
4 changes: 1 addition & 3 deletions src/specialEffects/applications/specials-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ export class SpecialsConfig extends Application {
return;
}
settings.splice(id, 1);
game.settings.set(packageId, "specialEffects", settings).then(() => {
this.render(true);
});
game.settings.set(packageId, "specialEffects", settings);
});

html.find(".edit-effect").click((ev) => {
Expand Down
15 changes: 4 additions & 11 deletions src/specialEffects/applications/specials-create.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SpecialsConfig } from "./specials-config.js";
import { easeFunctions } from "../../ease.js";
import { packageId } from "../../constants.js";

Expand Down Expand Up @@ -79,10 +78,10 @@ export class SpecialCreate extends FormApplication {
/**
* This method is called upon form submission after form data is validated
* @param event {Event} The initial triggering submission event
* @param formData {Object} The object of validated form data with which to update the object
* @private
* @param formData {object} The object of validated form data with which to update the object
* @protected
*/
_updateObject(_, formData) {
async _updateObject(_, formData) {
const fxs = game.settings.get(packageId, "specialEffects");

const newData = {
Expand Down Expand Up @@ -113,12 +112,6 @@ export class SpecialCreate extends FormApplication {
} else {
fxs.push(newData);
}
game.settings.set(packageId, "specialEffects", fxs).then(() => {
Object.values(ui.windows).forEach((w) => {
if (w instanceof SpecialsConfig) {
w.render();
}
});
});
await game.settings.set(packageId, "specialEffects", fxs);
}
}
2 changes: 1 addition & 1 deletion templates/specials-config.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{{#each folder.effects as |effect effectId|}}
<li class="directory-item entity flexrow special-effects" data-effect-id="{{effectId}}" draggable="true">
<div class="preview">
<video width="46" height="46" muted>
<video preload="none" width="46" height="46" muted>
<source src="{{effect.file}}">
</video>
</div>
Expand Down

0 comments on commit ca4f399

Please sign in to comment.