Merge branch 'v1.4-choic-type-item' into 'v1.4'

Améliorer le choix du type d'objet à créer #143

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!252
This commit is contained in:
Leratier Bretonnien 2021-05-25 05:39:40 +00:00
commit ebe877400a
9 changed files with 87 additions and 57 deletions

44
lang/fr.json Normal file
View File

@ -0,0 +1,44 @@
{
"ACTOR": {
"TypePersonnage": "Personnage",
"TypeCreature": "Créature",
"TypeEntite": "Entité de cauchemar",
"TypeVehicule": "Véhicule"
},
"ITEM": {
"TypeObjet": "Objet",
"TypeCompetence": "Compétence",
"TypeCompetencecreature": "Compétence de créature",
"TypeMaladie": "Maladie",
"TypePoison": "Poison",
"TypeNombreastral": "Nombre astral",
"TypeTarot": "Carte de tarot",
"TypeCasetmr": "TMR spéciale",
"TypeRencontresTMR": "Rencontre TMR",
"TypeMunition": "Munition",
"TypeMonnaie": "Monnaie",
"TypeHerbe": "Herbe ou plante",
"TypeIngredient": "Ingrédient",
"TypeLivre": "Livre",
"TypePotion": "Potion",
"TypeArme": "Arme",
"TypeArmure": "Armure",
"TypeConteneur": "Conteneur",
"TypeNourritureboisson": "Nourriture & boisson",
"TypeChant": "Chant",
"TypeDanse": "Danse",
"TypeMusique": "Musique",
"TypeOeuvre": "Oeuvre",
"TypeTache": "Tâche",
"TypeJeu": "Jeu",
"TypeRecettealchimique": "Recette alchimique",
"TypeRecettecuisine": "Recette de cuisine",
"TypeSort": "Sort",
"TypeMeditation": "Méditation",
"TypeSignedraconique": "Signe draconique",
"TypeQueue": "Queue de Dragon",
"TypeOmbre": "Ombre de Thanatos",
"TypeSouffle": "Souffle de Dragon",
"TypeTete": "Tête de Dragon"
}
}

View File

@ -108,6 +108,16 @@ export class Misc {
return Misc.data(it)?.data ?? {}
}
static getEntityTypeLabel(entity) {
const documentName = entity?.documentName;
const type = entity?.data.type;
if (documentName === 'Actor' || documentName === 'Item') {
const label = CONFIG[documentName]?.typeLabels?.[type] ?? type;
return game.i18n.has(label) ? game.i18n.localize(label) : t;
}
return type;
}
static connectedGMOrUser(ownerId = undefined) {
if (ownerId && game.user.id == ownerId) {
return ownerId;

View File

@ -13,7 +13,7 @@ export class RdDAudio {
let audioData = context2file[context];
if ( audioData ) {
let audioPath = "systems/foundryvtt-reve-de-dragon/sounds/" + audioData.file;
console.log(`wfrp4e | Playing Sound: ${audioPath}`)
console.log(`foundryvtt-reve-de-dragon | Playing Sound: ${audioPath}`)
AudioHelper.play({ src: audioPath }, audioData.isGlobal);
}
}

View File

@ -1207,8 +1207,7 @@ export class RdDCombat {
data: {
attackerId: this.attackerId,
defenderTokenId: defenderTokenId,
attackerRoll: attackerRoll,
gmId: Misc.connectedGMOrUser(),
attackerRoll: attackerRoll
}
});
}

View File

@ -1,36 +1,5 @@
import { Misc } from "./misc.js";
/* -------------------------------------------- */
/**
* Mapping des types d'Item/Actor vers le nom d'affichage.
* Par défaut, on prend le type avec la première lettre
* majuscule, pas besoin d'ajouter tous les types.
*/
const typeDisplayName = {
"competence": "Compétence",
"herbe": "Plante",
"ingredient": "Ingrédient",
"queue": "Queue de Dragon",
"ombre": "Ombre de Thanatos",
"souffle": "Souffle de Dragon",
"tete": "Tête de Dragon",
"nourritureboisson": "Nourriture & boisson",
"rencontresTMR": "Rencontre des TMR",
"competencecreature": "Compétence de créature",
"nombreastral": "Nombre astral",
"casetmr": "Effet sur TMR",
"recettealchimique": "Recette alchimique",
"recettecuisine": "Recette de cuisine",
"tarot": "Carte de tarot draconique",
"tache": "Tâche",
"meditation": "Méditation",
"musique": "Mélodie",
"chant": "Chanson",
"creature": "Créature",
"entite": "Entité",
"vehicule": "Véhicule"
}
export class RddCompendiumOrganiser {
static init() {
Hooks.on('renderCompendium', async (pack, html, data) => RddCompendiumOrganiser.onRenderCompendium(pack, html, data))
@ -38,22 +7,23 @@ export class RddCompendiumOrganiser {
static async onRenderCompendium(compendium, html, data) {
console.log('onRenderCompendium', compendium, html, data);
let pack = compendium.collection
const pack = compendium.collection
if (pack.metadata.system === 'foundryvtt-reve-de-dragon') {
html.find('.directory-item').each((i, element) => {
const entity = pack.get(element.dataset.documentId);
const entityName = entity?.documentName;
if (entityName === 'Actor' || entityName === 'Item') {
const entityType = entity.data.type;
const typeName = typeDisplayName[entityType] ?? Misc.upperFirst(entitytype);
RddCompendiumOrganiser.insertEntityType(element, typeName);
}
RddCompendiumOrganiser.setEntityTypeName(pack, element);
});
}
}
static insertEntityType(element, type) {
element.children[1].insertAdjacentHTML('afterbegin', `<label>${type}: </label>`);
static async setEntityTypeName(pack, element) {
const label = Misc.getEntityTypeLabel(await pack.getDocument(element.dataset.documentId));
RddCompendiumOrganiser.insertEntityType(element, label);
}
static insertEntityType(element, label) {
if (label) {
element.children[1].insertAdjacentHTML('afterbegin', `<label class="type-compendium">${label}: </label>`);
}
}
}

View File

@ -51,7 +51,7 @@ export class RdDHotbar {
macro = await Macro.create({
name: journal.data.name,
type: "script",
img: "systems/wfrp4e/icons/buildings/scroll.png",
img: "systems/foundryvtt-reve-de-dragon/icons/templates/icone_parchement_vierge.png",
command: command
}, { displaySheet: false })
game.user.assignHotbarMacro(macro, slot);

File diff suppressed because one or more lines are too long

View File

@ -530,6 +530,10 @@ table {border: 1px solid #7a7971;}
overflow: visible;
}
.type-compendium{
font-size: 0.60rem;
}
/* ======================================== */
/* Sheet */
.window-app.sheet .window-content .sheet-header{

View File

@ -320,7 +320,10 @@
}
],
"library": false,
"languages": [],
"languages": [
{ "lang": "en", "name": "English", "path": "lang/fr.json", "unreal": "this is a trick"},
{ "lang": "fr", "name": "Français", "path": "lang/fr.json" }
],
"gridDistance": 1,
"gridUnits": "m",
"primaryTokenAttribute": "sante.vie",