Added system keybind for spotlighting a combatant (#1749)

This commit is contained in:
WBHarry 2026-03-26 16:12:05 +01:00 committed by GitHub
parent eb9e47c39d
commit a4adbf8ac4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 64 additions and 1 deletions

View file

@ -7,3 +7,4 @@ export * as documents from './documents/_module.mjs';
export * as enrichers from './enrichers/_module.mjs';
export * as helpers from './helpers/_module.mjs';
export * as systemRegistration from './systemRegistration/_module.mjs';
export * as macros from './macros/_modules.mjs';

View file

@ -1,3 +1,7 @@
export const keybindings = {
spotlight: 'DHSpotlight'
};
export const menu = {
Automation: {
Name: 'GameSettingsAutomation',

View file

@ -0,0 +1 @@
export { default as spotlightCombatant } from './spotlightCombatant.mjs';

View file

@ -0,0 +1,21 @@
/**
* Spotlights a combatant.
* The combatant can be selected in a number of ways. If many are applied at the same time, the following order is used:
* 1) SelectedCombatant
* 2) HoveredCombatant
*/
const spotlightCombatant = () => {
if (!game.combat)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.MACROS.Spotlight.errors.noActiveCombat'));
const selectedCombatant = canvas.tokens.controlled.length > 0 ? canvas.tokens.controlled[0].combatant : null;
const hoveredCombatant = game.canvas.tokens.hover?.combatant;
const combatant = selectedCombatant ?? hoveredCombatant;
if (!combatant)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.MACROS.Spotlight.errors.noCombatantSelected'));
ui.combat.setCombatantSpotlight(combatant.id);
};
export default spotlightCombatant;

View file

@ -18,6 +18,7 @@ import {
import { CompendiumBrowserSettings, DhTagTeamRoll } from '../data/_module.mjs';
export const registerDHSettings = () => {
registerKeyBindings();
registerMenuSettings();
registerMenus();
registerNonConfigSettings();
@ -33,6 +34,25 @@ export const registerDHSettings = () => {
});
};
export const registerKeyBindings = () => {
game.keybindings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.keybindings.spotlight, {
name: game.i18n.localize('DAGGERHEART.SETTINGS.Keybindings.spotlight.name'),
hint: game.i18n.localize('DAGGERHEART.SETTINGS.Keybindings.spotlight.hint'),
uneditable: [],
editable: [
{
key: 's',
modifiers: []
}
],
onDown: game.system.api.macros.spotlightCombatant,
onUp: () => {},
restricted: true,
reservedModifiers: [],
precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL
});
};
const registerMenuSettings = () => {
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules, {
scope: 'world',