Skip to content

Commit

Permalink
Release version 1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Relic-Repo committed Jan 18, 2025
1 parent 1928f25 commit e9c5d41
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 53 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to the CRUX module will be documented in this file.

## [2024-01-18]

### Added
- New charge modification feature:
- Shift + Left Click to increase item charges
- Now uses Shift + Right Click to decrease item charges

- New settings to control visibility of main sections:
- Show/Hide Favorites Section
- Show/Hide Equipped Section
- Show/Hide Features Section
- Show/Hide Spells Section
- Show/Hide Inventory Section
Each section can be individually toggled and is visible by default.

## [2024-01-16]

### Current Features
Expand Down Expand Up @@ -33,7 +48,6 @@ All notable changes to the CRUX module will be documented in this file.

- Interactive Features
- Flippable character portrait with stats
- Right-click fast-forward activation
- Expandable item descriptions
- Quick access to ability checks and saves
- Combat turn management
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ Items are tagged for easy identification when they are:
### Interactive Features
- Flippable character portrait (click to flip for more Stats)
- Click item name to expand and view description
- Charge modification for items with uses:
- Hold Shift + Left Click to increase charges
- Hold Shift + Right Click to decrease charges
- Middle Click Opens Item Sheet
- Clicking on Name Expands Description
- Clicking on Image Rolls Item.
- Quick access to:
- Ability checks and saves
- End turn function (in combat)
Expand All @@ -74,6 +80,14 @@ Items are tagged for easy identification when they are:
- Automatic: Toggle for players, Selection-based for DMs
- Always Show: Persistent display

- **Section Visibility**:
- Show/Hide Favorites Section
- Show/Hide Equipped Section
- Show/Hide Features Section
- Show/Hide Spells Section
- Show/Hide Inventory Section
Each section can be individually toggled through settings

