diff --git a/src/lang/en.json b/src/lang/en.json index 4224303..952b330 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -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", diff --git a/src/module/actor/actor-sheet.js b/src/module/actor/actor-sheet.js index 3a0db27..f132f59 100644 --- a/src/module/actor/actor-sheet.js +++ b/src/module/actor/actor-sheet.js @@ -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); diff --git a/src/module/actor/character-sheet.js b/src/module/actor/character-sheet.js index 5bf496c..3de618c 100644 --- a/src/module/actor/character-sheet.js +++ b/src/module/actor/character-sheet.js @@ -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: '', + callback: (html) => { + resolve({ + choice: html.find('select[name="choice"]').val() + }); + }, + }, + cancel: { + icon: '', + 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(); diff --git a/src/module/config.js b/src/module/config.js index 48ec082..496f933 100644 --- a/src/module/config.js +++ b/src/module/config.js @@ -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" + ] }; diff --git a/src/module/preloadTemplates.js b/src/module/preloadTemplates.js index 4b4c546..a23464e 100644 --- a/src/module/preloadTemplates.js +++ b/src/module/preloadTemplates.js @@ -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' diff --git a/src/ose.js b/src/ose.js index 925c393..f905481 100644 --- a/src/ose.js +++ b/src/ose.js @@ -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 () => { diff --git a/src/scss/character.scss b/src/scss/character.scss index 934a2bc..24ac905 100644 --- a/src/scss/character.scss +++ b/src/scss/character.scss @@ -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; diff --git a/src/template.json b/src/template.json index 775dfec..6b55828 100644 --- a/src/template.json +++ b/src/template.json @@ -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 } diff --git a/src/templates/actors/character-sheet.html b/src/templates/actors/character-sheet.html index 12d1b89..e9c0cd6 100644 --- a/src/templates/actors/character-sheet.html +++ b/src/templates/actors/character-sheet.html @@ -42,11 +42,7 @@ {{> "systems/ose/templates/actors/partials/character-inventory-tab.html"}}