Add feature to save screenshot. Try Right-Alt + PrintScreen
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11452 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
16cd5fed20
commit
bf18201b30
@ -84,6 +84,7 @@ IrrDriver::IrrDriver()
|
|||||||
{
|
{
|
||||||
m_resolution_changing = RES_CHANGE_NONE;
|
m_resolution_changing = RES_CHANGE_NONE;
|
||||||
m_device = createDevice(video::EDT_NULL);
|
m_device = createDevice(video::EDT_NULL);
|
||||||
|
m_request_screenshot = false;
|
||||||
} // IrrDriver
|
} // IrrDriver
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -1601,6 +1602,42 @@ void IrrDriver::update(float dt)
|
|||||||
|
|
||||||
m_video_driver->endScene();
|
m_video_driver->endScene();
|
||||||
|
|
||||||
|
|
||||||
|
if (m_request_screenshot)
|
||||||
|
{
|
||||||
|
m_request_screenshot = false;
|
||||||
|
|
||||||
|
video::IImage* image = m_video_driver->createScreenShot();
|
||||||
|
if (image)
|
||||||
|
{
|
||||||
|
static int screenshot_id = 1;
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
std::string path = StringUtils::insertValues("C:\\Temp\\supertuxkart_%s_%i.png", race_manager->getTrackName().c_str(), screenshot_id++);
|
||||||
|
#else
|
||||||
|
std::string path = StringUtils::insertValues("/tmp/supertuxkart_%s_%i.png", race_manager->getTrackName().c_str(), screenshot_id++);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (irr_driver->getVideoDriver()->writeImageToFile(image, io::path(path.c_str()), 0))
|
||||||
|
{
|
||||||
|
RaceGUIBase* base = World::getWorld()->getRaceGUI();
|
||||||
|
if (base != NULL)
|
||||||
|
{
|
||||||
|
base->addMessage(core::stringw(("Screenshot saved to\n" + path).c_str()), NULL, 2.0f, video::SColor(255,255,255,255), true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RaceGUIBase* base = World::getWorld()->getRaceGUI();
|
||||||
|
if (base != NULL)
|
||||||
|
{
|
||||||
|
base->addMessage(core::stringw(("FAILED saving screenshot to\n" + path + "\n:(").c_str()), NULL, 2.0f, video::SColor(255,255,255,255), true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
image->drop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getPostProcessing()->update(dt);
|
getPostProcessing()->update(dt);
|
||||||
|
|
||||||
// Enable this next print statement to get render information printed
|
// Enable this next print statement to get render information printed
|
||||||
@ -1612,6 +1649,13 @@ void IrrDriver::update(float dt)
|
|||||||
// printRenderStats();
|
// printRenderStats();
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void IrrDriver::requestScreenshot()
|
||||||
|
{
|
||||||
|
m_request_screenshot = true;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Irrlicht Event handler.
|
// Irrlicht Event handler.
|
||||||
bool IrrDriver::OnEvent(const irr::SEvent &event)
|
bool IrrDriver::OnEvent(const irr::SEvent &event)
|
||||||
|
@ -107,6 +107,7 @@ private:
|
|||||||
void applyResolutionSettings();
|
void applyResolutionSettings();
|
||||||
void createListOfVideoModes();
|
void createListOfVideoModes();
|
||||||
|
|
||||||
|
bool m_request_screenshot;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IrrDriver();
|
IrrDriver();
|
||||||
@ -214,6 +215,8 @@ public:
|
|||||||
|
|
||||||
bool supportsSplatting();
|
bool supportsSplatting();
|
||||||
|
|
||||||
|
void requestScreenshot();
|
||||||
|
|
||||||
// --------------------- RTT --------------------
|
// --------------------- RTT --------------------
|
||||||
/**
|
/**
|
||||||
* Class that provides RTT (currently, only when no other 3D rendering
|
* Class that provides RTT (currently, only when no other 3D rendering
|
||||||
|
@ -156,8 +156,16 @@ void InputManager::handleStaticAction(int key, int value)
|
|||||||
kart->flyDown();
|
kart->flyDown();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case KEY_PRINT:
|
||||||
|
irr_driver->requestScreenshot();
|
||||||
|
break;
|
||||||
|
|
||||||
case KEY_F1:
|
case KEY_F1:
|
||||||
if (UserConfigParams::m_artist_debug_mode && world)
|
if (control_is_pressed)
|
||||||
|
{
|
||||||
|
irr_driver->requestScreenshot();
|
||||||
|
}
|
||||||
|
else if (UserConfigParams::m_artist_debug_mode && world)
|
||||||
{
|
{
|
||||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||||
kart->setPowerup(PowerupManager::POWERUP_BUBBLEGUM, 10000);
|
kart->setPowerup(PowerupManager::POWERUP_BUBBLEGUM, 10000);
|
||||||
|
Loading…
Reference in New Issue
Block a user