WIP: Settings and revamp

master
U~man 2020-06-29 21:52:50 +02:00
parent 647727f1ae
commit d55ec24342
11 changed files with 156 additions and 73 deletions

View File

@ -28,15 +28,15 @@
"OSE.scores.cha.short": "CHA",
"OSE.saves.death.short": "D",
"OSE.saves.death.long": "Death",
"OSE.saves.death.long": "Death, Poison",
"OSE.saves.wands.short": "W",
"OSE.saves.wands.long": "Wands",
"OSE.saves.wands.long": "Wand",
"OSE.saves.paralysis.short": "P",
"OSE.saves.paralysis.long": "Paralysis",
"OSE.saves.paralysis.long": "Paralysis, Petrify",
"OSE.saves.breath.short": "B",
"OSE.saves.breath.long": "Breath",
"OSE.saves.breath.long": "Dragon Breath",
"OSE.saves.spells.short": "S",
"OSE.saves.spells.long": "Spells",
"OSE.saves.spells.long": "Rod, Staff, Spell",
"OSE.Health": "Hit Points",
"OSE.HealthShort": "HP",
@ -49,6 +49,10 @@
"OSE.ArmorClassShort": "AC",
"OSE.SpellDC": "DC",
"OSE.Thac0": "THAC0",
"OSE.MeleeShort": "MEL",
"OSE.Melee": "Melee",
"OSE.MissileShort": "MIS",
"OSE.Missile": "Missile",
"OSE.Initiative": "Initiative",
"OSE.InitiativeShort": "INIT",
"OSE.Attacks": "Attacks Usable per Round",
@ -61,5 +65,14 @@
"OSE.category.notes": "Notes",
"OSE.panel.abilities": "Abilities",
"OSE.panel.equipment": "Equipment"
"OSE.panel.equipment": "Equipment",
"OSE.Setting.IndividualInit": "Individual Initiative",
"OSE.Setting.IndividualInitHint": "Initiative is rolled for each actor and modified by its DEX score",
"OSE.Setting.AscendingAC": "Ascending Armor Class",
"OSE.Setting.AscendingACHint": "The more the better",
"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"
}

View File

@ -0,0 +1,35 @@
import { OseActor } from "./entity.js";
export class OseActorSheet extends ActorSheet {
constructor(...args) {
super(...args);
}
/* -------------------------------------------- */
// Override to set resizable initial size
async _renderInner(...args) {
const html = await super._renderInner(...args);
this.form = html[0];
// Resize resizable classes
let resizable = html.find('.resizable');
if (resizable.length == 0) {
return;
}
resizable.each((_, el) => {
let heightDelta = this.position.height - (this.options.height);
el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`;
});
return html;
}
async _onResize(event) {
super._onResize(event);
let html = $(event.path);
let resizable = html.find('.resizable');
resizable.each((_, el) => {
let heightDelta = this.position.height - (this.options.height);
el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`;
});
}
}

View File

@ -1,9 +1,10 @@
import { OseActor } from "./entity.js";
import { OseActorSheet } from "./actor-sheet.js";
/**
* Extend the basic ActorSheet with some very simple modifications
*/
export class OseActorSheetCharacter extends ActorSheet {
export class OseActorSheetCharacter extends OseActorSheet {
constructor(...args) {
super(...args);
}
@ -31,22 +32,6 @@ export class OseActorSheetCharacter extends ActorSheet {
});
}
/* -------------------------------------------- */
// Override to set resizable initial size
async _renderInner(...args) {
const html = await super._renderInner(...args);
this.form = html[0];
// Resize resizable classes
let resizable = html.find('.resizable');
resizable.each((_, el) => {
let heightDelta = this.position.height - (this.options.height);
el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`;
});
return html;
}
/**
* Prepare data for rendering the Actor sheet
* The prepared data object contains both the actor data as well as additional sheet options
@ -62,7 +47,9 @@ export class OseActorSheetCharacter extends ActorSheet {
// Prepare owned items
this._prepareItems(data);
// DEBUG
// Settings
data.config.individualInit = game.settings.get('ose', 'individualInit');
return data;
}
@ -149,14 +136,4 @@ export class OseActorSheetCharacter extends ActorSheet {
// Handle default listeners last so system listeners are triggered first
super.activateListeners(html);
}
async _onResize(event) {
super._onResize(event);
let html = $(event.path);
let resizable = html.find('.resizable');
resizable.each((_, el) => {
let heightDelta = this.position.height - (this.options.height);
el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`;
});
}
}

