1- const { ux } = foundry . applications
1+ const { sheets , ux } = foundry . applications
22const { HandlebarsApplicationMixin } = foundry . applications . api
33const { 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 /**
0 commit comments