2021-06-29 20:40:54 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-07-13 13:59:11 +02:00
|
|
|
import { packageName } from '../config';
|
2021-06-29 20:40:54 +02:00
|
|
|
import { DarknessDependentVisionConfig } from '../darkness-dependent-vision-config';
|
|
|
|
|
|
|
|
export default function registerForGetTokenConfigHeaderButtonsHook() {
|
|
|
|
Hooks.on('getTokenConfigHeaderButtons', onGetTokenConfigHeaderButtons);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {TokenConfig} tokenConfig
|
|
|
|
* @param {ApplicationHeaderButton[]} buttons
|
|
|
|
*/
|
|
|
|
function onGetTokenConfigHeaderButtons(tokenConfig, buttons) {
|
2021-07-13 13:59:11 +02:00
|
|
|
if (!game.settings.get(packageName, 'configurationViaHeaderButton')) {
|
|
|
|
return;
|
|
|
|
}
|
2021-06-29 20:40:54 +02:00
|
|
|
buttons.unshift({
|
|
|
|
label: 'DarknessDependentVision.TokenConfigHeaderButtonLabel',
|
|
|
|
class: 'configure-darkness-dependent-vision',
|
|
|
|
icon: 'fas fa-eye',
|
|
|
|
onclick: async () => {
|
|
|
|
return new DarknessDependentVisionConfig(tokenConfig.object).render(true);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|