Skip to content

Commit

Permalink
[foundryvtt#729] Add ability for items to be stored within containers
Browse files Browse the repository at this point in the history
  • Loading branch information
arbron committed Jan 26, 2023
1 parent 15fa75b commit a01f360
Show file tree
Hide file tree
Showing 22 changed files with 1,072 additions and 295 deletions.
218 changes: 129 additions & 89 deletions dnd5e.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
/* ----------------------------------------- */
/* Sheet Styles */
/* ----------------------------------------- */
:root {
/* ----------------------------------------- */
/* Encumbrance & Capacity Bars */
/* ----------------------------------------- */
--dnd5e-capacity-container-background-color: #7a7971;
--dnd5e-capacity-container-border-color: #191813;
--dnd5e-capacity-background-color: #6c8aa5;
--dnd5e-capacity-border-color: #cde4ff;
--dnd5e-capacity-text-color: #eeeeee;
}
/* ----------------------------------------- */
/* Flexbox */
/* ----------------------------------------- */
Expand Down Expand Up @@ -1102,95 +1112,6 @@ h5 {
flex: 0 0 20px;
justify-content: flex-end;
}
.dnd5e.sheet.actor .inventory-filters .currency {
flex: 0 0 100%;
list-style: none;
margin: 4px 0 8px;
padding: 0;
font-size: 12px;
}
.dnd5e.sheet.actor .inventory-filters .currency label {
flex: 0;
margin-left: 8px;
text-align: right;
line-height: 20px;
color: #7a7971;
}
.dnd5e.sheet.actor .inventory-filters .currency input[type="text"],
.dnd5e.sheet.actor .inventory-filters .currency input[type="number"] {
flex: 0 0 48px;
text-align: center;
margin-left: 8px;
border-bottom: 2px groove #eeede0;
}
.dnd5e.sheet.actor .inventory-list {
padding: 0 5px;
}
.dnd5e.sheet.actor .inventory-list .item .item-name {
cursor: pointer;
}
.dnd5e.sheet.actor .inventory-list .item .item-name.rollable:hover .item-image {
background-image: url("../../icons/svg/d20-grey.svg") !important;
}
.dnd5e.sheet.actor .inventory-list .item .item-name.rollable .item-image:hover {
background-image: url("../../icons/svg/d20-black.svg") !important;
}
.dnd5e.sheet.actor .inventory-list .item .item-name i.attuned {
color: #7a7971;
}
.dnd5e.sheet.actor .inventory-list .item .item-name i.not-attuned {
color: #44191A;
}
.dnd5e.sheet.actor .inventory-list .item .item-uses input {
width: 24px;
text-align: center;
}
.dnd5e.sheet.actor .inventory-list .item .item-properties {
margin-top: 3px;
}
.dnd5e.sheet.actor .inventory-list .item .item-recharge {
flex: 0 0 80px;
text-align: right;
font-size: 11px;
white-space: nowrap;
}
.dnd5e.sheet.actor .inventory-list .inventory-header .item-controls a.item-create {
flex: 0 0 100%;
}
.dnd5e.sheet.actor .inventory-list .item-detail {
flex: 0 0 70px;
font-size: 12px;
text-align: center;
border-right: 1px solid #c9c7b8;
word-break: break-word;
white-space: nowrap;
overflow: hidden;
}
.dnd5e.sheet.actor .inventory-list .item-detail:last-child {
border-right: none;
}
.dnd5e.sheet.actor .inventory-list .item-detail.item-action {
flex: 0 0 100px;
}
.dnd5e.sheet.actor .inventory-list .item-detail.attunement {
flex: 0 0 24px;
}
.dnd5e.sheet.actor .inventory-list .item-weight {
flex: 0 0 60px;
border-left: 1px solid #c9c7b8;
border-right: 1px solid #c9c7b8;
}
.dnd5e.sheet.actor .inventory-list .item-controls {
flex: 0 0 44px;
}
.dnd5e.sheet.actor .inventory-list .item-summary {
flex: 0 0 100%;
font-size: 12px;
line-height: 16px;
padding: 0.25em 0.5em;
color: #191813;
border-top: 1px solid #c9c7b8;
}
.dnd5e.sheet.actor .encumbrance {
flex: 0 0 12px;
background: #7a7971;
Expand Down Expand Up @@ -1766,6 +1687,125 @@ h5 {
font-size: 0.7rem;
padding: 0.1em 0.5em;
}
.inventory-list {
padding: 0 5px;
}
.inventory-list .item .item-name {
cursor: pointer;
}
.inventory-list .item .item-name.rollable:hover .item-image {
background-image: url("../../icons/svg/d20-grey.svg") !important;
}
.inventory-list .item .item-name.rollable .item-image:hover {
background-image: url("../../icons/svg/d20-black.svg") !important;
}
.inventory-list .item .item-name i.attuned {
color: #7a7971;
}
.inventory-list .item .item-name i.not-attuned {
color: #44191A;
}
.inventory-list .item .item-uses input {
width: 24px;
text-align: center;
}
.inventory-list .item .item-properties {
margin-top: 3px;
}
.inventory-list .item .item-recharge {
flex: 0 0 80px;
text-align: right;
font-size: 11px;
white-space: nowrap;
}
.inventory-list .inventory-header .item-controls a.item-create {
flex: 0 0 100%;
}
.inventory-list .item-detail {
flex: 0 0 70px;
font-size: 12px;
text-align: center;
border-right: 1px solid #c9c7b8;
word-break: break-word;
white-space: nowrap;
overflow: hidden;
}
.inventory-list .item-detail:last-child {
border-right: none;
}
.inventory-list .item-detail.item-action {
flex: 0 0 100px;
}
.inventory-list .item-detail.attunement {
flex: 0 0 24px;
}
.inventory-list .item-weight {
flex: 0 0 60px;
border-left: 1px solid #c9c7b8;
border-right: 1px solid #c9c7b8;
}
.inventory-list .item-controls {
flex: 0 0 44px;
}
.inventory-list .item-summary {
flex: 0 0 100%;
font-size: 12px;
line-height: 16px;
padding: 0.25em 0.5em;
color: #191813;
border-top: 1px solid #c9c7b8;
}
.capacity {
flex: 0 0 12px;
margin-inline-end: 18px;
contain: content;
background: var(--dnd5e-capacity-container-background-color);
border: 1px solid var(--dnd5e-capacity-container-border-color);
border-radius: 3px;
}
.capacity .bar {
height: calc(100% - 2px);
margin: 1px;
background: var(--dnd5e-capacity-background-color);
border: 1px solid var(--dnd5e-capacity-border-color);
border-radius: 2px;
}
.capacity label {
position: absolute;
top: 0;
right: 0;
padding-inline: 5px;
color: var(--dnd5e-capacity-text-color);
font-size: var(--font-size-13);
text-shadow: 0 0 5px #000;
line-height: 0.8em;
}
.inventory .inventory-header {
margin: 0 8px;
flex: 0 0 20px;
justify-content: flex-end;
}
.inventory .currency {
flex: 0 0 100%;
justify-content: flex-end;
margin: 4px 0 8px;
padding: 0;
font-size: var(--font-size-12);
}
.inventory .currency label {
flex: 0;
margin-left: 8px;
text-align: right;
line-height: 20px;
color: #7a7971;
}
.inventory .currency input[type="text"],
.inventory .currency input[type="number"] {
flex: 0 0 48px;
text-align: center;
margin-left: 8px;
border-bottom: 2px groove #eeede0;
}
/* ----------------------------------------- */
/* SRD Compendium */
/* ----------------------------------------- */
Expand Down
8 changes: 8 additions & 0 deletions dnd5e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ Hooks.once("init", function() {
CONFIG.MeasuredTemplate.defaults.angle = 53.13; // 5e cone RAW should be 53.13 degrees
CONFIG.ui.combat = applications.combat.CombatTracker5e;

// Hook up custom item sidebar directory
CONFIG.Item.compendiumIndexFields.push("system.container");
CONFIG.ui.items = dnd5e.applications.item.ItemDirectory5e;

// Register System Settings
registerSystemSettings();

Expand Down Expand Up @@ -235,6 +239,10 @@ Hooks.once("ready", function() {
const rules = game.packs.get("dnd5e.rules");
rules.apps = [new applications.journal.SRDCompendium(rules)];

// Apply custom item compendium
game.packs.filter(p => p.metadata.type === "Item")
.forEach(p => p.apps = [new applications.item.ItemCompendium5e(p)]);

// Wait to register hotbar drop hook on ready so that modules could register earlier if they want to
Hooks.on("hotbarDrop", (bar, data, slot) => {
if ( ["Item", "ActiveEffect"].includes(data.type) ) {
Expand Down
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@
"DND5E.ComponentSomaticAbbr": "S",
"DND5E.ComponentVerbal": "Verbal",
"DND5E.ComponentVerbalAbbr": "V",
"DND5E.Container": "Container",
"DND5E.ContainerRecursiveError": "Containers cannot be moved to contain themselves.",
"DND5E.Contents": "Contents",
"DND5E.ContextMenuActionEdit": "Edit",
"DND5E.ContextMenuActionDuplicate": "Duplicate",
Expand Down
101 changes: 0 additions & 101 deletions less/actors.less
Original file line number Diff line number Diff line change
Expand Up @@ -459,107 +459,6 @@
margin: 0 8px;
flex: 0 0 20px;
justify-content: flex-end;

.currency {
flex: 0 0 100%;
list-style: none;
margin: 4px 0 8px;
padding: 0;
font-size: 12px;

label {
flex: 0;
margin-left: 8px;
text-align: right;
line-height: 20px;
color: @colorTan;
}
input[type="text"], input[type="number"] {
flex: 0 0 48px;
text-align: center;
margin-left: 8px;
border-bottom: @borderGroove;
}
}
}

// Inventory item lists
.inventory-list {
padding: 0 5px;
.item {
.item-name {
cursor: pointer;
&.rollable:hover .item-image {
background-image: url("../../icons/svg/d20-grey.svg") !important;
}
&.rollable .item-image:hover {
background-image: url("../../icons/svg/d20-black.svg") !important;
}
i.attuned { color: @colorTan; }
i.not-attuned { color: @colorCrimson; }
}

// Item uses
.item-uses input {
width: 24px;
text-align: center;
}

// Item Dropdown Properties
.item-properties {
margin-top: 3px;
}

// Charged
.item-recharge {
flex: 0 0 80px;
text-align: right;
font-size: 11px;
white-space: nowrap;
}
}

// Inventory Header
.inventory-header {
.item-controls a.item-create {
flex: 0 0 100%;
}
}

// Item Detail Sections
.item-detail {
flex: 0 0 70px;
font-size: 12px;
text-align: center;
border-right: 1px solid @colorFaint;
word-break: break-word;
white-space: nowrap;
overflow: hidden;
&:last-child { border-right: none; }
&.item-action {flex: 0 0 100px}
&.attunement {flex: 0 0 24px}
}

.item-weight {
flex: 0 0 60px;
border-left: 1px solid @colorFaint;
border-right: 1px solid @colorFaint;
}

// Item Control Buttons
.item-controls {
flex: 0 0 44px;
}

// Item Dropdown Summary
.item-summary {
flex: 0 0 100%;
font-size: 12px;
line-height: 16px;
padding: 0.25em 0.5em;
color: @colorDark;
border-top: 1px solid @colorFaint;
}
}

/* Encumbrance Bar */
Expand Down
1 change: 1 addition & 0 deletions less/dnd5e.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@import "actors.less";
@import "advancement.less";
@import "items.less";
@import "inventory.less";
@import "journal.less";
@import "chat.less";
@import "character.less";
Expand Down
Loading

0 comments on commit a01f360

Please sign in to comment.