Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: binaries/data/mods/public/gui/options/options.json
- ===================================================================
- --- binaries/data/mods/public/gui/options/options.json (revision 17965)
- +++ binaries/data/mods/public/gui/options/options.json (working copy)
- @@ -1,10 +1,28 @@
- {
- "generalSetting":
- [
- {
- "type": "boolean",
- + "label": "Screenshot based rendering",
- + "tooltip": "Take N screenshots per second",
- + "parameters": { "config": "videorendering.enabled" }
- + },
- + {
- + "type": "number",
- + "label": "Screenshot rendering FPS",
- + "tooltip": "Target frames per second",
- + "parameters": { "config": "videorendering.fps", "min": 1, "max": 65535 }
- + },
- + {
- + "type": "number",
- + "label": "Screenshot rendering start time",
- + "tooltip": "Starting simulation time in seconds",
- + "parameters": { "config": "videorendering.start", "min": 0, "max": 65535 }
- + },
- + {
- + "type": "boolean",
- "label": "Windowed Mode",
- "tooltip": "Start 0 A.D. in a window",
- "parameters": { "config": "windowed" }
- },
- {
- Index: source/main.cpp
- ===================================================================
- --- source/main.cpp (revision 17965)
- +++ source/main.cpp (working copy)
- @@ -248,10 +248,21 @@ static void Frame()
- g_Profiler2.IncrementFrameNumber();
- PROFILE2_ATTR("%d", g_Profiler2.GetFrameNumber());
- ogl_WarnIfError();
- + bool takeScreenshots;
- + int screenshotsFPS;
- + int screenshotsStartTime;
- +
- + CFG_GET_VAL("videorendering.enabled", takeScreenshots);
- + CFG_GET_VAL("videorendering.fps", screenshotsFPS);
- + CFG_GET_VAL("videorendering.start", screenshotsStartTime);
- +
- + bool doScreenshot = takeScreenshots && g_Game &&
- + g_Game->IsGameStarted() && g_Game->SimTime() >= screenshotsStartTime * 1000;
- +
- // get elapsed time
- const double time = timer_Time();
- g_frequencyFilter->Update(time);
- // .. old method - "exact" but contains jumps
- #if 0
- @@ -261,16 +272,22 @@ static void Frame()
- last_time = time;
- ONCE(return); // first call: set last_time and return
- // .. new method - filtered and more smooth, but errors may accumulate
- #else
- - const float realTimeSinceLastFrame = 1.0 / g_frequencyFilter->SmoothedFrequency();
- + // Fake target FPS when rendering a video using screenshots
- + float realTimeSinceLastFrame;
- + if (doScreenshot)
- + realTimeSinceLastFrame = 1.0 / ((float) screenshotsFPS);
- + else
- + realTimeSinceLastFrame = 1.0 / g_frequencyFilter->SmoothedFrequency();
- #endif
- +
- ENSURE(realTimeSinceLastFrame > 0.0f);
- // decide if update/render is necessary
- - bool need_render = !g_app_minimized;
- + bool need_render = !g_app_minimized || doScreenshot;
- bool need_update = true;
- // If we are not running a multiplayer game, disable updates when the game is
- // minimized or out of focus and relinquish the CPU a bit, in order to make
- // debugging easier.
- @@ -328,10 +345,13 @@ static void Frame()
- g_GUI->TickObjects();
- ogl_WarnIfError();
- + // Don't pause renderer on focus loss
- + g_app_has_focus = g_app_has_focus || doScreenshot;
- +
- if (g_Game && g_Game->IsGameStarted() && need_update)
- {
- g_Game->Update(realTimeSinceLastFrame);
- g_Game->GetView()->Update(float(realTimeSinceLastFrame));
- @@ -357,10 +377,13 @@ static void Frame()
- PROFILE3("swap buffers");
- SDL_GL_SwapWindow(g_VideoMode.GetWindow());
- }
- ogl_WarnIfError();
- + if (doScreenshot)
- + WriteScreenshot(L".png");
- +
- g_Profiler.Frame();
- g_GameRestarted = false;
- }
- Index: source/network/NetTurnManager.h
- ===================================================================
- --- source/network/NetTurnManager.h (revision 17965)
- +++ source/network/NetTurnManager.h (working copy)
- @@ -143,10 +143,11 @@ public:
- void QuickSave();
- void QuickLoad();
- u32 GetCurrentTurn() { return m_CurrentTurn; }
- + u32 GetCurrentTurnLength() { return m_TurnLength; }
- protected:
- /**
- * Store a command to be executed at a given turn.
- */
- Index: source/ps/Game.cpp
- ===================================================================
- --- source/ps/Game.cpp (revision 17965)
- +++ source/ps/Game.cpp (working copy)
- @@ -357,21 +357,26 @@ void CGame::StartGame(JS::MutableHandleV
- m_ReplayLogger->StartGame(attribs);
- RegisterInit(attribs, savedState);
- }
- +int CGame::SimTime()
- +{
- + return GetTurnManager()->GetCurrentTurn() * GetTurnManager()->GetCurrentTurnLength();
- +}
- +
- // TODO: doInterpolate is optional because Atlas interpolates explicitly,
- // so that it has more control over the update rate. The game might want to
- // do the same, and then doInterpolate should be redundant and removed.
- void CGame::Update(const double deltaRealTime, bool doInterpolate)
- {
- if (m_Paused || !m_TurnManager)
- return;
- const double deltaSimTime = deltaRealTime * m_SimRate;
- -
- +
- if (deltaSimTime)
- {
- // To avoid confusing the profiler, we need to trigger the new turn
- // while we're not nested inside any PROFILE blocks
- if (m_TurnManager->WillUpdate(deltaSimTime))
- Index: source/ps/Game.h
- ===================================================================
- --- source/ps/Game.h (revision 17965)
- +++ source/ps/Game.h (working copy)
- @@ -159,10 +159,12 @@ public:
- { if (isfinite(simRate)) m_SimRate = std::max(simRate, 0.0f); }
- inline float GetSimRate() const
- { return m_SimRate; }
- + int SimTime();
- +
- /**
- * Replace the current turn manager.
- * This class will take ownership of the pointer.
- */
- void SetTurnManager(CNetTurnManager* turnManager);
- Index: source/ps/GameSetup/GameSetup.cpp
- ===================================================================
- --- source/ps/GameSetup/GameSetup.cpp (revision 17965)
- +++ source/ps/GameSetup/GameSetup.cpp (working copy)
- @@ -492,11 +492,11 @@ static void InitVfs(const CmdLineArgs& a
- g_VFS->Mount(L"l10n/", paths.RData()/"l10n"/"");
- MountMods(paths, GetMods(args, flags));
- // We mount these dirs last as otherwise writing could result in files being placed in a mod's dir.
- - g_VFS->Mount(L"screenshots/", paths.UserData()/"screenshots"/"");
- + g_VFS->Mount(L"screenshots/", OsPath("/media/elexis/b44403ce-95f0-47d5-84c1-f0076850e183/home/packager/svn/screenshots")/"");
- g_VFS->Mount(L"saves/", paths.UserData()/"saves"/"", VFS_MOUNT_WATCH);
- // Mounting with highest priority, so that a mod supplied user.cfg is harmless
- g_VFS->Mount(L"config/", readonlyConfig, 0, (size_t)-1);
- if(readonlyConfig != paths.Config())
- g_VFS->Mount(L"config/", paths.Config(), 0, (size_t)-1);
- Index: source/ps/Util.cpp
- ===================================================================
- --- source/ps/Util.cpp (revision 17965)
- +++ source/ps/Util.cpp (working copy)
- @@ -270,11 +270,11 @@ void WriteScreenshot(const VfsPath& exte
- if (tex_write(&t, filename) == INFO::OK)
- {
- OsPath realPath;
- g_VFS->GetRealPath(filename, realPath);
- - LOGMESSAGERENDER(g_L10n.Translate("Screenshot written to '%s'"), realPath.string8());
- + debug_printf("Screenshot written to '%s'\n", realPath.string8().c_str());
- }
- else
- LOGERROR("Error writing screenshot to '%s'", filename.string8());
- }
- @@ -403,11 +403,11 @@ void WriteBigScreenshot(const VfsPath& e
- if (tex_write(&t, filename) == INFO::OK)
- {
- OsPath realPath;
- g_VFS->GetRealPath(filename, realPath);
- - LOGMESSAGERENDER(g_L10n.Translate("Screenshot written to '%s'"), realPath.string8());
- + debug_printf("Screenshot written to '%s'\n", realPath.string8().c_str());
- }
- else
- LOGERROR("Error writing screenshot to '%s'", filename.string8());
- free(tile_data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement