Skip to content

Commit

Permalink
complete tabbed sheet updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeffw committed Aug 25, 2024
1 parent dc36f25 commit 58004d4
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 74 deletions.
Binary file added icons/statuses/dd-condition-standing.webp
Binary file not shown.
Binary file added icons/statuses/dd-condition-standing.webp~
Binary file not shown.
35 changes: 19 additions & 16 deletions lib/moustachewax.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,15 @@ export default function () {

Handlebars.registerHelper('getPosture', function (name) {
const postures = GURPS.StatusEffect.getAllPostures()
return postures[name] ?? {} // synthetic "Standing" object
return (
postures[name] ?? {
id: 'standing',
img: 'systems/gurps/icons/statuses/dd-condition-standing.webp',
name: 'GURPS.STATUSStanding',
}
) // synthetic "Standing" object
})


Handlebars.registerHelper('showTheMath', function () {
return game.settings.get(settings.SYSTEM_NAME, settings.SETTING_SHOW_THE_MATH) ? 'checked' : ''
})
Expand All @@ -496,9 +501,9 @@ export default function () {
if (Array.isArray(link)) txt = link.join(',')
return !!txt
? txt
.split(',')
.map((/** @type {string} */ l) => gurpslink(`[PDF:${l}]`))
.join(', ')
.split(',')
.map((/** @type {string} */ l) => gurpslink(`[PDF:${l}]`))
.join(', ')
: ''
})

Expand Down Expand Up @@ -604,17 +609,15 @@ export default function () {
Handlebars.registerHelper('threshold-of', function (thresholds, max, value) {
// return the index of the threshold that the value falls into
let result = null
thresholds.some(
function (
/** @type {{ operator: string; comparison: string; value: number; }} */ threshold,
/** @type {number} */ index
) {
let op = getOperation(threshold.operator)
let comparison = getComparison(threshold.comparison)
let testValue = op(max, threshold.value)
return comparison(value, testValue) ? ((result = index), true) : false
}
)
thresholds.some(function (
/** @type {{ operator: string; comparison: string; value: number; }} */ threshold,
/** @type {number} */ index
) {
let op = getOperation(threshold.operator)
let comparison = getComparison(threshold.comparison)
let testValue = op(max, threshold.value)
return comparison(value, testValue) ? ((result = index), true) : false
})
return result
})

Expand Down
16 changes: 12 additions & 4 deletions module/actor/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,21 +362,29 @@ export class GurpsActorSheet extends ActorSheet {
})
} // end enhanced input

// Handle the "Maneuver" dropdown on the tabbed sheet.
// Handle the Maneuver and Posture dropdowns on the tabbed sheet.
html.find('#condition details').click(ev => {
ev.preventDefault()
const target = $(ev.currentTarget)[0]
target.open = !target.open
})

// Handle the "Maneuver" dropdown on the tabbed sheet.
html.find('#condition details .popup .button').click(ev => {
html.find('#condition details#maneuver .popup .button').click(ev => {
ev.preventDefault()
const details = $(ev.currentTarget).closest('details')
const target = $(ev.currentTarget)[0]
this.actor.replaceManeuver(target.alt)
details.open = !details.open
})

// Handle the "Posture" dropdown on the tabbed sheet.
html.find('#condition details#posture .popup .button').click(ev => {
ev.preventDefault()
const details = $(ev.currentTarget).closest('details')
const target = $(ev.currentTarget)[0]
this.actor.replacePosture(target.alt)
details.open = !details.open
})

// On mouseover any item with the class .tooltip-manager which also has a child (image) of class .tooltippic,
Expand Down Expand Up @@ -1003,7 +1011,7 @@ export class GurpsActorSheet extends ActorSheet {
;['name', 'uses', 'maxuses', 'techlevel', 'notes', 'pageref'].forEach(
a => (obj[a] = html.find(`.${a}`).val())
)
;['count', 'cost', 'weight'].forEach(a => (obj[a] = parseFloat(html.find(`.${a}`).val())))
;['count', 'cost', 'weight'].forEach(a => (obj[a] = parseFloat(html.find(`.${a}`).val())))
let u = html.find('.save') // Should only find in Note (or equipment)
if (!!u && obj.save != null) obj.save = u.is(':checked') // only set 'saved' if it was already defined
let v = html.find('.ignoreImportQty') // Should only find in equipment
Expand Down Expand Up @@ -1650,7 +1658,7 @@ export class GurpsActorTabSheet extends GurpsActorSheet {
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ['gurps', 'sheet', 'actor'],
width: 860,
width: 760,
height: 600,
tabs: [{ navSelector: '.gurps-sheet-tabs', contentSelector: '.sheet-body', initial: 'description' }],
dragDrop: [{ dragSelector: '.item-list .item', dropSelector: null }],
Expand Down
4 changes: 2 additions & 2 deletions module/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ export class GurpsActor extends Actor {
}

_adjustMove(move, threshold, value, reason) {
switch (value) {
switch (value.toString()) {
case MOVE_NONE:
return { move: 0, text: i18n_f('GURPS.moveNone', { reason: reason }) }

Expand Down Expand Up @@ -639,7 +639,7 @@ export class GurpsActor extends Actor {

if (foundry.utils.getProperty(this, PROPERTY_MOVEOVERRIDE_POSTURE)) {
let value = foundry.utils.getProperty(this, PROPERTY_MOVEOVERRIDE_POSTURE)
let reason = i18n(GURPS.StatusEffect.lookup(this.system.conditions.posture).label)
let reason = i18n(GURPS.StatusEffect.lookup(this.system.conditions.posture).name)
adjustment = this._adjustMove(move, threshold, value, reason)
}

Expand Down
2 changes: 1 addition & 1 deletion module/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class GurpsToken extends Token {
}

isPostureEffect(effect) {
return effect.icon && foundry.utils.getProperty(effect, 'flags.gurps.effect.type') === 'posture'
return effect.img && foundry.utils.getProperty(effect, 'flags.gurps.effect.type') === 'posture'
}

async setEffectActive(name, active) {
Expand Down
18 changes: 9 additions & 9 deletions styles/simple.css
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@
}

.gurps.sheet.actor {
min-width: 800px;
min-width: 760px;
min-height: 375px;
font-size: var(--font-size-13);
}
Expand Down Expand Up @@ -1173,11 +1173,11 @@ div#other {
grid-area: stats;
display: grid;
grid-template:
'portrait attributes-tab hp-fp encumbrance'
'portrait qnotes hp-fp encumbrance'
'combat-trackers combat-trackers other other'
'combat-trackers combat-trackers other other';
grid-template-columns: 0fr 1fr 0fr 1fr;
'portrait attributes-tab encumbrance hp-fp'
'portrait qnotes qnotes hp-fp'
'combat-trackers combat-trackers other other'
'combat-trackers combat-trackers other other';
grid-template-columns: 0fr 1fr 1fr 0fr;
grid-gap: var(--sectiongap);
}

Expand Down Expand Up @@ -1728,14 +1728,14 @@ div#other {
grid-template-columns: 1fr min-content;
grid-template-rows: 0fr auto auto 1fr;
grid-template-areas:
'condition condition'
'condition combat-sidebar'
'melee combat-sidebar'
'speed-range-table combat-sidebar'
'ranged combat-sidebar';
}

.sheet-body.tabbed-sheet #combat-sidebar {
grid-row: 1 / 4;
grid-area: combat-sidebar;
}

/* ----- combat sheet additions ----- */
Expand Down Expand Up @@ -2305,4 +2305,4 @@ input.gcs-input:disabled {

#attributes input.gcs-input {
min-width: 2.5em;
}
}
117 changes: 75 additions & 42 deletions templates/actor/sections/conditions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,100 @@
<div class='fieldblock'>

{{#if (ne system.conditions.maneuver 'undefined')}}
<div class='label'>{{i18n 'GURPS.maneuver'}}:</div>
<div class='field details'>
<details>
<summary>
{{#with (getManeuver system.conditions.maneuver) as |maneuver|}}
<img class="button" src='{{maneuver.icon}}' title="{{i18n maneuver.label}}" alt='{{maneuver.name}}' />
{{/with}}
</summary>
<div class="popup square5x4">
{{#each (listAllManeuvers) as |this key|}}
<img class="button" src='{{icon}}' title="{{i18n label}}" alt='{{key}}' />
{{/each}}
{{#if (eq view 'condensed')}}
<div class='label'>{{i18n 'GURPS.maneuver'}}:</div>
<div class='field details'>
<details id='maneuver'>
<summary>
{{#with (getManeuver system.conditions.maneuver) as |maneuver|}}
<img class='button' src='{{maneuver.icon}}' title='{{i18n maneuver.label}}' alt='{{maneuver.name}}' />
{{/with}}
</summary>
<div class='popup square5x4'>
{{#each (listAllManeuvers) as |this key|}}
<img class='button' src='{{icon}}' title='{{i18n label}}' alt='{{key}}' />
{{/each}}
</div>
</details>
</div>
</details>
</div>
{{else}}
<div class='label'>{{i18n 'GURPS.maneuver'}}:</div>
<div class='field' style='border: none;'>
<select
id='maneuver'
name='system.conditions.maneuver'
style='font-size: 90%; max-width: 14em;'
{{disabled (or isEditing (not (inCombat this)))}}
>
<option value='undefined' {{select-if system.conditions.maneuver 'undefined'}}>
{{i18n 'GURPS.none'}}
</option>
{{#each (listAllManeuvers) as |this key|}}
<option value='{{key}}' {{select-if ../system.conditions.maneuver key}}>
{{i18n this.label}}
</option>
{{/each}}
</select>
</div>
{{/if}}
{{/if}}


<div class='label'>{{i18n 'GURPS.modifierPosture'}}:</div>
<div class="'field details">
<details>
<summary>
{{#with (getPosture system.conditions.posture) as |posture|}}
<img class="button" src='{{posture.icon}}' title="{{i18n posture.label}}" alt='{{posture.name}}' />
{{/with}}
</summary>
<div class="popup square5x4">
{{#if (eq view 'condensed')}}
<div class='field details'>
<details id='posture'>
<summary>
{{#with (getPosture system.conditions.posture) as |posture|}}
<img class='button' src='{{posture.img}}' title='{{i18n posture.name}}' alt='{{posture.id}}' />
{{/with}}
</summary>
<div class='popup square5x4'>
<img
class='button'
src='systems/gurps/icons/statuses/dd-condition-standing.webp'
title='{{i18n "GURPS.STATUSStanding"}}'
alt='standing'
/>
{{#each (listAllPostures) as |this key|}}
<img class='button' src='{{img}}' title='{{i18n name}}' alt='{{id}}' />
{{/each}}
</div>
</details>
</div>
{{else}}
<div class='field' style='border: none;'>
<select id='posture' name='system.conditions.posture' style='font-size: 90%;' {{disabled isEditing}}>
<option value='standing' {{select-if system.conditions.posture 'standing'}}>{{i18n 'GURPS.STATUSStanding'}}
</option>
{{#each (listAllPostures) as |this key|}}
<img class="button" src='{{icon}}' title="{{i18n label}}" alt='{{key}}' />
<option value='{{key}}' {{select-if ../system.conditions.posture key}}>
{{i18n this.name}}
</option>
{{/each}}
</details>
</div>
{{!-- <div class='field' style="border: none;">
<select id='posture' name='system.conditions.posture' style='font-size: 90%;' {{disabled isEditing}}>
<option value='standing' {{select-if ../system.conditions.posture 'standing' }}>{{i18n 'GURPS.STATUSStanding'}}
</option>
{{#each (listAllPostures) as |this key|}}
<option value='{{key}}' {{select-if ../system.conditions.posture key}}>
{{i18n this.name}}
</option>
{{/each}}
</select>
</div> --}}
</select>
</div>
{{/if}}

<div class='label' for='move-mode'>{{i18n 'GURPS.moveModeType'}}:</div>
<div class='field' style='border: none'>
<select id='move-mode' style='font-size: 90%; max-width: 14em;' {{disabled (or isEditing (lt (length system.move)
2)) }}>
<select
id='move-mode'
style='font-size: 90%; max-width: 14em;'
{{disabled (or isEditing (lt (length system.move) 2))}}
>
{{#each system.move as |this key|}}
<option value='{{@key}}' {{select-if this.default true}}>{{i18n this.mode this.mode}}</option>
<option value='{{@key}}' {{select-if this.default true}}>{{i18n this.mode this.mode}}</option>
{{/each}}
</select>
{{#if isEditing}}
<button id='edit-move-modes' style='padding-bottom: 1px;'><i class="fas fa-pen"></i></button>
<button id='edit-move-modes' style='padding-bottom: 1px;'><i class='fas fa-pen'></i></button>
{{/if}}
</div>
<div class='label'>{{i18n 'GURPS.conditionsCombatMove'}}:</div>
<div class='field' name='system.conditions.combatmove'><span>{{system.conditions.move}}</span></div>
<div class='label'></div>
<div class='field' style='border: none; display: none;'>
<button id='open-modifier-popup'><i class="fas fa-external-link-alt"></i>{{i18n 'GURPS.activeEffects'}}</button>
<button id='open-modifier-popup'><i class='fas fa-external-link-alt'></i>{{i18n 'GURPS.activeEffects'}}</button>
</div>
</div>
</div>

0 comments on commit 58004d4

Please sign in to comment.