ENH: Language support
parent
1b11568593
commit
d15ae28ab4
|
@ -106,6 +106,7 @@
|
|||
"OSE.Damage": "Damage",
|
||||
"OSE.Spellcaster": "Spellcaster",
|
||||
|
||||
"OSE.Language": "Language",
|
||||
"OSE.SpokenLanguages": "Spoken Languages",
|
||||
"OSE.Literacy": "Literacy",
|
||||
"OSE.Literate": "Literate",
|
||||
|
@ -119,6 +120,8 @@
|
|||
"OSE.category.abilities": "Abilities",
|
||||
"OSE.category.spells": "Spells",
|
||||
"OSE.category.notes": "Notes",
|
||||
"OSE.category.languages": "Languages",
|
||||
"OSE.category.description": "Description",
|
||||
|
||||
"OSE.panel.abilities": "Abilities",
|
||||
"OSE.panel.equipment": "Equipment",
|
||||
|
|
|
@ -22,6 +22,14 @@ export class OseActorSheet extends ActorSheet {
|
|||
return data;
|
||||
}
|
||||
|
||||
_createEditor(target, editorOptions, initialContent) {
|
||||
// remove some controls to the editor as the space is lacking
|
||||
if (target == 'data.details.description') {
|
||||
editorOptions.toolbar = 'styleselect bullist hr table removeFormat save';
|
||||
}
|
||||
super._createEditor(target, editorOptions, initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Organize and classify Owned Items for Character sheets
|
||||
* @private
|
||||
|
@ -190,10 +198,21 @@ export class OseActorSheet extends ActorSheet {
|
|||
if (resizable.length == 0) {
|
||||
return;
|
||||
}
|
||||
// Resize divs
|
||||
resizable.each((_, el) => {
|
||||
let heightDelta = this.position.height - this.options.height;
|
||||
el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`;
|
||||
});
|
||||
// Resize editors
|
||||
let editors = html.find(".editor");
|
||||
editors.each((id, editor) => {
|
||||
let container = editor.closest('.resizable-editor');
|
||||
if (container) {
|
||||
let heightDelta = this.position.height - this.options.height;
|
||||
editor.style.height = `${heightDelta + parseInt(container.dataset.editorSize)}px`;
|
||||
}
|
||||
})
|
||||
// editors.css("height", this.position.height - 340);
|
||||
}
|
||||
|
||||
_onConfigureActor(event) {
|
||||
|
@ -218,7 +237,7 @@ export class OseActorSheet extends ActorSheet {
|
|||
{
|
||||
label: "Tweaks",
|
||||
class: "configure-actor",
|
||||
icon: "fas fa-dice",
|
||||
icon: "fas fa-code",
|
||||
onclick: (ev) => this._onConfigureActor(ev),
|
||||
},
|
||||
].concat(buttons);
|
||||
|
|
|
@ -145,6 +145,59 @@ export class OseActorSheetCharacter extends OseActorSheet {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
async _chooseLang() {
|
||||
let choices = CONFIG.OSE.languages;
|
||||
|
||||
let templateData = { choices: choices },
|
||||
dlg = await renderTemplate(
|
||||
"/systems/ose/templates/actors/dialogs/lang-create.html",
|
||||
templateData
|
||||
);
|
||||
//Create Dialog window
|
||||
return new Promise((resolve) => {
|
||||
new Dialog({
|
||||
title: "",
|
||||
content: dlg,
|
||||
buttons: {
|
||||
ok: {
|
||||
label: game.i18n.localize("OSE.Ok"),
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
callback: (html) => {
|
||||
resolve({
|
||||
choice: html.find('select[name="choice"]').val()
|
||||
});
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: game.i18n.localize("OSE.Cancel"),
|
||||
},
|
||||
},
|
||||
default: "ok",
|
||||
}).render(true);
|
||||
});
|
||||
}
|
||||
|
||||
_pushLang(table) {
|
||||
const data = this.actor.data.data;
|
||||
let update = duplicate(data[table]);
|
||||
this._chooseLang().then(dialogInput => {
|
||||
const name = CONFIG.OSE.languages[dialogInput.choice];
|
||||
console.log(name);
|
||||
if (update.value) {
|
||||
update.value.push(name);
|
||||
} else {
|
||||
update = {value: [name]};
|
||||
}
|
||||
let newData = {};
|
||||
newData[table] = update;
|
||||
return this.actor.update({data: newData}).then(() => {
|
||||
this.render(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
async _onQtChange(event) {
|
||||
|
@ -183,6 +236,14 @@ export class OseActorSheetCharacter extends OseActorSheet {
|
|||
this.actor.deleteOwnedItem(li.data("itemId"));
|
||||
li.slideUp(200, () => this.render(false));
|
||||
});
|
||||
|
||||
// Delete Inventory Item
|
||||
html.find(".item-push").click((ev) => {
|
||||
event.preventDefault();
|
||||
const header = event.currentTarget;
|
||||
const table = header.dataset.array;
|
||||
this._pushLang(table);
|
||||
});
|
||||
|
||||
html.find(".item-create").click((event) => {
|
||||
event.preventDefault();
|
||||
|
|
|
@ -36,4 +36,29 @@ export const OSE = {
|
|||
orange: "OSE.colors.orange",
|
||||
white: "OSE.colors.white"
|
||||
},
|
||||
languages: [
|
||||
"Common",
|
||||
"Lawful",
|
||||
"Chaotic",
|
||||
"Neutral",
|
||||
"Bugbear",
|
||||
"Doppelgänger",
|
||||
"Dragon",
|
||||
"Dwarvish",
|
||||
"Elvish",
|
||||
"Gargoyle",
|
||||
"Gnoll",
|
||||
"Gnomish",
|
||||
"Goblin",
|
||||
"Halfling",
|
||||
"Harpy",
|
||||
"Hobgoblin",
|
||||
"Kobold",
|
||||
"Lizard Man",
|
||||
"Medusa",
|
||||
"Minotaur",
|
||||
"Ogre",
|
||||
"Orcish",
|
||||
"Pixie"
|
||||
]
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ export const preloadHandlebarsTemplates = async function () {
|
|||
'systems/ose/templates/actors/partials/character-abilities-tab.html',
|
||||
'systems/ose/templates/actors/partials/character-spells-tab.html',
|
||||
'systems/ose/templates/actors/partials/character-inventory-tab.html',
|
||||
'systems/ose/templates/actors/partials/character-notes-tab.html',
|
||||
|
||||
'systems/ose/templates/actors/partials/monster-header.html',
|
||||
'systems/ose/templates/actors/partials/monster-attributes-tab.html'
|
||||
|
|
|
@ -69,6 +69,9 @@ Hooks.once("setup", function () {
|
|||
return obj;
|
||||
}, {});
|
||||
}
|
||||
for (let l of CONFIG.OSE.languages) {
|
||||
CONFIG.OSE.languages[l] = game.i18n.localize(CONFIG.OSE.languages[l]);
|
||||
}
|
||||
});
|
||||
|
||||
Hooks.once("ready", async () => {
|
||||
|
|
|
@ -25,6 +25,43 @@
|
|||
/* Sheet Body */
|
||||
/* ----------------------------------------- */
|
||||
.sheet-body {
|
||||
.notes-tab {
|
||||
.inventory {
|
||||
.languages {
|
||||
margin: 2px;
|
||||
flex: 0 0 130px;
|
||||
.item-titles {
|
||||
.item-controls {
|
||||
flex: 0 0 20px;
|
||||
}
|
||||
}
|
||||
ol {
|
||||
height: 100px;
|
||||
overflow: auto;
|
||||
list-style: none;
|
||||
padding: 5px;
|
||||
li {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
.description {
|
||||
margin: 2px;
|
||||
.editor {
|
||||
.tox .tox-tbtn {
|
||||
height: 24px;
|
||||
}
|
||||
height: 100px;
|
||||
}
|
||||
}
|
||||
&.notes {
|
||||
margin : 2px;
|
||||
.editor {
|
||||
height: 150px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.health {
|
||||
&.armor-class {
|
||||
background: url('/systems/ose/assets/shield.png') no-repeat center;
|
||||
|
|
|
@ -85,10 +85,10 @@
|
|||
},
|
||||
"details": {
|
||||
"biography": "",
|
||||
"notes": "",
|
||||
"class": "",
|
||||
"title": "",
|
||||
"alignment": "",
|
||||
"literate": false,
|
||||
"level": 1,
|
||||
"xp": {
|
||||
"next": 0,
|
||||
|
@ -132,7 +132,7 @@
|
|||
"max": 1600
|
||||
},
|
||||
"languages": {
|
||||
"values": [],
|
||||
"value": [],
|
||||
"literacy": "literate",
|
||||
"count": 1
|
||||
}
|
||||
|
|
|
@ -42,11 +42,7 @@
|
|||
{{> "systems/ose/templates/actors/partials/character-inventory-tab.html"}}
|
||||
</div>
|
||||
<div class="tab" data-group="primary" data-tab="notes">
|
||||
<div class="inventory">
|
||||
<div class="item-titles">{{localize "OSE.category.notes"}}</div>
|
||||
{{editor content=data.details.biography target="data.details.biography"
|
||||
button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
{{> "systems/ose/templates/actors/partials/character-notes-tab.html"}}
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
|
@ -0,0 +1,14 @@
|
|||
<form class="ose dialog">
|
||||
<div class="form-group">
|
||||
<label>{{localize 'OSE.Language'}}</label>
|
||||
<div class="form-fields">
|
||||
<select name="choice">
|
||||
{{#select choices}}
|
||||
{{#each choices as |label mode|}}
|
||||
<option value="{{mode}}">{{label}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,38 @@
|
|||
<section class="notes-tab">
|
||||
<div class="inventory">
|
||||
<div class="flexrow">
|
||||
<div class="languages">
|
||||
<div class="item-titles flexrow">
|
||||
<div class="item-name">
|
||||
{{localize "OSE.category.languages"}}
|
||||
</div>
|
||||
<div class="item-controls">
|
||||
<a class="item-control item-push" data-array="languages" title="{{localize 'OSE.Add'}}"><i
|
||||
class="fa fa-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<ol>
|
||||
{{#each data.languages.value as |lang|}}
|
||||
<li>
|
||||
{{lang}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</div>
|
||||
<div class="flex3 description">
|
||||
<div class="item-titles">{{localize "OSE.category.description"}}</div>
|
||||
<div>
|
||||
{{editor content=data.details.description target="data.details.description"
|
||||
button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inventory notes">
|
||||
<div class="item-titles">{{localize "OSE.category.notes"}}</div>
|
||||
<div class="resizable-editor" data-editor-size="140">
|
||||
{{editor content=data.details.notes target="data.details.notes"
|
||||
button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
Loading…
Reference in New Issue