mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-10 19:17:09 +01:00
FEAT: add filters getters on FilterMenu class
This commit is contained in:
parent
77edc73b2c
commit
0ad4c8d71e
5 changed files with 122 additions and 51 deletions
|
|
@ -571,23 +571,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
content: '.items-section',
|
content: '.items-section',
|
||||||
callback: this._onMenuFilterInventory.bind(this),
|
callback: this._onMenuFilterInventory.bind(this),
|
||||||
target: '.filter-button',
|
target: '.filter-button',
|
||||||
filters: [{
|
filters: FilterMenu.invetoryFilters,
|
||||||
group: "Type",
|
|
||||||
name: "Weapons",
|
|
||||||
filter: {
|
|
||||||
field: "type",
|
|
||||||
operator: foundry.applications.ux.SearchFilter.OPERATORS.EQUALS,
|
|
||||||
value: "weapon",
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
group: "Type",
|
|
||||||
name: "Armor",
|
|
||||||
filter: {
|
|
||||||
field: "type",
|
|
||||||
operator: foundry.applications.ux.SearchFilter.OPERATORS.EQUALS,
|
|
||||||
value: "armor",
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'loadout',
|
key: 'loadout',
|
||||||
|
|
@ -595,7 +579,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
content: '.items-section',
|
content: '.items-section',
|
||||||
callback: this._onMenuFilterLoadout.bind(this),
|
callback: this._onMenuFilterLoadout.bind(this),
|
||||||
target: '.filter-button',
|
target: '.filter-button',
|
||||||
filters: [],
|
filters: FilterMenu.cardsFilters,
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export default class FilterMenu extends foundry.applications.ux.ContextMenu {
|
||||||
await super.render(target, { ...options, animate: false });
|
await super.render(target, { ...options, animate: false });
|
||||||
|
|
||||||
// Create menu structure
|
// Create menu structure
|
||||||
const menu = document.createElement("div");
|
const menu = document.createElement("menu");
|
||||||
menu.className = "filter-menu";
|
menu.className = "filter-menu";
|
||||||
|
|
||||||
// Group items by their group property
|
// Group items by their group property
|
||||||
|
|
@ -158,4 +158,87 @@ export default class FilterMenu extends foundry.applications.ux.ContextMenu {
|
||||||
this.callback(event, this.contentElement, filters);
|
this.callback(event, this.contentElement, filters);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate and return a sorted array of inventory filters.
|
||||||
|
* @returns {Array<Object>} An array of filter objects, sorted by name within each group.
|
||||||
|
*/
|
||||||
|
static get invetoryFilters() {
|
||||||
|
const { OPERATORS } = foundry.applications.ux.SearchFilter;
|
||||||
|
|
||||||
|
const typesFilters = Object.entries(CONFIG.Item.dataModels)
|
||||||
|
.filter(([, { metadata }]) => metadata.isInventoryItem)
|
||||||
|
.map(([type, { metadata }]) => ({
|
||||||
|
group: game.i18n.localize("Type"),
|
||||||
|
name: game.i18n.localize(metadata.label),
|
||||||
|
filter: {
|
||||||
|
field: "type",
|
||||||
|
operator: OPERATORS.EQUALS,
|
||||||
|
value: type
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
const burdenFilter = Object.values(CONFIG.daggerheart.GENERAL.burden).map(({ value, label }) => ({
|
||||||
|
group: game.i18n.localize("DAGGERHEART.Sheets.Weapon.Burden"),
|
||||||
|
name: game.i18n.localize(label),
|
||||||
|
filter: {
|
||||||
|
field: "system.burden",
|
||||||
|
operator: OPERATORS.EQUALS,
|
||||||
|
value: value
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
const damageTypeFilter = Object.values(CONFIG.daggerheart.GENERAL.damageTypes).map(({ id, abbreviation }) => ({
|
||||||
|
group: "Damage Type", //TODO localize
|
||||||
|
name: game.i18n.localize(abbreviation),
|
||||||
|
filter: {
|
||||||
|
field: "system.damage.type",
|
||||||
|
operator: OPERATORS.EQUALS,
|
||||||
|
value: id
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
return [
|
||||||
|
...game.i18n.sortObjects(typesFilters, "name"),
|
||||||
|
...game.i18n.sortObjects(burdenFilter, "name"),
|
||||||
|
...game.i18n.sortObjects(damageTypeFilter, "name"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate and return a sorted array of inventory filters.
|
||||||
|
* @returns {Array<Object>} An array of filter objects, sorted by name within each group.
|
||||||
|
*/
|
||||||
|
static get cardsFilters() {
|
||||||
|
const { OPERATORS } = foundry.applications.ux.SearchFilter;
|
||||||
|
|
||||||
|
const typesFilters = Object.values(CONFIG.daggerheart.DOMAIN.cardTypes)
|
||||||
|
.map(({ id, label }) => ({
|
||||||
|
group: game.i18n.localize("Type"),
|
||||||
|
name: game.i18n.localize(label),
|
||||||
|
filter: {
|
||||||
|
field: "system.type",
|
||||||
|
operator: OPERATORS.EQUALS,
|
||||||
|
value: id
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
const domainFilter = Object.values(CONFIG.daggerheart.DOMAIN.domains).map(({id, label}) => ({
|
||||||
|
group: game.i18n.localize("DAGGERHEART.Sheets.DomainCard.Domain"),
|
||||||
|
name: game.i18n.localize(label),
|
||||||
|
filter: {
|
||||||
|
field: "system.domain",
|
||||||
|
operator: OPERATORS.EQUALS,
|
||||||
|
value: id
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
const sort = (arr) => game.i18n.sortObjects(arr, "name");
|
||||||
|
|
||||||
|
return [
|
||||||
|
...sort(typesFilters),
|
||||||
|
...sort(domainFilter),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -723,7 +723,3 @@ export const actionTypes = {
|
||||||
label: 'DAGGERHEART.ActionType.Reaction'
|
label: 'DAGGERHEART.ActionType.Reaction'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const invetoryFilters = [
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
@ -5208,24 +5208,28 @@ div.daggerheart.views.multiclass {
|
||||||
font-family: 'Montserrat', sans-serif;
|
font-family: 'Montserrat', sans-serif;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: light-dark(#18162e, #f3c267);
|
color: light-dark(#18162e, #f3c267);
|
||||||
|
font-size: var(--font-size-12);
|
||||||
}
|
}
|
||||||
.filter-buttons {
|
.filter-menu fieldset.filter-section .filter-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-evenly;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
}
|
}
|
||||||
.filter-buttons button {
|
.filter-menu fieldset.filter-section .filter-buttons button {
|
||||||
background: light-dark(rgba(0, 0, 0, 0.3), #18162e);
|
background: light-dark(rgba(0, 0, 0, 0.3), #18162e);
|
||||||
color: light-dark(#18162e, #f3c267);
|
color: light-dark(#18162e, #f3c267);
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
border: 1px solid light-dark(#18162e, #18162e);
|
border: 1px solid light-dark(#18162e, #18162e);
|
||||||
|
padding: 0 0.2rem;
|
||||||
|
font-size: var(--font-size-12);
|
||||||
}
|
}
|
||||||
.filter-buttons button:hover {
|
.filter-menu fieldset.filter-section .filter-buttons button:hover {
|
||||||
background: light-dark(transparent, #f3c267);
|
background: light-dark(transparent, #f3c267);
|
||||||
color: light-dark(#18162e, #18162e);
|
color: light-dark(#18162e, #18162e);
|
||||||
}
|
}
|
||||||
.filter-buttons button.active {
|
.filter-menu fieldset.filter-section .filter-buttons button.active {
|
||||||
animation: glow 0.75s infinite alternate;
|
animation: glow 0.75s infinite alternate;
|
||||||
}
|
}
|
||||||
.daggerheart {
|
.daggerheart {
|
||||||
|
|
|
||||||
|
|
@ -15,29 +15,33 @@
|
||||||
font-family: @font-body;
|
font-family: @font-body;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: light-dark(@dark-blue, @golden);
|
color: light-dark(@dark-blue, @golden);
|
||||||
}
|
font-size: var(--font-size-12);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
.filter-buttons {
|
||||||
.filter-buttons {
|
display: flex;
|
||||||
display: flex;
|
flex-wrap: wrap;
|
||||||
flex-wrap: wrap;
|
justify-content: space-evenly;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
background: light-dark(@light-black, @dark-blue);
|
background: light-dark(@light-black, @dark-blue);
|
||||||
color: light-dark(@dark-blue, @golden);
|
color: light-dark(@dark-blue, @golden);
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
border: 1px solid light-dark(@dark-blue, @dark-blue);
|
border: 1px solid light-dark(@dark-blue, @dark-blue);
|
||||||
|
padding: 0 0.2rem;
|
||||||
&:hover {
|
font-size: var(--font-size-12);
|
||||||
background: light-dark(transparent, @golden);
|
|
||||||
color: light-dark(@dark-blue, @dark-blue);
|
&:hover {
|
||||||
}
|
background: light-dark(transparent, @golden);
|
||||||
|
color: light-dark(@dark-blue, @dark-blue);
|
||||||
&.active {
|
}
|
||||||
animation: glow 0.75s infinite alternate;
|
|
||||||
|
&.active {
|
||||||
|
animation: glow 0.75s infinite alternate;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue