forked from ppfun/pixelplanet
give extensions a way to hook into pixel updates via
window.registerPixelUpdates
This commit is contained in:
parent
65269f5af7
commit
9e11ea3729
|
@ -1,6 +1,8 @@
|
|||
/*
|
||||
* sends events via window.pixelPlanetEvents to potential
|
||||
* Extensions and Userscripts
|
||||
* Also check out ui/PixelTransferController.js, which sends received
|
||||
* pixels to a window.registerPixelUpdates callback
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -28,6 +28,13 @@ class PixelTransferController {
|
|||
* [[i, j, offset, colorold, colornew], ...]
|
||||
*/
|
||||
this.clientPredictions = [];
|
||||
/*
|
||||
* allow extensions to hook into pixel updates
|
||||
*/
|
||||
this.extension = null;
|
||||
window.registerPixelUpdates = (cb) => {
|
||||
this.extension = cb;
|
||||
};
|
||||
}
|
||||
|
||||
initialize(store, socketClient, getRenderer) {
|
||||
|
@ -211,6 +218,9 @@ class PixelTransferController {
|
|||
j,
|
||||
pixels,
|
||||
}) {
|
||||
if (this.extension) {
|
||||
this.extension(i, j, pixels);
|
||||
}
|
||||
pixels.forEach((pxl) => {
|
||||
const [offset, color] = pxl;
|
||||
const { clientPredictions } = this;
|
||||
|
|
Loading…
Reference in New Issue
Block a user