Skip to content

Commit

Permalink
version 0.6.14
Browse files Browse the repository at this point in the history
  • Loading branch information
p4535992 committed Nov 23, 2022
1 parent 56a2c27 commit 9be21a0
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 23 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
### 0.6.10-11-12
### 0.6.14

- Bug fix: https://github.com/p4535992/foundryvtt-inventory-plus/issues/20
- Bug fix: https://github.com/p4535992/foundryvtt-inventory-plus/issues/19

### 0.6.10-11-12-13

- BUg fix; https://github.com/p4535992/foundryvtt-inventory-plus/issues/14
- Bug fix: https://github.com/p4535992/foundryvtt-inventory-plus/issues/13
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "inventory-plus",
"title": "Inventory+",
"description": "Enhances the default dnd5e sheets inventory to allow for reorganization",
"version": "0.6.13",
"version": "0.6.14",
"main": "main.js",
"scripts": {
"publish": "gulp publish --update",
Expand Down
6 changes: 3 additions & 3 deletions src/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "inventory-plus",
"title": "Inventory+",
"description": "Enhances the default dnd5e sheets inventory to allow for reorganization",
"version": "0.6.13",
"version": "0.6.14",
"authors": [
{
"name": "Felix#6196"
Expand Down Expand Up @@ -82,8 +82,8 @@
"url": "https://github.com/p4535992/foundryvtt-inventory-plus",
"manifest": "https://github.com/p4535992/foundryvtt-inventory-plus/releases/latest/download/module.json",
"download": "https://github.com/p4535992/foundryvtt-inventory-plus/releases/latest/download/module.zip",
"readme": "https://github.com/p4535992/foundryvtt-inventory-plus/blob/v0.6.13/README.md",
"changelog": "https://github.com/p4535992/foundryvtt-inventory-plus/blob/v0.6.13/CHANGELOG.md",
"readme": "https://github.com/p4535992/foundryvtt-inventory-plus/blob/v0.6.14/README.md",
"changelog": "https://github.com/p4535992/foundryvtt-inventory-plus/blob/v0.6.14/CHANGELOG.md",
"bugs": "https://github.com/p4535992/foundryvtt-inventory-plus/issues",
"allowBugReporter": true,
"relationships": {
Expand Down
98 changes: 80 additions & 18 deletions src/scripts/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { InventoryPlus } from "./inventory-plus";
import { Category, EncumbranceDnd5e, InventoryPlusFlags } from "./inventory-plus-models";
import {
getCSSName,
debug,
i18n,
warn,
i18nFormat,
Expand Down Expand Up @@ -160,13 +161,15 @@ export const readyHooks = async (): Promise<void> => {
? //@ts-ignore
itemDropped.actor.id
: //@ts-ignore
item.parent && item.parent instanceof Actor
itemDropped.parent && itemDropped.parent instanceof Actor
? //@ts-ignore
item.parent.id
itemDropped.parent.id
: //@ts-ignore
undefined;

const sourceActor = game.actors?.get(sourceActorId);
const sourceActor = sourceActorId
? game.actors?.get(sourceActorId)
: undefined;

let createdItem: Item | undefined = undefined;

Expand All @@ -187,21 +190,25 @@ export const readyHooks = async (): Promise<void> => {
if (!targetType) {
// No type founded use standard system

if (!this.actor.isOwner) return false;
if (!this.actor.isOwner) {
return false;
}
//@ts-ignore
const item = <Item>await Item.implementation.fromDropData(itemDropped);
const itemData = item.toObject();

// Handle item sorting within the same Actor
if (await _isFromSameActor(actor, itemDropped)) return this._onSortItem(event, itemData);

if (await _isFromSameActor(actor, itemDropped)) {
return this._onSortItem(event, itemData);
}
// Create the owned item
if (
game.settings.get(CONSTANTS.MODULE_NAME, "enableItemTransfer") &&
!(await _isFromSameActor(actor, itemDropped)) &&
!isAlt() &&
!dragAndDropFromCompendium &&
dragAndDropFromActorSource
dragAndDropFromActorSource &&
sourceActor
) {
//@ts-ignore
module.dropActorSheetDataTransferStuff(targetActor, sourceActor, itemDropped);
Expand Down Expand Up @@ -231,7 +238,8 @@ export const readyHooks = async (): Promise<void> => {
!(await _isFromSameActor(actor, itemDropped)) &&
!isAlt() &&
!dragAndDropFromCompendium &&
dragAndDropFromActorSource
dragAndDropFromActorSource &&
sourceActor
) {
//@ts-ignore
module.dropActorSheetDataTransferStuff(targetActor, sourceActor, itemDropped);
Expand All @@ -258,7 +266,8 @@ export const readyHooks = async (): Promise<void> => {
!(await _isFromSameActor(actor, itemDropped)) &&
!isAlt() &&
!dragAndDropFromCompendium &&
dragAndDropFromActorSource
dragAndDropFromActorSource &&
sourceActor
) {
//@ts-ignore
module.dropActorSheetDataTransferStuff(targetActor, sourceActor, itemDropped);
Expand Down Expand Up @@ -288,7 +297,8 @@ export const readyHooks = async (): Promise<void> => {
!(await _isFromSameActor(actor, itemDropped)) &&
!isAlt() &&
!dragAndDropFromCompendium &&
dragAndDropFromActorSource
dragAndDropFromActorSource &&
sourceActor
) {
//@ts-ignore
module.dropActorSheetDataTransferStuff(targetActor, sourceActor, itemDropped);
Expand Down Expand Up @@ -321,7 +331,8 @@ export const readyHooks = async (): Promise<void> => {
!(await _isFromSameActor(actor, itemDropped)) &&
!isAlt() &&
!dragAndDropFromCompendium &&
dragAndDropFromActorSource
dragAndDropFromActorSource &&
sourceActor
) {
//@ts-ignore
module.dropActorSheetDataTransferStuff(targetActor, sourceActor, itemDropped);
Expand Down Expand Up @@ -373,7 +384,8 @@ export const readyHooks = async (): Promise<void> => {
!(await _isFromSameActor(actor, itemDropped)) &&
!isAlt() &&
!dragAndDropFromCompendium &&
dragAndDropFromActorSource
dragAndDropFromActorSource &&
sourceActor
) {
//@ts-ignore
module.dropActorSheetDataTransferStuff(targetActor, sourceActor, itemDropped);
Expand Down Expand Up @@ -428,7 +440,8 @@ export const readyHooks = async (): Promise<void> => {
!(await _isFromSameActor(actor, itemDropped)) &&
!isAlt() &&
!dragAndDropFromCompendium &&
dragAndDropFromActorSource
dragAndDropFromActorSource &&
sourceActor
) {
//@ts-ignore
module.dropActorSheetDataTransferStuff(targetActor, sourceActor, itemDropped);
Expand Down Expand Up @@ -624,6 +637,15 @@ const module = {
if (!game.settings.get(CONSTANTS.MODULE_NAME, "enableInventorySorter")) {
return false;
}
const user = game.user;
if (!user?.character) {
debug(`Can't reorder you need to set a actor to the game user`);
return false;
}
if (user.character.id !== (<Actor>item.parent).id) {
debug(`Can't reorder you can order ONLY the actor connected to the game user`);
return false;
}
if (changes.sort !== undefined) {
if (!options.inventorySorterUpdate) {
const itemSorts = getItemSorts(<Actor>item.parent);
Expand All @@ -642,42 +664,82 @@ const module = {

createItemInventorySorter(item: Item, options: any, userId: string, ...args) {
if (!game.settings.get(CONSTANTS.MODULE_NAME, "enableInventorySorter")) {
return;
return false;
}
const user = game.users?.get(userId);
if (!user?.character) {
debug(`Can't reorder you need to set a actor to the game user`);
return false;
}
if (user.character.id !== (<Actor>item.parent).id) {
debug(`Can't reorder you can order ONLY the actor connected to the game user`);
return false;
}
if (userId === game.userId) {
delayedSort(<Actor>item.parent);
}
return true;
},

deleteItemInventorySorter(item: Item, options: any, userId: string, ...args) {
deleteItemInventorySorter(item: Item, options: any, userId: string, ...args): boolean {
if (!game.settings.get(CONSTANTS.MODULE_NAME, "enableInventorySorter")) {
return;
return false;
}
const user = game.users?.get(userId);
if (!user?.character) {
debug(`Can't reorder you need to set a actor to the game user`);
return false;
}
if (user.character.id !== (<Actor>item.parent).id) {
debug(`Can't reorder you can order ONLY the actor connected to the game user`);
return false;
}
if (userId === game.userId) {
delayedSort(<Actor>item.parent);
}
return true;
},

updateItemInventorySorter(item: Item, changes, options: any, userId: string) {
if (!game.settings.get(CONSTANTS.MODULE_NAME, "enableInventorySorter")) {
return;
return false;
}
const user = game.users?.get(userId);
if (!user?.character) {
debug(`Can't reorder you need to set a actor to the game user`);
return false;
}
if (user.character.id !== (<Actor>item.parent).id) {
debug(`Can't reorder you can order ONLY the actor connected to the game user`);
return false;
}
if (userId === game.userId) {
if (!options.inventorySorterUpdate) {
delayedSort(<Actor>item.parent);
}
}
return true;
},

renderActorSheetEnableInventorySorter(actorSheet: ActorSheet, html, data) {
if (!game.settings.get(CONSTANTS.MODULE_NAME, "enableInventorySorter")) {
return;
return false;
}
const user = game.user;
if (!user?.character) {
debug(`Can't reorder you need to set a actor to the game user`);
return false;
}
if (user.character.id !== actorSheet.actor.id) {
debug(`Can't reorder you can order ONLY the actor connected to the game user`);
return false;
}
if (actorSheet?.isEditable) {
const actor = actorSheet?.actor;
if (!sortedActors.has(actor.id)) {
delayedSort(actor);
}
}
return true;
},
};

0 comments on commit 9be21a0

Please sign in to comment.