View File

@ -1,9 +1,10 @@
import { OseActor } from "./entity.js";
import { OseActorSheet } from "./actor-sheet.js";
/**
* Extend the basic ActorSheet with some very simple modifications
*/
export class OseActorSheetMonster extends ActorSheet {
export class OseActorSheetMonster extends OseActorSheet {
constructor(...args) {
super(...args);
}
@ -31,25 +32,6 @@ export class OseActorSheetMonster extends ActorSheet {
});
}
/* -------------------------------------------- */
// Override to set resizable initial size
async _renderInner(...args) {
const html = await super._renderInner(...args);
this.form = html[0];
// Resize resizable classes
let resizable = html.find('.resizable');
if (resizable.length == 0) {
return;
}
resizable.each((_, el) => {
let heightDelta = this.position.height - (this.options.height);
el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`;
});
return html;
}
/**
* Prepare data for rendering the Actor sheet
* The prepared data object contains both the actor data as well as additional sheet options
@ -62,7 +44,9 @@ export class OseActorSheetMonster extends ActorSheet {
// Prepare owned items
this._prepareItems(data);
// DEBUG
// Settings
data.config.morale = game.settings.get('ose', 'morale');
return data;
}
@ -151,14 +135,4 @@ export class OseActorSheetMonster extends ActorSheet {
// Handle default listeners last so system listeners are triggered first
super.activateListeners(html);
}
async _onResize(event) {
super._onResize(event);
let html = $(event.path);
let resizable = html.find('.resizable');
resizable.each((_, el) => {
let heightDelta = this.position.height - (this.options.height);
el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`;
});
}
}

38
src/module/settings.js Normal file
View File

@ -0,0 +1,38 @@
export const registerSettings = function () {
game.settings.register('ose', 'individualInit', {
name: game.i18n.localize('OSE.Setting.IndividualInit'),
hint: game.i18n.localize('OSE.Setting.IndividualInitHint'),
default: false,
scope: 'world',
type: Boolean,
config: true
});
game.settings.register('ose', 'ascendingAC', {
name: game.i18n.localize('OSE.Setting.AscendingAC'),
hint: game.i18n.localize('OSE.Setting.AscendingACHint'),
default: false,
scope: 'world',
type: Boolean,
config: true
});
game.settings.register('ose', 'morale', {
name: game.i18n.localize('OSE.Setting.Morale'),
hint: game.i18n.localize('OSE.Setting.MoraleHint'),
default: false,
scope: 'world',
type: Boolean,
config: true
});
game.settings.register('ose', 'thac0Attacks', {
name: game.i18n.localize('OSE.Setting.THAC0Attacks'),
hint: game.i18n.localize('OSE.Setting.THAC0AttacksHint'),
default: false,
scope: 'world',
type: Boolean,
config: true
});
}

View File

@ -6,6 +6,7 @@ import { preloadHandlebarsTemplates } from "./module/preloadTemplates.js";
import { OseActor } from "./module/actor/entity.js";
import { OseItem } from "./module/item/entity.js";
import { OSE } from "./module/config.js";
import { registerSettings } from './module/settings.js';
// Handlebars template helpers
Handlebars.registerHelper("eq", function (a, b) {
@ -35,6 +36,10 @@ Hooks.once("init", async function () {
};
CONFIG.OSE = OSE;
// Register custom system settings
registerSettings();
CONFIG.Actor.entityClass = OseActor;
CONFIG.Item.entityClass = OseItem;

View File

@ -10,6 +10,9 @@
.panel {
border: 1px solid $colorDark;
&.spells {
border: 0;
}
.panel-title {
color: whitesmoke;
background: $colorDark;
@ -95,7 +98,7 @@
margin: 0;
padding: 0;
.attribute {
margin: 10px;
margin: 10px 2px;
border: 1px solid $colorTan;
.attribute-name {
color: whitesmoke;

View File

@ -9,7 +9,8 @@
"alignment": "",
"literate": false,
"level": 1,
"xp": 0
"xp": 0,
"xpmod": 0
},
"scores": {
"str": {
@ -63,6 +64,10 @@
"lvl5": {
"value": 0,
"max": 0
},
"lvl6": {
"value": 0,
"max": 0
}
},
"hp": {
@ -76,7 +81,9 @@
},
"thac0": {
"value": 19,
"mod": 0
"mod": 0,
"missile": 0,
"melee": 0
},
"saves": {
"D": 10,
@ -153,6 +160,10 @@
"lvl5": {
"value": 0,
"max": 0
},
"lvl6": {
"value": 0,
"max": 0
}
}
}

View File

@ -1,7 +1,7 @@
<section class="flexrow">
<ul class="attributes flexrow">
<li class="attribute health">
<h4 class="attribute-name box-title">{{ localize "OSE.HealthShort" }}</h4>
<h4 class="attribute-name box-title" title="{{ localize 'OSE.Health' }}">{{ localize "OSE.HealthShort" }}</h4>
<div class="attribute-value multiple">
<input name="data.hp.value" type="text" value="{{data.hp.value}}" data-dtype="Number"
placeholder="10" />
@ -10,26 +10,42 @@
</div>
</li>
<li class="attribute">
<h4 class="attribute-name box-title">{{ localize "OSE.ArmorClassShort" }}</h4>
<h4 class="attribute-name box-title" title="{{ localize 'OSE.ArmorClass' }}">{{ localize "OSE.ArmorClassShort" }}</h4>
<div class="attribute-value">
<input name="data.ac.value" type="text" value="{{data.ac.value}}" data-dtype="Number"
placeholder="10" data-dtype="Number" />
</div>
</li>
<li class="attribute">
<h4 class="attribute-name box-title">{{ localize "OSE.Thac0" }}</h4>
<h4 class="attribute-name box-title" title="{{ localize 'OSE.Thac0' }}">{{ localize "OSE.Thac0" }}</h4>
<div class="attribute-value">
<input name="data.thac0.value" type="text" value="{{data.thac0.value}}" placeholder="0"
data-dtype="Number" />
</div>
</li>
<li class="attribute">
<h4 class="attribute-name box-title">{{ localize "OSE.InitiativeShort" }}</h4>
<h4 class="attribute-name box-title" title="{{ localize 'OSE.Melee' }}">{{ localize "OSE.MeleeShort" }}</h4>
<div class="attribute-value">
<input name="data.thac0.melee" type="text" value="{{data.thac0.melee}}" placeholder="0"
data-dtype="Number" />
</div>
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.Missile' }}">{{ localize "OSE.MissileShort" }}</h4>
<div class="attribute-value">
<input name="data.thac0.missile" type="text" value="{{data.thac0.missile}}" placeholder="0"
data-dtype="Number" />
</div>
</li>
{{#if config.individualInit}}
<li class="attribute">
<h4 class="attribute-name box-title" title="{{ localize 'OSE.Initiative' }}">{{ localize "OSE.InitiativeShort" }}</h4>
<div class="attribute-value">
<input name="data.initiative.value" type="text" value="{{data.initiative.value}}"
placeholder="0" data-dtype="Number" />
</div>
</li>
{{/if}}
<li class="attribute">
<h4 class="attribute-name box-title">{{ localize "OSE.MovementShort" }}</h4>
<div class="attribute-value">

View File

@ -52,9 +52,18 @@
<input name="data.spells.lvl5.max" type="text" value="{{data.spells.lvl5.max}}" data-dtype="Number" placeholder="0" />
</div>
</li>
<li class="attribute">
<h4 class="attribute-name box-title">{{localize 'OSE.Level'}} 6</h4>
<div class="attribute-value multiple">
<input name="data.spells.lvl6.value" type="text" value="{{data.spells.lvl6.value}}"
placeholder="0" data-dtype="Number" />
<span class="sep"> / </span>
<input name="data.spells.lvl6.max" type="text" value="{{data.spells.lvl6.max}}" data-dtype="Number" placeholder="0" />
</div>
</li>
</ul>
</section>
<section class="panel inventory">
<section class="panel inventory spells">
<div class="panel-title">
<h4>{{localize 'OSE.category.spells'}}</h4>
<div class="item-controls">

View File

@ -31,10 +31,12 @@
placeholder="{{ localize 'OSE.Experience' }}" />
<label>{{localize 'OSE.Experience'}}</label>
</li>
{{#if config.morale}}
<li>
<input type="text" name="data.details.morale" value="{{data.details.morale}}"
placeholder="{{ localize 'OSE.Morale' }}" />
<label>{{localize 'OSE.Morale'}}</label>
</li>
{{/if}}
</ul>
</section>