mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 06:26:13 +01:00
Initial version
This commit is contained in:
parent
c1f7866594
commit
b053af21c6
13 changed files with 325 additions and 5 deletions
|
|
@ -343,6 +343,9 @@
|
|||
"requestSpotlight": "Request The Spotlight",
|
||||
"openCountdowns": "Countdowns"
|
||||
},
|
||||
"CompendiumBrowserSettings": {
|
||||
"title": "Compendium Browser Settings"
|
||||
},
|
||||
"ContextMenu": {
|
||||
"disableEffect": "Disable Effect",
|
||||
"enableEffect": "Enable Effect",
|
||||
|
|
@ -2787,6 +2790,7 @@
|
|||
"ItemBrowser": {
|
||||
"title": "Daggerheart Compendium Browser",
|
||||
"hint": "Select a Folder in sidebar to start browsing through the compendium",
|
||||
"browserSettings": "Browser Settings",
|
||||
"searchPlaceholder": "Search...",
|
||||
"columnName": "Name",
|
||||
"tooltipFilters": "Filters",
|
||||
|
|
@ -2943,7 +2947,7 @@
|
|||
"rulesOn": "Rules On",
|
||||
"rulesOff": "Rules Off",
|
||||
"remainingUses": "Uses refresh on {type}",
|
||||
"rightClickExtand": "Right-Click to extand",
|
||||
"rightClickExtend": "Right-Click to extend",
|
||||
"companionPartnerLevelBlock": "The companion needs an assigned partner to level up.",
|
||||
"configureAttribution": "Configure Attribution",
|
||||
"deleteItem": "Delete Item",
|
||||
|
|
|
|||
135
module/applications/dialogs/CompendiumBrowserSettings.mjs
Normal file
135
module/applications/dialogs/CompendiumBrowserSettings.mjs
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class CompendiumBrowserSettings extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.browserSettings = game.settings
|
||||
.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.CompendiumBrowserSettings)
|
||||
.toObject();
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ['daggerheart', 'dialog', 'dh-style', 'views', 'compendium-brower-settings'],
|
||||
window: {
|
||||
icon: 'fa-solid fa-book',
|
||||
title: 'DAGGERHEART.APPLICATIONS.CompendiumBrowserSettings.title'
|
||||
},
|
||||
position: {
|
||||
width: 500,
|
||||
height: 'auto'
|
||||
},
|
||||
actions: {
|
||||
finish: CompendiumBrowserSettings.#finish
|
||||
},
|
||||
form: {
|
||||
handler: this.updateData,
|
||||
submitOnChange: true,
|
||||
submitOnClose: false
|
||||
}
|
||||
};
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: {
|
||||
id: 'main',
|
||||
template: 'systems/daggerheart/templates/dialogs/compendiumBrowserSettingsDialog.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
static #browserPackTypes = ['Actor', 'Item'];
|
||||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
for (const element of htmlElement.querySelectorAll('.source-input')) {
|
||||
element.addEventListener('change', this.toggleSource.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
getPackageName = pack => (pack.metadata.packageType === 'world' ? 'world' : pack.metadata.packageName);
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
||||
const { excludedCompendiumPacks } = this.browserSettings;
|
||||
context.packOptions = game.packs.reduce((acc, pack) => {
|
||||
const { type, name, label, packageType, id } = pack.metadata;
|
||||
if (!CompendiumBrowserSettings.#browserPackTypes.includes(type)) return acc;
|
||||
|
||||
const packageName = this.getPackageName(pack);
|
||||
if (!acc[packageName])
|
||||
acc[packageName] = {
|
||||
label:
|
||||
packageType === 'world'
|
||||
? game.i18n.localize('PACKAGE.Type.world')
|
||||
: (game.modules.get(packageName)?.title ?? game.system.title),
|
||||
types: {}
|
||||
};
|
||||
if (!acc[packageName].types[type])
|
||||
acc[packageName].types[type] = {
|
||||
label: game.i18n.localize(`DOCUMENT.${type}`),
|
||||
checked: true,
|
||||
packs: {}
|
||||
};
|
||||
|
||||
if (id === 'daggerheart.ancestries') {
|
||||
console.log('test');
|
||||
}
|
||||
acc[packageName].types[type].packs[id] = {
|
||||
label: label,
|
||||
checked: !excludedCompendiumPacks[packageName]?.[id]
|
||||
};
|
||||
acc[packageName].types[type].checked &&= acc[packageName].types[type].packs[id].checked;
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static async updateData(_event, _, formData) {
|
||||
const { excludedCompendiumPacks } = foundry.utils.expandObject(formData.object);
|
||||
this.browserSettings.excludedCompendiumPacks = Object.keys(excludedCompendiumPacks).reduce(
|
||||
(acc, packageKey) => {
|
||||
const flattenedPack = foundry.utils.flattenObject(excludedCompendiumPacks[packageKey]);
|
||||
acc[packageKey] = Object.keys(flattenedPack).reduce((acc, key) => {
|
||||
acc[key] = !flattenedPack[key];
|
||||
return acc;
|
||||
}, {});
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
this.render();
|
||||
}
|
||||
|
||||
toggleSource(event) {
|
||||
event.stopPropagation();
|
||||
|
||||
const { excludedCompendiumPacks } = this.browserSettings;
|
||||
const { source, type } = event.target.dataset;
|
||||
|
||||
const allIncluded = !event.target.checked;
|
||||
const packs = game.packs.filter(pack => this.getPackageName(pack) === source && pack.metadata.type === type);
|
||||
for (const pack of packs) {
|
||||
if (!excludedCompendiumPacks[source]) excludedCompendiumPacks[source] = {};
|
||||
|
||||
excludedCompendiumPacks[source][pack.metadata.id] = allIncluded;
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async #finish() {
|
||||
const settings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.CompendiumBrowserSettings);
|
||||
await settings.updateSource(this.browserSettings);
|
||||
await game.settings.set(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.CompendiumBrowserSettings,
|
||||
settings.toObject()
|
||||
);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -16,3 +16,4 @@ export { default as ActionSelectionDialog } from './actionSelectionDialog.mjs';
|
|||
export { default as GroupRollDialog } from './group-roll-dialog.mjs';
|
||||
export { default as TagTeamDialog } from './tagTeamDialog.mjs';
|
||||
export { default as RiskItAllDialog } from './riskItAllDialog.mjs';
|
||||
export { default as CompendiumBrowserSettingsDialog } from './CompendiumBrowserSettings.mjs';
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
selectFolder: this.selectFolder,
|
||||
expandContent: this.expandContent,
|
||||
resetFilters: this.resetFilters,
|
||||
sortList: this.sortList
|
||||
sortList: this.sortList,
|
||||
openSettings: this.openSettings
|
||||
},
|
||||
position: {
|
||||
left: 100,
|
||||
|
|
@ -214,6 +215,10 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
loadItems() {
|
||||
let loadTimeout = this.toggleLoader(true);
|
||||
|
||||
const excludedCompendiumPacks = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.CompendiumBrowserSettings
|
||||
).excludedCompendiumPacks;
|
||||
const promises = [];
|
||||
|
||||
game.packs.forEach(pack => {
|
||||
|
|
@ -227,7 +232,13 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
|
||||
Promise.all(promises).then(async result => {
|
||||
this.items = ItemBrowser.sortBy(
|
||||
result.flatMap(r => r),
|
||||
result
|
||||
.flatMap(r => r)
|
||||
.filter(x => {
|
||||
const pack = game.packs.get(x.pack);
|
||||
const packageName = pack.metadata.packageType === 'world' ? 'world' : pack.metadata.packageName;
|
||||
return !excludedCompendiumPacks[packageName]?.[x.pack];
|
||||
}),
|
||||
'name'
|
||||
);
|
||||
|
||||
|
|
@ -512,6 +523,10 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
itemListContainer.replaceChildren(...newOrder);
|
||||
}
|
||||
|
||||
static async openSettings() {
|
||||
new game.system.api.applications.dialogs.CompendiumBrowserSettingsDialog().render({ force: true });
|
||||
}
|
||||
|
||||
_createDragProcess() {
|
||||
new foundry.applications.ux.DragDrop.implementation({
|
||||
dragSelector: '.item-container',
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ export const gameSettings = {
|
|||
LastMigrationVersion: 'LastMigrationVersion',
|
||||
TagTeamRoll: 'TagTeamRoll',
|
||||
SpotlightRequestQueue: 'SpotlightRequestQueue',
|
||||
CompendiumBrowserSettings: 'CompendiumBrowserSettings'
|
||||
};
|
||||
|
||||
export const actionAutomationChoices = {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ export { default as DhCombatant } from './combatant.mjs';
|
|||
export { default as DhTagTeamRoll } from './tagTeamRoll.mjs';
|
||||
export { default as DhRollTable } from './rollTable.mjs';
|
||||
export { default as RegisteredTriggers } from './registeredTriggers.mjs';
|
||||
export { default as CompendiumBrowserSettings } from './compendiumBrowserSettings.mjs';
|
||||
|
||||
export * as countdowns from './countdowns.mjs';
|
||||
export * as actions from './action/_module.mjs';
|
||||
|
|
|
|||
16
module/data/compendiumBrowserSettings.mjs
Normal file
16
module/data/compendiumBrowserSettings.mjs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
export default class CompendiumBrowserSettings extends foundry.abstract.DataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
return {
|
||||
excludedCompendiumPacks: new fields.TypedObjectField(
|
||||
new fields.TypedObjectField(new fields.BooleanField({ required: true, initial: true }))
|
||||
)
|
||||
// excludedSources: new fields.ArrayField(new fields.StringField({ required: true, nullable: false })),
|
||||
// excludedPacks: new fields.TypedObjectField(new fields.SchemaField({
|
||||
// attributionKeys: new fields.ArrayField(new fields.StringField({ required: true, nullable: false })),
|
||||
// excluded: new fields.BooleanField({ required: true, initial: false }),
|
||||
// })),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import {
|
|||
DhHomebrewSettings,
|
||||
DhVariantRuleSettings
|
||||
} from '../applications/settings/_module.mjs';
|
||||
import { DhTagTeamRoll } from '../data/_module.mjs';
|
||||
import { CompendiumBrowserSettings, DhTagTeamRoll } from '../data/_module.mjs';
|
||||
|
||||
export const registerDHSettings = () => {
|
||||
registerMenuSettings();
|
||||
|
|
@ -142,6 +142,12 @@ const registerNonConfigSettings = () => {
|
|||
config: false,
|
||||
type: DhTagTeamRoll
|
||||
});
|
||||
|
||||
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.CompendiumBrowserSettings, {
|
||||
scope: 'client',
|
||||
config: false,
|
||||
type: CompendiumBrowserSettings
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
95
styles/less/dialog/compendiumBrowserPackDialog/sheet.less
Normal file
95
styles/less/dialog/compendiumBrowserPackDialog/sheet.less
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
.daggerheart.dialog.dh-style.views.compendium-brower-settings {
|
||||
--text-color: beige;
|
||||
|
||||
.compendium-settings-label {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
color: light-dark(@dark-blue, @golden);
|
||||
font-size: var(--font-size-24);
|
||||
font-family: @font-subtitle;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pack-options-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
.pack-option-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
> label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: var(--font-size-16);
|
||||
font-family: @font-subtitle;
|
||||
font-weight: bold;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
flex: 1;
|
||||
height: 2px;
|
||||
background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, @golden 100%);
|
||||
margin-right: 8px;
|
||||
}
|
||||
&::after {
|
||||
content: '';
|
||||
flex: 1;
|
||||
height: 2px;
|
||||
background: linear-gradient(90deg, @golden 0%, rgba(0, 0, 0, 0) 100%);
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.sources-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
color: var(--text-color);
|
||||
|
||||
.source-container {
|
||||
padding: 5px;
|
||||
background: light-dark(@dark-blue-10, @golden-10);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
|
||||
.source-inner-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.source-inner-label-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.packs-container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 4px;
|
||||
padding-left: 24px;
|
||||
|
||||
.pack-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
|
||||
button {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,3 +43,5 @@
|
|||
@import './risk-it-all/sheet.less';
|
||||
|
||||
@import './character-reset/sheet.less';
|
||||
|
||||
@import './compendiumBrowserPackDialog/sheet.less';
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
input[type='checkbox'] {
|
||||
&:indeterminate {
|
||||
&::before {
|
||||
content: '\f0fe';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input[type='checkbox'],
|
||||
input[type='radio'] {
|
||||
height: 20px;
|
||||
|
|
|
|||
35
templates/dialogs/compendiumBrowserSettingsDialog.hbs
Normal file
35
templates/dialogs/compendiumBrowserSettingsDialog.hbs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<div>
|
||||
<label class="compendium-settings-label">{{localize "Enable Compendiums"}}</label>
|
||||
<div class="pack-options-container">
|
||||
{{#each packOptions as |option sourceKey|}}
|
||||
<div class="pack-option-container">
|
||||
<label>{{option.label}}</label>
|
||||
<div class="sources-container">
|
||||
{{#each option.types as |type typeKey|}}
|
||||
<div class="source-container">
|
||||
<div class="source-inner-container">
|
||||
<div class="source-inner-label-container">
|
||||
<input type="checkbox" class="source-input" data-source="{{@../key}}" data-type="{{typeKey}}" {{checked type.checked}} />
|
||||
<label>{{type.label}}</label>
|
||||
</div>
|
||||
<a><i class="fa-solid fa-angle-down"></i></a>
|
||||
</div>
|
||||
|
||||
<div class="packs-container">
|
||||
{{#each type.packs as |pack key|}}
|
||||
<div class="pack-container {{#unless pack.included}}excluded{{/unless}}">
|
||||
<input type="checkbox" name="{{concat "excludedCompendiumPacks." @../../key "." key}}" {{checked pack.checked}} />
|
||||
<label>{{pack.label}}</label>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
<footer>
|
||||
<button data-action="finish">{{localize "Save Settings"}}</button>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
<div class="compendium-sidebar">
|
||||
<button data-action="openSettings"><i class="fa-solid fa-gear"></i> {{localize "DAGGERHEART.UI.ItemBrowser.browserSettings"}}</button>
|
||||
<div class="folder-list">
|
||||
{{#each compendiums}}
|
||||
<div class="{{#if selected}} is-selected{{/if}}" data-action="selectFolder" data-folder-id="{{id}}" {{#if folders.length}}data-tooltip="DAGGERHEART.UI.Tooltip.rightClickExtand" data-tooltip-direction="RIGHT"{{/if}}>{{label}}</div>
|
||||
<div class="{{#if selected}} is-selected{{/if}}" data-action="selectFolder" data-folder-id="{{id}}" {{#if folders.length}}data-tooltip="DAGGERHEART.UI.Tooltip.rightClickExtend" data-tooltip-direction="RIGHT"{{/if}}>{{label}}</div>
|
||||
{{#if folders.length}}
|
||||
<div class="subfolder-list">
|
||||
<div class="wrapper">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue