Add auto-computed tables

This commit is contained in:
LeRatierBretonnien 2020-07-04 21:48:40 +02:00
parent e9504f7e3b
commit 46330eed61
4 changed files with 69 additions and 5 deletions

View File

@ -207,7 +207,6 @@ const _manage_inn_roll = async (content, msg) => {
} }
} }
/************************************************************************************/ /************************************************************************************/
let __eis_tables = { "animalmishap":1, "beasthead":1, "coincedentalenc":1, "demonic-mien":1, let __eis_tables = { "animalmishap":1, "beasthead":1, "coincedentalenc":1, "demonic-mien":1,
"expandedmutatemental":1, "expandedmutatephys":1, "fixations":1, "expandedmutatemental":1, "expandedmutatephys":1, "fixations":1,
@ -216,7 +215,27 @@ let __eis_tables = { "animalmishap":1, "beasthead":1, "coincedentalenc":1, "demo
let __wfrp4e_tables = { "career": 1, "critbody":1, "critleg": 1, "doom": 1, "eyes": 1, "majormis": 1, "mutatemental": 1, "oops": 1, "species":1, "travel": 1, let __wfrp4e_tables = { "career": 1, "critbody":1, "critleg": 1, "doom": 1, "eyes": 1, "majormis": 1, "mutatemental": 1, "oops": 1, "species":1, "travel": 1,
"critarm": 1, "crithead": 1, "delirium": 1, "event": 1, "hair": 1, "minormis": 1, "mutatephys": 1, "talents": 1, "wrath": 1 "critarm": 1, "crithead": 1, "delirium": 1, "event": 1, "hair": 1, "minormis": 1, "mutatephys": 1, "talents": 1, "wrath": 1
} }
let __to_table_translate = [ { name:"traits", transl:"Traits"}, {name:"talents", transl:"Talents"}, {name:"skills", transl:"Compétences"} ,
{ name:"careers", transl:"Carrières"}, {name:"spells", transl:"Sorts"}, {name:"prayers", transl:"Bénédictions et Miracles" }
]
/************************************************************************************/
const __create_translation_tables = async (compmod) => {
for (let iterData of __to_table_translate) {
let entityName = compmod+'.' + iterData.name;
let compData = game.packs.get( entityName);
let compFull = await compData.getContent();
let htmlTab = "<table border='1'><tbody>";
for (let entryData of compFull ) {
htmlTab += "<tr><td>"+ entryData.data.originalName + "</td><td>@Compendium["+ entityName + '.' + entryData.id + "]{"+ entryData.name +"}</td></tr>\n";
};
htmlTab += "</table>";
let myjournal = await JournalEntry.create( {name: 'Traduction des ' + iterData.transl, content: htmlTab } );
game.journal.insert( myjournal );
}
}
/************************************************************************************/ /************************************************************************************/
const __check_fix_wrong_modules = ( chatFlag, patchFinished ) => { const __check_fix_wrong_modules = ( chatFlag, patchFinished ) => {
@ -328,7 +347,7 @@ Hooks.once('ready', () => {
setTimeout( __check_fix_wrong_modules, 2000, true, false); setTimeout( __check_fix_wrong_modules, 2000, true, false);
setTimeout( __check_fix_wrong_modules, 10000, false, false); setTimeout( __check_fix_wrong_modules, 10000, false, false);
setTimeout( __check_fix_wrong_modules, 20000, false, true); setTimeout( __check_fix_wrong_modules, 20000, false, true);
const lang = game.settings.get('core', 'language'); const lang = game.settings.get('core', 'language');
if ( lang == "fr" ) { if ( lang == "fr" ) {
@ -372,4 +391,17 @@ Hooks.once('ready', () => {
} ); } );
game.packs = new Collection( pack_array ); game.packs = new Collection( pack_array );
} }
/* Uncomment this to auto-create the translation tables
let compmod = "wfrp4e";
// Check various settings in the installation
game.modules.forEach((module, name) => {
if ( name == "wfrp4e-content" && module.active) {
compmod = "wfrp4e-content";
}
} );
// Auto-create translation journal tables
__create_translation_tables(compmod);
*/
} ); } );

View File

@ -178,7 +178,7 @@ Hooks.once('init', () => {
lang: 'fr', lang: 'fr',
dir: 'compendium' dir: 'compendium'
}); });
Babele.get().registerConverters({ Babele.get().registerConverters({
"career_skills": (skills_list) => { "career_skills": (skills_list) => {
var compendium = game.packs.find(p => p.collection === compmod+'.skills'); var compendium = game.packs.find(p => p.collection === compmod+'.skills');

View File

@ -3,7 +3,7 @@
"name": "WH4-fr-translation", "name": "WH4-fr-translation",
"title": "Traduction du module WH4 en Français.", "title": "Traduction du module WH4 en Français.",
"description": "La traduction du module WH4.", "description": "La traduction du module WH4.",
"version": "1.0.4", "version": "1.1.0",
"minimumCoreVersion" : "0.6.0", "minimumCoreVersion" : "0.6.0",
"compatibleCoreVersion": "1.0.0", "compatibleCoreVersion": "1.0.0",
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
@ -33,6 +33,14 @@
"path": "packs/plats-dauberges.db", "path": "packs/plats-dauberges.db",
"system": "wfrp4e", "system": "wfrp4e",
"module": "WH4-fr-translation" "module": "WH4-fr-translation"
},
{
"label": "Tables des Traduction",
"entity": "JournalEntry",
"name": "tables-des-traductions",
"path": "packs/tables-des-traductions.db",
"system": "wfrp4e",
"module": "WH4-fr-translation"
} }
], ],
"languages": [{ "languages": [{

File diff suppressed because one or more lines are too long