-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from ben/ben/shared-sheet
Shared sheet
- Loading branch information
Showing
12 changed files
with
240 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { IronswornRollDialog } from '../../helpers/roll' | ||
import { IronswornSettings } from '../../helpers/settings' | ||
import { IronswornActor } from '../actor' | ||
|
||
export class IronswornSharedSheet extends ActorSheet<ActorSheet.Data<IronswornActor>, IronswornActor> { | ||
static get defaultOptions() { | ||
return mergeObject(super.defaultOptions, { | ||
classes: ['ironsworn', 'sheet', 'shared', `theme-${IronswornSettings.theme}`], | ||
width: 350, | ||
height: 700, | ||
template: 'systems/foundry-ironsworn/templates/actor/shared.hbs', | ||
} as BaseEntitySheet.Options) | ||
} | ||
|
||
activateListeners(html: JQuery) { | ||
super.activateListeners(html) | ||
|
||
html.find('.ironsworn__supply__roll').on('click', (e) => this._onSupplyRoll.call(this, e)) | ||
html.find('.ironsworn__supply__value').on('click', (e) => this._onSupplySet.call(this, e)) | ||
|
||
// Custom sheet listeners for every ItemType | ||
for (const itemClass of CONFIG.IRONSWORN.itemClasses) { | ||
itemClass.activateActorSheetListeners(html, this) | ||
} | ||
} | ||
|
||
getData() { | ||
let data: any = super.getData() | ||
|
||
data.vows = this.actor.items.filter((x) => x.type === 'vow') | ||
data.progresses = this.actor.items.filter((x) => x.type === 'progress') | ||
data.bonds = this.actor.items.find((x) => x.type === 'bondset') | ||
|
||
// Allow every itemtype to add data to the actorsheet | ||
for (const itemType of CONFIG.IRONSWORN.itemClasses) { | ||
data = itemType.getActorSheetData(data, this) | ||
} | ||
|
||
return data | ||
} | ||
|
||
_getHeaderButtons() { | ||
return [ | ||
{ | ||
class: 'ironsworn-toggle-edit-mode', | ||
label: 'Edit', | ||
icon: 'fas fa-edit', | ||
onclick: (e) => this._toggleEditMode(e), | ||
}, | ||
...super._getHeaderButtons(), | ||
] | ||
} | ||
|
||
_toggleEditMode(e: JQuery.ClickEvent) { | ||
e.preventDefault() | ||
|
||
const currentValue = this.actor.getFlag('foundry-ironsworn', 'edit-mode') | ||
this.actor.setFlag('foundry-ironsworn', 'edit-mode', !currentValue) | ||
} | ||
|
||
_onSupplyRoll(ev: JQuery.ClickEvent) { | ||
ev.preventDefault() | ||
|
||
const rollText = game.i18n.localize('IRONSWORN.Roll') | ||
const statText = game.i18n.localize('IRONSWORN.Supply') | ||
IronswornRollDialog.showDialog(this.actor.data.data, 'supply', `${rollText} +${statText}`) | ||
} | ||
|
||
_onSupplySet(ev: JQuery.ClickEvent) { | ||
ev.preventDefault() | ||
|
||
const el = ev.currentTarget | ||
const { value } = el.dataset | ||
// Clicked a value in momentum/health/etc, set the value | ||
const newValue = parseInt(value) | ||
this.actor.update({ data: { supply: newValue } }) | ||
IronswornSettings.maybeSetGlobalSupply(newValue) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,9 @@ | |
}, | ||
"xp": 0 | ||
}, | ||
"shared": {} | ||
"shared": { | ||
"supply": 5 | ||
} | ||
}, | ||
"Item": { | ||
"types": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{{#*inline "progress"}} | ||
<div class="flexcol item-row" data-id="{{id}}"> | ||
<div class="flexcol"> | ||
<div class="flexrow"> | ||
<div class="flexrow">{{>rankHexes rank=data.data.rank id=id}}</div> | ||
|
||
{{#if actor.data.flags.foundry-ironsworn.edit-mode}} | ||
<div class="clickable block nogrow ironsworn__{{type}}__delete" data-item="{{id}}"> | ||
<i class="fas fa-trash"></i> | ||
</div> | ||
{{/if}} | ||
|
||
<div class="clickable block nogrow ironsworn__{{type}}__settings" data-item="{{id}}"> | ||
<i class="fas fa-edit"></i> | ||
</div> | ||
<div class="clickable block nogrow ironsworn__progress__mark" {{! This works for vows too }} | ||
title="{{localize 'IRONSWORN.MarkProgress'}}" data-item="{{id}}"> | ||
<i class="fas fa-play"></i> | ||
</div> | ||
<div class="clickable block ironsworn__progress__fulfill" title="{{localize 'IRONSWORN.FulfillVow'}}" | ||
style="flex-grow: 0;" data-item="{{id}}"> | ||
<i class="fas fa-check"></i> | ||
</div> | ||
</div> | ||
<h3>{{name}}</h3> | ||
</div> | ||
<div class="flexrow"> | ||
<div class="flexrow track"> | ||
{{#each (progressCharacters data.data.current)}} | ||
<div class="track-box">{{{this}}}</div> | ||
{{/each}} | ||
</div> | ||
</div> | ||
</div> | ||
{{/inline}} | ||
|
||
<form class="{{cssClass}} flexcol" autocomplete="off"> | ||
|
||
<section class="sheet-area" style="flex-grow: 0;"> | ||
<h2 class="clickable text ironsworn__supply__roll"> | ||
{{localize 'IRONSWORN.Supply'}} | ||
</h2> | ||
<div class="boxgroup" style="line-height: 25px;"> | ||
<div class="flexrow boxrow"> | ||
{{#rangeEach from=0 to=5 current=data.data.supply}} | ||
<div class=" | ||
box clickable block ironsworn__supply__value | ||
{{#if isCurrent}} selected {{/if}} | ||
" data-value="{{value}}"> | ||
{{valueStr}} | ||
</div> | ||
{{/rangeEach}} | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section class="sheet-area" style="flex-grow: 0;"> | ||
<h2>{{localize 'IRONSWORN.Bonds'}}</h2> | ||
<div class="flexrow"> | ||
<div class="flexrow track"> | ||
{{#each (progressCharacters bonds.count)}} | ||
<div class="track-box">{{{this}}}</div> | ||
{{/each}} | ||
</div> | ||
<div data-item="{{bonds.id}}" class="ironsworn__bondset__settings block clickable" | ||
style="flex-grow: 0; padding: 5px; margin: 2px;"> | ||
<i class="fas fa-edit"></i> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section class="sheet-area progresses"> | ||
<h2>{{localize 'IRONSWORN.Vows'}}</h2> | ||
{{#each vows}} | ||
{{>progress}} | ||
{{/each}} | ||
<div class="block clickable ironsworn__vow__add"> | ||
<i class="fas fa-plus"></i> | ||
</div> | ||
</section> | ||
|
||
<section class="sheet-area progresses"> | ||
<h2>{{localize 'IRONSWORN.Progress'}}</h2> | ||
{{#each progresses}} | ||
{{>progress}} | ||
{{/each}} | ||
<div class="block clickable ironsworn__progress__add"> | ||
<i class="fas fa-plus"></i> | ||
</div> | ||
</section> | ||
|
||
</form> |