Skip to content

Commit

Permalink
Merge pull request #179 from ben/legacy-tracks
Browse files Browse the repository at this point in the history
Starforged character sheet
  • Loading branch information
ben authored Feb 6, 2022
2 parents f0c8bc0 + 3704a97 commit b5df640
Show file tree
Hide file tree
Showing 12 changed files with 337 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## In progress

- Add Starforged setting-truths dialog([#178](https://github.com/ben/foundry-ironsworn/pull/178))
- Add Starforged character sheet ([#179](https://github.com/ben/foundry-ironsworn/pull/179))

## 1.9.0

Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IronswornActor } from './module/actor/actor'
import { IronswornCharacterSheet } from './module/actor/sheets/charactersheet'
import { IronswornCharacterSheetV2 } from './module/actor/sheets/charactersheet-v2'
import { IronswornCompactCharacterSheet } from './module/actor/sheets/compactsheet'
import { StarforgedCharacterSheet } from './module/actor/sheets/sf-charactersheet'
import { IronswornSharedSheet } from './module/actor/sheets/sharedsheet'
import { IronswornSharedSheetV2 } from './module/actor/sheets/sharedsheet-v2'
import { IronswornSiteSheet } from './module/actor/sheets/sitesheet'
Expand Down Expand Up @@ -65,6 +66,12 @@ Hooks.once('init', async () => {
types: ['character'],
makeDefault: true,
})
if (CONFIG.IRONSWORN.IronswornSettings.starforgedBeta) {
Actors.registerSheet('ironsworn', StarforgedCharacterSheet, {
label: 'Starforged character sheet',
types: ['character'],
})
}
Actors.registerSheet('ironsworn', IronswornCompactCharacterSheet, {
label: 'Compact sheet',
types: ['character'],
Expand Down
72 changes: 72 additions & 0 deletions src/module/actor/sheets/sf-charactersheet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { IronswornSettings } from '../../helpers/settings'
import { IronswornVueActorSheet } from '../vueactorsheet'
// import { CharacterMoveSheet } from './charactermovesheet'

export class StarforgedCharacterSheet extends IronswornVueActorSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ['ironsworn', 'sheet', 'actor', `theme-${IronswornSettings.theme}`],
width: 630,
height: 800,
left: 50,
submitOnClose: true,
submitOnChange: true,
template: 'systems/foundry-ironsworn/templates/actor/sf-character.hbs',
})
}

getData() {
let data: any = super.getData()

// Allow every itemtype to add data to the actorsheet
for (const itemType of CONFIG.IRONSWORN.itemClasses) {
data = itemType.getActorSheetData(data, this)
}

data.actor = this.actor.toObject(false)
data.data = data.actor.data

return data
}

// render(...args) {
// if (this._state <= Application.RENDER_STATES.NONE) this._openMoveSheet()
// return super.render(...args)
// }

// close(...args) {
// this.actor.moveSheet?.close(...args)
// return super.close(...args)
// }

_getHeaderButtons() {
return [
{
class: 'ironsworn-toggle-edit-mode',
label: 'Edit',
icon: 'fas fa-edit',
onclick: (e) => this._toggleEditMode(e),
},
{
class: 'ironsworn-open-move-sheet',
label: 'Moves',
icon: 'fas fa-directions',
onclick: console.log // (e) => this._openMoveSheet(e),
},
...super._getHeaderButtons(),
]
}

_toggleEditMode(_e: JQuery.ClickEvent) {
const currentValue = this.actor.getFlag('foundry-ironsworn', 'edit-mode')
this.actor.setFlag('foundry-ironsworn', 'edit-mode', !currentValue)
}

// _openMoveSheet(_e?: JQuery.ClickEvent) {
// if (this.actor.moveSheet) {
// this.actor.moveSheet.render(true, { focus: true })
// } else {
// new CharacterMoveSheet(this.actor).render(true)
// }
// }
}
2 changes: 1 addition & 1 deletion src/module/features/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const ACTOR_TYPE_HANDLERS: { [key: string]: ActorTypeHandler } = {
}

for (const debility of ['corrupted', 'cursed', 'encumbered', 'maimed', 'shaken', 'tormented', 'unprepared', 'wounded']) {
const newValue = get(data.data.debility, debility)
const newValue = get(data.data?.debility, debility)
if (newValue !== undefined) {
const oldValue = characterData.data.debility[debility]
if (oldValue === newValue) continue
Expand Down
4 changes: 4 additions & 0 deletions src/module/helpers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export class IronswornSettings {
return game.settings.get('foundry-ironsworn', 'theme') as string
}

static get starforgedBeta(): boolean {
return game.settings.get('foundry-ironsworn', 'starforged-beta') as boolean
}

static get logCharacterChanges(): boolean {
return game.settings.get('foundry-ironsworn', 'log-changes') as boolean
}
Expand Down
15 changes: 12 additions & 3 deletions src/module/vue/components/document-img.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img
:src="document.img"
:title="document.name"
class="profile-img"
:style="style"
data-edit="img"
:height="size"
:width="size"
Expand All @@ -14,8 +14,17 @@ export default {
props: {
document: Object,
size: {
type: Number,
default: 50,
type: String,
default: '50px',
},
},
computed: {
style() {
return {
width: this.size,
height: this.size,
}
},
},
}
Expand Down
8 changes: 6 additions & 2 deletions src/module/vue/components/document-name.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<template>
<h1 class="charname">
<component :is="tag" class="charname">
<input
:placeholder="$t('IRONSWORN.Name')"
v-model="document.name"
name="name"
type="text"
/>
</h1>
</component>
</template>

<script>
export default {
props: {
document: Object,
tag: {
type: String,
default: 'h1',
},
},
methods: {
Expand Down
71 changes: 71 additions & 0 deletions src/module/vue/components/sf-characterheader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<header class="sheet-header flexrow">
<document-img :document="actor" size="75px" />

<div class="flexcol" style="flex-basis: 100px">
<input
type="text"
style="margin-bottom: 7px"
:placeholder="$t('IRONSWORN.Name')"
v-model="actor.name"
ref="name"
@blur="save"
/>
<input
type="text"
style="margin-bottom: 7px"
:placeholder="$t('IRONSWORN.Pronouns')"
:value="actor.data.pronouns"
ref="pronouns"
@blur="save"
/>
<input
type="text"
:placeholder="$t('IRONSWORN.Callsign')"
:value="actor.data.callsign"
ref="callsign"
@blur="save"
/>
</div>

<textarea
rows="4"
:value="actor.data.biography"
ref="characteristics"
style="flex-basis: 300px; margin-left: 6px"
:placeholder="$t('IRONSWORN.Characteristics')"
@blur="save"
/>
</header>
</template>

<style lang="less" scoped>
input,
textarea {
border-color: rgba(0, 0, 0, 0.1);
border-radius: 1px;
font-family: var(--font-primary);
resize: none;
}
</style>

<script>
export default {
props: {
actor: Object,
},
methods: {
save() {
this.$actor?.update({
name: this.$refs.name.value,
data: {
callsign: this.$refs.callsign.value,
pronouns: this.$refs.pronouns.value,
biography: this.$refs.characteristics.value,
},
})
},
},
}
</script>
145 changes: 145 additions & 0 deletions src/module/vue/sf-charactersheet.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<template>
<div class="flexcol">
<!-- Header row -->
<sf-characterheader :actor="actor" />

<!-- Main body row -->
<div class="flexrow">
<!-- Momentum on left -->
<div class="flexcol margin-left">
<div class="flexrow" style="flex-wrap: nowrap">
<div class="flexcol stack momentum">
<stack
:actor="actor"
stat="momentum"
:top="10"
:bottom="-6"
:softMax="actor.data.momentumMax"
></stack>
<hr class="nogrow" />
<div class="nogrow">
<div class="clickable block stack-row" @click="burnMomentum">
{{ $t('IRONSWORN.Burn') }}
</div>
</div>

{{ $t('IRONSWORN.Reset') }}: {{ actor.data.momentumReset }}
{{ $t('IRONSWORN.Max') }}: {{ actor.data.momentumMax }}
</div>

<h4 class="vertical-v2">{{ $t('IRONSWORN.Momentum') }}</h4>
</div>
</div>

<!-- Center area -->
<div class="flexcol">
<!-- Attributes -->
<div class="flexrow stats" style="margin-bottom: 10px">
<attr-box :actor="actor" attr="edge"></attr-box>
<attr-box :actor="actor" attr="heart"></attr-box>
<attr-box :actor="actor" attr="iron"></attr-box>
<attr-box :actor="actor" attr="shadow"></attr-box>
<attr-box :actor="actor" attr="wits"></attr-box>
</div>

<!-- Tabs -->
<div class="flexrow nogrow">
<div
class="tab"
v-for="tab in tabs"
:key="tab.titleKey"
:class="['clickable', 'block', { selected: currentTab === tab }]"
@click="currentTab = tab"
>
{{ $t(tab.titleKey) }}
</div>
</div>
<keep-alive>
<component :is="currentTab.component" />
</keep-alive>
</div>

<!-- Stats on right -->
<div class="flexcol margin-right">
<div class="flexrow nogrow" style="flex-wrap: nowrap">
<h4 class="vertical-v2 clickable text" @click="rollStat('health')">
{{ $t('IRONSWORN.Health') }}
</h4>
<div class="flexcol stack health">
<stack :actor="actor" stat="health" :top="5" :bottom="0"></stack>
</div>
</div>

<hr class="nogrow" />

<div class="flexrow nogrow" style="flex-wrap: nowrap">
<h4 class="vertical-v2 clickable text" @click="rollStat('spirit')">
{{ $t('IRONSWORN.Spirit') }}
</h4>
<div class="flexcol stack spirit">
<stack :actor="actor" stat="spirit" :top="5" :bottom="0"></stack>
</div>
</div>

<hr class="nogrow" />

<div class="flexrow nogrow" style="flex-wrap: nowrap">
<h4 class="vertical-v2 clickable text" @click="rollStat('supply')">
{{ $t('IRONSWORN.Supply') }}
</h4>
<div class="flexcol stack supply">
<stack :actor="actor" stat="supply" :top="5" :bottom="0"></stack>
</div>
</div>
</div>
</div>
</div>
</template>

<style lang="less" scoped>
.tab {
text-align: center;
padding: 5px;
border-bottom: 1px solid grey;
&.active {
background-color: darkgray;
}
}
</style>

<script>
export default {
props: {
actor: Object,
},
data() {
const tabs = [
{ titleKey: 'IRONSWORN.Legacies', component: 'sf-legacies' },
{ titleKey: 'IRONSWORN.Bonds', component: 'sf-bonds' },
{ titleKey: 'IRONSWORN.Progress', component: 'sf-progresses' },
{ titleKey: 'IRONSWORN.Clocks', component: 'sf-clocks' },
{ titleKey: 'IRONSWORN.Scenes', component: 'sf-scenes' },
]
return {
tabs,
currentTab: tabs[0],
}
},
methods: {
burnMomentum() {
this.$actor.burnMomentum()
},
rollStat(stat) {
CONFIG.IRONSWORN.RollDialog.show({ actor: this.$actor, stat })
},
openCompendium(name) {
const pack = game.packs?.get(`foundry-ironsworn.${name}`)
pack?.render(true)
},
},
}
</script>
Loading

0 comments on commit b5df640

Please sign in to comment.