Merge branch '12-resource-attr' into 'master'

12: Add resource attribute type

Closes #12

See merge request foundrynet/worldbuilding!7
This commit is contained in:
Andrew 2020-08-24 19:33:19 +00:00
commit d3f030b4f7
7 changed files with 77 additions and 5 deletions

View file

@ -5,5 +5,9 @@
"SETTINGS.SimpleInitFormulaL": "Enter an initiative formula, such as d20+@dex", "SETTINGS.SimpleInitFormulaL": "Enter an initiative formula, such as d20+@dex",
"SIMPLE.NotifyInitFormulaUpdated": "Initiative formula was updated to:", "SIMPLE.NotifyInitFormulaUpdated": "Initiative formula was updated to:",
"SIMPLE.NotifyInitFormulaInvalid": "Initiative formula was invalid:" "SIMPLE.NotifyInitFormulaInvalid": "Initiative formula was invalid:",
"SIMPLE.ResourceMin": "Min",
"SIMPLE.ResourceValue": "Value",
"SIMPLE.ResourceMax": "Max"
} }

View file

@ -21,9 +21,10 @@ export class SimpleActorSheet extends ActorSheet {
/** @override */ /** @override */
getData() { getData() {
const data = super.getData(); const data = super.getData();
data.dtypes = ["String", "Number", "Boolean", "Formula"]; data.dtypes = ["String", "Number", "Boolean", "Formula", "Resource"];
for ( let attr of Object.values(data.data.attributes) ) { for ( let attr of Object.values(data.data.attributes) ) {
attr.isCheckbox = attr.dtype === "Boolean"; attr.isCheckbox = attr.dtype === "Boolean";
attr.isResource = attr.dtype === "Resource";
} }
data.shorthand = !!game.settings.get("worldbuilding", "macroShorthand"); data.shorthand = !!game.settings.get("worldbuilding", "macroShorthand");
return data; return data;

View file

@ -20,9 +20,10 @@ export class SimpleItemSheet extends ItemSheet {
/** @override */ /** @override */
getData() { getData() {
const data = super.getData(); const data = super.getData();
data.dtypes = ["String", "Number", "Boolean", "Formula"]; data.dtypes = ["String", "Number", "Boolean", "Formula", "Resource"];
for ( let attr of Object.values(data.data.attributes) ) { for ( let attr of Object.values(data.data.attributes) ) {
attr.isCheckbox = attr.dtype === "Boolean"; attr.isCheckbox = attr.dtype === "Boolean";
attr.isResource = attr.dtype === "Resource";
} }
return data; return data;
} }

View file

@ -144,6 +144,17 @@
line-height: 28px; line-height: 28px;
border: none; border: none;
} }
.worldbuilding .attributes-list .attribute-col label {
font-size: 10px;
text-align: center;
line-height: 1;
}
.worldbuilding .attributes-list .attribute-col input {
font-size: 11px;
text-align: center;
line-height: 1;
height: 50%;
}
.worldbuilding.sheet.actor { .worldbuilding.sheet.actor {
min-width: 560px; min-width: 560px;
min-height: 420px; min-height: 420px;

View file

@ -164,6 +164,21 @@
line-height: 28px; line-height: 28px;
border: none; border: none;
} }
.attribute-col {
label {
font-size: 10px;
text-align: center;
line-height: 1;
}
input {
font-size: 11px;
text-align: center;
line-height: 1;
height: 50%;
}
}
} }
} }

View file

@ -77,10 +77,30 @@
{{#each data.attributes as |attr key|}} {{#each data.attributes as |attr key|}}
<li class="attribute flexrow" data-attribute="{{key}}"> <li class="attribute flexrow" data-attribute="{{key}}">
<input class="attribute-key" type="text" name="data.attributes.{{key}}.key" value="{{key}}"/> <input class="attribute-key" type="text" name="data.attributes.{{key}}.key" value="{{key}}"/>
{{!-- Handle booleans. --}}
{{#if attr.isCheckbox}} {{#if attr.isCheckbox}}
<label class="attribute-value checkbox"><input type="checkbox" name="data.attributes.{{key}}.value" {{checked attr.value}}/></label> <label class="attribute-value checkbox"><input type="checkbox" name="data.attributes.{{key}}.value" {{checked attr.value}}/></label>
{{else}} {{else}}
<input class="attribute-value" type="text" name="data.attributes.{{key}}.value" value="{{attr.value}}" data-dtype="{{attr.dtype}}"/> {{!-- Handle resources. --}}
{{#if attr.isResource}}
<div class="attribute-group flexrow">
<span class="attribute-col flexcol">
<label for="data.attributes.{{key}}.min">{{localize "SIMPLE.ResourceMin"}}</label>
<input class="attribute-value" type="text" name="data.attributes.{{key}}.min" value="{{attr.min}}" data-dtype="{{attr.dtype}}"/>
</span>
<span class="attribute-col flexcol">
<label for="data.attributes.{{key}}.value">{{localize "SIMPLE.ResourceValue"}}</label>
<input class="attribute-value" type="text" name="data.attributes.{{key}}.value" value="{{attr.value}}" data-dtype="{{attr.dtype}}"/>
</span>
<span class="attribute-col flexcol">
<label for="data.attributes.{{key}}.max">{{localize "SIMPLE.ResourceMax"}}</label>
<input class="attribute-value" type="text" name="data.attributes.{{key}}.max" value="{{attr.max}}" data-dtype="{{attr.dtype}}"/>
</span>
</div>
{{!-- Handle other input types. --}}
{{else}}
<input class="attribute-value" type="text" name="data.attributes.{{key}}.value" value="{{attr.value}}" data-dtype="{{attr.dtype}}"/>
{{/if}}
{{/if}} {{/if}}
<input class="attribute-label" type="text" name="data.attributes.{{key}}.label" value="{{attr.label}}"/> <input class="attribute-label" type="text" name="data.attributes.{{key}}.label" value="{{attr.label}}"/>
<select class="attribute-dtype" name="data.attributes.{{key}}.dtype"> <select class="attribute-dtype" name="data.attributes.{{key}}.dtype">

View file

@ -42,10 +42,30 @@
{{#each data.attributes as |attr key|}} {{#each data.attributes as |attr key|}}
<li class="attribute flexrow" data-attribute="{{key}}"> <li class="attribute flexrow" data-attribute="{{key}}">
<input class="attribute-key" type="text" name="data.attributes.{{key}}.key" value="{{key}}"/> <input class="attribute-key" type="text" name="data.attributes.{{key}}.key" value="{{key}}"/>
{{!-- Handle booleans. --}}
{{#if attr.isCheckbox}} {{#if attr.isCheckbox}}
<label class="attribute-value checkbox"><input type="checkbox" name="data.attributes.{{key}}.value" {{checked attr.value}}/></label> <label class="attribute-value checkbox"><input type="checkbox" name="data.attributes.{{key}}.value" {{checked attr.value}}/></label>
{{else}} {{else}}
<input class="attribute-value" type="text" name="data.attributes.{{key}}.value" value="{{attr.value}}" data-dtype="{{attr.dtype}}"/> {{!-- Handle resources. --}}
{{#if attr.isResource}}
<div class="attribute-group flexrow">
<span class="attribute-col flexcol">
<label for="data.attributes.{{key}}.min">Min</label>
<input class="attribute-value" type="text" name="data.attributes.{{key}}.min" value="{{attr.min}}" data-dtype="{{attr.dtype}}"/>
</span>
<span class="attribute-col flexcol">
<label for="data.attributes.{{key}}.value">Current</label>
<input class="attribute-value" type="text" name="data.attributes.{{key}}.value" value="{{attr.value}}" data-dtype="{{attr.dtype}}"/>
</span>
<span class="attribute-col flexcol">
<label for="data.attributes.{{key}}.max">Max</label>
<input class="attribute-value" type="text" name="data.attributes.{{key}}.max" value="{{attr.max}}" data-dtype="{{attr.dtype}}"/>
</span>
</div>
{{!-- Handle other input types. --}}
{{else}}
<input class="attribute-value" type="text" name="data.attributes.{{key}}.value" value="{{attr.value}}" data-dtype="{{attr.dtype}}"/>
{{/if}}
{{/if}} {{/if}}
<input class="attribute-label" type="text" name="data.attributes.{{key}}.label" value="{{attr.label}}"/> <input class="attribute-label" type="text" name="data.attributes.{{key}}.label" value="{{attr.label}}"/>
<select class="attribute-dtype" name="data.attributes.{{key}}.dtype"> <select class="attribute-dtype" name="data.attributes.{{key}}.dtype">