mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Merge commit 'upstream/master'
This commit is contained in:
commit
67227c34ef
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
screenshot*.png
|
||||
*.o
|
||||
*~
|
||||
data
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "input/poller.hpp"
|
||||
#include "boost/bind.hpp"
|
||||
#include "game/mwrender/playerpos.hpp"
|
||||
#include "platform/strings.h"
|
||||
|
||||
namespace MWInput
|
||||
{
|
||||
@ -13,6 +14,8 @@ namespace MWInput
|
||||
{
|
||||
A_Quit, // Exit the program
|
||||
|
||||
A_Screenshot, // Take a screenshot
|
||||
|
||||
A_MoveLeft, // Move player left / right
|
||||
A_MoveRight,
|
||||
A_MoveUp, // Move up / down
|
||||
@ -29,27 +32,45 @@ namespace MWInput
|
||||
// Note: the order here is important. The OISManager must be
|
||||
// initialized before poller and listener.
|
||||
Input::Dispatcher disp;
|
||||
Render::OgreRenderer &ogre;
|
||||
Input::OISManager input;
|
||||
Input::Poller poller;
|
||||
Input::InputListener listener;
|
||||
MWRender::PlayerPos &player;
|
||||
|
||||
// Count screenshots. TODO: We should move this functionality to
|
||||
// OgreRender or somewhere else.
|
||||
int shotCount;
|
||||
|
||||
// Write screenshot to file.
|
||||
void screenshot()
|
||||
{
|
||||
// TODO: add persistent counting so we don't overwrite shots
|
||||
// from previous runs.
|
||||
char buf[50];
|
||||
snprintf(buf,50, "screenshot%d.png", shotCount++);
|
||||
ogre.screenshot(buf);
|
||||
}
|
||||
|
||||
public:
|
||||
MWInputManager(Render::OgreRenderer &ogre,
|
||||
MWInputManager(Render::OgreRenderer &_ogre,
|
||||
MWRender::PlayerPos &_player)
|
||||
: disp(A_LAST),
|
||||
input(ogre),
|
||||
ogre(_ogre),
|
||||
input(_ogre),
|
||||
poller(input),
|
||||
listener(ogre, input, disp),
|
||||
player(_player)
|
||||
listener(_ogre, input, disp),
|
||||
player(_player),
|
||||
shotCount(0)
|
||||
{
|
||||
using namespace Input;
|
||||
using namespace OIS;
|
||||
|
||||
// Bind MW-specific functions
|
||||
disp.funcs.bind(A_Quit,
|
||||
boost::bind(&InputListener::exitNow, &listener),
|
||||
disp.funcs.bind(A_Quit, boost::bind(&InputListener::exitNow, &listener),
|
||||
"Quit program");
|
||||
disp.funcs.bind(A_Screenshot, boost::bind(&MWInputManager::screenshot, this),
|
||||
"Screenshot");
|
||||
|
||||
// Add ourselves as a frame listener, to catch movement keys
|
||||
ogre.getRoot()->addFrameListener(this);
|
||||
@ -60,6 +81,7 @@ namespace MWInput
|
||||
// Key bindings
|
||||
disp.bind(KC_Q, A_Quit);
|
||||
disp.bind(KC_ESCAPE, A_Quit);
|
||||
disp.bind(KC_SYSRQ, A_Screenshot);
|
||||
|
||||
// Key bindings for polled keys
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "nif/node.hpp"
|
||||
#include "nif/data.hpp"
|
||||
#include "nif/property.hpp"
|
||||
#include "platform/strings.h"
|
||||
|
||||
// For warning messages
|
||||
#include <iostream>
|
||||
@ -252,10 +253,6 @@ static void createMaterial(const String &name,
|
||||
// make sure that all materials are given unique names.
|
||||
static String getUniqueName(const String &input)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
static int addon = 0;
|
||||
static char buf[8];
|
||||
snprintf(buf, 8, "_%d", addon++);
|
||||
|
@ -15,6 +15,11 @@ void OgreRenderer::cleanup()
|
||||
mRoot = NULL;
|
||||
}
|
||||
|
||||
void OgreRenderer::screenshot(const std::string &file)
|
||||
{
|
||||
mWindow->writeContentsToFile(file);
|
||||
}
|
||||
|
||||
bool OgreRenderer::configure(bool showConfig,
|
||||
const std::string &pluginCfg,
|
||||
bool _logging)
|
||||
|
@ -42,6 +42,9 @@ namespace Render
|
||||
/// Start the main rendering loop
|
||||
void start() { mRoot->startRendering(); }
|
||||
|
||||
/// Write a screenshot to file
|
||||
void screenshot(const std::string &file);
|
||||
|
||||
/// Get the Root
|
||||
Ogre::Root *getRoot() { return mRoot; }
|
||||
|
||||
|
@ -92,14 +92,6 @@ public:
|
||||
MorroFrameListener mFrameListener;
|
||||
InputListener mInput;
|
||||
|
||||
// Functions called from D during event handling
|
||||
|
||||
// Dump screen contents to file
|
||||
extern "C" void ogre_screenshot(char* filename)
|
||||
{
|
||||
mWindow->writeContentsToFile(filename);
|
||||
}
|
||||
|
||||
// Get current camera orientation, in the form of 'front' and 'up'
|
||||
// vectors.
|
||||
extern "C" void ogre_getCameraOrientation(float *fx, float *fy, float *fz,
|
||||
|
@ -2,8 +2,10 @@
|
||||
#ifndef _STRINGS_WRAPPER_H
|
||||
#define _STRINGS_WRAPPER_H
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#define strcasecmp stricmp
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user