Browse Source

Take screenshots in the editor w/ F11

Chris Friesen 11 years ago
parent
commit
c346c3db23
3 changed files with 12 additions and 1 deletions
  1. 1 0
      .gitignore
  2. 10 1
      Bin/Data/Scripts/Editor/EditorUI.as
  3. 1 0
      Docs/GettingStarted.dox

+ 1 - 0
.gitignore

@@ -10,6 +10,7 @@ Bin/*
 Bin/*.app/
 Bin/*.app/
 Bin/*.app.dSYM/
 Bin/*.app.dSYM/
 Bin/Data/LuaScripts/jit/
 Bin/Data/LuaScripts/jit/
+Bin/Screenshots
 *-Bin/
 *-Bin/
 Lib/
 Lib/
 *-Lib/
 *-Lib/

+ 10 - 1
Bin/Data/Scripts/Editor/EditorUI.as

@@ -44,6 +44,7 @@ String uiImportPath;
 String uiScriptPath = fileSystem.programDir + "Data/Scripts";
 String uiScriptPath = fileSystem.programDir + "Data/Scripts";
 String uiParticlePath = fileSystem.programDir + "Data/Particles";
 String uiParticlePath = fileSystem.programDir + "Data/Particles";
 Array<String> uiRecentScenes;
 Array<String> uiRecentScenes;
+String screenshotDir = fileSystem.programDir + "Screenshots";
 
 
 bool uiFaded = false;
 bool uiFaded = false;
 float uiMinOpacity = 0.3;
 float uiMinOpacity = 0.3;
@@ -1141,7 +1142,15 @@ void HandleKeyDown(StringHash eventType, VariantMap& eventData)
         TogglePhysicsDebug();
         TogglePhysicsDebug();
     else if (key == KEY_F4)
     else if (key == KEY_F4)
         ToggleOctreeDebug();
         ToggleOctreeDebug();
-
+    else if (key == KEY_F11)
+    {
+        Image@ screenshot = Image();
+        graphics.TakeScreenShot(screenshot);
+        if (!fileSystem.DirExists(screenshotDir))
+            fileSystem.CreateDir(screenshotDir);
+        screenshot.SavePNG(screenshotDir + "/Screenshot_" +
+                time.timeStamp.Replaced(':', '_').Replaced('.', '_').Replaced(' ', '_') + ".png");
+    }   
     else if (key == KEY_KP_1 && ui.focusElement is null) // Front view
     else if (key == KEY_KP_1 && ui.focusElement is null) // Front view
     {
     {
         Vector3 pos = cameraNode.position;
         Vector3 pos = cameraNode.position;

+ 1 - 0
Docs/GettingStarted.dox

@@ -574,6 +574,7 @@ F1              - Toggle console
 F2              - Toggle rendering debug geometry
 F2              - Toggle rendering debug geometry
 F3              - Toggle physics debug geometry
 F3              - Toggle physics debug geometry
 F4              - Toggle octree debug geometry
 F4              - Toggle octree debug geometry
+F11             - Captures a screenshot
 \endverbatim
 \endverbatim
 
 
 Press right mouse button in the 3D view if you want to defocus the active window without changing the object selection.
 Press right mouse button in the 3D view if you want to defocus the active window without changing the object selection.