1
1
const MODULE_NAME = 'dnd5e-custom-skills' ;
2
2
3
- var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
4
- function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
5
- return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
6
- function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
7
- function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
8
- function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
9
- step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
10
- } ) ;
11
- } ;
12
-
13
3
Handlebars . registerHelper ( "csFormat" , ( path , ...args ) => {
14
4
return game . i18n . format ( path , args [ 0 ] . hash ) ;
15
5
} ) ;
@@ -41,7 +31,7 @@ class CustomSkillsForm extends FormApplication {
41
31
{ abilities : CONFIG . DND5E . abilities , skills : CONFIG . DND5E . skills } ,
42
32
this . reset ? mergeObject ( CustomSkills . defaultSettings , { requireSave :true } ) : mergeObject ( CustomSkills . settings , { requireSave :false } ) ) ;
43
33
this . reset = false ;
44
- //console.log('getData', data);
34
+ // console.log('getData', data);
45
35
return data ;
46
36
}
47
37
@@ -59,6 +49,7 @@ class CustomSkillsForm extends FormApplication {
59
49
let newSkills ;
60
50
let newAbilities ;
61
51
let newSettings = mergeObject ( oldSettings , Form ) ;
52
+
62
53
// update settings
63
54
await game . settings . set ( MODULE_NAME , 'settings' , newSettings ) ;
64
55
@@ -85,7 +76,7 @@ class CustomSkillsForm extends FormApplication {
85
76
} else {
86
77
newAbilities = mergeObject ( oldSettings . customAbilitiesList , Form . customAbilitiesList , { insertKeys : true , insertValues : true , overwrite :true } ) ;
87
78
} ;
88
-
79
+
89
80
await this . update ( newSkills , newAbilities ) ;
90
81
91
82
return this . render ( ) ;
@@ -120,7 +111,8 @@ class CustomSkillsForm extends FormApplication {
120
111
}
121
112
122
113
// modify system variables
123
- await CustomSkills . applyToSystem ( ) ;
114
+ CustomSkills . applyToSystem ( ) ;
115
+
124
116
// clean leftovers on players actors
125
117
await CustomSkills . cleanActors ( ) ;
126
118
ui . notifications . info ( game . i18n . localize ( MODULE_NAME + '.updateDone' ) ) ;
@@ -142,24 +134,36 @@ class CustomSkillsForm extends FormApplication {
142
134
const skillCode = elem . data ( 'skill' ) ;
143
135
if ( elem . prop ( 'checked' ) ) {
144
136
$ ( 'select#select_' + skillCode , container ) . attr ( 'disabled' , 'disabled' ) ;
145
- $ ( 'input[name="customSkillList .' + skillCode + '.label"]' , container ) . attr ( 'readonly' , 'readonly' ) ;
137
+ $ ( 'input[name="fakeSkillList .' + skillCode + '.label"]' , container ) . attr ( 'readonly' , 'readonly' ) ;
146
138
} else {
147
139
$ ( 'select#select_' + skillCode , container ) . removeAttr ( 'disabled' ) ;
148
- $ ( 'input[name="customSkillList .' + skillCode + '.label"]' , container ) . removeAttr ( 'readonly' ) ;
140
+ $ ( 'input[name="fakeSkillList .' + skillCode + '.label"]' , container ) . removeAttr ( 'readonly' ) ;
149
141
}
150
142
}
151
143
144
+ // fill hidden skill input
145
+ if ( elem . hasClass ( 'skill-label-capture' ) ) {
146
+ const skillKey = elem . data ( 'key' ) ;
147
+ $ ( 'input[name="customSkillList.' + skillKey + '.label"]' , container ) . val ( elem . val ( ) ) ;
148
+ }
149
+
152
150
// enable ability
153
151
if ( elem . hasClass ( 'apply_ability' ) ) {
154
152
const abilityCode = elem . data ( 'ability' ) ;
155
153
if ( elem . prop ( 'checked' ) ) {
156
- $ ( 'input[name="customAbilitiesList .' + abilityCode + '.label"]' , container ) . attr ( 'readonly' , 'readonly' ) ;
154
+ $ ( 'input[name="fakeAbilityLabel .' + abilityCode + '.label"]' , container ) . attr ( 'readonly' , 'readonly' ) ;
157
155
} else {
158
- $ ( 'input[name="customAbilitiesList .' + abilityCode + '.label"]' , container ) . removeAttr ( 'readonly' ) ;
156
+ $ ( 'input[name="fakeAbilityLabel .' + abilityCode + '.label"]' , container ) . removeAttr ( 'readonly' ) ;
159
157
}
160
158
}
161
159
162
- // select ability
160
+ // fill hidden ability input
161
+ if ( elem . hasClass ( 'ability-label-capture' ) ) {
162
+ const abilityKey = elem . data ( 'key' ) ;
163
+ $ ( 'input[name="customAbilitiesList.' + abilityKey + '.label"]' , container ) . val ( elem . val ( ) ) ;
164
+ }
165
+
166
+ // fill hidden skill ability from select
163
167
if ( elem . hasClass ( 'ability_select' ) ) {
164
168
const selected = elem . find ( 'option:selected' ) . val ( ) ;
165
169
const skillCode = elem . data ( 'skill' ) ;
@@ -354,10 +358,10 @@ class CustomSkills {
354
358
let systemSkills = game . dnd5e . config . skills ;
355
359
let systemAbilities = game . dnd5e . config . abilities ;
356
360
let systemAbilityAbbr = game . dnd5e . config . abilityAbbreviations ;
357
-
361
+
358
362
// see if we need to modify the _fallback translation for compatibility with tidy5esheet
359
363
let isFallback = false ;
360
- if ( typeof game . i18n . translations . DND5E === 'undefined' ) {
364
+ if ( typeof game . i18n . translations . DND5E === 'undefined' && typeof game . i18n . _fallback != 'undefined' ) {
361
365
isFallback = true ;
362
366
}
363
367
let abbrKey = '' ;
@@ -384,8 +388,10 @@ class CustomSkills {
384
388
//console.log('customSkills',customSkills);
385
389
for ( let s in customSkills ) {
386
390
if ( customSkills [ s ] . applied ) {
387
- let label = customSkills [ s ] . label ;
388
- systemSkills [ s ] = label ;
391
+ systemSkills [ s ] = {
392
+ 'label' : customSkills [ s ] . label ,
393
+ 'ability' : customSkills [ s ] . ability
394
+ } ;
389
395
if ( window . _isDaeActive ) {
390
396
this . daeAutoFields ( s , true )
391
397
}
0 commit comments