ENH: Template rework, more settings, Tweaks

master
U~man 2020-06-29 22:35:25 +02:00
parent d55ec24342
commit cb7fd49d55
10 changed files with 187 additions and 70 deletions

View File

@ -57,6 +57,7 @@
"OSE.InitiativeShort": "INIT",
"OSE.Attacks": "Attacks Usable per Round",
"OSE.AttacksShort": "ATT",
"OSE.Spellcaster": "Spellcaster",
"OSE.category.attributes": "Attributes",
@ -74,5 +75,7 @@
"OSE.Setting.Morale": "Enable Monster Morale checks",
"OSE.Setting.MoraleHint": "Morale Rating is shown on monster sheets",
"OSE.Setting.THAC0Attacks": "Attacks with THAC0",
"OSE.Setting.THAC0AttacksHint": "Attacks are resolved using the THAC0 value"
"OSE.Setting.THAC0AttacksHint": "Attacks are resolved using the THAC0 value, not compatible with AAC",
"OSE.Setting.VariableWeaponDamage": "Variable Weapon Damage",
"OSE.Setting.VariableWeaponDamageHint": "Weapons have different damage dice"
}

View File

@ -1,4 +1,5 @@
import { OseActor } from "./entity.js";
import { OseEntityTweaks } from "../dialog/entity-tweaks.js";
export class OseActorSheet extends ActorSheet {
constructor(...args) {
@ -6,6 +7,13 @@ export class OseActorSheet extends ActorSheet {
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
html.find('.saving-throw .attribute-name').click(ev => {
console.log('hey');
})
}
// Override to set resizable initial size
async _renderInner(...args) {
const html = await super._renderInner(...args);
@ -32,4 +40,35 @@ export class OseActorSheet extends ActorSheet {
el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`;
});
}
_onConfigureActor(event) {
event.preventDefault();
new OseEntityTweaks(this.actor, {
top: this.position.top + 40,
left: this.position.left + (this.position.width - 400) / 2,
}).render(true);
}
/**
* Extend and override the sheet header buttons
* @override
*/
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
// Token Configuration
const canConfigure = game.user.isGM || this.actor.owner;
if (this.options.editable && canConfigure) {
buttons = [
{
label: 'Tweaks',
class: 'configure-actor',
icon: 'fas fa-dice',
onclick: (ev) => this._onConfigureActor(ev),
},
].concat(buttons);
}
return buttons;
}
}

View File

@ -0,0 +1,58 @@
// eslint-disable-next-line no-unused-vars
import { OseActor } from '../actor/entity.js';
export class OseEntityTweaks extends FormApplication {
static get defaultOptions() {
const options = super.defaultOptions;
options.id = 'sheet-tweaks';
options.template =
'systems/ose/templates/actors/dialogs/tweaks-dialog.html';
options.width = 380;
return options;
}
/* -------------------------------------------- */
/**
* Add the Entity name into the window title
* @type {String}
*/
get title() {
return `${this.object.name}: OSE Tweaks`;
}
/* -------------------------------------------- */
/**
* Construct and return the data object used to render the HTML template for this form application.
* @return {Object}
*/
getData() {
let data = this.object.data;
if (this.object.data.type === 'character') {
data.isCharacter = true;
}
return data;
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
}
/**
* 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
* @private
*/
async _updateObject(event, formData) {
event.preventDefault();
// Update the actor
this.object.update(formData);
// Re-draw the updated sheet
this.object.sheet.render(true);
}
}

View File

@ -34,5 +34,14 @@ export const registerSettings = function () {
type: Boolean,
config: true
});
game.settings.register('ose', 'variableDamage', {
name: game.i18n.localize('OSE.Setting.VariableWeaponDamage'),
hint: game.i18n.localize('OSE.Setting.VariableWeaponDamageHint'),
default: false,
scope: 'world',
type: Boolean,
config: true
});
}

View File

@ -1,7 +1,40 @@
{
"Actor": {
"types": ["character", "monster"],
"templates": {
"spellcaster": {
"spells": {
"enabled": false,
"dc": 0,
"lvl1": {
"value": 0,
"max": 0
},
"lvl2": {
"value": 0,
"max": 0
},
"lvl3": {
"value": 0,
"max": 0
},
"lvl4": {
"value": 0,
"max": 0
},
"lvl5": {
"value": 0,
"max": 0
},
"lvl6": {
"value": 0,
"max": 0
}
}
}
},
"character": {
"templates": ["spellcaster"],
"details": {
"biography": "",
"class": "",
@ -43,33 +76,6 @@
"silver": 0,
"copper": 0
},
"spells": {
"dc": 0,
"lvl1": {
"value": 0,
"max": 0
},
"lvl2": {
"value": 0,
"max": 0
},
"lvl3": {
"value": 0,
"max": 0
},
"lvl4": {
"value": 0,
"max": 0
},
"lvl5": {
"value": 0,
"max": 0
},
"lvl6": {
"value": 0,
"max": 0
}
},
"hp": {
"hd": "",
"value": 20,
@ -103,6 +109,7 @@
"languages": []
},
"monster": {
"templates": ["spellcaster"],
"details": {
"biography": "",
"alignment": "",
@ -138,33 +145,6 @@
"movement": {
"base": 0,
"encounter": 0
},
"spells": {
"dc": 0,
"lvl1": {
"value": 0,
"max": 0
},
"lvl2": {
"value": 0,
"max": 0
},
"lvl3": {
"value": 0,
"max": 0
},
"lvl4": {
"value": 0,
"max": 0
},
"lvl5": {
"value": 0,
"max": 0
},
"lvl6": {
"value": 0,
"max": 0
}
}
}
},

View File

@ -12,9 +12,11 @@
<a class="item" data-tab="inventory">
{{localize "OSE.category.inventory"}}
</a>
{{#if data.spells.enabled}}
<a class="item" data-tab="spells">
{{localize "OSE.category.spells"}}
</a>
{{/if}}
<a class="item" data-tab="notes">
{{localize "OSE.category.notes"}}
</a>
@ -28,9 +30,11 @@
<div class="tab" data-group="primary" data-tab="inventory">
{{> "systems/ose/templates/actors/partials/character-inventory-tab.html"}}
</div>
{{#if data.spells.enabled}}
<div class="tab" data-group="primary" data-tab="spells">
{{> "systems/ose/templates/actors/partials/character-spells-tab.html"}}
</div>
{{/if}}
<div class="tab" data-group="primary" data-tab="notes">
{{editor content=data.details.biography target="data.details.biography"
button=true owner=owner editable=editable}}

View File

@ -0,0 +1,20 @@
<form autocomplete="off">
<div class="form-group">
<label for="spellcaster">{{localize "OSE.Spellcaster"}}</label>
<div class="form-fields">
<input
type="checkbox"
name="data.spells.enabled"
id="spellcaster"
{{checked
data.spells.enabled}}
/>
</div>
</div>
<footer class="sheet-footer">
<button type="submit">
<i class="fas fa-save"></i>{{localize "Save Changes"}}
</button>
</footer>
</form>

View File

@ -9,9 +9,11 @@
<a class="item" data-tab="attributes">
{{localize "OSE.category.attributes"}}
</a>
{{#if data.spells.enabled}}
<a class="item" data-tab="spells">
{{localize "OSE.category.spells"}}
</a>
{{/if}}
<a class="item" data-tab="notes">
{{localize "OSE.category.notes"}}
</a>
@ -22,9 +24,11 @@
<div class="tab" data-group="primary" data-tab="attributes">
{{> "systems/ose/templates/actors/partials/monster-attributes-tab.html"}}
</div>
{{#if data.spells.enabled}}
<div class="tab" data-group="primary" data-tab="spells">
{{> "systems/ose/templates/actors/partials/character-spells-tab.html"}}
</div>
{{/if}}
<div class="tab" data-group="primary" data-tab="notes">
{{editor content=data.details.biography target="data.details.biography"
button=true owner=owner editable=editable}}

View File

@ -129,32 +129,32 @@
{{!-- Saving throws --}}
<div class="attribute-group">
<ul class="attributes">
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.death.long' }}">{{ localize "OSE.saves.death.short" }}</h4>
<li class="attribute saving-throw">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.death.long' }}"><a>{{ localize "OSE.saves.death.short" }}</a></h4>
<div class="attribute-value">
<input name="data.saves.d.value" type="text" value="{{data.saves.d.value}}" placeholder="0"
data-dtype="Number" />
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.wands.long' }}">{{ localize "OSE.saves.wands.short" }}</h4>
<li class="attribute saving-throw">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.wands.long' }}"><a>{{ localize "OSE.saves.wands.short" }}</a></h4>
<div class="attribute-value">
<input name="data.saves.w.value" type="text" value="{{data.saves.w.value}}" placeholder="0"
data-dtype="Number" />
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.paralysis.long' }}">{{ localize "OSE.saves.paralysis.short" }}</h4>
<li class="attribute saving-throw">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.paralysis.long' }}"><a>{{ localize "OSE.saves.paralysis.short" }</a></h4>
<div class="attribute-value">
<input name="data.saves.p.value" type="text" value="{{data.saves.p.value}}" placeholder="0"
data-dtype="Number" />
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.breath.long' }}">{{ localize "OSE.saves.breath.short" }}</h4>
<li class="attribute saving-throw">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.breath.long' }}"><a>{{ localize "OSE.saves.breath.short" }}</a></h4>
<div class="attribute-value">
<input name="data.saves.b.value" type="text" value="{{data.saves.b.value}}" placeholder="0"
data-dtype="Number" />
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.spells.long' }}">{{ localize "OSE.saves.spells.short" }}</h4>
<li class="attribute saving-throw">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.spells.long' }}"><a>{{ localize "OSE.saves.spells.short" }}</a></h4>
<div class="attribute-value">
<input name="data.saves.s.value" type="text" value="{{data.saves.s.value}}" placeholder="0" />
</li>

View File

@ -113,31 +113,31 @@
<div class="attribute-group">
<ul class="attributes">
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.death.long' }}">{{ localize "OSE.saves.death.short" }}</h4>
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.death.long' }}"><a>{{ localize "OSE.saves.death.short" }}</a></h4>
<div class="attribute-value">
<input name="data.saves.d.value" type="text" value="{{data.saves.d.value}}" placeholder="0"
data-dtype="Number" />
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.wands.long' }}">{{ localize "OSE.saves.wands.short" }}</h4>
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.wands.long' }}"><a>{{ localize "OSE.saves.wands.short" }}</a></h4>
<div class="attribute-value">
<input name="data.saves.w.value" type="text" value="{{data.saves.w.value}}" placeholder="0"
data-dtype="Number" />
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.paralysis.long' }}">{{ localize "OSE.saves.paralysis.short" }}</h4>
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.paralysis.long' }}"><a>{{ localize "OSE.saves.paralysis.short" }}</a></h4>
<div class="attribute-value">
<input name="data.saves.p.value" type="text" value="{{data.saves.p.value}}" placeholder="0"
data-dtype="Number" />
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.breath.long' }}">{{ localize "OSE.saves.breath.short" }}</h4>
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.breath.long' }}"><a>{{ localize "OSE.saves.breath.short" }}</a></h4>
<div class="attribute-value">
<input name="data.saves.b.value" type="text" value="{{data.saves.b.value}}" placeholder="0"
data-dtype="Number" />
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.spells.long' }}">{{ localize "OSE.saves.spells.short" }}</h4>
<h4 class="attribute-name box-title" title="{{ localize 'OSE.saves.spells.long' }}"><a>{{ localize "OSE.saves.spells.short" }}</a></h4>
<div class="attribute-value">
<input name="data.saves.s.value" type="text" value="{{data.saves.s.value}}" placeholder="0" />
</li>