Skip to content

Commit 273d274

Browse files
committed
Version bump
- style improvements for filter controls and light application theme - FilterSelector will now manually sort the presets after rank change - Fixed FilterSelector rank sorting failing if two filters share the same rank
1 parent 7c9eb9c commit 273d274

File tree

5 files changed

+61
-24
lines changed

5 files changed

+61
-24
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Token Magic FX - Update v0.7.5
2+
3+
**Filter Editor**
4+
5+
- Slight style changes and improvements when using `Light` applications theme
6+
- Fixed rank sorting failing when two or more filters shared the same rank
7+
- Rank sorting will now take immediate effect upon change
8+
19
# Token Magic FX - Update v0.7.4
210

311
**Filter Editor**

tokenmagic/gui/apps/FilterEditor.js

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class FilterSelector extends HandlebarsApplicationMixin(ApplicationV2) {
106106

107107
/** @override */
108108
static DEFAULT_OPTIONS = {
109-
window: { resizable: true },
109+
window: { resizable: true, contentClasses: ['standard-form'] },
110110
classes: ['tokenmagic', 'selector', 'flexcol'],
111111
actions: {
112112
select: FilterSelector._onEdit,
@@ -134,13 +134,14 @@ class FilterSelector extends HandlebarsApplicationMixin(ApplicationV2) {
134134
};
135135

136136
static getFilter(document, { filterId, filterType, filterInternalId }) {
137-
const filters = document.getFlag('tokenmagic', 'filters');
138-
return filters?.find(
139-
(f) =>
140-
f.tmFilters.tmFilterId === filterId &&
141-
f.tmFilters.tmFilterType === filterType &&
142-
f.tmFilters.tmFilterInternalId === filterInternalId,
143-
)?.tmFilters.tmParams;
137+
return document
138+
.getFlag('tokenmagic', 'filters')
139+
?.find(
140+
(f) =>
141+
f.tmFilters.tmFilterId === filterId &&
142+
f.tmFilters.tmFilterType === filterType &&
143+
f.tmFilters.tmFilterInternalId === filterInternalId,
144+
)?.tmFilters.tmParams;
144145
}
145146

146147
/** @override */
@@ -290,9 +291,29 @@ class FilterSelector extends HandlebarsApplicationMixin(ApplicationV2) {
290291
}
291292

292293
async _onUpdateFilterRank(fromFilter, toFilter) {
293-
const filters = this._document.getFlag('tokenmagic', 'filters');
294+
const filters = deepClone(this._document.getFlag('tokenmagic', 'filters'));
294295
if (!filters || !filters.length) return;
295296

297+
// First make sure there are no duplicate ranks
298+
const paramArray = filters.map((f) => f.tmFilters.tmParams).sort((f1, f2) => f1.rank - f2.rank);
299+
let resort = false;
300+
for (let i = 0; i < paramArray.length - 1; i++) {
301+
if (paramArray[i].rank === paramArray[i + 1].rank) {
302+
resort = true;
303+
break;
304+
}
305+
}
306+
if (resort) {
307+
const updates = [];
308+
const minRank = paramArray[0].rank;
309+
for (let i = 1; i < paramArray.length; i++) {
310+
const { filterId, filterType, filterInternalId } = paramArray[i];
311+
updates.push({ filterId, filterType, filterInternalId, rank: minRank + i });
312+
}
313+
await TokenMagic.updateFiltersByPlaceable(this._document, updates);
314+
}
315+
316+
// Swap filters
296317
const fromParams = FilterSelector.getFilter(this._document, fromFilter);
297318
const toParams = FilterSelector.getFilter(this._document, toFilter);
298319
if (!fromParams || !toParams) return;
@@ -311,6 +332,11 @@ class FilterSelector extends HandlebarsApplicationMixin(ApplicationV2) {
311332
rank: fromParams.rank,
312333
},
313334
]);
335+
336+
// Sort filters based on new ranks
337+
const sprite = this._document.object?._TMFXgetSprite();
338+
if (sprite) sprite.filters = sprite.filters.sort((f1, f2) => f1.rank - f2.rank);
339+
314340
this.render(true);
315341
}
316342

tokenmagic/module.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"id": "tokenmagic",
33
"title": "Token Magic FX",
44
"description": "<p>Add special effects and animations on your tokens, tiles, drawings, templates, and regions</p>",
5-
"version": "0.7.4",
5+
"version": "0.7.5",
66
"manifest": "https://github.com/Feu-Secret/Tokenmagic/releases/latest/download/module.json",
7-
"download": "https://github.com/Feu-Secret/Tokenmagic/releases/download/0.7.4/tokenmagic.zip",
7+
"download": "https://github.com/Feu-Secret/Tokenmagic/releases/download/0.7.5/tokenmagic.zip",
88
"compatibility": {
99
"minimum": "13",
1010
"verified": "13.350"

tokenmagic/styles/tokenmagic.css

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
}
4141

4242
.tokenmagic.application .filter:hover {
43-
background-color: #2c2c2c;
43+
background-color: var(--sidebar-entry-hover-bg);
4444
}
4545

4646
.tokenmagic.application .filter img {
@@ -59,7 +59,7 @@
5959
display: flex;
6060
flex-direction: column;
6161
gap: 3px;
62-
color: white;
62+
color: var(--color-text-primary);
6363
}
6464

6565
.tokenmagic.application .filter .name > * {
@@ -74,14 +74,17 @@
7474

7575
.tokenmagic.application .filter .control {
7676
flex: 0 0 5px;
77+
border-color: darkgray;
7778
}
7879

7980
.tokenmagic.application .filter .control.active {
80-
color: chartreuse;
81+
color: greenyellow;
82+
outline: unset;
83+
box-shadow: unset;
8184
}
8285

8386
.tokenmagic.application .filter .control.delete {
84-
color: red;
87+
color: orangered;
8588
}
8689

8790
.tokenmagic.application .header {
@@ -135,7 +138,7 @@
135138
display: flex;
136139
align-items: center;
137140
justify-content: center;
138-
color: var(--color-light-1);
141+
color: var(--color-text-primary);
139142
}
140143

141144
.tokenmagic.application .header-controls > a[disabled] {
@@ -146,16 +149,16 @@
146149
color: darkorange;
147150
}
148151

149-
/* ====================
150-
* == Preset Toggler ==
151-
* ==================== */
152+
/* ========================
153+
* == Bespoke App Styles ==
154+
* ======================== */
152155

153-
.tokenmagic.toggler .filter .name {
154-
color: var(--color-text-primary);
156+
.tokenmagic.selector .header-controls > a {
157+
color: var(--color-light-1);
155158
}
156159

157-
.tokenmagic.toggler .header-controls a {
158-
color: var(--color-text-primary);
160+
.tokenmagic.selector .filter .name {
161+
color: white;
159162
}
160163

161164
.tokenmagic.toggler .filter.active {

tokenmagic/templates/apps/filter-editor/filter-list.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<span class="subtext">{{subtext}}</span>
99
</a>
1010
{{#each controls}}
11-
<a class="control{{#if class}} {{class}}{{/if}}{{#if active}} active{{/if}}" data-action="{{action}}" data-tooltip="{{tooltip}}"><i class="{{icon}}"></i></a>
11+
<button type="button" class="control{{#if class}} {{class}}{{/if}}{{#if active}} active{{/if}}" data-action="{{action}}" data-tooltip="{{tooltip}}"><i class="{{icon}}"></i></button>
1212
{{/each}}
1313
</li>
1414
{{/each}}

0 commit comments

Comments
 (0)