- **Visual Settings**:
- Three icon sizes (Small, Medium, Large)
- Two tray widths (Small, Large)
Expand Down
12 changes: 11 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,17 @@
"sub-sections-expanded": "Sub-Sections Default State",
"sub-sections-expanded-hint": "Choose whether sub-sections (like spell levels) start open or collapsed by default",
"use-tidy5e-sections": "Use Tidy 5e Sheet Sections",
"use-tidy5e-sections-hint": "When enabled, recognizes and uses Tidy 5e Sheet sections instead of standard Crux sections"
"use-tidy5e-sections-hint": "When enabled, recognizes and uses Tidy 5e Sheet sections instead of standard Crux sections",
"show-favorites-section": "Show Favorites Section",
"show-favorites-section-hint": "Display the Favorites section in the tray",
"show-equipped-section": "Show Equipped Section",
"show-equipped-section-hint": "Display the Equipped section in the tray",
"show-features-section": "Show Features Section",
"show-features-section-hint": "Display the Features section in the tray",
"show-spells-section": "Show Spells Section",
"show-spells-section-hint": "Display the Spells section in the tray",
"show-inventory-section": "Show Inventory Section",
"show-inventory-section-hint": "Display the Inventory section in the tray"
},
"item-context": {
"show": "Show in Crux",
Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"id": "crux",
"title": "Crux",
"description": "Adds an expanding tray for using an actor's items, abilities and spells",
"version": "1.0.6",
"version": "1.0.7",
"url": "https://github.com/Relic-Repo/crux",
"manifest": "https://github.com/Relic-Repo/crux/releases/latest/download/module.json",
"download": "https://github.com/Relic-Repo/crux/releases/download/1.0.6/module.zip",
"download": "https://github.com/Relic-Repo/crux/releases/download/1.0.7/module.zip",
"compatibility": {
"minimum": "12",
"verified": "12"
Expand Down
2 changes: 1 addition & 1 deletion packs/crux-items/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000041
MANIFEST-000045
6 changes: 3 additions & 3 deletions packs/crux-items/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2025/01/17-18:32:09.868 2100 Recovering log #40
2025/01/17-18:32:09.904 2100 Delete type=0 #40
2025/01/17-18:32:09.905 2100 Delete type=3 #39
2025/01/18-11:01:09.487 3238 Recovering log #44
2025/01/18-11:01:09.517 3238 Delete type=0 #44
2025/01/18-11:01:09.524 3238 Delete type=3 #43
6 changes: 3 additions & 3 deletions packs/crux-items/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2025/01/17-16:58:20.003 3cc0 Recovering log #38
2025/01/17-16:58:20.054 3cc0 Delete type=0 #38
2025/01/17-16:58:20.062 3cc0 Delete type=3 #37
2025/01/18-10:34:52.976 1514 Recovering log #42
2025/01/18-10:34:53.008 1514 Delete type=0 #42
2025/01/18-10:34:53.010 1514 Delete type=3 #41
2 changes: 1 addition & 1 deletion packs/crux-macro/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000041
MANIFEST-000045
6 changes: 3 additions & 3 deletions packs/crux-macro/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2025/01/17-18:32:09.924 3af0 Recovering log #40
2025/01/17-18:32:09.969 3af0 Delete type=0 #40
2025/01/17-18:32:09.972 3af0 Delete type=3 #39
2025/01/18-11:01:09.542 47c4 Recovering log #44
2025/01/18-11:01:09.564 47c4 Delete type=0 #44
2025/01/18-11:01:09.567 47c4 Delete type=3 #43
6 changes: 3 additions & 3 deletions packs/crux-macro/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2025/01/17-16:58:20.072 34ac Recovering log #38
2025/01/17-16:58:20.122 34ac Delete type=0 #38
2025/01/17-16:58:20.122 34ac Delete type=3 #37
2025/01/18-10:34:53.024 31cc Recovering log #42
2025/01/18-10:34:53.047 31cc Delete type=0 #42
2025/01/18-10:34:53.050 31cc Delete type=3 #41
46 changes: 46 additions & 0 deletions scripts/cruxSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,51 @@ import { updateTray } from "./cruxTrayUI.js";
* Configuration settings for the CRUX module
*/
export const SETTINGS = {
"show-favorites-section": {
name: "Show Favorites Section",
hint: "Display the Favorites section in the tray.",
scope: "client",
config: true,
type: Boolean,
default: true,
onChange: () => updateTray()
},
"show-equipped-section": {
name: "Show Equipped Section",
hint: "Display the Equipped section in the tray.",
scope: "client",
config: true,
type: Boolean,
default: true,
onChange: () => updateTray()
},
"show-features-section": {
name: "Show Features Section",
hint: "Display the Features section in the tray.",
scope: "client",
config: true,
type: Boolean,
default: true,
onChange: () => updateTray()
},
"show-spells-section": {
name: "Show Spells Section",
hint: "Display the Spells section in the tray.",
scope: "client",
config: true,
type: Boolean,
default: true,
onChange: () => updateTray()
},
"show-inventory-section": {
name: "Show Inventory Section",
hint: "Display the Inventory section in the tray.",
scope: "client",
config: true,
type: Boolean,
default: true,
onChange: () => updateTray()
},
"assume-default-character": {
name: "Assume Default Character",
hint: "When no other token is selected, show the tray for the user's default character (usually only set for players). This can help with scenes with no tokens (or a generic party token) visible.",
Expand Down Expand Up @@ -273,4 +318,5 @@ Hooks.once('init', () => {
}
}
});

});
134 changes: 99 additions & 35 deletions scripts/cruxTrayUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,20 @@ export async function updateTray() {
return Object.values(object).some(v => hasItems(v));
}

function isSectionEnabled(key) {
const settingMap = {
favorites: "show-favorites-section",
equipped: "show-equipped-section",
feature: "show-features-section",
spell: "show-spells-section",
inventory: "show-inventory-section"
};
const setting = settingMap[key];
return !setting || game.settings.get("crux", setting);
}

