From 7abc0ee25497a6c4f8249fffd17bfb6fbd5966fa Mon Sep 17 00:00:00 2001 From: Haxxer Date: Tue, 22 Feb 2022 23:07:05 +0000 Subject: [PATCH] Minimal UI module support, right click context menu --- changelog.md | 2 ++ scripts/api.js | 6 ++-- .../formapplications/item-pile-inventory.js | 34 +++++++++++++++++++ scripts/module.js | 5 ++- styles/module.css | 7 ++++ styles/module.css.map | 2 +- styles/module.scss | 9 +++++ 7 files changed, 61 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 512d2812..2eee14fb 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,8 @@ ## Version 1.4.4 +- Added a right click context menu to the item pile inventory UI, with an option to show an item's image to everyone +- Improved Request Trade button in the player list when the Minimal UI module is active - Improved splitting API functions to improve performance when playing on Forge - Improved documentation to better describe what each API method requires - Tweaked `Split n ways` button to disable itself instead of becoming hidden diff --git a/scripts/api.js b/scripts/api.js index 29d19d44..2f0aa5fa 100644 --- a/scripts/api.js +++ b/scripts/api.js @@ -8,7 +8,7 @@ import { hotkeyState } from "./hotkeys.js"; const preloadedFiles = new Set(); -export default { +const API = { /** * The actor class type used for the original item pile actor in this system @@ -2452,4 +2452,6 @@ export default { } -}; \ No newline at end of file +}; + +export default API; \ No newline at end of file diff --git a/scripts/formapplications/item-pile-inventory.js b/scripts/formapplications/item-pile-inventory.js index 84ef4854..7ce9388e 100644 --- a/scripts/formapplications/item-pile-inventory.js +++ b/scripts/formapplications/item-pile-inventory.js @@ -425,6 +425,40 @@ export class ItemPileInventory extends FormApplication { .replaceWith($('' + innerHTML + '')); html.find('.item-piles-change-actor-select').remove(); } + + // Activate context menu + this._contextMenu(html); + } + + /* -------------------------------------------- */ + + /** @inheritdoc */ + _contextMenu(html) { + ContextMenu.create(this, html, ".item-piles-item-row", this._getEntryContextOptions()); + } + + /* -------------------------------------------- */ + + /** + * Get the Macro entry context options + * @returns {object[]} The Macro entry context options + * @private + */ + _getEntryContextOptions() { + return [ + { + name: "JOURNAL.ActionShow", + icon: '', + condition: (div) => { + return game.user.isGM && div.data("item-id"); + }, + callback: (div) => { + const item = this.pileActor.items.get(div.data("item-id")); + const popout = new ImagePopout(item.data.img, { title: item.name }).render(true); + popout.shareImage(); + } + } + ]; } previewImage(html, element) { diff --git a/scripts/module.js b/scripts/module.js index c2f4d849..3db9712b 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -38,7 +38,10 @@ Hooks.once("init", async () => { if (game.settings.get(CONSTANTS.MODULE_NAME, "enableTrading") && game.settings.get(CONSTANTS.MODULE_NAME, "showTradeButton")) { Hooks.on("renderPlayerList", (app, html) => { - const button = $(``) + const minimalUI = game.modules.get('minimal-ui')?.active; + const classes = "item-piles-player-list-trade-button" + (minimalUI ? " item-piles-minimal-ui" : "") + const text = !minimalUI ? " Request Trade" : "" + const button = $(``) button.click(() => { TradeAPI.requestTrade(); }); diff --git a/styles/module.css b/styles/module.css index 09f56db8..52762c16 100644 --- a/styles/module.css +++ b/styles/module.css @@ -5,6 +5,13 @@ width: calc(100% - 0.5rem); margin: 0.25rem; } +.item-piles-player-list-trade-button.item-piles-minimal-ui { + padding: 2px 0 0 0; + text-align: center; +} +.item-piles-player-list-trade-button.item-piles-minimal-ui i { + width: 100%; +} .item-piles-specate-trade:disabled { background-color: rgba(0, 0, 0, 0.25); } diff --git a/styles/module.css.map b/styles/module.css.map index fb38b929..3be509a9 100644 --- a/styles/module.css.map +++ b/styles/module.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["module.scss"],"names":[],"mappings":"AAAA;AAIE;EACE;EACA;EACA;EACA;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAKJ;EACE;EACA;EACA;;AAGF;EACE;;AAGF;EACE;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;;AAIJ;EACE;;AAGF;EACE;EACA;;AAGF;EACE;;AAIA;EACE;;AAGF;EACE;;AAIJ;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EAEA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;;AAKN;EACE;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;;;AAKJ;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;;AAEA;EACE;EACA;EACA;EACA;;;AAIJ;AAGA;EACE;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;;AAIJ;EACE;EACA;;AAIJ;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AASJ;EACE;EACA;EACA;;AAGF;EACE;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAIJ;EACE;;AAEA;EACE;EACA;EACA;EACA;;;AAKN;AAEA;EACE;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;;;AAON;AAEA;EACE;;AAEA;EACE;EACA;;AAIA;EACE;EACA;EACA;;AAGF;EACE;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;EACA;;;AAKN;AAKE;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;AAKA;EACE;EACA;EACA;EAEA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;;AASR;EACE;EACA;;AAGF;EACE;EACA;;AAGF;EAEE;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAIA;EACE","file":"module.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["module.scss"],"names":[],"mappings":"AAAA;AAIE;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAEA;EACE;;AAKN;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAKJ;EACE;EACA;EACA;;AAGF;EACE;;AAGF;EACE;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;;AAIJ;EACE;;AAGF;EACE;EACA;;AAGF;EACE;;AAIA;EACE;;AAGF;EACE;;AAIJ;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EAEA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;;AAKN;EACE;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;;;AAKJ;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;;AAEA;EACE;EACA;EACA;EACA;;;AAIJ;AAGA;EACE;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;;AAIJ;EACE;EACA;;AAIJ;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AASJ;EACE;EACA;EACA;;AAGF;EACE;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAIJ;EACE;;AAEA;EACE;EACA;EACA;EACA;;;AAKN;AAEA;EACE;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;;;AAON;AAEA;EACE;;AAEA;EACE;EACA;;AAIA;EACE;EACA;EACA;;AAGF;EACE;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;EACA;;;AAKN;AAKE;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;AAKA;EACE;EACA;EACA;EAEA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;;AASR;EACE;EACA;;AAGF;EACE;EACA;;AAGF;EAEE;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAIA;EACE","file":"module.css"} \ No newline at end of file diff --git a/styles/module.scss b/styles/module.scss index eac0f747..172070fb 100644 --- a/styles/module.scss +++ b/styles/module.scss @@ -7,6 +7,15 @@ font-size: 0.85rem; width: calc(100% - 0.5rem); margin: 0.25rem; + + &.item-piles-minimal-ui { + padding: 2px 0 0 0; + text-align: center; + + i { + width: 100%; + } + } } &-specate-trade:disabled {