Advertisement
Guest User

Untitled

a guest
Jun 11th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.53 KB | None | 0 0
  1. Index: binaries/data/mods/public/gui/options/options.json
  2. ===================================================================
  3. --- binaries/data/mods/public/gui/options/options.json  (revision 17965)
  4. +++ binaries/data/mods/public/gui/options/options.json  (working copy)
  5. @@ -1,10 +1,28 @@
  6.  {
  7.     "generalSetting":
  8.     [
  9.         {
  10.             "type": "boolean",
  11. +           "label": "Screenshot based rendering",
  12. +           "tooltip": "Take N screenshots per second",
  13. +           "parameters": { "config": "videorendering.enabled" }
  14. +       },
  15. +       {
  16. +           "type": "number",
  17. +           "label": "Screenshot rendering FPS",
  18. +           "tooltip": "Target frames per second",
  19. +           "parameters": { "config": "videorendering.fps", "min": 1, "max": 65535 }
  20. +       },
  21. +       {
  22. +           "type": "number",
  23. +           "label": "Screenshot rendering start time",
  24. +           "tooltip": "Starting simulation time in seconds",
  25. +           "parameters": { "config": "videorendering.start", "min": 0, "max": 65535 }
  26. +       },
  27. +       {
  28. +           "type": "boolean",
  29.             "label": "Windowed Mode",
  30.             "tooltip": "Start 0 A.D. in a window",
  31.             "parameters": { "config": "windowed" }
  32.         },
  33.         {
  34. Index: source/main.cpp
  35. ===================================================================
  36. --- source/main.cpp (revision 17965)
  37. +++ source/main.cpp (working copy)
  38. @@ -248,10 +248,21 @@ static void Frame()
  39.     g_Profiler2.IncrementFrameNumber();
  40.     PROFILE2_ATTR("%d", g_Profiler2.GetFrameNumber());
  41.  
  42.     ogl_WarnIfError();
  43.  
  44. +   bool takeScreenshots;
  45. +   int screenshotsFPS;
  46. +   int screenshotsStartTime;
  47. +
  48. +   CFG_GET_VAL("videorendering.enabled", takeScreenshots);
  49. +   CFG_GET_VAL("videorendering.fps", screenshotsFPS);
  50. +   CFG_GET_VAL("videorendering.start", screenshotsStartTime);
  51. +
  52. +   bool doScreenshot = takeScreenshots && g_Game &&
  53. +           g_Game->IsGameStarted() && g_Game->SimTime() >= screenshotsStartTime * 1000;
  54. +
  55.     // get elapsed time
  56.     const double time = timer_Time();
  57.     g_frequencyFilter->Update(time);
  58.     // .. old method - "exact" but contains jumps
  59.  #if 0
  60. @@ -261,16 +272,22 @@ static void Frame()
  61.     last_time = time;
  62.     ONCE(return);   // first call: set last_time and return
  63.  
  64.     // .. new method - filtered and more smooth, but errors may accumulate
  65.  #else
  66. -   const float realTimeSinceLastFrame = 1.0 / g_frequencyFilter->SmoothedFrequency();
  67. +   // Fake target FPS when rendering a video using screenshots
  68. +   float realTimeSinceLastFrame;
  69. +   if (doScreenshot)
  70. +       realTimeSinceLastFrame = 1.0 / ((float) screenshotsFPS);
  71. +   else
  72. +       realTimeSinceLastFrame = 1.0 / g_frequencyFilter->SmoothedFrequency();
  73.  #endif
  74. +
  75.     ENSURE(realTimeSinceLastFrame > 0.0f);
  76.  
  77.     // decide if update/render is necessary
  78. -   bool need_render = !g_app_minimized;
  79. +   bool need_render = !g_app_minimized || doScreenshot;
  80.     bool need_update = true;
  81.  
  82.     // If we are not running a multiplayer game, disable updates when the game is
  83.     // minimized or out of focus and relinquish the CPU a bit, in order to make
  84.     // debugging easier.
  85. @@ -328,10 +345,13 @@ static void Frame()
  86.  
  87.     g_GUI->TickObjects();
  88.  
  89.     ogl_WarnIfError();
  90.  
  91. +   // Don't pause renderer on focus loss
  92. +   g_app_has_focus = g_app_has_focus || doScreenshot;
  93. +
  94.     if (g_Game && g_Game->IsGameStarted() && need_update)
  95.     {
  96.         g_Game->Update(realTimeSinceLastFrame);
  97.  
  98.         g_Game->GetView()->Update(float(realTimeSinceLastFrame));
  99. @@ -357,10 +377,13 @@ static void Frame()
  100.         PROFILE3("swap buffers");
  101.         SDL_GL_SwapWindow(g_VideoMode.GetWindow());
  102.     }
  103.     ogl_WarnIfError();
  104.  
  105. +   if (doScreenshot)
  106. +       WriteScreenshot(L".png");
  107. +
  108.     g_Profiler.Frame();
  109.  
  110.     g_GameRestarted = false;
  111.  }
  112.  
  113. Index: source/network/NetTurnManager.h
  114. ===================================================================
  115. --- source/network/NetTurnManager.h (revision 17965)
  116. +++ source/network/NetTurnManager.h (working copy)
  117. @@ -143,10 +143,11 @@ public:
  118.  
  119.     void QuickSave();
  120.     void QuickLoad();
  121.  
  122.     u32 GetCurrentTurn() { return m_CurrentTurn; }
  123. +   u32 GetCurrentTurnLength() { return m_TurnLength; }
  124.  
  125.  protected:
  126.     /**
  127.      * Store a command to be executed at a given turn.
  128.      */
  129. Index: source/ps/Game.cpp
  130. ===================================================================
  131. --- source/ps/Game.cpp  (revision 17965)
  132. +++ source/ps/Game.cpp  (working copy)
  133. @@ -357,21 +357,26 @@ void CGame::StartGame(JS::MutableHandleV
  134.         m_ReplayLogger->StartGame(attribs);
  135.  
  136.     RegisterInit(attribs, savedState);
  137.  }
  138.  
  139. +int CGame::SimTime()
  140. +{
  141. +   return GetTurnManager()->GetCurrentTurn() * GetTurnManager()->GetCurrentTurnLength();
  142. +}
  143. +
  144.  // TODO: doInterpolate is optional because Atlas interpolates explicitly,
  145.  // so that it has more control over the update rate. The game might want to
  146.  // do the same, and then doInterpolate should be redundant and removed.
  147.  
  148.  void CGame::Update(const double deltaRealTime, bool doInterpolate)
  149.  {
  150.     if (m_Paused || !m_TurnManager)
  151.         return;
  152.  
  153.     const double deltaSimTime = deltaRealTime * m_SimRate;
  154. -  
  155. +
  156.     if (deltaSimTime)
  157.     {
  158.         // To avoid confusing the profiler, we need to trigger the new turn
  159.         // while we're not nested inside any PROFILE blocks
  160.         if (m_TurnManager->WillUpdate(deltaSimTime))
  161. Index: source/ps/Game.h
  162. ===================================================================
  163. --- source/ps/Game.h    (revision 17965)
  164. +++ source/ps/Game.h    (working copy)
  165. @@ -159,10 +159,12 @@ public:
  166.     {   if (isfinite(simRate)) m_SimRate = std::max(simRate, 0.0f); }
  167.  
  168.     inline float GetSimRate() const
  169.     {   return m_SimRate; }
  170.  
  171. +   int SimTime();
  172. +
  173.     /**
  174.      * Replace the current turn manager.
  175.      * This class will take ownership of the pointer.
  176.      */
  177.     void SetTurnManager(CNetTurnManager* turnManager);
  178. Index: source/ps/GameSetup/GameSetup.cpp
  179. ===================================================================
  180. --- source/ps/GameSetup/GameSetup.cpp   (revision 17965)
  181. +++ source/ps/GameSetup/GameSetup.cpp   (working copy)
  182. @@ -492,11 +492,11 @@ static void InitVfs(const CmdLineArgs& a
  183.     g_VFS->Mount(L"l10n/", paths.RData()/"l10n"/"");
  184.  
  185.     MountMods(paths, GetMods(args, flags));
  186.  
  187.     // We mount these dirs last as otherwise writing could result in files being placed in a mod's dir.
  188. -   g_VFS->Mount(L"screenshots/", paths.UserData()/"screenshots"/"");
  189. +   g_VFS->Mount(L"screenshots/", OsPath("/media/elexis/b44403ce-95f0-47d5-84c1-f0076850e183/home/packager/svn/screenshots")/"");
  190.     g_VFS->Mount(L"saves/", paths.UserData()/"saves"/"", VFS_MOUNT_WATCH);
  191.     // Mounting with highest priority, so that a mod supplied user.cfg is harmless
  192.     g_VFS->Mount(L"config/", readonlyConfig, 0, (size_t)-1);
  193.     if(readonlyConfig != paths.Config())
  194.         g_VFS->Mount(L"config/", paths.Config(), 0, (size_t)-1);
  195. Index: source/ps/Util.cpp
  196. ===================================================================
  197. --- source/ps/Util.cpp  (revision 17965)
  198. +++ source/ps/Util.cpp  (working copy)
  199. @@ -270,11 +270,11 @@ void WriteScreenshot(const VfsPath& exte
  200.  
  201.     if (tex_write(&t, filename) == INFO::OK)
  202.     {
  203.         OsPath realPath;
  204.         g_VFS->GetRealPath(filename, realPath);
  205. -       LOGMESSAGERENDER(g_L10n.Translate("Screenshot written to '%s'"), realPath.string8());
  206. +       debug_printf("Screenshot written to '%s'\n", realPath.string8().c_str());
  207.     }
  208.     else
  209.         LOGERROR("Error writing screenshot to '%s'", filename.string8());
  210.  }
  211.  
  212. @@ -403,11 +403,11 @@ void WriteBigScreenshot(const VfsPath& e
  213.  
  214.     if (tex_write(&t, filename) == INFO::OK)
  215.     {
  216.         OsPath realPath;
  217.         g_VFS->GetRealPath(filename, realPath);
  218. -       LOGMESSAGERENDER(g_L10n.Translate("Screenshot written to '%s'"), realPath.string8());
  219. +       debug_printf("Screenshot written to '%s'\n", realPath.string8().c_str());
  220.     }
  221.     else
  222.         LOGERROR("Error writing screenshot to '%s'", filename.string8());
  223.  
  224.     free(tile_data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement