Page MenuHome

BGE: Adding a screenshot function to game actuator
ClosedPublic

Authored by Thomas Szepe (hg1) on Jul 16 2014, 7:57 PM.

Details

Summary

Extending the existing game actuator with a screenshot function, to give also non programmers the ability to take screenshots in the BGE.

Diff Detail

Event Timeline

source/blender/makesdna/DNA_actuator_types.h
191

Do we need a new value or can we just reuse filename as you do for the Python API?

source/blender/makesdna/DNA_actuator_types.h
191

We can reuse filename. But as I can remember I have made this extra variable, to get a different property UI text.
RNA_def_property_ui_text(prop, "Path", "Scrennshot Path and Filename, use the \"//\" prefix for a relative path");

source/blender/makesdna/DNA_actuator_types.h
191

If we change the property UI text from filename to a more general one like "Path and Filename, use the \"//\" prefix for a relative path" then the text will fit for both actuators.

source/blender/makesdna/DNA_actuator_types.h
191

That should work.

Mitchell Stokes (moguri) requested changes to this revision.Jul 18 2014, 8:04 AM
Thomas Szepe (hg1) updated this revision to Unknown Object (????).Jul 18 2014, 8:59 AM

Reused filename for the screenshot function and change the property UI text.

source/blender/makesrna/intern/rna_actuator.c
1738

Maybe this could be reworded to "The file to use depending on the mode (e.g., the blend file to load or a destination for saving a screenshot). Use the \"//\" prefix for a relative path."

I'm not sure what our guidelines are for multi-sentence tooltips, but I find a tooltip that just repeats the name of the field to be of little use.

Thomas Szepe (hg1) updated this revision to Unknown Object (????).Jul 19 2014, 8:09 PM

Changed the property UI text and the documentation in KX_GameActuator.rst.

This revision now requires changes to proceed.Aug 2 2014, 9:42 PM

@Genome36.Via. I have done all requested changes and the path is still mergeable.
Why you changed the status to need revision?

I revert the change of the status because I think that Genome36 changed by mistake

Strange, i only registered myself and don't touch anything else.

Either way, sorry for the inconvenience.

EDIT: Now that I think of it, "Moguri requested changes to this revision" and it only took effect right after I subscribed ... Meaning I didn't change status :P

Strange, i only registered myself and didn't touch anything else.

Either way, sorry for the inconvenience.

EDIT: Now that I think of it, "Moguri requested changes to this revision" and it only took effect right after I subscribed ... Meaning I didn't change status :P

source/gameengine/Ketsji/KX_GameActuator.cpp
205

I don't think it makes sense for this to ever be NULL, so there probably isn't a need for a check here.

211

I'm not a huge fan of silent failures. Could we print out a warning to the console?

source/gameengine/Ketsji/KX_GameActuator.cpp
205

I don't know why we have everywhere this checks. I removed the if statement and made some test if I can cause a crash. Seems to work. I also made some tests with removed if (canvas) statement. It seams that is works also without this statements.
Do you can imagine any condition where we can get an error if we remove one of these statements?

211

I don't know which fault it should print out. If the canvas not existing?

Thomas Szepe (hg1) retitled this revision from BGE: Adding a screeenshot function in to game actuator. to BGE: Adding a screenshot function to game actuator.
Thomas Szepe (hg1) updated this object.
Thomas Szepe (hg1) edited edge metadata.

Removed m_ketsjiengine and canvas check.

Thomas Szepe (hg1) edited edge metadata.

Adding back the canvas check and print out an error message if not exist.

Jorge Bernal (lordloki) edited edge metadata.

Other than the inline comment it looks ok to me.

source/blender/makesrna/intern/rna_actuator.c
1740

insert a space after destination word

  • Insert a space after destination word.
  • Added Campbell as reviver.

I'm okay with this for the most part. I'm not entirely sure on how the warning is done. It seems a little inconsistent with how we do things, but we usually do things with Python exceptions, which might not make sense in this case. The warning also doesn't seem too terribly user friendly (Canvas isn't something that's really mentioned much outside of the source code).

It seems a little inconsistent with how we do things, but we usually do things with Python exceptions, which might not make sense in this case.

The screenshot actuator will work without Python. So I can't use a Python exception to print out the error message. I found some printf for error messages in the Blender and BGE code. So I thought it is OK to use printf.

The warning also doesn't seem too terribly user friendly (Canvas isn't something that's really mentioned much outside of the source code).

Actually I don't know what else then canvas I should write. I don't found any error message if canvas is not available. Please make a suggestion for the error message.

Mitchell Stokes (moguri) edited edge metadata.

It would be nice to get @Campbell Barton (campbellbarton)'s thoughts on the error handling (the user-friendliness of the error message and consistency with other error reporting). If we don't get a review from Campbell in a reasonable time (a week?) then I think this is still okay to commit.

This revision is now accepted and ready to land.May 5 2015, 10:34 PM
Thomas Szepe (hg1) edited edge metadata.

Changed the error text from "Canvas not available" to "Rasterizer not available".
As taken with moguri on IRC, for most users it is not obvious what is meant by canvas. So we lie here and say rasterizer instead.

This revision was automatically updated to reflect the committed changes.