mirror of
https://github.com/RoY7x/worldbuilding.git
synced 2025-07-04 05:37:11 -04:00
10: Add attribute groups base implementation
- Added support for attribute groups - Added rollable buttons to formula attributes - Added additional i18n translation strings
This commit is contained in:
parent
c515f8d5b7
commit
f69e3841ff
13 changed files with 827 additions and 151 deletions
|
@ -9,11 +9,15 @@ import { SimpleActor } from "./actor.js";
|
|||
import { SimpleItemSheet } from "./item-sheet.js";
|
||||
import { SimpleActorSheet } from "./actor-sheet.js";
|
||||
import { preloadHandlebarsTemplates } from "./templates.js";
|
||||
import { createWorldbuildingMacro, rollAttrMacro } from "./macro.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Foundry VTT Initialization */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Init hook.
|
||||
*/
|
||||
Hooks.once("init", async function() {
|
||||
console.log(`Initializing Simple Worldbuilding System`);
|
||||
|
||||
|
@ -26,6 +30,12 @@ Hooks.once("init", async function() {
|
|||
decimals: 2
|
||||
};
|
||||
|
||||
game.worldbuilding = {
|
||||
SimpleActor,
|
||||
createWorldbuildingMacro,
|
||||
rollAttrMacro,
|
||||
};
|
||||
|
||||
// Define custom Entity classes
|
||||
CONFIG.Actor.entityClass = SimpleActor;
|
||||
|
||||
|
@ -94,6 +104,11 @@ Hooks.once("init", async function() {
|
|||
preloadHandlebarsTemplates();
|
||||
});
|
||||
|
||||
/**
|
||||
* Macrobar hook.
|
||||
*/
|
||||
Hooks.on("hotbarDrop", (bar, data, slot) => createWorldbuildingMacro(data, slot));
|
||||
|
||||
/**
|
||||
* Adds the actor template context menu.
|
||||
*/
|
||||
|
@ -205,7 +220,7 @@ async function _simpleDirectoryTemplates(entityType = 'actor') {
|
|||
// Setup entity data.
|
||||
let type = entityType == 'actor' ? 'character' : 'item';
|
||||
let createData = {
|
||||
name: `New ${ent}`,
|
||||
name: `${game.i18n.localize("SIMPLE.New")} ${ent}`,
|
||||
type: type,
|
||||
folder: event.currentTarget.dataset.folder
|
||||
};
|
||||
|
@ -231,40 +246,35 @@ async function _simpleDirectoryTemplates(entityType = 'actor') {
|
|||
dlg = await renderTemplate(`systems/worldbuilding/templates/sidebar/entity-create.html`, templateData);
|
||||
|
||||
// Render the confirmation dialog window
|
||||
new Dialog({
|
||||
title: `Create ${createData.name}`,
|
||||
Dialog.confirm({
|
||||
title: `${game.i18n.localize("SIMPLE.Create")} ${createData.name}`,
|
||||
content: dlg,
|
||||
buttons: {
|
||||
create: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: `Create ${ent}`,
|
||||
callback: html => {
|
||||
// Get the form data.
|
||||
const form = html[0].querySelector("form");
|
||||
mergeObject(createData, validateForm(form));
|
||||
yes: html => {
|
||||
// Get the form data.
|
||||
const form = html[0].querySelector("form");
|
||||
mergeObject(createData, validateForm(form));
|
||||
|
||||
// Store the type and name values, and retrieve the template entity.
|
||||
let templateActor = entityCollection.getName(createData.type);
|
||||
// Store the type and name values, and retrieve the template entity.
|
||||
let templateActor = entityCollection.getName(createData.type);
|
||||
|
||||
// If there's a template entity, handle the data.
|
||||
if (templateActor) {
|
||||
// Update the object with the existing template's values.
|
||||
createData = mergeObject(templateActor.data, createData, {inplace: false});
|
||||
createData.type = templateActor.data.type;
|
||||
// Clear the flag so that this doesn't become a new template.
|
||||
delete createData.flags.worldbuilding.isTemplate;
|
||||
}
|
||||
// Otherwise, restore to a valid entity type (character/item).
|
||||
else {
|
||||
createData.type = type;
|
||||
}
|
||||
|
||||
cls.create(createData, {renderSheet: true});
|
||||
}
|
||||
// If there's a template entity, handle the data.
|
||||
if (templateActor) {
|
||||
// Update the object with the existing template's values.
|
||||
createData = mergeObject(templateActor.data, createData, {inplace: false});
|
||||
createData.type = templateActor.data.type;
|
||||
// Clear the flag so that this doesn't become a new template.
|
||||
delete createData.flags.worldbuilding.isTemplate;
|
||||
}
|
||||
// Otherwise, restore to a valid entity type (character/item).
|
||||
else {
|
||||
createData.type = type;
|
||||
}
|
||||
|
||||
cls.create(createData, {renderSheet: true});
|
||||
},
|
||||
default: "create"
|
||||
}).render(true);
|
||||
no: () => {},
|
||||
defaultYes: false
|
||||
});
|
||||
}
|
||||
// Otherwise, just create a blank entity.
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue