Skip to content

Commit bbd284a

Browse files
committed
skill structure + settings bugfix
1 parent 157099b commit bbd284a

File tree

5 files changed

+55
-50
lines changed

5 files changed

+55
-50
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
- v1.0.7: Dae Compatibility + removed owned actor limitation
1111
- v1.0.8: Fixed regression with tidy 5e sheet.
1212
- v1.1.0: First FVTT v10 release.
13+
- v1.1.1: Changed inner skill structure to reflect dnd5e system latest update + bugfix

css/styles.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ div#cs-debug_box span {
3434
min-width: 100%;
3535
}
3636

37-
.dnd5e.sheet.actor.cb5es .custom-abilities .ability {
37+
.dnd5e.sheet.actor.cb5es .custom-abilities .ability,
38+
.dnd5e.sheet.actor.dndbcs .custom-abilities .ability {
3839
min-width:auto;
3940
}
4041
.dnd5e.sheet.actor .custom-abilities .ability > h4 {

dnd5e-custom-skills.js

+28-22
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
const MODULE_NAME = 'dnd5e-custom-skills';
22

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-
133
Handlebars.registerHelper("csFormat", (path, ...args) => {
144
return game.i18n.format(path, args[0].hash);
155
});
@@ -41,7 +31,7 @@ class CustomSkillsForm extends FormApplication {
4131
{ abilities: CONFIG.DND5E.abilities, skills: CONFIG.DND5E.skills },
4232
this.reset ? mergeObject(CustomSkills.defaultSettings, {requireSave:true}) : mergeObject(CustomSkills.settings, {requireSave:false}));
4333
this.reset = false;
44-
//console.log('getData', data);
34+
// console.log('getData', data);
4535
return data;
4636
}
4737

@@ -59,6 +49,7 @@ class CustomSkillsForm extends FormApplication {
5949
let newSkills;
6050
let newAbilities;
6151
let newSettings = mergeObject(oldSettings, Form);
52+
6253
// update settings
6354
await game.settings.set(MODULE_NAME, 'settings', newSettings);
6455

@@ -85,7 +76,7 @@ class CustomSkillsForm extends FormApplication {
8576
} else {
8677
newAbilities = mergeObject(oldSettings.customAbilitiesList, Form.customAbilitiesList, { insertKeys: true, insertValues: true, overwrite:true });
8778
};
88-
79+
8980
await this.update(newSkills, newAbilities);
9081

9182
return this.render();
@@ -120,7 +111,8 @@ class CustomSkillsForm extends FormApplication {
120111
}
121112

122113
// modify system variables
123-
await CustomSkills.applyToSystem();
114+
CustomSkills.applyToSystem();
115+
124116
// clean leftovers on players actors
125117
await CustomSkills.cleanActors();
126118
ui.notifications.info(game.i18n.localize(MODULE_NAME + '.updateDone'));
@@ -142,24 +134,36 @@ class CustomSkillsForm extends FormApplication {
142134
const skillCode = elem.data('skill');
143135
if (elem.prop('checked')) {
144136
$('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');
146138
} else {
147139
$('select#select_'+skillCode, container).removeAttr('disabled');
148-
$('input[name="customSkillList.' + skillCode + '.label"]', container).removeAttr('readonly');
140+
$('input[name="fakeSkillList.' + skillCode + '.label"]', container).removeAttr('readonly');
149141
}
150142
}
151143

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+
152150
// enable ability
153151
if (elem.hasClass('apply_ability')) {
154152
const abilityCode = elem.data('ability');
155153
if (elem.prop('checked')) {
156-
$('input[name="customAbilitiesList.' + abilityCode + '.label"]', container).attr('readonly', 'readonly');
154+
$('input[name="fakeAbilityLabel.' + abilityCode + '.label"]', container).attr('readonly', 'readonly');
157155
} else {
158-
$('input[name="customAbilitiesList.' + abilityCode + '.label"]', container).removeAttr('readonly');
156+
$('input[name="fakeAbilityLabel.' + abilityCode + '.label"]', container).removeAttr('readonly');
159157
}
160158
}
161159

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
163167
if (elem.hasClass('ability_select')) {
164168
const selected = elem.find('option:selected').val();
165169
const skillCode = elem.data('skill');
@@ -354,10 +358,10 @@ class CustomSkills {
354358
let systemSkills = game.dnd5e.config.skills;
355359
let systemAbilities = game.dnd5e.config.abilities;
356360
let systemAbilityAbbr = game.dnd5e.config.abilityAbbreviations;
357-
361+
358362
// see if we need to modify the _fallback translation for compatibility with tidy5esheet
359363
let isFallback = false;
360-
if (typeof game.i18n.translations.DND5E === 'undefined') {
364+
if (typeof game.i18n.translations.DND5E === 'undefined' && typeof game.i18n._fallback != 'undefined') {
361365
isFallback = true;
362366
}
363367
let abbrKey = '';
@@ -384,8 +388,10 @@ class CustomSkills {
384388
//console.log('customSkills',customSkills);
385389
for (let s in customSkills) {
386390
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+
};
389395
if (window._isDaeActive) {
390396
this.daeAutoFields(s, true)
391397
}

module.json

+13-18
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,36 @@
22
"id": "dnd5e-custom-skills",
33
"title": "5e - Custom Abilities & Skills",
44
"description": "FoundryVTT module for adding new character skills and abilities",
5-
"version": "1.1.0",
5+
"version": "1.1.1",
66
"compatibility": {
7-
"minimum": 10,
8-
"verified": "10.278",
9-
"maximum" : 10
7+
"minimum": "10",
8+
"maximum": "10"
109
},
1110
"url": "https://github.com/misthero/dnd5e-custom-skills",
1211
"manifest": "https://raw.githubusercontent.com/misthero/dnd5e-custom-skills/main/module.json",
1312
"download": "https://github.com/misthero/dnd5e-custom-skills/archive/main.zip",
14-
"system": ["dnd5e"],
15-
"includes": [
16-
"./assets/**",
17-
"./lang/**",
18-
"./scripts/**",
19-
"./styles/**",
20-
"./templates/**",
21-
"./module.json"
22-
],
2313
"authors": [{
2414
"name": "misthero",
25-
"url": "https://github.com/misthero"
15+
"url": "https://github.com/misthero",
16+
"flags": {}
2617
}],
2718
"esmodules": [
28-
"./dnd5e-custom-skills.js"
19+
"dnd5e-custom-skills.js"
20+
],
21+
"styles": [
22+
"css/styles.css"
2923
],
30-
"styles": ["css/styles.css"],
3124
"languages": [{
3225
"lang": "en",
3326
"name": "English",
34-
"path": "lang/en.json"
27+
"path": "lang/en.json",
28+
"flags": {}
3529
},
3630
{
3731
"lang": "it",
3832
"name": "Italiano",
39-
"path": "lang/it.json"
33+
"path": "lang/it.json",
34+
"flags": {}
4035
}
4136
]
4237
}

templates/skills-config.html

+11-9
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ <h2>{{localize "dnd5e-custom-skills.poptitle"}}</h2>
44
<form autocomplete="off" class="dnd5e-custom-skills" id="dnd5ecustomskillsform">
55
<div class="form-group">
66
<div class="label">{{localize "dnd5e-custom-skills.abilitiesNumLabel"}}
7-
<input name="abilitiesNum" type="number" min="1" max="20" length="2" value="{{abilitiesNum}}" />
7+
<input name="abilitiesNum" type="number" min="1" max="20" length="2" value="{{abilitiesNum}}" data-tooltip="{{localize 'dnd5e-custom-skills.abilitiesNumLabel' }}" />
88
</div>
99
</div>
1010
<div class="custom-abilities-list">
1111
{{#each customAbilitiesList as |abilitydata a|}}
1212
<div class="form-group ability_element {{a}}">
1313
<div class="ability_name">
1414
<div class="label">{{localize "dnd5e-custom-skills.abilityInput"}} ({{a}})</div>
15-
<input {{#if abilitydata.applied}}readonly{{/if}} type="text" name="customAbilitiesList.{{a}}.label" data-dtype="string" value="{{ abilitydata.label }}" />
15+
<input class="ability-label-capture" {{#if abilitydata.applied}}readonly{{/if}} type="text" data-key="{{a}}" name="fakeAbilityLabel.{{a}}.label" data-dtype="string" value="{{ abilitydata.label }}" />
16+
<input type="hidden" name="customAbilitiesList.{{a}}.label" value="{{ abilitydata.label }}" data-dtype="string" />
1617
</div>
17-
<div class="ability_apply" data-ability="{{a}}" data-tooltip="{{localize " dnd5e-custom-skills.abilityApply "}}">
18+
<div class="ability_apply" data-ability="{{a}}">
1819
<div class="label">{{localize "dnd5e-custom-skills.abilityApply"}}</div>
1920
<input type="checkbox" class="apply_ability" data-ability="{{a}}" name="customAbilitiesList.{{a}}.applied" data-dtype="Boolean" {{checked abilitydata.applied}}/>
2021
</div>
@@ -32,18 +33,19 @@ <h2>{{localize "dnd5e-custom-skills.poptitle"}}</h2>
3233
<div class="form-group skill_element {{n}}">
3334
<div class="skill_name">
3435
<div class="label">{{localize "dnd5e-custom-skills.skillInput"}} ({{n}})</div>
35-
<input {{#if skilldata.applied}}readonly{{/if}} type="text" name="customSkillList.{{n}}.label" data-dtype="string" value="{{ skilldata.label }}" />
36+
<input class="skill-label-capture" {{#if skilldata.applied}}readonly{{/if}} type="text" data-key="{{n}}" name="fakeSkillList.{{n}}.label" data-dtype="string" value="{{ skilldata.label }}" />
37+
<input type="hidden" name="customSkillList.{{n}}.label" data-dtype="string" value="{{ skilldata.label }}" />
3638
</div>
3739
<div class="skill_ability">
3840
<div class="label">{{localize "dnd5e-custom-skills.skillAbility"}}</div>
3941
<select data-skill="{{n}}" class="ability_select" {{#if skilldata.applied}}disabled{{/if}} id="select_{{n}}" style="flex: 1;">
40-
{{#each ../abilities as |name key|}}
42+
{{#each ../abilities as |name key|}}
4143
<option {{#if (eq key skilldata.ability )}} selected {{/if}} value="{{key}}">{{name}}</option>
42-
{{/each}}
43-
</select>
44+
{{/each}}
45+
</select>
4446
<input type="hidden" name="customSkillList.{{n}}.ability" value="{{skilldata.ability}}" />
4547
</div>
46-
<div class="skill_apply" data-skill="{{n}}" data-tooltip="{{localize " dnd5e-custom-skills.skillApply "}}">
48+
<div class="skill_apply" data-skill="{{n}}">
4749
<div class="label">{{localize "dnd5e-custom-skills.skillApply"}}</div>
4850
<input type="checkbox" class="apply_skill" data-skill="{{n}}" name="customSkillList.{{n}}.applied" data-dtype="Boolean" {{checked skilldata.applied}}/>
4951
</div>
@@ -65,7 +67,7 @@ <h3><span class="fas fa-mask"></span> {{localize "dnd5e-custom-skills.hideSkills
6567
{{#each skills as |name key|}}
6668
<label>
6769
<input type="checkbox" {{#if (lookup ../hiddenSkills key) }} checked {{/if}} name="hiddenSkills.{{key}}" value="{{key}}" data-dtype="Boolean"/>
68-
{{name}}
70+
{{name.label}}
6971
</label> {{/each}}
7072
</div>
7173
<!-- <div id="cs-debug_box"></div> -->

0 commit comments

Comments
 (0)