mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
get rid of special key for 360 screenshot
This commit is contained in:
parent
1f49612ca3
commit
525f8b4d8e
@ -249,9 +249,6 @@ namespace MWInput
|
||||
case A_Screenshot:
|
||||
screenshot();
|
||||
break;
|
||||
case A_Screenshot360:
|
||||
screenshot360();
|
||||
break;
|
||||
case A_Inventory:
|
||||
toggleInventory ();
|
||||
break;
|
||||
@ -1020,17 +1017,31 @@ namespace MWInput
|
||||
|
||||
void InputManager::screenshot()
|
||||
{
|
||||
mScreenCaptureHandler->setFramesToCapture(1);
|
||||
mScreenCaptureHandler->captureNextFrame(*mViewer);
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("Screenshot saved");
|
||||
}
|
||||
bool regularScreenshot = true;
|
||||
|
||||
void InputManager::screenshot360()
|
||||
{
|
||||
osg::ref_ptr<osg::Image> screenshot (new osg::Image);
|
||||
if (MWBase::Environment::get().getWorld()->screenshot360(screenshot.get()))
|
||||
(*mScreenCaptureOperation) (*(screenshot.get()),0);
|
||||
// calling mScreenCaptureHandler->getCaptureOperation() here caused segfault for some reason
|
||||
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->captureNextFrame(*mViewer);
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("Screenshot saved");
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::ref_ptr<osg::Image> screenshot (new osg::Image);
|
||||
|
||||
if (MWBase::Environment::get().getWorld()->screenshot360(screenshot.get()))
|
||||
(*mScreenCaptureOperation) (*(screenshot.get()),0);
|
||||
}
|
||||
}
|
||||
|
||||
void InputManager::toggleInventory()
|
||||
@ -1216,7 +1227,6 @@ namespace MWInput
|
||||
defaultKeyBindings[A_QuickKey9] = SDL_SCANCODE_9;
|
||||
defaultKeyBindings[A_QuickKey10] = SDL_SCANCODE_0;
|
||||
defaultKeyBindings[A_Screenshot] = SDL_SCANCODE_F12;
|
||||
defaultKeyBindings[A_Screenshot360] = SDL_SCANCODE_F8;
|
||||
defaultKeyBindings[A_ToggleHUD] = SDL_SCANCODE_F11;
|
||||
defaultKeyBindings[A_ToggleDebug] = SDL_SCANCODE_F10;
|
||||
defaultKeyBindings[A_AlwaysRun] = SDL_SCANCODE_CAPSLOCK;
|
||||
@ -1352,9 +1362,6 @@ namespace MWInput
|
||||
if (action == A_Screenshot)
|
||||
return "Screenshot";
|
||||
|
||||
if (action == A_Screenshot360)
|
||||
return "Screenshot 360";
|
||||
|
||||
descriptions[A_Use] = "sUse";
|
||||
descriptions[A_Activate] = "sActivate";
|
||||
descriptions[A_MoveBackward] = "sBack";
|
||||
@ -1516,7 +1523,6 @@ namespace MWInput
|
||||
ret.push_back(A_QuickSave);
|
||||
ret.push_back(A_QuickLoad);
|
||||
ret.push_back(A_Screenshot);
|
||||
ret.push_back(A_Screenshot360);
|
||||
ret.push_back(A_QuickKeysMenu);
|
||||
ret.push_back(A_QuickKey1);
|
||||
ret.push_back(A_QuickKey2);
|
||||
@ -1548,7 +1554,6 @@ namespace MWInput
|
||||
ret.push_back(A_QuickSave);
|
||||
ret.push_back(A_QuickLoad);
|
||||
ret.push_back(A_Screenshot);
|
||||
ret.push_back(A_Screenshot360);
|
||||
ret.push_back(A_QuickKeysMenu);
|
||||
ret.push_back(A_QuickKey1);
|
||||
ret.push_back(A_QuickKey2);
|
||||
|
@ -229,7 +229,6 @@ namespace MWInput
|
||||
void toggleInventory();
|
||||
void toggleConsole();
|
||||
void screenshot();
|
||||
void screenshot360();
|
||||
void toggleJournal();
|
||||
void activate();
|
||||
void toggleWalking();
|
||||
|
@ -41,6 +41,8 @@
|
||||
#include <components/esm/loadcell.hpp>
|
||||
#include <components/fallback/fallback.hpp>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
|
||||
#include "sky.hpp"
|
||||
@ -773,19 +775,62 @@ namespace MWRender
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
int screenshotHeight = Settings::Manager::tryGetInt("s360 height","Video",mViewer->getCamera()->getViewport()->height());
|
||||
SphericalScreenshot::SphericalScreenshotMapping mapping = static_cast<SphericalScreenshot::SphericalScreenshotMapping>(
|
||||
Settings::Manager::tryGetInt("s360 mapping","Video",SphericalScreenshot::MAPPING_SPHERICAL));
|
||||
int cubeWidth = Settings::Manager::tryGetInt("s360 cubemap size","Video",screenshotWidth / 2);
|
||||
if (mCamera->isVanityOrPreviewModeEnabled())
|
||||
{
|
||||
std::cerr << "Spherical screenshots are not allowed in preview mode." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mapping == SphericalScreenshot::MAPPING_CUBEMAP)
|
||||
screenshotWidth = cubeWidth * 6; // the image will consist of 6 cube sides in a row
|
||||
if (screenshotMapping == SphericalScreenshot::MAPPING_CUBEMAP)
|
||||
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(0,0,-1),
|
||||
@ -797,20 +842,20 @@ namespace MWRender
|
||||
};
|
||||
|
||||
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();
|
||||
|
||||
if (mCamera->isFirstPerson())
|
||||
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);
|
||||
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);
|
||||
mFieldOfView = fovBackup;
|
||||
|
Loading…
x
Reference in New Issue
Block a user