Skip to content

Commit b2c6d89

Browse files
committed
Rewrote/updated a lot of inspiration icon works
1 parent 1d278e0 commit b2c6d89

File tree

9 files changed

+162
-50
lines changed

9 files changed

+162
-50
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"build": "webpack",
7+
"build": "webpack --config webpack.config.js",
88
"build:prod": "webpack --mode production --env mode=production",
99
"start:test": "webpack serve --hot",
1010
"start": "webpack --config webpack.config.js"

tweaks/ExtraDamageTypes/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Hooks.once('ready', () => {
1515
});
1616

1717
game.settings.registerMenu(MODULE_ID, DamageTypeListForm.FORM_ID, {
18-
name: 'Config Type List',
18+
name: 'Extra Damage Types',
1919
label: 'Open Type List',
2020
hint: 'Add extra damage types to DnD5e.',
2121
scope: 'world',

tweaks/InspirationIcon/Settings.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { MODULE_ID } from '../constants';
2+
3+
const settings = {
4+
'tweak.inspiration.toggle': {
5+
name: `Toggle Chat Inspiration Module`,
6+
hint: 'Toggle on/off the module',
7+
scope: 'world',
8+
config: true,
9+
type: Boolean,
10+
default: false
11+
},
12+
'tweak.inspiration.badge': {
13+
name: `Toggle Chat Inspiration Badge`,
14+
hint: 'Replace chat icon with badge next to actor name',
15+
scope: 'world',
16+
config: true,
17+
type: Boolean,
18+
default: false
19+
},
20+
'tweak.inspiration.icon': {
21+
name: `Chat Inspiration Icon`,
22+
hint: 'Asset file for inspiration icon not badge',
23+
scope: 'world',
24+
config: true,
25+
type: String,
26+
default: 'systems/dnd5e/icons/spells/heal-sky-3.jpg',
27+
filePicker: true
28+
}
29+
};
30+
31+
/**
32+
* Setup Settings
33+
*/
34+
Hooks.once('init', () => {
35+
Object.entries(settings).forEach(([key, value]) => {
36+
game.settings.register(MODULE_ID, key, value);
37+
});
38+
});
39+
40+
export default class InspirationSettings {
41+
/**
42+
*
43+
* @returns
44+
*/
45+
static getToggle() {
46+
return game.settings.get(MODULE_ID, 'tweak.inspiration.toggle');
47+
}
48+
/**
49+
*
50+
* @returns
51+
*/
52+
static getBadge() {
53+
return game.settings.get(MODULE_ID, 'tweak.inspiration.badge');
54+
}
55+
/**
56+
*
57+
* @returns
58+
*/
59+
static getIcon() {
60+
return game.settings.get(MODULE_ID, 'tweak.inspiration.icon');
61+
}
62+
/**
63+
*
64+
* @returns
65+
*/
66+
static getSettings() {
67+
let set = {};
68+
Object.keys(settings).forEach(key => {
69+
console.log(key);
70+
set[key] = game.settings.get(MODULE_ID, key);
71+
});
72+
return set;
73+
}
74+
/**
75+
*
76+
* @returns
77+
*/
78+
static getSettingsMetaData() {
79+
return settings;
80+
}
81+
/**
82+
*
83+
* @returns
84+
*/
85+
static setSetting(key, value) {
86+
game.settings.set(MODULE_ID, key, value);
87+
}
88+
/**
89+
*
90+
* @returns
91+
*/
92+
static resetSettings() {
93+
Object.entries(settings).forEach(([key, value]) => {
94+
game.settings.set(MODULE_ID, key, value);
95+
});
96+
}
97+
}
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@-webkit-keyframes pulse {
2+
0% {
3+
box-shadow: 0 0 2px #ff6400, inset 0 0 2px #ff6400;
4+
}
5+
50% {
6+
box-shadow: 0 0 8px #ff6400, inset 0 0 8px #ff6400;
7+
}
8+
100% {
9+
box-shadow: 0 0 2px #ff6400, inset 0 0 2px #ff6400;
10+
}
11+
}

tweaks/InspirationIcon/index.js

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
11
import { MODULE_ID } from '../constants';
2-
3-
Hooks.once('init', () => {
4-
game.settings.register(MODULE_ID, 'tweak.inspiration.toggle', {
5-
name: `Toggle Chat Inspiration Icon`,
6-
hint: 'Toggle on/off the icon',
7-
scope: 'world',
8-
config: true,
9-
type: Boolean,
10-
default: false
11-
});
12-
game.settings.register(MODULE_ID, 'tweak.inspiration.icon', {
13-
name: `Chat Inspiration Icon`,
14-
hint: 'asset file for inspiration icon',
15-
scope: 'world',
16-
config: true,
17-
type: String,
18-
default: 'systems/dnd5e/icons/spells/heal-sky-3.jpg',
19-
filePicker: true
20-
});
21-
});
22-
23-
class InspirationSettings {
24-
static getToggle() {
25-
return game.settings.get(MODULE_ID, 'tweak.inspiration.toggle');
26-
}
27-
static getIcon() {
28-
return game.settings.get(MODULE_ID, 'tweak.inspiration.icon');
29-
}
30-
}
2+
import InspirationSettings from './Settings';
313

324
Hooks.on('renderChatMessage', (app, html, data) => {
335
if (InspirationSettings.getToggle()) {
@@ -37,20 +9,36 @@ Hooks.on('renderChatMessage', (app, html, data) => {
379
if (actor) {
3810
const inspiration = actor.data.data.attributes.inspiration;
3911
if (inspiration) {
40-
const img = document.createElement('img');
41-
img.width = 36;
42-
img.height = 36;
43-
img.src = InspirationSettings.getIcon();
44-
img.style.border = 'none';
45-
img.style.flex = 'none';
46-
4712
const chatElement = html[0];
4813
const header = chatElement.querySelector('header');
4914

50-
if (header.children[0] instanceof HTMLImageElement) {
51-
header.insertBefore(img, header.children[1]);
15+
if (InspirationSettings.getBadge()) {
16+
const img = document.createElement('img');
17+
img.width = 16;
18+
img.height = 16;
19+
img.src = `modules/${MODULE_ID}/assets/inspiration-icon.svg`;
20+
img.alt = 'inspiration';
21+
img.title = 'inspiration';
22+
img.style.border = 'none';
23+
img.style.position = 'relative';
24+
img.style.marginLeft = '5px';
25+
img.style.top = '3px';
26+
27+
header.children[0].appendChild(img);
5228
} else {
53-
header.prepend(img);
29+
const img = document.createElement('img');
30+
img.width = 36;
31+
img.height = 36;
32+
img.src = InspirationSettings.getIcon();
33+
img.style.border = 'none';
34+
img.style.flex = 'none';
35+
img.style.margin = '0 3px 5px 0';
36+
37+
if (header.children[0] instanceof HTMLImageElement) {
38+
header.insertBefore(img, header.children[1]);
39+
} else {
40+
header.prepend(img);
41+
}
5442
}
5543
}
5644
}

tweaks/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const MODULE_ID = 'dnd5e-tweaks';
2-
export const MODULE_VERSION = '0.0.1';
2+
export const MODULE_VERSION = '0.0.2';
33
export const TEMPLATE_PATH = `modules/${MODULE_ID}/templates`;

tweaks/module.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
"title": "DnD5e Tweaks",
44
"description": "Multi package of small togglable adjustments to DnD5e Game System.",
55
"author": "AspyMui",
6-
"version": "0.0.1",
7-
"minimumCoreVersion": "0.8.8",
8-
"compatibleCoreVersion": "0.8.4",
6+
"version": "0.0.2",
7+
"minimumCoreVersion": "0.8.4",
8+
"compatibleCoreVersion": "0.8.9",
99
"dependencies": [
1010
{
1111
"name": "dnd5e",
1212
"type": "system"
1313
}
1414
],
15-
"esmodules": ["./main.js"],
16-
"includes": ["./templates/**"],
17-
"styles": ["./style.css"],
15+
"includes": ["./templates/**", "./assets/**", "./styles/**"],
16+
"media": [{ "type": "icon", "location": "" }],
17+
"esmodules": ["main.js"],
18+
"styles": ["styles/inspriation.css"],
1819
"url": "https://github.com/AspyMui/dnd5e-tweaks",
19-
"manifest": "https://github.com/AspyMui/dnd5e-tweaks/releases/download/0.0.1/module.json",
20-
"download": "https://github.com/AspyMui/dnd5e-tweaks/releases/download/0.0.1/module.zip"
20+
"manifest": "https://github.com/AspyMui/dnd5e-tweaks/releases/download/0.0.2/module.json",
21+
"download": "https://github.com/AspyMui/dnd5e-tweaks/releases/download/0.0.2/module.zip"
2122
}

webpack.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ module.exports = {
2323
{
2424
from: './tweaks/**/*.hbs',
2525
to: 'templates/[name][ext]'
26+
},
27+
{
28+
from: './tweaks/**/*.jpg',
29+
from: './tweaks/**/*.png',
30+
from: './tweaks/**/*.svg',
31+
to: 'assets/[name][ext]'
32+
},
33+
{
34+
from: './tweaks/**/*.css',
35+
to: 'styles/[name][ext]'
2636
}
2737
]
2838
})

0 commit comments

Comments
 (0)