reworked cursor visibility and input grabbed control
git-svn-id: svn://anubis/anaglym/trunk@247 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
e14c2ef56c
commit
4daec02c31
15
Engine.cc
15
Engine.cc
@ -96,6 +96,9 @@ Engine::Engine(const string & path, Video & video)
|
|||||||
m_fileLoader = new EngineFileLoader(this);
|
m_fileLoader = new EngineFileLoader(this);
|
||||||
m_event_time = 0;
|
m_event_time = 0;
|
||||||
m_font = NULL;
|
m_font = NULL;
|
||||||
|
m_engine_cursor_visible = m_video.getCursorVisible();
|
||||||
|
m_script_cursor_visible = false;
|
||||||
|
m_input_grabbed = m_video.getInputGrabbed();
|
||||||
|
|
||||||
size_t pos = path.find_last_of("\\/");
|
size_t pos = path.find_last_of("\\/");
|
||||||
m_engine_path = (pos != string::npos) ? string(path, 0, pos) : ".";
|
m_engine_path = (pos != string::npos) ? string(path, 0, pos) : ".";
|
||||||
@ -826,14 +829,10 @@ void Engine::run()
|
|||||||
m_video.toggleFullScreen();
|
m_video.toggleFullScreen();
|
||||||
break;
|
break;
|
||||||
case SDLK_F2:
|
case SDLK_F2:
|
||||||
SDL_ShowCursor(
|
m_engine_cursor_visible = !m_engine_cursor_visible;
|
||||||
SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE
|
m_input_grabbed = !m_input_grabbed;
|
||||||
? SDL_DISABLE
|
updateCursorVisibility();
|
||||||
: SDL_ENABLE);
|
m_video.setInputGrabbed(m_input_grabbed);
|
||||||
SDL_WM_GrabInput(
|
|
||||||
SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON
|
|
||||||
? SDL_GRAB_OFF
|
|
||||||
: SDL_GRAB_ON);
|
|
||||||
break;
|
break;
|
||||||
case SDLK_F5:
|
case SDLK_F5:
|
||||||
reloadProgram();
|
reloadProgram();
|
||||||
|
8
Engine.h
8
Engine.h
@ -233,8 +233,16 @@ class Engine
|
|||||||
const std::string & event_name, bool & presentFlag);
|
const std::string & event_name, bool & presentFlag);
|
||||||
void reloadProgram();
|
void reloadProgram();
|
||||||
void checkForAllHandlerFunctions();
|
void checkForAllHandlerFunctions();
|
||||||
|
void updateCursorVisibility()
|
||||||
|
{
|
||||||
|
m_video.setCursorVisible(
|
||||||
|
m_engine_cursor_visible || m_script_cursor_visible);
|
||||||
|
}
|
||||||
|
|
||||||
Video & m_video;
|
Video & m_video;
|
||||||
|
bool m_engine_cursor_visible;
|
||||||
|
bool m_script_cursor_visible;
|
||||||
|
bool m_input_grabbed;
|
||||||
TextureCache m_textureCache;
|
TextureCache m_textureCache;
|
||||||
EngineFileLoader * m_fileLoader;
|
EngineFileLoader * m_fileLoader;
|
||||||
lua_State * m_luaState;
|
lua_State * m_luaState;
|
||||||
|
2
Video.cc
2
Video.cc
@ -28,7 +28,6 @@ Video::Video()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_surface = NULL;
|
m_surface = NULL;
|
||||||
m_inputGrabbed = false;
|
|
||||||
m_width = 0;
|
m_width = 0;
|
||||||
m_height = 0;
|
m_height = 0;
|
||||||
}
|
}
|
||||||
@ -59,7 +58,6 @@ void Video::start(int width, int height, bool fullscreen, bool grab_input,
|
|||||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
}
|
}
|
||||||
SDL_WM_SetCaption("Anaglym", "Anaglym");
|
SDL_WM_SetCaption("Anaglym", "Anaglym");
|
||||||
m_inputGrabbed = grab_input;
|
|
||||||
m_fullscreen = fullscreen;
|
m_fullscreen = fullscreen;
|
||||||
m_width = width;
|
m_width = width;
|
||||||
m_height = height;
|
m_height = height;
|
||||||
|
17
Video.h
17
Video.h
@ -18,6 +18,22 @@ class Video
|
|||||||
int getWidth() { return m_width; }
|
int getWidth() { return m_width; }
|
||||||
int getHeight() { return m_height; }
|
int getHeight() { return m_height; }
|
||||||
SDL_Surface * getSurface() { return m_surface; }
|
SDL_Surface * getSurface() { return m_surface; }
|
||||||
|
void setCursorVisible(bool visible)
|
||||||
|
{
|
||||||
|
SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE);
|
||||||
|
}
|
||||||
|
bool getCursorVisible()
|
||||||
|
{
|
||||||
|
return SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE;
|
||||||
|
}
|
||||||
|
void setInputGrabbed(bool grabbed)
|
||||||
|
{
|
||||||
|
SDL_WM_GrabInput(grabbed ? SDL_GRAB_ON : SDL_GRAB_OFF);
|
||||||
|
}
|
||||||
|
bool getInputGrabbed()
|
||||||
|
{
|
||||||
|
return SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_defaultWidth;
|
int m_defaultWidth;
|
||||||
@ -26,7 +42,6 @@ class Video
|
|||||||
int m_height;
|
int m_height;
|
||||||
SDL_Surface * m_surface;
|
SDL_Surface * m_surface;
|
||||||
bool m_fullscreen;
|
bool m_fullscreen;
|
||||||
bool m_inputGrabbed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user