Skip to content

Commit 030a35c

Browse files
committed
Fix header controls
1 parent f21e37a commit 030a35c

File tree

12 files changed

+93
-186
lines changed

12 files changed

+93
-186
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108

109109
# Pull YAML to LDB packs
110110
- name: Build Packs
111-
run: npm run YAMLtoLDB
111+
run: npm run YMLtoLDB
112112

113113
# Create a "system.zip" archive containing all the module's required files.
114114
# If you have other directories or files that will need to be added to

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 3.0.0
2+
- Compatibility Foundry V13
3+
14
# 2.2.0
25
- Fix issue [#51](https://github.com/voidcase/IntoTheOdd-FoundryVTT/issues/51)
36
- Add an option to display or not the wealth section in a character sheet

css/intotheodd.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
justify-content: space-between;
159159
align-items: center;
160160
}
161+
.intotheodd.actor.character nav {
162+
margin: 10px 0 10px 0;
163+
}
161164
.intotheodd.actor.encounter {
162165
min-width: 675px;
163166
}

module/sheets/character-sheet.mjs

Lines changed: 52 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,20 @@
1-
const { ux } = foundry.applications
1+
const { sheets, ux } = foundry.applications
22
const { HandlebarsApplicationMixin } = foundry.applications.api
33
const { DragDrop } = foundry.applications.ux
44

5-
export default class IntoTheOddCharacterSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ActorSheetV2) {
5+
export default class IntoTheOddCharacterSheet extends HandlebarsApplicationMixin(sheets.ActorSheetV2) {
66
/** @override */
77
static DEFAULT_OPTIONS = {
88
classes: ["intotheodd", "actor", "character"],
99
position: {
10-
width: 700,
11-
height: 500,
10+
width: 750,
11+
height: 800,
1212
},
1313
form: {
1414
submitOnChange: true,
1515
},
1616
window: {
1717
resizable: true,
18-
controls: [
19-
{
20-
action: "configurePrototypeToken",
21-
icon: "fa-solid fa-user-circle",
22-
label: "TOKEN.TitlePrototype",
23-
ownership: "OWNER",
24-
},
25-
{
26-
action: "showPortraitArtwork",
27-
icon: "fa-solid fa-image",
28-
label: "SIDEBAR.CharArt",
29-
ownership: "OWNER",
30-
},
31-
{
32-
action: "showTokenArtwork",
33-
icon: "fa-solid fa-image",
34-
label: "SIDEBAR.TokenArt",
35-
ownership: "OWNER",
36-
},
37-
{
38-
icon: "fa-solid fa-heart-pulse",
39-
label: "INTOTHEODD.Labels.long.shortRest",
40-
action: "shortRest",
41-
ownership: "OWNER",
42-
},
43-
{
44-
icon: "fas fa-bed",
45-
label: "INTOTHEODD.Labels.long.fullRest",
46-
action: "fullRest",
47-
ownership: "OWNER",
48-
},
49-
],
5018
},
5119
actions: {
5220
edit: IntoTheOddCharacterSheet.#onItemEdit,
@@ -61,77 +29,31 @@ export default class IntoTheOddCharacterSheet extends HandlebarsApplicationMixin
6129
},
6230
}
6331

64-
/** @override */
65-
_getHeaderControls() {
66-
const controls = super._getHeaderControls()
67-
68-
if (this.actor.system.deprived) {
69-
controls.findSplice((c) => c.action === "shortRest")
70-
controls.findSplice((c) => c.action === "fullRest")
71-
} else {
72-
if (!controls.find((c) => c.action === "shortRest")) {
73-
controls.push({
74-
icon: "fa-solid fa-heart-pulse",
75-
label: "INTOTHEODD.Labels.long.shortRest",
76-
action: "shortRest",
77-
})
78-
}
79-
if (!controls.find((c) => c.action === "fullRest")) {
80-
controls.push({
81-
icon: "fas fa-bed",
82-
label: "INTOTHEODD.Labels.long.fullRest",
83-
action: "fullRest",
84-
})
85-
}
86-
}
87-
88-
return controls
89-
}
90-
9132
/** @override */
9233
static PARTS = {
93-
header: {
94-
template: "systems/intotheodd/templates/character-header.hbs",
95-
},
96-
main: {
97-
template: "systems/intotheodd/templates/character-main.hbs",
98-
},
99-
tabs: {
100-
template: "templates/generic/tab-navigation.hbs",
101-
},
102-
biography: {
103-
template: "systems/intotheodd/templates/character-biography.hbs",
104-
},
105-
inventory: {
106-
template: "systems/intotheodd/templates/character-inventory.hbs",
107-
},
34+
header: { template: "systems/intotheodd/templates/character-header.hbs" },
35+
main: { template: "systems/intotheodd/templates/character-main.hbs" },
36+
tabs: { template: "templates/generic/tab-navigation.hbs" },
37+
biography: { template: "systems/intotheodd/templates/character-biography.hbs" },
38+
inventory: { template: "systems/intotheodd/templates/character-inventory.hbs" },
10839
}
10940

11041
/** @override */
111-
tabGroups = {
112-
sheet: "inventory",
113-
}
114-
115-
/**
116-
* Prepare an array of form header tabs.
117-
* @returns {Record<string, Partial<ApplicationTab>>}
118-
*/
119-
#getTabs() {
120-
const tabs = {
121-
biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "INTOTHEODD.Labels.long.biography" },
122-
inventory: { id: "inventory", group: "sheet", icon: "fa-solid fa-shapes", label: "INTOTHEODD.Labels.long.inventory" },
123-
}
124-
for (const v of Object.values(tabs)) {
125-
v.active = this.tabGroups[v.group] === v.id
126-
v.cssClass = v.active ? "active" : ""
127-
}
128-
return tabs
42+
static TABS = {
43+
primary: {
44+
tabs: [
45+
{ id: "biography", icon: "fa-solid fa-book" },
46+
{ id: "inventory", icon: "fa-solid fa-shapes" },
47+
],
48+
initial: "inventory",
49+
labelPrefix: "INTOTHEODD.Labels.long",
50+
},
12951
}
13052

13153
/** @override */
132-
async _prepareContext() {
133-
const context = {
134-
tabs: this.#getTabs(),
54+
async _prepareContext(options) {
55+
const context = await super._prepareContext(options)
56+
Object.assign(context, {
13557
fields: this.document.schema.fields,
13658
systemFields: this.document.system.schema.fields,
13759
actor: this.document,
@@ -146,21 +68,19 @@ export default class IntoTheOddCharacterSheet extends HandlebarsApplicationMixin
14668
},
14769
},
14870
displayWealth: game.settings.get("intotheodd", "displayWealth"),
149-
}
150-
//console.log('character context', context);
71+
})
15172
return context
15273
}
15374

15475
/** @override */
155-
async _preparePartContext(partId, context) {
156-
const doc = this.document
76+
async _preparePartContext(partId, context, options) {
77+
context = await super._preparePartContext(partId, context, options)
78+
15779
switch (partId) {
15880
case "biography":
159-
context.tab = context.tabs.biography
16081
context.enrichedBiography = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.biography, { async: true })
16182
break
16283
case "inventory":
163-
context.tab = context.tabs.inventory
16484
context.items = []
16585
const itemsRaw = this.actor.itemTypes.equipment
16686
for (const item of itemsRaw) {
@@ -189,6 +109,33 @@ export default class IntoTheOddCharacterSheet extends HandlebarsApplicationMixin
189109
}).bind(this.element)
190110
}
191111

112+
/** @override */
113+
_getHeaderControls() {
114+
const controls = super._getHeaderControls()
115+
116+
if (this.actor.system.deprived) {
117+
controls.findSplice((c) => c.action === "shortRest")
118+
controls.findSplice((c) => c.action === "fullRest")
119+
} else {
120+
if (!controls.find((c) => c.action === "shortRest")) {
121+
controls.push({
122+
icon: "fa-solid fa-heart-pulse",
123+
label: "INTOTHEODD.Labels.long.shortRest",
124+
action: "shortRest",
125+
})
126+
}
127+
if (!controls.find((c) => c.action === "fullRest")) {
128+
controls.push({
129+
icon: "fas fa-bed",
130+
label: "INTOTHEODD.Labels.long.fullRest",
131+
action: "fullRest",
132+
})
133+
}
134+
}
135+
136+
return controls
137+
}
138+
192139
//#region Drag-and-Drop Workflow
193140

194141
/**

module/sheets/encounter-sheet.mjs

Lines changed: 12 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const { ux } = foundry.applications
1+
const { sheets, ux } = foundry.applications
22
const { HandlebarsApplicationMixin } = foundry.applications.api
33
const { DragDrop } = foundry.applications.ux
44

5-
export default class IntoTheOddEncounterSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ActorSheetV2) {
5+
export default class IntoTheOddEncounterSheet extends HandlebarsApplicationMixin(sheets.ActorSheetV2) {
66
/** @override */
77
static DEFAULT_OPTIONS = {
88
classes: ["intotheodd", "actor", "encounter"],
@@ -15,26 +15,6 @@ export default class IntoTheOddEncounterSheet extends HandlebarsApplicationMixin
1515
},
1616
window: {
1717
resizable: true,
18-
controls: [
19-
{
20-
action: "configurePrototypeToken",
21-
icon: "fa-solid fa-user-circle",
22-
label: "TOKEN.TitlePrototype",
23-
ownership: "OWNER",
24-
},
25-
{
26-
action: "showPortraitArtwork",
27-
icon: "fa-solid fa-image",
28-
label: "SIDEBAR.CharArt",
29-
ownership: "OWNER",
30-
},
31-
{
32-
action: "showTokenArtwork",
33-
icon: "fa-solid fa-image",
34-
label: "SIDEBAR.TokenArt",
35-
ownership: "OWNER",
36-
},
37-
],
3818
},
3919
actions: {
4020
edit: IntoTheOddEncounterSheet.#onItemEdit,
@@ -45,41 +25,6 @@ export default class IntoTheOddEncounterSheet extends HandlebarsApplicationMixin
4525
},
4626
}
4727

