Skip to content

Commit

Permalink
Merge pull request #448 from ben/compact-sheet-updates
Browse files Browse the repository at this point in the history
Compact sheet updates
  • Loading branch information
ben authored Aug 25, 2022
2 parents 673f392 + 74178e9 commit c569521
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 119 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Next Release

- Freshen up the compact PC sheet, and use the new rolling pipeline ([#448](https://github.com/ben/foundry-ironsworn/pull/448))

## 1.17.1

- Make delve-site roll rendering a bit less ugly, until we can make it more pretty ([#446](https://github.com/ben/foundry-ironsworn/pull/446))
Expand Down
56 changes: 9 additions & 47 deletions src/module/actor/sheets/compactsheet.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import { RollDialog } from '../../helpers/rolldialog'
import { IronswornSettings } from '../../helpers/settings'
import { IronswornPrerollDialog } from '../../rolls'
import { CharacterMoveSheet } from './charactermovesheet'

interface CompactCharacterSheetOptions extends ActorSheet.Options {
statRollBonus: number
}

export class IronswornCompactCharacterSheet extends ActorSheet<CompactCharacterSheetOptions> {
constructor(actor, opts: CompactCharacterSheetOptions) {
opts.statRollBonus ||= 0
super(actor, opts)
}

export class IronswornCompactCharacterSheet extends ActorSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: [
Expand All @@ -21,7 +12,7 @@ export class IronswornCompactCharacterSheet extends ActorSheet<CompactCharacterS
`theme-${IronswornSettings.theme}`,
],
width: 560,
height: 228,
height: 210,
template: 'systems/foundry-ironsworn/templates/actor/compact.hbs',
resizable: false,
})
Expand All @@ -33,9 +24,6 @@ export class IronswornCompactCharacterSheet extends ActorSheet<CompactCharacterS
html
.find('.ironsworn__stat__roll')
.on('click', (e) => this._onStatRoll.call(this, e))
html
.find('.ironsworn__stat__bonusadajust')
.on('click', (e) => this._bonusAdjust.call(this, e))
html
.find('.ironsworn__resource__adjust')
.on('click', (e) => this._resourceAdjust.call(this, e))
Expand Down Expand Up @@ -77,39 +65,17 @@ export class IronswornCompactCharacterSheet extends ActorSheet<CompactCharacterS
}
}

_onBurnMomentum(ev: JQuery.ClickEvent) {
ev.preventDefault()

if (this.actor.data.type !== 'character') return
const { momentum, momentumReset } = this.actor.data.data
if (momentum > momentumReset) {
this.actor.update({
data: { momentum: momentumReset },
})
}
}

_bonusAdjust(ev: JQuery.ClickEvent) {
ev.preventDefault()

const amt = parseInt(ev.currentTarget.dataset.amt || '0')
this.options.statRollBonus += amt
this.render(true)
}

async _onStatRoll(ev: JQuery.ClickEvent) {
ev.preventDefault()

const el = ev.currentTarget
const stat = el.dataset.stat
if (stat) {
const bonus = this.options.statRollBonus || 0
await RollDialog.show({
actor: this.actor,
IronswornPrerollDialog.showForStat(
stat,
bonus,
})
this.options.statRollBonus = 0
this.actor.data.data[stat],
this.actor
)
this.render(true)
}
}
Expand All @@ -135,12 +101,8 @@ export class IronswornCompactCharacterSheet extends ActorSheet<CompactCharacterS
_momentumBurn(ev: JQuery.ClickEvent) {
ev.preventDefault()

if (this.actor.data.type !== 'character') return
const { momentum, momentumReset } = this.actor.data.data
if (momentum > momentumReset) {
this.actor.update({
data: { momentum: momentumReset },
})
if (this.actor.data.type === 'character') {
this.actor.burnMomentum()
}
}
}
2 changes: 2 additions & 0 deletions src/styles/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,12 @@
}

.compact {
h2,
h3,
h4,
h5 {
margin: 3px 0;
border: none;
}
}

