Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V12 support #189

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added artwork/thumbnails/galaxy-map-thumb.webp
Binary file not shown.
Binary file added artwork/thumbnails/hyperspace-thumb.webp
Binary file not shown.
Binary file added artwork/thumbnails/podracing-thumb.webp
Binary file not shown.
Binary file added artwork/thumbnails/ship-hyperspace-thumb.webp
Binary file not shown.
Binary file added artwork/thumbnails/ship-space-thumb.webp
Binary file not shown.
Binary file added artwork/thumbnails/space-combat-thumb.webp
Binary file not shown.
5 changes: 2 additions & 3 deletions ffg-star-wars-enhancements.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Hooks.once("init", async function () {
log("base_module", "Initializing finished");
});

Hooks.once("ready", () => {
Hooks.once("ready", async () => {
/* register functionality here */
attack_animation_check();
opening_crawl_ready();
Expand All @@ -106,7 +106,7 @@ Hooks.once("ready", () => {
dice_helper();
talent_checker();
register_hooks();
dice_helper_setup();
await dice_helper_setup();
hyperspace_ready();
});

Expand Down Expand Up @@ -153,7 +153,6 @@ function register_hooks() {
we may want to monkeypatch a different function in the future. this location doesn't seem to have access
to the actual weapon in use. I'm not sure if we actually care yet, but worth considering.
*/
if (!this._evaluated) this.evaluate();
var data = attack_animation(this, ...args);
return wrapped(...data);
}
Expand Down
14 changes: 7 additions & 7 deletions packs/sceneideas.db

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
`2.1.0` - ?

- COMPATABILITY: Module updated to work with FoundryVTT v12

`2.0.6` - 2024-04-06

- NEW FEATURE: Configurable Book of Boba Fett-style title cards can be played like the opening crawl (thanks `grafeisen`!)
Expand Down
12 changes: 5 additions & 7 deletions scripts/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ export function attack_animation_check() {
export function attack_animation(...args) {
// take our custom arg out of the array so we don't return it
const roll_data = args[0];
console.log(roll_data);
const hit = roll_data.ffg.success > 0;
console.log(hit);
args = args.splice(1);

if (!game.settings.get("ffg-star-wars-enhancements", "attack-animation-enable")) {
Expand Down Expand Up @@ -481,7 +479,7 @@ async function play_animation(animation_file, sound_file, skill, source, count,
canvas.specials.playVideo(animation_config);
game.socket.emit("module.fxmaster", animation_config);

AudioHelper.play({ src: sound_file, volume: 0.3, autoplay: true, loop: false }, true);
foundry.audio.AudioHelper.play({ src: sound_file, volume: 0.3, autoplay: true, loop: false }, true);
await sleepNow(250);
}
}
Expand All @@ -492,7 +490,7 @@ async function play_animation(animation_file, sound_file, skill, source, count,
class attack_animation_UISettings extends FormApplication {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
id: "data-importer",
classes: ["starwarsffg", "data-import"],
title: `${game.i18n.localize("ffg-star-wars-enhancements.attack-animation.ui.name")}`,
Expand All @@ -516,7 +514,7 @@ class attack_animation_UISettings extends FormApplication {
if (!setting.key.includes("attack-animation-") || (!canConfigure && setting.scope !== "client")) continue;

// Update setting data
const s = duplicate(setting);
const s = foundry.utils.duplicate(setting);
s.name = game.i18n.localize(s.name);
s.hint = game.i18n.localize(s.hint);
s.value = game.settings.get(s.module, s.key);
Expand Down Expand Up @@ -605,7 +603,7 @@ class attack_animation_UISettings extends FormApplication {
// noinspection JSUnusedGlobalSymbols
/** @override */
async _updateObject(event, formData) {
for (let [k, v] of Object.entries(flattenObject(formData))) {
for (let [k, v] of Object.entries(foundry.utils.flattenObject(formData))) {
let s = game.settings.settings.get(k);
let current = game.settings.get(s.module, s.key);
if (v !== current) {
Expand All @@ -621,7 +619,7 @@ class ConfigureAttackAnimation extends FormApplication {
}

static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
template: "modules/ffg-star-wars-enhancements/templates/configure_attack_animations.html",
id: "ffg-star-wars-enhancements-attack-animation-configure",
title: "Attack Animation",
Expand Down
11 changes: 10 additions & 1 deletion scripts/datapads.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ export async function create_datapad_journal() {

let data = {
name: template,
content: templates[template],
pages: [
{
name: template,
type: "text",
text: {
content: templates[template],
format: CONST.JOURNAL_ENTRY_PAGE_FORMATS.HTML,
},
},
],
};

JournalEntry.create(data).then((journal) => {
Expand Down
14 changes: 13 additions & 1 deletion scripts/dice_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,19 @@ export async function create_and_populate_journal() {
let suggestions = await $.getJSON(jsonFilePath);
let data = {
name: journal_name,
content: JSON.stringify(suggestions),
pages: [
{
name: "dice_helper",
type: "text",
text: {
content: JSON.stringify(suggestions),
format: CONST.JOURNAL_ENTRY_PAGE_FORMATS.HTML,
},
},
],
ownership: {
default: CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER,
},
};
JournalEntry.create(data);
}
Expand Down
41 changes: 4 additions & 37 deletions scripts/hyperspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function ready() {
export function launch_hyperspace(data) {
log("hyperspace", "launching");

data = mergeObject(data, {
data = foundry.utils.mergeObject(data, {
type: "hyperspace",
});
game.socket.emit("module.ffg-star-wars-enhancements", data);
Expand All @@ -49,7 +49,7 @@ export function select_hyperspace() {

class HyperspaceSelectApplication extends FormApplication {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
template: "modules/ffg-star-wars-enhancements/templates/hyperspace_select.html",
id: "ffg-star-wars-enhancements-hyperspace-select",
title: game.i18n.localize("ffg-star-wars-enhancements.controls.hyperspace.title"),
Expand Down Expand Up @@ -100,7 +100,7 @@ async function run_hyperspace(data) {
log("hyperspace", "Entering hyperspace");
// change to the hyperspace enter scene
await enter_scene.view();
video = find_video_layer(canvas);
video = canvas.primary.background.sourceElement;
video.loop = false;
video.currentTime = 0;
await video.play();
Expand All @@ -119,7 +119,7 @@ async function run_hyperspace(data) {
log("hyperspace", "Exiting hyperspace");
// change to the hyperspace enter scene
await exit_scene.view();
video = find_video_layer(canvas);
video = canvas.primary.background.sourceElement;
video.loop = false;
video.currentTime = 0;
await video.play();
Expand All @@ -140,36 +140,3 @@ async function run_hyperspace(data) {
// Restore the loading bar
$("#loading").css("left", "");
}

/**
* Search the PIXI layers for the specified layer
* @param {object} canvas canvas object
*/
function find_video_layer(canvas) {
let to_search = ["RenderedCanvasGroup", "EnvironmentCanvasGroup", "PrimaryCanvasGroup"];
let layer = canvas.app.stage.children;

for (let i = 0; i < to_search.length; i++) {
layer = _find_layer(layer, to_search[i])["children"];
}
// find the SpiteMesh layer, where the actual video is
layer = _find_layer(layer, "SpriteMesh");
if (!layer.isVideo) {
// this is not a video, ignore it
return false;
} else {
// return the HTML5 video element
return layer.sourceElement;
}
}

/**
* Given a list of layers, find a specific layer
* this is a bit brittle (it assumes the layer exists) but oh well. not worth the effort to fix it
* @param layers layers within the canvas, e.g. canvas.app.stage.children
* @param layer_name name of the layer to look for
* @private
*/
function _find_layer(layers, layer_name) {
return layers.filter((i) => i.constructor.name === layer_name)[0];
}
5 changes: 3 additions & 2 deletions scripts/minionsize_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ export function minionsize_sync(source, ...args) {
} else if (source === "canvasReady") {
log(module_name, "caught scene-transition, looking for minions");
let tokens = canvas.tokens.placeables.filter(
(searchedtoken) => searchedtoken.document.actor.type == "minion"
(searchedtoken) => searchedtoken.document.actor?.type == "minion"
);
for (var x = 0; x < tokens.length; x++) {
let token = tokens[x];
minionSize = token?.document?._actor?.system?.quantity.value;
log(module_name, `found token ${token.name}`);
minionSize = token?.document?.actor?.system?.quantity.value;
update_minion_status(token, minionSize);
}
} else {
Expand Down
25 changes: 17 additions & 8 deletions scripts/opening_crawl.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class OpeningCrawlApplication extends Application {
* Opening Crawl.
*/
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
template: "modules/ffg-star-wars-enhancements/templates/opening_crawl.html",
id: "ffg-star-wars-enhancements-opening-crawl",
title: game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.title"),
Expand Down Expand Up @@ -352,7 +352,7 @@ function parse_journal(journal) {
export function launch_opening_crawl(data) {
log("opening-crawl", "launching");

data = mergeObject(data, {
data = foundry.utils.mergeObject(data, {
type: "opening-crawl",
logo: game.settings.get("ffg-star-wars-enhancements", "opening-crawl-logo"),
music: game.settings.get("ffg-star-wars-enhancements", "opening-crawl-music"),
Expand Down Expand Up @@ -385,7 +385,7 @@ export function select_opening_crawl() {

class OpeningCrawlSelectApplication extends FormApplication {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
template: "modules/ffg-star-wars-enhancements/templates/opening_crawl_select.html",
id: "ffg-star-wars-enhancements-opening-crawl-select",
title: game.i18n.localize("ffg-star-wars-enhancements.controls.opening-crawl.title"),
Expand Down Expand Up @@ -464,8 +464,17 @@ export async function create_opening_crawl() {
let data = {
name: "Episode X",
folder: folder.id,
content:
'<h1>Episode X</h1><h2>Episode Title</h2><p>Replace the h1 and h2 above with your episode and title. Then, replace this block of text with the paragraphs of your opening crawl. Lastly, the opening crawl will pan to the image below. Replace the image with a planet, ship, or simply remove the image entirely to pan to open space.</p><img src="modules/ffg-star-wars-enhancements/artwork/planet.png"/>',
pages: [
{
name: "Opening Crawl",
type: "text",
text: {
content:
'<h1>Episode X</h1><h2>Episode Title</h2><p>Replace the h1 and h2 above with your episode and title. Then, replace this block of text with the paragraphs of your opening crawl. Lastly, the opening crawl will pan to the image below. Replace the image with a planet, ship, or simply remove the image entirely to pan to open space.</p><img src="modules/ffg-star-wars-enhancements/artwork/planet.png"/>',
format: CONST.JOURNAL_ENTRY_PAGE_FORMATS.HTML,
},
},
],
};
JournalEntry.create(data).then((journal) => {
journal.sheet.render(true);
Expand Down Expand Up @@ -498,7 +507,7 @@ function sleep(ms) {
class opening_crawl_UISettings extends FormApplication {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
id: "data-importer",
classes: ["starwarsffg", "data-import"],
title: `${game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.ui.name")}`,
Expand All @@ -522,7 +531,7 @@ class opening_crawl_UISettings extends FormApplication {
if (!setting.key.includes("opening-crawl-") || (!canConfigure && setting.scope !== "client")) continue;

// Update setting data
const s = duplicate(setting);
const s = foundry.utils.duplicate(setting);
s.name = game.i18n.localize(s.name);
s.hint = game.i18n.localize(s.hint);
s.value = game.settings.get(s.module, s.key);
Expand Down Expand Up @@ -611,7 +620,7 @@ class opening_crawl_UISettings extends FormApplication {
// noinspection JSUnusedGlobalSymbols
/** @override */
async _updateObject(event, formData) {
for (let [k, v] of Object.entries(flattenObject(formData))) {
for (let [k, v] of Object.entries(foundry.utils.flattenObject(formData))) {
let s = game.settings.settings.get(k);
let current = game.settings.get(s.module, s.key);
if (v !== current) {
Expand Down
27 changes: 14 additions & 13 deletions scripts/shop.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class Shop {
let specialization_mapping = {
general: {
compendiums: [
"world.oggdudearmor",
"world.oggdudegear",
"world.oggdudeweapons",
"world.oggdudeitemattachments",
"starwarsffg.oggdudearmor",
"starwarsffg.oggdudegear",
"starwarsffg.oggdudeweapons",
"starwarsffg.oggdudeitemattachments",
],
types: [
"weapon",
Expand All @@ -53,23 +53,23 @@ class Shop {
],
},
armor: {
compendiums: ["world.oggdudearmor", "world.oggdudeitemattachments"],
compendiums: ["starwarsffg.oggdudearmor", "starwarsffg.oggdudeitemattachments"],
types: [
"armour",
"armor", // attachments use the US spelling while items use the UK spelling
"itemattachment",
],
},
gear: {
compendiums: ["world.oggdudegear", "world.oggdudeitemattachments"],
compendiums: ["starwarsffg.oggdudegear", "starwarsffg.oggdudeitemattachments"],
types: ["gear", "itemattachment"],
},
weapon: {
compendiums: ["world.oggdudeweapons", "world.oggdudeitemattachments"],
compendiums: ["starwarsffg.oggdudeweapons", "starwarsffg.oggdudeitemattachments"],
types: ["weapon", "itemattachment"],
},
nerf_herder: {
compendiums: ["world.oggdudegear"],
compendiums: ["starwarsffg.oggdudegear"],
types: ["gear"],
},
};
Expand Down Expand Up @@ -202,7 +202,8 @@ class Shop {
"negotiation"
);
}
let result = new game.ffg.RollFFG(pool.renderDiceExpression()).roll().ffg;
let result = await new game.ffg.RollFFG(pool.renderDiceExpression()).roll();
result = result.ffg;

// see if the check was successful or not
if (result["success"] >= 1) {
Expand Down Expand Up @@ -357,7 +358,7 @@ class ShopGenerator extends FormApplication {
No idea what this does, but it is in stuff I'm basing the module off of so it's here too
*/
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
template: "modules/ffg-star-wars-enhancements/templates/shop/setup.html",
id: "ffg-star-wars-enhancements-shop-generator-setup",
title: "Shop Generator",
Expand Down Expand Up @@ -503,7 +504,7 @@ class ShopGenerator extends FormApplication {
// set the extended data as a flag
log(module_name, "Setting flag data: " + JSON.stringify(flag_data));
// actually set the flag data
vendor.setFlag("ffg-star-wars-enhancements", "vendor-data", flag_data);
await vendor.setFlag("ffg-star-wars-enhancements", "vendor-data", flag_data);

// actually delete the old items
await vendor.deleteEmbeddedDocuments("Item", to_delete);
Expand Down Expand Up @@ -531,7 +532,7 @@ class ShopCreator extends FormApplication {
}

static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
template: "modules/ffg-star-wars-enhancements/templates/shop/create.html",
id: "ffg-star-wars-enhancements-shop-generator-create",
title: "Shop Creator",
Expand All @@ -555,7 +556,7 @@ class ShopCreator extends FormApplication {
});
// swap the sheet type to vendor
// I'm not sure how to do it by default, but this seems reasonably fast
game.actors.get(actor.id).setFlag("core", "sheetClass", "ffg.Vendor");
await game.actors.get(actor.id).setFlag("core", "sheetClass", "ffg.Vendor");
new ShopGenerator(actor.id).render(true);
}
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/shop_sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class Vendor extends ActorSheetFFGV2 {
static get defaultOptions() {
const options = super.defaultOptions;

mergeObject(options, {
foundry.utils.mergeObject(options, {
classes: ["starwarsffg", "sheet", "actor", "v2", "ffg-sw-enhanced", "vendor"],
template: "modules/ffg-star-wars-enhancements/templates/shop/inventory.html",
width: 710,
Expand All @@ -132,7 +132,7 @@ export class Vendor extends ActorSheetFFGV2 {
}

async getData() {
const sheetData = super.getData();
const sheetData = await super.getData();
let vendor_data = this.document.getFlag("ffg-star-wars-enhancements", "vendor-data");
// validate that we got flag data before trying to index into it
if (vendor_data === undefined || vendor_data === null) {
Expand Down
Loading
Loading