mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:15:38 +00:00
Bring back the option to not grab mouse. Useful if running in a mouse-controlled GUI debugger.
This commit is contained in:
parent
ce2d521b8f
commit
bcf61331ab
7 changed files with 19 additions and 8 deletions
|
@ -147,6 +147,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
|||
, mEncoding(ToUTF8::WINDOWS_1252)
|
||||
, mEncoder(NULL)
|
||||
, mActivationDistanceOverride(-1)
|
||||
, mGrab(true)
|
||||
|
||||
{
|
||||
std::srand ( std::time(NULL) );
|
||||
|
@ -370,7 +371,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
|
||||
std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string();
|
||||
bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
|
||||
MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists);
|
||||
MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, mGrab);
|
||||
mEnvironment.setInputManager (input);
|
||||
|
||||
MWGui::WindowManager* window = new MWGui::WindowManager(
|
||||
|
|
|
@ -79,6 +79,8 @@ namespace OMW
|
|||
bool mScriptConsoleMode;
|
||||
std::string mStartupScript;
|
||||
int mActivationDistanceOverride;
|
||||
// Grab mouse?
|
||||
bool mGrab;
|
||||
|
||||
Compiler::Extensions mExtensions;
|
||||
Compiler::Context *mScriptContext;
|
||||
|
@ -152,6 +154,8 @@ namespace OMW
|
|||
/// Start as a new game.
|
||||
void setNewGame(bool newGame);
|
||||
|
||||
void setGrabMouse(bool grab) { mGrab = grab; }
|
||||
|
||||
/// Initialise and enter main loop.
|
||||
void go();
|
||||
|
||||
|
|
|
@ -154,6 +154,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
("fallback", bpo::value<FallbackMap>()->default_value(FallbackMap(), "")
|
||||
->multitoken()->composing(), "fallback values")
|
||||
|
||||
("no-grab", "Don't grab mouse cursor")
|
||||
|
||||
("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override");
|
||||
|
||||
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
|
||||
|
@ -184,6 +186,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
if (!run)
|
||||
return false;
|
||||
|
||||
engine.setGrabMouse(!variables.count("no-grab"));
|
||||
|
||||
// Font encoding settings
|
||||
std::string encoding(variables["encoding"].as<std::string>());
|
||||
std::cout << ToUTF8::encodingUsingMessage(encoding) << std::endl;
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace MWInput
|
|||
{
|
||||
InputManager::InputManager(OEngine::Render::OgreRenderer &ogre,
|
||||
OMW::Engine& engine,
|
||||
const std::string& userFile, bool userFileExists)
|
||||
const std::string& userFile, bool userFileExists, bool grab)
|
||||
: mOgre(ogre)
|
||||
, mPlayer(NULL)
|
||||
, mEngine(engine)
|
||||
|
@ -111,7 +111,7 @@ namespace MWInput
|
|||
|
||||
Ogre::RenderWindow* window = ogre.getWindow ();
|
||||
|
||||
mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow(), mOgre.getWindow());
|
||||
mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow(), mOgre.getWindow(), grab);
|
||||
mInputManager->setMouseEventCallback (this);
|
||||
mInputManager->setKeyboardEventCallback (this);
|
||||
mInputManager->setWindowEventCallback(this);
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace MWInput
|
|||
public:
|
||||
InputManager(OEngine::Render::OgreRenderer &_ogre,
|
||||
OMW::Engine& engine,
|
||||
const std::string& userFile, bool userFileExists);
|
||||
const std::string& userFile, bool userFileExists, bool grab);
|
||||
|
||||
virtual ~InputManager();
|
||||
|
||||
|
|
7
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
7
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
|
@ -9,7 +9,7 @@ namespace SFO
|
|||
{
|
||||
/// \brief General purpose wrapper for OGRE applications around SDL's event
|
||||
/// queue, mostly used for handling input-related events.
|
||||
InputWrapper::InputWrapper(SDL_Window* window, Ogre::RenderWindow* ogreWindow) :
|
||||
InputWrapper::InputWrapper(SDL_Window* window, Ogre::RenderWindow* ogreWindow, bool grab) :
|
||||
mSDLWindow(window),
|
||||
mOgreWindow(ogreWindow),
|
||||
mWarpCompensate(false),
|
||||
|
@ -27,7 +27,8 @@ namespace SFO
|
|||
mWindowHasFocus(true),
|
||||
mWantGrab(false),
|
||||
mWantRelative(false),
|
||||
mWantMouseVisible(false)
|
||||
mWantMouseVisible(false),
|
||||
mAllowGrab(grab)
|
||||
{
|
||||
_setupOISKeys();
|
||||
}
|
||||
|
@ -226,7 +227,7 @@ namespace SFO
|
|||
void InputWrapper::updateMouseSettings()
|
||||
{
|
||||
mGrabPointer = mWantGrab && mMouseInWindow && mWindowHasFocus;
|
||||
SDL_SetWindowGrab(mSDLWindow, mGrabPointer ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_SetWindowGrab(mSDLWindow, mGrabPointer && mAllowGrab ? SDL_TRUE : SDL_FALSE);
|
||||
|
||||
SDL_ShowCursor(mWantMouseVisible || !mWindowHasFocus);
|
||||
|
||||
|
|
3
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
3
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
|
@ -16,7 +16,7 @@ namespace SFO
|
|||
class InputWrapper
|
||||
{
|
||||
public:
|
||||
InputWrapper(SDL_Window *window, Ogre::RenderWindow* ogreWindow);
|
||||
InputWrapper(SDL_Window *window, Ogre::RenderWindow* ogreWindow, bool grab);
|
||||
~InputWrapper();
|
||||
|
||||
void setMouseEventCallback(MouseListener* listen) { mMouseListener = listen; }
|
||||
|
@ -62,6 +62,7 @@ namespace SFO
|
|||
bool mWarpCompensate;
|
||||
bool mWrapPointer;
|
||||
|
||||
bool mAllowGrab;
|
||||
bool mWantMouseVisible;
|
||||
bool mWantGrab;
|
||||
bool mWantRelative;
|
||||
|
|
Loading…
Reference in a new issue