From 9bcc0fd975f37f5d1e62d363c1cd2f53fd55a1dc Mon Sep 17 00:00:00 2001 From: U~man Date: Thu, 9 Jul 2020 11:56:11 +0200 Subject: [PATCH] ENH: Reworked roll interactions --- README.md | 4 ++- src/module/actor/actor-sheet.js | 11 ++++++- src/module/init.js | 0 src/ose.js | 33 ++++++++++++++----- src/scss/actor-base.scss | 22 ++++++++----- src/scss/apps.scss | 15 +++++++-- .../partials/character-abilities-tab.html | 5 +-- .../partials/character-inventory-tab.html | 2 +- .../actors/partials/character-spells-tab.html | 3 +- .../partials/monster-attributes-tab.html | 6 ++-- src/templates/chat/roll-attack.html | 5 ++- src/templates/chat/roll-result.html | 5 ++- 12 files changed, 82 insertions(+), 29 deletions(-) create mode 100644 src/module/init.js diff --git a/README.md b/README.md index fa01ccf..74591b1 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,6 @@ This Foundry VTT system requires Old-School Essentials Core Rules and does not c ## Contributions This system is currently under heavy development. -Feel free to grab a TO DO issue from the gitlab board. You can then do a merge request on the `development` branch. \ No newline at end of file +Feel free to grab a TO DO issue from the gitlab board. You can then do a merge request on the `development` branch. + +[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/H2H21WMKA) \ No newline at end of file diff --git a/src/module/actor/actor-sheet.js b/src/module/actor/actor-sheet.js index 4b95a1d..d3b671d 100644 --- a/src/module/actor/actor-sheet.js +++ b/src/module/actor/actor-sheet.js @@ -111,12 +111,21 @@ export class OseActorSheet extends ActorSheet { }); }); - html.find(".item-image").click(async (ev) => { + html.find(".item .item-controls .item-show").click(async (ev) => { const li = $(ev.currentTarget).parents(".item"); const item = this.actor.getOwnedItem(li.data("itemId")); item.roll({skipDialog: event.ctrlKey}); }); + html.find(".item .item-rollable .item-image").click(async ev => { + const li = $(ev.currentTarget).parents(".item"); + const item = this.actor.getOwnedItem(li.data("itemId")); + if (item.type == 'weapon') { + item.rollWeapon(); + } else { + item.rollFormula(); + } + }); html.find(".attack a").click(ev => { let actorObject = this.actor; diff --git a/src/module/init.js b/src/module/init.js new file mode 100644 index 0000000..e69de29 diff --git a/src/ose.js b/src/ose.js index 5637700..5a6dfcb 100644 --- a/src/ose.js +++ b/src/ose.js @@ -6,8 +6,8 @@ import { preloadHandlebarsTemplates } from "./module/preloadTemplates.js"; import { OseActor } from "./module/actor/entity.js"; import { OseItem } from "./module/item/entity.js"; import { OSE } from "./module/config.js"; -import { registerSettings } from './module/settings.js'; -import { registerHelpers } from './module/helpers.js'; +import { registerSettings } from "./module/settings.js"; +import { registerHelpers } from "./module/helpers.js"; import * as chat from "./module/chat.js"; import * as macros from "./module/macros.js"; @@ -26,17 +26,17 @@ Hooks.once("init", async function () { }; CONFIG.OSE = OSE; - + game.ose = { - rollItemMacro: macros.rollItemMacro - } + rollItemMacro: macros.rollItemMacro, + }; // Custom Handlebars helpers registerHelpers(); - + // Register custom system settings registerSettings(); - + CONFIG.Actor.entityClass = OseActor; CONFIG.Item.entityClass = OseItem; @@ -71,8 +71,23 @@ Hooks.once("setup", function () { }); Hooks.once("ready", () => { - Hooks.on("hotbarDrop", (bar, data, slot) => macros.createOseMacro(data, slot)); + Hooks.on("hotbarDrop", (bar, data, slot) => + macros.createOseMacro(data, slot) + ); }); +Hooks.on( + "preUpdateCombat", + async (combat, updateData, options, userId) => { + if (!updateData.round) { + return; + } + console.log("SETTING UP INITIATIVE"); + if (game.settings.get('ose', 'individualInit')) { + console.log("PLOP"); + } + } +); + Hooks.on("renderChatLog", (app, html, data) => OseItem.chatListeners(html)); -Hooks.on("getChatLogEntryContext", chat.addChatMessageContextOptions); \ No newline at end of file +Hooks.on("getChatLogEntryContext", chat.addChatMessageContextOptions); diff --git a/src/scss/actor-base.scss b/src/scss/actor-base.scss index cac7d12..b36563a 100644 --- a/src/scss/actor-base.scss +++ b/src/scss/actor-base.scss @@ -242,6 +242,15 @@ grid-area: item-equipped; justify-self: center; } + .item-rollable { + &:hover .item-image { + background-image: url("/icons/svg/d20-grey.svg") !important; + cursor: pointer; + } + .item-image:hover { + background-image: url("/icons/svg/d20-black.svg") !important; + } + } .item-name { text-indent: 8px; text-align: left; @@ -249,18 +258,11 @@ height: 30px; margin: 0; line-height: 30px; - &:hover .item-image { - background-image: url("/icons/svg/d20-grey.svg") !important; - cursor: pointer; - } .item-image { flex-basis: 30px; flex-grow: 0; background-size: contain; background-repeat: no-repeat; - &:hover { - background-image: url("/icons/svg/d20-black.svg") !important; - } } h4 { margin: 0; @@ -307,13 +309,17 @@ .item-unequipped { color: rgba(0, 0, 0, 0.2); } + a:hover { + color: $colorCrimson; + text-shadow: 0 0 5px $colorFaint, 1px 0 5px $colorFaint, 0 1px 5px $colorFaint, 1px 1px 5px $colorFaint; + } } &.spells { .item-titles { line-height: 24px; } .item-controls { - flex-basis: 30px; + flex-basis: 45px; } } } diff --git a/src/scss/apps.scss b/src/scss/apps.scss index 8c15a8c..214b31b 100644 --- a/src/scss/apps.scss +++ b/src/scss/apps.scss @@ -14,9 +14,20 @@ color: white; padding: 2px; box-shadow: 0 0 2px #FFF inset; - text-align: center; margin: 4px 0; - font-size: 16px; + display: flex; + h2 { + border: none; + line-height: 30px; + margin: 0; + text-indent: 10px; + font-size: 16px; + } + img { + border: none; + width: 30px; + height: 30px; + } } .chat-details { padding: 4px; diff --git a/src/templates/actors/partials/character-abilities-tab.html b/src/templates/actors/partials/character-abilities-tab.html index 4604697..9b26693 100644 --- a/src/templates/actors/partials/character-abilities-tab.html +++ b/src/templates/actors/partials/character-abilities-tab.html @@ -41,7 +41,7 @@ {{#each abilities as |item|}}
  • -
    +
    - {{item.roll}} + {{item.data.roll}}
    {{#if ../owner}} + {{/if}} diff --git a/src/templates/actors/partials/character-inventory-tab.html b/src/templates/actors/partials/character-inventory-tab.html index b5d990e..6276222 100644 --- a/src/templates/actors/partials/character-inventory-tab.html +++ b/src/templates/actors/partials/character-inventory-tab.html @@ -14,7 +14,7 @@ {{#each owned.weapons as |item|}}
  • -
    + -
    +
    {{#if ../../owner}} + {{/if}} diff --git a/src/templates/actors/partials/monster-attributes-tab.html b/src/templates/actors/partials/monster-attributes-tab.html index bd343de..d07fc3a 100644 --- a/src/templates/actors/partials/monster-attributes-tab.html +++ b/src/templates/actors/partials/monster-attributes-tab.html @@ -84,7 +84,7 @@ {{#each abilities as |item|}}