get rid of special key for 360 screenshot

0.6.3
Miloslav Číž 7 years ago
parent 1f49612ca3
commit 525f8b4d8e

@ -249,9 +249,6 @@ namespace MWInput
case A_Screenshot: case A_Screenshot:
screenshot(); screenshot();
break; break;
case A_Screenshot360:
screenshot360();
break;
case A_Inventory: case A_Inventory:
toggleInventory (); toggleInventory ();
break; break;
@ -1019,18 +1016,32 @@ namespace MWInput
} }
void InputManager::screenshot() void InputManager::screenshot()
{
bool regularScreenshot = true;
try
{
// FIXME: the same string "screenshot type" is queried here AND in renderingmanager.cpp
std::string s = Settings::Manager::getString("screenshot type","Video");
regularScreenshot = s.size() == 0;
}
catch (std::runtime_error)
{
}
if (regularScreenshot)
{ {
mScreenCaptureHandler->setFramesToCapture(1); mScreenCaptureHandler->setFramesToCapture(1);
mScreenCaptureHandler->captureNextFrame(*mViewer); mScreenCaptureHandler->captureNextFrame(*mViewer);
MWBase::Environment::get().getWindowManager()->messageBox("Screenshot saved"); MWBase::Environment::get().getWindowManager()->messageBox("Screenshot saved");
} }
else
void InputManager::screenshot360()
{ {
osg::ref_ptr<osg::Image> screenshot (new osg::Image); osg::ref_ptr<osg::Image> screenshot (new osg::Image);
if (MWBase::Environment::get().getWorld()->screenshot360(screenshot.get())) if (MWBase::Environment::get().getWorld()->screenshot360(screenshot.get()))
(*mScreenCaptureOperation) (*(screenshot.get()),0); (*mScreenCaptureOperation) (*(screenshot.get()),0);
// calling mScreenCaptureHandler->getCaptureOperation() here caused segfault for some reason }
} }
void InputManager::toggleInventory() void InputManager::toggleInventory()
@ -1216,7 +1227,6 @@ namespace MWInput
defaultKeyBindings[A_QuickKey9] = SDL_SCANCODE_9; defaultKeyBindings[A_QuickKey9] = SDL_SCANCODE_9;
defaultKeyBindings[A_QuickKey10] = SDL_SCANCODE_0; defaultKeyBindings[A_QuickKey10] = SDL_SCANCODE_0;
defaultKeyBindings[A_Screenshot] = SDL_SCANCODE_F12; defaultKeyBindings[A_Screenshot] = SDL_SCANCODE_F12;
defaultKeyBindings[A_Screenshot360] = SDL_SCANCODE_F8;
defaultKeyBindings[A_ToggleHUD] = SDL_SCANCODE_F11; defaultKeyBindings[A_ToggleHUD] = SDL_SCANCODE_F11;
defaultKeyBindings[A_ToggleDebug] = SDL_SCANCODE_F10; defaultKeyBindings[A_ToggleDebug] = SDL_SCANCODE_F10;
defaultKeyBindings[A_AlwaysRun] = SDL_SCANCODE_CAPSLOCK; defaultKeyBindings[A_AlwaysRun] = SDL_SCANCODE_CAPSLOCK;
@ -1352,9 +1362,6 @@ namespace MWInput
if (action == A_Screenshot) if (action == A_Screenshot)
return "Screenshot"; return "Screenshot";
if (action == A_Screenshot360)
return "Screenshot 360";
descriptions[A_Use] = "sUse"; descriptions[A_Use] = "sUse";
descriptions[A_Activate] = "sActivate"; descriptions[A_Activate] = "sActivate";
descriptions[A_MoveBackward] = "sBack"; descriptions[A_MoveBackward] = "sBack";
@ -1516,7 +1523,6 @@ namespace MWInput
ret.push_back(A_QuickSave); ret.push_back(A_QuickSave);
ret.push_back(A_QuickLoad); ret.push_back(A_QuickLoad);
ret.push_back(A_Screenshot); ret.push_back(A_Screenshot);
ret.push_back(A_Screenshot360);
ret.push_back(A_QuickKeysMenu); ret.push_back(A_QuickKeysMenu);
ret.push_back(A_QuickKey1); ret.push_back(A_QuickKey1);
ret.push_back(A_QuickKey2); ret.push_back(A_QuickKey2);
@ -1548,7 +1554,6 @@ namespace MWInput
ret.push_back(A_QuickSave); ret.push_back(A_QuickSave);
ret.push_back(A_QuickLoad); ret.push_back(A_QuickLoad);
ret.push_back(A_Screenshot); ret.push_back(A_Screenshot);
ret.push_back(A_Screenshot360);
ret.push_back(A_QuickKeysMenu); ret.push_back(A_QuickKeysMenu);
ret.push_back(A_QuickKey1); ret.push_back(A_QuickKey1);
ret.push_back(A_QuickKey2); ret.push_back(A_QuickKey2);

@ -229,7 +229,6 @@ namespace MWInput
void toggleInventory(); void toggleInventory();
void toggleConsole(); void toggleConsole();
void screenshot(); void screenshot();
void screenshot360();
void toggleJournal(); void toggleJournal();
void activate(); void activate();
void toggleWalking(); void toggleWalking();

@ -41,6 +41,8 @@
#include <components/esm/loadcell.hpp> #include <components/esm/loadcell.hpp>
#include <components/fallback/fallback.hpp> #include <components/fallback/fallback.hpp>
#include <boost/algorithm/string.hpp>
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "sky.hpp" #include "sky.hpp"
@ -773,19 +775,62 @@ namespace MWRender
bool RenderingManager::screenshot360(osg::Image* image) bool RenderingManager::screenshot360(osg::Image* image)
{ {
if (mCamera->isVanityOrPreviewModeEnabled()) int screenshotW = mViewer->getCamera()->getViewport()->width();
int screenshotH = mViewer->getCamera()->getViewport()->height();
SphericalScreenshot::SphericalScreenshotMapping screenshotMapping = SphericalScreenshot::MAPPING_SPHERICAL;
int cubeSize = screenshotW / 2;
try
{
std::string settingStr = Settings::Manager::getString("screenshot type","Video");
std::vector<std::string> settingArgs;
boost::algorithm::split(settingArgs,settingStr,boost::is_any_of(" "));
if (settingArgs.size() > 0)
{
std::string typeStrings[4] = {"spherical","cylindrical","planet","cubemap"};
bool found = false;
for (int i = 0; i < 4; ++i)
if (settingArgs[0].compare(typeStrings[i]) == 0)
{
screenshotMapping = (SphericalScreenshot::SphericalScreenshotMapping) i;
found = true;
break;
}
if (!found)
{
std::cerr << "Wrong screenshot type: " << settingArgs[0] << "." << std::endl;
return false; return false;
}
}
if (settingArgs.size() > 1)
screenshotW = std::min(10000,std::atoi(settingArgs[1].c_str()));
if (settingArgs.size() > 2)
screenshotH = std::min(10000,std::atoi(settingArgs[2].c_str()));
if (settingArgs.size() > 3)
cubeSize = std::min(5000,std::atoi(settingArgs[3].c_str()));
}
catch (std::runtime_error)
{
std::cerr << "Wrong parameters for screenshot type." << std::endl;
return false;
}
int screenshotWidth = Settings::Manager::tryGetInt("s360 width","Video",mViewer->getCamera()->getViewport()->width()); if (mCamera->isVanityOrPreviewModeEnabled())
int screenshotHeight = Settings::Manager::tryGetInt("s360 height","Video",mViewer->getCamera()->getViewport()->height()); {
SphericalScreenshot::SphericalScreenshotMapping mapping = static_cast<SphericalScreenshot::SphericalScreenshotMapping>( std::cerr << "Spherical screenshots are not allowed in preview mode." << std::endl;
Settings::Manager::tryGetInt("s360 mapping","Video",SphericalScreenshot::MAPPING_SPHERICAL)); return false;
int cubeWidth = Settings::Manager::tryGetInt("s360 cubemap size","Video",screenshotWidth / 2); }
if (mapping == SphericalScreenshot::MAPPING_CUBEMAP) if (screenshotMapping == SphericalScreenshot::MAPPING_CUBEMAP)
screenshotWidth = cubeWidth * 6; // the image will consist of 6 cube sides in a row screenshotW = cubeSize * 6; // the image will consist of 6 cube sides in a row
SphericalScreenshot s(cubeWidth); SphericalScreenshot s(cubeSize);
osg::Vec3 directions[6] = { osg::Vec3 directions[6] = {
osg::Vec3(0,0,-1), osg::Vec3(0,0,-1),
@ -797,20 +842,20 @@ namespace MWRender
}; };
double fovBackup = mFieldOfView; double fovBackup = mFieldOfView;
mFieldOfView = 90.0; // each side sees 90 degrees mFieldOfView = 90.0; // each cubemap side sees 90 degrees
int maskBackup = mPlayerAnimation->getObjectRoot()->getNodeMask(); int maskBackup = mPlayerAnimation->getObjectRoot()->getNodeMask();
if (mCamera->isFirstPerson()) if (mCamera->isFirstPerson())
mPlayerAnimation->getObjectRoot()->setNodeMask(0); mPlayerAnimation->getObjectRoot()->setNodeMask(0);
for (int i = 0; i < 6; i++) // for each cube side for (int i = 0; i < 6; i++) // for each cubemap side
{ {
osg::Image *sideImage = s.getImage(i); osg::Image *sideImage = s.getImage(i);
screenshot(sideImage,cubeWidth,cubeWidth,directions[i]); screenshot(sideImage,cubeSize,cubeSize,directions[i]);
} }
s.create(image,screenshotWidth,mapping != SphericalScreenshot::MAPPING_SMALL_PLANET ? screenshotHeight : screenshotWidth,mapping); s.create(image,screenshotW,screenshotMapping != SphericalScreenshot::MAPPING_SMALL_PLANET ? screenshotH : screenshotW,screenshotMapping);
mPlayerAnimation->getObjectRoot()->setNodeMask(maskBackup); mPlayerAnimation->getObjectRoot()->setNodeMask(maskBackup);
mFieldOfView = fovBackup; mFieldOfView = fovBackup;

Loading…
Cancel
Save