Refactor the way of symbols was handled, now compatible with "monks enhanced journal".

This commit is contained in:
Vlyan
2022-04-19 19:27:42 +02:00
parent 93e2bd23f8
commit 597c5a0b49
25 changed files with 38 additions and 90 deletions

View File

@@ -3,12 +3,14 @@ Date format : day/month/year
## 1.7.2 - ??/??/2022 - ? ## 1.7.2 - ??/??/2022 - ?
- Added 179 Japanese' style villages name table. - Added 179 Japanese' style villages name table.
- Added Rōnin icon tag symbol (thanks to TesserWract).
- Fixed : Missing translation for EN and ES - "Armors, Weapons, and Items" in Npc Generator dialog. - Fixed : Missing translation for EN and ES - "Armors, Weapons, and Items" in Npc Generator dialog.
- Compendium : Updated Weapon Names and Grips, thanks to TesserWract : - Compendium : Updated Weapon Names and Grips, thanks to TesserWract :
- Added "N/A" to invalid weapon grips. - Added "N/A" to invalid weapon grips.
- Grips with more than one quality and/or style now use a more consistent format: "(style): Quality 1, Quality 2, ..." - Grips with more than one quality and/or style now use a more consistent format: "(style): Quality 1, Quality 2, ..."
- Renamed "Tinbe-Rochin" to "Rochin" as the DB entry is for the single item rather than the item pair. - Renamed "Tinbe-Rochin" to "Rochin" as the DB entry is for the single item rather than the item pair.
- Added macrons to relevant weapon names. - Added macrons to relevant weapon names.
- Refactor the way of symbols was handled, now compatible with "monks enhanced journal".
## 1.7.1 - 01/04/2022 - Spring fixes ## 1.7.1 - 01/04/2022 - Spring fixes
- PC/NPC sheet : - PC/NPC sheet :

View File

@@ -78,29 +78,13 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
* @override * @override
*/ */
activateEditor(name, options = {}, initialContent = "") { activateEditor(name, options = {}, initialContent = "") {
// Symbols Compatibility with old compendium modules (PRE l5r v1.7.2)
if (["data.army_abilities", "data.supplies_logistics", "data.past_battles"].includes(name) && initialContent) { if (["data.army_abilities", "data.supplies_logistics", "data.past_battles"].includes(name) && initialContent) {
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false); initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
} }
super.activateEditor(name, options, initialContent); super.activateEditor(name, options, initialContent);
} }
/**
* This method is called upon form submission after form data is validated
* @param event {Event} The initial triggering submission event
* @param formData {Object} The object of validated form data with which to update the object
* @returns {Promise} A Promise which resolves once the update operation has completed
* @override
*/
async _updateObject(event, formData) {
["data.army_abilities", "data.supplies_logistics", "data.past_battles"].forEach((name) => {
if (!formData[name]) {
return;
}
formData[name] = game.l5r5e.HelpersL5r5e.convertSymbols(formData[name], true);
});
return super._updateObject(event, formData);
}
/** /**
* Subscribe to events from the sheet. * Subscribe to events from the sheet.
* @param {jQuery} html HTML content of the sheet. * @param {jQuery} html HTML content of the sheet.

View File

@@ -104,6 +104,7 @@ export class BaseSheetL5r5e extends ActorSheet {
* @override * @override
*/ */
activateEditor(name, options = {}, initialContent = "") { activateEditor(name, options = {}, initialContent = "") {
// Symbols Compatibility with old compendium modules (PRE l5r v1.7.2)
if (["data.notes", "data.description"].includes(name) && initialContent) { if (["data.notes", "data.description"].includes(name) && initialContent) {
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false); initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
} }
@@ -123,14 +124,6 @@ export class BaseSheetL5r5e extends ActorSheet {
delete formData["autoCompleteListName"]; delete formData["autoCompleteListName"];
delete formData["autoCompleteListSelectedIndex"]; delete formData["autoCompleteListSelectedIndex"];
} }
// Symbols
["data.notes", "data.description"].forEach((name) => {
if (!formData[name]) {
return;
}
formData[name] = game.l5r5e.HelpersL5r5e.convertSymbols(formData[name], true);
});
return super._updateObject(event, formData); return super._updateObject(event, formData);
} }