48-
/** @override */
49-
_getHeaderControls() {
50-
const controls = this.options.window.controls
51-
52-
if (!controls.find((c) => c.action === "showPortraitArtwork")) {
53-
controls.push({
54-
action: "showPortraitArtwork",
55-
icon: "fa-solid fa-image",
56-
label: "SIDEBAR.CharArt",
57-
ownership: "OWNER",
58-
})
59-
}
60-
if (!controls.find((c) => c.action === "showTokenArtwork")) {
61-
controls.push({
62-
action: "showTokenArtwork",
63-
icon: "fa-solid fa-image",
64-
label: "SIDEBAR.TokenArt",
65-
ownership: "OWNER",
66-
})
67-
}
68-
69-
// Portrait image
70-
const img = this.actor.img
71-
if (img === CONST.DEFAULT_TOKEN) controls.findSplice((c) => c.action === "showPortraitArtwork")
72-
73-
// Token image
74-
const pt = this.actor.prototypeToken
75-
const tex = pt.texture.src
76-
if (pt.randomImg || [null, undefined, CONST.DEFAULT_TOKEN].includes(tex)) {
77-
controls.findSplice((c) => c.action === "showTokenArtwork")
78-
}
79-
80-
return controls
81-
}
82-
8328
/** @override */
8429
static PARTS = {
8530
main: {
@@ -88,23 +33,28 @@ export default class IntoTheOddEncounterSheet extends HandlebarsApplicationMixin
8833
}
8934

9035
/** @override */
91-
async _prepareContext() {
92-
const context = {
36+
async _prepareContext(options) {
37+
const context = await super._prepareContext(options)
38+
Object.assign(context, {
9339
fields: this.document.schema.fields,
9440
systemFields: this.document.system.schema.fields,
9541
actor: this.document,
9642
system: this.document.system,
9743
source: this.document.toObject(),
9844
enrichedDescription: await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true }),
99-
}
45+
})
10046

101-
context.attacks = []
47+
const attacks = []
10248
const attacksRaw = this.actor.itemTypes.attack
10349
for (const item of attacksRaw) {
10450
item.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(item.system.description, { async: true })
105-
context.attacks.push(item)
51+
attacks.push(item)
10652
}
10753

54+
Object.assign(context, {
55+
attacks,
56+
})
57+
10858
//console.log('encounter context', context);
10959
return context
11060
}

styles/character.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,8 @@
119119
}
120120
}
121121
}
122+
123+
nav {
124+
margin: 10px 0 10px 0;
125+
}
122126
}

templates/attack-main.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<div class="details">
99
<fieldset>
1010
<legend>{{localize "INTOTHEODD.Labels.details"}}</legend>
11-
{{formField systemFields.damageFormula value=system.damageFormula }}
12-
{{formField systemFields.blast value=system.blast }}
11+
{{formGroup systemFields.damageFormula value=system.damageFormula }}
12+
{{formGroup systemFields.blast value=system.blast }}
1313
</fieldset>
1414
</div>
1515
</section>

templates/character-biography.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class="tab standard-form character-{{tab.id}} {{tab.cssClass}}" data-tab="{{tab.id}}" data-group="{{tab.group}}">
1+
<section class="tab standard-form character-biography {{#if tabs.biography.active}} active{{/if}}" data-group="primary" data-tab="biography">
22
{{formInput
33
systemFields.biography
44
enriched=enrichedBiography

templates/character-header.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<div class="character-name">{{formInput fields.name value=source.name }}</div>
55
<fieldset>
66
<legend>{{localize "INTOTHEODD.Labels.details"}}</legend>
7-
{{formField systemFields.level value=system.level localize=true }}
8-
{{formField systemFields.deprived value=system.deprived dataset=data.deprived }}
9-
{{formField systemFields.critical value=system.critical dataset=data.critical }}
7+
{{formGroup systemFields.level value=system.level localize=true }}
8+
{{formGroup systemFields.deprived value=system.deprived dataset=data.deprived }}
9+
{{formGroup systemFields.critical value=system.critical dataset=data.critical }}
1010
</fieldset>
1111
</div>
1212
</div>

templates/character-inventory.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class="tab standard-form character-{{tab.id}} {{tab.cssClass}}" data-tab="{{tab.id}}" data-group="{{tab.group}}">
1+
<section class="tab standard-form character-inventory {{#if tabs.inventory.active}} active{{/if}}" data-group="primary" data-tab="inventory">
22
<div class="character-items-list">
33
{{#each actor.items as |item id|}}
44
{{!log "item" id item}}

0 commit comments

Comments
 (0)