Améliorer le choix du type d'objet à créer #143
Utilisation du fichier de langue Utilisation de la même référence pour les compendiums Fix sur les compendium, le type n'apparaissait pas toujours
This commit is contained in:
parent
8e53759170
commit
286eaafe4e
44
lang/fr.json
Normal file
44
lang/fr.json
Normal 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"
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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>`);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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{
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user