Skip to content

Commit

Permalink
Fixed errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Jan 16, 2022
1 parent b0cbe06 commit 545cb0b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Item Piles Changelog

## Version 1.2.1
- Fixed hotkey errors on Foundry 0.8.9

## Version 1.2.0
- Now supports Foundry 0.8.9
- Added setting to output items picked up to chat
Expand Down
5 changes: 3 additions & 2 deletions scripts/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { itemPileSocket, SOCKET_HANDLERS } from "./socket.js";
import { ItemPileInventory } from "./formapplications/itemPileInventory.js";
import DropDialog from "./formapplications/dropDialog.js";
import { HOOKS } from "./hooks.js";
import { hotkeyState } from "./hotkeys.js";

export default class API {

Expand Down Expand Up @@ -1791,7 +1792,7 @@ export default class API {
if (!game.user.isGM) {
return lib.custom_warning(game.i18n.format("ITEM-PILES.Errors.DisallowedItemDrop", { type: disallowedType }), true)
}
if (!game.keyboard.downKeys.has("ShiftLeft")) {
if (!hotkeyState.shiftDown) {
const force = await Dialog.confirm({
title: game.i18n.localize("ITEM-PILES.Dialogs.DropTypeWarning.Title"),
content: `<p class="item-piles-dialog">${game.i18n.format("ITEM-PILES.Dialogs.DropTypeWarning.Content", { type: disallowedType })}</p>`,
Expand Down Expand Up @@ -1865,7 +1866,7 @@ export default class API {
}
}

if (game.keyboard.downKeys.has("AltLeft")) {
if (hotkeyState.altDown) {

if (droppableDocuments.length) {
action = "addToPile";
Expand Down
46 changes: 44 additions & 2 deletions scripts/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import * as lib from "./lib/lib.js";
import CONSTANTS from "./constants.js";

export const hotkeyState = {
ctrlDown: false
ctrlDown: false,
altDown: false,
shiftDown: false
}

export function registerHotkeysPre() {
Expand All @@ -21,7 +23,35 @@ export function registerHotkeysPre() {
onUp: () => {
hotkeyState.ctrlDown = false;
},
reservedModifiers: ["SHIFT"]
reservedModifiers: ["SHIFT", "ALT"]
});

game.keybindings.register(CONSTANTS.MODULE_NAME, "force-open-item-pile-inventory", {
name: "Force drop item (GM only)",
uneditable: [
{ key: "ShiftLeft" },
],
onDown: () => {
hotkeyState.shiftDown = true;
},
onUp: () => {
hotkeyState.shiftDown = false;
},
reservedModifiers: ["ALT", "CONTROL"]
});

game.keybindings.register(CONSTANTS.MODULE_NAME, "force-drop-item", {
name: "Force drop one item",
uneditable: [
{ key: "AltLeft" },
],
onDown: () => {
hotkeyState.altDown = true;
},
onUp: () => {
hotkeyState.altDown = false;
},
reservedModifiers: ["SHIFT", "CONTROL"]
});

}
Expand Down Expand Up @@ -65,6 +95,12 @@ export function registerHotkeysPost() {
case "ControlLeft":
hotkeyState.ctrlDown = true;
break;
case "ShiftLeft":
hotkeyState.shiftDown = true;
break;
case "AltLeft":
hotkeyState.altDown = true;
break;
}
});

Expand All @@ -73,6 +109,12 @@ export function registerHotkeysPost() {
case "ControlLeft":
hotkeyState.ctrlDown = false;
break;
case "ShiftLeft":
hotkeyState.shiftDown = false;
break;
case "AltLeft":
hotkeyState.altDown = false;
break;
}
});

Expand Down

0 comments on commit 545cb0b

Please sign in to comment.