Skip to content

Commit

Permalink
Merge branch 'new-datasworn' into 1.24.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
ben committed Aug 28, 2024
2 parents d1f67b9 + ec095ca commit 54c1405
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 55 deletions.
77 changes: 34 additions & 43 deletions src/module/features/tours/move-sheet-tour.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,40 @@
import { IronswornSettings } from '../../helpers/settings'
import { OracleTable } from '../../roll-table/oracle-table'
import { IronswornTour } from './ironsworn_tour'

export class MoveSheetTour extends IronswornTour {
constructor(sheet: Application) {
const sheetSel = `.app[data-appid="${sheet?.appId}"]`

const moveCategories = [
'move_category:starforged/adventure',
'move_category:ironsworn/adventure'
]
const moveCategorySelector = moveCategories
.map((id) => `${sheetSel} [data-tourid="move-category-${id}"]`)
.join(',')
const moveLinkSelector = moveCategories
.map(
(id) => `${sheetSel} [data-tourid="move-category-${id}"] .content-link`
)
.join(',')
// If multiple rulesets are enabled, prioritize Ironsworn because those items will be nearer the top
const preferIronsworn =
IronswornSettings.enabledRulesets.includes('classic')

const isMoveUuid =
'Compendium.foundry-ironsworn.ironswornmoves.Item.c8bacc17f73d3103'
const sfMoveUuid =
'Compendium.foundry-ironsworn.starforgedmoves.Item.e6ed148eff82c171'
const moveButtonsSelector = [sfMoveUuid, isMoveUuid]
.map(
(u) =>
`${sheetSel} [data-move-uuid="${u}"] [data-tourid="move-buttons"]`
)
.join(',')
const moveCategory = preferIronsworn
? 'move_category:classic/adventure'
: 'move_category:starforged/adventure'
const moveCategorySelector = `${sheetSel} [data-tourid="move-category-${moveCategory}"]`
const moveLinkSelector = `${sheetSel} [data-tourid="move-category-${moveCategory}"] .content-link`

const oracleCategorySelector = [
'oracle_collection:starforged/core',
'oracle_collection:classic/action_and_theme'
]
.map((dsid) => `${sheetSel} [data-tourid="oracle-${dsid}"]`)
.join(',')
const moveUuid = preferIronsworn
? 'Compendium.foundry-ironsworn.ironswornmoves.Item.c8bacc17f73d3103'
: 'Compendium.foundry-ironsworn.starforgedmoves.Item.e6ed148eff82c171'
const moveButtonsSelector = `${sheetSel} [data-move-uuid="${moveUuid}"] [data-tourid="move-buttons"]`

const oracleRowSelector = [
'oracle_rollable:starforged/core/action',
'oracle_rollable:classic/action_and_theme/action'
]
.map((dsid) => `${sheetSel} [data-tourid="oracle-${dsid}"]`)
.join(',')
const oracleCategory = preferIronsworn
? 'oracle_collection:classic/action_and_theme'
: 'oracle_collection:starforged/core'
const oracleCategorySelector = `${sheetSel} [data-tourid="oracle-${oracleCategory}"]`

const oracleRow = preferIronsworn
? 'oracle_rollable:classic/action_and_theme/action'
: 'oracle_rollable:starforged/core/action'
const oracleRowSelector = `${sheetSel} [data-tourid="oracle-${oracleRow}"]`

const scrollIntoView = async (selector) => {
document.querySelector(selector)?.scrollIntoView()
const el = document.querySelector(selector)
console.log(`Scrolling to ${selector}`, el)
el?.scrollIntoView()
await new Promise((r) => setTimeout(r, 400))
}

Expand All @@ -70,8 +60,7 @@ export class MoveSheetTour extends IronswornTour {
tooltipDirection: 'LEFT',
selector: moveCategorySelector,
async hook() {
CONFIG.IRONSWORN.emitter.emit('highlightMove', isMoveUuid)
CONFIG.IRONSWORN.emitter.emit('highlightMove', sfMoveUuid)
CONFIG.IRONSWORN.emitter.emit('highlightMove', moveUuid)
await new Promise((r) => setTimeout(r, 300))
await scrollIntoView(moveCategorySelector)
}
Expand Down Expand Up @@ -115,11 +104,9 @@ export class MoveSheetTour extends IronswornTour {
async hook() {
CONFIG.IRONSWORN.emitter.emit(
'highlightOracle',
'oracle_rollable:classic/action_and_theme'
)
CONFIG.IRONSWORN.emitter.emit(
'highlightOracle',
'oracle_rollable:starforged/core'
preferIronsworn
? 'oracle_rollable:classic/action_and_theme'
: 'oracle_rollable:starforged/core'
)
await scrollIntoView(oracleCategorySelector)
}
Expand All @@ -140,7 +127,11 @@ export class MoveSheetTour extends IronswornTour {
tooltipDirection: 'LEFT',
async hook() {
await sheet.minimize()
await OracleTable.ask('oracle_rollable:starforged/core/action')
await OracleTable.ask(
preferIronsworn
? 'oracle_rollable:classic/core/action'
: 'oracle_rollable:starforged/core/action'
)
await new Promise((r) => setTimeout(r, 300))
}
},
Expand Down
39 changes: 28 additions & 11 deletions src/module/vue/edit-sector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@
{{ $t('IRONSWORN.Region') }}
<i class="fa fa-circle-question" data-tooltip="IRONSWORN.RegionTip"></i>
</h4>
<label class="nogrow" v-for="option in options">
<input v-model="region" type="radio" :value="option.toLowerCase()" />
{{ $t(`IRONSWORN.REGION.${option}`) }}
</label>

<div v-if="starforged" class="nogrow" :class="$style.grid">
<label class="nogrow" v-for="option in starforgedOptions">
<input v-model="region" type="radio" :value="option.toLowerCase()" />
{{ $t(`IRONSWORN.REGION.${option}`) }}
</label>
</div>

<div v-if="sunderedIsles" class="nogrow" :class="$style.grid">
<label class="nogrow" v-for="option in sunderedIslesOptions">
<input v-model="region" type="radio" :value="option.toLowerCase()" />
{{ $t(`IRONSWORN.REGION.${option}`) }}
</label>
</div>
</div>
</template>

Expand All @@ -17,13 +27,12 @@ import { IronswornSettings } from '../helpers/settings'
const props = defineProps<{ data: { sceneId: string } }>()
const defaultToolbox = IronswornSettings.defaultToolbox
const options: string[] =
defaultToolbox === 'starforged'
? ['Terminus', 'Outlands', 'Expanse']
: defaultToolbox === 'sunderedisles'
? ['Myriads', 'Margins', 'Reaches']
: []
const starforged = IronswornSettings.enabledRulesets.includes('starforged')
const starforgedOptions = ['Terminus', 'Outlands', 'Expanse']
const sunderedIsles =
IronswornSettings.enabledRulesets.includes('sundered_isles')
const sunderedIslesOptions = ['Myriads', 'Margins', 'Reaches']
const scene = game.scenes?.get(props.data.sceneId)
// @ts-expect-error scene.flags isn't in the types
Expand All @@ -34,3 +43,11 @@ watch(region, (newValue) => {
scene?.setFlag('foundry-ironsworn', 'region', newValue)
})
</script>

<style lang="scss" module>
.grid {
margin: 0.25rem 1rem;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
</style>
2 changes: 1 addition & 1 deletion system/templates/first-start.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@


<div class='flexcol' style='margin-top: 1em;'>
<button class='ironsworn__save' style='flex: 1; justify-content: center; width: 100%'>
<button class='clickable block boxgroup box ironsworn__save' style='flex: 1; justify-content: center; width: 100%'>
<i class='fas fa-feather'></i>
{{localize 'Save'}}
</button>
Expand Down

0 comments on commit 54c1405

Please sign in to comment.