View File

@@ -47,7 +47,7 @@ export const RegisterHandlebars = function () {
/* ------------------------------------ */ /* ------------------------------------ */
/* Utility */ /* Utility */
/* ------------------------------------ */ /* ------------------------------------ */
// Json - Display a object in textarea (for debug) // Json - Display an object in textarea (for debug)
Handlebars.registerHelper("json", function (...objects) { Handlebars.registerHelper("json", function (...objects) {
objects.pop(); // remove this function call objects.pop(); // remove this function call
return new Handlebars.SafeString(objects.map((e) => `<textarea>${JSON.stringify(e)}</textarea>`)); return new Handlebars.SafeString(objects.map((e) => `<textarea>${JSON.stringify(e)}</textarea>`));
@@ -64,6 +64,11 @@ export const RegisterHandlebars = function () {
return objects.join(""); return objects.join("");
}); });
// enrichHTML
Handlebars.registerHelper("enrichHTML", function (text, options = {}) {
return TextEditor.enrichHTML(text, options);
});
// Add a setter // Add a setter
Handlebars.registerHelper("setVar", function (varName, varValue, options) { Handlebars.registerHelper("setVar", function (varName, varValue, options) {
options.data.root[varName] = varValue; options.data.root[varName] = varValue;

View File

@@ -48,26 +48,13 @@ export class ArmyCohortSheetL5r5e extends ItemSheetL5r5e {
* @override * @override
*/ */
activateEditor(name, options = {}, initialContent = "") { activateEditor(name, options = {}, initialContent = "") {
// Symbols Compatibility with old compendium modules (PRE l5r v1.7.2)
if (name === "data.abilities" && initialContent) { if (name === "data.abilities" && initialContent) {
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false); initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
} }
super.activateEditor(name, options, initialContent); super.activateEditor(name, options, initialContent);
} }
/**
* This method is called upon form submission after form data is validated
* @param event {Event} The initial triggering submission event
* @param formData {Object} The object of validated form data with which to update the object
* @returns {Promise} A Promise which resolves once the update operation has completed
* @override
*/
async _updateObject(event, formData) {
if (formData["data.abilities"]) {
formData["data.abilities"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.abilities"], true);
}
return super._updateObject(event, formData);
}
/** /**
* Subscribe to events from the sheet. * Subscribe to events from the sheet.
* @param {jQuery} html HTML content of the sheet. * @param {jQuery} html HTML content of the sheet.

View File

@@ -61,29 +61,13 @@ export class BaseItemSheetL5r5e extends ItemSheet {
* @override * @override
*/ */
activateEditor(name, options = {}, initialContent = "") { activateEditor(name, options = {}, initialContent = "") {
// Symbols Compatibility with old compendium modules (PRE l5r v1.7.2)
if (name === "data.description" && initialContent) { if (name === "data.description" && initialContent) {
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false); initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
} }
super.activateEditor(name, options, initialContent); super.activateEditor(name, options, initialContent);
} }
/**
* This method is called upon form submission after form data is validated
* @param event {Event} The initial triggering submission event
* @param formData {Object} The object of validated form data with which to update the object
* @returns {Promise} A Promise which resolves once the update operation has completed
* @override
*/
async _updateObject(event, formData) {
if (formData["data.description"]) {
// Base links (Journal, compendiums...)
formData["data.description"] = TextEditor.enrichHTML(formData["data.description"]);
// L5R Symbols
formData["data.description"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.description"], true);
}
return super._updateObject(event, formData);
}
/** /**
* Subscribe to events from the sheet. * Subscribe to events from the sheet.
* @param {jQuery} html HTML content of the sheet. * @param {jQuery} html HTML content of the sheet.

View File

@@ -46,26 +46,13 @@ export class BaseJournalSheetL5r5e extends JournalSheet {
* @override * @override
*/ */
activateEditor(name, options = {}, initialContent = "") { activateEditor(name, options = {}, initialContent = "") {
// For Compatibility with old compendium modules (PRE l5r v1.7.2)
if (initialContent) { if (initialContent) {
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false); initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
} }
super.activateEditor(name, options, initialContent); super.activateEditor(name, options, initialContent);
} }
/**
* This method is called upon form submission after form data is validated
* @param event {Event} The initial triggering submission event
* @param formData {Object} The object of validated form data with which to update the object
* @returns {Promise} A Promise which resolves once the update operation has completed
* @override
*/
async _updateObject(event, formData) {
if (formData.content) {
formData.content = game.l5r5e.HelpersL5r5e.convertSymbols(formData.content, true);
}
return super._updateObject(event, formData);
}
/** /**
* Subscribe to events from the sheet. * Subscribe to events from the sheet.
* @param {jQuery} html HTML content of the sheet. * @param {jQuery} html HTML content of the sheet.

View File

@@ -200,6 +200,12 @@ Hooks.once("init", async () => {
makeDefault: true, makeDefault: true,
}); });
// Override enrichHTML for Symbol replacement
const oldEnrichHTML = TextEditor.prototype.constructor.enrichHTML;
TextEditor.prototype.constructor.enrichHTML = function (content, options = {}) {
return HelpersL5r5e.convertSymbols(oldEnrichHTML.call(this, content, options), true);
};
// Override the default Token _drawBar function to allow fatigue bar reversing. // Override the default Token _drawBar function to allow fatigue bar reversing.
Token.prototype._drawBar = function (number, bar, data) { Token.prototype._drawBar = function (number, bar, data) {
const reverseBar = data.attribute === "fatigue" && game.settings.get("l5r5e", "token-reverseFatigueBar"); const reverseBar = data.attribute === "fatigue" && game.settings.get("l5r5e", "token-reverseFatigueBar");

View File

@@ -6,6 +6,6 @@
</header> </header>
<section class="sheet-body"> <section class="sheet-body">
{{#if data.img}}<p><img src="{{data.img}}" title="{{data.name}}" /></p>{{/if}} {{#if data.img}}<p><img src="{{data.img}}" title="{{data.name}}" /></p>{{/if}}
{{#if data.data.description}}<p>{{{data.data.description}}}</p>{{/if}} {{#if data.data.description}}<p>{{{enrichHTML data.data.description}}}</p>{{/if}}
</section> </section>
</div> </div>

View File

@@ -7,10 +7,10 @@
{{!-- commander --}} {{!-- commander --}}
<li><b>{{localize 'l5r5e.army.commander_abilities'}}</b> : {{actorData.data.commander_abilities}}</li> <li><b>{{localize 'l5r5e.army.commander_abilities'}}</b> : {{actorData.data.commander_abilities}}</li>
<li><b>{{localize 'l5r5e.army.army_abilities'}}</b> : {{{actorData.data.army_abilities}}}</li> <li><b>{{localize 'l5r5e.army.army_abilities'}}</b> : {{{enrichHTML actorData.data.army_abilities}}}</li>
</ul> </ul>
{{!-- description --}} {{!-- description --}}
<p>{{{actorData.data.description}}}</p> <p>{{{enrichHTML actorData.data.description}}}</p>
{{!-- Cohorts --}} {{!-- Cohorts --}}
{{#if actorData.splitItemsList.army_cohort}} {{#if actorData.splitItemsList.army_cohort}}

View File

@@ -17,5 +17,5 @@
<li><b>{{localize 'l5r5e.social.glory'}}</b> : <span class="{{#ifCond actorData.social.glory '>' 64}}goodvalue{{/ifCond}}{{#ifCond actorData.social.glory '<' 20}}badvalue{{/ifCond}}">{{actorData.social.glory}}</span></li> <li><b>{{localize 'l5r5e.social.glory'}}</b> : <span class="{{#ifCond actorData.social.glory '>' 64}}goodvalue{{/ifCond}}{{#ifCond actorData.social.glory '<' 20}}badvalue{{/ifCond}}">{{actorData.social.glory}}</span></li>
<li><b>{{localize 'l5r5e.social.status'}}</b> : {{actorData.social.status}}</li> <li><b>{{localize 'l5r5e.social.status'}}</b> : {{actorData.social.status}}</li>
</ul> </ul>
<p>{{{actorData.description}}}</p> <p>{{{enrichHTML actorData.description}}}</p>
</section> </section>

View File

@@ -17,7 +17,7 @@
<li><strong>{{localize 'l5r5e.sheets.bought_at_rank'}}</strong> : {{data.data.bought_at_rank}}</li> <li><strong>{{localize 'l5r5e.sheets.bought_at_rank'}}</strong> : {{data.data.bought_at_rank}}</li>
</ul> </ul>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -36,7 +36,7 @@
{{#each data.data.properties as |property idx|}}{{#ifCond idx '>' 0}}, {{/ifCond}}{{property.name}}{{/each}} {{#each data.data.properties as |property idx|}}{{#ifCond idx '>' 0}}, {{/ifCond}}{{property.name}}{{/each}}
</p> </p>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -13,9 +13,9 @@
<li><strong>{{localize 'l5r5e.army.battle_readiness.discipline'}}</strong> : {{data.data.battle_readiness.panic_discipline.max}}</li> <li><strong>{{localize 'l5r5e.army.battle_readiness.discipline'}}</strong> : {{data.data.battle_readiness.panic_discipline.max}}</li>
</ul> </ul>
{{!-- abilities --}} {{!-- abilities --}}
<p><strong>{{localize 'l5r5e.army.cohort.abilities'}}</strong> : {{{data.data.abilities}}}</p> <p><strong>{{localize 'l5r5e.army.cohort.abilities'}}</strong> : {{{enrichHTML data.data.abilities}}}</p>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -8,7 +8,7 @@
<li><strong>{{localize 'l5r5e.army.fortification.attrition_reduction'}}</strong> : {{data.data.attrition_reduction}}</li> <li><strong>{{localize 'l5r5e.army.fortification.attrition_reduction'}}</strong> : {{data.data.attrition_reduction}}</li>
</ul> </ul>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -26,7 +26,7 @@
{{#each data.data.properties as |property idx|}}{{#ifCond idx '>' 0}}, {{/ifCond}}{{property.name}}{{/each}} {{#each data.data.properties as |property idx|}}{{#ifCond idx '>' 0}}, {{/ifCond}}{{property.name}}{{/each}}
</p> </p>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -13,7 +13,7 @@
{{!--Linked property--}} {{!--Linked property--}}
<strong>{{localize 'l5r5e.sheets.linked_property'}}</strong> : {{{data.linkedProperty.name}}} <strong>{{localize 'l5r5e.sheets.linked_property'}}</strong> : {{{data.linkedProperty.name}}}
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -30,7 +30,7 @@
{{#each data.data.properties as |property idx|}}{{#ifCond idx '>' 0}}, {{/ifCond}}{{property.name}}{{/each}} {{#each data.data.properties as |property idx|}}{{#ifCond idx '>' 0}}, {{/ifCond}}{{property.name}}{{/each}}
</p> </p>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -27,7 +27,7 @@
</li> </li>
</ul> </ul>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -11,7 +11,7 @@
</li> </li>
</ul> </ul>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -18,7 +18,7 @@
</li> </li>
</ul> </ul>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -33,7 +33,7 @@
</li> </li>
</ul> </ul>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -30,7 +30,7 @@
</p> </p>
{{/if}} {{/if}}
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -52,7 +52,7 @@
{{#each data.data.properties as |property idx|}}{{#ifCond idx '>' 0}}, {{/ifCond}}{{property.name}}{{/each}} {{#each data.data.properties as |property idx|}}{{#ifCond idx '>' 0}}, {{/ifCond}}{{property.name}}{{/each}}
</p> </p>
{{!--item-infos--}} {{!--item-infos--}}
<p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{data.data.description}}}</p> <p><strong>{{localize 'l5r5e.sheets.description'}}</strong> : {{{enrichHTML data.data.description}}}</p>
<p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p> <p><strong>{{localize 'l5r5e.sheets.book_reference'}}</strong> : {{data.data.book_reference}}</p>
</section> </section>
</div> </div>

View File

@@ -7,7 +7,7 @@
<section class="sheet-body"> <section class="sheet-body">
<p> <p>
{{#if data.content}} {{#if data.content}}
{{{data.content}}} {{{enrichHTML data.content}}}
{{else}} {{else}}
{{#if data.img}}<img src="{{data.img}}" title="{{data.name}}" />{{/if}} {{#if data.img}}<img src="{{data.img}}" title="{{data.name}}" />{{/if}}
{{/if}} {{/if}}