return Object.entries(sections).reduce((acc, [key, value]) => {
if (key === 'favorites' || hasItems(value)) {
if ((key === 'favorites' || hasItems(value)) && isSectionEnabled(key)) {
acc[key] = value;
}
return acc;
Expand Down Expand Up @@ -341,16 +353,33 @@ export async function updateTray() {
event.preventDefault();
const itemUuid = event.currentTarget.closest(".item").dataset.itemUuid;
const item = fromUuid(itemUuid);
if (item) {
if (!game.modules.get("wire")?.active && game.modules.get("itemacro")?.active && game.settings.get("itemacro", "defaultmacro")) {
if (item.hasMacro()) {
item.executeMacro();
return false;
}
if (!item) return false;
// Handle charge modifications with Shift key
if (event.shiftKey && item.system.uses?.max > 0) {
const currentValue = item.system.uses.value;
const maxValue = item.system.uses.max;
let newValue;

if (event.which === 1) { // Left click
newValue = Math.min(currentValue + 1, maxValue);
} else if (event.which === 3) { // Right click
newValue = Math.max(currentValue - 1, 0);
}

item.use({}, event);
if (newValue !== undefined && newValue !== currentValue) {
item.update({"system.uses.value": newValue});
return false;
}
}

if (!game.modules.get("wire")?.active && game.modules.get("itemacro")?.active && game.settings.get("itemacro", "defaultmacro")) {
if (item.hasMacro()) {
item.executeMacro();
return false;
}
}

item.use({}, event);
return false;
}

Expand All @@ -368,43 +397,78 @@ export async function updateTray() {
Hooks.callAll(hookName, item, $(event.currentTarget));
}

html.find('.rollable .item-image').mousedown(roll);
html.find('.rollable .item-image, .rollable.item-name').mousedown(async function(event) {
event.preventDefault();
const itemUuid = event.currentTarget.closest(".item").dataset.itemUuid;
const item = fromUuid(itemUuid);
if (!item) return false;

// Handle shift-click for both image and name
if (event.shiftKey && item.system.uses?.max > 0) {
const currentValue = item.system.uses.value;
const maxValue = item.system.uses.max;
let newValue;

if (event.which === 1) { // Left click
newValue = Math.min(currentValue + 1, maxValue);
} else if (event.which === 3) { // Right click
newValue = Math.max(currentValue - 1, 0);
}

html.find('.rollable.item-name')
.hover(
event => hover(event, "actorItemHoverIn"),
event => hover(event, "actorItemHoverOut")
);
if (newValue !== undefined && newValue !== currentValue) {
await item.update({"system.uses.value": newValue});
return false;
}
}

html.find('.rollable.item-name').mousedown(async function(event) {
if (event.which == 2) {
// Handle middle-click on name
if ($(event.currentTarget).hasClass('item-name') && event.which === 2) {
return openSheet(event);
}

event.preventDefault();
const li = $(event.currentTarget).parents(".item");
const item = await fromUuid(li.data("item-uuid"));
const chatData = await item.getChatData({ secrets: item.actor.isOwner });
// Handle normal click on name (expand description)
if ($(event.currentTarget).hasClass('item-name') && !event.shiftKey) {
const li = $(event.currentTarget).closest(".item");
const chatData = await item.getChatData({ secrets: item.actor.isOwner });

if (li.hasClass("expanded")) {
let summary = li.children(".item-summary");
summary.slideUp(200, () => summary.remove());
} else {
let div = $(`<div class="item-summary">${chatData.description.value}</div>`);
let props = $('<div class="item-properties"></div>');
chatData.properties.forEach(p => props.append(`<span class="tag">${p}</span>`));
div.append(props);
li.append(div.hide());
div.slideDown(200);
}
li.toggleClass("expanded");
return false;
}

if (li.hasClass("expanded")) {
let summary = li.children(".item-summary");
summary.slideUp(200, () => summary.remove());
} else {
let div = $(`<div class="item-summary">${chatData.description.value}</div>`);
let props = $('<div class="item-properties"></div>');
chatData.properties.forEach(p => props.append(`<span class="tag">${p}</span>`));
div.append(props);
li.append(div.hide());
div.slideDown(200);
}
li.toggleClass("expanded");
// Handle normal click on image (use item)
if (!event.shiftKey) {
if (!game.modules.get("wire")?.active && game.modules.get("itemacro")?.active && game.settings.get("itemacro", "defaultmacro")) {
if (item.hasMacro()) {
item.executeMacro();
return false;
}
}
item.use({}, event);
}
return false;
});

html.find('.rollable.item-name').hover(
event => hover(event, "actorItemHoverIn"),
event => hover(event, "actorItemHoverOut")
);

html.find('.rollable.item-recharge').mousedown(function(event) {
const li = $(event.currentTarget).parents(".item");
const item = fromUuid(li.data("item-uuid"));
handleItemRecharge(item);
event.preventDefault();
const itemUuid = event.currentTarget.closest(".item").dataset.itemUuid;
const item = fromUuid(itemUuid);
if (item) handleItemRecharge(item);
return false;
});

Expand Down

0 comments on commit e9c5d41

Please sign in to comment.