Skip to content

Commit

Permalink
feat: update for 0.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGiddyLimit committed Sep 15, 2021
1 parent c21a1e7 commit 9f23474
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 42 deletions.
88 changes: 51 additions & 37 deletions js/GooglyEyes.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
class GooglyEyes {
static async pInit () {
await this._pInitTexture();
this._initToggle();
this._initTokenMods();
}

static async _pInitTexture () {
GooglyEyes._TEXTURE = await loadTexture(`modules/${GooglyEyes._MODULE_NAME}/media/googly-eye.png`);
}

static _initToggle () {
const $btn = $(`<button class="ggly__btn" title="Toggle Google Eye Tool"></button>`)
.click(() => {
Expand All @@ -19,36 +14,55 @@ class GooglyEyes {
}

static _initTokenMods () {
const cachedRefresh = Token.prototype.refresh;
const cachedClickLeft = Token.prototype._onClickLeft;
const cachedClickRight = Token.prototype._onClickRight;
const cachedClickLeft2 = Token.prototype._onClickLeft2;
const cachedClickRight2 = Token.prototype._onClickRight2;

Token.prototype.refresh = function (...args) {
GooglyEyes._doRender(this);
return cachedRefresh.bind(this)(...args);
};

Token.prototype._onClickLeft = function (...args) {
if (GooglyEyes._doHandleClickLeft(this, ...args)) return false;
return cachedClickLeft.bind(this)(...args);
};

Token.prototype._onClickLeft2 = function (...args) {
if (GooglyEyes._doHandleClickLeft(this, ...args)) return false;
return cachedClickLeft2.bind(this)(...args);
};

Token.prototype._onClickRight = function (...args) {
if (GooglyEyes._doHandleClickRight(this, ...args)) return false;
return cachedClickRight.bind(this)(...args);
};

Token.prototype._onClickRight2 = function (...args) {
if (GooglyEyes._doHandleClickRight(this, ...args)) return false;
return cachedClickRight2.bind(this)(...args);
};
libWrapper.register(
GooglyEyes._MODULE_NAME,
"Token.prototype.refresh",
function (fn, ...args) {
GooglyEyes._doRender(this);
return fn(...args);
},
"WRAPPER",
);

libWrapper.register(
GooglyEyes._MODULE_NAME,
"Token.prototype._onClickLeft",
function (fn, ...args) {
if (GooglyEyes._doHandleClickLeft(this, ...args)) return false;
return fn(...args);
},
"MIXED",
);

libWrapper.register(
GooglyEyes._MODULE_NAME,
"Token.prototype._onClickLeft2",
function (fn, ...args) {
if (GooglyEyes._doHandleClickLeft(this, ...args)) return false;
return fn(...args);
},
"MIXED",
);

libWrapper.register(
GooglyEyes._MODULE_NAME,
"Token.prototype._onClickRight",
function (fn, ...args) {
if (GooglyEyes._doHandleClickRight(this, ...args)) return false;
return fn(...args);
},
"MIXED",
);

libWrapper.register(
GooglyEyes._MODULE_NAME,
"Token.prototype._onClickRight2",
function (fn, ...args) {
if (GooglyEyes._doHandleClickRight(this, ...args)) return false;
return fn(...args);
},
"MIXED",
);

this._doTriggerExistingTokens();
}
Expand Down Expand Up @@ -83,7 +97,7 @@ class GooglyEyes {
if (sptEye && sptEye.parent) return;
if (sptEye && !sptEye.parent) token.removeChild(sptEye);

sptEye = new PIXI.Sprite(GooglyEyes._TEXTURE);
sptEye = PIXI.Sprite.from(GooglyEyes._TEXTURE_PATH);

sptEye.anchor.set(0.5, 0.5);
sptEye.position.set(pt.x, pt.y);
Expand Down Expand Up @@ -174,9 +188,9 @@ class GooglyEyes {
return JSON.parse(JSON.stringify(token.data.flags?.[GooglyEyes._MODULE_NAME]?.points || []));
}
}
GooglyEyes._TEXTURE = null;
GooglyEyes._IS_ACTIVE = false;
GooglyEyes._MODULE_NAME = "googly-eyes";
GooglyEyes._TEXTURE_PATH = `modules/${GooglyEyes._MODULE_NAME}/media/googly-eye.png`;

Hooks.on("ready", () => {
GooglyEyes.pInit();
Expand Down
13 changes: 9 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "googly-eyes",
"title": "Googly Eyes",
"description": "Google Eyes",
"version": "0.1.1",
"version": "0.2.0",
"author": "Giddy",
"keywords": [
"visuals"
Expand All @@ -11,9 +11,14 @@
"license": "MIT",
"url": "https://www.patreon.com/Giddy5e",
"manifest": "https://raw.githubusercontent.com/TheGiddyLimit/foundry-googly-eyes/master/module.json",
"download": "https://github.com/TheGiddyLimit/foundry-googly-eyes/archive/v0.1.1.zip",
"minimumCoreVersion": "0.7.7",
"compatibleCoreVersion": "0.7.7",
"download": "https://github.com/TheGiddyLimit/foundry-googly-eyes/archive/v0.2.0.zip",
"minimumCoreVersion": "0.8.6",
"compatibleCoreVersion": "0.8.9",
"dependencies": [
{
"name": "lib-wrapper"
}
],
"esmodules": [
"./js/GooglyEyes.js"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foundry-googly-eyes",
"version": "0.1.1",
"version": "0.2.0",
"author": "Giddy",
"license": "MIT",
"devDependencies": {
Expand Down

0 comments on commit 9f23474

Please sign in to comment.