Skip to content

Commit

Permalink
Merge pull request #36 from aMediocreDad/skulls-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aMediocreDad committed Mar 10, 2021
2 parents c9fb37b + dd24cde commit edf8d56
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 73 deletions.
2 changes: 1 addition & 1 deletion model/armor.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="skulls {{#unless data.bonus.value }}broken{{/unless}}">
<a class="change-bonus" data-attribute="{{data.bonus}}">
{{#skulls data.bonus.value data.bonus.max}}
<i class="skull far {{#if @damaged}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
<i class="skull {{#if @damaged}}far fa-times-circle{{else}}{{#if alternativeSkulls}} fas {{else}} far {{/if}} fa-circle{{/if}}"></i>
{{/skulls}}
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion model/character.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<div class="skulls {{#unless data.bio.willpower.value }}broken{{/unless}} flex row align-center">
<a class="change-willpower">
{{#skulls data.bio.willpower.value data.bio.willpower.max}}
<i class="skull far {{#if @damaged}}fa-circle{{else}}fa-times-circle{{/if}}"></i>
<i class="skull {{#if @damaged}}far fa-circle{{else}}{{#if alternativeSkulls}} fas fa-circle {{else}} far fa-times-circle{{/if}}{{/if}}"></i>
{{/skulls}}
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion model/gear.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="skulls {{#unless data.bonus.value }}broken{{/unless}}">
<a class="change-bonus" data-attribute="{{data.bonus}}">
{{#skulls data.bonus.value data.bonus.max}}
<i class="skull far {{#if @damaged}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
<i class="skull {{#if @damaged}}far fa-times-circle{{else}}{{#if alternativeSkulls}} fas {{else}} far {{/if}} fa-circle{{/if}}"></i>
{{/skulls}}
</a>
</div>
Expand Down
85 changes: 46 additions & 39 deletions model/tab/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,47 @@
<div class="attributes border">
<h1>{{localize "HEADER.ATTRIBUTES"}}</h1>
{{#each data.attribute as |attribute key|}}
<div class="name">
<button type="button" class="roll-attribute" data-attribute="{{key}}">{{localize attribute.label}}</button>
</div>
<div class="skulls {{#unless attribute.value }}broken{{/unless}}">
<a class="change-attribute" data-attribute="{{key}}">
{{#skulls attribute.value attribute.max}}
<i class="skull far {{#if @damaged}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
{{/skulls}}
</a>
</div>
<div class="value">
<input name="data.attribute.{{key}}.value" type="number" value="{{attribute.value}}" data-dtype="Number" />
/
<input name="data.attribute.{{key}}.max" type="number" value="{{attribute.max}}" data-dtype="Number" />
</div>
<div class="name">
<button type="button" class="roll-attribute"
data-attribute="{{key}}">{{localize attribute.label}}</button>
</div>
<div class="skulls {{#unless attribute.value }}broken{{/unless}}">
<a class="change-attribute" data-attribute="{{key}}">
{{#skulls attribute.value attribute.max}}
<i
class="skull {{#if @damaged}}far fa-times-circle{{else}}{{#if ../alternativeSkulls}} fas {{else}} far {{/if}} fa-circle{{/if}}"></i>
{{/skulls}}
</a>
</div>
<div class="value">
<input name="data.attribute.{{key}}.value" type="number" value="{{attribute.value}}"
data-dtype="Number" />
/
<input name="data.attribute.{{key}}.max" type="number" value="{{attribute.max}}" data-dtype="Number" />
</div>
{{/each}}
</div>

<div class="conditions flex column border grow center">
<h1>{{localize "HEADER.CONDITION"}}</h1>
<div class="flex row wrap grow center align-center">
<a class="condition {{# if data.condition.sleepy.value}}active{{/if}}" data-condition="sleepy"
title="{{localize "CONDITION.SLEEPY"}}">
title="{{localize " CONDITION.SLEEPY"}}">
{{localize "CONDITION.SLEEPY"}}
<i class="far {{#if data.condition.sleepy.value}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
</a>
<a class="condition {{# if data.condition.thirsty.value}}active{{/if}}" data-condition="thirsty"
title="{{localize "CONDITION.THIRSTY"}}">
title="{{localize " CONDITION.THIRSTY"}}">
{{localize "CONDITION.THIRSTY"}}
<i class="far {{#if data.condition.thirsty.value}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
</a>
<a class="condition {{# if data.condition.hungry.value}}active{{/if}}" data-condition="hungry"
title="{{localize "CONDITION.HUNGRY"}}">
title="{{localize " CONDITION.HUNGRY"}}">
{{localize "CONDITION.HUNGRY"}}
<i class="far {{#if data.condition.hungry.value}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
</a>
<a class="condition {{# if data.condition.cold.value}}active{{/if}}" data-condition="cold"
title="{{localize "CONDITION.COLD"}}">
title="{{localize " CONDITION.COLD"}}">
{{localize "CONDITION.COLD"}}
<i class="far {{#if data.condition.cold.value}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
</a>
Expand All @@ -49,41 +52,45 @@ <h1>{{localize "HEADER.CONDITION"}}</h1>
<div class="skills strength border">
<h1>{{localize "ATTRIBUTE.STRENGTH"}}</h1>
{{#each data.skill as |skill key|}}
{{#if skill.hasStrength}}
<div class="name"><button type="button" class="roll-skill" data-skill="{{key}}">{{localize skill.label}}</button></div>
<input name="data.skill.{{key}}.value" type="number" value="{{skill.value}}" min="{{skill.min}}"
data-dtype="Number" />
{{/if}}
{{#if skill.hasStrength}}
<div class="name"><button type="button" class="roll-skill"
data-skill="{{key}}">{{localize skill.label}}</button></div>
<input name="data.skill.{{key}}.value" type="number" value="{{skill.value}}" min="{{skill.min}}"
data-dtype="Number" />
{{/if}}
{{/each}}
</div>
<div class="skills agility border">
<h1>{{localize "ATTRIBUTE.AGILITY"}}</h1>
{{#each data.skill as |skill key|}}
{{#if skill.hasAgility}}
<div class="name"><button type="button" class="roll-skill" data-skill="{{key}}">{{localize skill.label}}</button></div>
<input name="data.skill.{{key}}.value" type="number" value="{{skill.value}}" min="{{skill.min}}"
data-dtype="Number" />
{{/if}}
{{#if skill.hasAgility}}
<div class="name"><button type="button" class="roll-skill"
data-skill="{{key}}">{{localize skill.label}}</button></div>
<input name="data.skill.{{key}}.value" type="number" value="{{skill.value}}" min="{{skill.min}}"
data-dtype="Number" />
{{/if}}
{{/each}}
</div>
<div class="skills wits border">
<h1>{{localize "ATTRIBUTE.WITS"}}</h1>
{{#each data.skill as |skill key|}}
{{#if skill.hasWits}}
<div class="name"><button type="button" class="roll-skill" data-skill="{{key}}">{{localize skill.label}}</button></div>
<input name="data.skill.{{key}}.value" type="number" value="{{skill.value}}" min="{{skill.min}}"
data-dtype="Number" />
{{/if}}
{{#if skill.hasWits}}
<div class="name"><button type="button" class="roll-skill"
data-skill="{{key}}">{{localize skill.label}}</button></div>
<input name="data.skill.{{key}}.value" type="number" value="{{skill.value}}" min="{{skill.min}}"
data-dtype="Number" />
{{/if}}
{{/each}}
</div>
<div class="skills empathy border">
<h1>{{localize "ATTRIBUTE.EMPATHY"}}</h1>
{{#each data.skill as |skill key|}}
{{#if skill.hasEmpathy}}
<div class="name"><button type="button" class="roll-skill" data-skill="{{key}}">{{localize skill.label}}</button></div>
<input name="data.skill.{{key}}.value" type="number" value="{{skill.value}}" min="{{skill.min}}"
data-dtype="Number" />
{{/if}}
{{#if skill.hasEmpathy}}
<div class="name"><button type="button" class="roll-skill"
data-skill="{{key}}">{{localize skill.label}}</button></div>
<input name="data.skill.{{key}}.value" type="number" value="{{skill.value}}" min="{{skill.min}}"
data-dtype="Number" />
{{/if}}
{{/each}}
</div>
</div>
2 changes: 1 addition & 1 deletion model/weapon.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="skulls {{#unless data.bonus.value }}broken{{/unless}}">
<a class="change-bonus" data-attribute="{{data.bonus}}">
{{#skulls data.bonus.value data.bonus.max}}
<i class="skull far {{#if @damaged}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
<i class="skull {{#if @damaged}}far fa-times-circle{{else}}{{#if alternativeSkulls}} fas {{else}} far {{/if}} fa-circle{{/if}}"></i>
{{/skulls}}
</a>
</div>
Expand Down
5 changes: 4 additions & 1 deletion script/hooks/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,8 @@ const migrateSettings = async function (worldSchemaVersion) {
game.settings.set("forbidden-lands", "showDescriptionField", true);
game.settings.set("forbidden-lands", "showDrawbackField", true);
game.settings.set("forbidden-lands", "showAppearanceField", true);
}
}
if (worldSchemaVersion <= 4) {
game.settings.set("forbidden-lands", "alternativeSkulls", false);
}
};
8 changes: 8 additions & 0 deletions script/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Hooks.once("init", () => {
default: 0,
type: Number,
});
game.settings.register("forbidden-lands", "alternativeSkulls", {
name: "Alternative Sheet Interaction",
hint: "Changes the look and interaction of Attribute/Bonus/Willpower radio buttons in the Character, Monster and Item sheets.",
scope: "world",
config: true,
default: false,
type: Boolean,
});
game.settings.register("forbidden-lands", "showCraftingFields", {
name: "Show crafting fields",
hint: "Used to show or hide crafting related fields on item sheets.",
Expand Down
43 changes: 16 additions & 27 deletions script/sheet/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@ import { RollDialog } from "../dialog/roll-dialog.js";
import DiceRoller from "../components/dice-roller.js";

export class ForbiddenLandsActorSheet extends ActorSheet {
altInteraction = game.settings.get("forbidden-lands", "alternativeSkulls");
diceRoller = new DiceRoller();

/**
* @override
* Extends the sheet drop handler for system specific usages
*/
async _onDrop(event)
{
async _onDrop(event) {
let dragData = JSON.parse(event.dataTransfer.getData("text/plain"));

// To be extended if future features add more drop functionality
if (dragData.type === "itemDrop")
this.actor.createEmbeddedEntity("OwnedItem", dragData.item)
else // Call base _onDrop for normal FVTT drop handling
super._onDrop(event)
if (dragData.type === "itemDrop") this.actor.createEmbeddedEntity("OwnedItem", dragData.item);
// Call base _onDrop for normal FVTT drop handling
else super._onDrop(event);
}


activateListeners(html) {
super.activateListeners(html);

Expand All @@ -28,9 +26,9 @@ export class ForbiddenLandsActorSheet extends ActorSheet {
const attributeName = $(ev.currentTarget).data("attribute");
const attribute = this.actor.data.data.attribute[attributeName];
let value = attribute.value;
if (ev.type === "click") {
if ((ev.type === "click" && !this.altInteraction) || (ev.type === "contextmenu" && this.altInteraction)) {
value = Math.max(value - 1, 0);
} else if (ev.type === "contextmenu") {
} else if ((ev.type === "contextmenu" && !this.altInteraction) || (ev.type === "click" && this.altInteraction)) {
value = Math.min(value + 1, attribute.max);
}
this.actor.update({
Expand All @@ -42,9 +40,9 @@ export class ForbiddenLandsActorSheet extends ActorSheet {
html.find(".change-willpower").on("click contextmenu", (ev) => {
const attribute = this.actor.data.data.bio.willpower;
let value = attribute.value;
if (ev.type === "click") {
if ((ev.type === "click" && !this.altInteraction) || (ev.type === "contextmenu" && this.altInteraction)) {
value = Math.max(value - 1, 0);
} else if (ev.type === "contextmenu") {
} else if ((ev.type === "contextmenu" && !this.altInteraction) || (ev.type === "click" && this.altInteraction)) {
value = Math.min(value + 1, attribute.max);
}
this.actor.update({ "data.bio.willpower.value": value });
Expand All @@ -70,9 +68,9 @@ export class ForbiddenLandsActorSheet extends ActorSheet {
const itemId = $(ev.currentTarget).data("itemId");
const item = this.actor.getOwnedItem(itemId);
let value = item.data.data.bonus.value;
if (ev.type === "click") {
if ((ev.type === "click" && !this.altInteraction) || (ev.type === "contextmenu" && this.altInteraction)) {
value = Math.max(value - 1, 0);
} else if (ev.type === "contextmenu") {
} else if ((ev.type === "contextmenu" && !this.altInteraction) || (ev.type === "click" && this.altInteraction)) {
value = Math.min(value + 1, item.data.data.bonus.max);
}
item.update({
Expand Down Expand Up @@ -240,7 +238,10 @@ export class ForbiddenLandsActorSheet extends ActorSheet {
});
return modifiers;
}

async _renderInner(data, options) {
data.alternativeSkulls = game.settings.get("forbidden-lands", "alternativeSkulls");
return super._renderInner(data, options);
}
computerItemEncumbrance(data) {
switch (data.type) {
case "armor":
Expand All @@ -254,20 +255,8 @@ export class ForbiddenLandsActorSheet extends ActorSheet {
return 0.5;
case "heavy":
return 2;
case "3":
return 3;
case "4":
return 4;
case "5":
return 5;
case "6":
return 6;
case "7":
return 7;
case "8":
return 8;
default:
return 1;
return data.data.weight || 1;
}
case "rawMaterial":
return 1;
Expand Down
6 changes: 4 additions & 2 deletions script/sheet/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ export class ForbiddenLandsItemSheet extends ItemSheet {
html.find(".change-bonus").on("click contextmenu", (ev) => {
const bonus = this.object.data.data.bonus;
let value = bonus.value;
if (ev.type === "click") {
const altInteraction = game.settings.get("forbidden-lands", "alternativeSkulls");
if ((ev.type === "click" && !altInteraction) || (ev.type === "contextmenu" && altInteraction)) {
value = Math.max(value - 1, 0);
} else if (ev.type === "contextmenu") {
} else if ((ev.type === "contextmenu" && !altInteraction) || (ev.type === "click" && altInteraction)) {
value = Math.min(value + 1, bonus.max);
}
this.object.update({
Expand Down Expand Up @@ -109,6 +110,7 @@ export class ForbiddenLandsItemSheet extends ItemSheet {
}

async _renderInner(data, options) {
data.alternativeSkulls = game.settings.get("forbidden-lands", "alternativeSkulls");
data.data.customRollModifiers = await this.getCustomRollModifiers();
data.showCraftingFields = game.settings.get("forbidden-lands", "showCraftingFields");
data.showCostField = game.settings.get("forbidden-lands", "showCostField");
Expand Down
23 changes: 23 additions & 0 deletions style/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,26 @@ button,
.forbidden-lands .pre-wrap {
white-space: pre-wrap;
}

.fas.fa-circle,
.far.fa-circle,
.far.fa-times-circle,
.far.fa-check-circle {
font-size: 14px;
color: #333;
}

.forbidden-lands .broken {
color: #a00;
}

.broken .fas.fa-circle,
.broken .far.fa-circle,
.broken .far.fa-times-circle,
.condition .far.fa-times-circle,
.broken .far.fa-check-circle {
color: #a00;
}
.broken .change-willpower .far.fa-circle {
color: #333;
}

0 comments on commit edf8d56

Please sign in to comment.