Merge branch 'configuration-in-token-config' into 'master'
Add configuration to directly inject the ddv config into the token config See merge request ghost/darkness-dependent-vision!1
This commit is contained in:
commit
8ba05f55f9
13 changed files with 126 additions and 33 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -30,3 +30,5 @@ dist
|
||||||
|
|
||||||
# Junit results
|
# Junit results
|
||||||
junit.xml
|
junit.xml
|
||||||
|
|
||||||
|
foundry.js
|
||||||
|
|
11
src/lang/de.json
Normal file
11
src/lang/de.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"DarknessDependentVision.WarningLackingPermissionToConfigure": "Dir fehlt die Berechtigung diese Figur zu konfigurieren!",
|
||||||
|
"DarknessDependentVision.Title": "Einstellungen zur dunkelheitsabhängigen Sicht",
|
||||||
|
"DarknessDependentVision.TokenConfigHeaderButtonLabel": "DDV",
|
||||||
|
"DarknessDependentVision.DimVisionDarknessRange": "Dämmersicht Dunkelheitsbereich",
|
||||||
|
"DarknessDependentVision.DimVisionDarknessRangeHint": "Du kannst einen Bereich an Dunkelheitswerten angeben, in denen diese Figur Dämmersicht hat.",
|
||||||
|
"DarknessDependentVision.BrightVisionDarknessRange": "Helle Sicht Dunkelheitsbereich",
|
||||||
|
"DarknessDependentVision.BrightVisionDarknessRangeHint": "Du kannst einen Bereich an Dunkelheitswerten angeben, in denen diese Figur helle Sicht hat.",
|
||||||
|
"DarknessDependentVision.ConfigurationViaHeaderButtonName": "Konfiguration per Button in der Titelleiste",
|
||||||
|
"DarknessDependentVision.ConfigurationViaHeaderButtonHint": "Ist diese Einstellung ausgewählt, so erscheint in den Figur Einstellungen ein zusätzlicher Button in der Titelleiste, der ein weiteres Fester öffnet, über das die duneklheitsabhängige Sicht konfiguriert werden kann. Ist sie deaktiviert, so erscheineinen die entsprechenden Eingabefelder direkt im Vision Tab der Figur Einstellungen."
|
||||||
|
}
|
3
src/lang/de.json.license
Normal file
3
src/lang/de.json.license
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
SPDX-FileCopyrightText: 2021 Johannes Loher
|
||||||
|
|
||||||
|
SPDX-License-Identifier: MIT
|
|
@ -5,5 +5,7 @@
|
||||||
"DarknessDependentVision.DimVisionDarknessRange": "Dim Vision Darkness Range",
|
"DarknessDependentVision.DimVisionDarknessRange": "Dim Vision Darkness Range",
|
||||||
"DarknessDependentVision.DimVisionDarknessRangeHint": "You may specify a range of darkness levels during which this token has dim vision.",
|
"DarknessDependentVision.DimVisionDarknessRangeHint": "You may specify a range of darkness levels during which this token has dim vision.",
|
||||||
"DarknessDependentVision.BrightVisionDarknessRange": "Bright Vision Darkness Range",
|
"DarknessDependentVision.BrightVisionDarknessRange": "Bright Vision Darkness Range",
|
||||||
"DarknessDependentVision.BrightVisionDarknessRangeHint": "You may specify a range of darkness levels during which this token has bright vision."
|
"DarknessDependentVision.BrightVisionDarknessRangeHint": "You may specify a range of darkness levels during which this token has bright vision.",
|
||||||
|
"DarknessDependentVision.ConfigurationViaHeaderButtonName": "Configuration via Header Button",
|
||||||
|
"DarknessDependentVision.ConfigurationViaHeaderButtonHint": "If checked, a header button that opens a separate window to configure darkness dependent vision is added to the Token Configuration. If unchecked, the corresponding configuration fields are injected directly into the Vision tab of the Token Configuration."
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
"compatibleCoreVersion": "0.8.8",
|
"compatibleCoreVersion": "0.8.8",
|
||||||
"esmodules": ["module/darkness-dependent-vision.js"],
|
"esmodules": ["module/darkness-dependent-vision.js"],
|
||||||
"languages": [
|
"languages": [
|
||||||
|
{
|
||||||
|
"lang": "de",
|
||||||
|
"name": "Deutsch",
|
||||||
|
"path": "lang/de.json"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"lang": "en",
|
"lang": "en",
|
||||||
"name": "English",
|
"name": "English",
|
||||||
|
|
10
src/module/handlebars-partials.js
Normal file
10
src/module/handlebars-partials.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
export default async function registerHandlebarsPartials() {
|
||||||
|
const templatePaths = [
|
||||||
|
'modules/darkness-dependent-vision/templates/darkness-dependent-vision-config-form-groups.hbs',
|
||||||
|
];
|
||||||
|
await loadTemplates(templatePaths);
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import registerForGetTokenConfigHeaderButtonsHook from './hooks/getTokenConfigHeaderButtons';
|
import registerForGetTokenConfigHeaderButtonsHook from './hooks/getTokenConfigHeaderButtons';
|
||||||
import registerForInitHook from './hooks/init';
|
import registerForInitHook from './hooks/init';
|
||||||
|
import registerForRenderTokenConfigHook from './hooks/renderTokenConfig';
|
||||||
import registerForUpdateSceneHook from './hooks/updateScene';
|
import registerForUpdateSceneHook from './hooks/updateScene';
|
||||||
import registerForUpdateTokenHook from './hooks/updateToken';
|
import registerForUpdateTokenHook from './hooks/updateToken';
|
||||||
|
|
||||||
|
@ -15,4 +16,5 @@ export default function registerForHooks() {
|
||||||
registerForUpdateSceneHook();
|
registerForUpdateSceneHook();
|
||||||
registerForUpdateTokenHook();
|
registerForUpdateTokenHook();
|
||||||
registerForGetTokenConfigHeaderButtonsHook();
|
registerForGetTokenConfigHeaderButtonsHook();
|
||||||
|
registerForRenderTokenConfigHook();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import { packageName } from '../config';
|
||||||
import { DarknessDependentVisionConfig } from '../darkness-dependent-vision-config';
|
import { DarknessDependentVisionConfig } from '../darkness-dependent-vision-config';
|
||||||
|
|
||||||
export default function registerForGetTokenConfigHeaderButtonsHook() {
|
export default function registerForGetTokenConfigHeaderButtonsHook() {
|
||||||
|
@ -13,6 +14,9 @@ export default function registerForGetTokenConfigHeaderButtonsHook() {
|
||||||
* @param {ApplicationHeaderButton[]} buttons
|
* @param {ApplicationHeaderButton[]} buttons
|
||||||
*/
|
*/
|
||||||
function onGetTokenConfigHeaderButtons(tokenConfig, buttons) {
|
function onGetTokenConfigHeaderButtons(tokenConfig, buttons) {
|
||||||
|
if (!game.settings.get(packageName, 'configurationViaHeaderButton')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
buttons.unshift({
|
buttons.unshift({
|
||||||
label: 'DarknessDependentVision.TokenConfigHeaderButtonLabel',
|
label: 'DarknessDependentVision.TokenConfigHeaderButtonLabel',
|
||||||
class: 'configure-darkness-dependent-vision',
|
class: 'configure-darkness-dependent-vision',
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import { packageName } from '../config';
|
import { packageName } from '../config';
|
||||||
|
import registerHandlebarsPartials from '../handlebars-partials';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
|
import registerSettings from '../setiings';
|
||||||
import { libWrapper } from '../shims/libWrapperShim';
|
import { libWrapper } from '../shims/libWrapperShim';
|
||||||
import { getBrightRadius, getDimRadius, updateSource } from '../wrappers/token';
|
import { getBrightRadius, getDimRadius, updateSource } from '../wrappers/token';
|
||||||
|
|
||||||
|
@ -11,7 +13,7 @@ export default function registerForInitHook() {
|
||||||
Hooks.on('init', onInit);
|
Hooks.on('init', onInit);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInit() {
|
async function onInit() {
|
||||||
logger.info(`Initializing ${packageName}`);
|
logger.info(`Initializing ${packageName}`);
|
||||||
|
|
||||||
const dimRadiusTarget = 'Token.prototype.dimRadius';
|
const dimRadiusTarget = 'Token.prototype.dimRadius';
|
||||||
|
@ -29,4 +31,7 @@ function onInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
libWrapper.register(packageName, 'Token.prototype.updateSource', updateSource, 'WRAPPER');
|
libWrapper.register(packageName, 'Token.prototype.updateSource', updateSource, 'WRAPPER');
|
||||||
|
|
||||||
|
registerSettings();
|
||||||
|
await registerHandlebarsPartials();
|
||||||
}
|
}
|
||||||
|
|
21
src/module/hooks/renderTokenConfig.js
Normal file
21
src/module/hooks/renderTokenConfig.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import { packageName } from '../config';
|
||||||
|
|
||||||
|
export default function registerForRenderTokenConfigHook() {
|
||||||
|
Hooks.on('renderTokenConfig', onRenderTokenConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onRenderTokenConfig(app, html, data) {
|
||||||
|
if (game.settings.get(packageName, 'configurationViaHeaderButton')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const contents = await renderTemplate(
|
||||||
|
'modules/darkness-dependent-vision/templates/darkness-dependent-vision-config-form-groups.hbs',
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
html.find(`div[data-tab="vision"] .form-group input[name="brightSight"]`).parent().after(contents);
|
||||||
|
app.setPosition({ height: 'auto' });
|
||||||
|
}
|
23
src/module/setiings.js
Normal file
23
src/module/setiings.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import { packageName } from './config';
|
||||||
|
|
||||||
|
export default function registerSettings() {
|
||||||
|
game.settings.register(packageName, 'configurationViaHeaderButton', {
|
||||||
|
name: 'DarknessDependentVision.ConfigurationViaHeaderButtonName',
|
||||||
|
hint: 'DarknessDependentVision.ConfigurationViaHeaderButtonHint',
|
||||||
|
scope: 'client',
|
||||||
|
config: true,
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
onChange: () =>
|
||||||
|
Object.values(ui.windows)
|
||||||
|
.filter((w) => w instanceof TokenConfig)
|
||||||
|
.forEach(async (w) => {
|
||||||
|
await w.close();
|
||||||
|
w.render(true);
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
{{!--
|
||||||
|
SPDX-FileCopyrightText: 2021 Johannes Loher
|
||||||
|
//
|
||||||
|
SPDX-License-Identifier: MIT
|
||||||
|
--}}
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>{{ localize 'DarknessDependentVision.DimVisionDarknessRange' }}</label>
|
||||||
|
<div class="form-fields">
|
||||||
|
<label for="flags.darkness-dependent-vision.dimVisionDarknessMin">{{ localize "Between" }}</label>
|
||||||
|
<input type="number" name="flags.darkness-dependent-vision.dimVisionDarknessMin"
|
||||||
|
value="{{object.flags.darkness-dependent-vision.dimVisionDarknessMin}}" min="0" max="1" step="any"
|
||||||
|
placeholder="0" />
|
||||||
|
<label for="flags.darkness-dependent-vision.dimVisionDarknessMax">{{ localize "and" }}</label>
|
||||||
|
<input type="number" name="flags.darkness-dependent-vision.dimVisionDarknessMax"
|
||||||
|
value="{{object.flags.darkness-dependent-vision.dimVisionDarknessMax}}" min="0" max="1" step="any"
|
||||||
|
placeholder="1" />
|
||||||
|
</div>
|
||||||
|
<p class="hint">{{ localize "DarknessDependentVision.DimVisionDarknessRangeHint" }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>{{ localize 'DarknessDependentVision.BrightVisionDarknessRange' }}</label>
|
||||||
|
<div class="form-fields">
|
||||||
|
<label for="flags.darkness-dependent-vision.brightVisionDarknessMin">{{ localize "Between" }}</label>
|
||||||
|
<input type="number" name="flags.darkness-dependent-vision.brightVisionDarknessMin"
|
||||||
|
value="{{object.flags.darkness-dependent-vision.brightVisionDarknessMin}}" min="0" max="1" step="any"
|
||||||
|
placeholder="0" />
|
||||||
|
<label for="flags.darkness-dependent-vision.brightVisionDarknessMax">{{ localize "and" }}</label>
|
||||||
|
<input type="number" name="flags.darkness-dependent-vision.brightVisionDarknessMax"
|
||||||
|
value="{{object.flags.darkness-dependent-vision.brightVisionDarknessMax}}" min="0" max="1" step="any"
|
||||||
|
placeholder="1" />
|
||||||
|
</div>
|
||||||
|
<p class="hint">{{ localize "DarknessDependentVision.BrightVisionDarknessRangeHint" }}</p>
|
||||||
|
</div>
|
|
@ -5,36 +5,6 @@ SPDX-License-Identifier: MIT
|
||||||
--}}
|
--}}
|
||||||
|
|
||||||
<form class="{{cssClasses}}" autocomplete="off">
|
<form class="{{cssClasses}}" autocomplete="off">
|
||||||
|
{{> modules/darkness-dependent-vision/templates/darkness-dependent-vision-config-form-groups.hbs}}
|
||||||
<div class="form-group">
|
|
||||||
<label>{{ localize 'DarknessDependentVision.DimVisionDarknessRange' }}</label>
|
|
||||||
<div class="form-fields">
|
|
||||||
<label for="flags.darkness-dependent-vision.dimVisionDarknessMin">{{ localize "Between" }}</label>
|
|
||||||
<input type="number" name="flags.darkness-dependent-vision.dimVisionDarknessMin"
|
|
||||||
value="{{object.flags.darkness-dependent-vision.dimVisionDarknessMin}}" min="0" max="1" step="any"
|
|
||||||
placeholder="0" />
|
|
||||||
<label for="flags.darkness-dependent-vision.dimVisionDarknessMax">{{ localize "and" }}</label>
|
|
||||||
<input type="number" name="flags.darkness-dependent-vision.dimVisionDarknessMax"
|
|
||||||
value="{{object.flags.darkness-dependent-vision.dimVisionDarknessMax}}" min="0" max="1" step="any"
|
|
||||||
placeholder="1" />
|
|
||||||
</div>
|
|
||||||
<p class="hint">{{ localize "DarknessDependentVision.DimVisionDarknessRangeHint" }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>{{ localize 'DarknessDependentVision.BrightVisionDarknessRange' }}</label>
|
|
||||||
<div class="form-fields">
|
|
||||||
<label for="flags.darkness-dependent-vision.brightVisionDarknessMin">{{ localize "Between" }}</label>
|
|
||||||
<input type="number" name="flags.darkness-dependent-vision.brightVisionDarknessMin"
|
|
||||||
value="{{object.flags.darkness-dependent-vision.brightVisionDarknessMin}}" min="0" max="1" step="any"
|
|
||||||
placeholder="0" />
|
|
||||||
<label for="flags.darkness-dependent-vision.brightVisionDarknessMax">{{ localize "and" }}</label>
|
|
||||||
<input type="number" name="flags.darkness-dependent-vision.brightVisionDarknessMax"
|
|
||||||
value="{{object.flags.darkness-dependent-vision.brightVisionDarknessMax}}" min="0" max="1" step="any"
|
|
||||||
placeholder="1" />
|
|
||||||
</div>
|
|
||||||
<p class="hint">{{ localize "DarknessDependentVision.BrightVisionDarknessRangeHint" }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" name="submit" value="1"><i class="far fa-save"></i> {{localize "TOKEN.Update"}}</button>
|
<button type="submit" name="submit" value="1"><i class="far fa-save"></i> {{localize "TOKEN.Update"}}</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue