Skip to content

Commit

Permalink
Merge pull request #912 from Muttley/911-refactor-art-mappings
Browse files Browse the repository at this point in the history
Replaced module-art.mjs with built in art mapping function
  • Loading branch information
Muttley authored Oct 13, 2024
2 parents 6a642a6 + d6ec70a commit 19f15db
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 206 deletions.
9 changes: 9 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# vX.X.X

## Chores
* [#911] Replaced compendium art mapping with default Foundry method.

- Settings for compendium art mapping are now found in *Settings > Core > Compendium Art*

---

# v3.1.3

## Enhancements
Expand Down
6 changes: 1 addition & 5 deletions system/shadowdark.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import * as dice from "./src/dice/_module.mjs";
import * as documents from "./src/documents/_module.mjs";
import * as sheets from "./src/sheets/_module.mjs";

import { ModuleArt } from "./src/utils/module-art.mjs";

import {
HooksSD,
HooksImmediate,
Expand Down Expand Up @@ -77,7 +75,7 @@ Hooks.once("init", () => {
registerSystemSettings();
loadTemplates();

game.shadowdark.moduleArt = new ModuleArt();
UtilitySD.loadLegacyArtMappings();

// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Expand Down Expand Up @@ -141,8 +139,6 @@ Hooks.on("ready", async () => {
Hooks.once("setup", () => {
shadowdark.log("Setup Hook");

game.shadowdark.moduleArt.registerModuleArt();

// Localize all the strings in the game config in advance
//
for (const obj in game.shadowdark.config) {
Expand Down
27 changes: 0 additions & 27 deletions system/src/documents/ActorSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,6 @@ export default class ActorSD extends Actor {
}
}


/** @inheritdoc */
_initializeSource(source, options={}) {
source = super._initializeSource(source, options);

if (!source._id || !options.pack || game.shadowdark.moduleArt.suppressArt) {
return source;
}

const uuid = `Compendium.${options.pack}.${source._id}`;

const art = game.shadowdark.moduleArt.map.get(uuid);

if (art?.actor || art?.token) {
if (art.actor) source.img = art.actor;

if (typeof art.token === "string") {
source.prototypeToken.texture.src = art.token;
}
else if (art.token) {
foundry.utils.mergeObject(source.prototypeToken, art.token);
}
}
return source;
}


async _learnSpell(item) {
const characterClass = await this.getClass();

Expand Down
25 changes: 1 addition & 24 deletions system/src/settings.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ModuleArtConfig } from "./utils/module-art.mjs";
import SourceFilterSettings from "./apps/SourceFilterSettings.mjs";

/**
Expand All @@ -7,31 +6,9 @@ import SourceFilterSettings from "./apps/SourceFilterSettings.mjs";
export default function registerSystemSettings() {

// -----------------
// DYNAMIC ARTWORK
// Content Sources
// -----------------
//
game.settings.registerMenu("shadowdark", "moduleArtConfiguration", {
name: "SHADOWDARK.settings.module_art.name",
label: "SHADOWDARK.settings.module_art.label",
hint: "SHADOWDARK.settings.module_art.hint",
icon: "fa-solid fa-palette",
type: ModuleArtConfig,
restricted: true,
});

game.settings.register("shadowdark", "moduleArtConfiguration", {
name: "Module Art Configuration",
scope: "world",
config: false,
type: Object,
default: {
shadowdark: {
portraits: true,
tokens: true,
},
},
});

game.settings.registerMenu("shadowdark", "sources", {
name: "SHADOWDARK.settings.source_filter.name",
hint: "SHADOWDARK.settings.source_filter.hint",
Expand Down
15 changes: 15 additions & 0 deletions system/src/utils/UtilitySD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,19 @@ export default class UtilitySD {
const src = sounds[0];
game.audio.play(src, {volume: 1});
}

static async loadLegacyArtMappings() {
// search modules for legacy art mappings and convert to new format
for (const module of game.modules) {
if (!module.active) continue;
const flags = module.flags?.[module.id];
if (flags?.["shadowdark-art"]) {
module.flags.compendiumArtMappings = {
shadowdark: {
mapping: flags["shadowdark-art"],
},
};
}
}
}
}
150 changes: 0 additions & 150 deletions system/src/utils/module-art.mjs

This file was deleted.

0 comments on commit 19f15db

Please sign in to comment.