Add screenshot location logging w/ rendered console message. Rendered messages are hidden before screenshot is taken. Fixes #675
This was SVN commit r8675.
This commit is contained in:
parent
e7b859b8a5
commit
2963422173
@ -150,7 +150,7 @@ static std::string ToHTML(const wchar_t* message)
|
|||||||
return cmessage;
|
return cmessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogger::WriteMessage(const wchar_t* message)
|
void CLogger::WriteMessage(const wchar_t* message, bool doRender = false)
|
||||||
{
|
{
|
||||||
std::string cmessage = ToHTML(message);
|
std::string cmessage = ToHTML(message);
|
||||||
|
|
||||||
@ -163,8 +163,12 @@ void CLogger::WriteMessage(const wchar_t* message)
|
|||||||
*m_MainLog << "<p>" << cmessage << "</p>\n";
|
*m_MainLog << "<p>" << cmessage << "</p>\n";
|
||||||
m_MainLog->flush();
|
m_MainLog->flush();
|
||||||
|
|
||||||
// Don't do this since it results in too much noise:
|
if (doRender)
|
||||||
// PushRenderMessage(Normal, message);
|
{
|
||||||
|
if (g_Console) g_Console->InsertMessage(L"INFO: %ls", message);
|
||||||
|
|
||||||
|
PushRenderMessage(Normal, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogger::WriteError(const wchar_t* message)
|
void CLogger::WriteError(const wchar_t* message)
|
||||||
@ -254,6 +258,22 @@ void CLogger::LogMessage(const wchar_t* fmt, ...)
|
|||||||
WriteMessage(buffer);
|
WriteMessage(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CLogger::LogMessageRender(const wchar_t* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list argp;
|
||||||
|
wchar_t buffer[BUFFER_SIZE] = {0};
|
||||||
|
|
||||||
|
va_start(argp, fmt);
|
||||||
|
if (sys_vswprintf(buffer, ARRAY_SIZE(buffer), fmt, argp) == -1)
|
||||||
|
{
|
||||||
|
// Buffer too small - ensure the string is nicely terminated
|
||||||
|
wcscpy_s(buffer+ARRAY_SIZE(buffer)-4, 4, L"...");
|
||||||
|
}
|
||||||
|
va_end(argp);
|
||||||
|
|
||||||
|
WriteMessage(buffer, true);
|
||||||
|
}
|
||||||
|
|
||||||
void CLogger::LogWarning(const wchar_t* fmt, ...)
|
void CLogger::LogWarning(const wchar_t* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list argp;
|
va_list argp;
|
||||||
|
@ -34,6 +34,7 @@ extern CLogger* g_Logger;
|
|||||||
// from all of the files. LOG_INFO, LOG_WARNING and LOG_ERROR are currently existing macros.
|
// from all of the files. LOG_INFO, LOG_WARNING and LOG_ERROR are currently existing macros.
|
||||||
|
|
||||||
#define LOGMESSAGE g_Logger->LogMessage
|
#define LOGMESSAGE g_Logger->LogMessage
|
||||||
|
#define LOGMESSAGERENDER g_Logger->LogMessageRender
|
||||||
#define LOGWARNING g_Logger->LogWarning
|
#define LOGWARNING g_Logger->LogWarning
|
||||||
#define LOGERROR g_Logger->LogError
|
#define LOGERROR g_Logger->LogError
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ public:
|
|||||||
|
|
||||||
// Functions to write different message types (Errors and warnings are placed
|
// Functions to write different message types (Errors and warnings are placed
|
||||||
// both in mainLog and intrestingLog.)
|
// both in mainLog and intrestingLog.)
|
||||||
void WriteMessage(const wchar_t* message);
|
void WriteMessage(const wchar_t* message, bool doRender);
|
||||||
void WriteError (const wchar_t* message);
|
void WriteError (const wchar_t* message);
|
||||||
void WriteWarning(const wchar_t* message);
|
void WriteWarning(const wchar_t* message);
|
||||||
|
|
||||||
@ -77,6 +78,7 @@ public:
|
|||||||
|
|
||||||
// Functions to write a message, warning or error to file.
|
// Functions to write a message, warning or error to file.
|
||||||
void LogMessage(const wchar_t* fmt, ...) WPRINTF_ARGS(2);
|
void LogMessage(const wchar_t* fmt, ...) WPRINTF_ARGS(2);
|
||||||
|
void LogMessageRender(const wchar_t* fmt, ...) WPRINTF_ARGS(2);
|
||||||
void LogWarning(const wchar_t* fmt, ...) WPRINTF_ARGS(2);
|
void LogWarning(const wchar_t* fmt, ...) WPRINTF_ARGS(2);
|
||||||
void LogError(const wchar_t* fmt, ...) WPRINTF_ARGS(2);
|
void LogError(const wchar_t* fmt, ...) WPRINTF_ARGS(2);
|
||||||
|
|
||||||
|
@ -113,6 +113,7 @@ ERROR_TYPE(System, RequiredExtensionsMissing);
|
|||||||
#define LOG_CATEGORY L"gamesetup"
|
#define LOG_CATEGORY L"gamesetup"
|
||||||
|
|
||||||
bool g_DoRenderGui = true;
|
bool g_DoRenderGui = true;
|
||||||
|
bool g_DoRenderLogger = true;
|
||||||
|
|
||||||
static const int SANE_TEX_QUALITY_DEFAULT = 5; // keep in sync with code
|
static const int SANE_TEX_QUALITY_DEFAULT = 5; // keep in sync with code
|
||||||
|
|
||||||
@ -258,7 +259,7 @@ void Render()
|
|||||||
ogl_WarnIfError();
|
ogl_WarnIfError();
|
||||||
|
|
||||||
PROFILE_START("render logger");
|
PROFILE_START("render logger");
|
||||||
g_Logger->Render();
|
if(g_DoRenderLogger) g_Logger->Render();
|
||||||
PROFILE_END("render logger");
|
PROFILE_END("render logger");
|
||||||
|
|
||||||
ogl_WarnIfError();
|
ogl_WarnIfError();
|
||||||
@ -734,7 +735,7 @@ void EarlyInit()
|
|||||||
|
|
||||||
static bool Autostart(const CmdLineArgs& args);
|
static bool Autostart(const CmdLineArgs& args);
|
||||||
|
|
||||||
void Init(const CmdLineArgs& args, int flags)
|
void Init(const CmdLineArgs& args, int UNUSED(flags))
|
||||||
{
|
{
|
||||||
h_mgr_init();
|
h_mgr_init();
|
||||||
|
|
||||||
@ -878,6 +879,10 @@ void RenderGui(bool RenderingState)
|
|||||||
g_DoRenderGui = RenderingState;
|
g_DoRenderGui = RenderingState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderLogger(bool RenderingState)
|
||||||
|
{
|
||||||
|
g_DoRenderLogger = RenderingState;
|
||||||
|
}
|
||||||
|
|
||||||
static bool Autostart(const CmdLineArgs& args)
|
static bool Autostart(const CmdLineArgs& args)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ enum InitFlags
|
|||||||
* enable/disable rendering of the GUI (intended mainly for screenshots)
|
* enable/disable rendering of the GUI (intended mainly for screenshots)
|
||||||
*/
|
*/
|
||||||
extern void RenderGui(bool RenderingState);
|
extern void RenderGui(bool RenderingState);
|
||||||
|
extern void RenderLogger(bool RenderingState);
|
||||||
|
|
||||||
class CmdLineArgs;
|
class CmdLineArgs;
|
||||||
extern void Init(const CmdLineArgs& args, int flags);
|
extern void Init(const CmdLineArgs& args, int flags);
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "ps/GameSetup/Config.h"
|
#include "ps/GameSetup/Config.h"
|
||||||
#include "ps/GameSetup/GameSetup.h"
|
#include "ps/GameSetup/GameSetup.h"
|
||||||
#include "ps/Game.h"
|
#include "ps/Game.h"
|
||||||
|
#include "ps/CLogger.h"
|
||||||
#include "ps/Filesystem.h"
|
#include "ps/Filesystem.h"
|
||||||
#include "ps/VideoMode.h"
|
#include "ps/VideoMode.h"
|
||||||
#include "renderer/Renderer.h"
|
#include "renderer/Renderer.h"
|
||||||
@ -243,6 +244,11 @@ void WriteScreenshot(const std::wstring& extension)
|
|||||||
flags |= TEX_BGR;
|
flags |= TEX_BGR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide log messages and re-render
|
||||||
|
RenderLogger(false);
|
||||||
|
Render();
|
||||||
|
RenderLogger(true);
|
||||||
|
|
||||||
const size_t img_size = w * h * bpp/8;
|
const size_t img_size = w * h * bpp/8;
|
||||||
const size_t hdr_size = tex_hdr_size(filename);
|
const size_t hdr_size = tex_hdr_size(filename);
|
||||||
shared_ptr<u8> buf = io_Allocate(hdr_size+img_size);
|
shared_ptr<u8> buf = io_Allocate(hdr_size+img_size);
|
||||||
@ -251,7 +257,16 @@ void WriteScreenshot(const std::wstring& extension)
|
|||||||
if(tex_wrap(w, h, bpp, flags, buf, hdr_size, &t) < 0)
|
if(tex_wrap(w, h, bpp, flags, buf, hdr_size, &t) < 0)
|
||||||
return;
|
return;
|
||||||
glReadPixels(0, 0, (GLsizei)w, (GLsizei)h, fmt, GL_UNSIGNED_BYTE, img);
|
glReadPixels(0, 0, (GLsizei)w, (GLsizei)h, fmt, GL_UNSIGNED_BYTE, img);
|
||||||
(void)tex_write(&t, filename);
|
|
||||||
|
if (tex_write(&t, filename) == INFO::OK)
|
||||||
|
{
|
||||||
|
fs::wpath realPath;
|
||||||
|
g_VFS->GetRealPath(filename, realPath);
|
||||||
|
LOGMESSAGERENDER(L"Screenshot written to '%ls'", realPath.string().c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LOGERROR(L"Error writing screenshot to '%ls'", filename.string().c_str());
|
||||||
|
|
||||||
tex_free(&t);
|
tex_free(&t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,9 +350,11 @@ void WriteBigScreenshot(const std::wstring& extension, int tiles)
|
|||||||
// Adjust the camera to render the appropriate region
|
// Adjust the camera to render the appropriate region
|
||||||
g_Game->GetView()->GetCamera()->SetProjectionTile(tiles, tile_x, tile_y);
|
g_Game->GetView()->GetCamera()->SetProjectionTile(tiles, tile_x, tile_y);
|
||||||
|
|
||||||
|
RenderLogger(false);
|
||||||
RenderGui(false);
|
RenderGui(false);
|
||||||
Render();
|
Render();
|
||||||
RenderGui(true);
|
RenderGui(true);
|
||||||
|
RenderLogger(true);
|
||||||
|
|
||||||
// Copy the tile pixels into the main image
|
// Copy the tile pixels into the main image
|
||||||
glReadPixels(0, 0, tile_w, tile_h, fmt, GL_UNSIGNED_BYTE, tile_data);
|
glReadPixels(0, 0, tile_w, tile_h, fmt, GL_UNSIGNED_BYTE, tile_data);
|
||||||
@ -367,7 +384,15 @@ void WriteBigScreenshot(const std::wstring& extension, int tiles)
|
|||||||
g_Game->GetView()->GetCamera()->SetProjectionTile(1, 0, 0);
|
g_Game->GetView()->GetCamera()->SetProjectionTile(1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tex_write(&t, filename);
|
if (tex_write(&t, filename) == INFO::OK)
|
||||||
|
{
|
||||||
|
fs::wpath realPath;
|
||||||
|
g_VFS->GetRealPath(filename, realPath);
|
||||||
|
LOGMESSAGERENDER(L"Screenshot written to '%ls'", realPath.string().c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LOGERROR(L"Error writing screenshot to '%ls'", filename.string().c_str());
|
||||||
|
|
||||||
tex_free(&t);
|
tex_free(&t);
|
||||||
free(tile_data);
|
free(tile_data);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user