From a1072de6706b4750ae419e854eb98463a92bdb94 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Thu, 19 May 2016 11:10:50 -0400 Subject: [PATCH] Don't hardcode screenshot directory (still hardcodes filename) Signed-off-by: Rob Crittenden --- rwgame/RWGame.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index e7e6f37c..834b05dc 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -794,9 +794,18 @@ void RWGame::globalKeyEvent(const sf::Event& event) case sf::Keyboard::F3: showDebugPhysics = ! showDebugPhysics; break; - case sf::Keyboard::F12: - window.capture().saveToFile("/home/dan/screenshot.png"); + case sf::Keyboard::F12: { + auto homedir = getenv("HOME"); + if( homedir == nullptr ) { + std::cerr << "Unable to determine home directory for screenshot" << std::endl; + break; + } + + std::string savePath(homedir); + std::string path = savePath+"/screenshot.png"; + window.capture().saveToFile(path); break; + } default: break; } }