forked from Mirrors/openclonk
Added message board command: /screenshot zoom
Creates a whole map screenshot at given zoom level. Use carefully; files can become pretty large!stable-5.4
parent
e1b972f960
commit
e31a207330
|
@ -2690,8 +2690,8 @@ bool C4Game::InitKeyboard()
|
|||
|
||||
// globals
|
||||
KeyboardInput.RegisterKey(new C4CustomKey(C4KeyCodeEx(K_F3 ), "MusicToggle", C4KeyScope(KEYSCOPE_Generic | KEYSCOPE_Gui), new C4KeyCB <C4MusicSystem> (Application.MusicSystem, &C4MusicSystem::ToggleOnOff)));
|
||||
KeyboardInput.RegisterKey(new C4CustomKey(C4KeyCodeEx(K_F9 ), "Screenshot", C4KeyScope(KEYSCOPE_Fullscreen | KEYSCOPE_Gui), new C4KeyCBEx<C4GraphicsSystem, bool>(GraphicsSystem, false, &C4GraphicsSystem::SaveScreenshot)));
|
||||
KeyboardInput.RegisterKey(new C4CustomKey(C4KeyCodeEx(K_F9, KEYS_Control), "ScreenshotEx", KEYSCOPE_Fullscreen, new C4KeyCBEx<C4GraphicsSystem, bool>(GraphicsSystem, true, &C4GraphicsSystem::SaveScreenshot)));
|
||||
KeyboardInput.RegisterKey(new C4CustomKey(C4KeyCodeEx(K_F9 ), "Screenshot", C4KeyScope(KEYSCOPE_Fullscreen | KEYSCOPE_Gui), new C4KeyCBEx<C4GraphicsSystem, bool>(GraphicsSystem, false, &C4GraphicsSystem::SaveScreenshotKey)));
|
||||
KeyboardInput.RegisterKey(new C4CustomKey(C4KeyCodeEx(K_F9, KEYS_Control), "ScreenshotEx", KEYSCOPE_Fullscreen, new C4KeyCBEx<C4GraphicsSystem, bool>(GraphicsSystem, true, &C4GraphicsSystem::SaveScreenshotKey)));
|
||||
KeyboardInput.RegisterKey(new C4CustomKey(C4KeyCodeEx(K_C, KEYS_Alt), "ToggleChat", C4KeyScope(KEYSCOPE_Generic | KEYSCOPE_Gui), new C4KeyCB <C4Game> (*this, &C4Game::ToggleChat)));
|
||||
|
||||
// main ingame
|
||||
|
|
|
@ -215,7 +215,7 @@ void C4GraphicsSystem::EnableLoaderDrawing()
|
|||
if (pLoaderScreen) pLoaderScreen->SetBlackScreen(false);
|
||||
}
|
||||
|
||||
bool C4GraphicsSystem::SaveScreenshot(bool fSaveAll)
|
||||
bool C4GraphicsSystem::SaveScreenshot(bool fSaveAll, float fSaveAllZoom)
|
||||
{
|
||||
// Filename
|
||||
char szFilename[_MAX_PATH+1];
|
||||
|
@ -224,7 +224,7 @@ bool C4GraphicsSystem::SaveScreenshot(bool fSaveAll)
|
|||
do
|
||||
sprintf(szFilename,"Screenshot%03i.png",iScreenshotIndex++);
|
||||
while (FileExists(strFilePath = Config.AtScreenshotPath(szFilename)));
|
||||
bool fSuccess=DoSaveScreenshot(fSaveAll, strFilePath);
|
||||
bool fSuccess=DoSaveScreenshot(fSaveAll, strFilePath, fSaveAllZoom);
|
||||
// log if successful/where it has been stored
|
||||
if (!fSuccess)
|
||||
LogF(LoadResStr("IDS_PRC_SCREENSHOTERROR"), Config.AtUserDataRelativePath(Config.AtScreenshotPath(szFilename)));
|
||||
|
@ -234,7 +234,7 @@ bool C4GraphicsSystem::SaveScreenshot(bool fSaveAll)
|
|||
return !!fSuccess;
|
||||
}
|
||||
|
||||
bool C4GraphicsSystem::DoSaveScreenshot(bool fSaveAll, const char *szFilename)
|
||||
bool C4GraphicsSystem::DoSaveScreenshot(bool fSaveAll, const char *szFilename, float fSaveAllZoom)
|
||||
{
|
||||
// Fullscreen only
|
||||
if (Application.isEditor) return false;
|
||||
|
@ -245,7 +245,7 @@ bool C4GraphicsSystem::DoSaveScreenshot(bool fSaveAll, const char *szFilename)
|
|||
if (fSaveAll)
|
||||
{
|
||||
// Create full map screenshots at zoom 2x. Fractional zooms (like 1.7x) should work but might cause some trouble at screen borders.
|
||||
float zoom = 2.0f;
|
||||
float zoom = fSaveAllZoom;
|
||||
// get viewport to draw in
|
||||
C4Viewport *pVP=::Viewports.GetFirstViewport(); if (!pVP) return false;
|
||||
// create image large enough to hold the landcape
|
||||
|
|
|
@ -58,8 +58,9 @@ public:
|
|||
bool Init();
|
||||
bool InitLoaderScreen(const char *szLoaderSpec);
|
||||
void EnableLoaderDrawing(); // reset black screen loader flag
|
||||
bool SaveScreenshot(bool fSaveAll);
|
||||
bool DoSaveScreenshot(bool fSaveAll, const char *szFilename);
|
||||
bool SaveScreenshotKey(bool fSaveAll) { return SaveScreenshot(fSaveAll, 2.0f); } // keyboard callback for creating screenshot. create at default zoom.
|
||||
bool SaveScreenshot(bool fSaveAll, float fSaveAllZoom);
|
||||
bool DoSaveScreenshot(bool fSaveAll, const char *szFilename, float fSaveAllZoom);
|
||||
inline void InvalidateBg() { iRedrawBackground=2; }
|
||||
inline void OverwriteBg() { InvalidateBg(); }
|
||||
protected:
|
||||
|
|
|
@ -774,6 +774,15 @@ bool C4MessageInput::ProcessCommand(const char *szCommand)
|
|||
if (SEqual(szCmdName, "chart"))
|
||||
return Game.ToggleChart();
|
||||
|
||||
// whole map screenshot
|
||||
if (SEqual(szCmdName, "screenshot"))
|
||||
{
|
||||
double zoom = atof(pCmdPar);
|
||||
if (zoom<=0) return false;
|
||||
::GraphicsSystem.SaveScreenshot(true, zoom);
|
||||
return true;
|
||||
}
|
||||
|
||||
// custom command
|
||||
C4MessageBoardCommand *pCmd;
|
||||
if (Game.IsRunning)
|
||||
|
|
Loading…
Reference in New Issue