Author Topic: A good way to check if the user's client is done taking a screenshot?  (Read 1327 times)

I'm using a hacky method right now. Just want to know if anyone knows of any call backs or anything?

Code: [Select]
package screenshotCallback {
function doScreenShot() {
Parent::doScreenShot();
screenshotCallback();
}
};
activatePackage(screenshotCallback);

This should work fine, unless doScreenshot() happens to be unpackageable.

Code: [Select]
package screenshotCallback {
function doScreenShot() {
Parent::doScreenShot();
screenshotCallback();
}
};
activatePackage(screenshotCallback);

This should work fine, unless doScreenshot() happens to be unpackageable.

From the name of that function I'm guessing that it runs at the start of taking a screenshot. What if you're taking a mega-/DOF screenshot which takes a bit of time and (supposedly) also ticks the game in the meantime?

Code: [Select]
package screenshotCallback {
function doScreenShot() {
Parent::doScreenShot();
screenshotCallback();
}
};
activatePackage(screenshotCallback);

This should work fine, unless doScreenshot() happens to be unpackageable.

Like what port said, I need it to tell me when the user's client is done processing stuff. I have a working method, but it's real hacky..

From the name of that function I'm guessing that it runs at the start of taking a screenshot. What if you're taking a mega-/DOF screenshot which takes a bit of time and (supposedly) also ticks the game in the meantime?
Both doScreenshot() and doDOFScreenshot() handle the entire processing and writing for the screenshot. Both of them do freeze game ticks though, which is why Badspot disabled doDOFScreenshot() for the host of a server--at least, that's how it was a couple of versions ago.

Code: [Select]
package screenshotCallback {
function doScreenShot(%val) {
Parent::doScreenShot(%val);
screenshotCallback();
}

function doDOFScreenShot(%val) {
Parent::doDOFScreenShot(%val);
dofScreenShotCallback();
}
};
activatePackage(screenshotCallback);

Though doDOFScreenshot() and doScreenshot() appear to be called twice, one time with %val = 1; and after with %val = 0;.


Anyways, that's what I've gotten from messing with trace() and this:
Code: [Select]
package screenshotCallback {
function doDOFScreenShot(%val) {
echo(getSimTime());
Parent::doDOFScreenShot(%val);
if(isFile("screenshots/Blockland_00011.png"))
echo("yes!");
echo(getSimTime());
dofScreenShotCallback();
}
};
activatePackage(screenshotCallback);

Both doScreenshot() and doDOFScreenshot() handle the entire processing and writing for the screenshot. Both of them do freeze game ticks though, which is why Badspot disabled doDOFScreenshot() for the host of a server--at least, that's how it was a couple of versions ago.

Code: [Select]
package screenshotCallback {
function doScreenShot(%val) {
Parent::doScreenShot(%val);
screenshotCallback();
}

function doDOFScreenShot(%val) {
Parent::doDOFScreenShot(%val);
dofScreenShotCallback();
}
};
activatePackage(screenshotCallback);

Though doDOFScreenshot() and doScreenshot() appear to be called twice, one time with %val = 1; and after with %val = 0;.


Anyways, that's what I've gotten from messing with trace() and this:
Code: [Select]
package screenshotCallback {
function doDOFScreenShot(%val) {
echo(getSimTime());
Parent::doDOFScreenShot(%val);
if(isFile("screenshots/Blockland_00011.png"))
echo("yes!");
echo(getSimTime());
dofScreenShotCallback();
}
};
activatePackage(screenshotCallback);

I still dont think that works because i tried this.

I still dont think that works because i tried this.
Really?

Code: [Select]
package screenshotCallback {
function doDOFScreenShot(%val) {
echo("Time 1:" SPC getSimTime());
echo("File Check 1:" SPC isFile("screenshots/Blockland_00007.png"));
echo("Value 1:" SPC %val);
Parent::doDOFScreenShot(%val);
echo("Time 2:" SPC getSimTime());
echo("File Check 2:" SPC isFile("screenshots/Blockland_00007.png"));
echo("Value 2:" SPC %val);
dofScreenShotCallback();
}

function dofScreenShotCallback() {
echo("Time 3:" SPC getSimTime());
echo("File Check 3:" SPC isFile("screenshots/Blockland_00007.png"));
echo("Callback ran.");
}
};
activatePackage(screenshotCallback);

trace() output:
Code: [Select]
Entering [screenshotCallback]doDofScreenShot(1)
   Time 1: 36778
   File Check 1: 0
   Value 1: 1
   Entering doDofScreenShot(1)
      //Various GUI function called.
      Entering formatImageNumber(8)
      Leaving formatImageNumber() - return 00008
      Screenshot file overwritting detected, aborting...
      Entering formatImageNumber(9)
      Leaving formatImageNumber() - return 00009
      //More GUI functions called.
   Leaving doDofScreenShot() - return
   Time 2: 36778
   File Check 2: 1
   Value 2: 1
   Entering [screenshotCallback]dofScreenShotCallback()
      Time 3: 36778
      File Check 3: 1
      Callback ran.
   Leaving [screenshotCallback]dofScreenShotCallback() - return
Leaving [screenshotCallback]doDofScreenShot() - return
Entering [screenshotCallback]doDofScreenShot(0)
   Time 1: 36778
   File Check 1: 1
   Value 1: 0
   Entering doDofScreenShot(0)
   Leaving doDofScreenShot() - return
   Time 2: 36778
   File Check 2: 1
   Value 2: 0
   Entering [screenshotCallback]dofScreenShotCallback()
      Time 3: 36778
      File Check 3: 1
      Callback ran.
   Leaving [screenshotCallback]dofScreenShotCallback() - return
Leaving [screenshotCallback]doDofScreenShot() - return
« Last Edit: December 23, 2012, 04:24:12 AM by Daenth »

Why are you using getSimTime()? Use getrealtime and post the results again please. (Im not home right now)

Why are you using getSimTime()? Use getrealtime and post the results again please. (Im not home right now)
That's a good question. I think I popped it in there because of...
What if you're taking a mega-/DOF screenshot which takes a bit of time and (supposedly) also ticks the game in the meantime?

Results:
Code: [Select]
Entering [screenshotCallback]doDofScreenShot(1)
   Sim Time 1: 46095
   Real Time 1: 692289692
   File Check 1: 0
   Value 1: 1
   Entering doDofScreenShot(1)
      //GUI stuff.
      //Image number stuff.
      //More GUI stuff.
   Leaving doDofScreenShot() - return
   Time 2: 46095
   Real Time 2: 692292750
   File Check 2: 1
   Value 2: 1
   Entering [screenshotCallback]dofScreenShotCallback()
      Time 3: 46095
      Real Time 3: 692292750
      File Check 3: 1
      Callback ran.
   Leaving [screenshotCallback]dofScreenShotCallback() - return
Leaving [screenshotCallback]doDofScreenShot() - return
Entering [screenshotCallback]doDofScreenShot(0)
   Sim Time 1: 46095
   Real Time 1: 692292750
   File Check 1: 1
   Value 1: 0
   Entering doDofScreenShot(0)
   Leaving doDofScreenShot() - return
   Time 2: 46095
   Real Time 2: 692292766
   File Check 2: 1
   Value 2: 0
   Entering [screenshotCallback]dofScreenShotCallback()
      Time 3: 46095
      Real Time 3: 692292766
      File Check 3: 1
      Callback ran.
   Leaving [screenshotCallback]dofScreenShotCallback() - return
Leaving [screenshotCallback]doDofScreenShot() - return


So, yes; this, albeit slightly edited, should work fine for you for both DOF and regular screenshots.
Code: [Select]
package screenshotCallback {
function doScreenShot(%val) {
Parent::doScreenShot(%val);
                if(%val)
   screenshotCallback();
}
};
activatePackage(screenshotCallback);
« Last Edit: December 23, 2012, 04:26:50 AM by Daenth »

I'll go ahead and do further testing to confirm this a little later, thanks.