Skip to content

Commit

Permalink
[#1852] Allow for choosing a skill's ability on the character sheet r…
Browse files Browse the repository at this point in the history
…ather than during the intermediary roll dialog.
  • Loading branch information
Fyorl committed Oct 8, 2022
1 parent c3a7f30 commit 8cb647d
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 78 deletions.
8 changes: 3 additions & 5 deletions dnd5e.css
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@
cursor: default;
}
.dnd5e.sheet.actor ul.skills-list {
flex: 0 0 180px;
flex: 0 0 212px;
list-style: none;
margin: 0 5px 0;
padding: 0;
Expand All @@ -991,6 +991,7 @@
.dnd5e.sheet.actor ul.skills-list li.skill {
height: 24px;
padding: 3px 2px;
align-items: center;
}
.dnd5e.sheet.actor ul.skills-list li.skill:nth-child(even) {
background: rgba(0, 0, 0, 0.05);
Expand Down Expand Up @@ -1019,6 +1020,7 @@
}
.dnd5e.sheet.actor ul.skills-list li.skill .skill-ability {
flex: 0 0 26px;
border: none;
text-transform: capitalize;
}
.dnd5e.sheet.actor ul.skills-list li.skill .skill-mod {
Expand Down Expand Up @@ -1934,16 +1936,12 @@
margin: 0;
top: -6px;
}
.dnd5e.sheet.actor.character ul.skills-list {
flex: 0 0 212px;
}
.dnd5e.sheet.actor.character ul.skills-list li.skill {
padding: 3px;
}
.dnd5e.sheet.actor.character ul.skills-list li.skill h4 {
flex: 1px;
margin: 0;
font-size: 13px;
}
.dnd5e.sheet.actor.character .item-detail.player-class {
flex: 0 0 180px;
Expand Down
4 changes: 3 additions & 1 deletion less/actors.less
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
/* ----------------------------------------- */

ul.skills-list {
flex: 0 0 180px;
flex: 0 0 212px;
list-style: none;
margin: 0 5px 0;
padding: 0;
Expand All @@ -303,6 +303,7 @@
li.skill {
height: 24px;
padding: 3px 2px;
align-items: center;

&:nth-child(even) {
background: rgba(0, 0, 0, 0.05);
Expand Down Expand Up @@ -337,6 +338,7 @@

.skill-ability {
flex: 0 0 26px;
border: none;
text-transform: capitalize;
}

Expand Down
3 changes: 0 additions & 3 deletions less/character.less
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,11 @@
}

ul.skills-list {
flex: 0 0 212px;

li.skill {
padding: 3px;
h4 {
flex: 1px;
margin: 0;
font-size: 13px;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion module/applications/actor/npc-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class ActorSheet5eNPC extends ActorSheet5e {
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["dnd5e", "sheet", "actor", "npc"],
width: 600
width: 632
});
}

Expand Down
7 changes: 1 addition & 6 deletions module/dice/d20-roll.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -187,23 +187,18 @@ export default class D20Roll extends Roll {
* @param {string} [data.title] The title of the shown dialog window
* @param {number} [data.defaultRollMode] The roll mode that the roll mode select element should default to
* @param {number} [data.defaultAction] The button marked as default
* @param {boolean} [data.chooseModifier] Choose which ability modifier should be applied to the roll?
* @param {string} [data.defaultAbility] For tool rolls, the default ability modifier applied to the roll
* @param {string} [data.template] A custom path to an HTML template to use instead of the default
* @param {object} options Additional Dialog customization options
* @returns {Promise<D20Roll|null>} A resulting D20Roll object constructed with the dialog, or null if the
* dialog was closed
*/
async configureDialog({title, defaultRollMode, defaultAction=D20Roll.ADV_MODE.NORMAL, chooseModifier=false,
defaultAbility, template}={}, options={}) {
async configureDialog({title, defaultRollMode, defaultAction=D20Roll.ADV_MODE.NORMAL, template}={}, options={}) {

// Render the Dialog inner HTML
const content = await renderTemplate(template ?? this.constructor.EVALUATION_TEMPLATE, {
formula: `${this.formula} + @bonus`,
defaultRollMode,
rollModes: CONFIG.Dice.rollModes,
chooseModifier,
defaultAbility,
abilities: CONFIG.DND5E.abilities
});

Expand Down
10 changes: 1 addition & 9 deletions module/dice/dice.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
*
* ## Roll Configuration Dialog
* @property {boolean} [fastForward] Should the roll configuration dialog be skipped?
* @property {boolean} [chooseModifier=false] If the configuration dialog is shown, should the ability modifier be
* configurable within that interface?
* @property {string} [template] The HTML template used to display the roll configuration dialog.
* @property {string} [title] Title of the roll configuration dialog.
* @property {object} [dialogOptions] Additional options passed to the roll configuration dialog.
Expand All @@ -52,18 +50,14 @@ export async function d20Roll({
parts=[], data={}, event,
advantage, disadvantage, critical=20, fumble=1, targetValue,
elvenAccuracy, halflingLucky, reliableTalent,
fastForward, chooseModifier=false, template, title, dialogOptions,
fastForward, template, title, dialogOptions,
chatMessage=true, messageData={}, rollMode, flavor
}={}) {

// Handle input arguments
const formula = ["1d20"].concat(parts).join(" + ");
const {advantageMode, isFF} = _determineAdvantageMode({advantage, disadvantage, fastForward, event});
const defaultRollMode = rollMode || game.settings.get("core", "rollMode");
if ( chooseModifier && !isFF ) {
data.mod = "@mod";
if ( "abilityCheckBonus" in data ) data.abilityCheckBonus = "@abilityCheckBonus";
}

// Construct the D20Roll instance
const roll = new CONFIG.Dice.D20Roll(formula, data, {
Expand All @@ -83,10 +77,8 @@ export async function d20Roll({
if ( !isFF ) {
const configured = await roll.configureDialog({
title,
chooseModifier,
defaultRollMode,
defaultAction: advantageMode,
defaultAbility: data?.item?.ability || data?.defaultAbility,
template
}, dialogOptions);
if ( configured === null ) return null;
Expand Down
2 changes: 0 additions & 2 deletions module/documents/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,6 @@ export default class Actor5e extends Actor {

// Add ability modifier
data.mod = skl.mod;
data.defaultAbility = skl.ability;

// Include proficiency bonus
if ( skl.prof.hasProficiency ) {
Expand Down Expand Up @@ -873,7 +872,6 @@ export default class Actor5e extends Actor {
data: data,
title: `${flavor}: ${this.name}`,
flavor,
chooseModifier: true,
halflingLucky: this.getFlag("dnd5e", "halflingLucky"),
reliableTalent,
messageData: {
Expand Down
1 change: 0 additions & 1 deletion module/documents/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,6 @@ export default class Item5e extends Item {
top: options.event ? options.event.clientY - 80 : null,
left: window.innerWidth - 710
},
chooseModifier: true,
halflingLucky: this.actor.getFlag("dnd5e", "halflingLucky" ),
reliableTalent: (this.system.proficient >= 1) && this.actor.getFlag("dnd5e", "reliableTalent"),
messageData: {
Expand Down
1 change: 1 addition & 0 deletions module/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export async function preloadHandlebarsTemplates() {
"systems/dnd5e/templates/actors/parts/actor-features.hbs",
"systems/dnd5e/templates/actors/parts/actor-spellbook.hbs",
"systems/dnd5e/templates/actors/parts/actor-warnings.hbs",
"systems/dnd5e/templates/actors/parts/actor-skills.hbs",

// Item Sheet Partials
"systems/dnd5e/templates/items/parts/item-action.hbs",
Expand Down
22 changes: 1 addition & 21 deletions templates/actors/character-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,7 @@
</ul>

{{!-- Skills --}}
<ul class="skills-list">
{{#each config.skills as |obj s|}}
{{#with (lookup ../system.skills s) as |skill|}}
<li class="skill flexrow {{#if skill.value}}proficient{{/if}}" data-skill="{{s}}">
<input type="hidden" name="system.skills.{{s}}.value" value="{{skill.baseValue}}" data-dtype="Number"/>
<a class="proficiency-toggle skill-proficiency" title="{{skill.hover}}">{{{skill.icon}}}</a>
<div class="skill-name-controls">
<h4 class="skill-name rollable">{{skill.label}}</h4>
<a class="config-button" data-action="skill" title="{{localize 'DND5E.SkillConfigure'}}"><i class="fas fa-cog"></i></a>
</div>
<span class="skill-ability">{{skill.ability}}</span>
<span class="skill-mod" title="{{ localize 'DND5E.SkillModifierHint' skill=skill.label }}">
{{numberFormat skill.total decimals=0 sign=true}}
</span>
<span class="skill-passive" title="{{ localize 'DND5E.SkillPassiveHint' skill=skill.label }}">
({{skill.passive}})
</span>
</li>
{{/with}}
{{/each}}
</ul>
{{> "dnd5e.actor-skills"}}

<section class="center-pane flexcol">

Expand Down
22 changes: 1 addition & 21 deletions templates/actors/npc-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -129,27 +129,7 @@
</ul>

{{!-- Skills --}}
<ul class="skills-list">
{{#each config.skills as |obj s|}}
{{#with (lookup ../system.skills s) as |skill|}}
<li class="skill flexrow {{#if skill.value}}proficient{{/if}}" data-skill="{{s}}">
<input type="hidden" name="system.skills.{{s}}.value" value="{{skill.baseValue}}" data-dtype="Number"/>
<a class="proficiency-toggle skill-proficiency" title="{{skill.hover}}">{{{skill.icon}}}</a>
<div class="skill-name-controls">
<h4 class="skill-name rollable">{{skill.label}}</h4>
<a class="config-button" data-action="skill" title="{{localize 'DND5E.SkillConfigure'}}"><i class="fas fa-cog"></i></a>
</div>
<span class="skill-ability">{{skill.ability}}</span>
<span class="skill-mod" title="{{ localize 'DND5E.SkillModifierHint' skill=skill.label }}">
{{numberFormat skill.total decimals=0 sign=true}}
</span>
<span class="skill-passive" title="{{ localize 'DND5E.SkillPassiveHint' skill=skill.label }}">
({{skill.passive}})
</span>
</li>
{{/with}}
{{/each}}
</ul>
{{> "dnd5e.actor-skills"}}

<section class="center-pane flexcol">

Expand Down
25 changes: 25 additions & 0 deletions templates/actors/parts/actor-skills.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<ul class="skills-list">
{{#each config.skills as |obj s|}}
{{#with (lookup ../system.skills s) as |skill|}}
<li class="skill flexrow {{#if skill.value}}proficient{{/if}}" data-skill="{{s}}">
<input type="hidden" name="system.skills.{{s}}.value" value="{{skill.baseValue}}" data-dtype="Number">
<a class="proficiency-toggle skill-proficiency" title="{{skill.hover}}">{{{skill.icon}}}</a>
<div class="skill-name-controls">
<h4 class="skill-name rollable">{{skill.label}}</h4>
<a class="config-button" data-action="skill" title="{{localize 'DND5E.SkillConfigure'}}">
<i class="fas fa-cog"></i>
</a>
</div>
<select class="skill-ability" name="system.skills.{{s}}.ability">
{{selectOptions @root.config.abilityAbbreviations selected=skill.ability}}
</select>
<span class="skill-mod" title="{{localize 'DND5E.SkillModifierHint' skill=skill.label}}">
{{numberFormat skill.total decimals=0 sign=true}}
</span>
<span class="skill-passive" title="{{localize 'DND5E.SkillPassiveHint' skill=skill.label}}">
({{skill.passive}})
</span>
</li>
{{/with}}
{{/each}}
</ul>
8 changes: 0 additions & 8 deletions templates/chat/roll-dialog.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
<label>{{ localize "DND5E.Formula" }}</label>
<input type="text" name="formula" value="{{formula}}" disabled/>
</div>
{{#if chooseModifier}}
<div class="form-group">
<label>{{ localize "DND5E.AbilityModifier" }}</label>
<select name="ability">
{{selectOptions abilities selected=defaultAbility}}
</select>
</div>
{{/if}}
<div class="form-group">
<label>{{ localize "DND5E.RollSituationalBonus" }}</label>
<input type="text" name="bonus" value="" placeholder="{{ localize 'DND5E.RollExample' }}"/>
Expand Down

0 comments on commit 8cb647d

Please sign in to comment.