Explorar el Código

Take screenshots in the editor w/ F11

Chris Friesen hace 11 años
padre
commit
c346c3db23
Se han modificado 3 ficheros con 12 adiciones y 1 borrados
  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.dSYM/
 Bin/Data/LuaScripts/jit/
+Bin/Screenshots
 *-Bin/
 Lib/
 *-Lib/

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

@@ -44,6 +44,7 @@ String uiImportPath;
 String uiScriptPath = fileSystem.programDir + "Data/Scripts";
 String uiParticlePath = fileSystem.programDir + "Data/Particles";
 Array<String> uiRecentScenes;
+String screenshotDir = fileSystem.programDir + "Screenshots";
 
 bool uiFaded = false;
 float uiMinOpacity = 0.3;
@@ -1141,7 +1142,15 @@ void HandleKeyDown(StringHash eventType, VariantMap& eventData)
         TogglePhysicsDebug();
     else if (key == KEY_F4)
         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
     {
         Vector3 pos = cameraNode.position;

+ 1 - 0
Docs/GettingStarted.dox

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