Skip to content

Commit

Permalink
Fix some inconsistencies and remove unused styles
Browse files Browse the repository at this point in the history
  • Loading branch information
juanferrer committed Jan 10, 2024
1 parent 6cb9645 commit 8838974
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/module/data/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function characteristics() {
export function action() {
return new foundry.data.fields.SchemaField({
active: makeBoolField(true),
attribute: makeStringField(),
attack: makeStringField(),
against: makeStringField(),
damageactive: makeBoolField(true),
damage: makeStringField(),
Expand Down
3 changes: 1 addition & 2 deletions src/module/data/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export const makeIntField = (init = 0, max = 20, min = 0) => new foundry.data.fi
initial: init,
min: min,
max: max,
integer: true,
clean: true
integer: true
})

export const makeStringField = (init = '', blank = true) => new foundry.data.fields.StringField({
Expand Down
9 changes: 9 additions & 0 deletions src/module/item/sheets/role-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export default class DLRoleSheet extends DLBaseItemSheet {
// Nested item transfer checkbox
html.find('.dl-item-transfer').click(async ev => await this._transferItem(ev))

html.find('.dl-stat-toggle').click(async ev => await this._toggleStat(ev))

// Set immune on rollable attribute
html.find('.attribute .name').contextmenu(async ev => {
const div = $(ev.currentTarget)
Expand Down Expand Up @@ -164,6 +166,13 @@ export default class DLRoleSheet extends DLBaseItemSheet {
await deleteActorNestedItems(actor, null, itemId)
}

async _toggleStat(ev) {
let path = $(ev.currentTarget).closest('[data-toggle-name').data('toggleName').trim()
const currentValue = $(ev.currentTarget).hasClass('checked')

await this.document.update({[path]: !currentValue})
}


/** @override */
async _onNestedItemEdit(ev) {
Expand Down
8 changes: 7 additions & 1 deletion src/styles/newrules/generic-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
min-width: 24px;
color: black !important;

&[type='text'] {
&[type='text']:not(.editable-stat-input) {
width: fit-content !important;
}

Expand Down Expand Up @@ -392,6 +392,12 @@
height: 14px;
padding: 0;

.editable-stat & {
/* Parent is editable-stat */
margin-left: 3px;
top: -2px;
}

&.checked {
background: rgba(105, 105, 105, 0.61);
}
Expand Down
22 changes: 8 additions & 14 deletions src/styles/newrules/item-sheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@
flex-direction: row;
align-items: center;
justify-content: space-between;

& > div:last-child {
display: flex;
align-items: center;
gap: 4px;
}
}

&.dl-column-flex {
Expand Down Expand Up @@ -263,15 +257,15 @@
}

& > .dl-item-row-header {
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-gap: 16px;
}
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-gap: 16px;
}

margin: 4px 0;
padding: 0 16px;
font-family: $font-primary;
font-size: $f-size-big-slight;
margin: 4px 0;
padding: 0 16px;
font-family: $font-primary;
font-size: $f-size-big-slight;
}

a.create-nested-item {
Expand Down
19 changes: 6 additions & 13 deletions src/templates/item/item-ancestry-edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,31 @@
<span class="sep"></span>
<span style="width: 64px; text-align: center; text-overflow: ellipsis">{{localize "DL.AttributeStrength"}}</span>
<span class="sep"></span>
<input type="number" name="system.attributes.strength.value" value="{{system.attributes.strength.value}}"
placeholder="0" autosize/>
<input class="editable-stat-input" type="{{ifThen system.attributes.strength.immune "text" "Number"}}" name="system.attributes.strength.value" value="{{ifThen system.attributes.strength.immune "-" system.attributes.strength.value}}" {{disabled system.attributes.strength.immune}} placeholder="0" autosize/>
</div>

<div class="dl-new-project-2 editable-stat" data-tippy-content="{{localize "DL.AttributeAgility"}}" data-stat-type="attributes" data-stat-name="agility">
<i class="dl-icon-agility"></i>
<span class="sep"></span>
<span style="width: 64px; text-align: center; text-overflow: ellipsis">{{localize "DL.AttributeAgility"}}</span>
<span class="sep"></span>
<input type="number" name="system.attributes.agility.value" value="{{system.attributes.agility.value}}"
placeholder="0"
autosize/>
<input class="editable-stat-input" type="{{ifThen system.attributes.agility.immune "text" "Number"}}" name="system.attributes.agility.value" value="{{ifThen system.attributes.agility.immune "-" system.attributes.agility.value}}" {{disabled system.attributes.agility.immune}} placeholder="0" autosize/>
</div>

<div class="dl-new-project-2 editable-stat" data-tippy-content="{{localize "DL.AttributeIntellect"}}" data-stat-type="attributes" data-stat-name="intellect">
<i class="dl-icon-intellect"></i>
<span class="sep"></span>
<span style="width: 64px; text-align: center; text-overflow: ellipsis">{{localize "DL.AttributeIntellect"}}</span>
<span class="sep"></span>
<input type="number" name="system.attributes.intellect.value" value="{{system.attributes.intellect.value}}"
placeholder="0" autosize/>
<input class="editable-stat-input" type="{{ifThen system.attributes.intellect.immune "text" "Number"}}" name="system.attributes.intellect.value" value="{{ifThen system.attributes.intellect.immune "-" system.attributes.intellect.value}}" {{disabled system.attributes.intellect.immune}} placeholder="0" autosize/>
</div>

<div class="dl-new-project-2 editable-stat" data-tippy-content="{{localize "DL.AttributeWill"}}" data-stat-type="attributes" data-stat-name="will">
<i class="dl-icon-will"></i>
<span class="sep"></span>
<span style="width: 64px; text-align: center; text-overflow: ellipsis">{{localize "DL.AttributeWill"}}</span>
<span class="sep"></span>
<input type="number" name="system.attributes.will.value" value="{{system.attributes.will.value}}" placeholder="0"
autosize/>
<input class="editable-stat-input" type="{{ifThen system.attributes.will.immune "text" "Number"}}" name="system.attributes.will.value" value="{{ifThen system.attributes.will.immune "-" system.attributes.will.value}}" {{disabled system.attributes.will.immune}} placeholder="0"/>
</div>
</div>
</div>
Expand Down Expand Up @@ -123,17 +118,15 @@
<span class="sep"></span>
<span>{{localize "DL.CharInsanity"}}</span>
<span class="sep"></span>
<input type="number" name="system.characteristics.insanity.value" value="{{system.characteristics.insanity.value}}"
placeholder="0"/>
<input class="editable-stat-input" type="{{ifThen system.characteristics.insanity.immune "text" "Number"}}" name="system.characteristics.insanity.value" value="{{ifThen system.characteristics.insanity.immune "-" system.characteristics.insanity.value}}" {{disabled system.characteristics.insanity.immune}} placeholder="0"/>
</div>

<div class="dl-new-project-2 editable-stat" data-tippy-content="{{localize "DL.CharCorruption"}}" data-stat-type="characteristics" data-stat-name="corruption">
<i class="dl-icon-corruption"></i>
<span class="sep"></span>
<span>{{localize "DL.CharCorruption"}}</span>
<span class="sep"></span>
<input type="number" name="system.characteristics.corruption.value" value="{{system.characteristics.corruption.value}}"
placeholder="0"/>
<input class="editable-stat-input" type="{{ifThen system.characteristics.corruption.immune "text" "Number"}}" name="system.characteristics.corruption.value" value="{{ifThen system.characteristics.corruption.immune "-" system.characteristics.corruption.value}}" {{disabled system.characteristics.corruption.immune}} placeholder="0"/>
</div>
</div>

Expand Down
10 changes: 5 additions & 5 deletions src/templates/item/item-ancestry-view.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<span class="sep"></span>
<span style="width: 64px; text-align: center; text-overflow: ellipsis">{{localize loc}}</span>
<span class="sep"></span>
<span style="width: {{defaultValue width "16px"}};text-align: center;margin-left: 4px;">{{value}}</span>
<span style="width: {{defaultValue width "16px"}};text-align: center;margin-left: 4px;">{{ifThen immune '-' value}}</span>
</div>
{{/inline}}

Expand Down Expand Up @@ -51,10 +51,10 @@
<b>{{localize "DL.AncestryStartingAttributes"}}</b>
</div>
<div class="dl-column-flex">
{{> dlAttributeField attribute="strength" value=system.attributes.strength.value loc="DL.AttributeStrength"}}
{{> dlAttributeField attribute="agility" value=system.attributes.agility.value loc="DL.AttributeAgility"}}
{{> dlAttributeField attribute="intellect" value=system.attributes.intellect.value loc="DL.AttributeIntellect"}}
{{> dlAttributeField attribute="will" value=system.attributes.will.value loc="DL.AttributeWill"}}
{{> dlAttributeField attribute="strength" value=system.attributes.strength.value immune=system.attributes.strength.immune loc="DL.AttributeStrength"}}
{{> dlAttributeField attribute="agility" value=system.attributes.agility.value immune=system.attributes.agility.immune loc="DL.AttributeAgility"}}
{{> dlAttributeField attribute="intellect" value=system.attributes.intellect.value immune=system.attributes.intellect.immune loc="DL.AttributeIntellect"}}
{{> dlAttributeField attribute="will" value=system.attributes.will.value immune=system.attributes.will.immune loc="DL.AttributeWill"}}
</div>
</div>
<hr>
Expand Down
18 changes: 10 additions & 8 deletions src/templates/item/item-role-edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<span class="sep"></span>
<span class="name" data-key="strength" style="width: 64px; text-align: center; text-overflow: ellipsis">{{localize "DL.AttributeStrength"}}</span>
<span class="sep"></span>
<input type="{{ifThen system.attributes.strengthImmune "text" "Number"}}" name="system.attributes.strength" value="{{ifThen system.attributes.strengthImmune "-" system.attributes.strength}}" {{disabled system.attributes.strengthImmune}}
<input class="editable-stat-input" type="{{ifThen system.attributes.strengthImmune "text" "Number"}}" name="system.attributes.strength" value="{{ifThen system.attributes.strengthImmune "-" system.attributes.strength}}" {{disabled system.attributes.strengthImmune}}
placeholder="0" autosize />
</div>

Expand All @@ -25,7 +25,7 @@
<span class="sep"></span>
<span class="name" data-key="agility" style="width: 64px; text-align: center; text-overflow: ellipsis">{{localize "DL.AttributeAgility"}}</span>
<span class="sep"></span>
<input type="{{ifThen system.attributes.agilityImmune "text" "Number"}}" name="system.attributes.agility" value="{{ifThen system.attributes.agilityImmune "-" system.attributes.agility}}" {{disabled system.attributes.agilityImmune}}
<input class="editable-stat-input" type="{{ifThen system.attributes.agilityImmune "text" "Number"}}" name="system.attributes.agility" value="{{ifThen system.attributes.agilityImmune "-" system.attributes.agility}}" {{disabled system.attributes.agilityImmune}}
placeholder="0" autosize />
</div>

Expand All @@ -34,7 +34,7 @@
<span class="sep"></span>
<span class="name" data-key="intellect" style="width: 64px; text-align: center; text-overflow: ellipsis">{{localize "DL.AttributeIntellect"}}</span>
<span class="sep"></span>
<input type="{{ifThen system.attributes.intellectImmune "text" "Number"}}" name="system.attributes.intellect" value="{{ifThen system.attributes.intellectImmune "-" system.attributes.intellect}}" {{disabled system.attributes.intellectImmune}}
<input class="editable-stat-input" type="{{ifThen system.attributes.intellectImmune "text" "Number"}}" name="system.attributes.intellect" value="{{ifThen system.attributes.intellectImmune "-" system.attributes.intellect}}" {{disabled system.attributes.intellectImmune}}
placeholder="0" autosize />
</div>

Expand All @@ -43,7 +43,7 @@
<span class="sep"></span>
<span class="name" data-key="will" style="width: 64px; text-align: center; text-overflow: ellipsis">{{localize "DL.AttributeWill"}}</span>
<span class="sep"></span>
<input type="{{ifThen system.attributes.willImmune "text" "Number"}}" name="system.attributes.will" value="{{ifThen system.attributes.willImmune "-" system.attributes.will}}" {{disabled system.attributes.willImmune}}
<input class="editable-stat-input" type="{{ifThen system.attributes.willImmune "text" "Number"}}" name="system.attributes.will" value="{{ifThen system.attributes.willImmune "-" system.attributes.will}}" {{disabled system.attributes.willImmune}}
placeholder="0" autosize />
</div>
</div>
Expand Down Expand Up @@ -148,19 +148,21 @@
<input type="number" name="system.difficulty" value="{{system.difficulty}}"
placeholder="0" />
</div>
<div class="dl-new-project-2 nohover">
<div class="dl-new-project-2 editable-stat nohover">
<i class="dl-icon-frightening"></i>
<span class="sep"></span>
<span>{{localize "DL.CreatureFrightening"}}</span>
<span class="sep"></span>
<input type="checkbox" name="system.frightening" {{checked system.frightening}} />
{{!-- <input type="checkbox" name="system.frightening" {{checked system.frightening}} /> --}}
<div class="dl-custom-checkbox dl-stat-toggle {{checked system.frightening}}" data-toggle-name="system.frightening"></div>
</div>
<div class="dl-new-project-2 nohover">
<div class="dl-new-project-2 editable-stat nohover">
<i class="dl-icon-horrifying"></i>
<span class="sep"></span>
<span>{{localize "DL.CreatureHorrifying"}}</span>
<span class="sep"></span>
<input type="checkbox" name="system.horrifying" {{checked system.horrifying}} />
{{!-- <input type="checkbox" name="system.horrifying" {{checked system.horrifying}} /> --}}
<div class="dl-custom-checkbox dl-stat-toggle {{checked system.horrifying}}" data-toggle-name="system.horrifying"></div>
</div>
</div>

Expand Down

0 comments on commit 8838974

Please sign in to comment.