Added weights and content weight to containers UI

This commit is contained in:
Stefan Zermatten
2021-02-24 14:07:20 +02:00
parent c248d8f4a0
commit 0404020335
5 changed files with 94 additions and 9 deletions

View File

@@ -88,6 +88,9 @@ function getInventoryData(tree, containersToWrite){
data.weightCarried = 0;
data.valueCarried = 0;
}
if (node.contentsWeightless){
data.weightCarried = node.weight;
}
return data
}

View File

@@ -10,7 +10,7 @@ import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
import { recomputeCreatureById } from '/imports/api/creature/computation/methods/recomputeCreature.js';
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
const organizeDoc = new ValidatedMethod({
name: 'organize.organizeDoc',
validate: new SimpleSchema({
@@ -20,7 +20,10 @@ const organizeDoc = new ValidatedMethod({
type: Number,
// Should end in 0.5 to place it reliably between two existing documents
},
skipRecompute: Boolean,
skipRecompute: {
type: Boolean,
optional: true,
},
}).validator(),
mixins: [RateLimiterMixin],
rateLimit: {
@@ -60,6 +63,9 @@ const organizeDoc = new ValidatedMethod({
// The active status of some properties might change due to a change in
// ancestry
recomputeInactiveProperties(id);
if (doc.type === 'container' || doc.type === 'item'){
recomputeInventory(id);
}
// Some Dependencies depend on ancestry, so a full recompute is needed
recomputeCreatureById(id);
});

View File

@@ -15,7 +15,7 @@
</v-list-tile-content>
<v-list-tile-action>
<v-list-tile-title>
{{ creature.denormalizedStats.weightCarried || 0 }} lbs
{{ creature.denormalizedStats.weightCarried || 0 }} lb
</v-list-tile-title>
</v-list-tile-action>
</v-list-tile>

View File

@@ -9,6 +9,31 @@
{{ model.name }}
</v-toolbar-title>
<v-spacer />
<v-toolbar-title>
<v-icon
small
style="width: 16px;"
class="mr-1"
>
$vuetify.icons.weight
</v-icon>
{{ (model.contentsWeight || 0) + (model.weight || 0) }}
</v-toolbar-title>
<v-toolbar-title
class="layout row align-center"
style="flex-grow: 0;"
>
<v-icon
small
style="width: 16px;"
class="mr-1"
>
$vuetify.icons.two_coins
</v-icon>
<coin-value
:value="(model.contentsValue || 0) + (model.value || 0)"
/>
</v-toolbar-title>
</template>
<v-card-text class="px-0">
<item-list
@@ -23,11 +48,13 @@
import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
import ItemList from '/imports/ui/properties/components/inventory/ItemList.vue';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import CoinValue from '/imports/ui/components/CoinValue.vue';
export default {
components: {
ToolbarCard,
ItemList,
CoinValue,
},
props: {
model: {

View File

@@ -3,12 +3,13 @@
<property-tags :tags="model.tags" />
<div class="layout row wrap justify-space-around">
<div
v-if="model.value !== undefined"
class="mr-3 my-3"
>
<v-layout
v-if="model.value !== undefined"
row
align-center
class="mb-2"
>
<v-icon
class="mr-2"
@@ -21,15 +22,34 @@
:value="model.value"
/>
</v-layout>
</div>
<div
v-if="model.weight !== undefined"
class="my-3"
>
<v-layout
row
align-center
>
<v-icon
class="mr-2"
x-large
>
$vuetify.icons.cash
</v-icon>
<coin-value
class="title mr-2"
:value="model.contentsValue"
/>
<span class="title">
contents
</span>
</v-layout>
</div>
<div
class="my-3"
>
<v-layout
v-if="model.weight !== undefined"
row
align-center
justify-end
class="mb-2"
>
<span class="title mr-2">
{{ model.weight }} lb
@@ -41,6 +61,35 @@
$vuetify.icons.weight
</v-icon>
</v-layout>
<v-layout
row
align-center
justify-end
>
<template v-if="model.contentsWeightless">
<span
class="title"
>
contents weightless
</span>
</template>
<template v-else>
<span class="title mr-2">
{{ model.contentsWeight }} lb
</span>
<span
class="title"
>
contents
</span>
</template>
<v-icon
class="ml-2"
x-large
>
$vuetify.icons.injustice
</v-icon>
</v-layout>
</div>
</div>
<property-description