Skip to content

Commit

Permalink
Merge pull request #21 from Feu-Secret/tokenmagic-dev
Browse files Browse the repository at this point in the history
Update v0.2.2b-alpha
  • Loading branch information
Feu-Secret authored Aug 7, 2020
2 parents 2156494 + a6d6786 commit 6d56579
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 42 deletions.
Binary file modified .vs/Tokenmagic/v16/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"\\tokenmagic",
"\\tokenmagic\\fx",
"\\tokenmagic\\fx\\filters",
"\\tokenmagic\\fx\\filters\\proto",
"\\tokenmagic\\fx\\glsl",
"\\tokenmagic\\fx\\glsl\\fragmentshaders",
"\\tokenmagic\\fx\\presets",
"\\tokenmagic\\module",
"\\tokenmagic\\module\\proto",
"\\tokenmagic\\updates"
Expand Down
Binary file modified .vs/slnx.sqlite
Binary file not shown.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Token Magic FX - Update v0.2.2b-alpha

*Fixed issues :*
- Compatibility problem with furnace module drawings tools.

# Token Magic FX - Update v0.2.2-alpha

*Added :*
Expand Down
Binary file modified Tokenmagic.zip
Binary file not shown.
13 changes: 8 additions & 5 deletions tokenmagic/fx/Anime.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,14 @@ export class Anime {
if (Anime._frameTime >= canvas.app.ticker.deltaMS) {
// enough time passed : call animate for each animation
Anime._animeMap.forEach((anime, id) => {
if (anime.puppet.hasOwnProperty("preComputation")) {
anime.puppet.preComputation();
}
if (anime.puppet.hasOwnProperty("animated") && !(anime.puppet.animated == null)) {
anime.animate(Anime._frameTime);
if (anime.puppet.enabled) {
if (anime.puppet.hasOwnProperty("preComputation")
&& anime.puppet.placeableImg != null) {
anime.puppet.preComputation();
}
if (anime.puppet.hasOwnProperty("animated") && !(anime.puppet.animated == null)) {
anime.animate(Anime._frameTime);
}
}
});
Anime._prevTime = Anime._lastTime;
Expand Down
6 changes: 5 additions & 1 deletion tokenmagic/fx/filters/proto/FilterProto.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { objectAssign, getPlaceableById, getMinPadding, PlaceableType } from "../../../module/tokenmagic.js";
import { objectAssign, getPlaceableById, getMinPadding, PlaceableType, Magic } from "../../../module/tokenmagic.js";
import "../../../module/proto/PlaceableObjectProto.js";

PIXI.Filter.prototype.setTMParams = function (params) {
Expand Down Expand Up @@ -52,6 +52,10 @@ PIXI.Filter.prototype.assignPlaceable = function () {
: this.placeableImg = null;
}

PIXI.Filter.prototype.assignPlaceable = function () {
this.placeableImg = this.getPlaceable();
}

PIXI.Filter.prototype.activateTransform = function () {
this.preComputation = this.filterTransform;
this.filterTransform();
Expand Down
35 changes: 9 additions & 26 deletions tokenmagic/fx/glsl/fragmentshaders/forcefield.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ varying vec2 vFilterCoord;
#define SQRT5B20 0.30901699
#define PI 3.14159265
#define TWOPI 6.28318531
#define SPEED 0.01
#define MU_TWOPI 0.15915494309
#define MU_289 0.00346020761
Expand Down Expand Up @@ -394,33 +395,19 @@ vec4 surface4d(vec2 suv)
{
float s = suv.x + 0.61;
float t = suv.y + 0.5;
float multiplier = 1.0 * MU_TWOPI;
float nx = cos( s * 2.0 * PI ) * multiplier;
float ny = cos( t * 2.0 * PI ) * multiplier;
float nz = sin( s * 2.0 * PI ) * multiplier;
float nw = sin( t * 2.0 * PI ) * multiplier;
float nx = cos( s * TWOPI ) * MU_TWOPI;
float ny = cos( t * TWOPI ) * MU_TWOPI;
float nz = sin( s * TWOPI ) * MU_TWOPI;
float nw = sin( t * TWOPI ) * MU_TWOPI;
float surf = surface( vec4( nx, ny, nz, nw ) + time * SPEED * 3. );
float surf = surface( vec4( nx, ny, nz, nw ) + time * 0.03 );
return vec4( color * vec3( surf ), 1.0 );
}
vec4 fbmy(vec2 suv)
{
vec4 noiseColor;
noiseColor.r = (color.r * fbm(suv + time*0.5));
noiseColor.g = (color.g * fbm(suv + time*0.5));
noiseColor.b = (color.b * fbm(suv + time*0.5));
noiseColor.a = 1.;
return clamp(noiseColor,0.,1.);
}
vec4 noisy(vec2 suv)
{
vec4 noiseColor;
noiseColor.r = (color.r * noise(suv + fbm(suv) + time*0.5));
noiseColor.g = (color.g * noise(suv + fbm(suv) + time*0.5));
noiseColor.b = (color.b * noise(suv + fbm(suv) + time*0.5));
noiseColor.rgb = (color.rgb * noise(suv + fbm(suv) + time*0.5));
noiseColor.a = 1.;
return clamp(noiseColor,0.,1.);
}
Expand Down Expand Up @@ -455,9 +442,7 @@ vec4 denseSmoke(vec2 suv)
vec2 uv;
uv.x = (fbm(suv*2.)-suv.x);
uv.y = (suv.y+fbm(suv*2.));
noiseColor.r = (color.r * min(fbm(uv - time*0.5),fbm(uv)*1.5));
noiseColor.g = (color.g * min(fbm(uv - time*0.5),fbm(uv)*1.5));
noiseColor.b = (color.b * min(fbm(uv - time*0.5),fbm(uv)*1.5));
noiseColor.rgb = (color.rgb * min(fbm(uv - time*0.5),fbm(uv)*1.5));
noiseColor.a = 1.0;
return clamp(noiseColor,0.,1.);
}
Expand All @@ -469,9 +454,7 @@ vec4 dancingFume(vec2 suv)
uv.x += noise(suv)+fbm(suv);
uv.y += noise(suv)+fbm(suv);
uv *= 0.5;
noiseColor.r = (color.r * fbm((uv + suv*0.15) - time));
noiseColor.g = (color.g * fbm((uv + suv*0.15) - time));
noiseColor.b = (color.b * fbm((uv + suv*0.15) - time));
noiseColor.rgb = (color.rgb * fbm((uv + suv*0.15) - time));
noiseColor.a = 1.0;
return clamp(noiseColor,0.,1.);
}
Expand Down
2 changes: 1 addition & 1 deletion tokenmagic/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "tokenmagic",
"title": "Token Magic FX",
"description": "<p>Add graphic filters and animations on your tokens and tiles.</p>",
"version": "0.2.2",
"version": "0.2.2b",
"compatibleCoreVersion": "0.6.5",
"minimumCoreVersion": "0.6.0",
"author": "SecretFire",
Expand Down
6 changes: 4 additions & 2 deletions tokenmagic/module/proto/PlaceableObjectProto.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ PlaceableObject.prototype._TMFXgetSprite = function () {
return this.template;
break;
case PlaceableType.DRAWING:
return this.drawing;
return this.drawing || this.img;
break;
default:
return null;
Expand All @@ -72,7 +72,9 @@ PlaceableObject.prototype._TMFXcheckSprite = function () {
break;
case PlaceableType.DRAWING:
return (this.hasOwnProperty("drawing")
&& !(this.drawing == null));
&& !(this.drawing == null))
|| (this.hasOwnProperty("img")
&& !(this.img == null));
break;
default:
return null;
Expand Down
50 changes: 44 additions & 6 deletions tokenmagic/module/tokenmagic.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const PlaceableType = {
TOKEN: Token.embeddedName,
TILE: Tile.embeddedName,
TEMPLATE: MeasuredTemplate.embeddedName,
DRAWING: Drawing.embeddedName,
DRAWING: Drawing.embeddedName,
NOT_SUPPORTED: null
};

Expand All @@ -107,7 +107,7 @@ function i18n(key) {

async function exportObjectAsJson(exportObj, exportName) {
let jsonStr = JSON.stringify(exportObj, null, 4);

const a = document.createElement('a');
const file = new Blob([jsonStr], { type: 'plain/text' });

Expand Down Expand Up @@ -195,6 +195,15 @@ export function isAdditivePaddingConfig() {
return game.settings.get("tokenmagic", "useAdditivePadding");
}

export var isFurnaceDrawingsActive = () => {
// module exeption for the Furnace by KaKaRoTo
if (isActiveModule("furnace")
&& game.settings.get("furnace", "enableDrawingTools")) {
return true;
}
return false;
};

export function isTheOne() {
const theOne = game.users.find((user) => user.isGM && user.active);
if (theOne && game.user !== theOne) {
Expand Down Expand Up @@ -868,7 +877,7 @@ export function TokenMagic() {
} catch (e) {
error(e.message);
}
}
}
}

async function importPresetLibraryFromURL(url) {
Expand Down Expand Up @@ -1081,6 +1090,35 @@ function initSocketListener() {
});
};

function initFurnaceDrawingsException() {
if (isFurnaceDrawingsActive) {
DrawingConfig.prototype.refresh = (function () {
const cachedDCR = DrawingConfig.prototype.refresh;
return async function (html) {

// Clear animations and filters
let tmfxUpdate = false;
if (this.object.data.hasOwnProperty("flags")
&& this.object.data.flags.hasOwnProperty("tokenmagic")
&& this.object.data.flags.tokenmagic.hasOwnProperty("filters")) {
tmfxUpdate = true;
Anime.removeAnimation(this.object.id);
Magic._clearImgFiltersByPlaceable(this.object);
}

// Furnace function apply (updating data and full redraw : destruction/reconstruction)
cachedDCR.apply(this, arguments);

// Reapply the filters if needed
if (tmfxUpdate) {
Magic._singleLoadFilters(this.object);
}

};
})();
}
}

async function requestLoadFilters(placeable, startTimeout = 0) {
var reqTimer;

Expand Down Expand Up @@ -1113,6 +1151,7 @@ Hooks.once("init", () => {
Hooks.on("ready", () => {
log("Hook -> ready");
initSocketListener();
initFurnaceDrawingsException();
window.TokenMagic = Magic;
});

Expand Down Expand Up @@ -1242,10 +1281,9 @@ Hooks.on("updateDrawing", (scene, data, options, action) => {

if (scene.id !== game.user.viewedScene) return;

// hum.. let's explain. Position change do not trigger a diff:true
if ((action.hasOwnProperty("diff") && action.diff
&& !(options.hasOwnProperty("flags") && options.flags.hasOwnProperty("tokenmagic")))
|| (options.hasOwnProperty("x") || options.hasOwnProperty("y")) ) {
|| (options.hasOwnProperty("x") || options.hasOwnProperty("y"))) {

var placeable = getPlaceableById(data._id, PlaceableType.DRAWING);

Expand All @@ -1256,7 +1294,7 @@ Hooks.on("updateDrawing", (scene, data, options, action) => {
Magic._clearImgFiltersByPlaceable(placeable);

// querying filters reload (when pixi containers are ready)
requestLoadFilters(placeable, 50);
requestLoadFilters(placeable, 250);

} else {
Magic._updateFilters(data, options, PlaceableType.DRAWING);
Expand Down
4 changes: 4 additions & 0 deletions tokenmagic/updates/UPDATE-0.2.2b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Token Magic FX - Update v0.2.2b-alpha

*Fixed issues :*
- Compatibility problem with furnace module drawings tools.

0 comments on commit 6d56579

Please sign in to comment.