Added item icon on hotbar drop (#54)
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
Date format : day/month/year
|
Date format : day/month/year
|
||||||
|
|
||||||
## 1.11.1 - ??/05/2024 - Little fixes again
|
## 1.11.1 - ??/05/2024 - Some QoL
|
||||||
- Added ability to players to set their default Item's windows height in settings (#55).
|
- Added ability to players to set their default Item's windows height in settings (#55).
|
||||||
|
- Macro : Added item icon on hotbar drop (#54).
|
||||||
- Moved `The blade with no name: Ancestral sword of the Dragon [Blessed Treasure]` from items to weapons compendium.
|
- Moved `The blade with no name: Ancestral sword of the Dragon [Blessed Treasure]` from items to weapons compendium.
|
||||||
|
|
||||||
## 1.11.0 - 13/12/2023 - Little fixes
|
## 1.11.0 - 13/12/2023 - Little fixes
|
||||||
|
|||||||
@@ -203,6 +203,11 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
|||||||
|
|
||||||
let itemData = item.toObject(true);
|
let itemData = item.toObject(true);
|
||||||
|
|
||||||
|
// If from another actor, break the link
|
||||||
|
if (itemData.system.parent_id !== null && itemData.system.parent_id.actor_id !== this.actor._id) {
|
||||||
|
itemData.system.parent_id = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Item subtype specific
|
// Item subtype specific
|
||||||
switch (itemData.type) {
|
switch (itemData.type) {
|
||||||
case "army_cohort":
|
case "army_cohort":
|
||||||
@@ -247,11 +252,10 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
|||||||
itemData.system.xp_used = 0;
|
itemData.system.xp_used = 0;
|
||||||
itemData.system.in_curriculum = true;
|
itemData.system.in_curriculum = true;
|
||||||
} else {
|
} else {
|
||||||
// Check if technique is allowed for this character
|
// Informative message : Check if technique is allowed for this character
|
||||||
// if (!game.user.isGM && !this.actor.system.techniques[itemData.system.technique_type]) {
|
if (!game.user.isGM && !this.actor.system.techniques[itemData.system.technique_type]) {
|
||||||
// ui.notifications.info("l5r5e.techniques.not_allowed", {localize: true});
|
ui.notifications.info("l5r5e.techniques.not_allowed", {localize: true});
|
||||||
// return;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// Verify cost
|
// Verify cost
|
||||||
itemData.system.xp_cost =
|
itemData.system.xp_cost =
|
||||||
@@ -277,12 +281,10 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
|||||||
if (li.dataset.itemParentId && li.dataset.itemId) {
|
if (li.dataset.itemParentId && li.dataset.itemId) {
|
||||||
const item = this.actor.items.get(li.dataset.itemParentId)?.items.get(li.dataset.itemId);
|
const item = this.actor.items.get(li.dataset.itemParentId)?.items.get(li.dataset.itemId);
|
||||||
if (item) {
|
if (item) {
|
||||||
const dragData = {
|
event.dataTransfer.setData("text/plain", JSON.stringify({
|
||||||
type: "Item",
|
type: "Item",
|
||||||
data: foundry.utils.duplicate(item),
|
uuid: item.uuid,
|
||||||
};
|
}));
|
||||||
dragData.data.system.parent_id = null;
|
|
||||||
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,11 +289,10 @@ export class TwentyQuestionsDialog extends FormApplication {
|
|||||||
`L5R5E | 20Q | This technique is not a school ability : ${item.system.technique_type}`
|
`L5R5E | 20Q | This technique is not a school ability : ${item.system.technique_type}`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
} else if (!this.object.data.step3.allowed_techniques?.[item.system.technique_type]) {
|
||||||
|
// Informative message : Tech not allowed
|
||||||
|
ui.notifications.info("l5r5e.techniques.not_allowed", {localize: true});
|
||||||
}
|
}
|
||||||
// } else if (!this.object.data.step3.allowed_techniques?.[item.system.technique_type]) {
|
|
||||||
// // Tech not allowed
|
|
||||||
// ui.notifications.info("l5r5e.techniques.not_allowed", {localize: true});
|
|
||||||
// return;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -685,9 +685,9 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
macro = await Macro.create({
|
macro = await Macro.create({
|
||||||
name,
|
name,
|
||||||
type: "script",
|
type: "script",
|
||||||
scope: "global",
|
scope: "actor",
|
||||||
command,
|
command,
|
||||||
img: this._actor?.img ? this._actor.img : "systems/l5r5e/assets/dices/default/ring_et.svg",
|
img: this._actor?.img || "systems/l5r5e/assets/dices/default/ring_et.svg",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ export default class HooksL5r5e {
|
|||||||
game.l5r5e.migrations.migrateWorld({ force: false }).then();
|
game.l5r5e.migrations.migrateWorld({ force: false }).then();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Taken from dnd5 : Wait to register hotbar drop hook on ready so that modules could register earlier if they want to
|
||||||
|
Hooks.on("hotbarDrop", (bar, data, slot) => {
|
||||||
|
if (data.type === "Item") {
|
||||||
|
HooksL5r5e.#createItemMacro(data, slot);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// For some reasons, not always really ready, so wait a little
|
// For some reasons, not always really ready, so wait a little
|
||||||
await new Promise((r) => setTimeout(r, 2000));
|
await new Promise((r) => setTimeout(r, 2000));
|
||||||
|
|
||||||
@@ -76,9 +84,7 @@ export default class HooksL5r5e {
|
|||||||
skillsList: "artisan,martial,scholar,social,trade",
|
skillsList: "artisan,martial,scholar,social,trade",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
ui.notifications.info(
|
ui.notifications.info("l5r5e.dice.dicepicker.gm_request_dp_to_players", {localize: true});
|
||||||
game.i18n.localize("l5r5e.dice.dicepicker.gm_request_dp_to_players")
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
3000,
|
3000,
|
||||||
true
|
true
|
||||||
@@ -313,4 +319,35 @@ export default class HooksL5r5e {
|
|||||||
context.blind = true;
|
context.blind = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to create a macro from the dropped data. Will use an existing macro if one exists.
|
||||||
|
* @param {object} dropData The dropped data
|
||||||
|
* @param {number} slot The hotbar slot to use
|
||||||
|
* @returns {Promise}
|
||||||
|
*/
|
||||||
|
static async #createItemMacro(dropData, slot) {
|
||||||
|
const itemData = await Item.implementation.fromDropData(dropData);
|
||||||
|
if (!itemData) {
|
||||||
|
console.log("L5R5E | HK | Fail to get itemData", dropData);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const macroData = {
|
||||||
|
type: "script",
|
||||||
|
scope: "actor",
|
||||||
|
name: (itemData.actor?.name ? `${itemData.actor?.name} : ` : '') + itemData.name,
|
||||||
|
img: itemData.img,
|
||||||
|
command: `await Hotbar.toggleDocumentSheet("${itemData.uuid}")`,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Assign the macro to the hotbar
|
||||||
|
const macro = game.macros.find((m) =>
|
||||||
|
m.name === macroData.name
|
||||||
|
&& m.command === macroData.command
|
||||||
|
&& m.isAuthor
|
||||||
|
) || await Macro.create(macroData);
|
||||||
|
|
||||||
|
await game.user.assignHotbarMacro(macro, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user