F1 toggles fullscreen, F2 toggles mouse cursor grabbing
git-svn-id: svn://anubis/anaglym/trunk@113 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
66e8b9c015
commit
f8e918526e
25
Engine.cc
25
Engine.cc
@ -2,6 +2,7 @@
|
||||
#include "ag.h"
|
||||
#include "anaglym.h"
|
||||
#include "Engine.h"
|
||||
#include "Video.h"
|
||||
#include "sdl_keymap.h"
|
||||
#include <lua.hpp>
|
||||
#include <stdlib.h> /* exit() */
|
||||
@ -24,7 +25,8 @@ Engine * g_engine;
|
||||
|
||||
SDL_Event Engine::userEvent;
|
||||
|
||||
Engine::Engine(const string & path)
|
||||
Engine::Engine(const string & path, Video & video)
|
||||
: m_video(video)
|
||||
{
|
||||
m_next_object_index = 1;
|
||||
m_eye[0] = 0;
|
||||
@ -312,11 +314,26 @@ void Engine::run()
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_KEYDOWN:
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE)
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
goto RET;
|
||||
case SDLK_ESCAPE:
|
||||
goto RET;
|
||||
case SDLK_F1:
|
||||
m_video.toggleFullScreen();
|
||||
break;
|
||||
case SDLK_F2:
|
||||
SDL_ShowCursor(
|
||||
SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE
|
||||
? SDL_DISABLE
|
||||
: SDL_ENABLE);
|
||||
SDL_WM_GrabInput(
|
||||
SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON
|
||||
? SDL_GRAB_OFF
|
||||
: SDL_GRAB_ON);
|
||||
break;
|
||||
default:
|
||||
key_down_event(event.key.keysym.sym);
|
||||
}
|
||||
key_down_event(event.key.keysym.sym);
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
key_up_event(event.key.keysym.sym);
|
||||
|
4
Engine.h
4
Engine.h
@ -9,6 +9,7 @@
|
||||
#include "OdeWorld/OdeWorld.h"
|
||||
#include "TextureCache/TextureCache.h"
|
||||
#include "wfobj/WFObj.h"
|
||||
#include "Video.h"
|
||||
|
||||
class Engine
|
||||
{
|
||||
@ -78,7 +79,7 @@ class Engine
|
||||
Engine * m_engine;
|
||||
};
|
||||
|
||||
Engine(const std::string & path);
|
||||
Engine(const std::string & path, Video & video);
|
||||
~Engine();
|
||||
|
||||
std::string locateResource(const std::string & shortname);
|
||||
@ -130,6 +131,7 @@ class Engine
|
||||
void checkForFunctionFull(const std::string & lua_fn_name,
|
||||
const std::string & event_name, bool & presentFlag);
|
||||
|
||||
Video & m_video;
|
||||
TextureCache m_textureCache;
|
||||
EngineFileLoader * m_fileLoader;
|
||||
lua_State * m_luaState;
|
||||
|
1
Video.h
1
Video.h
@ -14,6 +14,7 @@ class Video
|
||||
void stop();
|
||||
int getDefaultWidth() { return m_defaultWidth; }
|
||||
int getDefaultHeight() { return m_defaultHeight; }
|
||||
void toggleFullScreen() { SDL_WM_ToggleFullScreen(m_surface); }
|
||||
|
||||
protected:
|
||||
int m_defaultWidth;
|
||||
|
@ -72,7 +72,7 @@ int main(int argc, char * argv[])
|
||||
Video video;
|
||||
video.start(width, height, fullscreen, grab_input);
|
||||
|
||||
g_engine = new Engine(argv[0]);
|
||||
g_engine = new Engine(argv[0], video);
|
||||
if (g_engine->load(program))
|
||||
g_engine->run();
|
||||
delete g_engine;
|
||||
|
Loading…
x
Reference in New Issue
Block a user