Skip to content

Commit

Permalink
v10 Conversion (#40)
Browse files Browse the repository at this point in the history
* v10 conversion

* v10 conversion

* v10 conversion

* v10 conversion scss

* Update module.json

* class & level header show level
  • Loading branch information
EndlesNights authored Oct 30, 2022
1 parent c97c96d commit f51b10b
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 130 deletions.
5 changes: 5 additions & 0 deletions src/foundryvtt-5eOGLCharacterSheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,9 @@
.flexcol > * {
flex: 0 auto;
}

.prosemirror .editor-container {
min-height: 80px;
margin-bottom: 8px;
}
}
63 changes: 50 additions & 13 deletions src/foundryvtt-5eOGLCharacterSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { registerSettings } from './module/settings.js';
import { preloadTemplates } from './module/preloadTemplates.js';
import { MODULE_ID, MySettings } from './constants.js';
//@ts-ignore
import ActorSheet5eCharacter from '../../systems/dnd5e/module/actor/sheets/character.js';

Handlebars.registerHelper('ogl5e-sheet-path', (relativePath: string) => {
return `modules/${MODULE_ID}/${relativePath}`;
Expand All @@ -27,10 +26,10 @@ Handlebars.registerHelper('ogl5e-sheet-isEmpty', (input: Object | Array<any> | S
if (input instanceof Set) {
return input.size < 1;
}
return isObjectEmpty(input);
return isEmpty(input);
});

export class OGL5eCharacterSheet extends ActorSheet5eCharacter {
export class OGL5eCharacterSheet extends dnd5e.applications.actor.ActorSheet5eCharacter {
get template() {
//@ts-ignore
if (!game.user.isGM && this.actor.limited && !game.settings.get(MODULE_ID, MySettings.expandedLimited)) {
Expand Down Expand Up @@ -99,7 +98,7 @@ export class OGL5eCharacterSheet extends ActorSheet5eCharacter {
const item = this.actor.items.get(itemId);
const quantity = parseInt(event.target.value);
event.target.value = quantity;
return item.update({ 'data.quantity': quantity });
return item.update({ 'system.quantity': quantity });
}

/**
Expand All @@ -121,21 +120,24 @@ export class OGL5eCharacterSheet extends ActorSheet5eCharacter {
.change(this._onQuantityChange.bind(this));
}

getData() {
const sheetData = super.getData();
async getData() {
const sheetData = await super.getData();

// replace classLabels with Subclass + Class list
try {
let items = sheetData.items;
let classList;
//@ts-ignore
if (!foundry.utils.isNewerVersion('1.6.0', game.system.data.version)) {
classList = sheetData.features[1].items.map((item) => item.name);
} else {
if (!foundry.utils.isNewerVersion('1.6.0', game.system.version)) {
classList = sheetData.features[1].items.map((item) => {
if(item.type === "class") return `${item.name} ${item.system.levels}`;
return item.name
});
} else {
classList = items
.filter((item) => item.type === 'class')
.map((item) => {
return `${item.data.subclass} ${item.name} ${item.data.levels}`;
return `${item.system.subclass} ${item.name} ${item.system.levels}`;
});
}

Expand Down Expand Up @@ -195,8 +197,8 @@ export class OGL5eCharacterSheet extends ActorSheet5eCharacter {
// if description is populated and appearance isn't use description as appearance
try {
log(false, sheetData);
if (!!sheetData.data.details.description?.value && !sheetData.data.details.appearance) {
sheetData.data.details.appearance = sheetData.data.details.description.value;
if (!!sheetData.system.details.description?.value && !sheetData.system.details.appearance) {
sheetData.system.details.appearance = sheetData.system.details.description.value;
}
} catch (e) {
log(true, 'error trying to migrate description to appearance', e);
Expand All @@ -208,7 +210,7 @@ export class OGL5eCharacterSheet extends ActorSheet5eCharacter {
sheetData.settingsShowEquipInventory = game.settings.get(MODULE_ID, MySettings.showEquipOnInventoryList);

// system features
const systemVersion = game.system.data.version;
const systemVersion = game.system.version;
//@ts-ignore
sheetData.systemFeatures = {
//@ts-ignore
Expand All @@ -227,6 +229,41 @@ export class OGL5eCharacterSheet extends ActorSheet5eCharacter {
subclasses: !foundry.utils.isNewerVersion('1.6.0', systemVersion),
};

sheetData.trait = await TextEditor.enrichHTML(sheetData.system.details.trait, {
secrets: this.actor.isOwner,
rollData: sheetData.rollData,
async: true,
relativeTo: this.actor
});

sheetData.ideal = await TextEditor.enrichHTML(sheetData.system.details.ideal, {
secrets: this.actor.isOwner,
rollData: sheetData.rollData,
async: true,
relativeTo: this.actor
});

sheetData.bond = await TextEditor.enrichHTML(sheetData.system.details.bond, {
secrets: this.actor.isOwner,
rollData: sheetData.rollData,
async: true,
relativeTo: this.actor
});

sheetData.flaw = await TextEditor.enrichHTML(sheetData.system.details.flaw, {
secrets: this.actor.isOwner,
rollData: sheetData.rollData,
async: true,
relativeTo: this.actor
});

sheetData.appearance = await TextEditor.enrichHTML(sheetData.system.details.appearance, {
secrets: this.actor.isOwner,
rollData: sheetData.rollData,
async: true,
relativeTo: this.actor
});

return sheetData;
}
}
Expand Down
23 changes: 19 additions & 4 deletions src/module.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"id": "5e-ogl-character-sheet",
"name": "5e-ogl-character-sheet",
"title": "D&D 5e OGL Character Sheet",
"description": "A character sheet resembling a classic Pencil and Paper or Roll20 sheet.",
Expand Down Expand Up @@ -56,9 +57,23 @@
"link": "https://raw.githubusercontent.com/ElfFriend-DnD/foundryvtt-5eOGLCharacterSheet/master/readme-img/biography.png"
}
],
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9",
"minimumSystemVersion": "1.4.0",
"relationships": {
"systems": [
{
"id": "dnd5e",
"type": "system",
"manifest": "https://raw.githubusercontent.com/foundryvtt/dnd5e/master/system.json",
"compatibility": {
"minimum": "2.0.0"
}
}
]
},
"compatibility":{
"minimum": 10,
"verified": 10,
"maximum": 10
},
"bugs": "https://github.com/ElfFriend-DnD/foundryvtt-5eOGLCharacterSheet/issues",
"changelog": "https://github.com/ElfFriend-DnD/foundryvtt-5eOGLCharacterSheet/releases",
"download": "https://github.com/ElfFriend-DnD/foundryvtt-5eOGLCharacterSheet/releases/download/v0.14.1/module.zip",
Expand All @@ -69,4 +84,4 @@
"allowBugReporter": true
},
"manifestPlusVersion": "1.0.0"
}
}
4 changes: 2 additions & 2 deletions src/templates/character-sheet-ltd.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<div class="left-notes note-entries flexcol">
<article>
<h4 class="box-title">{{ localize "DND5E.Appearance" }}</h4>
{{editor content=data.details.appearance target="data.details.appearance" button=true owner=owner editable=editable}}
{{editor appearance target="system.details.appearance" button=true editable=editable engine="prosemirror" collaborate=false}}
</article>
</div>

<div class="right-notes note-entries flexcol">
<article class="biography-notes big-bio">
<h4 class="box-title">{{ localize "DND5E.Background" }}/{{ localize "DND5E.Biography" }}</h4>
{{editor content=data.details.biography.value target="data.details.biography.value" button=true owner=owner editable=editable}}
{{editor biographyHTML target="system.details.biography.value" button=true editable=editable engine="prosemirror" collaborate=false}}
</article>
</div>

Expand Down
28 changes: 13 additions & 15 deletions src/templates/character-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<div class="abilities-skills flexrow">
{{!-- Ability Scores --}}
<ul class="ability-scores ability-score-column">
{{#each data.abilities as |ability id|}}
{{#each system.abilities as |ability id|}}
<li class="ability" data-ability="{{id}}">
<div class="ability-outline">
{{> (ogl5e-sheet-path "assets/strength.hbs")}}
</div>
<h4 class="ability-name box-title rollable">{{ability.label}}</h4>
<input class="ability-score" name="data.abilities.{{id}}.value" type="text" value="{{ability.value}}"
<input class="ability-score" name="system.abilities.{{id}}.value" type="text" value="{{ability.value}}"
data-dtype="Number" placeholder="10" />
<div class="ability-modifiers flexrow">
<span class="ability-mod" title="Modifier">{{numberFormat ability.mod decimals=0 sign=true}}</span>
Expand Down Expand Up @@ -55,19 +55,19 @@
<article class="personality">
<section>
<h4 class="box-title">{{ localize "DND5E.PersonalityTraits" }}</h4>
{{editor content=data.details.trait target="data.details.trait" button=true owner=owner editable=editable}}
{{editor trait target="system.details.trait" button=true editable=editable engine="prosemirror" collaborate=false}}
</section>
<section>
<h4 class="box-title">{{ localize "DND5E.Ideals" }}</h4>
{{editor content=data.details.ideal target="data.details.ideal" button=true owner=owner editable=editable}}
{{editor ideal target="system.details.ideal" button=true editable=editable engine="prosemirror" collaborate=false}}
</section>
<section>
<h4 class="box-title">{{ localize "DND5E.Bonds" }}</h4>
{{editor content=data.details.bond target="data.details.bond" button=true owner=owner editable=editable}}
{{editor bond target="system.details.bond" button=true editable=editable engine="prosemirror" collaborate=false}}
</section>
<section>
<h4 class="box-title">{{ localize "DND5E.Flaws" }}</h4>
{{editor content=data.details.flaw target="data.details.flaw" button=true owner=owner editable=editable}}
{{editor flaw target="system.details.flaw" button=true editable=editable engine="prosemirror" collaborate=false}}
</section>
</article>

Expand All @@ -76,26 +76,26 @@
{{#each resources as |res|}}
<li class="attribute resource">
<h4 class="attribute-name box-title">
<input name="data.resources.{{res.name}}.label" type="text" value="{{res.label}}"
<input name="system.resources.{{res.name}}.label" type="text" value="{{res.label}}"
placeholder="{{res.placeholder}}" />
</h4>
<div class="attribute-value">

<input name="data.resources.{{res.name}}.value" type="text" value="{{res.value}}" data-dtype="Number"
<input name="system.resources.{{res.name}}.value" type="text" value="{{res.value}}" data-dtype="Number"
placeholder="0" />
<span class="sep"> / </span>
<input name="data.resources.{{res.name}}.max" type="text" value="{{res.max}}" data-dtype="Number"
<input name="system.resources.{{res.name}}.max" type="text" value="{{res.max}}" data-dtype="Number"
placeholder="0" />

</div>
<div class="attribute-footer">
<label class="recharge checkbox">
{{ localize "DND5E.AbbreviationSR" }} <input name="data.resources.{{res.name}}.sr" type="checkbox"
{{ localize "DND5E.AbbreviationSR" }} <input name="system.resources.{{res.name}}.sr" type="checkbox"
{{checked res.sr}} />
</label>

<label class="recharge checkbox">
{{ localize "DND5E.AbbreviationLR" }} <input name="data.resources.{{res.name}}.lr" type="checkbox"
{{ localize "DND5E.AbbreviationLR" }} <input name="system.resources.{{res.name}}.lr" type="checkbox"
{{checked res.lr}} />
</label>
</div>
Expand Down Expand Up @@ -130,16 +130,14 @@

<article>
<h4 class="box-title">{{ localize "DND5E.Appearance" }}</h4>
{{editor content=data.details.appearance target="data.details.appearance" button=true owner=owner
editable=editable}}
{{editor appearance target="system.details.appearance" button=true editable=editable engine="prosemirror" collaborate=false}}
</article>
</div>

<div class="right-notes note-entries flexcol">
<article class="biography-notes big-bio">
<h4 class="box-title">{{ localize "DND5E.Background" }}</h4>
{{editor content=data.details.biography.value target="data.details.biography.value" button=true owner=owner
editable=editable}}
{{editor biographyHTML target="system.details.biography.value" button=true editable=editable engine="prosemirror" collaborate=false}}
</article>
</div>

Expand Down
14 changes: 7 additions & 7 deletions src/templates/parts/actor-features.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<h4 title="{{item.name}}">
{{#if (eq item.type "subclass")}}&rdsh;{{/if}}
{{item.name}}
{{#if item.data.isOriginalClass}} <i class="original-class fas fa-sun"
{{#if item.system.isOriginalClass}} <i class="original-class fas fa-sun"
title="{{localize 'DND5E.ClassOriginal'}}"></i>{{/if}}
</h4>
{{else}}
Expand All @@ -59,20 +59,20 @@
{{/if}}
{{/if}}

{{#if (or item.isOnCooldown item.data.recharge.value item.hasUses)}}
{{#if (or item.isOnCooldown item.system.recharge.value item.hasUses)}}
<div class="item-detail item-uses" title="{{localize 'DND5E.Uses'}}">

{{#if item.isOnCooldown}}

<a class="item-recharge rollable">{{item.labels.recharge}}</a>

{{else if item.data.recharge.value}}
{{else if item.system.recharge.value}}

{{localize "DND5E.Charged"}}

{{else if item.hasUses}}

<span><input type="text" value="{{item.data.uses.value}}" placeholder="0" /> / {{item.data.uses.max}}</span>
<span><input type="text" value="{{item.system.uses.value}}" placeholder="0" /> / {{item.system.uses.max}}</span>

<small>{{localize "DND5E.Uses"}}</small>

Expand All @@ -84,7 +84,7 @@

{{#if section.hasActions}}
<div class="item-detail item-action">
{{#if item.data.activation.type }}
{{#if item.system.activation.type }}
{{!-- Use our custom abbreviated labels --}}
{{item.labels.activationAbbrev}}
{{/if}}
Expand All @@ -94,13 +94,13 @@
{{#if section.isClass}}
{{#unless @root/systemFeatures.subclasses}}
<div class="item-detail player-class">
{{item.data.subclass}}
{{item.system.subclass}}
</div>
{{/unless}}
{{#unless @root/systemFeatures.levelDropdown}}
{{#if (eq item.type "class")}}
<div class="item-detail item-action">
Level {{item.data.levels}}
Level {{item.system.levels}}
</div>
{{/if}}
{{/unless}}
Expand Down
Loading

0 comments on commit f51b10b

Please sign in to comment.