mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 13:11:08 +01:00
First bit
This commit is contained in:
parent
c44a7d5403
commit
ddd4672ba3
5 changed files with 99 additions and 3 deletions
10
lang/en.json
10
lang/en.json
|
|
@ -1099,6 +1099,16 @@
|
||||||
"biography": "Biography",
|
"biography": "Biography",
|
||||||
"effects": "Effects"
|
"effects": "Effects"
|
||||||
},
|
},
|
||||||
|
"ContextMenu": {
|
||||||
|
"Equip": "Equip",
|
||||||
|
"Unequip": "Unequip",
|
||||||
|
"Edit": "Edit",
|
||||||
|
"Delete": "Delete",
|
||||||
|
"ToLoadout": "Send to Loadout",
|
||||||
|
"ToVault": "Send to Vault",
|
||||||
|
"Consume": "Consume Item",
|
||||||
|
"SendToChat": "Send To Chat"
|
||||||
|
},
|
||||||
"Armor": {
|
"Armor": {
|
||||||
"Title": "Active Armor"
|
"Title": "Active Armor"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,15 @@ import DaggerheartSheet from './daggerheart-sheet.mjs';
|
||||||
import { abilities } from '../../config/actorConfig.mjs';
|
import { abilities } from '../../config/actorConfig.mjs';
|
||||||
import DhlevelUp from '../levelup.mjs';
|
import DhlevelUp from '../levelup.mjs';
|
||||||
import DhCharacterCreation from '../characterCreation.mjs';
|
import DhCharacterCreation from '../characterCreation.mjs';
|
||||||
|
import DhContextMenu from '../contextMenu.mjs';
|
||||||
|
|
||||||
const { ActorSheetV2 } = foundry.applications.sheets;
|
const { ActorSheetV2 } = foundry.applications.sheets;
|
||||||
const { TextEditor } = foundry.applications.ux;
|
const { TextEditor } = foundry.applications.ux;
|
||||||
export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
super(options);
|
super(options);
|
||||||
|
|
||||||
|
this.contextMenu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
|
|
@ -48,7 +51,8 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
useAdvancementAbility: this.useAdvancementAbility,
|
useAdvancementAbility: this.useAdvancementAbility,
|
||||||
toggleEquipItem: this.toggleEquipItem,
|
toggleEquipItem: this.toggleEquipItem,
|
||||||
levelManagement: this.levelManagement,
|
levelManagement: this.levelManagement,
|
||||||
editImage: this._onEditImage
|
editImage: this._onEditImage,
|
||||||
|
contextMenu: this.createContextMenu
|
||||||
},
|
},
|
||||||
window: {
|
window: {
|
||||||
resizable: true
|
resizable: true
|
||||||
|
|
@ -214,6 +218,78 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
return { primary: primaryTabs, secondary: secondaryTabs };
|
return { primary: primaryTabs, secondary: secondaryTabs };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async createContextMenu(event, baseTarget) {
|
||||||
|
const target = baseTarget.closest('a');
|
||||||
|
const selector = Array.from(target.classList)
|
||||||
|
.map(x => `.${x}`)
|
||||||
|
.join('');
|
||||||
|
|
||||||
|
const getMenuOptions = () => {
|
||||||
|
const allOptions = {
|
||||||
|
equip: {
|
||||||
|
name: 'DAGGERHEART.Sheets.PC.ContextMenu.Equip',
|
||||||
|
icon: '<i class="fa-solid fa-hands"></i>',
|
||||||
|
callback: () => this.constructor.toggleEquipItem.bind(this)(event, target)
|
||||||
|
},
|
||||||
|
unequip: {
|
||||||
|
name: 'DAGGERHEART.Sheets.PC.ContextMenu.Unequip',
|
||||||
|
icon: '<i class="fa-solid fa-hands"></i>',
|
||||||
|
callback: this.constructor.toggleEquipItem.bind(this)
|
||||||
|
},
|
||||||
|
edit: {
|
||||||
|
name: 'DAGGERHEART.Sheets.PC.ContextMenu.Edit',
|
||||||
|
icon: '<i class="fa-solid fa-pen-to-square"></i>',
|
||||||
|
callback: this.constructor.viewObject.bind(this)
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
name: 'DAGGERHEART.Sheets.PC.ContextMenu.Delete',
|
||||||
|
icon: '<i class="fa-solid fa-trash"></i>',
|
||||||
|
callback: this.constructor.deleteItem.bind(this)
|
||||||
|
},
|
||||||
|
sendToLoadout: {
|
||||||
|
name: 'DAGGERHEART.Sheets.PC.ContextMenu.ToLoadout',
|
||||||
|
icon: '<i class="fa-solid fa-plus"></i>',
|
||||||
|
callback: () => {}
|
||||||
|
},
|
||||||
|
sendToVault: {
|
||||||
|
name: 'DAGGERHEART.Sheets.PC.ContextMenu.ToVault',
|
||||||
|
icon: '<i class="fa-solid fa-plus"></i>',
|
||||||
|
callback: () => {}
|
||||||
|
},
|
||||||
|
consumeItem: {
|
||||||
|
name: 'DAGGERHEART.Sheets.PC.ContextMenu.Consume',
|
||||||
|
icon: '<i class="fa-solid fa-plus"></i>',
|
||||||
|
callback: this.constructor.useItem.bind(this)
|
||||||
|
},
|
||||||
|
sendToChat: {
|
||||||
|
name: 'DAGGERHEART.Sheets.PC.ContextMenu.SendToChat',
|
||||||
|
icon: '<i class="fa-solid fa-plus"></i>',
|
||||||
|
callback: () => {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let menuItems = [];
|
||||||
|
switch (target.dataset.type) {
|
||||||
|
case 'weapon':
|
||||||
|
case 'armor':
|
||||||
|
menuItems = [allOptions.equip, allOptions.unequip];
|
||||||
|
break;
|
||||||
|
case 'domainCard':
|
||||||
|
menuItems = [allOptions.sendToLoadout, allOptions.sendToVault];
|
||||||
|
break;
|
||||||
|
case 'consumable':
|
||||||
|
menuItems = [allOptions.consumeItem];
|
||||||
|
}
|
||||||
|
menuItems.push(...[allOptions.edit, allOptions.sendToChat, allOptions.delete]);
|
||||||
|
|
||||||
|
return menuItems;
|
||||||
|
};
|
||||||
|
|
||||||
|
this._createContextMenu(getMenuOptions, selector, { fixed: true, parentClassHooks: false }).render(
|
||||||
|
this.element.querySelector(selector)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
_attachPartListeners(partId, htmlElement, options) {
|
_attachPartListeners(partId, htmlElement, options) {
|
||||||
super._attachPartListeners(partId, htmlElement, options);
|
super._attachPartListeners(partId, htmlElement, options);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ export default class RegisterHandlebarsHelpers {
|
||||||
includes: this.includes,
|
includes: this.includes,
|
||||||
debug: this.debug,
|
debug: this.debug,
|
||||||
signedNumber: this.signedNumber,
|
signedNumber: this.signedNumber,
|
||||||
|
cleanClass: this.cleanClass,
|
||||||
|
tertiary: this.tertiary,
|
||||||
length: this.length,
|
length: this.length,
|
||||||
switch: this.switch,
|
switch: this.switch,
|
||||||
case: this.case,
|
case: this.case,
|
||||||
|
|
@ -137,4 +139,12 @@ export default class RegisterHandlebarsHelpers {
|
||||||
console.log(a);
|
console.log(a);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cleanClass(className) {
|
||||||
|
return className.replaceAll('.', '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
static tertiary(condition, a, b) {
|
||||||
|
return condition ? a : b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<a data-tooltip="{{localize 'DAGGERHEART.Tooltip.sendToChat'}}"><i class="fa-regular fa-message"></i></a>
|
<a data-tooltip="{{localize 'DAGGERHEART.Tooltip.sendToChat'}}"><i class="fa-regular fa-message"></i></a>
|
||||||
<a data-tooltip="{{localize 'DAGGERHEART.Tooltip.moreOptions'}}"><i class="fa-solid fa-ellipsis-vertical"></i></a>
|
<a data-action="contextMenu" class="{{concat type "-" item.uuid "-context-menu"}}" data-tooltip="{{localize 'DAGGERHEART.Tooltip.moreOptions'}}"><i class="fa-solid fa-ellipsis-vertical"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-name">{{item.name}}</div>
|
<div class="card-name">{{item.name}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,6 @@
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<a data-tooltip="{{localize 'DAGGERHEART.Tooltip.sendToChat'}}"><i class="fa-regular fa-message"></i></a>
|
<a data-tooltip="{{localize 'DAGGERHEART.Tooltip.sendToChat'}}"><i class="fa-regular fa-message"></i></a>
|
||||||
<a data-tooltip="{{localize 'DAGGERHEART.Tooltip.moreOptions'}}"><i class="fa-solid fa-ellipsis-vertical"></i></a>
|
<a data-action="contextMenu" class="{{concat (tertiary isSidebar 'sidebar-' '') type '-' (cleanClass item.uuid) '-context-menu'}}" data-type="{{type}}" id="{{item.id}}" data-tooltip="{{localize 'DAGGERHEART.Tooltip.moreOptions'}}"><i class="fa-solid fa-ellipsis-vertical"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue