Skip to content

Commit

Permalink
Merge pull request #33 from napolitanod/1.1.11
Browse files Browse the repository at this point in the history
1.1.11
  • Loading branch information
napolitanod authored May 8, 2023
2 parents bec749c + 8ae405d commit d8c6fbc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"styles/napolitano-scripts.css"
],
"title": "_Napolitano Scripts",
"version": "1.1.10",
"version": "1.1.11",
"url": "https://github.com/napolitanod/napolitano-scripts",
"manifest": "https://raw.githubusercontent.com/napolitanod/napolitano-scripts/master/module.json",
"download": "https://github.com/napolitanod/napolitano-scripts/releases/download/1.1.10/module.zip"
"download": "https://github.com/napolitanod/napolitano-scripts/releases/download/1.1.11/module.zip"
}
23 changes: 12 additions & 11 deletions scripts/hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@ import {hudHover, hudHoverOut} from "./tooltip.js";
import {macros} from './macros.js';

export function buildHud(html, token){
let combatactions = $('<div>').addClass("tah-actions").addClass("napolitano-tah-actions")
let hudActions = $('<div>').addClass("tah-actions").addClass("napolitano-tah-actions")
for (const [k,option] of Object.entries(HUDOPTIONS).sort(([,a],[,b]) => a.name.localeCompare(b.name))){
combatactions.append(
hudActions.append(
$('<div>').addClass("tah-action").append(
$('<button>').data("data-id", {token: token.id, ruleset: k}).click(_run).append(
$('<button>').addClass("tah-action-button").data("data-id", {token: token.id, ruleset: k}).click(_run).append(
$('<span>').addClass("tah-action-button-content").append(
$('<div>').addClass("tah-action-button-text").html(option.name)
)
)
)
)
}
const titlebutton = $('<button>').addClass("tah-category-button").addClass("disable-edit").val("combatactions").attr("data-name", "Combat").append(
$('<span>').addClass("tah-category-button-content").append(
$('<div>').addClass("tah-category-button-text").html('Combat')
}
let combatactions = $('<div>').addClass("tah-groups").append(hudActions)
const titlebutton = $('<button>').addClass("tah-group-button").addClass("disable-edit").val("combatactions").attr("data-name", "Combat").append(
$('<span>').addClass("tah-button-content").append(
$('<div>').addClass("tah-button-text").html('Combat')
)
)
const subcategory = $('<div>').addClass("tah-subcategories-wrapper").addClass("expand-down").append($('<div>').addClass("tah-subcategories").addClass("napolitano-tah-subcategories").append($('<div>').addClass("tah-subcategory").attr("data-has-actions","true").attr("data-show-title","true").append($('<div>').addClass("tah-subtitle").addClass("disable-edit").attr("data-type","system").attr("id","combat_actions").attr("data-has-derived-subcategories", "false").html('Actions')).append(combatactions)))
const category = $('<div>').addClass("tah-category").attr('id', 'tah-category-combatactions').attr('data-type', 'custom').hover(_hudCategoryHover, _hudCategoryHoverOut).append(titlebutton).append(subcategory)
$(html).find(`div[id="tah-category-attributes"]`).after(category)
const subcategory = $('<div>').addClass("tah-groups-container").addClass("expand-down").append($('<div>').addClass("tah-groups").addClass("napolitano-tah-subcategories").append($('<div>').addClass("tah-list-groups").append($('<div>').addClass("tah-group").attr("data-has-actions","true").attr("data-level","2").attr("data-type","system").attr("data-show-title","true").append($('<div>').addClass("tah-subtitle").addClass("disable-edit").attr("data-type","system").attr("id","combat_actions").attr("data-has-derived-subcategories", "false").html('Actions')).append(combatactions))))
const category = $('<div>').addClass("tah-tab-group").attr('id', 'tah-group-combatactions').attr('data-type', 'custom').hover(_hudCategoryHover, _hudCategoryHoverOut).append(titlebutton).append(subcategory)
$(html).find(`div[id="tah-group-attributes"]`).after(category)
return html
}

export function setHudHelp(html, token){
if(token?.actor?.items?.size){
for(const item of token.actor.items){
const id = `${item.type === 'feat' ? 'feature' : (item.type ==='spell' ? 'spell' : 'item')}|${token.actor.id}|${token.id}|${item.id}`
const id = `${item.type === 'feat' ? 'feature' : (item.type ==='spell' ? 'spell' : 'item')}|${item.id}` //|${token.actor.id}|${token.id}|${item.id}`
const res = $(html).find(`button[value="${id}"]`)
res.data("data-id", {uuid: item.uuid}).hover(hudHover, hudHoverOut)
}
Expand Down
4 changes: 3 additions & 1 deletion scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ Hooks.once('ready', async function() {
});

HOOKIDS['renderTokenActionHud'] = Hooks.on('renderTokenActionHud', async function(hud, html, options = {}){
const token = canvas.scene.tokens.find(t => t.id === options.actions?.tokenId)
//const token = canvas.scene.tokens.find(t => t.id === options.actions?.tokenId)
const token = hud?.token?.document
console.log(token)
if(!token) return
html = setHudHelp(html, token)
html = buildHud(html, token)
Expand Down

0 comments on commit d8c6fbc

Please sign in to comment.