Expand Down
12 changes: 3 additions & 9 deletions system/templates/actor/compact.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{#*inline "stat"}}
<div class="box flexcol clickable block ironsworn__stat__roll" data-stat="{{stat}}">
<h4>{{localize (concat 'IRONSWORN.' (capitalize stat))}}</h4>
<h3>{{lookup data.data stat}}</h3>
<h2>{{lookup data.data stat}}</h2>
</div>
{{/inline}}

Expand All @@ -15,21 +15,15 @@
{{>stat stat="shadow"}}
{{>stat stat="wits"}}
</div>
<div class="flexrow boxrow small">
<div class="box clickable block ironsworn__stat__bonusadajust" data-amt="-1">&minus;</div>
<div class="box" title="{{localize 'IRONSWORN.StatBonusTooltip'}}">
{{options.statRollBonus}}
</div>
<div class="box clickable block ironsworn__stat__bonusadajust" data-amt="1">&plus;</div>
</div>
</div>

{{!-- Resources --}}
<div class="flexcol boxgroup" style="margin: 5px;">
<div class="flexrow boxrow">
{{#*inline "resource"}}
<div class="box flexcol">
<div class="flexcol boxrow clickable block ironsworn__stat__roll" data-stat="{{stat}}">
<div class="flexcol boxrow {{#unless burn}}clickable block ironsworn__stat__roll{{/unless}}"
data-stat="{{stat}}">
<h5>{{localize (concat 'IRONSWORN.' (capitalize stat))}}</h5>
<h4>{{lookup data.data stat}}</h4>
</div>
Expand Down
102 changes: 39 additions & 63 deletions system/templates/rolls/preroll-dialog.hbs
Original file line number Diff line number Diff line change
@@ -1,60 +1,50 @@
<form class='preroll-dialog{{#if action}} action-roll-dialog{{else}} progress-roll-dialog{{/if}}'>
{{#if move}}
<section class='roll-trigger-text'>
{{{enrichMarkdown move.data.data.Trigger.Text}}}
</section>
{{#if move.data.data.Trigger.Options}}
<ul class='trigger-options'>
{{#each move.data.data.Trigger.Options}}
{{#if Text}}
<li class='trigger-option'>
{{Text}}:
<strong>{{formatRollMethod Method Using}}</strong>
</li>
{{/if}}
{{/each}}
</ul>
<section class='roll-trigger-text'>
{{{enrichMarkdown move.data.data.Trigger.Text}}}
</section>
{{#if move.data.data.Trigger.Options}}
<ul class='trigger-options'>
{{#each move.data.data.Trigger.Options}}
{{#if Text}}
<li class='trigger-option'>
{{Text}}:
<strong>{{formatRollMethod Method Using}}</strong>
</li>
{{/if}}
{{/each}}
</ul>
{{/if}}
{{/if}}
<section class='dice-roll ironsworn-roll'>
{{{graphic}}}
</section>
{{#if action}}
<fieldset class='form-group'>
<label for='roll-input-adds'>{{localize 'IRONSWORN.Adds'}}</label>
<input
id='roll-input-adds'
type='number'
step='1'
name='adds'
value='0'
/>
</fieldset>
<fieldset class='form-group'>
<label for='roll-input-adds'>{{localize 'IRONSWORN.Adds'}}</label>
<input id='roll-input-adds' type='number' step='1' name='adds' value='0' />
</fieldset>
{{/if}}

{{#if showActorSelect}}
<fieldset class='form-group'>
<label for='char'>{{localize 'IRONSWORN.Character'}}</label>
<select name='char' id='char' class='select-character'>
{{#each allActors}}
<option value='{{id}}'>
{{name}}
</option>
{{/each}}
</select>
</fieldset>
<fieldset class='form-group'>
<label for='char'>{{localize 'IRONSWORN.Character'}}</label>
<select name='char' id='char' class='select-character'>
{{#each allActors}}
<option value='{{id}}'>
{{name}}
</option>
{{/each}}
</select>
</fieldset>
{{/if}}
{{! TODO: simple options from the move + actor assets }}
<details class='advanced-roll-options'>
<summary>{{localize 'IRONSWORN.RollDialog.AdvancedRollOptions'}}</summary>

<fieldset class='form-group'>
<label class='checkbox'>
<input
type='checkbox'
class='advanced-roll-options-toggle'
name='automaticOutcome'
/>
<input type='checkbox' class='advanced-roll-options-toggle' name='automaticOutcome' />
{{localize 'IRONSWORN.RollDialog.PredeterminedOutcome'}}
</label>
<select name='automaticOutcomeValue'>
Expand All @@ -65,35 +55,21 @@
</fieldset>

{{#if action}}
<fieldset class='form-group'>
<label class='checkbox'>
<input
type='checkbox'
class='advanced-roll-options-toggle'
name='presetActionDie'
/>
{{localize 'IRONSWORN.RollDialog.PresetActionDie'}}
</label>
<input type='number' step='1' name='presetActionDieValue' value='0' />
</fieldset>
<fieldset class='form-group'>
<label class='checkbox'>
<input type='checkbox' class='advanced-roll-options-toggle' name='presetActionDie' />
{{localize 'IRONSWORN.RollDialog.PresetActionDie'}}
</label>
<input type='number' step='1' name='presetActionDieValue' value='0' />
</fieldset>
{{/if}}
<fieldset class='form-group'>
<label class='checkbox'>
<input
type='checkbox'
class='advanced-roll-options-toggle'
name='extraChallengeDice'
/>
<input type='checkbox' class='advanced-roll-options-toggle' name='extraChallengeDice' />
{{localize 'IRONSWORN.RollDialog.ExtraChallengeDice'}}
</label>
<input
type='number'
step='1'
name='extraChallengeDiceValue'
value='0'
min='0'
/>
<input type='number' step='1' name='extraChallengeDiceValue' value='0' min='0' />
</fieldset>

</details>
</form>
</form>

0 comments on commit c569521

Please sign in to comment.