Merge branch 'master' into 050-basic-active-effects
This commit is contained in:
commit
ac84d40528
7 changed files with 131 additions and 80 deletions
|
@ -72,8 +72,15 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Data<DS4Actor>> {
|
|||
// Update Inventory Item
|
||||
html.find(".item-edit").on("click", (ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.actor.getOwnedItem(li.data("itemId"));
|
||||
item.sheet?.render(true);
|
||||
const id = li.data("itemId");
|
||||
const item = this.actor.getOwnedItem(id);
|
||||
if (!item) {
|
||||
throw new Error(game.i18n.format("DS4.ErrorActorDoesNotHaveItem", { id, actor: this.actor.name }));
|
||||
}
|
||||
if (!item.sheet) {
|
||||
throw new Error(game.i18n.localize("DS4.ErrorUnexpectedError"));
|
||||
}
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
// Delete Inventory Item
|
||||
|
|
|
@ -91,8 +91,12 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Data<DS4Item>> {
|
|||
case "create":
|
||||
return this._createActiveEffect();
|
||||
case "edit":
|
||||
const effect = this.item.effects.get(li.data("effectId"));
|
||||
return effect?.sheet.render(true);
|
||||
const id = li.data("effectId");
|
||||
const effect = this.item.effects.get(id);
|
||||
if (!effect) {
|
||||
throw new Error(game.i18n.format("DS4.ErrorItemDoesNotHaveEffect", { id, item: this.item.name }));
|
||||
}
|
||||
return effect.sheet.render(true);
|
||||
case "delete": {
|
||||
return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
|
||||
}
|
||||
|
|
37
src/module/ui/notifications.ts
Normal file
37
src/module/ui/notifications.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
const notifications = {
|
||||
info: (message: string, { permanent = false }: { permanent?: boolean } = {}): void => {
|
||||
if (ui.notifications) {
|
||||
ui.notifications.info(message, { permanent });
|
||||
} else {
|
||||
console.info(message);
|
||||
}
|
||||
},
|
||||
warn: (message: string, { permanent = false }: { permanent?: boolean } = {}): void => {
|
||||
if (ui.notifications) {
|
||||
ui.notifications.warn(message, { permanent });
|
||||
} else {
|
||||
console.log(message);
|
||||
}
|
||||
},
|
||||
error: (message: string, { permanent = false }: { permanent?: boolean } = {}): void => {
|
||||
if (ui.notifications) {
|
||||
ui.notifications.error(message, { permanent });
|
||||
} else {
|
||||
console.warn(message);
|
||||
}
|
||||
},
|
||||
notify: (
|
||||
message: string,
|
||||
type: "info" | "warning" | "error" = "info",
|
||||
{ permanent = false }: { permanent?: boolean } = {},
|
||||
): void => {
|
||||
if (ui.notifications) {
|
||||
ui.notifications.notify(message, type, { permanent });
|
||||
} else {
|
||||
const log = { info: console.info, warning: console.warn, error: console.error }[type];
|
||||
log(message);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default notifications;
|
Loading…
Add table
Add a link
Reference in a new issue